@bryanhu/codexly 0.4.0 → 0.5.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 (208) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/README.md +3 -1
  3. package/README.zh-CN.md +3 -1
  4. package/dist/{chunk-I5XCZA2U.js → chunk-4PA52XB7.js} +874 -54
  5. package/dist/{chunk-6W2NSQP6.js → chunk-AGMOIRX4.js} +1 -1
  6. package/dist/{chunk-3OBVX5TN.js → chunk-RNTA4MFS.js} +9 -1
  7. package/dist/{chunk-63TSFHXS.js → chunk-UAJCHOZK.js} +916 -399
  8. package/dist/{chunk-TGDKFWII.js → chunk-ZSWNUDDK.js} +115 -6
  9. package/dist/cli.js +10 -6
  10. package/dist/client/index.js +35 -5
  11. package/dist/core/index.js +1 -1
  12. package/dist/protocol/index.js +1 -1
  13. package/dist/providers/codex/index.js +3 -3
  14. package/dist/server/index.js +5 -5
  15. package/dist/sqlite-state-worker.js +117 -7
  16. package/dist/web/.vite/manifest.json +254 -128
  17. package/dist/web/.vite/manifest.json.br +0 -0
  18. package/dist/web/.vite/manifest.json.gz +0 -0
  19. package/dist/web/assets/button-group-GolVMDRO.js +1 -0
  20. package/dist/web/assets/button-group-GolVMDRO.js.br +0 -0
  21. package/dist/web/assets/button-group-GolVMDRO.js.gz +0 -0
  22. package/dist/web/assets/check-DufG-ZUa.js +1 -0
  23. package/dist/web/assets/check-DufG-ZUa.js.br +0 -0
  24. package/dist/web/assets/check-DufG-ZUa.js.gz +0 -0
  25. package/dist/web/assets/checkbox-37DlWLBa.js +1 -0
  26. package/dist/web/assets/checkbox-37DlWLBa.js.br +0 -0
  27. package/dist/web/assets/checkbox-37DlWLBa.js.gz +0 -0
  28. package/dist/web/assets/{chunk-BO2N2NFS-D3J36g1Z.js → chunk-BO2N2NFS-C9R62W5i.js} +4 -4
  29. package/dist/web/assets/chunk-BO2N2NFS-C9R62W5i.js.br +0 -0
  30. package/dist/web/assets/chunk-BO2N2NFS-C9R62W5i.js.gz +0 -0
  31. package/dist/web/assets/{code-highlighter-Cl_7OKC4.js → code-highlighter-B_sQt157.js} +1 -1
  32. package/dist/web/assets/code-highlighter-B_sQt157.js.br +0 -0
  33. package/dist/web/assets/code-highlighter-B_sQt157.js.gz +0 -0
  34. package/dist/web/assets/{code-languages-CoeGleQS.js → code-languages-lQDTaxNN.js} +1 -1
  35. package/dist/web/assets/code-languages-lQDTaxNN.js.br +0 -0
  36. package/dist/web/assets/code-languages-lQDTaxNN.js.gz +0 -0
  37. package/dist/web/assets/context-menu-Dag_JnAP.js +1 -0
  38. package/dist/web/assets/context-menu-Dag_JnAP.js.br +0 -0
  39. package/dist/web/assets/context-menu-Dag_JnAP.js.gz +0 -0
  40. package/dist/web/assets/dist-D75B5EEW.js +1 -0
  41. package/dist/web/assets/dist-D75B5EEW.js.br +0 -0
  42. package/dist/web/assets/dist-D75B5EEW.js.gz +0 -0
  43. package/dist/web/assets/dist-rI8Y0b5t.js +1 -0
  44. package/dist/web/assets/dist-rI8Y0b5t.js.br +0 -0
  45. package/dist/web/assets/dist-rI8Y0b5t.js.gz +0 -0
  46. package/dist/web/assets/es2015-Bu8fG2VP.js +41 -0
  47. package/dist/web/assets/es2015-Bu8fG2VP.js.br +0 -0
  48. package/dist/web/assets/es2015-Bu8fG2VP.js.gz +0 -0
  49. package/dist/web/assets/file-code-corner-BfUyC-bF.js +1 -0
  50. package/dist/web/assets/file-code-corner-BfUyC-bF.js.br +1 -0
  51. package/dist/web/assets/file-code-corner-BfUyC-bF.js.gz +0 -0
  52. package/dist/web/assets/file-navigation-view-preference-De4_ih3I.js +1 -0
  53. package/dist/web/assets/file-navigation-view-preference-De4_ih3I.js.br +0 -0
  54. package/dist/web/assets/file-navigation-view-preference-De4_ih3I.js.gz +0 -0
  55. package/dist/web/assets/file-review-dialog-D6itznUk.js +2 -0
  56. package/dist/web/assets/file-review-dialog-D6itznUk.js.br +0 -0
  57. package/dist/web/assets/file-review-dialog-D6itznUk.js.gz +0 -0
  58. package/dist/web/assets/file-tree-CFUaXf_b.js +1 -0
  59. package/dist/web/assets/file-tree-CFUaXf_b.js.br +0 -0
  60. package/dist/web/assets/file-tree-CFUaXf_b.js.gz +0 -0
  61. package/dist/web/assets/git-commit-horizontal-BsjVPZ9W.js +1 -0
  62. package/dist/web/assets/git-commit-horizontal-BsjVPZ9W.js.br +0 -0
  63. package/dist/web/assets/git-commit-horizontal-BsjVPZ9W.js.gz +0 -0
  64. package/dist/web/assets/git-history-panel-DIr_4cfP.js +2 -0
  65. package/dist/web/assets/git-history-panel-DIr_4cfP.js.br +0 -0
  66. package/dist/web/assets/git-history-panel-DIr_4cfP.js.gz +0 -0
  67. package/dist/web/assets/global-settings-dialog-CWeXTy89.js +1 -0
  68. package/dist/web/assets/global-settings-dialog-CWeXTy89.js.br +0 -0
  69. package/dist/web/assets/global-settings-dialog-CWeXTy89.js.gz +0 -0
  70. package/dist/web/assets/{highlighted-body-OFNGDK62-DLuRF1Ir.js → highlighted-body-OFNGDK62-J6vd4AIe.js} +1 -1
  71. package/dist/web/assets/highlighted-body-OFNGDK62-J6vd4AIe.js.br +0 -0
  72. package/dist/web/assets/highlighted-body-OFNGDK62-J6vd4AIe.js.gz +0 -0
  73. package/dist/web/assets/index-CMCPev5S.js +4 -0
  74. package/dist/web/assets/index-CMCPev5S.js.br +0 -0
  75. package/dist/web/assets/index-CMCPev5S.js.gz +0 -0
  76. package/dist/web/assets/index-CcSDzrvO.css +2 -0
  77. package/dist/web/assets/index-CcSDzrvO.css.br +0 -0
  78. package/dist/web/assets/index-CcSDzrvO.css.gz +0 -0
  79. package/dist/web/assets/lazy-message-response-kziUJe0I.js +2 -0
  80. package/dist/web/assets/lazy-message-response-kziUJe0I.js.br +0 -0
  81. package/dist/web/assets/lazy-message-response-kziUJe0I.js.gz +0 -0
  82. package/dist/web/assets/loader-circle-DUyazd0N.js +1 -0
  83. package/dist/web/assets/loader-circle-DUyazd0N.js.br +0 -0
  84. package/dist/web/assets/loader-circle-DUyazd0N.js.gz +0 -0
  85. package/dist/web/assets/mermaid-GHXKKRXX-6KIGYUKQ.js +1 -0
  86. package/dist/web/assets/mermaid-GHXKKRXX-6KIGYUKQ.js.br +0 -0
  87. package/dist/web/assets/mermaid-GHXKKRXX-6KIGYUKQ.js.gz +0 -0
  88. package/dist/web/assets/message-response-BH1WLiOG.js +7 -0
  89. package/dist/web/assets/message-response-BH1WLiOG.js.br +0 -0
  90. package/dist/web/assets/message-response-BH1WLiOG.js.gz +0 -0
  91. package/dist/web/assets/{patch-diff-viewer-7Ar-plzV.js → patch-diff-viewer-BP7d9z00.js} +2 -2
  92. package/dist/web/assets/patch-diff-viewer-BP7d9z00.js.br +0 -0
  93. package/dist/web/assets/patch-diff-viewer-BP7d9z00.js.gz +0 -0
  94. package/dist/web/assets/project-file-popup-page-BqEZEv1s.js +1 -0
  95. package/dist/web/assets/project-file-popup-page-BqEZEv1s.js.br +0 -0
  96. package/dist/web/assets/project-file-popup-page-BqEZEv1s.js.gz +0 -0
  97. package/dist/web/assets/project-source-panel-BkRa6eOs.js +3 -0
  98. package/dist/web/assets/project-source-panel-BkRa6eOs.js.br +0 -0
  99. package/dist/web/assets/project-source-panel-BkRa6eOs.js.gz +0 -0
  100. package/dist/web/assets/prompt-input-controls-5tCLhg2X.js +1 -0
  101. package/dist/web/assets/prompt-input-controls-5tCLhg2X.js.br +0 -0
  102. package/dist/web/assets/prompt-input-controls-5tCLhg2X.js.gz +0 -0
  103. package/dist/web/assets/prompt-reference-token-Dnq6GpIQ.js +1 -0
  104. package/dist/web/assets/prompt-reference-token-Dnq6GpIQ.js.br +3 -0
  105. package/dist/web/assets/prompt-reference-token-Dnq6GpIQ.js.gz +0 -0
  106. package/dist/web/assets/provider-connection-queries-BPczkhUT.js +1 -0
  107. package/dist/web/assets/provider-connection-queries-BPczkhUT.js.br +0 -0
  108. package/dist/web/assets/provider-connection-queries-BPczkhUT.js.gz +0 -0
  109. package/dist/web/assets/{shiki-bundle-UDLEjOL9.js → shiki-bundle-VSjMZiOC.js} +1 -1
  110. package/dist/web/assets/shiki-bundle-VSjMZiOC.js.br +0 -0
  111. package/dist/web/assets/shiki-bundle-VSjMZiOC.js.gz +0 -0
  112. package/dist/web/assets/tooltip-jGsHGylL.js +1 -0
  113. package/dist/web/assets/tooltip-jGsHGylL.js.br +0 -0
  114. package/dist/web/assets/tooltip-jGsHGylL.js.gz +0 -0
  115. package/dist/web/assets/upload-D6X3pnK5.js +1 -0
  116. package/dist/web/assets/upload-D6X3pnK5.js.br +0 -0
  117. package/dist/web/assets/upload-D6X3pnK5.js.gz +0 -0
  118. package/dist/web/assets/useInfiniteQuery-Bs3l5hx7.js +1 -0
  119. package/dist/web/assets/useInfiniteQuery-Bs3l5hx7.js.br +0 -0
  120. package/dist/web/assets/useInfiniteQuery-Bs3l5hx7.js.gz +0 -0
  121. package/dist/web/assets/workbench-inspector-changes-BbHDvE9x.js +2 -0
  122. package/dist/web/assets/workbench-inspector-changes-BbHDvE9x.js.br +0 -0
  123. package/dist/web/assets/workbench-inspector-changes-BbHDvE9x.js.gz +0 -0
  124. package/dist/web/assets/workbench-pet-canvas-DRzsdZ1c.js +1 -0
  125. package/dist/web/assets/workbench-pet-canvas-DRzsdZ1c.js.br +0 -0
  126. package/dist/web/assets/workbench-pet-canvas-DRzsdZ1c.js.gz +0 -0
  127. package/dist/web/assets/workbench-shell-wnOOfeVI.js +15 -0
  128. package/dist/web/assets/workbench-shell-wnOOfeVI.js.br +0 -0
  129. package/dist/web/assets/workbench-shell-wnOOfeVI.js.gz +0 -0
  130. package/dist/web/index.html +12 -8
  131. package/dist/web/index.html.br +0 -0
  132. package/dist/web/index.html.gz +0 -0
  133. package/package.json +1 -1
  134. package/dist/web/assets/button-SdoQawHa.js +0 -1
  135. package/dist/web/assets/button-SdoQawHa.js.br +0 -0
  136. package/dist/web/assets/button-SdoQawHa.js.gz +0 -0
  137. package/dist/web/assets/button-group-cIDkfDF9.js +0 -1
  138. package/dist/web/assets/button-group-cIDkfDF9.js.br +0 -0
  139. package/dist/web/assets/button-group-cIDkfDF9.js.gz +0 -0
  140. package/dist/web/assets/checkbox-BlpFo5_d.js +0 -1
  141. package/dist/web/assets/checkbox-BlpFo5_d.js.br +0 -0
  142. package/dist/web/assets/checkbox-BlpFo5_d.js.gz +0 -0
  143. package/dist/web/assets/chunk-BO2N2NFS-D3J36g1Z.js.br +0 -0
  144. package/dist/web/assets/chunk-BO2N2NFS-D3J36g1Z.js.gz +0 -0
  145. package/dist/web/assets/code-highlighter-Cl_7OKC4.js.br +0 -0
  146. package/dist/web/assets/code-highlighter-Cl_7OKC4.js.gz +0 -0
  147. package/dist/web/assets/code-languages-CoeGleQS.js.br +0 -0
  148. package/dist/web/assets/code-languages-CoeGleQS.js.gz +0 -0
  149. package/dist/web/assets/es2015-B-skuqay.js +0 -41
  150. package/dist/web/assets/es2015-B-skuqay.js.br +0 -0
  151. package/dist/web/assets/es2015-B-skuqay.js.gz +0 -0
  152. package/dist/web/assets/file-DwOQ4CRt.js +0 -1
  153. package/dist/web/assets/file-DwOQ4CRt.js.br +0 -0
  154. package/dist/web/assets/file-DwOQ4CRt.js.gz +0 -0
  155. package/dist/web/assets/file-review-dialog-BmXxZad1.js +0 -2
  156. package/dist/web/assets/file-review-dialog-BmXxZad1.js.br +0 -0
  157. package/dist/web/assets/file-review-dialog-BmXxZad1.js.gz +0 -0
  158. package/dist/web/assets/file-tree-Bl6o98td.js +0 -1
  159. package/dist/web/assets/file-tree-Bl6o98td.js.br +0 -0
  160. package/dist/web/assets/file-tree-Bl6o98td.js.gz +0 -0
  161. package/dist/web/assets/git-commit-horizontal-1BtAo1_y.js +0 -1
  162. package/dist/web/assets/git-commit-horizontal-1BtAo1_y.js.br +0 -0
  163. package/dist/web/assets/git-commit-horizontal-1BtAo1_y.js.gz +0 -0
  164. package/dist/web/assets/git-history-panel-zXprGDsD.js +0 -2
  165. package/dist/web/assets/git-history-panel-zXprGDsD.js.br +0 -0
  166. package/dist/web/assets/git-history-panel-zXprGDsD.js.gz +0 -0
  167. package/dist/web/assets/global-settings-dialog-CQK8OvfF.js +0 -1
  168. package/dist/web/assets/global-settings-dialog-CQK8OvfF.js.br +0 -0
  169. package/dist/web/assets/global-settings-dialog-CQK8OvfF.js.gz +0 -0
  170. package/dist/web/assets/highlighted-body-OFNGDK62-DLuRF1Ir.js.br +0 -0
  171. package/dist/web/assets/highlighted-body-OFNGDK62-DLuRF1Ir.js.gz +0 -0
  172. package/dist/web/assets/index-BQDjXTIj.js +0 -4
  173. package/dist/web/assets/index-BQDjXTIj.js.br +0 -0
  174. package/dist/web/assets/index-BQDjXTIj.js.gz +0 -0
  175. package/dist/web/assets/index-Cg_JyLiC.css +0 -2
  176. package/dist/web/assets/index-Cg_JyLiC.css.br +0 -0
  177. package/dist/web/assets/index-Cg_JyLiC.css.gz +0 -0
  178. package/dist/web/assets/lazy-message-response-BAESsr6y.js +0 -2
  179. package/dist/web/assets/lazy-message-response-BAESsr6y.js.br +0 -0
  180. package/dist/web/assets/lazy-message-response-BAESsr6y.js.gz +0 -0
  181. package/dist/web/assets/mermaid-GHXKKRXX-D80VLkUl.js +0 -1
  182. package/dist/web/assets/mermaid-GHXKKRXX-D80VLkUl.js.br +0 -0
  183. package/dist/web/assets/mermaid-GHXKKRXX-D80VLkUl.js.gz +0 -0
  184. package/dist/web/assets/message-response-ll2GyVvz.js +0 -7
  185. package/dist/web/assets/message-response-ll2GyVvz.js.br +0 -0
  186. package/dist/web/assets/message-response-ll2GyVvz.js.gz +0 -0
  187. package/dist/web/assets/patch-diff-viewer-7Ar-plzV.js.br +0 -0
  188. package/dist/web/assets/patch-diff-viewer-7Ar-plzV.js.gz +0 -0
  189. package/dist/web/assets/prompt-input-controls-t69FYoWk.js +0 -1
  190. package/dist/web/assets/prompt-input-controls-t69FYoWk.js.br +0 -0
  191. package/dist/web/assets/prompt-input-controls-t69FYoWk.js.gz +0 -0
  192. package/dist/web/assets/prompt-reference-token-Cxx6C-IR.js +0 -1
  193. package/dist/web/assets/prompt-reference-token-Cxx6C-IR.js.br +0 -0
  194. package/dist/web/assets/prompt-reference-token-Cxx6C-IR.js.gz +0 -0
  195. package/dist/web/assets/provider-connection-queries-BKyJMJn1.js +0 -1
  196. package/dist/web/assets/provider-connection-queries-BKyJMJn1.js.br +0 -0
  197. package/dist/web/assets/provider-connection-queries-BKyJMJn1.js.gz +0 -0
  198. package/dist/web/assets/shiki-bundle-UDLEjOL9.js.br +0 -0
  199. package/dist/web/assets/shiki-bundle-UDLEjOL9.js.gz +0 -0
  200. package/dist/web/assets/upload-Bbk2LEzM.js +0 -1
  201. package/dist/web/assets/upload-Bbk2LEzM.js.br +0 -0
  202. package/dist/web/assets/upload-Bbk2LEzM.js.gz +0 -0
  203. package/dist/web/assets/workbench-inspector-changes-CumCxeA7.js +0 -1
  204. package/dist/web/assets/workbench-inspector-changes-CumCxeA7.js.br +0 -0
  205. package/dist/web/assets/workbench-inspector-changes-CumCxeA7.js.gz +0 -0
  206. package/dist/web/assets/workbench-shell-D21PPmmO.js +0 -13
  207. package/dist/web/assets/workbench-shell-D21PPmmO.js.br +0 -0
  208. package/dist/web/assets/workbench-shell-D21PPmmO.js.gz +0 -0
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/global-settings-dialog-CQK8OvfF.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CVaUQXZF.js","assets/button-SdoQawHa.js","assets/bundle-mjs-rHxsej31.js","assets/es2015-B-skuqay.js","assets/checkbox-BlpFo5_d.js","assets/lazy-message-response-BAESsr6y.js","assets/prompt-input-controls-t69FYoWk.js","assets/provider-connection-queries-BKyJMJn1.js","assets/git-commit-horizontal-1BtAo1_y.js","assets/upload-Bbk2LEzM.js","assets/workbench-shell-D21PPmmO.js","assets/file-tree-Bl6o98td.js","assets/file-DwOQ4CRt.js","assets/file-review-dialog-BmXxZad1.js","assets/file-change-D7aZLgtG.js","assets/button-group-cIDkfDF9.js","assets/code-languages-CoeGleQS.js","assets/prompt-reference-token-Cxx6C-IR.js"])))=>i.map(i=>d[i]);
2
- import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,n as r,r as i,t as a}from"./react-runtime-CVaUQXZF.js";import{_ as o,a as s,b as c,d as l,f as u,g as d,h as f,m as p,n as m,p as h,r as g,s as _,t as v,u as y,v as b,x,y as S}from"./button-SdoQawHa.js";import{$ as C,A as w,At as T,C as E,Ct as D,D as O,E as k,Et as A,M as j,O as M,Ot as N,Q as P,S as F,St as I,T as L,Tt as ee,X as R,Z as z,_t as B,a as V,at as te,b as H,c as U,ct as ne,d as W,dt as re,et as ie,f as ae,g as oe,gt as se,h as ce,ht as G,i as le,it as ue,k as de,kt as fe,l as pe,lt as me,m as he,mt as ge,n as _e,nt as ve,o as ye,ot as be,p as xe,q as Se,r as Ce,rt as we,s as Te,st as Ee,t as De,tt as Oe,u as ke,ut as Ae,v as je,vt as Me,w as Ne,wt as Pe,x as Fe,xt as Ie,y as Le,z as Re}from"./es2015-B-skuqay.js";import{a as ze,c as Be,d as Ve,i as He,l as Ue,n as We,o as Ge,r as Ke,s as qe,t as Je,u as Ye}from"./checkbox-BlpFo5_d.js";import{$ as Xe,B as Ze,F as Qe,G as $e,H as et,I as tt,J as nt,K as rt,L as it,M as at,P as ot,V as st,W as ct,X as lt,Y as ut,Z as dt,_ as ft,d as pt,f as mt,g as ht,h as gt,i as _t,l as vt,m as yt,p as bt,q as xt,s as St,t as Ct,tt as wt,u as Tt,v as Et,x as Dt,z as Ot}from"./file-tree-Bl6o98td.js";import{a as kt,c as At,i as jt,l as Mt,n as Nt,o as Pt,r as Ft,s as It,t as Lt,u as Rt}from"./provider-connection-queries-BKyJMJn1.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var K=e(n(),1),zt=typeof window<`u`?K.useLayoutEffect:K.useEffect;function Bt(e){let t=K.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function Vt(e,t,n={},r={}){K.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function Ht(e){let t=K.useRef(null);return K.useImperativeHandle(e,()=>t.current,[]),t}function Ut(e){return e[e.length-1]}function Wt(e){return typeof e==`function`}function Gt(e,t){return Wt(e)?e(t):e}var Kt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable;function Jt(e){for(let t in e)if(Kt.call(e,t))return!0;return!1}var Yt=()=>Object.create(null),Xt=(e,t)=>Zt(e,t,Yt);function Zt(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=tn(e)&&tn(i);if(!a&&!($t(e)&&$t(i)))return i;let o=a?e:Qt(e);if(!o)return i;let s=a?i:Qt(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:Kt.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=Zt(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function Qt(e){let t=Object.getOwnPropertyNames(e);for(let n of t)if(!qt.call(e,n))return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;let r=t;for(let t of n){if(!qt.call(e,t))return!1;r.push(t)}return r}function $t(e){if(!en(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!en(n)||!n.hasOwnProperty(`isPrototypeOf`))}function en(e){return Object.prototype.toString.call(e)===`[object Object]`}function tn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function nn(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!nn(e[r],t[r],n))return!1;return!0}if($t(e)&&$t(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!nn(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!nn(e[o],t[o],n)))return!1;return i===a}return!1}function rn(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function an(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}var on=/[\x00-\x1f\x7f"<>`{}]/g;function sn(e){return e.replace(on,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function cn(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return sn(t)}var ln=[`http:`,`https:`,`mailto:`,`tel:`];function un(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function dn(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=cn(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=cn(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function fn(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function pn(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function mn(){throw Error(`Invariant failed`)}function hn(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var gn=4,_n=5;function vn(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function yn(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=vn(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function bn(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e,l=n.options?.params?.parse??n.options?.parseParams;for(;s<o;){let e=yn(r,s,t),o,u=s,d=e[5];switch(s=d+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=Cn(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=Cn(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.dynamic?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=wn(1,n.fullPath??n.from,f,p,m);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.optional?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=wn(3,n.fullPath??n.from,f,p,m);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),l=c&&!!(t||s),f=t?l?t:t.toLowerCase():void 0,p=s?l?s:s.toLowerCase():void 0,m=wn(2,n.fullPath??n.from,l,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if(l&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=Cn(n.fullPath??n.from);e.kind=_n,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let u=(n.path||!n.children)&&!n.isRoot;if(u&&r.endsWith(`/`)){let e=Cn(n.fullPath??n.from);e.kind=gn,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=l??null,i.priority=n.options?.params?.priority??0,u&&!i.route&&(i.route=n,i.fullPath=n.fullPath??n.from)}if(n.children)for(let r of n.children)bn(e,t,r,s,i,a,o)}function xn(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function Sn(e){if(e.pathless)for(let t of e.pathless)Sn(t);if(e.static)for(let t of e.static.values())Sn(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())Sn(t);if(e.dynamic?.length){e.dynamic.sort(xn);for(let t of e.dynamic)Sn(t)}if(e.optional?.length){e.optional.sort(xn);for(let t of e.optional)Sn(t)}if(e.wildcard?.length){e.wildcard.sort(xn);for(let t of e.wildcard)Sn(t)}}function Cn(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,priority:0}}function wn(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function Tn(e,t){let n=Cn(`/`),r=new Uint16Array(6);for(let t of e)bn(!1,r,t,1,n,0);Sn(n),t.masksTree=n,t.flatCache=hn(1e3)}function En(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=jn(e,t.masksTree);return t.flatCache.set(e,r),r}function Dn(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=Cn(`/`),bn(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),jn(r,o,n)}function On(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=jn(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=Nn(a.route)),t.matchCache.set(r,a),a}function kn(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function An(e,t=!1,n){let r=Cn(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return bn(t,i,e,1,r,0,e=>{if(n?.(e,s),e.id in a&&mn(),a[e.id]=e,s!==0&&e.path){let t=kn(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),Sn(r),{processedTree:{segmentTree:r,singleCache:hn(1e3),matchCache:hn(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function jn(e,t,n=!1){let r=e.split(`/`),i=Fn(e,r,t,n);if(!i)return null;let[a]=Mn(e,r,i);return{route:i.node.route,rawParams:a}}function Mn(e,t,n){let r=Pn(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===gn)break;if(u.kind===_n){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function Nn(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Pn(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function Fn(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!Ut(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,depth:1,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,depth:f,statics:p,dynamics:m,optionals:h}=n,{extract:g,rawParams:_}=n;if(i.kind===2&&i.route&&!zn(l,n))continue;if(i.parse){if(!Rn(e,t,n))continue;_=n.rawParams,g=n.extract}r&&i.route&&i.kind!==gn&&zn(c,n)&&(c=n);let v=u===o;if(v&&(i.route&&(!a||i.kind===gn||i.kind===2)&&zn(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let y=v?void 0:t[u],b;if(v&&i.index){let n={node:i.index,index:u,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_},r=!0;if(i.index.parse&&(Rn(e,t,n)||(r=!1)),r){if(!m&&!h&&!d&&Ln(p,o))return n;zn(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!(r&&(v||!(n.caseSensitive?y:b??=y.toLowerCase()).startsWith(r)))){if(a){if(v)continue;let e=t.slice(u).join(`/`).slice(-a.length);if((n.caseSensitive?e:e.toLowerCase())!==a)continue}s.push({node:n,index:o,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}if(i.optional){let e=d|1<<f,t=f+1;for(let n=i.optional.length-1;n>=0;n--){let r=i.optional[n];s.push({node:r,index:u,skipped:e,depth:t,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v)for(let e=i.optional.length-1;e>=0;e--){let n=i.optional[e],{prefix:r,suffix:a}=n;if(r||a){let e=n.caseSensitive?y:b??=y.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:n,index:u+1,skipped:d,depth:t,statics:p,dynamics:m,optionals:h+In(o,u),extract:g,rawParams:_})}}if(!v&&i.dynamic&&y)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?y:b??=y.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:u+1,skipped:d,depth:f+1,statics:p,dynamics:m+In(o,u),optionals:h,extract:g,rawParams:_})}if(!v&&i.staticInsensitive){let e=i.staticInsensitive.get(b??=y.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+In(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v&&i.static){let e=i.static.get(y);e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+In(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(i.pathless){let e=f+1;for(let t=i.pathless.length-1;t>=0;t--){let n=i.pathless[t];s.push({node:n,index:u,skipped:d,depth:e,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function In(e,t){return 2**(e-t-1)}function Ln(e,t){return e===2**(t-1)-1}function Rn(e,t,n){let r,i;try{[r,i]=Mn(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function zn(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===gn)>(e.node.kind===gn)||t.node.kind===gn==(e.node.kind===gn)&&t.depth>e.depth)))}function Bn(e){return Vn(e.filter(e=>e!==void 0).join(`/`))}function Vn(e){return e.replace(/\/{2,}/g,`/`)}function Hn(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function Un(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function Wn(e){return Un(Hn(e))}function Gn(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function Kn(e,t,n){return Gn(e,n)===Gn(t,n)}function qn({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&Ut(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(Ut(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c=Vn(s.join(`/`))||`/`;return o&&r&&r.set(o,c),c}function Jn(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function Yn(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>Zn(e,n)).join(`/`):Zn(r,n):r}function Xn({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=yn(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=Yn(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=Yn(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=Yn(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function Zn(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function q(e){return e?.isNotFound===!0}function Qn(){try{return sessionStorage}catch{return}}var $n=`tsr-scroll-restoration-v1_3`,er=Qn();function tr(){try{return JSON.parse(er?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}function nr(){try{er?.setItem($n,JSON.stringify(rr))}catch{}}var rr=tr(),ir=`data-scroll-restoration-id`,ar=e=>e.state.__TSR_key||e.href;function or(e){let t=e.getAttribute(ir);if(t)return`[${ir}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var sr=!1,cr=`window`;function lr(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function ur(e){let t=new Set;for(let n of e){if(n===cr)continue;let e=lr(n);e&&t.add(e)}return t}function dr(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.restoring=!0);let i=e.options.getScrollRestorationKey||ar,a=new Set,o=e=>{let t=rr[e]||={};for(let e of a)e===document?t[cr]={scrollX,scrollY}:e.isConnected&&(t[or(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.restoration&&(r.restoration=!0,sr=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{sr||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{o(i(e.stores.resolvedLocation.get()??e.stores.location.get())),nr()})),!r.reset&&(r.reset=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.next,c=r.hash,l;if(a.clear(),r.next=!0,r.hash=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.restoring&&d&&d!==u){let e=rr[d];if(e){let t=rr[u];for(let n in e){if(n===cr){if(s)continue}else{let e=lr(n);if(!e||s&&o&&(l??=ur(o),l.has(e)))continue}t||=rr[u]={},t[n]??=e[n]}}}sr=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=ur(o));let t=e&&i&&c,s=r.restoring?rr[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===cr){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=lr(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{sr=!1}}))}function fr(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function pr(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function mr(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=pr(r):Array.isArray(t)?t.push(pr(r)):n[e]=[t,pr(r)]}return n}var hr=_r(JSON.parse),gr=vr(JSON.stringify,JSON.parse);function _r(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=mr(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function vr(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=fr(e,r);return t?`?${t}`:``}}var yr=`__root__`;function br(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function xr(e){return e instanceof Response&&!!e.options}function Sr(e){return{input:({url:t})=>{for(let n of e)t=wr(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=Tr(e[n],t);return t}}}function Cr(e){let t=Wn(e.basepath),n=`/${t}`,r=e.caseSensitive?n:n.toLowerCase(),i=`${r}/`;return{input:({url:t})=>{let a=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return a===r?t.pathname=`/`:a.startsWith(i)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=Bn([`/`,t,e.pathname]),e)}}function wr(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Tr(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Er(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i,init:a}=t,o=new Map,s=new Map,c=new Map,l=n(e.status),u=n(e.loadedAt),d=n(e.isLoading),f=n(e.isTransitioning),p=n(e.location),m=n(e.resolvedLocation),h=n(e.statusCode),g=n(e.redirect),_=n([]),v=n([]),y=n([]),b=r(()=>Dr(o,_.get())),x=r(()=>Dr(s,v.get())),S=r(()=>Dr(c,y.get())),C=r(()=>_.get()[0]),w=r(()=>_.get().some(e=>o.get(e)?.get().status===`pending`)),T=r(()=>({locationHref:p.get().href,resolvedLocationHref:m.get()?.href,status:l.get()})),E=r(()=>({status:l.get(),loadedAt:u.get(),isLoading:d.get(),isTransitioning:f.get(),matches:b.get(),location:p.get(),resolvedLocation:m.get(),statusCode:h.get(),redirect:g.get()})),D=hn(64);function O(e){let t=D.get(e);return t||(t=r(()=>{let t=_.get();for(let n of t){let t=o.get(n);if(t&&t.routeId===e)return t.get()}}),D.set(e,t)),t}let k={status:l,loadedAt:u,isLoading:d,isTransitioning:f,location:p,resolvedLocation:m,statusCode:h,redirect:g,matchesId:_,pendingIds:v,cachedIds:y,matches:b,pendingMatches:x,cachedMatches:S,firstId:C,hasPending:w,matchRouteDeps:T,matchStores:o,pendingMatchStores:s,cachedMatchStores:c,__store:E,getRouteMatchStore:O,setMatches:A,setPending:j,setCached:M};A(e.matches),a?.(k);function A(e){Or(e,o,_,n,i)}function j(e){Or(e,s,v,n,i)}function M(e){Or(e,c,y,n,i)}return k}function Dr(e,t){let n=[];for(let r of t){let t=e.get(r);t&&n.push(t.get())}return n}function Or(e,t,n,r,i){let a=e.map(e=>e.id),o=new Set(a);i(()=>{for(let e of t.keys())o.has(e)||t.delete(e);for(let n of e){let e=t.get(n.id);if(!e){let e=r(n);e.routeId=n.routeId,t.set(n.id,e);continue}e.routeId=n.routeId,e.get()!==n&&e.set(n)}pn(n.get(),a)||n.set(a)})}var kr=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},Ar=e=>e.stores.matchesId.get().some(t=>e.stores.matchStores.get(t)?.get()._forcePending),jr=(e,t)=>!!(e.preload&&!e.router.stores.matchStores.has(t)),Mr=(e,t,n=!0)=>{let r={...e.router.options.context??{}},i=n?t:t-1;for(let t=0;t<=i;t++){let n=e.matches[t];if(!n)continue;let i=e.router.getMatch(n.id);i&&Object.assign(r,i.__routeContext,i.__beforeLoadContext)}return r},Nr=(e,t)=>{if(!e.matches.length)return;let n=t.routeId,r=e.matches.findIndex(t=>t.routeId===e.router.routeTree.id),i=r>=0?r:0,a=n?e.matches.findIndex(e=>e.routeId===n):e.firstBadMatchIndex??e.matches.length-1;a<0&&(a=i);for(let t=a;t>=0;t--){let n=e.matches[t];if(e.router.looseRoutesById[n.routeId].options.notFoundComponent)return t}return n?a:i},Pr=(e,t,n)=>{if(!(!xr(n)&&!q(n)))throw xr(n)&&n.redirectHandled&&!n.options.reloadDocument?n:(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=n,e.updateMatch(t.id,r=>({...r,status:xr(n)?`redirected`:q(n)?`notFound`:r.status===`pending`?`success`:r.status,context:Mr(e,t.index),isFetching:!1,error:n})),q(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),xr(n)&&(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n)),n)},Fr=(e,t)=>{let n=e.router.getMatch(t);return!!(!n||n._nonReactive.dehydrated)},Ir=(e,t,n)=>{let r=Mr(e,n);e.updateMatch(t,e=>({...e,context:r}))},Lr=(e,t,n)=>{let{id:r,routeId:i}=e.matches[t],a=e.router.looseRoutesById[i];if(n instanceof Promise)throw n;e.firstBadMatchIndex??=t,Pr(e,e.router.getMatch(r),n);try{a.options.onError?.(n)}catch(t){n=t,Pr(e,e.router.getMatch(r),n)}e.updateMatch(r,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!xr(n)&&!q(n)&&(e.serialError??=n)},Rr=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!jr(e,t)&&(n.options.loader||n.options.beforeLoad||Yr(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{kr(e)},i);r._nonReactive.pendingTimeout=t}},zr=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;Rr(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&Pr(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},Br=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=rn(()=>{a?.resolve(),a=void 0});let{paramsError:o,searchError:s}=i;o&&Lr(e,n,o),s&&Lr(e,n,s),Rr(e,t,r,i);let c=new AbortController,l=!1,u=()=>{l||(l=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c})))},d=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){e.router.batch(()=>{u(),d()});return}i._nonReactive.beforeLoadPromise=rn();let f={...Mr(e,n,!1),...i.__routeContext},{search:p,params:m,cause:h}=i,g=jr(e,t),_={search:p,abortController:c,params:m,preload:g,context:f,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:g?`preload`:h,matches:e.matches,routeId:r.id,...e.router.options.additionalContext},v=r=>{if(r===void 0){e.router.batch(()=>{u(),d()});return}(xr(r)||q(r))&&(u(),Lr(e,n,r)),e.router.batch(()=>{u(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r})),d()})},y;try{if(y=r.options.beforeLoad(_),an(y))return u(),y.catch(t=>{Lr(e,n,t)}).then(v)}catch(t){u(),Lr(e,n,t)}v(y)},Vr=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>s(),o=()=>Br(e,n,t,i),s=()=>{if(Fr(e,n))return;let t=zr(e,n,i);return an(t)?t.then(o):o()};return a()},Hr=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={ssr:e.router.options.ssr,matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},Ur=(e,t,n,r,i)=>{let a=t[r-1],{params:o,loaderDeps:s,abortController:c,cause:l}=e.router.getMatch(n),u=Mr(e,r),d=jr(e,n);return{params:o,deps:s,preload:!!d,parentMatchPromise:a,abortController:c,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:d?`preload`:l,route:i,...e.router.options.additionalContext}},Wr=async(e,t,n,r,i)=>{try{let a=e.router.getMatch(n);try{Jr(i);let o=i.options.loader,s=typeof o==`function`?o:o?.handler,c=s?.(Ur(e,t,n,r,i)),l=!!s&&an(c);if((l||i._lazyPromise||i._componentsPromise||i.options.head||i.options.scripts||i.options.headers||a._nonReactive.minPendingPromise)&&e.updateMatch(n,e=>({...e,isFetching:`loader`})),s){let t=l?await c:c;Pr(e,e.router.getMatch(n),t),t!==void 0&&e.updateMatch(n,e=>({...e,loaderData:t}))}i._lazyPromise&&await i._lazyPromise;let u=a._nonReactive.minPendingPromise;u&&await u,i._componentsPromise&&await i._componentsPromise,e.updateMatch(n,t=>({...t,error:void 0,context:Mr(e,r),status:`success`,isFetching:!1,updatedAt:Date.now()}))}catch(t){let o=t;if(o?.name===`AbortError`){if(a.abortController.signal.aborted){a._nonReactive.loaderPromise?.resolve(),a._nonReactive.loaderPromise=void 0;return}e.updateMatch(n,t=>({...t,status:t.status===`pending`?`success`:t.status,isFetching:!1,context:Mr(e,r)}));return}let s=a._nonReactive.minPendingPromise;s&&await s,q(t)&&await i.options.notFoundComponent?.preload?.(),Pr(e,e.router.getMatch(n),t);try{i.options.onError?.(t)}catch(t){o=t,Pr(e,e.router.getMatch(n),t)}!xr(o)&&!q(o)&&await Jr(i,[`errorComponent`]),e.updateMatch(n,t=>({...t,error:o,context:Mr(e,r),status:`error`,isFetching:!1}))}}catch(t){let r=e.router.getMatch(n);r&&(r._nonReactive.loaderPromise=void 0),Pr(e,r,t)}},Gr=async(e,t,n)=>{async function r(r,a,c,l,d){let f=Date.now()-a.updatedAt,p=r?d.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:d.options.staleTime??e.router.options.defaultStaleTime??0,m=d.options.shouldReload,h=typeof m==`function`?m(Ur(e,t,i,n,d)):m,{status:g,invalid:_}=l,v=f>=p&&(!!e.forceStaleReload||l.cause===`enter`||c!==void 0&&c!==l.id);o=g===`success`&&(_||(h??v)),r&&d.options.preload===!1||(o&&!e.sync&&u?(s=!0,(async()=>{try{await Wr(e,t,i,n,d);let r=e.router.getMatch(i);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0,r._nonReactive.loadPromise=void 0}catch(t){xr(t)&&await e.router.navigate(t.options)}})()):g!==`success`||o?await Wr(e,t,i,n,d):Ir(e,i,n))}let{id:i,routeId:a}=e.matches[n],o=!1,s=!1,c=e.router.looseRoutesById[a],l=c.options.loader,u=((typeof l==`function`?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!==`blocking`;if(Fr(e,i)){if(!e.router.getMatch(i))return e.matches[n];Ir(e,i,n)}else{let t=e.router.getMatch(i),o=e.router.stores.matchesId.get()[n],s=(o&&e.router.stores.matchStores.get(o)||null)?.routeId===a?o:e.router.stores.matches.get().find(e=>e.routeId===a)?.id,l=jr(e,i);if(t._nonReactive.loaderPromise){if(t.status===`success`&&!e.sync&&!t.preload&&u)return t;await t._nonReactive.loaderPromise;let n=e.router.getMatch(i),a=n._nonReactive.error||n.error;a&&Pr(e,n,a),n.status===`pending`&&await r(l,t,s,n,c)}else{let n=l&&!e.router.stores.matchStores.has(i),a=e.router.getMatch(i);a._nonReactive.loaderPromise=rn(),n!==a.preload&&e.updateMatch(i,e=>({...e,preload:n})),await r(l,t,s,a,c)}}let d=e.router.getMatch(i);s||(d._nonReactive.loaderPromise?.resolve(),d._nonReactive.loadPromise?.resolve(),d._nonReactive.loadPromise=void 0),clearTimeout(d._nonReactive.pendingTimeout),d._nonReactive.pendingTimeout=void 0,s||(d._nonReactive.loaderPromise=void 0),d._nonReactive.dehydrated=void 0;let f=s?d.isFetching:!1;return f!==d.isFetching||d.invalid!==!1?(e.updateMatch(i,e=>({...e,isFetching:f,invalid:!1})),e.router.getMatch(i)):d};async function Kr(e){let t=e,n=[];Ar(t.router)&&kr(t);let r;for(let e=0;e<t.matches.length;e++){try{let n=Vr(t,e);an(n)&&await n}catch(e){if(xr(e))throw e;if(q(e))r=e;else if(!t.preload)throw e;break}if(t.serialError||t.firstBadMatchIndex!=null)break}let i=t.firstBadMatchIndex??t.matches.length,a=r&&!t.preload?Nr(t,r):void 0,o=r&&t.preload?0:a===void 0?i:Math.min(a+1,i),s,c;for(let e=0;e<o;e++)n.push(Gr(t,n,e));try{await Promise.all(n)}catch{let e=await Promise.allSettled(n);for(let t of e){if(t.status!==`rejected`)continue;let e=t.reason;if(xr(e))throw e;q(e)?s??=e:c??=e}if(c!==void 0)throw c}let l=s??(r&&!t.preload?r:void 0),u=t.firstBadMatchIndex===void 0?t.matches.length-1:t.firstBadMatchIndex;if(!l&&r&&t.preload)return t.matches;if(l){let e=Nr(t,l);e===void 0&&mn();let n=t.matches[e],r=t.router.looseRoutesById[n.routeId],i=t.router.options?.defaultNotFoundComponent;!r.options.notFoundComponent&&i&&(r.options.notFoundComponent=i),l.routeId=n.routeId;let a=n.routeId===t.router.routeTree.id;t.updateMatch(n.id,e=>({...e,...a?{status:`success`,globalNotFound:!0,error:void 0}:{status:`notFound`,error:l},isFetching:!1})),u=e,await Jr(r,[`notFoundComponent`])}else if(!t.preload){let e=t.matches[0];e.globalNotFound||t.router.getMatch(e.id)?.globalNotFound&&t.updateMatch(e.id,e=>({...e,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){let e=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await Jr(e,[`errorComponent`])}for(let e=0;e<=u;e++){let{id:n,routeId:r}=t.matches[e],i=t.router.looseRoutesById[r];try{let e=Hr(t,n,i);if(e){let r=await e;t.updateMatch(n,e=>({...e,...r}))}}catch(e){console.error(`Error executing head for route ${r}:`,e)}}let d=kr(t);if(an(d)&&await d,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function qr(e,t){let n=t.map(t=>e.options[t]?.preload?.()).filter(Boolean);if(n.length!==0)return Promise.all(n)}function Jr(e,t=Xr){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);let n=()=>e._componentsLoaded?void 0:t===Xr?(()=>{if(e._componentsPromise===void 0){let t=qr(e,Xr);t?e._componentsPromise=t.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():qr(e,t);return e._lazyPromise?e._lazyPromise.then(n):n()}function Yr(e){for(let t of Xr)if(e.options[t]?.preload)return!0;return!1}var Xr=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`],Zr=`__TSR_index`,Qr=`popstate`,$r=`beforeunload`;function ei(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=ii(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[Zr];i=ti(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[Zr];i=ti(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[Zr]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function ti(e,t){t||={};let n=ai();return{...t,key:n,__TSR_key:n,[Zr]:e}}function ni(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>ii(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=ai();t.history.replaceState({[Zr]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=ii(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[Zr]-l.state[Zr],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=ei({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener($r,S,{capture:!0}),t.removeEventListener(Qr,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener($r,S,{capture:!0}),t.addEventListener(Qr,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function ri(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function ii(e,t){let n=ri(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=ai();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[Zr]:0,key:a,__TSR_key:a}}}function ai(){return(Math.random()+1).toString(36).substring(7)}function oi(e,t){let n=t,r=e;return{fromLocation:n,toLocation:r,pathChanged:n?.pathname!==r.pathname,hrefChanged:n?.href!==r.href,hashChanged:n?.hash!==r.hash}}var si=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={next:!0},this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.routeBranchCache=new WeakMap,this.lightweightCache=new WeakMap,this.startTransition=e=>e(),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=Jn(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=ni()),this.origin=this.options.origin,this.origin||(window?.origin&&window.origin!==`null`?this.origin=window.origin:this.origin=`http://localhost`),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;this.resolvePathCache=hn(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=Er(ui(this.latestLocation),e),dr(this)}let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[],t=Wn(o);t&&t!==`/`&&e.push(Cr({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:Sr(e),this.history&&this.updateLatestLocation(),a=!0}a&&this.stores&&this.stores.location.set(this.latestLocation),typeof window<`u`&&`CSS`in window&&typeof window.CSS?.supports==`function`&&(this.isViewTransitionTypesSupported=window.CSS.supports(`selector(:active-view-transition-type(a))`))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=An(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&Tn(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:dn(e).path,external:!1,searchStr:o,search:Xt(t?.search,i),hash:dn(r.slice(1)).path,state:Zt(t?.state,a)}}let o=new URL(i,this.origin),s=wr(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:dn(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:Xt(t?.search,c),hash:dn(s.hash.slice(1)).path,state:Zt(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>qn({base:e,to:t.includes(`//`)?Vn(t):t,trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>fi({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingIds.get().forEach(e=>{this.cancelMatch(e)}),this.stores.matchesId.get().forEach(e=>{if(this.stores.pendingMatchStores.has(e))return;let t=this.stores.matchStores.get(e)?.get();t&&(t.status===`pending`||t.isFetching===`loader`)&&this.cancelMatch(e)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=t.to?`${t.to}`:void 0,o=r.search,s=Object.assign(Object.create(null),r.params),c=a?.charCodeAt(0)===47?`/`:this.resolvePathWithBase(i,`.`),l=a?this.resolvePathWithBase(c,a):c,u=t.params===!1||t.params===null?Object.create(null):(t.params??!0)===!0?s:Object.assign(s,Gt(t.params,s)),d=this.routesByPath[Un(l)],f;if(d)f=this.getRouteBranch(d);else if(l.includes(`$`))f=[];else{let e=this.getMatchedRoutes(l);f=e.matchedRoutes,this.options.notFoundRoute&&(!e.foundRoute||e.foundRoute.path!==`/`&&e.routeParams[`**`])&&(f=[...f,this.options.notFoundRoute])}if(f.length&&Jt(u))for(let e of f){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(u,t(u))}catch{}}let p=e.leaveParams?l:dn(Xn({path:l,params:u,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,m=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};f.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,di(t.options.validateSearch,{...e,...m}))}catch{}}),m=e}m=pi({search:m,dest:t,destRoutes:f,_includeValidateSearch:e._includeValidateSearch}),m=Xt(o,m);let h=this.options.stringifySearch(m),g=t.hash===!0?n.hash:t.hash?Gt(t.hash,n.hash):void 0,_=g?`#${g}`:``,v=t.state===!0?n.state:t.state?Gt(t.state,n.state):{};v=Zt(n.state,v);let y=`${p}${h}${_}`,b,x,S=!1;if(this.rewrite){let e=new URL(y,this.origin),t=Tr(this.rewrite,e);b=e.href.replace(e.origin,``),t.origin===this.origin?x=t.pathname+t.search+t.hash:(x=t.href,S=!0)}else b=fn(y),x=b;return{publicHref:x,href:b,pathname:p,search:m,searchStr:h,state:v,hash:g??``,external:S,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=En(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=s===!1||s===null?Object.create(null):(s??!0)===!0?n:Object.assign(n,Gt(s,n));r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r,i=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=nn(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},a=Un(this.latestLocation.href)===Un(n.href),o=this.commitLocationPromise;if(this.commitLocationPromise=rn(()=>{o?.resolve(),o=void 0}),a&&i())this.load();else{let{maskedLocation:i,hashScrollIntoView:a,...o}=n;i&&(o={...i,state:{...i.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state.__hashScrollIntoViewOptions=a??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,r=n.replace?`REPLACE`:`PUSH`,this.history[r===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t})}return this._scroll.next=n.resetScroll??!0,this.history.subscribers.size||this.load(r?{action:{type:r}}:void 0),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=ii(a,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);o.to=wr(this.rewrite,r).pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(un(t,this.protocolAllowlist))return;if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return}i.replace?window.location.replace(t):window.location.href=t;return}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();let e=this.matchRoutes(this.latestLocation),t=this.stores.cachedMatches.get().filter(t=>!e.some(e=>e.id===t.id));this.batch(()=>{this.stores.status.set(`pending`),this.stores.statusCode.set(200),this.stores.isLoading.set(!0),this.stores.location.set(this.latestLocation),this.stores.setPending(e),this.stores.setCached(t)})},this.load=async e=>{let t=e?.action?.type,n,r,i,a=this.stores.resolvedLocation.get()??this.stores.location.get();for(i=new Promise(o=>{this.startTransition(async()=>{try{this.beforeLoad(),t&&(this._scroll.hash=t===`PUSH`||t===`REPLACE`);let n=this.latestLocation,r=oi(n,this.stores.resolvedLocation.get());this.stores.redirect.get()||this.emit({type:`onBeforeNavigate`,...r}),this.emit({type:`onBeforeLoad`,...r}),await Kr({router:this,sync:e?.sync,forceStaleReload:a.href===n.href,matches:this.stores.pendingMatches.get(),location:n,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=null,t=null,n=null,r=null;this.batch(()=>{let i=this.stores.pendingMatches.get(),a=i.length,o=this.stores.matches.get();e=a?o.filter(e=>!this.stores.pendingMatchStores.has(e.id)):null;let s=new Set;for(let e of this.stores.pendingMatchStores.values())e.routeId&&s.add(e.routeId);let c=new Set;for(let e of this.stores.matchStores.values())e.routeId&&c.add(e.routeId);t=a?o.filter(e=>!s.has(e.routeId)):null,n=a?i.filter(e=>!c.has(e.routeId)):null,r=a?i.filter(e=>c.has(e.routeId)):o,this.stores.isLoading.set(!1),this.stores.loadedAt.set(Date.now()),a&&(this.stores.setMatches(i),this.stores.setPending([]),this.stores.setCached([...this.stores.cachedMatches.get(),...e.filter(e=>e.status!==`error`&&e.status!==`notFound`&&e.status!==`redirected`)]),this.clearExpiredCache())});for(let[e,i]of[[t,`onLeave`],[n,`onEnter`],[r,`onStay`]])if(e)for(let t of e)this.looseRoutesById[t.routeId].options[i]?.(t)})})}})}catch(e){xr(e)?(n=e,this.navigate({...n.options,replace:!0,ignoreBlocker:!0})):q(e)&&(r=e);let t=n?n.status:r?404:this.stores.matches.get().some(e=>e.status===`error`)?500:200;this.batch(()=>{this.stores.statusCode.set(t),this.stores.redirect.set(n)})}this.latestLoadPromise===i&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),o()})}),this.latestLoadPromise=i,await i;this.latestLoadPromise&&i!==this.latestLoadPromise;)await this.latestLoadPromise;let o;this.hasNotFoundMatch()?o=404:this.stores.matches.get().some(e=>e.status===`error`)&&(o=500),o!==void 0&&this.stores.statusCode.set(o)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(oi(r,i)):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.stores.pendingMatchStores.get(e);if(n){n.set(t);return}let r=this.stores.matchStores.get(e);if(r){r.set(t);return}let i=this.stores.cachedMatchStores.get(e);if(i){let n=t(i.get());n.status===`redirected`?this.stores.cachedMatchStores.delete(e)&&this.stores.cachedIds.set(t=>t.filter(t=>t!==e)):i.set(n)}})},this.getMatch=e=>this.stores.cachedMatchStores.get(e)?.get()??this.stores.pendingMatchStores.get(e)?.get()??this.stores.matchStores.get(e)?.get(),this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.batch(()=>{this.stores.setMatches(this.stores.matches.get().map(t)),this.stores.setCached(this.stores.cachedMatches.get().map(t)),this.stores.setPending(this.stores.pendingMatches.get().map(t))}),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.getParsedLocationHref=e=>e.publicHref||`/`,this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=e.options._builtLocation??this.buildLocation(e.options),n=this.getParsedLocationHref(t);e.options.href=n,e.headers.set(`Location`,n)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&un(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.stores.setCached([]):this.stores.setCached(this.stores.cachedMatches.get().filter(e=>!t(e)))},this.clearExpiredCache=()=>{let e=Date.now();this.clearCache({filter:t=>{let n=this.looseRoutesById[t.routeId];if(!n.options.loader)return!0;let r=(t.preload?n.options.preloadGcTime??this.options.defaultPreloadGcTime:n.options.gcTime??this.options.defaultGcTime)??300*1e3;return t.status===`error`||e-t.updatedAt>=r}})},this.loadRouteChunk=Jr,this.preloadRoute=async e=>{let t=e._builtLocation??this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.stores.matchesId.get(),...this.stores.pendingIds.get()]),i=new Set([...r,...this.stores.cachedIds.get()]),a=n.filter(e=>!i.has(e.id));if(a.length){let e=this.stores.cachedMatches.get();this.stores.setCached([...e,...a])}try{return n=await Kr({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(xr(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});q(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.stores.status.get()!==`pending`)return!1;let i=(t?.pending===void 0?!this.stores.isLoading.get():t.pending)?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),a=Dn(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!nn(a.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?nn(i.search,r.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.matches.get().some(e=>e.status===`notFound`||e.globalNotFound),this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??gr,parseSearch:e.parseSearch??hr,protocolAllowlist:e.protocolAllowlist??ln}),typeof document<`u`&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.stores.__store.get()}setRoutes({routesById:e,routesByPath:t,processedTree:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}getRouteBranch(e){let t=this.routeBranchCache.get(e);return t||(t=Nn(e),this.routeBranchCache.set(e,t)),t}get looseRoutesById(){return this.routesById}getParentContext(e){return e?.id?e.context??this.options.context??void 0:this.options.context??void 0}matchRoutesInternal(e,t){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i}=n,{matchedRoutes:a}=n,o=!1;(r?r.path!==`/`&&i[`**`]:Un(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?hi(this.options.notFoundMode,a):void 0,c=Array(a.length),l=new Map;for(let e of this.stores.matchStores.values())e.routeId&&l.set(e.routeId,e.get());for(let n=0;n<a.length;n++){let r=a[n],o=c[n-1],u,d,f;{let n=o?.search??e.search,i=o?._strictSearch??void 0;try{let e=di(r.options.validateSearch,{...n})??void 0;u={...n,...e},d={...i,...e},f=void 0}catch(e){let r=e;if(e instanceof ci||(r=new ci(e.message,{cause:e})),t?.throwOnError)throw r;u=n,d={},f=r}}let p=r.options.loaderDeps?.({search:u})??``,m=p?JSON.stringify(p):``,{interpolatedPath:h,usedParams:g}=Xn({path:r.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),_=r.id+h+m,v=this.getMatch(_),y=l.get(r.id),b=v?._strictParams??g,x;if(!v)try{gi(r,b)}catch(e){if(x=q(e)||xr(e)?e:new li(e.message,{cause:e}),t?.throwOnError)throw x}Object.assign(i,b);let S=y?`stay`:`enter`,C;if(v)C={...v,cause:S,params:y?.params??i,_strictParams:b,search:Xt(y?y.search:v.search,u),_strictSearch:d};else{let e=r.options.loader||r.options.beforeLoad||r.lazyFn||Yr(r)?`pending`:`success`;C={id:_,ssr:r.options.ssr,index:n,routeId:r.id,params:y?.params??i,_strictParams:b,pathname:h,updatedAt:Date.now(),search:y?Xt(y.search,u):u,_strictSearch:d,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:x,__routeContext:void 0,_nonReactive:{loadPromise:rn()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:S,loaderDeps:y?Zt(y.loaderDeps,p):p,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:r.options.staticData||{},fullPath:r.fullPath}}t?.preload||(C.globalNotFound=s===r.id),C.searchError=f;let w=this.getParentContext(o);C.context={...w,...C.__routeContext,...C.__beforeLoadContext},c[n]=C}for(let t=0;t<c.length;t++){let n=c[t],r=this.looseRoutesById[n.routeId],a=this.getMatch(n.id),o=l.get(n.routeId);if(n.params=o?Xt(o.params,i):i,!a){let i=c[t-1],a=this.getParentContext(i);if(r.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:c,routeId:r.id};n.__routeContext=r.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}return c}matchRoutesLightweight(e){let t=Ut(this.stores.matchesId.get()),n=this.lightweightCache.get(e);if(n&&n[0]===t)return n[1];let{matchedRoutes:r,routeParams:i}=this.getMatchedRoutes(e.pathname),a=Ut(r),o={...e.search};for(let e of r)try{Object.assign(o,di(e.options.validateSearch,o))}catch{}let s=t&&this.stores.matchStores.get(t)?.get(),c=s&&s.routeId===a.id&&s.pathname===e.pathname,l;if(c)l=s.params;else{let e=Object.assign(Object.create(null),i);for(let t of r)try{gi(t,e)}catch{}l=e}let u={matchedRoutes:r,fullPath:a.fullPath,search:o,params:l};return this.lightweightCache.set(e,[t,u]),u}},ci=class extends Error{},li=class extends Error{};function ui(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function di(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new ci(`Async validation not supported`);if(n.issues)throw new ci(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function fi({pathname:e,routesById:t,processedTree:n}){let r=Object.create(null),i=Un(e),a,o=On(i,n,!0);return o&&(a=o.route,Object.assign(r,o.rawParams)),{matchedRoutes:o?.branch||[t.__root__],routeParams:r,foundRoute:a}}function pi({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){return mi(n)(e,t,r??!1)}function mi(e){let t,n,r=[];for(let t of e){let e=t.options;`search`in e?e.search?.middlewares&&r.push(...e.search.middlewares):(e.preSearchFilters||e.postSearchFilters)&&r.push(({search:t,next:n})=>{let r=n(e.preSearchFilters?e.preSearchFilters.reduce((e,t)=>t(e),t):t);return e.postSearchFilters?e.postSearchFilters.reduce((e,t)=>t(e),r):r});let i=e.validateSearch;i&&r.push(({search:e,next:t,meta:r})=>{let a=t(e);if(n)try{let e=di(i,a);if(r&&e)for(let t in e)t in a||(r.defaulted||=new Map).set(t,e[t]);return{...a,...e}}catch{}return a})}let i=(e,n,a)=>{if(e>=r.length){if(!t.search)return{};if(t.search===!0)return n;let e=Gt(t.search,n);return a&&(a.explicit=e),e}return r[e]({search:n,next:(t,n)=>{if(n){let n=a||{};return{search:i(e+1,t,n),meta:n}}return i(e+1,t,a)},meta:a})};return function(e,r,a){return t=r,n=a,i(0,e)}}function hi(e,t){if(e!==`root`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.children)return n.id}return yr}function gi(e,t){let n=e.options.params?.parse??e.options.parseParams;if(n){let e=n(t);if(e===!1)throw Error(`Route params.parse returned false for a matched route`);Object.assign(t,e)}}var _i=`Error preloading route! ☝️`,vi=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=yr:this.parentRoute||mn();let r=n?yr:t?.path;r&&r!==`/`&&(r=Hn(r));let i=t?.id||r,a=n?yr:Bn([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=Bn([`/`,a]));let o=a===`__root__`?`/`:Bn([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=Un(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>br({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},yi=class extends vi{constructor(e){super(e)}},J=a();function bi(e){let t=e.errorComponent??Si;return(0,J.jsx)(xi,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?K.createElement(t,{error:n,reset:r}):e.children})}var xi=class extends K.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:null}:{resetKey:n}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.error,reset:()=>{this.reset()}})}};function Si({error:e}){let[t,n]=K.useState(!1);return(0,J.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,J.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,J.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,J.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,J.jsx)(`div`,{children:(0,J.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,J.jsx)(`code`,{children:e.message}):null})}):null]})}function Ci({children:e,fallback:t=null}){return wi()?(0,J.jsx)(K.Fragment,{children:e}):(0,J.jsx)(K.Fragment,{children:t})}function wi(){return K.useSyncExternalStore(Ti,()=>!0,()=>!1)}function Ti(){return()=>{}}var Ei=K.createContext(null);function Di(e){return K.useContext(Ei)}var Oi=K.createContext(void 0),ki=K.createContext(void 0),Y=(e=>(e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e))(Y||{});function Ai({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function ji(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var Mi=[],Ni=0,{link:Pi,unlink:Fi,propagate:Ii,checkDirty:Li,shallowPropagate:Ri}=Ai({update(e){return e._update()},notify(e){Mi[Bi++]=e,e.flags&=~Y.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=Y.Mutable|Y.Dirty,Wi(e))}}),zi=0,Bi=0,Vi,Hi=0;function Ui(e){try{++Hi,e()}finally{--Hi||Gi()}}function Wi(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Fi(n,e)}function Gi(){if(!(Hi>0)){for(;zi<Bi;){let e=Mi[zi];Mi[zi++]=void 0,e.notify()}zi=0,Bi=0}}function Ki(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?Y.None:Y.Mutable,get(){return Vi!==void 0&&Pi(i,Vi,Ni),i._snapshot},subscribe(e){let t=ji(e),n={current:!1},r=qi(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=Vi,o=t?.compare??Object.is;if(n)Vi=i,++Ni,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=Y.Mutable|Y.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{Vi=a,n&&(i.flags&=~Y.RecursedCheck),Wi(i)}}};return n?(i.flags=Y.Mutable|Y.Dirty,i.get=function(){let e=i.flags;if(e&Y.Dirty||e&Y.Pending&&Li(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Ri(e)}}else e&Y.Pending&&(i.flags=e&~Y.Pending);return Vi!==void 0&&Pi(i,Vi,Ni),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Ii(e),Ri(e),Gi())}},i}function qi(e){let t=()=>{let t=Vi;Vi=n,++Ni,n.depsTail=void 0,n.flags=Y.Watching|Y.RecursedCheck;try{return e()}finally{Vi=t,n.flags&=~Y.RecursedCheck,Wi(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:Y.Watching|Y.RecursedCheck,notify(){let e=this.flags;e&Y.Dirty||e&Y.Pending&&Li(this.deps,this)?t():this.flags=Y.Watching},stop(){this.flags=Y.None,this.depsTail=void 0,Wi(this)}};return t(),n}var Ji=t((e=>{var t=n(),r=x();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Yi=t(((e,t)=>{t.exports=Ji()}))();function Xi(e,t){return e===t}function Zi(e,t,n=Xi){let r=(0,K.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,K.useCallback)(()=>e?.get(),[e]);return(0,Yi.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var Qi={get(){},subscribe(){return{unsubscribe(){}}}};function $i(e,t){let n=K.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=Zt(n.current,i):i}}function ea(e){let t=Di(),n=K.useContext(e.from?ki:Oi),r=e.from?t.stores.getRouteMatchStore(e.from):t.stores.matchStores.get(n),i=$i(e,t),a=Zi(r??Qi,e=>e?i(e):Qi);if(a!==Qi)return a;(e.shouldThrow??!0)&&mn()}function ta(e){return ea({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function na(e){let{select:t,...n}=e;return ea({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function ra(e){return ea({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function ia(e){return ea({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function aa(e){let t=Di();return K.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function oa(e){return ea({...e,select:t=>e.select?e.select(t.context):t.context})}var sa=e(i(),1);function ca(e,t){let n=Di(),r=Ht(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,preloadIntentProximity:u,hashScrollIntoView:d,replace:f,startTransition:p,resetScroll:m,viewTransition:h,children:g,target:_,disabled:v,style:y,className:b,onClick:x,onBlur:S,onFocus:C,onMouseEnter:w,onMouseLeave:T,onTouchStart:E,ignoreBlocker:D,params:O,search:k,hash:A,state:j,mask:M,reloadDocument:N,unsafeRelative:P,from:F,_fromLocation:I,...L}=e,ee=wi(),R=K.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),z=Zi(n.stores.location,e=>e,(e,t)=>e.href===t.href),B=K.useMemo(()=>{let e={_fromLocation:z,...R};return n.buildLocation(e)},[n,z,R]),V=B.maskedLocation?B.maskedLocation.publicHref:B.publicHref,te=B.maskedLocation?B.maskedLocation.external:B.external,H=K.useMemo(()=>_a(V,te,n.history,v),[v,te,V,n.history]),U=K.useMemo(()=>{if(H?.external)return un(H.href,n.protocolAllowlist)?void 0:H.href;if(!va(s)&&!(typeof s!=`string`||s.indexOf(`:`)===-1))try{return new URL(s),un(s,n.protocolAllowlist)?void 0:s}catch{}},[s,H,n.protocolAllowlist]),ne=K.useMemo(()=>{if(U)return!1;if(o?.exact){if(!Kn(z.pathname,B.pathname,n.basepath))return!1}else{let e=Gn(z.pathname,n.basepath),t=Gn(B.pathname,n.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return(o?.includeSearch??!0)&&!nn(z.search,B.search,{partial:!o?.exact,ignoreUndefined:!o?.explicitUndefined})?!1:!o?.includeHash||ee&&z.hash===B.hash},[o?.exact,o?.explicitUndefined,o?.includeHash,o?.includeSearch,z,U,ee,B.hash,B.pathname,B.search,n.basepath]),W=ne?Gt(i,{})??ua:la,re=ne?la:Gt(a,{})??la,ie=[b,W.className,re.className].filter(Boolean).join(` `),ae=(y||W.style||re.style)&&{...y,...W.style,...re.style},[oe,se]=K.useState(!1),ce=K.useRef(!1),G=e.reloadDocument||U?!1:c??n.options.defaultPreload,le=l??n.options.defaultPreloadDelay??0,ue=K.useCallback(()=>{n.preloadRoute({...R,_builtLocation:B}).catch(e=>{console.warn(e),console.warn(_i)})},[n,R,B]);Vt(r,K.useCallback(e=>{e?.isIntersecting&&ue()},[ue]),ha,{disabled:!!v||G!==`viewport`}),K.useEffect(()=>{ce.current||!v&&G===`render`&&(ue(),ce.current=!0)},[v,ue,G]);let de=e=>{let t=e.currentTarget.getAttribute(`target`),r=_===void 0?t:_;if(!v&&!ba(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,sa.flushSync)(()=>{se(!0)});let t=n.subscribe(`onResolved`,()=>{t(),se(!1)});n.navigate({...R,replace:f,resetScroll:m,hashScrollIntoView:d,startTransition:p,viewTransition:h,ignoreBlocker:D})}};if(U)return{...L,ref:r,href:U,...g&&{children:g},..._&&{target:_},...v&&{disabled:v},...y&&{style:y},...b&&{className:b},...x&&{onClick:x},...S&&{onBlur:S},...C&&{onFocus:C},...w&&{onMouseEnter:w},...T&&{onMouseLeave:T},...E&&{onTouchStart:E}};let fe=e=>{if(v||G!==`intent`)return;if(!le){ue();return}let t=e.currentTarget;if(ma.has(t))return;let n=setTimeout(()=>{ma.delete(t),ue()},le);ma.set(t,n)},pe=e=>{v||G!==`intent`||ue()},me=e=>{if(v||!G||!le)return;let t=e.currentTarget,n=ma.get(t);n&&(clearTimeout(n),ma.delete(t))};return{...L,...W,...re,href:H?.href,ref:r,onClick:ga([x,de]),onBlur:ga([S,me]),onFocus:ga([C,fe]),onMouseEnter:ga([w,fe]),onMouseLeave:ga([T,me]),onTouchStart:ga([E,pe]),disabled:!!v,target:_,...ae&&{style:ae},...ie&&{className:ie},...v&&da,...ne&&fa,...ee&&oe&&pa}}var la={},ua={className:`active`},da={role:`link`,"aria-disabled":!0},fa={"data-status":`active`,"aria-current":`page`},pa={"data-transitioning":`transitioning`},ma=new WeakMap,ha={rootMargin:`100px`},ga=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function _a(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function va(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var ya=K.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=ca(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return K.createElement(`a`,t,o)}return K.createElement(n,a,o)});function ba(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var xa=class extends vi{constructor(e){super(e),this.useMatch=e=>ea({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>oa({...e,from:this.id}),this.useSearch=e=>ia({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>ra({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>na({...e,from:this.id}),this.useLoaderData=e=>ta({...e,from:this.id}),this.useNavigate=()=>aa({from:this.fullPath}),this.Link=K.forwardRef((e,t)=>(0,J.jsx)(ya,{ref:t,from:this.fullPath,...e}))}};function Sa(e){return new xa(e)}var Ca=class extends yi{constructor(e){super(e),this.useMatch=e=>ea({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>oa({...e,from:this.id}),this.useSearch=e=>ia({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>ra({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>na({...e,from:this.id}),this.useLoaderData=e=>ta({...e,from:this.id}),this.useNavigate=()=>aa({from:this.fullPath}),this.Link=K.forwardRef((e,t)=>(0,J.jsx)(ya,{ref:t,from:this.fullPath,...e}))}};function wa(e){return new Ca(e)}function Ta(e){let t=Di(),n=`not-found-${Zi(t.stores.location,e=>e.pathname)}-${Zi(t.stores.status,e=>e)}`;return(0,J.jsx)(bi,{getResetKey:()=>n,onCatch:(t,n)=>{if(q(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(q(t))return e.fallback?.(t);throw t},children:e.children})}function Ea(){return(0,J.jsx)(`p`,{children:`Not Found`})}function Da(e){return(0,J.jsx)(J.Fragment,{children:e.children})}function Oa(e,t,n){return t.options.notFoundComponent?(0,J.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,J.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,J.jsx)(Ea,{})}var ka=(e,t)=>e.routeId===t.routeId&&e._displayPending===t._displayPending,Aa=(e,t)=>e[0]===t[0]&&e[1]===t[1],ja=K.memo(function({matchId:e}){let t=Di(),n=t.stores.matchStores.get(e);n||mn();let r=Zi(t.stores.loadedAt,e=>e),i=Zi(n,e=>e,ka);return(0,J.jsx)(Ma,{router:t,matchId:e,resetKey:r,matchState:K.useMemo(()=>{let e=i.routeId,n=t.routesById[e].parentRoute?.id;return{routeId:e,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:n}},[i._displayPending,i.routeId,i.ssr,t.routesById])})});function Ma({router:e,matchId:t,resetKey:n,matchState:r}){let i=e.routesById[r.routeId],a=i.options.pendingComponent??e.options.defaultPendingComponent,o=a?(0,J.jsx)(a,{}):null,s=i.options.errorComponent??e.options.defaultErrorComponent,c=i.options.onCatch??e.options.defaultOnCatch,l=i.isRoot?i.options.notFoundComponent??e.options.notFoundRoute?.options.component:i.options.notFoundComponent,u=r.ssr===!1||r.ssr===`data-only`,d=(!i.isRoot||i.options.wrapInSuspense||u)&&(i.options.wrapInSuspense??a??(i.options.errorComponent?.preload||u))?K.Suspense:Da,f=s?bi:Da,p=l?Ta:Da;return(0,J.jsxs)(i.isRoot?i.options.shellComponent??Da:Da,{children:[(0,J.jsx)(Oi.Provider,{value:t,children:(0,J.jsx)(d,{fallback:o,children:(0,J.jsx)(f,{getResetKey:()=>n,errorComponent:s||Si,onCatch:(e,t)=>{if(q(e))throw e.routeId??=r.routeId,e;c?.(e,t)},children:(0,J.jsx)(p,{fallback:e=>{if(e.routeId??=r.routeId,!l||e.routeId&&e.routeId!==r.routeId||!e.routeId&&!i.isRoot)throw e;return K.createElement(l,e)},children:u||r._displayPending?(0,J.jsx)(Ci,{fallback:o,children:(0,J.jsx)(Pa,{matchId:t})}):(0,J.jsx)(Pa,{matchId:t})})})})}),r.parentRouteId===`__root__`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Na,{}),(e.options.scrollRestoration,null)]}):null]})}function Na(){let e=Di(),t=K.useRef();return zt(()=>{let n=e.stores.resolvedLocation.get(),r=t.current;n&&(!r||r.href!==n.href)&&e.emit({type:`onRendered`,...oi(e.stores.location.get(),r??n)}),t.current=n},[Zi(e.stores.resolvedLocation,e=>e?.state.__TSR_key),e]),null}var Pa=K.memo(function({matchId:e}){let t=Di(),n=(e,n)=>t.getMatch(e.id)?._nonReactive[n]??e._nonReactive[n],r=t.stores.matchStores.get(e);r||mn();let i=Zi(r,e=>e),a=i.routeId,o=t.routesById[a],s=K.useMemo(()=>{let e=(t.routesById[a].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:a,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return e?JSON.stringify(e):void 0},[a,i.loaderDeps,i._strictParams,i._strictSearch,t.options.defaultRemountDeps,t.routesById]),c=K.useMemo(()=>{let e=o.options.component??t.options.defaultComponent;return e?(0,J.jsx)(e,{},s):(0,J.jsx)(Fa,{})},[s,o.options.component,t.options.defaultComponent]);if(i._displayPending)throw n(i,`displayPendingPromise`);if(i._forcePending)throw n(i,`minPendingPromise`);if(i.status===`pending`){let e=o.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let n=t.getMatch(i.id);if(n&&!n._nonReactive.minPendingPromise){let t=rn();n._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),n._nonReactive.minPendingPromise=void 0},e)}}throw n(i,`loadPromise`)}if(i.status===`notFound`)return q(i.error)||mn(),Oa(t,o,i.error);if(i.status===`redirected`)throw xr(i.error)||mn(),n(i,`loadPromise`);if(i.status===`error`)throw i.error;return c}),Fa=K.memo(function(){let e=Di(),t=K.useContext(Oi),n,r=!1,i;{let a=t?e.stores.matchStores.get(t):void 0;[n,r]=Zi(a,e=>[e?.routeId,e?.globalNotFound??!1],Aa),i=Zi(e.stores.matchesId,e=>e[e.findIndex(e=>e===t)+1])}let a=n?e.routesById[n]:void 0,o=e.options.defaultPendingComponent?(0,J.jsx)(e.options.defaultPendingComponent,{}):null;if(r)return a||mn(),Oa(e,a,void 0);if(!i)return null;let s=(0,J.jsx)(ja,{matchId:i});return n===`__root__`?(0,J.jsx)(K.Suspense,{fallback:o,children:s}):s});function Ia(){let e=Di(),t=K.useRef({router:e,mounted:!1}),[n,r]=K.useState(!1),i=Zi(e.stores.isLoading,e=>e),a=Zi(e.stores.hasPending,e=>e),o=Bt(i),s=i||n||a,c=Bt(s),l=i||a,u=Bt(l);return e.startTransition=e=>{r(!0),K.startTransition(()=>{e(),r(!1)})},K.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return Un(e.latestLocation.publicHref)!==Un(n.publicHref)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),zt(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),zt(()=>{o&&!i&&e.emit({type:`onLoad`,...oi(e.stores.location.get(),e.stores.resolvedLocation.get())})},[o,e,i]),zt(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,...oi(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,u,e]),zt(()=>{if(c&&!s){let t=oi(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:`onResolved`,...t}),Ui(()=>{e.stores.status.set(`idle`),e.stores.resolvedLocation.set(e.stores.location.get())})}},[s,c,e]),null}function La(){let e=Di(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,J.jsx)(t,{}):null,r=(0,J.jsxs)(typeof document<`u`&&e.ssr?Da:K.Suspense,{fallback:n,children:[(0,J.jsx)(Ia,{}),(0,J.jsx)(Ra,{})]});return e.options.InnerWrap?(0,J.jsx)(e.options.InnerWrap,{children:r}):r}function Ra(){let e=Di(),t=Zi(e.stores.firstId,e=>e),n=Zi(e.stores.loadedAt,e=>e),r=t?(0,J.jsx)(ja,{matchId:t}):null;return(0,J.jsx)(Oi.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,J.jsx)(bi,{getResetKey:()=>n,errorComponent:Si,onCatch:void 0,children:r})})}var za=e=>({createMutableStore:Ki,createReadonlyStore:Ki,batch:Ui}),Ba=e=>new Va(e),Va=class extends si{constructor(e){super(e,za)}};function Ha({router:e,children:t,...n}){Jt(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,J.jsx)(Ei.Provider,{value:e,children:t});return e.options.Wrap?(0,J.jsx)(e.options.Wrap,{children:r}):r}function Ua({router:e,...t}){return(0,J.jsx)(Ha,{router:e,...t,children:(0,J.jsx)(La,{})})}var Wa=class extends ne{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ae(t,n.data),hasPreviousPage:re(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function Ga(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ka(e,t,n){let r=e.slice(0);return r[t]=n,r}var qa=class extends T{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,G.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!A(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ga(e,n).forEach(e=>{e.destroy()}),Ga(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=Pe(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new ne(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ka(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&G.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},Ja=class extends T{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Me(r,t),a=this.get(i);return a||(a=new me({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){G.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ie(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Ie(e,t)):t}notify(e){G.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){G.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){G.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ya=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ja,this.#t=e.mutationCache||new Ve,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=ge.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ee(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=se(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return G.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;G.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return G.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=G.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(I).catch(I)}invalidateQueries(e,t={}){return G.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=G.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(I)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(I)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(ee(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(I).catch(I)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(I).catch(I)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return ge.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(B(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{D(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(B(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{D(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Me(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===N&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function Xa({queries:e,...t},n){let r=Ee(n),i=te(),a=ue(),o=K.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{P(e);let t=r.getQueryCache().get(e.queryHash);Oe(e,a,t)}),we(a);let[s]=K.useState(()=>new qa(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;K.useSyncExternalStore(K.useCallback(e=>d?s.subscribe(G.batchCalls(e)):I,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),K.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>ie(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&ie(n,e)?C(n,new ne(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&ve({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}function Za(e,t){return z(e,Wa,t)}var Qa={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},$a=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function eo(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Qa[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp($a),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var to=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,no=/<\/?([^\s]+?)[/\s>]/,ro=/^\s*$/,io=/^(script|style)$/i,ao=`\0`,oo=Object.create(null);function so(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(ao).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(ao).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(ao)>-1&&(e.attrs[t]=n.split(ao).join(`<`))}e.children.length&&so(e.children)})}function co(e,t){let n=t&&t.components||oo,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;to.lastIndex=0;let o;for(;o=to.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(no);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=ao,a=o.index+1,to.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=to.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let m=i.charAt(1)!==`/`,h=i.startsWith(`<!--`),g=p+i.length,_=e.charAt(g),v=f[r+1],y;if(_===`<`&&v){let t=e.substring(g,v.index);y=t.split(`<`).length>t.split(`>`).length}let b;if(h){let t=eo(i);if(c<0)return a.push(t),a;b=o[c],b.children.push(t);let n=e.slice(g,v?v.index:void 0);return n.length>0&&b.children.push({type:`text`,content:n}),a}if(m){c++,s=eo(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&io.test(s.name)){t=!0,d||=e.toLowerCase();let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,g),r=n===-1?e.length:n,i=e.slice(g,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&_&&_!==`<`&&s.children.push({type:`text`,content:e.slice(g,v?v.index:void 0)}),c===0&&a.push(s),b=o[c-1],b&&b.children.push(s),o[c]=s}if((!m||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(_!==`<`||y)&&_)){b=c===-1?a:o[c].children;let t=v?v.index:-1,n=e.slice(g,t===-1?void 0:t);ro.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&so(a),a}function lo(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`&quot;`)+`"`);return t.length?` `+t.join(` `):``}function uo(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?lo(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(uo,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function fo(e){return e.reduce(function(e,t){return e+uo(``,t)},``)}var po={parse:co,stringify:fo},mo=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},ho=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?_o(t):t},go=e=>Array.isArray(e)&&e.every(K.isValidElement),_o=e=>Array.isArray(e)?e:[e],vo=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},yo=e=>{let t={};if(!e)return t;let n=e=>{_o(e).forEach(e=>{d(e)||(mo(e)?n(ho(e)):f(e)&&!(0,K.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},bo=(e,t,n,r)=>{if(!e)return``;let i=``,a=_o(e),s=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(d(e)){i+=`${e}`;return}if((0,K.isValidElement)(e)){let{props:o,type:c}=e,l=Object.keys(o).length,u=s.indexOf(c)>-1,f=o.children;if(!f&&u&&!l){i+=`<${c}/>`;return}if(!f&&(!u||l)||o.i18nIsDynamicList){i+=`<${a}></${a}>`;return}if(u&&l<=1){let e=d(f)?f:bo(f,t,n,r);i+=`<${c}>${e}</${c}>`;return}let p=bo(f,t,n,r);i+=`<${a}>${p}</${a}>`;return}if(e===null){o(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(f(e)){let{format:t,...a}=e,s=Object.keys(a);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];i+=`{{${e}}}`;return}o(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}o(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},xo=(e,t,n,r,i,a,o)=>{if(n===``)return[];let s=i.transKeepBasicHtmlNodesFor||[],c=n&&new RegExp(s.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!c&&!o)return[n];let l=t??{},u=e=>{_o(e).forEach(e=>{d(e)||(mo(e)?u(ho(e)):f(e)&&!(0,K.isValidElement)(e)&&Object.assign(l,e))})};u(e);let m=Object.keys(l),g=po.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||s.indexOf(e)>-1||m.indexOf(e)>-1}),_={...l,...a},v=(e,t,n)=>{let r=ho(e),i=b(r,t.children,n);return go(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},y=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,K.cloneElement)(e,{key:r},i?void 0:t))):n.push(...K.Children.map([e],e=>{if(e.type===K.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),(0,K.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),(0,K.cloneElement)(e,n,i?null:t)}))},b=(e,n,a)=>{let l=_o(e),u=_o(n),m={};return u.reduce((e,n,u)=>{let g=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,_,r.language);if(n.type===`tag`){let h=l[parseInt(n.name,10)];!h&&t&&(h=t[n.name]),a.length===1&&!h&&(h=a[0][n.name]),h||={};let x={...n.attrs};o&&Object.keys(x).forEach(e=>{let t=x[e];d(t)&&(x[e]=p(t))});let S=Object.keys(x).length===0?h:vo({props:x},h),C=(0,K.isValidElement)(S),w=C&&mo(n,!0)&&!n.voidElement,T=c&&f(S)&&S.dummy&&!C,E=f(t)&&Object.hasOwnProperty.call(t,n.name);if(d(S)){let t=r.services.interpolator.interpolate(S,_,r.language);e.push(t)}else if(mo(S)||w){let t=v(S,n,a);y(S,t,e,u)}else if(T){let t=b(l,n.children,a);y(S,t,e,u)}else if(Number.isNaN(parseFloat(n.name)))if(E){let t=v(S,n,a);y(S,t,e,u,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&s.indexOf(n.name)>-1)if(n.voidElement)e.push((0,K.createElement)(n.name,{key:`${n.name}-${u}`}));else{let t=m[n.name]||0;m[n.name]=t+1;let r,i=0;for(let e=0;e<l.length;e+=1){let a=l[e];if((0,K.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let o=r?_o(ho(r)):l,s=b(o,n.children,a);e.push((0,K.createElement)(n.name,{key:`${n.name}-${u}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=b(l,n.children,a);e.push(`<${n.name}>${t}</${n.name}>`)}else if(f(S)&&!C){let t=n.children[0]?g:null;t&&e.push(t)}else y(S,g,e,u,n.children.length!==1||!g)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:h().unescape,s=o?a(r.services.interpolator.interpolate(n.content,_,r.language)):r.services.interpolator.interpolate(n.content,_,r.language);t?e.push((0,K.createElement)(t,{key:`${n.name}-${u}`},s)):e.push(s)}return e},[])};return ho(b([{dummy:!0,children:e||[]}],g,_o(e||[]))[0])},So=(e,t,n)=>{let r=e.key||t,i=(0,K.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,K.createElement)(K.Fragment,null,i)}return(0,K.createElement)(a,{key:r})},Co=(e,t)=>e.map((e,n)=>So(e,n,t)),wo=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:So(e[r],r,t)})}),n},To=(e,t,n,r)=>e?Array.isArray(e)?Co(e,t):f(e)?wo(e,t):(b(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,Eo=e=>!f(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function Do({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:l,ns:f,i18n:p,t:m,shouldUnescape:g,..._}){let v=p||u();if(!v)return b(v,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:r}),e;let y=m||v.t.bind(v)||(e=>e),x={...h(),...v.options?.react},S=f||y.ns||v.options?.defaultNS;S=d(S)?[S]:S||[`translation`];let{transDefaultProps:C}=x,w=C?.tOptions?{...C.tOptions,...a}:a,T=g??C?.shouldUnescape,E=C?.values?{...C.values,...o}:o,D=C?.components?{...C.components,...l}:l,O=bo(e,x,v,r),k=s||w?.defaultValue||O||x.transEmptyNodeValue||(typeof r==`function`?c(r):r),{hashTransKey:A}=x,j=r||(A?A(O||k):O||k);o=v.options?.interpolation?.defaultVariables?E&&Object.keys(E).length>0?{...E,...v.options.interpolation.defaultVariables}:{...v.options.interpolation.defaultVariables}:E;let M=yo(e);M&&typeof M.count==`number`&&t===void 0&&(t=M.count);let N=o||t!==void 0&&!v.options?.interpolation?.alwaysFormat||!e?w.interpolation:{interpolation:{...w.interpolation,prefix:`#$?`,suffix:`?$#`}},P={...w,context:i||w.context,count:t,...o,...N,defaultValue:k,ns:S},F=j?y(j,P):k;F===j&&k&&(F=k);let I=To(D,F,v,r),L=I||e,ee=null;Eo(I)&&(ee=I,L=e);let R=xo(L,ee,F,v,x,P,T),z=n??x.defaultTransParent;return z?(0,K.createElement)(z,_,R):R}function Oo({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:c,ns:d,i18n:f,t:p,shouldUnescape:m,...h}){let{i18n:g,defaultNS:_}=(0,K.useContext)(l)||{},v=f||g||u(),y=p||v?.t.bind(v);return Do({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:c,ns:d||y?.ns||_||v?.options?.defaultNS,i18n:v,t:p,shouldUnescape:m,...h})}function ko({i18n:e,defaultNS:t,children:n}){let r=(0,K.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,K.createElement)(l.Provider,{value:r},n)}var Ao=r(),jo=[],Mo={error:null,hasNextPage:!1,isFetchingNextPage:!1,isPending:!0};async function No(e,t){await e.get(t)?.fetchNextPage()}var Po=(0,K.createContext)(void 0),Fo=(0,K.createContext)(void 0),Io=(0,K.createContext)(void 0),Lo=(0,K.createContext)(void 0);function Ro({client:e,onRemove:t,onUpdate:n,projectId:r}){let i=Za(mt(r,e)),a=(0,K.useMemo)(()=>$e(i.data),[i.data]);return(0,K.useEffect)(()=>{n(r,{controller:{fetchNextPage:i.fetchNextPage},state:{error:i.error,hasNextPage:i.hasNextPage,isFetchingNextPage:i.isFetchingNextPage,isPending:i.isPending},tasks:a})},[n,r,i.error,i.fetchNextPage,i.hasNextPage,i.isFetchingNextPage,i.isPending,a]),(0,K.useEffect)(()=>()=>{t(r)},[t,r]),null}function zo(e,t){let n=e.flatMap(e=>t.get(e)?.tasks??jo);return{projectTaskStates:new Map(e.map(e=>[e,t.get(e)?.state??Mo])),tasks:n}}function Bo(){let e=(0,K.useContext)(Po);if(e===void 0)throw Error(`useProjectData must be used inside ProjectProvider`);return e}function Vo(){let e=(0,K.useContext)(Fo);if(e===void 0)throw Error(`useProjectActions must be used inside ProjectProvider`);return e}function Ho(){let e=(0,K.useContext)(Io);if(e===void 0)throw Error(`useProjectActivity must be used inside ProjectProvider`);return e}function Uo(){let e=(0,K.useContext)(Lo);if(e===void 0)throw Error(`useProjectRootSelection must be used inside ProjectProvider`);return e}function Wo(e){let{client:t,projects:n}=Bo(),r=e.length>0,i=Xa({queries:[Re,...n.map(e=>e.id)].map(e=>nt(e,r,t))}),a=r&&i.some(e=>e.isPending),o=i.find(e=>e.error!==null)?.error??null;return{error:o,isPending:a,tasks:a||o!==null?jo:i.flatMap(e=>e.data??jo).filter(t=>t.title.toLocaleLowerCase().includes(e))}}function Go(){let{client:e,projects:t}=Bo(),n=Xa({queries:[Re,...t.map(e=>e.id)].map(t=>xt(t,e))});return{error:n.find(e=>e.error!==null)?.error??null,isPending:n.some(e=>e.isPending),tasks:n.flatMap(e=>e.data??jo)}}function Ko(e){return e instanceof Error&&e.message.trim().length>0?e.message:typeof e==`string`&&e.trim().length>0?e:`Unknown internal error`}function qo(e,t,n={}){console.warn(`Codexly internal warning`,{diagnosticCode:e,errorMessage:Ko(t),...n})}var Jo=256;function Yo(){if(globalThis.Notification===void 0)return;let e=globalThis.Notification;return{getPermission:()=>e.permission,requestPermission:()=>e.requestPermission(),show(t,n){let r=new e(t,n);return{addClickListener(e){r.addEventListener(`click`,e)},close(){r.close()}}}}}function Xo(e){return`${e.taskId}:${e.turnId}`}function Zo(e,t){switch(t.type){case`turn.completed`:{let n=t.payload.turn.status===`completed`?S.t(`notification.completed`,{ns:`conversation`}):t.payload.turn.status===`interrupted`?S.t(`notification.interrupted`,{ns:`conversation`}):t.payload.turn.status===`failed`?S.t(`notification.failed`,{ns:`conversation`}):void 0;return n===void 0?void 0:{body:n,tag:`${e}:${t.taskId}:${t.turnId}:terminal`}}case`provider.error`:return t.payload.willRetry?void 0:{body:S.t(`notification.failedWithMessage`,{message:t.payload.message,ns:`conversation`}),tag:`${e}:${t.taskId}:${t.turnId}:terminal`};case`pending_request.created`:return{body:t.payload.request.type===`user_input`?S.t(`notification.waitingInput`,{ns:`conversation`}):S.t(`notification.waitingApproval`,{ns:`conversation`}),tag:`${e}:${t.taskId}:${t.payload.request.requestId}:request`};default:return}}var Qo=class{#e;#t=new Set;#n;#r;#i;#a;#o;constructor(e){this.#e=e.api,this.#n=e.focusPage??(()=>{globalThis.window.focus()}),this.#r=e.isEnabled??(()=>!0),this.#i=e.isPageForeground??(()=>globalThis.document.visibilityState===`visible`&&globalThis.document.hasFocus()),this.#a=e.navigateToTask??(()=>void 0)}notify(e,t,n){if(!this.#r()||this.#e?.getPermission()!==`granted`||this.#i())return;if(t.type===`provider.error`&&!t.payload.willRetry){let e=Xo(t);if(this.#t.has(e))return;if(this.#t.size>=Jo){let e=this.#t.values().next().value;e!==void 0&&this.#t.delete(e)}this.#t.add(e)}else if(t.type===`turn.completed`&&this.#t.delete(Xo(t)))return;let r=Zo(e,t);if(r!==void 0)try{let i=n.trim()||`Task`,a=this.#e.show(`Codexly · ${i}`,{body:r.body,data:{projectId:e,taskId:t.taskId},tag:r.tag});a.addClickListener(()=>{a.close(),this.#n(),this.#a(e,t.taskId)})}catch(n){qo(`browser_notification_show_failed`,n,{projectId:e,taskId:t.taskId})}}requestPermission(){if(!this.#r()||this.#e===void 0)return Promise.resolve();if(this.#o!==void 0)return this.#o;let e;try{if(this.#e.getPermission()!=="default")return Promise.resolve();e=this.#e.requestPermission()}catch(e){return qo(`notification_permission_failed`,e),Promise.resolve()}return this.#o=e.then(()=>void 0).catch(e=>{qo(`notification_permission_failed`,e)}).finally(()=>{this.#o=void 0}),this.#o}};function $o(e={}){return new Qo({...e,api:e.api??Yo()})}var es={attention:null,isAwaitingApproval:!1,isRunning:!1};function ts(e,t){return`${e}\u0000${t}`}function ns(e){return e.type===`command_approval`||e.type===`file_change_approval`||e.type===`permissions_approval`||e.type===`mcp_elicitation`}function rs(e){return new Set(e.filter(e=>e.status===`pending`&&ns(e)).map(e=>e.requestId))}function is(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function as(e,t,n,r){let i=ts(t,n),a=e.get(i);if(a?.attention===r.attention&&a.isRunning===r.isRunning&&is(a.pendingApprovalRequestIds,r.pendingApprovalRequestIds))return e;let o=new Map(e);return o.set(i,r),o}function os(e,t,n){return as(e,t,n,{attention:null,isRunning:!0,pendingApprovalRequestIds:e.get(ts(t,n))?.pendingApprovalRequestIds??new Set,projectId:t,taskId:n})}function ss(e,t,n){let r=e.get(ts(t,n));return r===void 0?es:{attention:r.attention,isAwaitingApproval:r.pendingApprovalRequestIds.size>0,isRunning:r.isRunning}}function cs(e,t,n){let r=e.get(ts(t,n));return r?.attention===void 0||r.attention===null?e:as(e,t,n,{...r,attention:null})}function ls(e,t){for(let n of e.values())if(n.projectId===t&&(n.isRunning||n.pendingApprovalRequestIds.size>0))return!0;return!1}function us(e,t){let n=[];for(let r of e.values())r.projectId===t&&(r.isRunning||r.pendingApprovalRequestIds.size>0)&&n.push(r.taskId);return n}function ds(e,t,n){let r=ts(t,n);if(!e.has(r))return e;let i=new Map(e);return i.delete(r),i}function fs(e,t,n=!1){let r=e.get(ts(t.projectId,t.id)),i=rs(t.pendingRequests),a=n?null:i.size>0?`approval`:t.status===`running`?null:r?.attention===`completed`||r?.attention===`failed`?r.attention:null;return as(e,t.projectId,t.id,{attention:a,isRunning:t.status===`running`,pendingApprovalRequestIds:i,projectId:t.projectId,taskId:t.id})}function ps(e,t,n,r=!1){let i=ts(t,n.taskId),a=e.get(i)??{attention:null,isRunning:!1,pendingApprovalRequestIds:new Set,projectId:t,taskId:n.taskId},o=a.attention,s=a.isRunning,c=a.pendingApprovalRequestIds;switch(n.type){case`turn.started`:o=null,s=!0;break;case`task.status_updated`:s=n.payload.status===`running`,s&&(o=null);break;case`turn.completed`:o=r?null:n.payload.turn.status===`failed`||n.payload.turn.status===`interrupted`?`failed`:`completed`,s=!1,c=new Set;break;case`provider.error`:n.payload.willRetry||(o=r?null:`failed`,s=!1,c=new Set);break;case`pending_request.created`:ns(n.payload.request)&&(o=r?null:`approval`,c=new Set(c).add(n.payload.request.requestId));break;case`pending_request.resolved`:case`pending_request.expired`:if(c.has(n.payload.request.requestId)){let e=new Set(c);e.delete(n.payload.request.requestId),c=e,e.size===0&&o===`approval`&&(o=null)}break;default:return e}return as(e,t,n.taskId,{attention:o,isRunning:s,pendingApprovalRequestIds:c,projectId:t,taskId:n.taskId})}var ms=new TextEncoder,hs=32,gs=8,_s=48,vs=16,ys=16;function bs(e){return ms.encode(e).byteLength}function X(e){let t=new WeakSet;function n(e){if(e==null)return 8;if(typeof e==`string`)return ys+bs(e);if(typeof e==`number`||typeof e==`bigint`)return 8;if(typeof e==`boolean`)return 4;if(typeof e==`symbol`||typeof e==`function`)return 16;if(t.has(e))return 0;if(t.add(e),Array.isArray(e)){let t=hs+e.length*gs;for(let r of e)t+=n(r);return t}let r=_s;for(let[t,i]of Object.entries(e))r+=vs+bs(t)+n(i);return r}return n(e)}var xs=class{#e=new Map;#t;#n;#r;#i;#a=0;constructor(e){if(!Number.isSafeInteger(e.maxBytes)||e.maxBytes<0)throw RangeError(`Byte LRU maxBytes must be a non-negative safe integer`);let t=e.maxEntries??2**53-1;if(!Number.isSafeInteger(t)||t<0)throw RangeError(`Byte LRU maxEntries must be a non-negative safe integer`);this.#t=e.getRetainedBytes,this.#n=e.maxBytes,this.#r=t,this.#i=e.onEvict}get retainedBytes(){return this.#a}get size(){return this.#e.size}delete(e){let t=this.#e.get(e);return t===void 0?!1:(this.#e.delete(e),this.#a-=t.retainedBytes,!0)}get(e){let t=this.#e.get(e);if(t!==void 0)return this.#e.delete(e),this.#e.set(e,t),t.value}peek(e){return this.#e.get(e)?.value}set(e,t){let n=this.#t(e,t);if(!Number.isSafeInteger(n)||n<0)throw RangeError(`Byte LRU entry size must be a non-negative safe integer`);let r=this.#e.get(e);return r!==void 0&&(this.#e.delete(e),this.#a-=r.retainedBytes,this.#i?.(e,r.value,`replaced`)),n>this.#n||this.#r===0?!1:(this.#e.set(e,{retainedBytes:n,value:t}),this.#a+=n,this.#o(),this.#e.has(e))}#o(){for(;this.#e.size>this.#r||this.#a>this.#n;){let e=this.#e.entries().next().value;if(e===void 0)return;let[t,n]=e;this.#e.delete(t),this.#a-=n.retainedBytes,this.#i?.(t,n.value,this.#e.size>=this.#r?`entries`:`bytes`)}}},Ss=1e3,Cs=3e4,ws=class{#e=0;#t;#n=0;#r;#i;#a=0;#o=0;constructor(e){if(!Number.isSafeInteger(e.maxBytes)||e.maxBytes<0)throw RangeError(`Project Event history maxBytes must be non-negative`);if(!Number.isSafeInteger(e.maxEvents)||e.maxEvents<0)throw RangeError(`Project Event history maxEvents must be non-negative`);this.#r=e.maxBytes,this.#i=e.maxEvents,this.#t=Array(e.maxEvents)}get floorSequence(){return this.#n}append(e){let t=X(e);if(t>this.#r||this.#i===0){this.reset(e.sequence);return}this.#e===this.#i&&this.#s();let n=(this.#o+this.#e)%this.#i;for(this.#t[n]={event:e,retainedBytes:t},this.#e+=1,this.#a+=t;this.#a>this.#r;)this.#s()}forEachAfter(e,t){for(let n=0;n<this.#e;n+=1){let r=this.#t[(this.#o+n)%this.#i];r!==void 0&&r.event.sequence>e&&t(r.event)}}reset(e=this.#n){this.#t=Array(this.#i),this.#e=0,this.#n=e,this.#a=0,this.#o=0}#s(){let e=this.#t[this.#o];e!==void 0&&(this.#t[this.#o]=void 0,this.#o=(this.#o+1)%this.#i,--this.#e,this.#a-=e.retainedBytes,this.#n=e.event.sequence)}};function Ts(e){return e.type===`message.delta`||e.type===`plan.delta`||e.type===`reasoning.delta`||e.type===`command.output_delta`}function Es(e,t){return`${e}\u0000${t}`}function Ds(e,t,n){return`${Es(e,t)}\u0000${n}`}var Os=1048576,ks=1e3,As=new TextEncoder;function js(e){let t=e.items.map(e=>{if(e.type!==`message`||e.role!==`user`||(e.skills?.length??0)===0)return e;let t=Se(e.text,e.skills??[]);return t===e.text?e:{...e,text:t}});return t.some((t,n)=>t!==e.items[n])?{...e,items:t}:e}function Ms(e,t,n){let r=js(t),i=r.items.find(e=>e.type===`message`&&e.role===`user`);if(n.text.length===0&&n.skills.length===0&&n.attachments.length===0&&i===void 0)return e;let a=e.turns.findIndex(e=>e.id===r.id),o=e.turns[a],s=js(o??r),c=s.items.findIndex(e=>e.type===`message`&&e.role===`user`),l=s.items[c],u=c>=0;if(a>=0&&l?.type===`message`){if((l.attachments?.length??0)>0||(n.messageAttachments?.length??0)===0){if(s===o)return e;let t=[...e.turns];return t[a]=s,{...e,turns:t}}let t=[...e.turns],r=[...s.items];return r[c]={...l,attachments:[...n.messageAttachments??[]],...n.text.length===0?{text:``}:{}},t[a]={...s,items:r},{...e,turns:t}}let d=u?s:{...s,items:[i??{id:`submitted-user-${t.id}`,role:`user`,...n.skills.length===0?{}:{skills:n.skills.map(e=>({name:e.name}))},...(n.messageAttachments?.length??0)===0?{}:{attachments:[...n.messageAttachments??[]]},text:n.text,type:`message`},...s.items]};if(a<0)return{...e,status:`running`,turns:[...e.turns,d]};let f=[...e.turns];return f[a]=d,{...e,turns:f}}function Ns(e){return e.type===`message.delta`||e.type===`plan.delta`||e.type===`reasoning.delta`||e.type===`command.output_delta`}function Ps(e){let t=e.type===`reasoning.delta`?`${e.payload.field}:${String(e.payload.sectionIndex??-1)}`:`value`;return`${e.taskId}:${e.turnId}:${e.itemId}:${e.type}:${t}`}var Fs=class{#e;#t;#n=[];#r=0;constructor(e={}){if(this.#e=e.maxBytes??Os,this.#t=e.maxEvents??ks,!Number.isInteger(this.#e)||this.#e<=0)throw RangeError(`Agent Event buffer maxBytes must be a positive integer`);if(!Number.isInteger(this.#t)||this.#t<=0)throw RangeError(`Agent Event buffer maxEvents must be a positive integer`)}push(e){if(!Ns(e))throw TypeError(`Only Agent Event deltas can be buffered`);let t=Ps(e),n=this.#n.at(-1),r=n?.event,i=r!==void 0&&Ps(r)===t,a=As.encode(e.payload.delta).byteLength;return this.#n.length+ +!i>this.#t||this.#r+a>this.#e?(this.#n.length=0,this.#r=0,!1):(this.#r+=a,i?(this.#n[this.#n.length-1]={event:{...e,payload:{...e.payload,delta:`${r.payload.delta}${e.payload.delta}`}},retainedBytes:(n?.retainedBytes??0)+a},!0):(this.#n.push({event:e,retainedBytes:a}),!0))}drain(){return this.flushThrough(1/0)}flushThrough(e){let t=this.#n.findIndex(({event:t})=>t.sequence>=e),n=t<0?this.#n.length:t,r=this.#n.splice(0,n);for(let e of r)this.#r-=e.retainedBytes;return r.map(({event:e})=>e)}},Is=4,Ls=class{#e;#t=new Set;#n;#r=!1;#i=0;#a=!1;#o;constructor(e,t){this.#n=e,this.#e=t}dispose(){this.#r=!0,this.#t.clear(),this.#s()}forgetTask(e){this.#t.delete(e),this.#c()}markRecovered(e){this.#t.delete(e),this.#c()}requestRecovery(e){if(!this.#r){for(let t of e)t.length>0&&this.#t.add(t);this.#t.size>0&&!this.#a&&this.#o===void 0&&this.#u()}}#s(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0)}#c(){this.#t.size>0||this.#a||(this.#s(),this.#i=0)}#l(){if(this.#r||this.#t.size===0){this.#c();return}let e=Math.min(Ss*2**this.#i,Cs);this.#i+=1,this.#o=setTimeout(()=>{this.#o=void 0,this.#u()},e)}#u(){if(this.#r||this.#a||this.#t.size===0)return;this.#a=!0;let e=[...this.#t],t=0,n=async()=>{for(;!this.#r;){let n=e[t];if(t+=1,n===void 0)return;if(!this.#t.has(n))continue;let r;try{r=await this.#n(n)}catch(e){qo(`snapshot_recovery_failed`,e);continue}if(!(r===void 0||!this.#t.delete(n)))try{this.#e(n,r)}catch(e){this.#t.add(n),qo(`snapshot_recovery_failed`,e)}}},r=Math.min(Is,e.length);Promise.all(Array.from({length:r},n)).then(()=>{if(this.#a=!1,!this.#r){if(this.#t.size===0){this.#i=0;return}this.#l()}})}},Rs=class{#e;#t;#n;#r=0;#i=0;#a=`ready`;#o;constructor(e,t,n=()=>void 0){this.#n=e,this.#e=t,this.#t=n}get isReady(){return this.#a===`ready`}dispose(){this.#a=`disposed`,this.#i+=1,this.#s()}requestRecovery(){this.#a===`ready`&&this.#l()}reset(){this.#a!==`disposed`&&(this.#s(),this.#r=0,this.#i+=1,this.#a=`ready`)}#s(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0)}#c(){if(this.#a===`disposed`)return;this.#a=`waiting_to_retry`;let e=Math.min(Ss*2**this.#r,Cs);this.#r+=1,this.#o=setTimeout(()=>{this.#o=void 0,this.#l()},e)}#l(){if(this.#a===`disposed`)return;this.#a=`recovering`,this.#t();let e=this.#i,t;try{t=Promise.resolve(this.#n())}catch(t){qo(`snapshot_recovery_failed`,t),e===this.#i&&this.#c();return}t.then(t=>{if(!(this.#a!==`recovering`||e!==this.#i)){if(t===void 0){this.#c();return}this.#e(t)}}).catch(t=>{qo(`snapshot_recovery_failed`,t),this.#a===`recovering`&&e===this.#i&&this.#c()})}},zs=class{#e=new Fs;#t;#n=new Set;#r;#i;#a;constructor(e,t,n){this.#i=e,this.#n.add(t),this.#t=n,this.#r=new Rs(async()=>this.#n.values().next().value?.(),e=>{this.#t(e,this)},()=>{this.#i.getState().setConnectionState(`reconnecting`)})}get sessionId(){return this.#i.getState().checkpoint?.sessionId}get taskId(){return this.#i.getState().taskId}addConsumer(e){this.#n.add(e)}removeConsumer(e){return this.#n.delete(e),this.#n.size}resetForSnapshot(){this.#a!==void 0&&(cancelAnimationFrame(this.#a),this.#a=void 0),this.#e.drain(),this.#r.reset()}apply(e){if(this.#r.isReady){if(Ts(e)){if(this.#a===void 0){this.#a=requestAnimationFrame(()=>{this.#a=void 0;let e=this.#e.drain();e.length>0&&this.#i.getState().applyEvents(e)}),this.#i.getState().applyEvents([e]);return}if(!this.#e.push(e)){this.requestRecovery();return}return}this.#o(e.sequence),this.#i.getState().applyEvents([e])}}dispose(){this.#r.dispose(),this.#a!==void 0&&(cancelAnimationFrame(this.#a),this.#a=void 0),this.#e.drain()}requestRecovery(){this.#r.isReady&&(this.#a!==void 0&&(cancelAnimationFrame(this.#a),this.#a=void 0),this.#e.drain(),this.#r.requestRecovery())}setConnectionState(e){let t=e===`connected`&&!this.#r.isReady?`reconnecting`:e;this.#i.getState().setConnectionState(t),t===`connected`&&this.#i.getState().setError(null)}#o(e){this.#a!==void 0&&(cancelAnimationFrame(this.#a),this.#a=void 0),this.#i.getState().applyEvents(this.#e.flushThrough(e))}},Bs=1e3,Vs=3e4,Hs=class{#e;#t=new Map;#n;#r;#i=!1;constructor(e,t,n){this.#e=t,this.#n=n,this.#r=e}cancel(e){let t=this.#t.get(e);t?.timer!==void 0&&clearTimeout(t.timer),this.#t.delete(e)}dispose(){this.#i=!0;for(let e of this.#t.keys())this.cancel(e)}request(e){if(this.#i||this.#t.has(e))return;let t={attempt:0,timer:void 0};this.#t.set(e,t),this.#a(e,t)}async#a(e,t){try{let n=await this.#e.unsubscribeTask(this.#r,e);if(this.#i||this.#t.get(e)!==t)return;if(n.status!==`busy`){this.#t.delete(e);return}let r=Math.min(Bs*2**t.attempt,Vs);t.attempt+=1,t.timer=setTimeout(()=>{t.timer=void 0,this.#a(e,t)},r)}catch(n){this.#t.get(e)===t&&(this.#t.delete(e),this.#n(n,e))}}},Us=class{#e;#t;#n;#r;#i;#a;#o;#s=new Map;#c;#l=`closed`;#u=!1;#d;#f=Date.now();#p=0;#m;#h=!1;constructor(e,t,n,r){this.#i=e,this.#t=t,this.#e=n,this.#r=r.idleTimeoutMs,this.#n=new ws({maxBytes:r.maxEventHistoryBytes,maxEvents:r.maxEventHistoryEvents}),this.#a=new Ls(async e=>this.#t.readTask(this.#i,e),(e,t)=>{this.#e.onSnapshot(t)}),this.#o=new Hs(e,t,(t,n)=>{qo(`task_unsubscribe_failed`,t,{projectId:e,taskId:n})})}attachTaskStore(e,t,n){this.#_(e),this.#o.cancel(e.snapshot.id);let r=t.getState();if(r.projectId!==this.#i||r.taskId!==e.snapshot.id)throw Error(`Task store identity does not match the Project Runtime snapshot`);this.#D(),r.reconcile(e);let i=this.#s.get(t);i===void 0?(i=new zs(t,n,(e,n)=>{this.#S(e,t,n)}),this.#s.set(t,i)):i.addConsumer(n),i.resetForSnapshot(),i.setConnectionState(this.#l===`closed`?`connecting`:this.#l),this.observeSnapshot(e),this.#w(e.checkpoint,i);let a=!0;return()=>{if(!a)return;a=!1;let e=this.#s.get(t);e!==i||e.removeConsumer(n)>0||(e.dispose(),this.#s.delete(t),this.#o.request(t.getState().taskId),this.#D(),this.#C())}}dispose(){if(!this.#u){this.#u=!0,this.#y(),this.#a.dispose(),this.#o.dispose(),this.#E();for(let e of this.#s.values())e.dispose();this.#s.clear(),this.#v()}}forgetTask(e){this.#o.cancel(e),this.#a.forgetTask(e),this.#C()}markAccess(){this.#D(),this.#C()}observeSnapshot(e){this.#_(e),this.#a.markRecovered(e.snapshot.id),this.#h=!1,this.#D(),this.#b(e.checkpoint);for(let t of this.#s.values())t.sessionId===e.checkpoint.sessionId?t.setConnectionState(this.#l):t.requestRecovery();this.#C()}reconcileTaskSnapshot(e){this.#_(e);let t=[];for(let[n,r]of this.#s)n.getState().taskId===e.snapshot.id&&(n.getState().reconcile(e),r.resetForSnapshot(),t.push(r));this.observeSnapshot(e);for(let n of t)n.setConnectionState(this.#l),this.#w(e.checkpoint,n)}#g(e){this.#n.append(e)}#_(e){if(e.snapshot.projectId!==this.#i)throw Error(`Snapshot Project does not match the Project Runtime`)}#v(){this.#n.reset()}#y(){this.#d!==void 0&&(clearTimeout(this.#d),this.#d=void 0)}#b(e){if(this.#u||this.#c!==void 0&&this.#m===e.sessionId)return;this.#E(),this.#m=e.sessionId,this.#p=e.sequence,this.#n.reset(e.sequence);let t=this.#t.subscribeEvents({afterSequence:e.sequence,onConnectionState:e=>{this.#l=e,e===`reconnecting`&&(this.#h=!0);let t=e===`closed`&&this.#h?`reconnecting`:e;for(let e of this.#s.values())e.setConnectionState(t);e===`reconnecting`&&this.#T()},onError:e=>{qo(`event_connection_failed`,e,{projectId:this.#i})},onEvent:e=>{this.#p=e.sequence,this.#g(e),this.#e.onActivityEvent(this.#i,e);for(let[t,n]of this.#s)t.getState().taskId===e.taskId&&n.apply(e);e.type===`turn.completed`&&!this.#x(e.taskId)&&this.#o.request(e.taskId),this.#C()},onResyncRequired:()=>{this.#h=!0,this.#E(),this.#l=`reconnecting`;for(let e of this.#s.values())e.setConnectionState(`reconnecting`);this.#T()},projectId:this.#i,sessionId:e.sessionId});this.#c=t}#x(e){for(let t of this.#s.keys())if(t.getState().taskId===e)return!0;return!1}#S(e,t,n){if(this.#s.get(t)!==n)return;this.#_(e);let r=t.getState();if(r.projectId!==this.#i||r.taskId!==e.snapshot.id)throw Error(`Task store identity does not match the recovered snapshot`);r.reconcile(e),n.resetForSnapshot(),this.#e.onSnapshot(e),this.#w(e.checkpoint,n)}#C(){if(this.#y(),this.#u||this.#c===void 0||this.#s.size>0||ls(this.#e.getTaskActivity(),this.#i))return;let e=this.#r-(Date.now()-this.#f);if(e<=0){this.dispose(),this.#e.onIdle(this);return}this.#d=setTimeout(()=>{this.#d=void 0,this.#C()},e)}#w(e,t){if(e.sessionId!==this.#m){t.requestRecovery();return}if(e.sequence<this.#n.floorSequence&&e.sequence<this.#p){t.requestRecovery();return}this.#n.forEachAfter(e.sequence,e=>{e.taskId===t.taskId&&t.apply(e)})}#T(){let e=new Set;for(let t of this.#s.values())e.add(t.taskId),t.requestRecovery();let t=us(this.#e.getTaskActivity(),this.#i).filter(t=>!e.has(t));this.#a.requestRecovery(t)}#E(){let e=this.#c;this.#c=void 0;try{e?.()}catch(e){qo(`event_connection_cleanup_failed`,e,{projectId:this.#i})}this.#l=`closed`}#D(){this.#f=Date.now(),this.#y()}},Ws=class{#e=new Set;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d=new Map;#f;#p=new Map;#m=new Map;#h=new Set;#g;client;constructor(e,t={}){if(this.client=e,this.#t=t.idleTimeoutMs??12e4,this.#n=t.maxEventHistoryBytes??4194304,this.#r=t.maxEventHistoryEvents??2048,this.#i=t.onMcpServerStatusChanged??(()=>void 0),this.#a=t.onProjectGitActivity??(()=>void 0),this.#o=t.onProjectGitMetadataChanged??(()=>void 0),this.#s=t.onQueueChanged??(()=>void 0),this.#c=t.onSkillsChanged??(()=>void 0),this.#l=t.onTaskRemoved??(()=>void 0),this.#u=t.onTaskMetadataChanged??(()=>void 0),this.#f=t.taskNotifier??$o(),!Number.isSafeInteger(this.#t)||this.#t<0)throw RangeError(`Project Runtime idleTimeoutMs must be non-negative`);if(!Number.isSafeInteger(this.#n)||this.#n<0)throw RangeError(`Project Runtime maxEventHistoryBytes must be non-negative`);if(!Number.isSafeInteger(this.#r)||this.#r<0)throw RangeError(`Project Runtime maxEventHistoryEvents must be non-negative`)}attachTaskStore(e,t,n){return this.#x(e.snapshot),this.#b(e.snapshot),this.#_(e.snapshot.projectId).attachTaskStore(e,t,n)}dispose(){for(let e of this.#d.values())e.dispose();this.#d.clear(),this.#e.clear(),this.#m.clear(),this.#h.clear()}forgetTask(e,t){this.#v(ds(this.#p,e,t)),this.#m.delete(Es(e,t)),this.#d.get(e)?.forgetTask(t)}forgetProject(e){this.#d.get(e)?.dispose(),this.#d.delete(e);let t=this.#p;for(let n of this.#p.values())n.projectId===e&&(t=ds(t,e,n.taskId));this.#v(t);let n=`${e}\u0000`;for(let e of this.#m.keys())e.startsWith(n)&&this.#m.delete(e);for(let e of this.#h)e.startsWith(n)&&this.#h.delete(e);this.#g?.projectId===e&&(this.#g=void 0)}getTaskActivity(){return this.#p}markTaskRunning(e,t){this.#v(os(this.#p,e,t)),this.#a(e,t,`turn_started`),this.#d.get(e)?.markAccess()}observeSnapshot(e){this.#x(e.snapshot),this.#b(e.snapshot),this.#_(e.snapshot.projectId).observeSnapshot(e)}requestNotificationPermission(){return this.#f.requestPermission().catch(e=>{qo(`notification_permission_failed`,e)})}reconcileTaskSnapshot(e){this.#x(e.snapshot),this.#b(e.snapshot),this.#_(e.snapshot.projectId).reconcileTaskSnapshot(e)}async refreshTaskSnapshot(e,t){let n=await this.client.readTask(e,t);return this.reconcileTaskSnapshot(n),n}rememberTaskTitles(e){for(let t of e)this.#x(t)}viewTask(e,t){this.#g=t===void 0?void 0:{projectId:e,taskId:t},t!==void 0&&this.#v(cs(this.#p,e,t)),this.#d.get(e)?.markAccess()}subscribeTaskActivity(e){return this.#e.add(e),()=>{this.#e.delete(e)}}#_(e){let t=this.#d.get(e);return t===void 0?(t=new Us(e,this.client,{getTaskActivity:()=>this.#p,onActivityEvent:(e,t)=>{if(t.type===`project.git_metadata_changed`){this.#o(e,t.payload.rootPath);return}if(t.type===`skills.changed`?this.#c(e):t.type===`queue.changed`?this.#s(e,t.taskId):t.type===`task.metadata_changed`?this.#u(e,t.taskId,`native_notification`):t.type===`task.removed`?(this.#l(e,t.taskId),this.forgetTask(e,t.taskId)):t.type===`mcp_server.status_updated`?this.#i(e,t.taskId):t.type===`turn.started`?this.#a(e,t.taskId,`turn_started`):t.type===`item.completed`&&t.payload.item.type===`file_change`&&t.payload.item.status===`completed`&&this.#a(e,t.taskId,`file_changed`),t.type===`message.delta`){let n=Ds(e,t.taskId,t.turnId);if(!this.#h.has(n)){if(this.#h.add(n),this.#h.size>2048){let e=this.#h.values().next().value;e!==void 0&&this.#h.delete(e)}this.#u(e,t.taskId,`assistant_reply_started`)}}if(t.type===`turn.completed`){let n=Ds(e,t.taskId,t.turnId);this.#h.delete(n),this.#a(e,t.taskId,`turn_completed`),this.#u(e,t.taskId,`turn_completed`)}try{this.#f.notify(e,t,this.#m.get(Es(e,t.taskId))??`Task`)}catch(n){qo(`task_notification_failed`,n,{projectId:e,taskId:t.taskId})}this.#v(ps(this.#p,e,t,this.#y(e,t.taskId)))},onIdle:t=>{this.#d.get(e)===t&&this.#d.delete(e)},onSnapshot:e=>{this.observeSnapshot(e)}},{idleTimeoutMs:this.#t,maxEventHistoryBytes:this.#n,maxEventHistoryEvents:this.#r}),this.#d.set(e,t),t):t}#v(e){if(e!==this.#p){this.#p=e;for(let e of this.#e)e()}}#y(e,t){return this.#g?.projectId===e&&this.#g.taskId===t}#b(e){let t=ss(this.#p,e.projectId,e.id).isRunning,n=e.status===`running`;n!==t&&this.#a(e.projectId,e.id,n?`turn_started`:`turn_completed`),this.#v(fs(this.#p,e,this.#y(e.projectId,e.id)))}#x(e){let t=Es(e.projectId,e.id);if(this.#m.delete(t),this.#m.set(t,e.title),this.#m.size>2048){let e=this.#m.keys().next().value;e!==void 0&&this.#m.delete(e)}}};function Gs(e,t={}){return new Ws(e,t)}function Ks(){return typeof document>`u`||document.visibilityState===`visible`}var qs=class{#e;#t;#n;#r;#i=new Map;#a;#o;#s;#c;#l=!1;constructor(e,t,n={}){this.#a=e,this.#e=t,this.#t=n.fileChangeDebounceMs??300,this.#n=n.isPageVisible??Ks,this.#r=n.pollIntervalMs??3e5,this.#o=n.random??Math.random,this.#s=n.retryBaseMs??1e3,this.#c=n.retryMaxMs??3e4}dispose(){if(!this.#l){this.#l=!0;for(let e of this.#i.values())this.#p(e);this.#i.clear()}}forgetProject(e){for(let[t,n]of this.#i)n.projectId===e&&(this.#p(n),this.#i.delete(t))}handleActivity(e,t,n,r){if(this.#l)return;let i=this.#h(e,t);if(r===`turn_started`){let e=i.activeTaskIds.size===0,t=i.consecutiveFailures>0||i.retryTimer!==void 0;if(i.activeTaskIds.add(n),i.isGitProject===!1)return;e||t?(this.#f(i),this.#v(i)):this.#m(i);return}if(r===`file_changed`){if(i.activeTaskIds.add(n),this.#f(i),i.isGitProject===!1)return;this.#y(i);return}if(i.activeTaskIds.delete(n),this.#u(i),this.#f(i),i.activeTaskIds.size===0&&this.#d(i),i.isGitProject===!1){i.activeTaskIds.size===0&&this.#i.delete(this.#g(i.projectId,i.rootPath));return}this.#v(i)}handleGitMetadataChanged(e,t){if(this.#l)return;let n=this.#h(e,t);this.#f(n),this.#y(n)}async refreshProject(e,t){if(this.#l)return;let n=this.#h(e,t);this.#f(n),await this.#_(n,`manual`)}#u(e){e.fileChangeTimer!==void 0&&(clearTimeout(e.fileChangeTimer),e.fileChangeTimer=void 0)}#d(e){e.pollingTimer!==void 0&&(clearInterval(e.pollingTimer),e.pollingTimer=void 0)}#f(e){e.retryTimer!==void 0&&(clearTimeout(e.retryTimer),e.retryTimer=void 0)}#p(e){e.closed=!0,e.refreshPending=void 0,this.#u(e),this.#d(e),this.#f(e)}#m(e){e.closed||e.isGitProject!==!0||e.consecutiveFailures>0||e.activeTaskIds.size===0||e.pollingTimer!==void 0||e.retryTimer!==void 0||(e.pollingTimer=setInterval(()=>{this.#n()&&this.#v(e)},this.#r))}#h(e,t){let n=this.#g(e,t),r=this.#i.get(n);if(r!==void 0)return r;let i={activeTaskIds:new Set,closed:!1,consecutiveFailures:0,fileChangeTimer:void 0,inFlight:void 0,isGitProject:void 0,pollingTimer:void 0,projectId:e,rootPath:t,refreshPending:void 0,retryTimer:void 0};return this.#i.set(n,i),i}#g(e,t){return`${e}\u0000${t}`}#_(e,t){if(e.closed||this.#l)return Promise.resolve();if(e.inFlight!==void 0)return e.refreshPending=t===`manual`||e.refreshPending===`manual`?`manual`:`background`,e.inFlight;let n=at(e.projectId,e.rootPath,this.#e),r=this.#e.getProjectGitStatus(e.projectId,{rootPath:e.rootPath}).then(t=>{this.#a.setQueryData(n.queryKey,t),e.consecutiveFailures=0,e.isGitProject=t.repositoryMode!==`none`,e.isGitProject||(this.#u(e),this.#d(e),this.#f(e))}).catch(t=>{throw e.consecutiveFailures+=1,this.#d(e),t}).finally(()=>{if(e.closed||this.#l)return;e.inFlight=void 0;let t=e.refreshPending;if(e.refreshPending=void 0,t!==void 0&&(t===`manual`||e.isGitProject!==!1)){this.#v(e,t);return}if(e.activeTaskIds.size>0){e.consecutiveFailures>0?e.isGitProject!==!1&&this.#b(e):this.#m(e);return}e.activeTaskIds.size===0&&e.fileChangeTimer===void 0&&this.#i.delete(this.#g(e.projectId,e.rootPath))});return e.inFlight=r,r}#v(e,t=`background`){this.#_(e,t).catch(t=>{qo(`git_status_poll_failed`,t,{projectId:e.projectId,rootPath:e.rootPath})})}#y(e){this.#u(e),e.fileChangeTimer=setTimeout(()=>{e.fileChangeTimer=void 0,this.#v(e)},this.#t)}#b(e){if(e.closed||e.isGitProject===!1||e.activeTaskIds.size===0||e.retryTimer!==void 0)return;let t=Math.min(this.#c,this.#s*2**Math.min(e.consecutiveFailures-1,30)),n=Math.min(this.#c,Math.round(t*(.8+this.#o()*.4)));e.retryTimer=setTimeout(()=>{e.retryTimer=void 0,this.#n()?this.#v(e):this.#b(e)},n)}};function Js(e,t){if(e!==void 0)return e.roots.find(n=>t?.projectId===e.id&&n.id===t.rootId)??e.roots[0]}function Ys(e,t){if(e===void 0)return;let n=t.get(e.id);return Js(e,n===void 0?void 0:{projectId:e.id,rootId:n})}function Xs(e,t,n){return n?e.includes(t)?e:[...e,t]:e.filter(e=>e!==t)}function Zs(e){let t=t=>Ys(e.getProject(t),e.getSelectedRootIds());return{onProjectGitActivity(n,r,i){if(n===`temporary`)return;let a=t(n);a!==void 0&&e.coordinator.handleActivity(n,a.path,r,i)},onProjectGitMetadataChanged(n,r){t(n)?.path===r&&e.coordinator.handleGitMetadataChanged(n,r)}}}function Qs({actions:e,activity:t,children:n,client:r,data:i,onRemoveTaskQuery:a,onUpdateTaskQuery:o,projects:s,rootSelection:c}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ro,{client:r,onRemove:a,onUpdate:o,projectId:Re}),s.map(e=>(0,J.jsx)(Ro,{client:r,onRemove:a,onUpdate:o,projectId:e.id},e.id)),(0,J.jsx)(Po.Provider,{value:i,children:(0,J.jsx)(Fo.Provider,{value:e,children:(0,J.jsx)(Lo.Provider,{value:c,children:(0,J.jsx)(Io.Provider,{value:t,children:n})})})})]})}var $s=[];function ec({children:e,client:t=j,taskNotifier:n}){let r=Ee(),[i,a]=(0,K.useState)(()=>new Map),o=(0,K.useRef)(i);o.current=i;let s=(0,K.useCallback)((e,t)=>{a(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})},[]),c=(0,K.useMemo)(()=>new qs(r,t),[t,r]),l=(0,K.useMemo)(()=>{let e=new Map;return Gs(t,{...n===void 0?{}:{taskNotifier:n},...Zs({coordinator:c,getProject:e=>r.getQueryData([`projects`])?.data.find(t=>t.id===e),getSelectedRootIds:()=>o.current}),onMcpServerStatusChanged(e,t){r.invalidateQueries({exact:!0,queryKey:[`projects`,e,`tasks`,t,`mcp-servers`]})},onQueueChanged(e,t){rt(r,e,t)},onSkillsChanged(e){r.invalidateQueries({exact:!0,queryKey:[`projects`,e,`skills`]})},onTaskRemoved(e,t){ut(r,e,t),r.removeQueries({exact:!0,queryKey:[`projects`,e,`tasks`,t]})},onTaskMetadataChanged(n,i,a){let o=async()=>{(a===`turn_completed`||a===`native_notification`)&&await Promise.all([r.invalidateQueries({exact:!0,queryKey:[`projects`,n,`tasks`]}),r.invalidateQueries({exact:!0,queryKey:[`projects`,n,`tasks`,w]}),r.invalidateQueries({exact:!0,queryKey:[`projects`,n,`tasks`,de]})]),r.removeQueries({exact:!0,queryKey:[`projects`,n,`tasks`,i]});let e=await t.readTask(n,i);l.reconcileTaskSnapshot(e),Xe(r,e.snapshot,{assistantReplyStarted:a===`assistant_reply_started`})},s=`${n}\u0000${i}`,c=(e.get(s)??Promise.resolve()).catch(()=>void 0).then(o);e.set(s,c);let u=()=>{e.get(s)===c&&e.delete(s)};c.then(u,u)}})},[t,c,r,n]),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(()=>new Map),[m,h]=(0,K.useState)(),[g,_]=(0,K.useState)(()=>new Set),v=(0,K.useSyncExternalStore)((0,K.useCallback)(e=>l.subscribeTaskActivity(e),[l]),(0,K.useCallback)(()=>l.getTaskActivity(),[l]),(0,K.useCallback)(()=>l.getTaskActivity(),[l])),y=R(ht(t)),b=R(it(t)),{isPending:x,mutateAsync:C}=Ye(tt(t)),{isPending:T,mutateAsync:E}=Ye(Qe(t)),{isPending:D,mutateAsync:O}=Ye(ot(t)),k=(0,K.useRef)(Ue()),A=(0,K.useRef)(Ue()),M=(0,K.useRef)(Ue()),N=b.data?.data??$s,P=(0,K.useMemo)(()=>{let e=new Set(g);return m!==void 0&&e.add(m),e},[m,g]),F=(0,K.useMemo)(()=>N.filter(e=>P.has(e.id)),[N,P]),I=(0,K.useMemo)(()=>[Re,...F.map(e=>e.id)],[F]),L=(0,K.useRef)(f);L.current=f;let ee=(0,K.useCallback)((e,t)=>{l.rememberTaskTitles(t.tasks),p(n=>{let r=n.get(e);if(r?.tasks===t.tasks&&r.state.error===t.state.error&&r.state.hasNextPage===t.state.hasNextPage&&r.state.isFetchingNextPage===t.state.isFetchingNextPage&&r.state.isPending===t.state.isPending)return n;let i=new Map(n);return i.set(e,t),i})},[l]),z=(0,K.useCallback)(e=>{p(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),{projectTaskStates:B,tasks:V}=(0,K.useMemo)(()=>zo(I,f),[f,I]),te=(0,K.useCallback)(async e=>{await No(new Map([...L.current].map(([e,t])=>[e,t.controller])),e)},[]),H=b.isPending,U=(0,K.useCallback)((e,t)=>{l.markTaskRunning(e,t)},[l]),ne=(0,K.useCallback)((e,t)=>{l.forgetTask(e,t)},[l]),W=(0,K.useCallback)((e,t)=>{h(t=>t===e?t:e),l.viewTask(e,t)},[l]),re=(0,K.useCallback)(e=>{_(t=>t.size===e.size&&[...t].every(t=>e.has(t))?t:new Set(e))},[]),ie=(0,K.useCallback)(()=>{l.requestNotificationPermission()},[l]),ae=(0,K.useCallback)(e=>k.current.run(async()=>{d(!0);try{let n=await t.addProject(e);return r.setQueryData([`projects`],e=>{if(e===void 0)return{data:[n.project],nextCursor:null};let t=e.data.findIndex(e=>e.id===n.project.id);return t<0?{...e,data:[...e.data,n.project]}:{...e,data:e.data.map((e,r)=>r===t?n.project:e)}}),qe(),n.project}catch(e){Ge(e);return}finally{d(!1)}}),[t,r]),oe=(0,K.useCallback)(async e=>await M.current.run(async()=>{let t=r.getQueryData([`projects`]),n=lt(t,e);if(n===void 0)return Ge(Error(S.t(`errors.reorderProjectChanged`,{ns:`conversation`}))),!1;r.setQueryData([`projects`],n);try{let t=await C(e);return r.setQueryData([`projects`],t),!0}catch{return r.setQueryData([`projects`],t),!1}})??!1,[C,r]),se=(0,K.useCallback)(async(e,t)=>await A.current.run(async()=>{try{let n=await E({name:t,projectId:e});return r.setQueryData([`projects`],t=>t===void 0?void 0:{...t,data:t.data.map(t=>t.id===e?n.project:t)}),!0}catch{return!1}})??!1,[E,r]),ce=(0,K.useCallback)(e=>A.current.run(async()=>{try{await O(e),await r.cancelQueries({queryKey:[`projects`,e]}),r.removeQueries({queryKey:[`projects`,e]}),c.forgetProject(e),l.forgetProject(e);let t=r.getQueryData([`projects`]),n=t?.data.filter(t=>t.id!==e)??$s;return a(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n}),r.setQueryData([`projects`],t===void 0?void 0:{...t,data:n}),n}catch{return}}),[c,O,l,r]),G=(0,K.useCallback)(async(e,t)=>{try{await c.refreshProject(e,t),qe()}catch(e){Ge(e)}},[c]),le=(0,K.useCallback)(async()=>{await r.invalidateQueries()},[r]);(0,K.useEffect)(()=>()=>{l.dispose(),c.dispose()},[c,l]);let ue=(0,K.useMemo)(()=>({capabilities:y.data,client:t,error:y.error??b.error,isPending:H,projectTaskStates:B,projects:N,tasks:V}),[y.data,y.error,t,H,B,N,b.error,V]);return(0,J.jsx)(Qs,{actions:(0,K.useMemo)(()=>({addProject:ae,fetchNextProjectTaskPage:te,forgetTask:ne,markTaskRunning:U,projectRuntime:l,refreshProjectGitStatus:G,removeProject:ce,renameProject:se,reorderProjects:oe,requestNotificationPermission:ie,retry:le,setExpandedProjectTaskIds:re,viewTask:W}),[ae,te,ne,U,l,G,ce,se,oe,ie,le,re,W]),activity:(0,K.useMemo)(()=>({isProjectActionPending:T||D,isProjectOrderPending:x,isProjectAddPending:u,taskActivity:v}),[u,x,D,T,v]),client:t,data:ue,onRemoveTaskQuery:z,onUpdateTaskQuery:ee,projects:F,rootSelection:(0,K.useMemo)(()=>({selectedRootIds:i,setSelectedProjectRoot:s}),[i,s]),children:e})}var tc=`modulepreload`,nc=function(e){return`/`+e},rc={},ic=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=nc(t,n),t=s(t),t in rc)return;rc[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:tc,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function ac(){return ic(()=>import(`./global-settings-dialog-CQK8OvfF.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))}var oc={error:null,loading:!0,pairing:!1},sc=class{#e;#t=new Set;#n;#r=0;#i=oc;#a;constructor(e,t){this.#e=e,this.#n=t}getSnapshot=()=>this.#i;subscribe=e=>(this.#t.add(e),()=>this.#t.delete(e));start(){this.#a===void 0&&(this.#a=this.#e.subscribeUnauthorized(()=>{this.#r+=1,this.#o()}),this.load())}stop(){this.#r+=1,this.#a?.(),this.#a=void 0}async load(){let e=this.#r+=1;this.#s({...this.#i,error:null,loading:!0});try{let t=await this.#e.getAccessStatus();e===this.#r&&this.#s({error:null,loading:!1,pairing:!1,status:t})}catch{e===this.#r&&this.#s({...this.#i,error:`load`,loading:!1})}}async pair(e){this.#s({...this.#i,error:null,pairing:!0});try{let t=await this.#e.pairAccess(e);this.#s({error:null,loading:!1,pairing:!1,status:t}),qe()}catch(e){this.#s({...this.#i,error:null,pairing:!1}),Ge(e)}}async logout(){try{let e=await this.#e.logoutAccess();this.#n.clear(),this.#s({error:null,loading:!1,pairing:!1,status:e}),qe()}catch(e){throw Ge(e),e}}#o(){this.#n.clear(),this.#s({error:null,loading:!1,pairing:!1,status:{authenticated:!1,mode:`lan`,version:1}})}#s(e){this.#i=e;for(let e of this.#t)e()}},cc=(0,K.createContext)(void 0);function lc({children:e,client:t,queryClient:n}){let[r]=(0,K.useState)(()=>new sc(t,n)),i=(0,K.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot);(0,K.useEffect)(()=>(r.start(),()=>{r.stop()}),[r]);let a=(0,K.useMemo)(()=>({...i,logout:()=>r.logout(),pair:e=>r.pair(e),retry:()=>{r.load()}}),[r,i]);return(0,J.jsx)(cc.Provider,{value:a,children:e})}function uc(){let e=(0,K.useContext)(cc);if(e===void 0)throw Error(`useAccess must be used inside AccessProvider`);return e}var dc=_(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),fc=_(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),pc=_(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),mc=_(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),hc=_(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),gc=_(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),_c=_(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),vc=_(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),yc=_(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),bc=_(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),xc=_(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Sc=_(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Cc=_(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),wc=_(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),Tc=_(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Ec=_(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Dc=_(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),Oc=_(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),kc=_(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Ac=_(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),jc=_(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Mc=_(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Nc=_(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Pc=_(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Fc=_(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ic=_(`wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),Lc=_(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Rc({onRetry:e}){let{t}=y(`common`);return(0,J.jsx)(`section`,{className:`grid min-h-0 flex-1 place-items-center bg-content px-6 py-10 text-center`,"aria-labelledby":`runtime-unavailable-title`,children:(0,J.jsxs)(`div`,{className:`max-w-md`,children:[(0,J.jsx)(gc,{className:`mx-auto size-8 text-danger`,"aria-hidden":`true`,strokeWidth:1.6}),(0,J.jsx)(`h1`,{id:`runtime-unavailable-title`,className:`mt-4 text-xl font-semibold`,children:t(`errors.runtimeUnavailableTitle`)}),(0,J.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:(0,J.jsx)(Oo,{components:{command:(0,J.jsx)(`code`,{className:`font-mono text-foreground`})},i18nKey:`errors.runtimeUnavailableDescription`,ns:`common`})}),(0,J.jsxs)(v,{className:`mx-auto mt-5`,onClick:e,size:`lg`,type:`button`,children:[(0,J.jsx)(Mt,{className:`size-4`,"aria-hidden":`true`}),t(`actions.retry`)]})]})})}function zc(e){return e.filter(e=>e.pinned)}function Bc(e,t){return t||e.length<=5?{hasMore:!1,tasks:e}:{hasMore:!0,tasks:e.slice(0,5)}}function Vc(e){let t=Math.max(1,Math.floor((Date.now()-Date.parse(e))/6e4));if(t<60)return`${String(t)}m`;let n=Math.floor(t/60);return n<24?`${String(n)}h`:`${String(Math.floor(n/24))}d`}var Hc=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Uc=(e=>e?Hc(e):Hc),Wc=e=>e;function Gc(e,t=Wc){let n=K.useSyncExternalStore(e.subscribe,K.useCallback(()=>t(e.getState()),[e,t]),K.useCallback(()=>t(e.getInitialState()),[e,t]));return K.useDebugValue(n),n}var Kc=1048576,qc=1e4,Jc=16*1024,Yc=256,Xc=new TextDecoder,Zc=new TextEncoder,Qc=class{#e;#t;#n=()=>this.materialize();#r;#i;#a=0;#o=[];#s=!1;#c=0;#l=!1;#u=``;#d=-1;#f=1;#p={bytes:0,lines:0};#m=0;#h=[];#g=0;#_=0;#v=0;#y=[];#b=-1;constructor(e,t,n={}){let r=n.maxBytes??Kc,i=Math.max(1,n.maxLines??qc),a=Math.ceil(i/2),o=i-a;this.#e=Math.ceil(r/2),this.#r=r-this.#e,this.#t=a,this.#i=Math.max(0,o-1),this.replace(e,t)}append(e){this.#l=!0,this.#x(Zc.encode(e)),this.#v+=1}getView(){return{chunks:this.#E(),hasOutput:this.#l,materialize:this.#n,outputBytes:this.#a+this.#m,outputLines:this.#c+this.#_,outputOmitted:this.#p,startIndex:0,version:this.#v}}materialize(){if(this.#d===this.#v)return this.#u;let e=this.#E().map(e=>e.text).join(``);return this.#u=e,this.#d=this.#v,e}replace(e,t){this.#a=0,this.#o=[],this.#s=!1,this.#c=0,this.#l=e!==void 0,this.#p=t,this.#m=0,this.#h=[],this.#g=0,this.#_=0,e!==void 0&&e.length>0&&this.#x(Zc.encode(e)),this.#v+=1}#x(e){let t=0;if(!this.#s){let n=$c(e,this.#e-this.#a,this.#t-this.#c);if(n>0){let t=this.#S(this.#o,e.subarray(0,n));this.#a+=t.bytes,this.#c+=t.newlines}t=n,this.#s=n<e.byteLength}if(t<e.byteLength){let n=this.#S(this.#h,e.subarray(t),this.#g);this.#m+=n.bytes,this.#_+=n.newlines,this.#T()}}#S(e,t,n=0){let r=0,i=0;for(;r<t.byteLength;){let a=r,o=0;for(;a<t.byteLength;){let e=t[a]??0,n=tl(e);if(a>r&&a+n-r>Jc||(a+=n,e===10&&(o+=1,o>=Yc)))break}let s=t.subarray(r,a).slice();e.push(this.#C(s,o)),i+=o,this.#w(e,n),r=a}return{bytes:t.byteLength,newlines:i}}#C(e,t,n=0){let r={byteLength:e.byteLength,encodedValue:e,id:this.#f,mergeLevel:n,newlineCount:t,text:Xc.decode(e)};return this.#f+=1,r}#w(e,t){for(;e.length-t>=2;){let t=e.at(-1),n=e.at(-2);if(t===void 0||n?.mergeLevel!==t.mergeLevel||n.byteLength+t.byteLength>Jc||n.newlineCount+t.newlineCount>Yc)return;let r=new Uint8Array(n.byteLength+t.byteLength);r.set(n.encodedValue),r.set(t.encodedValue,n.byteLength),e.splice(-2,2,this.#C(r,n.newlineCount+t.newlineCount,n.mergeLevel+1))}}#T(){for(;this.#m>this.#r||this.#_>this.#i;){let e=this.#h[this.#g];if(e===void 0)break;let t=el(e.encodedValue,this.#m-this.#r,this.#_-this.#i);if(this.#m-=t.bytes,this.#_-=t.newlines,this.#p={bytes:this.#p.bytes+t.bytes,lines:this.#p.lines+t.newlines},t.bytes===e.byteLength)this.#g+=1;else{let n=e.encodedValue.subarray(t.bytes).slice();this.#h[this.#g]=this.#C(n,e.newlineCount-t.newlines)}}this.#g>=128&&this.#g*2>=this.#h.length&&(this.#h=this.#h.slice(this.#g),this.#g=0)}#E(){return this.#b!==this.#v&&(this.#y=[...this.#o,...this.#h.slice(this.#g)],this.#b=this.#v),this.#y}};function $c(e,t,n){let r=0,i=0;for(;r<e.byteLength&&!(i>=n);){let a=e[r]??0,o=tl(a);if(r+o>t||a===10&&i>=n)break;r+=o,a===10&&(i+=1)}return r}function el(e,t,n){let r=0,i=0;for(;r<e.byteLength&&(r<t||i<n);){let t=e[r]??0;r+=tl(t),t===10&&(i+=1)}return{bytes:r,newlines:i}}function tl(e){return e&128?(e&224)==192?2:(e&240)==224?3:4:1}var nl=`__CODEXLY_PENDING_COMMAND__`,rl=`__CODEXLY_RETAINED_COMMAND_OUTPUT__`,il=new TextEncoder().encode(rl).byteLength;function al(e){if(e.type!==`command`||e.output===`__CODEXLY_RETAINED_COMMAND_OUTPUT__`)return e;let t={...e};return delete t.output,t}function ol(e){let t=al(e),n=new Map,r=0,i=e.type===`command`?-1:0,a=t,o,s=e.type===`reasoning`?e.summary.length:0,c=e.type===`command`?new Qc(e.output,e.outputOmitted):void 0,l=X(t)+(c?.getView().outputBytes??0),u=Uc()(()=>({revision:0}));function d(e,t){let i=n.get(e);i===void 0?n.set(e,[t]):i.push(t),e===`summary`&&(s+=t.length),l+=bs(t),r+=1}return Object.assign(u,{appendDelta(e){if(e.type===`message.delta`)return t.type!==`message`||t.role!==`assistant`?!1:(d(`text`,e.payload.delta),!0);if(e.type===`reasoning.delta`)return t.type===`reasoning`?(e.payload.field===`summary`&&e.payload.sectionIndex!==void 0&&((o===void 0?e.payload.sectionIndex>0:e.payload.sectionIndex!==o)&&s>0&&d(`summary`,`
3
-
4
- `),o=e.payload.sectionIndex),d(e.payload.field,e.payload.delta),!0):!1;if(e.type===`plan.delta`)return t.type===`plan`?(d(`plan`,e.payload.delta),!0):!1;if(t.type!==`command`)return!1;let n=c?.getView().outputBytes??0;return c?.append(e.payload.delta),l+=(c?.getView().outputBytes??0)-n,r+=1,!0},getRetainedBytes:()=>l,peek:()=>t,publish(){u.setState(e=>({revision:e.revision+1}))},read(){if(i===r)return a;let e=t;if(t.type===`message`){let r=n.get(`text`);r!==void 0&&(e={...t,text:[t.text,...r].join(``)})}else if(t.type===`reasoning`){let r=n.get(`content`),i=n.get(`summary`);(r!==void 0||i!==void 0)&&(e={...t,content:r===void 0?t.content:[t.content,...r].join(``),summary:i===void 0?t.summary:[t.summary,...i].join(``)})}else if(t.type===`command`){let n=c?.getView();n!==void 0&&(e={...t,...n.hasOutput?{output:n.materialize()}:{},outputOmitted:n.outputOmitted})}else if(t.type===`plan`){let r=n.get(`plan`);r!==void 0&&(e={...t,text:[t.text,...r].join(``)})}return a=e,i=r,a},readCommandOutput(){return c?.getView()},replace(e){t=al(e),n.clear(),o=void 0,s=e.type===`reasoning`?e.summary.length:0,c=e.type===`command`?new Qc(e.output,e.outputOmitted):void 0,l=X(t)+(c?.getView().outputBytes??0),r+=1}})}function sl(e,t){let n=e.pendingRequestsById[t.requestId]!==void 0,r=e.pendingRequestIds;t.status===`pending`?n||(r=[...e.pendingRequestIds,t.requestId]):r=[...e.pendingRequestIds.filter(e=>e!==t.requestId),t.requestId];let i={...e.pendingRequestsById,[t.requestId]:t},a=r.filter(e=>i[e]?.status!==`pending`),o=new Set(a.slice(0,-20));return o.size===0?{pendingRequestIds:r,pendingRequestsById:i}:{pendingRequestIds:r.filter(e=>!o.has(e)),pendingRequestsById:Object.fromEntries(Object.entries(i).filter(([e])=>!o.has(e)))}}function cl(e,t){return JSON.stringify([e,t])}function ll(e,t){return e.itemStoresByKey.get(t)?.read()}function ul(e){let{pendingRequests:t,turns:n,turnsNextCursor:r,...i}=e.snapshot,a=[],o={},s={},c=new Map;for(let e of n){let{items:t,...n}=e;a.push(e.id),o[e.id]=n,s[e.id]=t.map(t=>cl(e.id,t.id));for(let n of t){let t=cl(e.id,n.id);c.set(t,ol(n))}}let l={pendingRequestIds:[],pendingRequestsById:{}};for(let e of t)l=sl(l,e);let{budget:u}=dl({previousBudget:{commandOutputAccessByItemKey:new Map,commandOutputAccessSequence:0,commandOutputBytes:0,commandOutputBytesByItemKey:new Map},sourceItemStoresByKey:c,touchedItemKeys:[...c.keys()]}),d=X(e.checkpoint)+X(i)+X(r);for(let e of a){d+=X(o[e]);for(let t of s[e]??[])d+=c.get(t)?.getRetainedBytes()??0}for(let e of l.pendingRequestIds)d+=X(l.pendingRequestsById[e]);return{checkpoint:e.checkpoint,...u,itemKeysByTurnId:s,itemStoresByKey:c,itemStructureRevision:0,notices:[],...l,retainedBytes:d,snapshotMetadata:i,turnIds:a,turnsNextCursor:r,turnsById:o}}function dl(e){let t=e.previousBudget.commandOutputAccessByItemKey,n=e.previousBudget.commandOutputBytesByItemKey,r=e.previousBudget.commandOutputAccessSequence,i=e.previousBudget.commandOutputBytes,a=new Map;for(let a of new Set(e.touchedItemKeys)){let o=n.get(a)??0,s=e.sourceItemStoresByKey.get(a)?.readCommandOutput();if(!s?.hasOutput){t.delete(a),n.delete(a),i-=o;continue}r+=1,t.set(a,r),n.set(a,s.outputBytes),i+=s.outputBytes-o}if(i<=8388608)return{budget:{commandOutputAccessByItemKey:t,commandOutputAccessSequence:r,commandOutputBytes:i,commandOutputBytesByItemKey:n},retainedBytesDeltaByItemKey:a};let o=[...t.keys()].toSorted((e,n)=>(t.get(e)??0)-(t.get(n)??0));for(let t of o){if(i<=8388608)break;let r=e.sourceItemStoresByKey.get(t),o=r?.peek();if(r===void 0||o?.type!==`command`)continue;let s=n.get(t)??0,c=r.getRetainedBytes(),l=r.readCommandOutput();r.replace({...o,output:rl,outputOmitted:{bytes:(l?.outputOmitted.bytes??o.outputOmitted.bytes)+s,lines:(l?.outputOmitted.lines??o.outputOmitted.lines)+(l?.outputLines??0)}}),e.changedItemStores?.add(r),n.set(t,il),i-=s-il,a.set(t,r.getRetainedBytes()-c)}return{budget:{commandOutputAccessByItemKey:t,commandOutputAccessSequence:r,commandOutputBytes:i,commandOutputBytesByItemKey:n},retainedBytesDeltaByItemKey:a}}function fl(e,t){if(e?.type!==`message`||e.role!==`user`||t.type!==`message`||t.role!==`user`||t.text.length>0||(t.skills?.length??0)===0)return;let n=new Set((e.skills??[]).map(e=>e.name)),r=[...e.skills??[]];for(let e of t.skills??[])n.has(e.name)||(n.add(e.name),r.push(e));return{...e,skills:r,text:Se(e.text,r)}}function pl(e,t,n){if(n.type===`command.output_delta`)return[cl(n.turnId,n.itemId)];if(n.type===`item.started`||n.type===`item.completed`){let t=cl(n.turnId,n.itemId);return n.payload.item.type===`command`||e.commandOutputBytesByItemKey.has(t)?[t]:void 0}if(n.type===`turn.started`||n.type===`turn.completed`)return[...e.itemKeysByTurnId[n.turnId]??[],...t.itemKeysByTurnId[n.turnId]??[]]}function ml(e){switch(e.type){case`message.delta`:return{id:e.itemId,role:`assistant`,text:``,type:`message`};case`reasoning.delta`:return{content:``,id:e.itemId,summary:``,type:`reasoning`};case`plan.delta`:return{id:e.itemId,text:``,type:`plan`};case`command.output_delta`:return{command:nl,cwd:``,id:e.itemId,output:``,outputOmitted:{bytes:0,lines:0},status:`running`,type:`command`};default:return}}function hl(e,t,n,r){let i=e.itemKeysByTurnId[t]??[],a=new Set(n.map(e=>cl(t,e.id)));for(let t of i)a.has(t)||e.itemStoresByKey.delete(t);for(let i of n){let n=cl(t,i.id),a=e.itemStoresByKey.get(n);a===void 0?e.itemStoresByKey.set(n,ol(i)):(a.replace(i),r.add(a))}return{itemKeysByTurnId:{...e.itemKeysByTurnId,[t]:[...a]}}}function gl(e,t,n){let r=`submitted-user-${t}`,i=n.find(e=>e.type===`message`&&e.role===`user`),a=[],o=new Set;for(let n of e.itemKeysByTurnId[t]??[]){let t=ll(e,n);if(t===void 0)continue;let s=t.id===r&&i!==void 0?i:t;o.has(s.id)||(o.add(s.id),a.push(s))}let s=new Set(a.map(e=>e.id)),c=new Map(n.map(e=>[e.id,e])),l=new Map,u=[];for(let e of n){if(!s.has(e.id)){u.push(e);continue}u.length>0&&(l.set(e.id,u),u=[])}return[...a.flatMap(e=>[...l.get(e.id)??[],c.get(e.id)??e]),...u]}function _l(e,t,n){let r=e.snapshotMetadata;if(r===null)return{};let i={sequence:t.sequence,sessionId:t.sessionId};switch(t.type){case`project.git_metadata_changed`:return{};case`turn.started`:{let{items:a,...o}=t.payload.turn;return{checkpoint:i,...hl(e,t.turnId,a,n),snapshotMetadata:{...r,status:`running`,updatedAt:t.timestamp},itemStructureRevision:e.itemStructureRevision+1,turnIds:[...e.turnIds.filter(e=>e!==t.turnId),t.turnId],turnsById:{...e.turnsById,[t.turnId]:o}}}case`message.delta`:case`plan.delta`:case`reasoning.delta`:case`command.output_delta`:{let a=e.turnsById[t.turnId];if(a===void 0)return{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}};let o=a.status===`running`&&a.error!==null?{...e.turnsById,[t.turnId]:{...a,error:null}}:e.turnsById,s=cl(t.turnId,t.itemId),c=e.itemStoresByKey.get(s);if(c!==void 0)return c.appendDelta(t)&&n.add(c),{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp},turnsById:o};let l=ml(t);if(l===void 0)return{checkpoint:i};let u=ol(l);return u.appendDelta(t),e.itemStoresByKey.set(s,u),n.add(u),{checkpoint:i,itemKeysByTurnId:{...e.itemKeysByTurnId,[t.turnId]:[...e.itemKeysByTurnId[t.turnId]??[],s]},itemStructureRevision:e.itemStructureRevision+1,snapshotMetadata:{...r,updatedAt:t.timestamp},turnsById:o}}case`tool.progress`:{let a=cl(t.turnId,t.itemId),o=e.itemStoresByKey.get(a);if(o===void 0)return{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}};let s=o.read();return s.type===`tool`?(o.replace({...s,progress:t.payload.message}),n.add(o),{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}}):{checkpoint:i}}case`file_change.updated`:{let a=cl(t.turnId,t.itemId),o=e.itemStoresByKey.get(a);if(o!==void 0){let e=o.read();return e.type===`file_change`?(o.replace({...e,changes:t.payload.changes,status:`running`}),n.add(o),{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}}):{checkpoint:i}}if(e.turnsById[t.turnId]===void 0)return{checkpoint:i};let s=ol({changes:t.payload.changes,id:t.itemId,status:`running`,type:`file_change`});return e.itemStoresByKey.set(a,s),n.add(s),{checkpoint:i,itemKeysByTurnId:{...e.itemKeysByTurnId,[t.turnId]:[...e.itemKeysByTurnId[t.turnId]??[],a]},itemStructureRevision:e.itemStructureRevision+1,snapshotMetadata:{...r,updatedAt:t.timestamp}}}case`task.notice`:return{checkpoint:i,notices:t.payload.code===`guardian_warning`?e.notices:[...e.notices,t].slice(-20),snapshotMetadata:{...r,updatedAt:t.timestamp}};case`mcp_server.status_updated`:return{checkpoint:i};case`goal.updated`:return{checkpoint:i,snapshotMetadata:{...r,goal:t.payload.goal,updatedAt:t.timestamp}};case`goal.cleared`:return{checkpoint:i,snapshotMetadata:{...r,goal:null,updatedAt:t.timestamp}};case`queue.changed`:return{checkpoint:i};case`task.status_updated`:return{checkpoint:i,snapshotMetadata:{...r,status:t.payload.status,updatedAt:t.timestamp}};case`skills.changed`:case`task.metadata_changed`:case`task.removed`:return{checkpoint:i};case`item.started`:case`item.completed`:{if(e.turnsById[t.turnId]===void 0)return{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}};let a=cl(t.turnId,t.itemId),o=e.itemStoresByKey.get(a),s=o!==void 0,c=e.itemKeysByTurnId[t.turnId]??[],l=c.at(-1),u=l===void 0?void 0:e.itemStoresByKey.get(l),d=fl(u?.read(),t.payload.item);if(d!==void 0&&u!==void 0)return u.replace(d),n.add(u),{checkpoint:i,snapshotMetadata:{...r,updatedAt:t.timestamp}};let f=`submitted-user-${t.turnId}`,p=cl(t.turnId,f),m=t.payload.item.type===`message`&&t.payload.item.role===`user`&&c.includes(p),h=m?c.filter(e=>e!==p).concat(s?[]:a):s?c:[...c,a];return m&&e.itemStoresByKey.delete(p),o===void 0?e.itemStoresByKey.set(a,ol(t.payload.item)):(o.replace(t.payload.item),n.add(o)),{checkpoint:i,itemKeysByTurnId:h===c?e.itemKeysByTurnId:{...e.itemKeysByTurnId,[t.turnId]:h},itemStructureRevision:e.itemStructureRevision+1,snapshotMetadata:{...r,updatedAt:t.timestamp}}}case`turn.completed`:{let a=e.turnsById[t.turnId],o=a?.status===`failed`?a.error:null,s=t.payload.turn.error===null&&o!==null?{...t.payload.turn,error:o}:t.payload.turn,{items:c,...l}=s,u=gl(e,t.turnId,c);return{checkpoint:i,...a===void 0?{}:hl(e,t.turnId,u,n),notices:[],snapshotMetadata:{...r,status:s.status===`failed`?`failed`:`idle`,updatedAt:t.timestamp},itemStructureRevision:e.itemStructureRevision+1,turnsById:a===void 0?e.turnsById:{...e.turnsById,[t.turnId]:l}}}case`plan.updated`:return{checkpoint:i,snapshotMetadata:{...r,plan:t.payload.plan,updatedAt:t.timestamp}};case`usage.updated`:return{checkpoint:i,snapshotMetadata:{...r,contextUsage:t.payload.usage,updatedAt:t.timestamp}};case`provider.error`:{let n=e.turnsById[t.turnId],a=n===void 0?e.turnsById:{...e.turnsById,[t.turnId]:{...n,error:t.payload.message,status:t.payload.willRetry?n.status:`failed`}};return{checkpoint:i,snapshotMetadata:t.payload.willRetry?r:{...r,status:`failed`,updatedAt:t.timestamp},turnsById:a}}case`pending_request.created`:case`pending_request.resolved`:case`pending_request.expired`:{let n=t.payload.request;return{checkpoint:i,...sl(e,n),snapshotMetadata:{...r,updatedAt:t.timestamp}}}}}function vl(e){if(e.snapshotMetadata!==null)return{...e.snapshotMetadata,pendingRequests:e.pendingRequestIds.flatMap(t=>{let n=e.pendingRequestsById[t];return n?.status===`pending`?[n]:[]}),turnsNextCursor:e.turnsNextCursor,turns:e.turnIds.flatMap(t=>{let n=e.turnsById[t];if(n===void 0)return[];let r=(e.itemKeysByTurnId[t]??[]).flatMap(t=>{let n=ll(e,t);return n===void 0?[]:[n]});return[{...n,items:r}]})}}function yl(e,t){let n=new Map(t.items.map(e=>[e.id,e])),r=new Map,i=e.items.filter(e=>e.type===`message`),a=t.items.filter(e=>e.type===`message`),o=new Map(i.map(e=>[e.id,e])),s=new Set,c=new Set,l=(e,t)=>{s.add(e.id),c.add(t.id),n.delete(t.id),r.set(e.id,{...t,id:e.id})};for(let e of a){let t=o.get(e.id);t!==void 0&&l(t,e)}let u=i.filter(e=>!s.has(e.id)),d=a.filter(e=>!c.has(e.id)),f=new Map,p=new Map;for(let e of d){let t=u.filter(t=>t.role===e.role&&t.text.length>0&&e.text.length>0&&(t.text.startsWith(e.text)||e.text.startsWith(t.text)));f.set(e.id,t);for(let e of t)p.set(e.id,(p.get(e.id)??0)+1)}for(let e of d){let t=f.get(e.id)??[],n=t.length===1?t[0]:void 0;n!==void 0&&p.get(n.id)===1&&l(n,e)}return[...e.items.flatMap(e=>{let t=r.get(e.id);if(t!==void 0)return[t];let i=n.get(e.id);return i===void 0?[e]:(n.delete(e.id),[i])}),...n.values()]}function bl(e,t){let n=vl(e);if(n===void 0)return t;let r=new Map(n.turns.map(e=>[e.id,e])),i=new Set(t.snapshot.turns.map(e=>e.id)),a=n.turns.flatMap((e,t)=>i.has(e.id)?[t]:[]),o=a.at(0),s=a.at(-1),c=t.snapshot.turnsNextCursor!==null&&o!==void 0&&s!==void 0,l=c?n.turns.slice(0,o).filter(e=>!i.has(e.id)):[],u=c?n.turns.slice(s+1).filter(e=>!i.has(e.id)):[];return{...t,snapshot:{...t.snapshot,turns:[...l,...t.snapshot.turns.map(e=>{let t=r.get(e.id);return t===void 0?e:{...e,items:yl(t,e)}}),...u],turnsNextCursor:l.length>0?n.turnsNextCursor:t.snapshot.turnsNextCursor}}}function xl(e,t){let n=t===void 0?{checkpoint:null,commandOutputAccessByItemKey:new Map,commandOutputAccessSequence:0,commandOutputBytesByItemKey:new Map,commandOutputBytes:0,itemKeysByTurnId:{},itemStoresByKey:new Map,itemStructureRevision:0,notices:[],pendingRequestIds:[],pendingRequestsById:{},retainedBytes:0,snapshotMetadata:null,turnIds:[],turnsNextCursor:null,turnsById:{}}:ul(t);if(t!==void 0&&(t.snapshot.projectId!==e.projectId||t.snapshot.id!==e.taskId))throw Error(`Task store identity does not match the initial snapshot`);return Uc()((t,r)=>({...n,applyEvents(e){if(e.length===0)return;let n=new Set;t(t=>{let r=t;for(let t of e){let e=r.checkpoint,i=e!==null&&t.sessionId===e.sessionId&&t.sequence>e.sequence;if(t.taskId!==r.taskId||!i)continue;let a=r,o=Cl(a,t),s=Tl(a,t);r={...r,..._l(r,t,n)};let c=pl(a,r,t),l=new Map;if(c!==void 0){let e=dl({previousBudget:a,changedItemStores:n,sourceItemStoresByKey:r.itemStoresByKey,touchedItemKeys:c});({retainedBytesDeltaByItemKey:l}=e),r={...r,...e.budget}}let u=new Set([...s.keys(),...wl(r,t)]),d=El(r,u)-Dl(s),f=[...l].reduce((e,[t,n])=>e+(u.has(t)?0:n),0);r={...r,retainedBytes:r.retainedBytes+Cl(r,t)-o+d+f}}return r});for(let e of n)e.publish()},connectionState:`connecting`,error:null,hydrate(n){if(n.snapshot.projectId!==e.projectId||n.snapshot.id!==e.taskId)throw Error(`Task store identity does not match the snapshot`);t(e=>({...ul(n),itemStructureRevision:e.itemStructureRevision+1,connectionState:`connecting`,error:null}))},projectId:e.projectId,prependHistory(n){if(n.snapshot.projectId!==e.projectId||n.snapshot.id!==e.taskId)throw Error(`Task store identity does not match the history page`);let r=new Set;t(e=>Sl(e,n,r));for(let e of r)e.publish()},reconcile(n){if(n.snapshot.projectId!==e.projectId||n.snapshot.id!==e.taskId)throw Error(`Task store identity does not match the snapshot`);t(e=>{let t=e.checkpoint;return t!==null&&t.sessionId===n.checkpoint.sessionId&&t.sequence>n.checkpoint.sequence?e:{...ul(bl(e,n)),itemStructureRevision:e.itemStructureRevision+1,connectionState:`connecting`,error:null}})},getItem:(e,t)=>r().itemStoresByKey.get(cl(t,e))?.read(),getItemByKey:e=>r().itemStoresByKey.get(e)?.read(),reconstructSnapshot:()=>vl(r()),setConnectionState(e){t({connectionState:e})},setError(e){t({error:e})},setTaskSettings(e){t(t=>t.snapshotMetadata===null?t:{snapshotMetadata:{...t.snapshotMetadata,settings:e}})},taskId:e.taskId}))}function Sl(e,t,n){let r=ul(t),i=r.turnIds.filter(t=>e.turnsById[t]===void 0),a=new Set(i.flatMap(e=>r.itemKeysByTurnId[e]??[])),o=new Map(e.itemStoresByKey);for(let e of a){let t=r.itemStoresByKey.get(e);t!==void 0&&o.set(e,t)}let s={...e.itemKeysByTurnId},c={...e.turnsById};for(let e of i){s[e]=r.itemKeysByTurnId[e]??[];let t=r.turnsById[e];t!==void 0&&(c[e]=t)}let{budget:l,retainedBytesDeltaByItemKey:u}=dl({previousBudget:{commandOutputAccessByItemKey:new Map,commandOutputAccessSequence:0,commandOutputBytes:0,commandOutputBytesByItemKey:new Map},changedItemStores:n,sourceItemStoresByKey:o,touchedItemKeys:[...a,...e.itemStoresByKey.keys()]}),d=e.retainedBytes-X(e.turnsNextCursor)+X(t.snapshot.turnsNextCursor);for(let e of i){d+=X(c[e]);for(let t of s[e]??[])d+=o.get(t)?.getRetainedBytes()??0}for(let[e,t]of u)a.has(e)||(d+=t);return{...e,...l,checkpoint:e.checkpoint??t.checkpoint,itemKeysByTurnId:s,itemStoresByKey:o,itemStructureRevision:e.itemStructureRevision+1,retainedBytes:d,turnIds:[...i,...e.turnIds],turnsNextCursor:t.snapshot.turnsNextCursor,turnsById:c}}function Cl(e,t){let n=0;if((t.type===`turn.started`||t.type===`turn.completed`||t.type===`provider.error`)&&(n+=X(e.turnsById[t.turnId])),(t.type===`task.notice`||t.type===`turn.completed`)&&(n+=e.notices.reduce((e,t)=>e+X(t),0)),(t.type===`goal.updated`||t.type===`goal.cleared`||t.type===`plan.updated`||t.type===`provider.error`||t.type===`task.status_updated`||t.type===`turn.started`||t.type===`turn.completed`||t.type===`usage.updated`)&&(n+=X(e.snapshotMetadata)),t.type===`pending_request.created`||t.type===`pending_request.resolved`||t.type===`pending_request.expired`)for(let t of e.pendingRequestIds)n+=X(e.pendingRequestsById[t]);return n}function wl(e,t){if(t.type===`turn.started`||t.type===`turn.completed`)return e.itemKeysByTurnId[t.turnId]??[];if(!(`itemId`in t)||!(`turnId`in t))return[];let n=[cl(t.turnId,t.itemId)];if(t.type===`item.started`||t.type===`item.completed`){let r=(e.itemKeysByTurnId[t.turnId]??[]).at(-1);r!==void 0&&n.push(r),n.push(cl(t.turnId,`submitted-user-${t.turnId}`))}return n}function Tl(e,t){return new Map(wl(e,t).map(t=>[t,e.itemStoresByKey.get(t)?.getRetainedBytes()??0]))}function El(e,t){let n=0;for(let r of t)n+=e.itemStoresByKey.get(r)?.getRetainedBytes()??0;return n}function Dl(e){let t=0;for(let n of e.values())t+=n;return t}var Ol=class{#e;#t=new Map;#n=new Map;#r;#i;#a;#o=0;constructor(e={}){if(this.#r=e.maxRetainedBytes??67108864,!Number.isSafeInteger(this.#r)||this.#r<0)throw RangeError(`Task store registry maxRetainedBytes must be non-negative`);if(this.#i=e.maxRetainedStores??20,!Number.isInteger(this.#i)||this.#i<0)throw RangeError(`Task store registry maxRetainedStores must be a non-negative integer`);this.#e=e.createStore??(e=>xl(e)),this.#a=e.onEvict}acquire(e,t){let n=kl(e,t),r=this.#t.get(n);return r===void 0?(r={consumers:0,identity:{projectId:e,taskId:t},retainedBytes:0,store:this.#e({projectId:e,taskId:t})},this.#t.set(n,r)):r.consumers===0&&this.#c(n,r),r.consumers+=1,r.store}release(e,t){let n=this.#t.get(kl(e,t));return n===void 0||n.consumers===0?!1:(--n.consumers,n.consumers===0&&(n.retainedBytes=n.store.getState().retainedBytes,this.#n.set(kl(e,t),n),this.#o+=n.retainedBytes,this.#s()),n.consumers===0)}get retainedBytes(){return this.#o}get size(){return this.#t.size}peek(e,t){return this.#t.get(kl(e,t))?.store}remove(e,t){let n=kl(e,t),r=this.#t.get(n);return r===void 0||r.consumers>0?!1:(this.#c(n,r),this.#t.delete(n),this.#a?.(r.identity,r.store),!0)}#s(){for(;this.#n.size>this.#i||this.#o>this.#r;){let e=this.#n.entries().next().value;if(e===void 0)return;let[t,n]=e;this.#c(t,n),this.#t.delete(t),this.#a?.(n.identity,n.store)}}#c(e,t){this.#n.delete(e)&&(this.#o-=t.retainedBytes,t.retainedBytes=0)}};function kl(e,t){return JSON.stringify([e,t])}function Al(e={}){return new Ol(e)}var jl=Al({maxRetainedStores:20}),Ml=xl({projectId:``,taskId:``});function Nl(e,t,n){let r=Ee(),i=n.client,a=`${e}\u0000${t??``}`,[o,s]=(0,K.useState)({error:null,isPending:t!==void 0,scope:a}),[c,l]=(0,K.useState)(),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),m=(0,K.useRef)(null),h=c??Ml,g=Gc(h,e=>e.turnIds.findLast(t=>e.turnsById[t]?.status===`running`)),_=Gc(h,e=>e.connectionState),v=Gc(h,e=>e.error),y=Gc(h,e=>e.snapshotMetadata??void 0),b=Gc(h,e=>e.itemStructureRevision),x=Gc(h,e=>e.turnsNextCursor);(0,K.useEffect)(()=>{m.current=null,d(!1),p(null)},[e,t]),(0,K.useEffect)(()=>{if(t===void 0){l(void 0);return}let n=jl.acquire(e,t);return l(n),()=>{jl.release(e,t)}},[e,t]),(0,K.useEffect)(()=>{if(c===void 0||t===void 0)return;let o=c.getState();if(o.projectId!==e||o.taskId!==t)return;let l=new AbortController,u=bt(e,t,i).queryKey,d,f=!1;s({error:null,isPending:!0,scope:a});let p=Pl(r,u);return(p===void 0?i.readTask(e,t,{signal:l.signal}):Promise.resolve(p)).then(o=>{f||(d=n.attachTaskStore(o,c,()=>i.readTask(e,t)),r.removeQueries({exact:!0,queryKey:u}),s({error:null,isPending:!1,scope:a}))}).catch(e=>{!f&&!l.signal.aborted&&s({error:e instanceof Error?e:Error(String(e)),isPending:!1,scope:a})}),()=>{f=!0,l.abort(),d?.()}},[i,e,n,r,c,t,a]);let S=c===void 0?void 0:Il(c,e,t),C=(0,K.useCallback)(async()=>{if(S===void 0||t===void 0||x===null||m.current!==null)return;let n={};m.current=n,d(!0),p(null);try{let n=await i.readTask(e,t,{cursor:x});S.getState().prependHistory(n)}catch(e){m.current===n&&p(e instanceof Error?e:Error(String(e)))}finally{m.current===n&&(m.current=null,d(!1))}},[S,i,e,t,x]),w=S?.getState().snapshotMetadata!==null,T=o.scope===a?o.error:null,E=t!==void 0&&(o.scope!==a||o.isPending),D=S===void 0||!w?T:_===`closed`?v:null,O=(0,K.useCallback)(()=>S?.getState().reconstructSnapshot(),[S]),k=D===null&&(E||S===void 0||!w);return(0,K.useMemo)(()=>({activeTurnId:g,connectionState:S===void 0?`connecting`:_,error:D,hasOlderHistory:x!==null,isLoadingOlderHistory:u,isPending:k,itemStructureRevision:b,loadOlderHistory:C,metadata:y,olderHistoryError:f,readSnapshot:O,store:S}),[S,g,_,D,u,k,b,C,y,f,O,x])}function Pl(e,t){let n=e.getQueryData(t);return n!==void 0&&e.removeQueries({exact:!0,queryKey:t}),n}function Fl(e,t){return jl.remove(e,t)}function Il(e,t,n){let r=e?.getState();return n!==void 0&&r?.projectId===t&&r.taskId===n?e:void 0}var Ll=8;function Rl(e,t,n,r){if(t===n||!e.includes(t))return e;let i=e.filter(e=>e!==t),a=i.indexOf(n);if(a===-1)return e;let o=r===`after`?a+1:a;return i.toSpliced(o,0,t)}function zl(e,t,n){let r=e.indexOf(t),i=r+n;return r===-1||i<0||i>=e.length?e:e.toSpliced(r,1).toSpliced(i,0,t)}function Bl(e,t){if(t===null)return e;let n=new Map(e.map(e=>[e.id,e])),r=t.flatMap(e=>{let t=n.get(e);return t===void 0?[]:[t]}),i=new Set(r.map(e=>e.id));return[...r,...e.filter(e=>!i.has(e.id))]}function Vl({disabled:e=!1,onReorder:t,projects:n}){let{t:r}=y(`conversation`),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(null),u=(0,K.useRef)(null),d=(0,K.useRef)(null),f=Bl(n,c),p=(0,K.useRef)(f);p.current=f;let m=e=>{let t=u.current;t!==null&&(t.removeGlobalListeners(),e&&t.element.hasPointerCapture(t.pointerId)&&t.element.releasePointerCapture(t.pointerId),u.current=null)};(0,K.useEffect)(()=>()=>{m(!1)},[]);let h=async(e,i)=>{let a=await t(e);if(l(null),a){let t=n.find(e=>e.id===i),a=e.indexOf(i)+1;s(r(`reorder.moved`,{name:t?.name??r(`reorder.projectFallback`),position:a}))}},g=(t,n)=>{if(e||t.button!==0)return;m(!0),t.currentTarget.setPointerCapture(t.pointerId);let r=t.currentTarget,i=e=>{v(e.pointerId)},a=e=>{b(e.pointerId)},o={activated:!1,element:r,pointerId:t.pointerId,projectId:n,removeGlobalListeners:()=>{window.removeEventListener(`pointercancel`,a),window.removeEventListener(`pointerup`,i)},startClientX:t.clientX,startClientY:t.clientY};u.current=o,window.addEventListener(`pointercancel`,a),window.addEventListener(`pointerup`,i)},_=e=>{let t=u.current;if(t?.pointerId!==e.pointerId)return;let n=Math.hypot(e.clientX-t.startClientX,e.clientY-t.startClientY);if(!t.activated){if(n<=Ll)return;t.activated=!0,t.element.hasPointerCapture(t.pointerId)&&t.element.releasePointerCapture(t.pointerId),l(p.current.map(e=>e.id)),a(t.projectId),s(r(`reorder.started`))}e.preventDefault();let i=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-project-reorder-id]`)??null;if(i===null)return;let o=i.dataset.projectReorderId;if(o===void 0)return;let c=i.getBoundingClientRect(),d=e.clientY<c.top+c.height/2?`before`:`after`;l(e=>e===null?e:Rl(e,t.projectId,o,d))},v=e=>{let t=u.current;if(t?.pointerId!==e)return;let n=t.activated;if(m(!0),!n)return;d.current=t.projectId,a(null);let r=p.current.map(e=>e.id);h(r,t.projectId)},b=e=>{u.current?.pointerId===e&&(m(!1),a(null),l(null),s(r(`reorder.cancelled`)))},x=e=>{v(e.pointerId)},S=e=>{b(e.pointerId)},C=(e,t)=>{d.current===t&&(d.current=null,e.preventDefault(),e.stopPropagation())},w=(t,n)=>{if(e||!t.altKey||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let r=p.current.map(e=>e.id),i=zl(r,n,t.key===`ArrowUp`?-1:1);i!==r&&(l(i),h(i,n))};return{activeProjectId:i,announcement:o,getProjectReorderProps:e=>({"aria-keyshortcuts":`Alt+ArrowUp Alt+ArrowDown`,"data-project-reorder-id":e,onClickCapture:t=>{C(t,e)},onKeyDown:t=>{w(t,e)},onPointerCancel:S,onPointerDown:t=>{g(t,e)},onPointerMove:_,onPointerUp:x,title:r(`reorder.title`)}),orderedProjects:f}}function Hl({actionLock:e,activeProjectId:t,activeTaskId:n}){let{client:r}=Bo(),{forgetTask:i}=Vo(),a=aa(),o=Ee(),[s,c]=(0,K.useState)(null),l=Ye(Ze(r));return{closeTaskDeletion:()=>{l.isPending||c(null)},confirmTaskDeletion:()=>{let u=s;return u===null?Promise.resolve(void 0):e.run(async()=>{try{await l.mutateAsync({projectId:u.projectId,taskId:u.id}),c(null),await ut(o,u.projectId,u.id).catch(()=>void 0),o.removeQueries({exact:!0,queryKey:[`projects`,u.projectId,`tasks`,u.id]}),i(u.projectId,u.id),Fl(u.projectId,u.id),u.projectId===t&&u.id===n&&await(u.projectId===`temporary`?a({to:`/temporary`}):a({params:{projectId:u.projectId},to:`/p/$projectId`})),r.unsubscribeTask(u.projectId,u.id).catch(()=>void 0)}catch{}})},deletingTask:s,isDeletePending:l.isPending,requestTaskDeletion:c}}var Ul=`codexly:project-sidebar:expanded-projects:v1`,Wl=`codexly:project-sidebar:temporary-tasks-expanded:v1`;function Gl(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function Kl(e){if(e===void 0)return null;try{let t=e.getItem(Ul);if(t===null)return null;let n=JSON.parse(t);return Ql(n)?new Set(n.expandedProjectIds):null}catch{return null}}function ql(e,t){if(e===void 0)return;let n={expandedProjectIds:[...t],version:1};try{e.setItem(Ul,JSON.stringify(n))}catch{}}function Jl(e){if(e===void 0)return!0;try{let t=e.getItem(Wl);if(t===null)return!0;let n=JSON.parse(t);return!$l(n)||n.expanded}catch{return!0}}function Yl(e,t){if(e===void 0)return;let n={expanded:t,version:1};try{e.setItem(Wl,JSON.stringify(n))}catch{}}function Xl(e,t){if(t===null){let t=e[0];return t===void 0?new Set:new Set([t])}return new Set(e.filter(e=>t.has(e)))}function Zl(e,t){let n=Xl(e,t);return e.find(e=>n.has(e))??e[0]}function Ql(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&Array.isArray(t.expandedProjectIds)&&t.expandedProjectIds.every(e=>typeof e==`string`)}function $l(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&typeof t.expanded==`boolean`}var eu=Object.defineProperty,Z=(e,t)=>eu(e,`name`,{value:t,configurable:!0});function tu(e){let t=e+`CollectionProvider`,[n,r]=L(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Z(e=>{let{scope:t,children:n}=e,r=K.useRef(null),a=K.useRef(new Map).current;return(0,J.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let c=e+`CollectionSlot`,l=g(c),u=K.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=s(t,a(c,n).collectionRef);return(0,J.jsx)(l,{ref:i,children:r})});u.displayName=c;let d=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=g(d),m=K.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=K.useRef(null),c=s(t,o),l=a(d,n);return K.useEffect(()=>(l.itemMap.set(o,{ref:o,...i}),()=>void l.itemMap.delete(o))),(0,J.jsx)(p,{[f]:``,ref:c,children:r})});m.displayName=d;function h(t){let n=a(e+`CollectionConsumer`,t);return K.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return Z(h,`useCollection`),[{Provider:o,Slot:u,ItemSlot:m},h,r]}Z(tu,`createCollection`);var nu=new WeakMap,ru=class e extends Map{static{Z(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],nu.set(this,!0)}set(e,t){return nu.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=ou(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=iu(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=iu(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return iu(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function iu(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=au(e,t);return n===-1?void 0:e[n]}Z(iu,`at`);function au(e,t){let n=e.length,r=ou(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Z(au,`toSafeIndex`);function ou(e){return e!==e||e===0?0:Math.trunc(e)}Z(ou,`toSafeInteger`);function su(e){let t=e+`CollectionProvider`,[n,r]=L(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new ru,setItemMap:Z(()=>void 0,`setItemMap`)}),o=Z(({state:e,...t})=>e?(0,J.jsx)(l,{...t,state:e}):(0,J.jsx)(c,{...t}),`CollectionProvider`);o.displayName=t;let c=Z(e=>{let t=_();return(0,J.jsx)(l,{...e,state:t})},`CollectionInit`);c.displayName=t+`Init`;let l=Z(e=>{let{scope:t,children:n,state:r}=e,a=K.useRef(null),[o,c]=K.useState(null),l=s(a,c),[u,d]=r;return K.useEffect(()=>{if(!o)return;let e=du(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,J.jsx)(i,{scope:t,itemMap:u,setItemMap:d,collectionRef:l,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);l.displayName=t+`Impl`;let u=e+`CollectionSlot`,d=g(u),f=K.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=s(t,a(u,n).collectionRef);return(0,J.jsx)(d,{ref:i,children:r})});f.displayName=u;let p=e+`CollectionItemSlot`,m=g(p),h=K.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=K.useRef(null),[c,l]=K.useState(null),u=s(t,o,l),{setItemMap:d}=a(p,n),f=K.useRef(i);cu(f.current,i)||(f.current=i);let h=f.current;return K.useEffect(()=>{let e=h;return d(t=>c?t.has(c)?t.set(c,{...e,element:c}).toSorted(uu):(t.set(c,{...e,element:c}),t.toSorted(uu)):t),()=>{d(e=>!c||!e.has(c)?e:(e.delete(c),new ru(e)))}},[c,h,d]),(0,J.jsx)(m,{"data-radix-collection-item":``,ref:u,children:r})});h.displayName=p;function _(){return K.useState(new ru)}Z(_,`useInitCollection`);function v(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return Z(v,`useCollection`),[{Provider:o,Slot:f,ItemSlot:h},{createCollectionScope:r,useCollection:v,useInitCollection:_}]}Z(su,`createCollection`);function cu(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}Z(cu,`shallowEqual`);function lu(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Z(lu,`isElementPreceding`);function uu(e,t){return!e[1].element||!t[1].element?0:lu(e[1].element,t[1].element)?-1:1}Z(uu,`sortByDocumentPosition`);function du(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}Z(du,`getChildListObserver`);var fu=Object.defineProperty,pu=(e,t)=>fu(e,`name`,{value:t,configurable:!0}),mu=K.createContext(void 0);function hu(e){let t=K.useContext(mu);return e||t||`ltr`}pu(hu,`useDirection`);var gu=Object.defineProperty,_u=(e,t)=>gu(e,`name`,{value:t,configurable:!0}),vu=`Dialog`,[yu,bu]=L(vu),[xu,Su]=yu(vu),Cu=_u(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=K.useRef(null),c=K.useRef(null),[l,u]=ke({prop:r,defaultProp:i??!1,onChange:a,caller:vu}),[d,f]=K.useState(0),[p,m]=K.useState(0);return(0,J.jsx)(xu,{scope:t,triggerRef:s,contentRef:c,contentId:je(),titleId:je(),descriptionId:je(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:K.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),wu=`DialogTrigger`,Tu=K.forwardRef(_u(function(e,t){let{__scopeDialog:n,...r}=e,i=Su(wu,n),a=s(t,i.triggerRef);return(0,J.jsx)(E.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Uu(i.open),...r,ref:a,onClick:k(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),Eu=`DialogPortal`,[Du,Ou]=yu(Eu,{forceMount:void 0}),ku=_u(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Su(Eu,t);return(0,J.jsx)(Du,{scope:t,forceMount:n,children:K.Children.map(r,e=>(0,J.jsx)(W,{present:n||a.open,children:(0,J.jsx)(ae,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Au=`DialogOverlay`,ju=K.forwardRef(_u(function(e,t){let n=Ou(Au,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Su(Au,e.__scopeDialog);return a.modal?(0,J.jsx)(W,{present:r||a.open,children:(0,J.jsx)(Nu,{...i,ref:t})}):null},`DialogOverlay`)),Mu=g(`DialogOverlay.RemoveScroll`),Nu=K.forwardRef(_u(function(e,t){let{__scopeDialog:n,...r}=e,i=Su(Au,n),a=s(t,Fe());return(0,J.jsx)(_e,{as:Mu,allowPinchZoom:!0,shards:[i.contentRef],children:(0,J.jsx)(E.div,{"data-state":Uu(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Pu=`DialogContent`,Fu=K.forwardRef(_u(function(e,t){let n=Ou(Pu,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Su(Pu,e.__scopeDialog);return(0,J.jsx)(W,{present:r||a.open,children:a.modal?(0,J.jsx)(Iu,{...i,ref:t}):(0,J.jsx)(Lu,{...i,ref:t})})},`DialogContent`)),Iu=K.forwardRef(_u(function(e,t){let n=Su(Pu,e.__scopeDialog),r=K.useRef(null),i=s(t,n.contentRef,r);return K.useEffect(()=>{let e=r.current;if(e)return De(e)},[]),(0,J.jsx)(Ru,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:k(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:k(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:k(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Lu=K.forwardRef(_u(function(e,t){let n=Su(Pu,e.__scopeDialog),r=K.useRef(!1),i=K.useRef(!1);return(0,J.jsx)(Ru,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Ru=K.forwardRef(_u(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Su(Pu,n);return Ce(),(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(le,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,J.jsx)(H,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Uu(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),zu=`DialogTitle`,Bu=K.forwardRef(_u(function(e,t){let{__scopeDialog:n,...r}=e,i=Su(zu,n),{setTitleCount:a}=i;return Le(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,J.jsx)(E.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Vu=`DialogDescription`,Hu=K.forwardRef(_u(function(e,t){let{__scopeDialog:n,...r}=e,i=Su(Vu,n),{setDescriptionCount:a}=i;return Le(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,J.jsx)(E.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`));function Uu(e){return e?`open`:`closed`}_u(Uu,`getState`);var Wu=Object.defineProperty,Gu=(e,t)=>Wu(e,`name`,{value:t,configurable:!0}),Ku=!1;function qu(){let[e,t]=K.useState(Ku);return K.useEffect(()=>{Ku||(Ku=!0,t(!0))},[]),e}Gu(qu,`useIsHydrated`);var Ju=K.useSyncExternalStore;function Yu(){return()=>{}}Gu(Yu,`subscribe`);function Xu(){return Ju(Yu,()=>!0,()=>!1)}Gu(Xu,`useIsHydratedModern`);var Zu=typeof Ju==`function`?Xu:qu,Qu=Object.defineProperty,$u=(e,t)=>Qu(e,`name`,{value:t,configurable:!0}),ed=`rovingFocusGroup.onEntryFocus`,td={bubbles:!1,cancelable:!0},nd=`RovingFocusGroup`,[rd,id,ad]=tu(nd),[od,sd]=L(nd,[ad]),[cd,ld]=od(nd),ud=K.forwardRef($u(function(e,t){return(0,J.jsx)(rd.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,J.jsx)(rd.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,J.jsx)(dd,{...e,ref:t})})})},`RovingFocusGroup`)),dd=K.forwardRef($u(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=K.useRef(null),m=s(t,p),h=hu(a),[g,_]=ke({prop:o,defaultProp:c??null,onChange:l,caller:nd}),[v,y]=K.useState(!1),b=F(u),x=id(n),S=K.useRef(!1),[C,w]=K.useState(0);return K.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(ed,b),()=>e.removeEventListener(ed,b)},[b]),(0,J.jsx)(cd,{scope:n,orientation:r,dir:h,loop:i,currentTabStopId:g,onItemFocus:K.useCallback(e=>_(e),[_]),onItemShiftTab:K.useCallback(()=>y(!0),[]),onFocusableItemAdd:K.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:K.useCallback(()=>w(e=>e-1),[]),children:(0,J.jsx)(E.div,{tabIndex:v||C===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:k(e.onMouseDown,()=>{S.current=!0}),onFocus:k(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(ed,td);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);_d([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),d)}}S.current=!1}),onBlur:k(e.onBlur,()=>y(!1))})})},`RovingFocusGroupImpl`)),fd=`RovingFocusGroupItem`,pd=K.forwardRef($u(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=je(),l=a||c,u=ld(fd,n),d=u.currentTabStopId===l,f=id(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=Zu();return Le(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),K.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,J.jsx)(rd.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,J.jsx)(E.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:k(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:k(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:k(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=gd(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?vd(n,r+1):n.slice(r+1)}setTimeout(()=>_d(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),md={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function hd(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}$u(hd,`getDirectionAwareKey`);function gd(e,t,n){let r=hd(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return md[r]}$u(gd,`getFocusIntent`);function _d(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}$u(_d,`focusFirst`);function vd(e,t){return e.map((n,r)=>e[(t+r)%e.length])}$u(vd,`wrapArray`);var yd=ud,bd=pd,xd=Object.defineProperty,Q=(e,t)=>xd(e,`name`,{value:t,configurable:!0}),Sd=[`Enter`,` `],Cd=[`ArrowDown`,`PageUp`,`Home`],wd=[`ArrowUp`,`PageDown`,`End`],Td=[...Cd,...wd],Ed={ltr:[...Sd,`ArrowRight`],rtl:[...Sd,`ArrowLeft`]},Dd={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Od=`Menu`,[kd,Ad,jd]=tu(Od),[Md,Nd]=L(Od,[jd,oe,sd]),Pd=oe(),Fd=sd(),[Id,Ld]=Md(Od),[Rd,zd]=Md(Od),Bd=Q(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Pd(t),[c,l]=K.useState(null),u=K.useRef(!1),d=F(a),f=hu(i);return K.useEffect(()=>{let e=Q(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=Q(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),K.useEffect(()=>{if(!n)return;let e=Q(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,J.jsx)(ce,{...s,children:(0,J.jsx)(Id,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,J.jsx)(Rd,{scope:t,onClose:K.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),Vd=K.forwardRef(Q(function(e,t){let{__scopeMenu:n,...r}=e,i=Pd(n);return(0,J.jsx)(xe,{...i,...r,ref:t})},`MenuAnchor`)),Hd=`MenuPortal`,[Ud,Wd]=Md(Hd,{forceMount:void 0}),Gd=Q(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Ld(Hd,t);return(0,J.jsx)(Ud,{scope:t,forceMount:n,children:(0,J.jsx)(W,{present:n||a.open,children:(0,J.jsx)(ae,{asChild:!0,container:i,children:r})})})},`MenuPortal`),Kd=`MenuContent`,[qd,Jd]=Md(Kd),Yd=K.forwardRef(Q(function(e,t){let n=Wd(Kd,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Ld(Kd,e.__scopeMenu),o=zd(Kd,e.__scopeMenu);return(0,J.jsx)(kd.Provider,{scope:e.__scopeMenu,children:(0,J.jsx)(W,{present:r||a.open,children:(0,J.jsx)(kd.Slot,{scope:e.__scopeMenu,children:o.modal?(0,J.jsx)(Xd,{...i,ref:t}):(0,J.jsx)(Zd,{...i,ref:t})})})})},`MenuContent`)),Xd=K.forwardRef(Q(function(e,t){let n=Ld(Kd,e.__scopeMenu),r=K.useRef(null),i=s(t,r);return K.useEffect(()=>{let e=r.current;if(e)return De(e)},[]),(0,J.jsx)($d,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:k(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Zd=K.forwardRef(Q(function(e,t){let n=Ld(Kd,e.__scopeMenu);return(0,J.jsx)($d,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Qd=g(`MenuContent.ScrollLock`),$d=K.forwardRef(Q(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:c,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=Ld(Kd,n),v=zd(Kd,n),y=Pd(n),b=Fd(n),x=Ad(n),[S,C]=K.useState(null),w=K.useRef(null),T=s(t,w,_.onContentChange),E=K.useRef(0),D=K.useRef(``),O=K.useRef(0),A=K.useRef(null),j=K.useRef(`right`),M=K.useRef(0),N=h?_e:K.Fragment,P=h?{as:Qd,allowPinchZoom:!0}:void 0,F=Q(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Af(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;Q((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);K.useEffect(()=>()=>window.clearTimeout(E.current),[]),Ce();let I=K.useCallback(e=>j.current===A.current?.side&&Mf(e,A.current?.area),[]);return(0,J.jsx)(qd,{scope:n,searchRef:D,onItemEnter:K.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:K.useCallback(e=>{I(e)||(w.current?.focus(),C(null))},[I]),onTriggerLeave:K.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:O,onPointerGraceIntentChange:K.useCallback(e=>{A.current=e},[]),children:(0,J.jsx)(N,{...P,children:(0,J.jsx)(le,{asChild:!0,trapped:i,onMountAutoFocus:k(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,J.jsx)(H,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,J.jsx)(yd,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:k(l,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,J.jsx)(he,{role:`menu`,"aria-orientation":`vertical`,"data-state":Tf(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:k(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&F(e.key));let i=w.current;if(e.target!==i||!Td.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);wd.includes(e.key)&&a.reverse(),Of(a)}),onBlur:k(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:k(e.onPointerMove,Nf(e=>{let t=e.target,n=M.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>M.current?`right`:`left`;j.current=t,M.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),ef=K.forwardRef(Q(function(e,t){let{__scopeMenu:n,...r}=e;return(0,J.jsx)(E.div,{role:`group`,...r,ref:t})},`MenuGroup`)),tf=K.forwardRef(Q(function(e,t){let{__scopeMenu:n,...r}=e;return(0,J.jsx)(E.div,{...r,ref:t})},`MenuLabel`)),nf=`MenuItem`,rf=`menu.itemSelect`,af=K.forwardRef(Q(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=K.useRef(null),o=zd(nf,e.__scopeMenu),c=Jd(nf,e.__scopeMenu),l=s(t,a),u=K.useRef(!1),d=Q(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(rf,{bubbles:!0,cancelable:!0});e.addEventListener(rf,e=>r?.(e),{once:!0}),Ne(e,t),t.defaultPrevented?u.current=!1:o.onClose()}},`handleSelect`);return(0,J.jsx)(of,{...i,ref:l,disabled:n,onClick:k(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),u.current=!0},onPointerUp:k(e.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:k(e.onKeyDown,e=>{n||e.target!==e.currentTarget||c.searchRef.current!==``&&e.key===` `||Sd.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),of=K.forwardRef(Q(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Jd(nf,n),c=Fd(n),l=K.useRef(null),u=s(t,l),[d,f]=K.useState(!1),[p,m]=K.useState(``);return K.useEffect(()=>{let e=l.current;e&&m((e.textContent??``).trim())},[a.children]),(0,J.jsx)(kd.ItemSlot,{scope:n,disabled:r,textValue:i??p,children:(0,J.jsx)(bd,{asChild:!0,...c,focusable:!r,children:(0,J.jsx)(E.div,{role:`menuitem`,"data-highlighted":d?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:u,onPointerMove:k(e.onPointerMove,Nf(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:k(e.onPointerLeave,Nf(e=>o.onItemLeave(e))),onFocus:k(e.onFocus,()=>f(!0)),onBlur:k(e.onBlur,()=>f(!1))})})})},`MenuItemImpl`)),[sf,cf]=Md(`MenuRadioGroup`,{value:void 0,onValueChange:Q(()=>{},`onValueChange`)}),lf=K.forwardRef(Q(function(e,t){let{value:n,onValueChange:r,...i}=e,a=F(r);return(0,J.jsx)(sf,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,J.jsx)(ef,{...i,ref:t})})},`MenuRadioGroup`)),uf=`MenuRadioItem`,df=K.forwardRef(Q(function(e,t){let{value:n,...r}=e,i=cf(uf,e.__scopeMenu),a=n===i.value;return(0,J.jsx)(pf,{scope:e.__scopeMenu,checked:a,children:(0,J.jsx)(af,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Df(a),onSelect:k(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),ff=`MenuItemIndicator`,[pf,mf]=Md(ff,{checked:!1}),hf=K.forwardRef(Q(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=mf(ff,n);return(0,J.jsx)(W,{present:r||Ef(a.checked)||a.checked===!0,children:(0,J.jsx)(E.span,{...i,ref:t,"data-state":Df(a.checked)})})},`MenuItemIndicator`)),gf=K.forwardRef(Q(function(e,t){let{__scopeMenu:n,...r}=e;return(0,J.jsx)(E.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),_f=`MenuSub`,[vf,yf]=Md(_f),bf=Q(e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Ld(_f,t),o=Pd(t),[s,c]=K.useState(null),[l,u]=K.useState(null),d=F(i);return K.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,J.jsx)(ce,{...o,children:(0,J.jsx)(Id,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,J.jsx)(vf,{scope:t,contentId:je(),triggerId:je(),trigger:s,onTriggerChange:c,children:n})})})},`MenuSub`),xf=`MenuSubTrigger`,Sf=K.forwardRef(Q(function(e,t){let n=Ld(xf,e.__scopeMenu),r=zd(xf,e.__scopeMenu),i=yf(xf,e.__scopeMenu),a=Jd(xf,e.__scopeMenu),o=K.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:l}=a,u={__scopeMenu:e.__scopeMenu},d=K.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);K.useEffect(()=>d,[d]),K.useEffect(()=>{let e=c.current;return()=>{window.clearTimeout(e),l(null)}},[c,l]);let f=s(t,i.onTriggerChange);return(0,J.jsx)(Vd,{asChild:!0,...u,children:(0,J.jsx)(of,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":Tf(n.open),...e,ref:f,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:k(e.onPointerMove,Nf(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:k(e.onPointerLeave,Nf(e=>{d();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,s=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:s,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:s,y:t.bottom}],side:r}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:k(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||a.searchRef.current!==``&&t.key===` `||Ed[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),Cf=`MenuSubContent`,wf=K.forwardRef(Q(function(e,t){let n=Wd(Kd,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=Ld(Kd,e.__scopeMenu),c=zd(Kd,e.__scopeMenu),l=yf(Cf,e.__scopeMenu),u=K.useRef(null),d=s(t,u);return(0,J.jsx)(kd.Provider,{scope:e.__scopeMenu,children:(0,J.jsx)(W,{present:r||o.open,children:(0,J.jsx)(kd.Slot,{scope:e.__scopeMenu,children:(0,J.jsx)($d,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:d,align:i,side:c.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{c.isUsingKeyboardRef.current&&u.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:k(e.onFocusOutside,e=>{e.target!==l.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:k(e.onEscapeKeyDown,e=>{c.onClose(),e.preventDefault()}),onKeyDown:k(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Dd[c.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function Tf(e){return e?`open`:`closed`}Q(Tf,`getOpenState`);function Ef(e){return e===`indeterminate`}Q(Ef,`isIndeterminate`);function Df(e){return Ef(e)?`indeterminate`:e?`checked`:`unchecked`}Q(Df,`getCheckedState`);function Of(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Q(Of,`focusFirst`);function kf(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Q(kf,`wrapArray`);function Af(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=kf(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}Q(Af,`getNextMatch`);function jf(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Q(jf,`isPointInPolygon`);function Mf(e,t){return t?jf({x:e.clientX,y:e.clientY},t):!1}Q(Mf,`isPointerInGraceArea`);function Nf(e){return t=>t.pointerType===`mouse`?e(t):void 0}Q(Nf,`whenMouse`);var Pf=Bd,Ff=Vd,If=Gd,Lf=Yd,Rf=ef,zf=tf,Bf=af,Vf=lf,Hf=df,Uf=hf,Wf=gf,Gf=bf,Kf=Sf,qf=wf,Jf=Object.defineProperty,Yf=(e,t)=>Jf(e,`name`,{value:t,configurable:!0}),Xf=`DropdownMenu`,[Zf,Qf]=L(Xf,[Nd]),$f=Nd(),[ep,tp]=Zf(Xf),np=Yf(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=$f(t),l=K.useRef(null),[u,d]=ke({prop:i,defaultProp:a??!1,onChange:o,caller:Xf});return(0,J.jsx)(ep,{scope:t,triggerId:je(),triggerRef:l,contentId:je(),open:u,onOpenChange:d,onOpenToggle:K.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,J.jsx)(Pf,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),rp=`DropdownMenuTrigger`,ip=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=tp(rp,n),o=$f(n),c=s(t,a.triggerRef);return(0,J.jsx)(Ff,{asChild:!0,...o,children:(0,J.jsx)(E.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:c,onPointerDown:k(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:k(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),ap=Yf(e=>{let{__scopeDropdownMenu:t,...n}=e,r=$f(t);return(0,J.jsx)(If,{...r,...n})},`DropdownMenuPortal`),op=`DropdownMenuContent`,sp=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tp(op,n),a=$f(n),o=K.useRef(!1);return(0,J.jsx)(Lf,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:k(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:k(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),cp=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$f(n);return(0,J.jsx)(Rf,{...i,...r,ref:t})},`DropdownMenuGroup`)),lp=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$f(n);return(0,J.jsx)(zf,{...i,...r,ref:t})},`DropdownMenuLabel`)),up=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$f(n);return(0,J.jsx)(Bf,{...i,...r,ref:t})},`DropdownMenuItem`)),dp=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$f(n);return(0,J.jsx)(Vf,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),fp=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$f(n);return(0,J.jsx)(Hf,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),pp=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$f(n);return(0,J.jsx)(Uf,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),mp=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$f(n);return(0,J.jsx)(Wf,{...i,...r,ref:t})},`DropdownMenuSeparator`)),hp=Yf(e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=$f(t),[s,c]=ke({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,J.jsx)(Gf,{...o,open:s,onOpenChange:c,children:n})},`DropdownMenuSub`),gp=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$f(n);return(0,J.jsx)(Kf,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),_p=K.forwardRef(Yf(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$f(n);return(0,J.jsx)(qf,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuSubContent`)),vp=np,yp=ip,bp=ap,xp=sp,Sp=cp,Cp=lp,wp=up,Tp=dp,Ep=fp,Dp=pp,Op=mp,kp=hp,Ap=gp,jp=_p,Mp=Object.defineProperty,Np=(e,t)=>Mp(e,`name`,{value:t,configurable:!0});function Pp(e){let t=K.useRef({value:e,previous:e});return K.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}Np(Pp,`usePrevious`);var Fp=Object.defineProperty,Ip=(e,t)=>Fp(e,`name`,{value:t,configurable:!0});function Lp(e,[t,n]){return Math.min(n,Math.max(t,e))}Ip(Lp,`clamp`);var Rp=Object.defineProperty,$=(e,t)=>Rp(e,`name`,{value:t,configurable:!0}),zp=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Bp=[` `,`Enter`],Vp=`Select`,[Hp,Up,Wp]=tu(Vp),[Gp,Kp]=L(Vp,[Wp,oe]),qp=oe(),[Jp,Yp]=Gp(Vp),[Xp,Zp]=Gp(Vp);function Qp(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=qp(t),[_,v]=K.useState(null),[y,b]=K.useState(null),[x,S]=K.useState(!1),C=hu(l),[w,T]=ke({prop:r,defaultProp:i??!1,onChange:a,caller:Vp}),[E,D]=ke({prop:o,defaultProp:s,onChange:c,caller:Vp}),O=K.useRef(null),k=K.useRef(E);K.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=$(()=>D(k.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,D]);let A=!_||!!m||!!_.closest(`form`),[j,M]=K.useState(new Set),N=je(),P=Array.from(j).map(e=>e.props.value).join(`;`),F=K.useCallback(e=>{M(t=>new Set(t).add(e))},[]),I=K.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),L={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:N,value:E,onValueChange:D,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:j,nativeSelectKey:P,isFormControl:A};return(0,J.jsx)(ce,{...g,children:(0,J.jsx)(Jp,{scope:t,...L,children:(0,J.jsx)(Hp.Provider,{scope:t,children:(0,J.jsx)(Xp,{scope:t,onNativeOptionAdd:F,onNativeOptionRemove:I,children:Bm(h)?h(L):n})})})})}$(Qp,`SelectProvider`);var $p=$(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,J.jsx)(Qp,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,J.jsxs)(J.Fragment,{children:[n,e?(0,J.jsx)(zm,{__scopeSelect:t}):null]})})},`Select`),em=`SelectTrigger`,tm=K.forwardRef($(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=qp(n),o=Yp(em,n),c=o.disabled||r,l=s(t,o.onTriggerChange),u=Up(n),d=K.useRef(`touch`),[f,p,m]=Hm(e=>{let t=u().filter(e=>!e.disabled),n=Um(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),h=$(e=>{c||(o.onOpenChange(!0),m()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,J.jsx)(xe,{asChild:!0,...a,children:(0,J.jsx)(E.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":Vm(o.value)?``:void 0,...i,ref:l,onClick:k(i.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:k(i.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:k(i.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&p(e.key),!(t&&e.key===` `)&&zp.includes(e.key)&&(h(),e.preventDefault())})})})},`SelectTrigger`)),nm=`SelectValue`,rm=K.forwardRef($(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...c}=e,l=Yp(nm,n),{onValueNodeHasChildrenChange:u}=l,d=a!==void 0,f=s(t,l.onValueNodeChange);Le(()=>{u(d)},[u,d]);let p=Vm(l.value);return(0,J.jsx)(E.span,{...c,asChild:!p&&c.asChild,ref:f,style:{pointerEvents:`none`},children:(0,J.jsx)(K.Fragment,{children:p?o:a},p?`placeholder`:`value`)})},`SelectValue`)),im=K.forwardRef($(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,J.jsx)(E.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[am,om]=Gp(`SelectPortal`,{forceMount:void 0}),sm=$(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,J.jsx)(am,{scope:e.__scopeSelect,forceMount:n,children:(0,J.jsx)(ae,{asChild:!0,...r})})},`SelectPortal`),cm=`SelectContent`,lm=K.forwardRef($(function(e,t){let n=om(cm,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=Yp(cm,e.__scopeSelect),[o,s]=K.useState();return Le(()=>{s(new DocumentFragment)},[]),(0,J.jsx)(W,{present:r||a.open,children:({present:e})=>e?(0,J.jsx)(hm,{...i,ref:t}):(0,J.jsx)(um,{...i,fragment:o})})},`SelectContent`)),um=K.forwardRef($(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?sa.createPortal((0,J.jsx)(fm,{scope:n,children:(0,J.jsx)(Hp.Slot,{scope:n,children:(0,J.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),dm=10,[fm,pm]=Gp(cm),mm=g(`SelectContent.RemoveScroll`),hm=K.forwardRef($(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_,...v}=e,y=Yp(cm,n),[b,x]=K.useState(null),[S,C]=K.useState(null),w=s(t,x),[T,E]=K.useState(null),[D,O]=K.useState(null),A=Up(n),[j,M]=K.useState(!1),N=K.useRef(!1);K.useEffect(()=>{if(b)return De(b)},[b]),Ce();let P=K.useCallback(e=>{let[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[A,S]),F=K.useCallback(()=>P([T,b]),[P,T,b]);K.useEffect(()=>{j&&F()},[j,F]);let{onOpenChange:I,triggerPointerDownPosRef:L}=y;K.useEffect(()=>{if(b){let e={x:0,y:0},t=$(t=>{e={x:Math.abs(Math.round(t.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(L.current?.y??0))}},`handlePointerMove`),n=$(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(b)||I(!1),document.removeEventListener(`pointermove`,t),L.current=null},`handlePointerUp`);return L.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[b,I,L]),K.useEffect(()=>{let e=$(()=>I(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[I]);let[ee,R]=Hm(e=>{let t=A().filter(e=>!e.disabled),n=Um(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),z=K.useCallback((e,t,n)=>{let r=!N.current&&!n;(y.value!==void 0&&y.value===t||r)&&(E(e),r&&(N.current=!0))},[y.value]),B=K.useCallback(()=>b?.focus(),[b]),V=K.useCallback((e,t,n)=>{let r=!N.current&&!n;(y.value!==void 0&&y.value===t||r)&&O(e)},[y.value]),te=r===`popper`?_m:gm,U=te===_m?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_}:{};return(0,J.jsx)(fm,{scope:n,content:b,viewport:S,onViewportChange:C,itemRefCallback:z,selectedItem:T,onItemLeave:B,itemTextRefCallback:V,focusSelectedItem:F,selectedItemText:D,position:r,isPositioned:j,searchRef:ee,children:(0,J.jsx)(_e,{as:mm,allowPinchZoom:!0,children:(0,J.jsx)(le,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:k(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,J.jsx)(H,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,J.jsx)(te,{role:`listbox`,id:y.contentId,"data-state":y.open?`open`:`closed`,dir:y.dir,onContextMenu:e=>e.preventDefault(),...v,...U,onPlaced:()=>M(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,...v.style},onKeyDown:k(v.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&R(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>P(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),gm=K.forwardRef($(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=Yp(cm,n),o=pm(cm,n),[c,l]=K.useState(null),[u,d]=K.useState(null),f=s(t,d),p=Up(n),m=K.useRef(!1),h=K.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,b=K.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&u&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-dm,d=Lp(a,[dm,Math.max(dm,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-dm,d=Lp(a,[dm,Math.max(dm,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let o=p(),s=window.innerHeight-dm*2,l=g.scrollHeight,d=window.getComputedStyle(u),f=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=f+h+l+b+y,S=Math.min(_.offsetHeight*5,x),C=window.getComputedStyle(g),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-dm,D=s-E,O=_.offsetHeight/2,k=_.offsetTop+O,A=f+h+k,j=x-A;if(A<=E){let e=o.length>0&&_===o[o.length-1].ref.current;c.style.bottom=`0px`;let t=u.clientHeight-g.offsetTop-g.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);c.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+g.offsetTop+(e?w:0)+O)+j;c.style.height=t+`px`,g.scrollTop=A-E+g.offsetTop}c.style.margin=`${dm}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,c,u,g,_,v,a.dir,r]);Le(()=>b(),[b]);let[x,S]=K.useState();return Le(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]),(0,J.jsx)(vm,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:K.useCallback(e=>{e&&h.current===!0&&(b(),y?.(),h.current=!1)},[b,y]),children:(0,J.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,J.jsx)(E.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),_m=K.forwardRef($(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=dm,...a}=e,o=qp(n);return(0,J.jsx)(he,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[vm,ym]=Gp(cm,{}),bm=`SelectViewport`,xm=K.forwardRef($(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=pm(bm,n),o=ym(bm,n),c=s(t,a.onViewportChange),l=K.useRef(0);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,J.jsx)(Hp.Slot,{scope:n,children:(0,J.jsx)(E.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:k(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-dm*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})},`SelectViewport`)),[Sm,Cm]=Gp(`SelectGroup`),wm=K.forwardRef($(function(e,t){let{__scopeSelect:n,...r}=e,i=je();return(0,J.jsx)(Sm,{scope:n,id:i,children:(0,J.jsx)(E.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})},`SelectGroup`)),Tm=`SelectItem`,[Em,Dm]=Gp(Tm),Om=K.forwardRef($(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,c=Yp(Tm,n),l=pm(Tm,n),u=c.value===r,[d,f]=K.useState(a??``),[p,m]=K.useState(!1),h=s(t,F(e=>l.itemRefCallback?.(e,r,i))),g=je(),_=K.useRef(`touch`),v=$(()=>{i||(c.onValueChange(r),c.onOpenChange(!1))},`handleSelect`);return(0,J.jsx)(Em,{scope:n,value:r,disabled:i,textId:g,isSelected:u,onItemTextChange:K.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,J.jsx)(Hp.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:(0,J.jsx)(E.div,{role:`option`,"aria-labelledby":g,"data-highlighted":p?``:void 0,"aria-selected":u&&p,"data-state":u?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:k(o.onFocus,()=>m(!0)),onBlur:k(o.onBlur,()=>m(!1)),onClick:k(o.onClick,()=>{_.current!==`mouse`&&v()}),onPointerUp:k(o.onPointerUp,()=>{_.current===`mouse`&&v()}),onPointerDown:k(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:k(o.onPointerMove,e=>{_.current=e.pointerType,i?l.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:k(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:k(o.onKeyDown,e=>{i||e.target!==e.currentTarget||l.searchRef?.current!==``&&e.key===` `||(Bp.includes(e.key)&&v(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),km=`SelectItemText`,Am=K.forwardRef($(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=Yp(km,n),c=pm(km,n),l=Dm(km,n),u=Zp(km,n),[d,f]=K.useState(null),p=F(e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),m=s(t,f,l.onItemTextChange,p),h=d?.textContent,g=K.useMemo(()=>(0,J.jsx)(`option`,{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:_,onNativeOptionRemove:v}=u;return Le(()=>(_(g),()=>v(g)),[_,v,g]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(E.span,{id:l.textId,...a,ref:m}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!Vm(o.value)?sa.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),jm=`SelectItemIndicator`,Mm=K.forwardRef($(function(e,t){let{__scopeSelect:n,...r}=e;return Dm(jm,n).isSelected?(0,J.jsx)(E.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Nm=`SelectScrollUpButton`,Pm=K.forwardRef($(function(e,t){let n=pm(Nm,e.__scopeSelect),r=ym(Nm,e.__scopeSelect),[i,a]=K.useState(!1),o=s(t,r.onScrollButtonChange);return Le(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};$(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,J.jsx)(Lm,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Fm=`SelectScrollDownButton`,Im=K.forwardRef($(function(e,t){let n=pm(Fm,e.__scopeSelect),r=ym(Fm,e.__scopeSelect),[i,a]=K.useState(!1),o=s(t,r.onScrollButtonChange);return Le(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};$(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,J.jsx)(Lm,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Lm=K.forwardRef($(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=pm(`SelectScrollButton`,n),o=K.useRef(null),s=Up(n),c=K.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return K.useEffect(()=>()=>c(),[c]),Le(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,J.jsx)(E.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:k(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:k(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:k(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),Rm=`SelectBubbleInput`,zm=K.forwardRef($(function({__scopeSelect:e,...t},n){let r=Yp(Rm,e),{value:i,onValueChange:a,required:o,disabled:c,name:l,autoComplete:u,form:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=K.useRef(null),h=s(n,m),g=i??``,_=Pp(g),v=Array.from(f).some(e=>(e.props.value??``)===``);return K.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(_!==g&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,g),e.dispatchEvent(t)}},[_,g]),(0,J.jsxs)(E.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:l,autoComplete:u,disabled:c,form:d,onChange:e=>a(e.target.value),...t,style:{...pe,...t.style},ref:h,defaultValue:g,children:[Vm(i)&&!v?(0,J.jsx)(`option`,{value:``}):null,Array.from(f)]},p)},`SelectBubbleInput`));function Bm(e){return typeof e==`function`}$(Bm,`isFunction`);function Vm(e){return e===``||e===void 0}$(Vm,`shouldShowPlaceholder`);function Hm(e){let t=F(e),n=K.useRef(``),r=K.useRef(0),i=K.useCallback(e=>{let i=n.current+e;t(i),$((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=K.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return K.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}$(Hm,`useTypeaheadSearch`);function Um(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Wm(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}$(Um,`findNextItem`);function Wm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}$(Wm,`wrapArray`);function Gm(e){return(0,J.jsx)(Cu,{"data-slot":`dialog`,...e})}function Km(e){return(0,J.jsx)(Tu,{"data-slot":`dialog-trigger`,...e})}function qm({children:e,...t}){return typeof document>`u`?(0,J.jsx)(J.Fragment,{children:e}):(0,J.jsx)(ku,{"data-slot":`dialog-portal`,...t,children:e})}function Jm({className:e,...t}){return(0,J.jsx)(ju,{className:m(`fixed inset-0 z-50 bg-scrim data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),"data-slot":`dialog-overlay`,...t})}function Ym({children:e,className:t,...n}){return(0,J.jsxs)(qm,{children:[(0,J.jsx)(Jm,{}),(0,J.jsx)(Fu,{className:m(`fixed left-1/2 top-1/2 z-50 grid min-w-0 max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-auto rounded-surface bg-dialog p-5 text-foreground shadow-panel outline-none duration-180 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,t),"data-slot":`dialog-content`,...n,children:e})]})}function Xm({className:e,...t}){return(0,J.jsx)(`div`,{className:m(`flex flex-col gap-1 text-left`,e),"data-slot":`dialog-header`,...t})}function Zm({className:e,...t}){return(0,J.jsx)(`div`,{className:m(`flex justify-end gap-2`,e),"data-slot":`dialog-footer`,...t})}function Qm({className:e,...t}){return(0,J.jsx)(Bu,{className:m(`text-heading font-semibold leading-tight`,e),"data-slot":`dialog-title`,...t})}function $m({className:e,...t}){return(0,J.jsx)(Hu,{className:m(`text-body-small text-muted-foreground`,e),"data-slot":`dialog-description`,...t})}function eh({draftPath:e,isPathValidated:t,requestedPath:n,selectedPaths:r,submittedPath:i,validatedPath:a}){return r.length>0?r:!t||e!==void 0||i===void 0||n!==i||a===void 0?[]:[a]}var th=`flex cursor-default items-center justify-center py-1 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`;function nh({...e}){return(0,J.jsx)($p,{"data-slot":`select`,...e})}function rh({...e}){return(0,J.jsx)(wm,{"data-slot":`select-group`,...e})}function ih({...e}){return(0,J.jsx)(rm,{"data-slot":`select-value`,...e})}function ah({className:e,size:t=`default`,children:n,...r}){return(0,J.jsxs)(tm,{"data-slot":`select-trigger`,"data-size":t,className:m(`flex w-fit items-center justify-between gap-2 whitespace-nowrap rounded-control border border-separator-strong bg-panel px-3 py-2 text-label outline-none transition-colors focus:border-brand focus:shadow-focus disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:text-muted-foreground [&_svg:not([class*='size-'])]:size-4`,t===`toolbar`&&`h-6 gap-1 px-1 text-caption [&_svg:not([class*='size-'])]:size-3`,e),...r,children:[n,(0,J.jsx)(im,{asChild:!0,children:(0,J.jsx)(M,{className:`opacity-50`})})]})}function oh({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,J.jsx)(sm,{children:(0,J.jsxs)(lm,{"data-slot":`select-content`,className:m(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-control border border-separator bg-raised text-foreground shadow-panel data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,J.jsx)(ch,{}),(0,J.jsx)(xm,{className:m(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,J.jsx)(lh,{})]})})}function sh({className:e,children:t,...n}){return(0,J.jsxs)(Om,{"data-slot":`select-item`,className:m(`relative flex w-full cursor-default items-center gap-2 rounded-control py-1.5 pr-8 pl-2 text-label outline-hidden select-none focus:bg-control-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:text-muted-foreground [&_svg:not([class*='size-'])]:size-3.5`,e),...n,children:[(0,J.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,J.jsx)(Mm,{children:(0,J.jsx)(Ke,{})})}),(0,J.jsx)(Am,{children:t})]})}function ch({className:e,...t}){return(0,J.jsx)(Pm,{"data-slot":`select-scroll-up-button`,className:m(th,e),...t,children:(0,J.jsx)(vt,{})})}function lh({className:e,...t}){return(0,J.jsx)(Im,{"data-slot":`select-scroll-down-button`,className:m(th,e),...t,children:(0,J.jsx)(M,{})})}function uh(e,t){let n=t.toLowerCase();return e.find(e=>n.startsWith(e.path.toLowerCase()))}function dh({disabled:e,includeHidden:t,labels:n,listing:r,onNavigateParent:i,onNavigatePath:a,onNavigateRoot:o,onPathChange:s,onToggleHidden:c,path:l}){let u=r===void 0?void 0:uh(r.roots,r.path)?.path,d=t?n.hideHidden:n.showHidden;return(0,J.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 border-y border-separator bg-panel px-3 sm:px-4`,children:[r===void 0||r.roots.length<2?null:(0,J.jsxs)(nh,{disabled:e,onValueChange:o,...u===void 0?{}:{value:u},children:[(0,J.jsx)(ah,{"aria-label":n.filesystemRoot,className:`h-8 min-w-20 px-2 font-mono`,size:`sm`,children:(0,J.jsx)(ih,{placeholder:n.filesystemRoot})}),(0,J.jsx)(oh,{position:`popper`,children:r.roots.map(e=>(0,J.jsx)(sh,{value:e.path,children:e.name},e.path))})]}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":n.parent,disabled:r?.parentPath===null||r===void 0||e,onClick:i,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(He,{"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:n.parent})]}),(0,J.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1`,onSubmit:e=>{e.preventDefault(),a()},children:[(0,J.jsx)(Pt,{"aria-label":n.pathLabel,autoComplete:`off`,className:`h-8 min-w-0 px-2 font-mono text-caption max-workbench:h-11`,disabled:e,onChange:e=>{s(e.target.value)},placeholder:n.pathPlaceholder,spellCheck:!1,value:l,variant:`compact`}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":n.goToPath,disabled:l.trim().length===0||e,size:`icon-sm`,type:`submit`,variant:`ghost`,children:(0,J.jsx)(mc,{"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:n.goToPath})]})]}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":d,"aria-pressed":t,disabled:e,onClick:c,size:`icon-sm`,type:`button`,variant:`ghost`,children:t?(0,J.jsx)(bc,{"aria-hidden":`true`}):(0,J.jsx)(xc,{"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:d})]})]})}function fh({directoryStates:e,entries:t,expandedPaths:n,onRetry:r,onRootCheckedChange:i,selectedPaths:a,selectionDisabled:o=!1}){let{t:s}=y(`workbench`);return t.map(t=>{let c=e.get(t.path),l=n.has(t.path);return(0,J.jsx)(_t,{name:t.name,path:t.path,selectionControl:(0,J.jsx)(Je,{"aria-label":s(`projectPicker.selectRoot`,{name:t.name}),checked:a.has(t.path),disabled:o,onCheckedChange:e=>{i(t.path,e===!0)}}),trailing:l&&c?.isFetching===!0?(0,J.jsx)(O,{"aria-hidden":`true`,className:`size-3.5 animate-spin text-muted-foreground`}):void 0,children:l?c?.error!==null&&c?.error!==void 0?(0,J.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-2 px-2 py-1`,children:[(0,J.jsx)(`p`,{className:`min-w-0 text-caption text-danger`,role:`alert`,children:s(`projectPicker.loadBranchError`)}),(0,J.jsxs)(v,{className:`shrink-0`,onClick:()=>{r(t.path)},size:`sm`,type:`button`,variant:`ghost`,children:[(0,J.jsx)(Ac,{"aria-hidden":`true`,"data-icon":`inline-start`}),s(`actions.retry`)]})]}):c?.data===void 0?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-caption text-muted-foreground`,role:`status`,children:s(`projectPicker.loadingBranch`)}):c.data.entries.length===0?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-caption text-muted-foreground`,children:s(`projectPicker.empty`)}):(0,J.jsx)(fh,{directoryStates:e,entries:c.data.entries,expandedPaths:n,onRetry:r,onRootCheckedChange:i,selectedPaths:a,selectionDisabled:o}):null},t.path)})}function ph({directoryStates:e,expandedPaths:t,listing:n,onExpandedChange:r,onRetry:i,onRootCheckedChange:a,selectedPaths:o,selectionDisabled:s=!1}){let{t:c}=y(`workbench`),l=(0,K.useMemo)(()=>new Map(e.map(e=>[e.path,e])),[e]);return(0,J.jsx)(Ct,{"aria-label":c(`projectPicker.treeLabel`),expanded:t,onExpandedChange:r,children:(0,J.jsx)(fh,{directoryStates:l,entries:n.entries,expandedPaths:t,onRetry:i,onRootCheckedChange:a,selectedPaths:o,selectionDisabled:s})})}function mh({client:e,isAdding:t,onAdd:n,onClose:r}){let{t:i}=y(`workbench`),[a,o]=(0,K.useState)(),[s,c]=(0,K.useState)(),[l,u]=(0,K.useState)(),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(()=>new Set),[h,g]=(0,K.useState)([]),_=R({queryFn:({signal:t})=>e.listProjectDirectories(a,{includeHidden:d,signal:t}),queryKey:[`project-directories`,a??null,d],staleTime:3e4}),b=_.data,x=eh({draftPath:s,isPathValidated:_.isSuccess,requestedPath:a,selectedPaths:h,submittedPath:l,validatedPath:b?.path}),S=x.length>0,C=h.length===0&&x.length===1,w=(0,K.useMemo)(()=>new Set(h),[h]),T=C?x[0]??``:h.map((e,t)=>t===0?i(`projectPicker.primaryRootSummary`,{path:e}):e).join(i(`projectPicker.rootSeparator`)),E=(0,K.useMemo)(()=>[...p],[p]),D=Xa({queries:E.map(t=>({queryFn:({signal:n})=>e.listProjectDirectories(t,{includeHidden:d,signal:n}),queryKey:[`project-directories`,t,d],staleTime:3e4}))}),k=E.map((e,t)=>{let n=D[t];return{...n?.data===void 0?{}:{data:n.data},error:n?.error??null,isFetching:n?.isFetching??!1,path:e}}),A=s??a??b?.path??``;return(0,J.jsx)(Gm,{onOpenChange:e=>{!e&&!t&&r()},open:!0,children:(0,J.jsxs)(Ym,{"aria-labelledby":`project-directory-picker-title`,className:`grid h-[min(84dvh,42rem)] max-w-2xl grid-rows-[auto_auto_minmax(0,1fr)_auto] gap-0 overflow-hidden p-0`,onEscapeKeyDown:e=>{t&&e.preventDefault()},onInteractOutside:e=>{t&&e.preventDefault()},children:[(0,J.jsxs)(Xm,{className:`px-4 pb-3 pt-4 sm:px-5 sm:pt-5`,children:[(0,J.jsx)(Qm,{id:`project-directory-picker-title`,children:i(`projectPicker.title`)}),(0,J.jsx)($m,{className:`sr-only`,children:i(`projectPicker.description`)})]}),(0,J.jsx)(dh,{disabled:t,includeHidden:d,labels:{filesystemRoot:i(`projectPicker.filesystemRoot`),goToPath:i(`projectPicker.goToPath`),hideHidden:i(`projectPicker.hideHidden`),parent:i(`projectPicker.parent`),pathLabel:i(`projectPicker.pathLabel`),pathPlaceholder:i(`projectPicker.pathPlaceholder`),showHidden:i(`projectPicker.showHidden`)},listing:b,onNavigateParent:()=>{let e=b?.parentPath;e!=null&&(o(e),c(void 0),u(void 0),m(new Set),g([]))},onNavigatePath:()=>{let e=A.trim();e.length!==0&&(o(e),c(void 0),u(e),m(new Set),g([]))},onNavigateRoot:e=>{o(e),c(void 0),u(void 0),m(new Set),g([])},onPathChange:e=>{c(e),u(void 0)},onToggleHidden:()=>{f(e=>!e),g([])},path:A}),(0,J.jsx)(`div`,{className:`min-h-0 overflow-y-auto px-3 py-2 sm:px-4`,children:_.isPending?(0,J.jsxs)(`p`,{className:`flex min-h-32 items-center justify-center gap-2 text-body-small text-muted-foreground`,role:`status`,children:[(0,J.jsx)(O,{"aria-hidden":`true`,className:`size-4 animate-spin`}),i(`projectPicker.loading`)]}):_.error===null?b===void 0?null:b.entries.length===0?(0,J.jsx)(`p`,{className:`grid min-h-32 place-items-center text-body-small text-muted-foreground`,children:i(`projectPicker.empty`)}):(0,J.jsx)(ph,{directoryStates:k,expandedPaths:p,listing:b,onExpandedChange:m,onRetry:e=>{let t=E.indexOf(e);D[t]?.refetch()},onRootCheckedChange:(e,t)=>{u(void 0),g(n=>Xs(n,e,t))},selectedPaths:w,selectionDisabled:t}):(0,J.jsxs)(`div`,{className:`flex min-h-32 flex-col items-center justify-center gap-3 text-center`,children:[(0,J.jsx)(`p`,{className:`text-body-small text-danger`,role:`alert`,children:i(`projectPicker.loadError`)}),(0,J.jsxs)(v,{onClick:()=>void _.refetch(),type:`button`,variant:`outline`,children:[(0,J.jsx)(Ac,{"aria-hidden":`true`,"data-icon":`inline-start`}),i(`actions.retry`)]})]})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-separator bg-raised px-4 py-3 sm:flex-row sm:items-center sm:px-5`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,J.jsx)(`p`,{"aria-live":`polite`,className:`text-caption text-muted-foreground`,children:C?i(`projectPicker.directPathReady`):i(`projectPicker.selectedRoots`,{count:h.length})}),C?null:(0,J.jsx)(`p`,{className:`ml-auto text-right text-caption text-muted-foreground`,children:i(`projectPicker.primaryRootHint`)})]}),T.length===0?null:(0,J.jsx)(`p`,{className:`min-w-0 break-words font-mono text-caption text-foreground [overflow-wrap:anywhere]`,children:T})]}),(0,J.jsxs)(Zm,{className:`w-full flex-col-reverse sm:w-auto sm:flex-row`,children:[(0,J.jsx)(v,{className:`h-10 w-full sm:h-8 sm:w-auto`,disabled:t,onClick:r,type:`button`,variant:`outline`,children:i(`actions.cancel`)}),(0,J.jsxs)(v,{className:`h-10 w-full sm:h-8 sm:w-auto`,disabled:!S||t,onClick:()=>{x.length>0&&n(x)},type:`button`,children:[t?(0,J.jsx)(O,{"aria-hidden":`true`,className:`animate-spin`,"data-icon":`inline-start`}):(0,J.jsx)(Sc,{"aria-hidden":`true`,"data-icon":`inline-start`}),i(t?`projectPicker.adding`:`projectPicker.add`)]})]})]})]})})}function hh({isPending:e,onClose:t,onRemove:n,project:r}){let{t:i}=y(`workbench`);return(0,J.jsx)(Gm,{onOpenChange:n=>{!n&&!e&&t()},open:!0,children:(0,J.jsxs)(Ym,{"aria-labelledby":`project-remove-title`,className:`max-w-96 p-4`,onEscapeKeyDown:t=>{e&&t.preventDefault()},onInteractOutside:t=>{e&&t.preventDefault()},children:[(0,J.jsxs)(Xm,{children:[(0,J.jsx)(Qm,{id:`project-remove-title`,children:i(`projectDialog.remove`)}),(0,J.jsx)($m,{children:i(`projectDialog.removeDescription`,{name:r.name})})]}),(0,J.jsxs)(Zm,{children:[(0,J.jsx)(v,{className:`h-8 rounded-control px-3 text-body-small text-muted-foreground hover:bg-control-hover hover:text-foreground`,disabled:e,onClick:t,type:`button`,variant:`ghost`,children:i(`actions.cancel`)}),(0,J.jsx)(v,{disabled:e,onClick:n,type:`button`,variant:`destructive`,children:i(`projectDialog.delete`)})]})]})})}function gh({initialName:e,isPending:t,onClose:n,onRename:r}){let{t:i}=y(`workbench`),[a,o]=(0,K.useState)(e),s=a.trim();return(0,J.jsx)(Gm,{onOpenChange:e=>{!e&&!t&&n()},open:!0,children:(0,J.jsx)(Ym,{"aria-labelledby":`project-rename-title`,className:`max-w-96 p-4`,onEscapeKeyDown:e=>{t&&e.preventDefault()},onInteractOutside:e=>{t&&e.preventDefault()},children:(0,J.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),s.length>0&&r(s)},children:[(0,J.jsxs)(Xm,{children:[(0,J.jsx)(Qm,{id:`project-rename-title`,children:i(`projectDialog.rename`)}),(0,J.jsx)($m,{children:i(`projectDialog.renameDescription`)})]}),(0,J.jsx)(Pt,{"aria-label":i(`projectDialog.name`),autoFocus:!0,disabled:t,maxLength:200,onChange:e=>{o(e.currentTarget.value)},value:a}),(0,J.jsxs)(Zm,{children:[(0,J.jsx)(v,{disabled:t,onClick:n,type:`button`,variant:`ghost`,children:i(`actions.cancel`)}),(0,J.jsx)(v,{disabled:t||s.length===0||s===e,type:`submit`,children:i(`actions.save`)})]})]})})})}function _h({initialTitle:e,isPending:t,onClose:n,onRename:r}){let{t:i}=y(`workbench`),[a,o]=(0,K.useState)(e);return(0,J.jsx)(Gm,{onOpenChange:e=>{!e&&!t&&n()},open:!0,children:(0,J.jsx)(Ym,{"aria-labelledby":`task-rename-title`,className:`max-w-96 p-4`,onEscapeKeyDown:e=>{t&&e.preventDefault()},onInteractOutside:e=>{t&&e.preventDefault()},children:(0,J.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault();let t=a.trim();t.length>0&&r(t)},children:[(0,J.jsx)(Xm,{children:(0,J.jsx)(Qm,{id:`task-rename-title`,children:i(`taskDialog.rename`)})}),(0,J.jsx)(Pt,{"aria-label":i(`taskDialog.name`),autoFocus:!0,disabled:t,maxLength:200,onChange:e=>{o(e.currentTarget.value)},value:a}),(0,J.jsxs)(Zm,{children:[(0,J.jsx)(v,{disabled:t,onClick:n,type:`button`,variant:`ghost`,children:i(`actions.cancel`)}),(0,J.jsx)(v,{disabled:t||a.trim().length===0,type:`submit`,children:i(`actions.save`)})]})]})})})}function vh({client:e,isProjectActionPending:t,isProjectAddPending:n,isProjectPickerOpen:r,onAddProject:i,onCloseProjectDialog:a,onCloseProjectPicker:o,onCloseTaskRename:s,onRemoveProject:c,onRenameProject:l,onRenameTask:u,removingProject:d,renamingProject:f,renamingTask:p,taskRenamePending:m}){return(0,J.jsxs)(J.Fragment,{children:[p===null?null:(0,J.jsx)(_h,{initialTitle:p.title,isPending:m,onClose:s,onRename:e=>{u(p,e)}},p.id),r?(0,J.jsx)(mh,{client:e,isAdding:n,onAdd:i,onClose:o}):null,f===null?null:(0,J.jsx)(gh,{initialName:f.name,isPending:t,onClose:()=>{a(f.id)},onRename:e=>{l(f,e)}},f.id),d===null?null:(0,J.jsx)(hh,{isPending:t,onClose:()=>{a(d.id)},onRemove:()=>{c(d)},project:d},d.id)]})}var yh=4,bh=100;async function xh(e,t){let n=new Set,r=new Set,i;for(;;){let a=await e.listTasks(t,{archived:!0,...i===void 0?{}:{cursor:i},limit:bh});for(let e of a.data)n.add(e.id);if(a.nextCursor===null)break;if(r.has(a.nextCursor))throw Error(`Archived task pagination returned a repeated cursor`);r.add(a.nextCursor),i=a.nextCursor}return[...n]}async function Sh(e,t){let n=await xh(e,t),r;for(let i=0;i<n.length;i+=yh){let a=n.slice(i,i+yh),o=await Promise.allSettled(a.map(n=>e.deleteTask(t,n)));for(let e of o)e.status===`rejected`&&r===void 0&&(r=e.reason instanceof Error?e.reason:Error(String(e.reason)))}if(r!==void 0)throw r}function Ch({confirmLabel:e,description:t,isPending:n,onClose:r,onConfirm:i,title:a}){let{t:o}=y(`workbench`);return(0,J.jsx)(Gm,{onOpenChange:e=>{!e&&!n&&r()},open:!0,children:(0,J.jsxs)(Ym,{"aria-labelledby":`task-delete-confirmation-title`,className:`max-w-96 p-4`,onEscapeKeyDown:e=>{n&&e.preventDefault()},onInteractOutside:e=>{n&&e.preventDefault()},children:[(0,J.jsxs)(Xm,{children:[(0,J.jsx)(Qm,{id:`task-delete-confirmation-title`,children:a}),(0,J.jsx)($m,{children:t})]}),(0,J.jsxs)(Zm,{children:[(0,J.jsx)(v,{disabled:n,onClick:r,type:`button`,variant:`ghost`,children:o(`actions.cancel`)}),(0,J.jsx)(v,{disabled:n,onClick:i,type:`button`,variant:`destructive`,children:e})]})]})})}function wh({isPending:e,onClose:t,onDelete:n,task:r}){let{t:i}=y(`workbench`);return(0,J.jsx)(Ch,{confirmLabel:i(`sidebar.deletePermanently`),description:i(`sidebar.deleteTaskDescription`,{task:r.title}),isPending:e,onClose:t,onConfirm:n,title:i(`sidebar.deleteTaskTitle`)})}function Th({error:e,isPending:t,mutationPending:n,onDelete:r,onDeleteAll:i,onNext:a,onPrevious:o,onRestore:s,onRetry:c,page:l,pageNumber:u}){let{t:d}=y(`workbench`);return t?(0,J.jsxs)(`div`,{className:`flex min-h-48 items-center justify-center`,role:`status`,children:[(0,J.jsx)(O,{className:`size-5 animate-spin text-muted-foreground`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`sr-only`,children:d(`archivedTasks.loading`)})]}):e===null?(0,J.jsxs)(`div`,{className:`grid min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[l?.data.length===0?(0,J.jsx)(`p`,{className:`flex min-h-48 items-center justify-center px-4 text-body-small text-muted-foreground`,children:d(`archivedTasks.empty`)}):(0,J.jsx)(`ul`,{className:`min-h-0 overflow-y-auto`,children:l?.data.map(e=>(0,J.jsxs)(`li`,{className:`flex min-h-14 min-w-0 items-center gap-3 px-4 py-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`p`,{className:`truncate text-body-small font-medium text-foreground`,children:e.title}),(0,J.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:d(`archivedTasks.updatedAt`,{date:new Date(e.updatedAt).toLocaleString()})})]}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":d(`archivedTasks.restoreTask`,{task:e.title}),disabled:n,onClick:()=>{s(e)},size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(dc,{"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:d(`archivedTasks.restore`)})]}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":d(`archivedTasks.deleteTask`,{task:e.title}),disabled:n,onClick:()=>{r(e)},size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(It,{"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:d(`archivedTasks.delete`)})]})]},e.id))}),(0,J.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-2 px-4`,children:[(0,J.jsxs)(v,{className:`text-danger hover:text-danger`,disabled:n,onClick:i,size:`sm`,type:`button`,variant:`ghost`,children:[(0,J.jsx)(It,{"aria-hidden":`true`}),d(`archivedTasks.deleteAll`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":d(`archivedTasks.previous`),className:`size-11 sm:size-8`,disabled:n||u===1,onClick:o,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(hc,{"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:d(`archivedTasks.previous`)})]}),(0,J.jsx)(`span`,{className:`min-w-16 text-center text-caption text-muted-foreground`,children:d(`archivedTasks.page`,{page:u})}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":d(`archivedTasks.next`),className:`size-11 sm:size-8`,disabled:n||l?.nextCursor===null,onClick:a,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(Tt,{"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:d(`archivedTasks.next`)})]})]})]})]}):(0,J.jsxs)(`div`,{className:`flex min-h-48 flex-col items-center justify-center gap-3 px-4 text-center`,children:[(0,J.jsx)(`p`,{className:`text-body-small text-danger`,role:`alert`,children:d(`archivedTasks.loadError`)}),(0,J.jsx)(v,{onClick:c,size:`sm`,type:`button`,variant:`outline`,children:d(`actions.retry`)})]})}function Eh({client:e,onClose:t,project:n}){let{t:r}=y(`workbench`),i=Ee(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)([void 0]),[d,f]=(0,K.useState)(0),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(!1),_=(0,K.useRef)(Ue()),v=l[d],b=R(pt(n.id,v,s,e)),x=Ye(ct(e)),S=Ye(Ze(e)),C=Ye({mutationFn:()=>Sh(e,n.id),mutationKey:[`tasks`,`delete-all-archived`,n.id]}),w=x.isPending||S.isPending||C.isPending;(0,K.useEffect)(()=>{let e=window.setTimeout(()=>{c(a.trim()),u([void 0]),f(0)},250);return()=>{window.clearTimeout(e)}},[a]);let T=()=>{u([void 0]),f(0),i.removeQueries({queryKey:[`projects`,n.id,`archived-tasks`]})},E=e=>_.current.run(async()=>{try{let t=await x.mutateAsync({projectId:n.id,taskId:e.id});i.setQueryData([`projects`,n.id,`tasks`],e=>wt(e,t.task)),dt(i,t.task),T()}catch{}}),D=e=>_.current.run(async()=>{try{await S.mutateAsync({projectId:n.id,taskId:e.id}),m(null),T()}catch{}}),O=()=>_.current.run(async()=>{try{await C.mutateAsync(),g(!1)}catch{}finally{T()}});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Gm,{onOpenChange:e=>{!e&&!w&&t()},open:!0,children:(0,J.jsxs)(Ym,{className:`grid h-[min(42rem,calc(100dvh-2rem))] max-w-2xl grid-rows-[auto_auto_minmax(0,1fr)] gap-0 overflow-hidden p-0`,children:[(0,J.jsx)(Xm,{className:`px-4 pb-3 pt-4 sm:px-5 sm:pt-5`,children:(0,J.jsx)(Qm,{children:r(`archivedTasks.title`,{project:n.name})})}),(0,J.jsxs)(`div`,{className:`relative px-4 pb-3 sm:px-5`,children:[(0,J.jsx)(Mc,{"aria-hidden":`true`,className:`pointer-events-none absolute left-7 top-2.5 size-4 text-muted-foreground sm:left-8`}),(0,J.jsx)(Pt,{"aria-label":r(`archivedTasks.search`),className:`h-9 w-full pl-8`,onChange:e=>{o(e.currentTarget.value)},placeholder:r(`archivedTasks.search`),value:a})]}),(0,J.jsx)(Th,{error:b.error,isPending:b.isPending,mutationPending:w,onDelete:m,onDeleteAll:()=>{g(!0)},onNext:()=>{let e=b.data?.nextCursor;e!=null&&(u(t=>[...t.slice(0,d+1),e]),f(e=>e+1))},onPrevious:()=>{f(e=>Math.max(0,e-1))},onRestore:e=>{E(e)},onRetry:()=>{b.refetch()},page:b.data,pageNumber:d+1})]})}),p===null?null:(0,J.jsx)(Ch,{confirmLabel:r(`archivedTasks.confirmDelete`),description:r(`archivedTasks.deleteDescription`,{task:p.title}),isPending:S.isPending,onClose:()=>{m(null)},onConfirm:()=>{D(p)},title:r(`archivedTasks.deleteTitle`)}),h?(0,J.jsx)(Ch,{confirmLabel:r(`archivedTasks.confirmDeleteAll`),description:r(`archivedTasks.deleteAllDescription`,{project:n.name}),isPending:C.isPending,onClose:()=>{g(!1)},onConfirm:()=>{O()},title:r(`archivedTasks.deleteAllTitle`)}):null]})}function Dh(e){return(0,J.jsx)(vp,{"data-slot":`dropdown-menu`,...e})}function Oh(e){return(0,J.jsx)(yp,{"data-slot":`dropdown-menu-trigger`,...e})}function kh(e){return(0,J.jsx)(kp,{"data-slot":`dropdown-menu-sub`,...e})}function Ah({children:e,...t}){return typeof document>`u`?(0,J.jsx)(J.Fragment,{children:e}):(0,J.jsx)(bp,{"data-slot":`dropdown-menu-portal`,...t,children:e})}function jh({children:e,className:t,collisionPadding:n=8,sideOffset:r=2,...i}){return(0,J.jsx)(Ah,{children:(0,J.jsx)(xp,{className:m(`z-50 min-w-32 overflow-hidden rounded-surface bg-raised p-1 text-foreground shadow-floating outline-none`,t),collisionPadding:n,"data-slot":`dropdown-menu-content`,sideOffset:r,...i,children:e})})}function Mh({className:e,...t}){return(0,J.jsx)(wp,{className:m(`flex cursor-default select-none items-center gap-2 rounded-control px-2 py-1.5 text-body-small outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[highlighted]:bg-control-hover [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),"data-slot":`dropdown-menu-item`,...t})}function Nh({children:e,className:t,...n}){return(0,J.jsxs)(Ap,{className:m(`flex cursor-default select-none items-center gap-2 rounded-control px-2 py-1.5 text-body-small outline-none transition-colors data-[state=open]:bg-control-hover data-[highlighted]:bg-control-hover [&_svg]:pointer-events-none [&_svg]:shrink-0`,t),"data-slot":`dropdown-menu-sub-trigger`,...n,children:[e,(0,J.jsx)(Tt,{"aria-hidden":`true`,className:`ml-auto size-3.5 text-muted-foreground`})]})}function Ph({children:e,className:t,collisionPadding:n=8,sideOffset:r=2,...i}){return(0,J.jsx)(Ah,{children:(0,J.jsx)(jp,{className:m(`z-50 min-w-40 max-h-[calc(100dvh-1rem)] overflow-y-auto rounded-surface bg-raised p-1 text-foreground shadow-floating outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,t),collisionPadding:n,"data-slot":`dropdown-menu-sub-content`,sideOffset:r,...i,children:e})})}function Fh(e){return(0,J.jsx)(Sp,{"data-slot":`dropdown-menu-group`,...e})}function Ih({className:e,...t}){return(0,J.jsx)(Cp,{className:m(`px-2 py-1 text-label font-medium text-foreground`,e),"data-slot":`dropdown-menu-label`,...t})}function Lh({className:e,...t}){return(0,J.jsx)(Op,{className:m(`-mx-1 my-1 h-px bg-separator`,e),"data-slot":`dropdown-menu-separator`,...t})}function Rh(e){return(0,J.jsx)(Tp,{"data-slot":`dropdown-menu-radio-group`,...e})}function zh({children:e,className:t,indicator:n=`radio`,...r}){return(0,J.jsxs)(Ep,{className:m(`relative flex cursor-default select-none items-center gap-2.5 rounded-control py-1.5 text-body-small outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[highlighted]:bg-control-hover [&_svg]:pointer-events-none [&_svg]:shrink-0`,n===`check`?`pl-2 pr-8`:`pl-8 pr-2`,t),"data-indicator":n,"data-indicator-position":n===`check`?`end`:`start`,"data-slot":`dropdown-menu-radio-item`,...r,children:[(0,J.jsx)(`span`,{className:m(`pointer-events-none absolute flex size-3.5 items-center justify-center`,n===`check`?`right-2`:`left-2`),children:(0,J.jsx)(Dp,{children:n===`check`?(0,J.jsx)(Ke,{"aria-hidden":`true`,className:`size-3.5`}):(0,J.jsx)(vc,{"aria-hidden":`true`,className:`size-2 fill-current text-brand`})})}),e]})}function Bh(e){let t=new Map;for(let n of e){let e=t.get(n.projectId);e===void 0?t.set(n.projectId,[n]):e.push(n)}return t}function Vh({error:e,hasHiddenLoadedTasks:t,hasNextPage:n,isExpanded:r,isFetchingNextPage:i}){return r?n?{action:`load`,disabled:i,label:i?S.t(`sidebar.expandLoading`,{ns:`workbench`}):e===null?S.t(`sidebar.expand`,{ns:`workbench`}):S.t(`sidebar.expandRetry`,{ns:`workbench`})}:t?{action:`collapse`,disabled:!1,label:S.t(`sidebar.collapse`,{ns:`workbench`})}:null:n?{action:`expand-and-load`,disabled:!1,label:S.t(`sidebar.expand`,{ns:`workbench`})}:t?{action:`expand`,disabled:!1,label:S.t(`sidebar.expand`,{ns:`workbench`})}:null}function Hh({hasActiveTask:e,projectDataFailed:t,projectDataPending:n,taskConnectionState:r}){return e?r:t?`closed`:n?`connecting`:`connected`}function Uh(e){switch(e){case`connected`:return{labelKey:`sidebar.connection.online`,toneClassName:`text-diff-added`};case`connecting`:return{labelKey:`sidebar.connection.connecting`,toneClassName:`text-warning`};case`reconnecting`:return{labelKey:`sidebar.connection.reconnecting`,toneClassName:`text-warning`};case`closed`:return{labelKey:`sidebar.connection.offline`,toneClassName:`text-danger`}}}function Wh({disabled:e,onOpen:t}){let{t:n}=y(`workbench`);return(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":n(`sidebar.addProject`),disabled:e,onClick:t,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(We,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,J.jsx)(ye,{children:n(`sidebar.addProject`)})]})}function Gh({isPending:e,onOpenArchived:t,onRemove:n,onRename:r,project:i}){let{t:a}=y(`workbench`);return(0,J.jsx)(`div`,{className:`relative shrink-0`,children:(0,J.jsxs)(Dh,{modal:!1,children:[(0,J.jsx)(Oh,{asChild:!0,children:(0,J.jsx)(v,{variant:`ghost`,"aria-label":a(`sidebar.openProjectActions`,{project:i.name}),className:`grid size-7 place-items-center rounded-control text-muted-foreground opacity-0 transition-[color,background-color,opacity] hover:bg-control-hover hover:text-foreground focus-visible:opacity-100 focus-visible:shadow-focus group-hover/project:opacity-100 data-[state=open]:opacity-100`,disabled:e,id:`project-actions-${i.id}`,type:`button`,children:(0,J.jsx)(yc,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,J.jsx)(qh,{isPending:e,onOpenArchived:()=>{t(i)},onRemove:()=>{n(i)},onRename:()=>{r(i)},project:i})]})})}var Kh=`h-8 w-full text-left text-foreground`;function qh({isPending:e,onOpenArchived:t,onRemove:n,onRename:r,project:i}){let{t:a}=y(`workbench`);return(0,J.jsxs)(jh,{align:`start`,"aria-label":a(`sidebar.projectActions`,{project:i.name}),"aria-labelledby":void 0,className:`w-32`,children:[(0,J.jsxs)(Mh,{className:Kh,disabled:e,onSelect:r,children:[(0,J.jsx)(Oc,{className:`size-3.5`,"aria-hidden":`true`}),a(`sidebar.rename`)]}),(0,J.jsxs)(Mh,{className:Kh,disabled:e,onSelect:t,children:[(0,J.jsx)(fc,{className:`size-3.5`,"aria-hidden":`true`}),a(`sidebar.archived`)]}),(0,J.jsxs)(Mh,{className:`${Kh} text-danger`,disabled:e,onSelect:n,children:[(0,J.jsx)(It,{className:`size-3.5`,"aria-hidden":`true`}),a(`sidebar.remove`)]})]})}function Jh({appInfo:e,connectionState:t,onOpen:n}){let{t:r}=y(`workbench`),i=Uh(t),a=r(i.labelKey),o=e?.appVersion??`…`,s=e?.updateAvailable===!0;return(0,J.jsxs)(`div`,{className:`flex h-9 w-full items-stretch text-body-small text-muted-foreground`,children:[(0,J.jsxs)(v,{"aria-label":r(`sidebar.settings`),className:`h-full min-w-0 flex-1 gap-2.5 rounded-r-none px-2.5`,contentAlign:`start`,id:`global-settings-trigger`,onClick:()=>{n(`appearance`)},type:`button`,variant:`ghost`,children:[(0,J.jsx)(At,{className:`size-4`,"aria-hidden":`true`}),r(`sidebar.settings`)]}),(0,J.jsx)(v,{"aria-label":r(`sidebar.aboutStatus`,{status:a,update:s?r(`sidebar.updateAvailableLabel`):``,version:o}),className:`h-full gap-1 rounded-l-none px-2.5 text-caption`,id:`global-settings-about-trigger`,onClick:()=>{n(`about`)},type:`button`,variant:`ghost`,children:(0,J.jsxs)(`span`,{"aria-live":`polite`,className:`inline-flex items-center gap-1`,children:[(0,J.jsxs)(`span`,{className:s?`text-warning`:`text-muted-foreground`,children:[s?(0,J.jsx)(_c,{"aria-hidden":`true`,className:`mr-1 inline size-3`}):null,`v`,o]}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground`,children:`·`}),(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 ${i.toneClassName}`,children:[(0,J.jsx)(Yh,{connectionState:t}),a]})]})})]})}function Yh({connectionState:e}){return e===`connected`?(0,J.jsx)(Ic,{className:`size-3`,"aria-hidden":`true`}):e===`closed`?(0,J.jsx)(Fc,{className:`size-3`,"aria-hidden":`true`}):(0,J.jsx)(`span`,{className:`inline-flex animate-spin`,"aria-hidden":`true`,children:(0,J.jsx)(O,{className:`size-3`})})}function Xh(e,t){return e===`temporary`?{params:{taskId:t},to:`/temporary/t/$taskId`}:{params:{projectId:e,taskId:t},to:`/p/$projectId/t/$taskId`}}function Zh({active:e,attention:t,icon:n,isActionPending:r,isAwaitingApproval:i,isRunning:a,onArchive:o,onDelete:s,onPin:c,onRename:l,task:u}){let{t:d}=y(`workbench`),f=Xh(u.projectId,u.id);return(0,J.jsxs)(`div`,{className:`group relative min-w-0`,children:[(0,J.jsxs)(ya,{"aria-current":e?`page`:void 0,className:`flex h-8 min-w-0 items-center gap-2 rounded-control px-2 text-body-small transition-colors ${e?`bg-control-active font-medium text-foreground`:`text-muted-foreground hover:bg-control-hover hover:text-foreground`}`,...f,children:[n===void 0?null:(0,J.jsx)(`span`,{className:`shrink-0 text-subtle-foreground`,children:n}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:u.title}),(0,J.jsx)(Qh,{attention:t,isAwaitingApproval:i,isRunning:a,updatedAt:u.updatedAt})]}),(0,J.jsxs)(Dh,{modal:!1,children:[(0,J.jsx)(Oh,{asChild:!0,children:(0,J.jsx)(v,{variant:`ghost`,"aria-label":d(`sidebar.openTaskActions`,{task:u.title}),className:`task-actions absolute right-1 top-1 grid size-6 place-items-center rounded-control text-muted-foreground transition-colors hover:bg-control-hover hover:text-foreground focus-visible:opacity-100 focus-visible:shadow-focus`,disabled:r,type:`button`,children:(0,J.jsx)(yc,{className:`size-4`,"aria-hidden":`true`})})}),(0,J.jsx)(eg,{isPending:r,onArchive:()=>{o(u)},onDelete:()=>{s(u)},onPin:()=>{c(u)},onRename:()=>{l(u)},task:u})]})]})}function Qh({attention:e,isAwaitingApproval:t,isRunning:n,updatedAt:r}){let{t:i}=y(`workbench`),a;return a=t||e===`approval`?{animated:!0,label:i(`sidebar.taskApproval`),tone:`text-task-waiting`}:n?{animated:!0,label:i(`sidebar.taskRunning`),tone:`text-task-running`}:e===`completed`?{animated:!1,label:i(`sidebar.taskComplete`),tone:`text-task-completed`}:e===`failed`?{animated:!1,label:i(`sidebar.taskIncomplete`),tone:`text-task-failed`}:null,a===null?(0,J.jsx)(`span`,{className:`task-age task-status ml-auto shrink-0 text-caption text-subtle-foreground`,children:Vc(r)}):(0,J.jsx)(`span`,{"aria-label":a.label,className:`task-status ml-auto inline-grid size-3.5 shrink-0 place-items-center ${a.tone}`,role:`status`,children:(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`task-status-dot block size-2 rounded-full bg-current ${a.animated?`task-status-dot--breathing`:``}`})})}var $h=`h-8 w-full text-left text-foreground`;function eg({isPending:e,onArchive:t,onDelete:n,onPin:r,onRename:i,task:a}){let{t:o}=y(`workbench`);return(0,J.jsxs)(jh,{align:`start`,"aria-label":o(`sidebar.taskActions`,{task:a.title}),"aria-labelledby":void 0,className:`w-40`,children:[(0,J.jsxs)(Mh,{className:$h,disabled:e,onSelect:r,children:[(0,J.jsx)(kc,{className:`size-3.5`,"aria-hidden":`true`}),a.pinned?o(`sidebar.unpin`):o(`sidebar.pin`)]}),(0,J.jsxs)(Mh,{className:$h,disabled:e,onSelect:i,children:[(0,J.jsx)(Oc,{className:`size-3.5`,"aria-hidden":`true`}),o(`sidebar.rename`)]}),(0,J.jsxs)(Mh,{className:`${$h} text-danger`,disabled:e,onSelect:t,children:[(0,J.jsx)(fc,{className:`size-3.5`,"aria-hidden":`true`}),o(`sidebar.archive`)]}),(0,J.jsxs)(Mh,{className:`${$h} text-danger`,disabled:e,onSelect:n,children:[(0,J.jsx)(It,{className:`size-3.5`,"aria-hidden":`true`}),o(`sidebar.deletePermanently`)]})]})}var tg=[];function ng({archiveTask:e,deleteTask:t,error:n,expandedProjects:r,expandedTaskProjects:i,fetchNextProjectTaskPage:a,getProjectReorderProps:o,hasTaskError:s,isPending:c,isProjectActionPending:l,isProjectAddPending:u,normalizedQuery:d,onOpenTemporaryDraft:f,onOpenProjectDraft:p,onOpenArchived:m,onOpenProjectPicker:h,onRemoveProject:g,onRenameProject:_,orderedProjects:b,pinTask:x,pinnedTasks:S,projectId:C,projectOrderAnnouncement:w,projectTaskStates:T,reorderingProjectId:E,setExpandedTaskProjects:D,setRenamingTask:O,taskActionPending:k,taskActivity:A,taskId:j,taskSearch:M,tasksByProjectId:N,toggleProject:P}){let{t:F}=y(`workbench`),[I]=(0,K.useState)(Gl),[L,ee]=(0,K.useState)(()=>Jl(I)),R=N.get(`temporary`)??tg,z=T.get(Re),B=i.has(Re),te=Bc(R,B),H=Vh({error:z?.error??null,hasHiddenLoadedTasks:R.length>5,hasNextPage:d.length===0?z?.hasNextPage??!1:!1,isExpanded:B,isFetchingNextPage:z?.isFetchingNextPage??!1});return(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden px-2 pt-5`,children:[S.length>0?(0,J.jsxs)(`section`,{className:`mb-4 max-h-40 shrink-0 overflow-y-auto`,"aria-labelledby":`pinned-title`,children:[(0,J.jsx)(`h2`,{className:`px-2 pb-2 text-meta font-semibold text-muted-foreground`,id:`pinned-title`,children:F(`sidebar.pinned`)}),(0,J.jsx)(`div`,{className:`space-y-0.5`,children:S.map(n=>{let r=ss(A,n.projectId,n.id);return(0,J.jsx)(Zh,{active:n.projectId===C&&n.id===j,attention:r.attention,icon:(0,J.jsx)(kc,{className:`size-3.5`,"aria-hidden":`true`}),isActionPending:k,isAwaitingApproval:r.isAwaitingApproval,isRunning:r.isRunning,onArchive:t=>void e(t),onDelete:e=>void t(e),onPin:e=>void x(e),onRename:O,task:n},`${n.projectId}:${n.id}`)})})]}):null,(0,J.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,"aria-labelledby":`projects-title`,children:[(0,J.jsxs)(`div`,{className:`flex h-8 min-w-0 w-full shrink-0 items-center justify-between pl-2`,children:[(0,J.jsx)(`h2`,{className:`text-body-small font-semibold text-foreground`,id:`projects-title`,children:F(`sidebar.projects`)}),(0,J.jsx)(Wh,{disabled:u,onOpen:()=>{h()}})]}),c?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:F(`sidebar.taskLoading`)}):null,M.isPending?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:F(`sidebar.searchAll`)}):null,n===null&&!s?null:(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta leading-5 text-danger`,role:`alert`,children:F(`sidebar.errorLoadTasks`)}),M.error===null?null:(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta leading-5 text-danger`,role:`alert`,children:F(`sidebar.errorSearchTasks`)}),(0,J.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,children:w}),(0,J.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pb-3`,"data-testid":`project-tree-scroll`,children:[(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-labelledby":`temporary-tasks-title`,children:[(0,J.jsx)(rg,{expanded:L,onCreate:f,onToggle:()=>{ee(e=>{let t=!e;return Yl(I,t),t})}}),L?(0,J.jsxs)(`div`,{className:`min-w-0 space-y-0.5 pl-5`,id:`temporary-tasks-content`,children:[te.tasks.map(n=>{let r=ss(A,n.projectId,n.id);return(0,J.jsx)(Zh,{active:C===`temporary`&&n.id===j,attention:r.attention,isActionPending:k,isAwaitingApproval:r.isAwaitingApproval,isRunning:r.isRunning,onArchive:t=>void e(t),onDelete:e=>void t(e),onPin:e=>void x(e),onRename:O,task:n},`${n.projectId}:${n.id}`)}),z?.isPending===!0?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:F(`sidebar.taskLoading`)}):null,H===null?null:(0,J.jsx)(v,{variant:`ghost`,"aria-expanded":B,className:`flex h-7 w-full items-center rounded-control px-2 text-left text-meta font-medium text-subtle-foreground transition-colors hover:bg-control-hover hover:text-foreground`,contentAlign:`start`,disabled:H.disabled,onClick:()=>{H.action===`expand`||H.action===`expand-and-load`?D(e=>new Set(e).add(Re)):H.action===`collapse`&&D(e=>{let t=new Set(e);return t.delete(Re),t}),(H.action===`expand-and-load`||H.action===`load`)&&a(Re).catch(()=>void 0)},type:`button`,children:H.label}),R.length===0&&d.length===0&&z?.isPending!==!0?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:F(`sidebar.noTemporaryTasks`)}):null,R.length===0&&d.length>0&&!M.isPending&&M.error===null?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:F(`sidebar.noMatchingTasks`)}):null]}):null]}),b.map(n=>{let s=N.get(n.id)??tg,c=r.has(n.id),u=i.has(n.id),f=Bc(s,u),h=T.get(n.id),y=Vh({error:h?.error??null,hasHiddenLoadedTasks:s.length>5,hasNextPage:d.length===0?h?.hasNextPage??!1:!1,isExpanded:u,isFetchingNextPage:h?.isFetchingNextPage??!1});return(0,J.jsxs)(`div`,{className:`min-w-0 transition-[opacity,transform] ${E===n.id?`relative z-10 opacity-80`:``}`,"data-project-reordering":E===n.id?`true`:`false`,children:[(0,J.jsxs)(`div`,{className:`group/project flex min-w-0 items-center gap-0.5`,children:[(0,J.jsxs)(v,{variant:`ghost`,"aria-expanded":c,"aria-label":F(`sidebar.toggleProject`,{project:n.name}),className:`flex h-8 min-w-0 flex-1 touch-pan-y select-none items-center gap-2 rounded-control px-2 text-body-small font-medium transition-colors hover:bg-control-hover hover:text-foreground ${E===n.id?`cursor-grabbing bg-control-active text-foreground shadow-sm`:`cursor-grab text-muted-foreground`}`,contentAlign:`start`,onClick:()=>{P(n.id)},type:`button`,...o(n.id),children:[(0,J.jsx)(St,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`truncate`,children:n.name})]}),(0,J.jsx)(Gh,{isPending:l,onOpenArchived:m,onRemove:e=>{g(e)},onRename:e=>{_(e)},project:n}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":F(`sidebar.createInProject`,{project:n.name}),onClick:()=>{p(n.id)},size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(We,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:F(`sidebar.createInProject`,{project:n.name})})]})]}),c?(0,J.jsxs)(`div`,{className:`mt-0.5 min-w-0 space-y-0.5 pl-5`,children:[f.tasks.map(r=>{let i=ss(A,r.projectId,r.id);return(0,J.jsx)(Zh,{active:n.id===C&&r.id===j,attention:i.attention,isActionPending:k,isAwaitingApproval:i.isAwaitingApproval,isRunning:i.isRunning,onArchive:t=>void e(t),onDelete:e=>void t(e),onPin:e=>void x(e),onRename:O,task:r},`${r.projectId}:${r.id}`)}),h?.isPending===!0?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:F(`sidebar.taskLoading`)}):null,y===null?null:(0,J.jsx)(v,{variant:`ghost`,"aria-expanded":u,className:`flex h-7 w-full items-center rounded-control px-2 text-left text-meta font-medium text-subtle-foreground transition-colors hover:bg-control-hover hover:text-foreground`,contentAlign:`start`,disabled:y.disabled,onClick:()=>{y.action===`expand`||y.action===`expand-and-load`?D(e=>new Set(e).add(n.id)):y.action===`collapse`&&D(e=>{let t=new Set(e);return t.delete(n.id),t}),(y.action===`expand-and-load`||y.action===`load`)&&a(n.id).catch(()=>void 0)},type:`button`,children:y.label}),s.length===0&&d.length===0&&h?.isPending!==!0?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:F(`sidebar.noTasks`)}):null,s.length===0&&d.length>0&&!M.isPending&&M.error===null?(0,J.jsx)(`p`,{className:`px-2 py-1.5 text-meta text-subtle-foreground`,children:F(`sidebar.noMatchingTasks`)}):null]}):null]},n.id)})]})]})]})})}function rg({expanded:e,onCreate:t,onToggle:n}){let{t:r}=y(`workbench`);return(0,J.jsxs)(`div`,{className:`flex h-8 items-center gap-0.5 text-muted-foreground`,children:[(0,J.jsxs)(v,{"aria-controls":`temporary-tasks-content`,"aria-expanded":e,className:`h-8 min-w-0 flex-1 gap-2 rounded-control px-2 text-body-small font-medium`,contentAlign:`start`,id:`temporary-tasks-title`,onClick:n,type:`button`,variant:`ghost`,children:[(0,J.jsx)(Ec,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`truncate`,children:r(`sidebar.temporaryTasks`)})]}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":r(`sidebar.newTask`),onClick:t,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(We,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:r(`sidebar.newTask`)})]})]})}var ig=`flex h-9 w-full items-center gap-2.5 rounded-control px-2.5 text-body-small font-medium text-foreground transition-colors hover:bg-control-hover`,ag=`size-4 shrink-0 text-muted-foreground`;function og({appInfo:e,connectionState:t,onClose:n,onOpenSettings:r,projectId:i,taskId:a}){let{t:o}=y(`workbench`),{client:s,error:c,isPending:l,projects:u,projectTaskStates:d,tasks:f}=Bo(),{addProject:p,fetchNextProjectTaskPage:m,forgetTask:h,reorderProjects:g,removeProject:_,renameProject:b,setExpandedProjectTaskIds:x}=Vo(),{isProjectActionPending:S,isProjectOrderPending:C,isProjectAddPending:w,taskActivity:T}=Ho(),E=aa(),D=Ee(),[O]=(0,K.useState)(Gl),[k]=(0,K.useState)(()=>Kl(O)),A=(0,K.useRef)(k),j=(0,K.useRef)(u.length>0),[M,N]=(0,K.useState)(()=>Xl(u.map(e=>e.id),k)),P=(0,K.useRef)(M),[F,I]=(0,K.useState)(``),[L,ee]=(0,K.useState)(()=>new Set),[R,z]=(0,K.useState)(null),[B,te]=(0,K.useState)(null),[H,ne]=(0,K.useState)(null),[W,re]=(0,K.useState)(null),[ie,ae]=(0,K.useState)(!1),oe=Ye(st(s)),se=Ye(et(s)),ce=Ye(Ot(s)),G=(0,K.useRef)(Ue()),le=Hl({actionLock:G.current,activeProjectId:i,activeTaskId:a}),ue=F.trim().toLocaleLowerCase(),de=Wo(ue),fe=Go(),pe=ue.length===0?f:de.tasks,me=(0,K.useMemo)(()=>Bh(pe),[pe]),he=zc(ue.length===0?fe.tasks:pe),ge=fe.error!==null||[...d.values()].some(e=>e.error!==null),_e=oe.isPending||se.isPending||ce.isPending||le.isDeletePending,{activeProjectId:ve,announcement:be,getProjectReorderProps:xe,orderedProjects:Se}=Vl({disabled:C,onReorder:g,projects:u});(0,K.useEffect)(()=>{if(l||i===void 0||i===`temporary`||u.some(e=>e.id===i))return;let e=u[0];E(e===void 0?{replace:!0,to:`/`}:{params:{projectId:e.id},replace:!0,to:`/p/$projectId`})},[l,E,i,u]),(0,K.useEffect)(()=>{let e=u.map(e=>e.id);if(!j.current&&e.length>0){j.current=!0;let t=Xl(e,A.current);P.current=t,N(t);return}let t=new Set(e),n=P.current,r=new Set([...n].filter(e=>t.has(e)));r.size!==n.size&&(P.current=r,N(r))},[u]),(0,K.useEffect)(()=>{x(M)},[M,x]);let Ce=(0,K.useCallback)(e=>{let t=e(P.current);P.current=t,A.current=t,ql(O,t),N(t)},[O]),we=e=>{Ce(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Te=async e=>{await p(e)!==void 0&&ae(!1)},De=async e=>{Ce(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n}),await E({params:{projectId:e},to:`/p/$projectId`})},Oe=e=>{dt(D,e)},ke=e=>G.current.run(async()=>{try{let t=await oe.mutateAsync({pinned:!e.pinned,projectId:e.projectId,taskId:e.id});Oe(t.task)}catch{}}),Ae=(e,t)=>G.current.run(async()=>{try{let n=await se.mutateAsync({projectId:e.projectId,taskId:e.id,title:t});Oe(n.task),z(null)}catch{}}),je=e=>G.current.run(async()=>{try{await ce.mutateAsync({projectId:e.projectId,taskId:e.id}),await ut(D,e.projectId,e.id),D.removeQueries({exact:!0,queryKey:[`projects`,e.projectId,`tasks`,e.id]}),h(e.projectId,e.id),e.projectId===i&&e.id===a&&await(e.projectId===`temporary`?E({to:`/temporary`}):E({params:{projectId:e.projectId},to:`/p/$projectId`})),Fl(e.projectId,e.id),s.unsubscribeTask(e.projectId,e.id).catch(()=>void 0)}catch{}}),Me=e=>{re(null),te(null),ne(null),requestAnimationFrame(()=>{document.getElementById(`project-actions-${e}`)?.focus()})},Ne=async(e,t)=>{await b(e.id,t)&&Me(e.id)},Pe=async e=>{await _(e.id)!==void 0&&ne(null)};return(0,J.jsxs)(`aside`,{"aria-label":o(`sidebar.landmark`),className:`workbench-sidebar z-30 grid min-h-0 grid-rows-[auto_auto_minmax(0,1fr)_auto] bg-sidebar shadow-divider`,children:[(0,J.jsxs)(`div`,{className:`flex h-workbench-header items-center gap-2 px-3`,children:[(0,J.jsx)(sg,{}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":o(`sidebar.close`),className:`min-workbench:hidden`,onClick:n,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(Dc,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,J.jsx)(ye,{children:o(`sidebar.close`)})]})]}),(0,J.jsxs)(`nav`,{className:`space-y-0.5 px-2`,"aria-label":o(`sidebar.agentNavigation`),children:[(0,J.jsxs)(`div`,{className:`relative px-1 pb-1`,children:[(0,J.jsx)(Mc,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-2.5 size-4 text-muted-foreground`}),(0,J.jsx)(Pt,{"aria-label":o(`sidebar.search`),className:`h-9 w-full rounded-control bg-control pl-8 pr-2.5 text-body-small text-foreground shadow-sm outline-none placeholder:text-muted-foreground focus:shadow-focus`,onChange:e=>{I(e.currentTarget.value)},placeholder:o(`sidebar.search`),value:F})]}),(0,J.jsxs)(ya,{className:ig,to:`/temporary`,children:[(0,J.jsx)(Nc,{className:ag,"aria-hidden":`true`}),o(`sidebar.newTask`)]})]}),(0,J.jsx)(ng,{archiveTask:je,deleteTask:le.requestTaskDeletion,error:c,expandedProjects:M,expandedTaskProjects:L,fetchNextProjectTaskPage:m,getProjectReorderProps:xe,hasTaskError:ge,isPending:l,isProjectActionPending:S,isProjectAddPending:w,normalizedQuery:ue,onOpenTemporaryDraft:()=>{E({to:`/temporary`})},onOpenProjectDraft:De,onOpenArchived:re,onOpenProjectPicker:()=>{ae(!0)},onRemoveProject:e=>{ne(e)},onRenameProject:e=>{te(e)},orderedProjects:Se,pinTask:ke,pinnedTasks:he,...i===void 0?{}:{projectId:i},projectOrderAnnouncement:be,projectTaskStates:d,reorderingProjectId:ve,setExpandedTaskProjects:ee,setRenamingTask:z,taskActionPending:_e,taskActivity:T,...a===void 0?{}:{taskId:a},taskSearch:de,tasksByProjectId:me,toggleProject:we}),W===null?null:(0,J.jsx)(Eh,{client:s,onClose:()=>{Me(W.id)},project:W}),le.deletingTask===null?null:(0,J.jsx)(wh,{isPending:le.isDeletePending,onClose:le.closeTaskDeletion,onDelete:()=>{le.confirmTaskDeletion()},task:le.deletingTask}),(0,J.jsx)(vh,{client:s,isProjectActionPending:S,isProjectAddPending:w,isProjectPickerOpen:ie,onAddProject:Te,onCloseProjectDialog:Me,onCloseProjectPicker:()=>{w||ae(!1)},onCloseTaskRename:()=>{z(null)},onRemoveProject:e=>{Pe(e)},onRenameProject:(e,t)=>{Ne(e,t)},onRenameTask:(e,t)=>{Ae(e,t)},removingProject:H,renamingProject:B,renamingTask:R,taskRenamePending:se.isPending}),(0,J.jsx)(`div`,{className:`p-2`,children:(0,J.jsx)(Jh,{...e===void 0?{}:{appInfo:e},connectionState:t,onOpen:r})})]})}function sg(){return(0,J.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,J.jsx)(`img`,{alt:`Codexly`,className:`h-7 w-auto max-w-full`,height:`28`,src:`/brand/codexly-logo.svg`,width:`116`})})}function cg(){let{t:e}=y(`common`);return(0,J.jsx)(`main`,{className:`grid h-full place-items-center bg-window px-6`,"aria-labelledby":`not-found-title`,children:(0,J.jsxs)(`section`,{className:`w-full max-w-md rounded-surface bg-raised p-6 shadow-panel`,children:[(0,J.jsx)(`p`,{className:`mb-2 font-mono text-xs text-warning`,children:`404`}),(0,J.jsx)(`h1`,{id:`not-found-title`,className:`text-xl font-semibold`,children:e(`errors.notFoundTitle`)}),(0,J.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:e(`errors.notFoundDescription`)}),(0,J.jsxs)(ya,{className:`mt-5 inline-flex items-center gap-2 text-sm font-medium text-brand-strong`,to:`/`,children:[(0,J.jsx)(pc,{className:`size-4`,"aria-hidden":`true`}),e(`actions.backToWorkbench`)]})]})})}var lg=wa({component:dg,errorComponent:ug,notFoundComponent:cg});function ug({error:e,reset:t}){let{t:n}=y(`common`);return(0,J.jsx)(`main`,{className:`grid h-full place-items-center bg-window px-6`,"aria-labelledby":`route-error-title`,children:(0,J.jsxs)(`section`,{className:`w-full max-w-lg rounded-surface bg-raised p-6 shadow-panel`,children:[(0,J.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-danger uppercase`,children:n(`errors.routeErrorLabel`)}),(0,J.jsx)(`h1`,{id:`route-error-title`,className:`text-xl font-semibold text-foreground`,children:n(`errors.routeErrorTitle`)}),(0,J.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e.message}),(0,J.jsx)(v,{variant:`ghost`,className:`mt-5 rounded-control bg-control px-3 py-2 text-body font-medium text-foreground shadow-sm transition-colors hover:bg-control-hover`,onClick:t,type:`button`,children:n(`actions.retry`)})]})})}function dg(){return(0,J.jsx)(`div`,{className:`h-full min-h-0 bg-window text-foreground`,"data-testid":`app-root`,children:(0,J.jsx)(Fa,{})})}var fg=(0,K.lazy)(()=>ac().then(e=>({default:e.GlobalSettingsDialog}))),pg=Sa({component:mg,getParentRoute:()=>lg,path:`/`});function mg(){let{t:e}=y(`common`),t=uc(),{client:n,error:r,isPending:i,projects:a}=Bo(),{retry:o}=Vo(),s=aa(),c=Ee(),l=R(yt(n)),u=Ye({...gt(n),onSuccess(e){c.setQueryData([`app-info`],e)}}),d=R(Et(n)),f=R(Dt(n)),p=Ye({...ft(n),onSuccess(e){c.setQueryData([`settings`],e)}}),[m,h]=(0,K.useState)(null),[g]=(0,K.useState)(()=>Kl(Gl())),_=Zl(a.map(e=>e.id),g);return(0,K.useEffect)(()=>{if(_!==void 0){s({params:{projectId:_},replace:!0,to:`/p/$projectId`});return}!i&&a.length===0&&s({replace:!0,to:`/temporary`})},[_,i,s,a.length]),r===null?i||_!==void 0||a.length===0?(0,J.jsx)(`main`,{className:`grid h-full place-items-center text-sm text-muted-foreground`,children:e(`app.loadingProjects`)}):(0,J.jsxs)(`div`,{className:`workbench-shell h-full min-h-0 overflow-hidden bg-window`,"data-inspector-open":`false`,"data-sidebar-open":`true`,children:[(0,J.jsx)(og,{...l.data===void 0?{}:{appInfo:l.data},connectionState:`connected`,onClose:()=>void 0,onOpenSettings:e=>{h(e)}}),(0,J.jsx)(`main`,{className:`grid min-h-0 min-w-0 place-items-center bg-content text-sm text-muted-foreground`,children:e(`app.noProjects`)}),m===null?null:(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(fg,{...t.status===void 0?{}:{accessMode:t.status.mode},...l.data===void 0?{}:{appInfo:l.data},appInfoError:l.error,initialSection:m,apps:[],error:d.error??f.error,isPending:d.isPending||f.isPending,isAppInfoPending:l.isPending,isAppUpdatePending:u.isPending,models:f.data?.data??[],onClose:()=>{let e=m===`about`?`#global-settings-about-trigger`:`#global-settings-trigger`;h(null),requestAnimationFrame(()=>{document.querySelector(e)?.focus()})},onLogoutAccess:t.logout,onRetry:()=>Promise.all([d.refetch(),f.refetch()]),onRetryAppInfo:()=>l.refetch(),onSave:e=>p.mutateAsync(e).then(()=>void 0),onUpdate:e=>u.mutateAsync(e).then(()=>void 0),...d.data===void 0?{}:{settings:d.data.settings}})})]}):(0,J.jsx)(`main`,{className:`flex h-full min-h-0`,children:(0,J.jsx)(Rc,{onRetry:()=>void o()})})}function hg(){return ic(()=>import(`./workbench-shell-D21PPmmO.js`),__vite__mapDeps([12,1,2,3,4,5,6,13,14,7,8,9,15,16,17,10,18,19]))}var gg=(0,K.lazy)(()=>hg().then(e=>({default:e.WorkbenchShell})));function _g(e){let{t}=y(`common`);return(0,J.jsx)(K.Suspense,{fallback:(0,J.jsx)(`main`,{className:`grid h-full place-items-center text-sm text-muted-foreground`,role:`status`,children:t(`app.loadingProjects`)}),children:(0,J.jsx)(gg,{...e})})}var vg=Sa({component:yg,getParentRoute:()=>lg,path:`/p/$projectId`});function yg(){let{projectId:e}=vg.useParams();return(0,J.jsx)(_g,{projectId:e})}var bg=Sa({component:xg,getParentRoute:()=>lg,path:`/p/$projectId/t/$taskId`});function xg(){let{projectId:e,taskId:t}=bg.useParams();return(0,J.jsx)(_g,{projectId:e,taskId:t})}var Sg=Sa({component:Cg,getParentRoute:()=>lg,path:`/temporary`});function Cg(){return(0,J.jsx)(_g,{projectId:Re,temporary:!0})}var wg=Sa({component:Tg,getParentRoute:()=>lg,path:`/temporary/t/$taskId`});function Tg(){let{taskId:e}=wg.useParams();return(0,J.jsx)(_g,{projectId:Re,taskId:e,temporary:!0})}var Eg=Ba({defaultPreload:`intent`,routeTree:lg.addChildren([pg,vg,bg,Sg,wg]),scrollRestoration:!0});function Dg(){return(0,J.jsx)(Ua,{router:Eg})}function Og({error:e,loading:t,onPair:n,onRetry:r,pairing:i}){let{t:a}=y(`common`),[o,s]=(0,K.useState)(``);return(0,J.jsx)(`main`,{className:`access-gate grid h-full min-h-0 place-items-center overflow-y-auto bg-window px-5 py-10 text-foreground`,children:(0,J.jsxs)(`section`,{"aria-labelledby":`access-gate-title`,className:`w-full max-w-sm`,children:[(0,J.jsx)(`h1`,{className:`mb-8`,id:`access-gate-title`,children:(0,J.jsx)(`img`,{alt:`Codexly`,className:`h-10 w-auto`,height:`40`,src:`/brand/codexly-logo.svg`,width:`165`})}),t?(0,J.jsx)(`p`,{className:`text-body-small text-muted-foreground`,role:`status`,children:a(`access.checking`)}):e===`load`?(0,J.jsxs)(`div`,{className:`space-y-4`,role:`alert`,children:[(0,J.jsx)(`p`,{className:`text-body-small text-danger`,children:a(`access.loadError`)}),(0,J.jsxs)(v,{onClick:r,size:`lg`,type:`button`,variant:`secondary`,children:[(0,J.jsx)(jc,{"aria-hidden":`true`,className:`size-4`}),a(`actions.retry`)]})]}):(0,J.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault();let t=o.trim();t.length>0&&!i&&n(t)},children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-heading font-semibold`,children:a(`access.pairingTitle`)}),(0,J.jsx)(`p`,{className:`mt-1 text-body-small text-muted-foreground`,children:a(`access.pairingDescription`)})]}),(0,J.jsx)(`label`,{className:`block text-body-small font-medium`,htmlFor:`access-pairing-code`,children:a(`access.codeLabel`)}),(0,J.jsxs)(`div`,{className:`flex h-10 items-center rounded-control border border-separator-strong bg-panel focus-within:border-brand focus-within:shadow-focus`,children:[(0,J.jsx)(Cc,{"aria-hidden":`true`,className:`ml-3 size-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(Pt,{"aria-label":a(`access.codeLabel`),autoComplete:`current-password`,className:`access-code-input min-w-0 flex-1 bg-transparent px-3 font-mono text-body`,id:`access-pairing-code`,onChange:e=>{s(e.currentTarget.value)},spellCheck:!1,type:`password`,value:o,variant:`embedded`}),(0,J.jsx)(v,{"aria-label":a(`access.pair`),className:`mr-1`,disabled:i||o.trim().length===0,title:a(`access.pair`),type:`submit`,size:`icon-compact`,children:(0,J.jsx)(mc,{"aria-hidden":`true`,className:`size-4`})})]}),i?(0,J.jsx)(`p`,{className:`text-meta text-muted-foreground`,role:`status`,children:a(`access.pairing`)}):null]})]})})}function kg({disabled:e,models:t,onAdd:n,onChange:r,onRemove:i}){let{t:a}=y(`settings`);return(0,J.jsxs)(`div`,{className:`grid gap-2`,children:[t.length===0?null:(0,J.jsxs)(`div`,{className:`hidden grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2rem] gap-2 px-1 text-meta font-medium text-muted-foreground sm:grid`,children:[(0,J.jsx)(`span`,{children:a(`provider.modelId`)}),(0,J.jsx)(`span`,{children:a(`provider.modelName`)}),(0,J.jsx)(`span`,{})]}),t.map(t=>(0,J.jsxs)(`div`,{className:`grid gap-2 border-b border-separator pb-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2rem] sm:items-end`,children:[(0,J.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,J.jsx)(`span`,{className:`text-meta font-medium text-muted-foreground sm:sr-only`,children:a(`provider.modelId`)}),(0,J.jsx)(Pt,{autoCapitalize:`none`,autoComplete:`off`,disabled:e,maxLength:256,onChange:e=>{r(t.key,`id`,e.currentTarget.value)},spellCheck:!1,value:t.id,variant:`outline`})]}),(0,J.jsxs)(`label`,{className:`grid min-w-0 gap-1`,children:[(0,J.jsx)(`span`,{className:`text-meta font-medium text-muted-foreground sm:sr-only`,children:a(`provider.modelName`)}),(0,J.jsx)(Pt,{autoComplete:`off`,disabled:e,maxLength:256,onChange:e=>{r(t.key,`name`,e.currentTarget.value)},value:t.name,variant:`outline`})]}),(0,J.jsxs)(V,{children:[(0,J.jsx)(U,{asChild:!0,children:(0,J.jsx)(v,{"aria-label":a(`provider.removeModel`),className:`justify-self-end sm:justify-self-auto`,disabled:e,onClick:()=>{i(t.key)},size:`icon-compact`,type:`button`,variant:`ghost`,children:(0,J.jsx)(It,{"aria-hidden":`true`,className:`size-4`})})}),(0,J.jsx)(ye,{children:a(`provider.removeModel`)})]})]},t.key)),(0,J.jsxs)(v,{className:`justify-self-start`,disabled:e||t.length>=1e3,onClick:n,type:`button`,variant:`outline`,children:[(0,J.jsx)(We,{"aria-hidden":`true`,className:`size-4`}),a(`provider.addModel`)]})]})}function Ag({apiKey:e,baseUrl:t,error:n,isBusy:r,mode:i,models:a,onAddModel:o,onApiKeyChange:s,onBaseUrlChange:c,onCancelLogin:l,onConfigureCustom:u,onLogout:d,onModelChange:f,onModeChange:p,onRetry:h,onRemoveModel:g,onStartOfficialLogin:_,status:b}){let{t:x}=y(`settings`),S=b?.mode===i&&b.state===`connected`,C=b?.mode===`official`&&b.state===`pending`;return(0,J.jsxs)(`div`,{className:`w-full max-w-[38rem]`,children:[(0,J.jsxs)(`div`,{"aria-label":x(`provider.mode`),className:`grid grid-cols-2 rounded-control bg-control p-1`,role:`group`,children:[(0,J.jsxs)(v,{"aria-pressed":i===`official`,className:m(`inline-flex h-10 items-center justify-center gap-2 rounded-[5px] text-body-small font-medium sm:h-9`,i===`official`?`bg-raised text-foreground shadow-control`:`text-muted-foreground hover:text-foreground`),onClick:()=>{p(`official`)},type:`button`,variant:`ghost`,children:[(0,J.jsx)(wc,{"aria-hidden":`true`,"data-icon":`inline-start`}),x(`provider.official`)]}),(0,J.jsxs)(v,{"aria-pressed":i===`custom`,className:m(`inline-flex h-10 items-center justify-center gap-2 rounded-[5px] text-body-small font-medium sm:h-9`,i===`custom`?`bg-raised text-foreground shadow-control`:`text-muted-foreground hover:text-foreground`),onClick:()=>{p(`custom`)},type:`button`,variant:`ghost`,children:[(0,J.jsx)(Pc,{"aria-hidden":`true`,"data-icon":`inline-start`}),x(`provider.custom`)]})]}),(0,J.jsx)(`div`,{className:`mt-5`,children:i===`official`?(0,J.jsxs)(`div`,{className:`grid gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-12 items-center gap-3 border-b border-separator pb-4`,children:[S?(0,J.jsx)(Rt,{"aria-hidden":`true`,className:`size-5 shrink-0 text-brand`}):C?(0,J.jsx)(O,{"aria-hidden":`true`,className:`size-5 shrink-0 animate-spin text-brand`}):(0,J.jsx)(wc,{"aria-hidden":`true`,className:`size-5 shrink-0 text-muted-foreground`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-body-small font-medium text-foreground`,children:x(S?`provider.connected`:C?`provider.waiting`:`provider.disconnected`)}),b?.account?.type===`chatgpt`&&b.account.email!==null?(0,J.jsx)(`p`,{className:`truncate text-meta text-muted-foreground`,children:b.account.email}):null]})]}),C?(0,J.jsxs)(v,{className:`h-11 justify-self-start sm:h-9`,disabled:r,onClick:l,type:`button`,variant:`outline`,children:[(0,J.jsx)(Lc,{"aria-hidden":`true`,className:`size-4`}),x(`provider.cancelLogin`)]}):S?(0,J.jsxs)(v,{className:`h-11 justify-self-start sm:h-9`,disabled:r,onClick:d,type:`button`,variant:`outline`,children:[(0,J.jsx)(Tc,{"aria-hidden":`true`,className:`size-4`}),x(`provider.logout`)]}):(0,J.jsxs)(v,{className:`h-11 justify-self-start sm:h-9`,disabled:r,onClick:_,type:`button`,children:[r?(0,J.jsx)(O,{"aria-hidden":`true`,className:`size-4 animate-spin`}):(0,J.jsx)(wc,{"aria-hidden":`true`,className:`size-4`}),x(`provider.login`)]})]}):(0,J.jsxs)(`div`,{className:`grid gap-4`,children:[(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-body-small font-medium text-foreground`,children:[x(`provider.baseUrl`),(0,J.jsx)(Pt,{autoCapitalize:`none`,autoComplete:`url`,disabled:r,inputMode:`url`,maxLength:2048,onChange:e=>{c(e.currentTarget.value)},placeholder:`https://api.example.com/v1`,spellCheck:!1,type:`url`,value:t,variant:`outline`})]}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-body-small font-medium text-foreground`,children:[x(`provider.apiKey`),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(Cc,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,J.jsx)(Pt,{autoComplete:`new-password`,className:`pl-9`,disabled:r,maxLength:16384,onChange:e=>{s(e.currentTarget.value)},spellCheck:!1,type:`password`,value:e,variant:`outline`})]})]}),(0,J.jsxs)(`div`,{className:`grid gap-1.5 text-body-small font-medium text-foreground`,children:[(0,J.jsx)(`span`,{children:x(`provider.models`)}),(0,J.jsx)(kg,{disabled:r,models:a,onAdd:o,onChange:f,onRemove:g})]}),S?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small text-brand`,children:[(0,J.jsx)(Rt,{"aria-hidden":`true`,className:`size-4`}),(0,J.jsx)(`span`,{children:x(`provider.connected`)})]}):null,(0,J.jsxs)(v,{className:`h-11 justify-self-start sm:h-9`,disabled:r||t.trim().length===0||jg(a),onClick:u,type:`button`,children:[r?(0,J.jsx)(O,{"aria-hidden":`true`,className:`size-4 animate-spin`}):(0,J.jsx)(Pc,{"aria-hidden":`true`,className:`size-4`}),x(S?`provider.reconnect`:`provider.connect`)]})]})}),n===null?null:(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 text-body-small`,role:`alert`,children:[(0,J.jsx)(`p`,{className:`min-w-0 text-danger`,children:n}),(0,J.jsx)(v,{"aria-label":x(`provider.retry`),className:`shrink-0`,onClick:h,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,J.jsx)(Mt,{"aria-hidden":`true`,className:`size-4`})})]})]})}function jg(e){return e.some(e=>e.id.trim().length===0||e.name.trim().length===0)}function Mg({apiKey:e,baseUrl:t,models:n}){let r=n.map(({id:e,name:t})=>({id:e.trim(),name:t.trim()}));return{...e.length===0?{}:{apiKey:e},baseUrl:t.trim(),...r.length===0?{}:{models:r}}}function Ng(e){let t=new URL(e);if(t.protocol!==`https:`)throw Error(`Official login URL must use HTTPS`);window.open(t,`_blank`,`noopener,noreferrer`)}function Pg(){let e=Ee(),t=R(jt()),n=Ye(kt(e)),r=Ye(Lt(e)),i=Ye(Ft(e)),[a,o]=(0,K.useState)(`official`),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)([]),p=(0,K.useRef)(1),[m,h]=(0,K.useState)(!1),g=t.data;(0,K.useEffect)(()=>{g!==void 0&&(o(g.mode),g.customBaseUrl!==null&&c(g.customBaseUrl))},[g]);let _=n.isPending||r.isPending||i.isPending||m;return(0,J.jsx)(Ag,{apiKey:l,baseUrl:s,error:t.error?.message??null,isBusy:_,mode:a,models:d,onAddModel:()=>{let e=`custom-model-${String(p.current)}`;p.current+=1,f(t=>[...t,{id:``,key:e,name:``}])},onApiKeyChange:u,onBaseUrlChange:c,onCancelLogin:()=>{let e=g?.pendingLogin?.loginId;e!==void 0&&r.mutateAsync(e).catch(()=>void 0)},onConfigureCustom:()=>{h(!0),Nt(Mg({apiKey:l,baseUrl:s,models:d}),e).then(()=>{u(``),qe()}).catch(e=>{Ge(e)}).finally(()=>{u(``),h(!1)})},onLogout:()=>{i.mutateAsync().catch(()=>void 0)},onModelChange:(e,t,n)=>{f(r=>r.map(r=>r.key===e?{...r,[t]:n}:r))},onModeChange:e=>{o(e)},onRetry:()=>{t.refetch()},onRemoveModel:e=>{f(t=>t.filter(t=>t.key!==e))},onStartOfficialLogin:()=>{n.mutateAsync().then(e=>{try{Ng(e.authUrl)}catch(e){Ge(e)}}).catch(()=>void 0)},status:g})}function Fg({children:e}){let{t}=y(`settings`),n=R(jt());return n.data?.state===`connected`?e:n.isPending?(0,J.jsx)(`main`,{className:`grid h-full min-h-0 place-items-center bg-window text-body-small text-muted-foreground`,children:t(`provider.loading`)}):(0,J.jsx)(`main`,{className:`h-full min-h-0 overflow-y-auto bg-window px-5 py-8 sm:px-8 sm:py-12`,children:(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-[42rem]`,children:[(0,J.jsxs)(`header`,{className:`mb-8 border-b border-separator pb-5`,children:[(0,J.jsx)(`h1`,{className:`text-xl font-semibold text-foreground`,children:`Codexly`}),(0,J.jsx)(`p`,{className:`mt-1 text-body-small text-muted-foreground`,children:t(`provider.title`)})]}),n.error===null?(0,J.jsx)(Pg,{}):(0,J.jsxs)(`div`,{className:`grid justify-items-start gap-3`,role:`alert`,children:[(0,J.jsx)(`p`,{className:`text-body-small text-danger`,children:t(`provider.errors.load`)}),(0,J.jsx)(v,{onClick:()=>void n.refetch(),type:`button`,variant:`outline`,children:t(`provider.retry`)})]})]})})}var Ig={attachments:[],content:[]},Lg=(0,K.createContext)(void 0);function Rg(e,t){return JSON.stringify([e,t??`draft`])}function zg(e){return e.content.length===0&&e.attachments.length===0}function Bg(e){return e.attachments.map(e=>e.previewUrl)}function Vg(e){for(let t of new Set(Bg(e)))t.startsWith(`blob:`)&&URL.revokeObjectURL(t)}function Hg(e,t){let n=new Set(Bg(t));for(let t of new Set(Bg(e)))!n.has(t)&&t.startsWith(`blob:`)&&URL.revokeObjectURL(t)}function Ug(){let e=new Map,t=t=>e.get(t)??Ig;return{clear:t=>{let n=e.get(t);n!==void 0&&(Vg(n),e.delete(t))},dispose:()=>{e.forEach(Vg),e.clear()},read:t,update:(n,r)=>{let i=t(n),a=r(i);Hg(i,a),zg(a)?e.delete(n):e.set(n,a)}}}function Wg({children:e}){let t=(0,K.useRef)(Ug()).current;return(0,K.useEffect)(()=>()=>{t.dispose()},[t]),(0,J.jsx)(Lg.Provider,{value:t,children:e})}function Gg(){let e=(0,K.useContext)(Lg);if(e===void 0)throw Error(`useComposerDraftStore must be used inside ComposerDraftProvider`);return e}var Kg=`codexly.notification-preference`,qg=1;function Jg(e){try{let t=JSON.parse(e.getItem(Kg)??`null`);if(typeof t==`object`&&t&&`version`in t&&t.version===qg&&`enabled`in t&&typeof t.enabled==`boolean`)return t.enabled}catch{}return!0}function Yg(e,t){try{t.setItem(Kg,JSON.stringify({enabled:e,version:qg}))}catch{}}function Xg(){try{return typeof window>`u`||Jg(window.localStorage)}catch{return!0}}function Zg(e){try{typeof window<`u`&&Yg(e,window.localStorage)}catch{}}var Qg=48*1048576;function $g(e){return Array.isArray(e)&&e.length===4&&e[0]===`projects`&&typeof e[1]==`string`&&e[2]===`tasks`&&typeof e[3]==`string`}function e_(e,t=Qg,n=12){let r=new xs({getRetainedBytes:(e,t)=>t.retainedBytes,maxBytes:t,maxEntries:n,onEvict(t,n,r){r!==`replaced`&&e.getQueryCache().find({exact:!0,queryKey:n.queryKey})?.getObserversCount()===0&&e.removeQueries({exact:!0,queryKey:n.queryKey})}});return e.getQueryCache().subscribe(e=>{let t=e.query,n=t.queryKey,i=t.queryHash,a=t.state.data;if(!(!$g(n)||typeof i!=`string`)){if(e.type===`removed`||t.getObserversCount()>0||a===void 0){r.delete(i);return}r.set(i,{queryKey:n,retainedBytes:X(a)})}})}var t_=2*6e4;function n_(){let e=new Ya({mutationCache:ze(),defaultOptions:{queries:{gcTime:t_,refetchOnWindowFocus:!1,retry:1,staleTime:3e4}}});return e_(e),e}var r_=n_();function i_(e,t){e===`temporary`?Eg.navigate({params:{taskId:t},to:`/temporary/t/$taskId`}):Eg.navigate({params:{projectId:e,taskId:t},to:`/p/$projectId/t/$taskId`})}var a_=$o({isEnabled:Xg,navigateToTask:i_});function o_({access:e,children:t}){return e.status?.authenticated===!0?t:(0,J.jsx)(Og,{error:e.error,loading:e.loading,onPair:e.pair,onRetry:e.retry,pairing:e.pairing})}function s_({children:e}){let t=uc(),{t:n}=y(`common`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(o_,{access:t,children:(0,J.jsx)(Fg,{children:(0,J.jsx)(ec,{taskNotifier:a_,children:(0,J.jsx)(Wg,{children:e})})})}),(0,J.jsx)(Be,{containerAriaLabel:n(`app.notificationRegion`),duration:5e3,position:`top-center`,richColors:!0,theme:`system`})]})}function c_({children:e}){return(0,J.jsx)(ko,{i18n:S,children:(0,J.jsx)(Te,{children:(0,J.jsx)(be,{client:r_,children:(0,J.jsx)(lc,{client:j,queryClient:r_,children:(0,J.jsx)(s_,{children:e})})})})})}var l_=`codexly.theme-preference`,u_=1,d_=`(prefers-color-scheme: dark)`,f_;function p_(e){try{let t=JSON.parse(e.getItem(l_)??`null`);if(typeof t==`object`&&t&&`version`in t&&t.version===u_&&`theme`in t&&(t.theme===`dark`||t.theme===`light`||t.theme===`system`))return t.theme}catch{}return`system`}function m_(e,t){try{t.setItem(l_,JSON.stringify({theme:e,version:u_}))}catch{}}function h_(e,t,n=!1){t.dataset.theme=e===`system`?n?`dark`:`light`:e}function g_(e){f_?.(),f_=void 0;let t=window.matchMedia(d_),n=()=>{h_(e,document.documentElement,t.matches)};n(),e===`system`&&(t.addEventListener(`change`,n),f_=()=>{t.removeEventListener(`change`,n)})}function __(e){m_(e,window.localStorage),g_(e)}function v_(){let e=p_(window.localStorage);return g_(e),e}var y_=document.querySelector(`#root`);if(!(y_ instanceof HTMLElement))throw Error(`Missing #root element`);v_(),(0,Ao.createRoot)(y_).render((0,J.jsx)(K.StrictMode,{children:(0,J.jsx)(c_,{children:(0,J.jsx)(Dg,{})})}));export{Ac as $,Gm as A,If as B,dh as C,sh as D,rh as E,Qm as F,Nd as G,Gf as H,Km as I,nl as J,Nl as K,Ff as L,$m as M,Zm as N,ah as O,Xm as P,Lc as Q,Lf as R,_h as S,oh as T,qf as U,Pf as V,Kf as W,Gc as X,rl as Y,Rc as Z,Lh as _,Uo as _t,Rg as a,vc as at,Nh as b,aa as bt,og as c,ac as ct,jh as d,Ms as dt,Oc as et,Fh as f,xs as ft,zh as g,Bo as gt,Rh as h,Vo as ht,Zg as i,yc as it,Ym as j,ih as k,Hh as l,ic as lt,Ih as m,bs as mt,__ as n,Tc as nt,Gg as o,gc as ot,Mh as p,X as pt,xl as q,Xg as r,xc as rt,Pg as s,uc as st,p_ as t,Ec as tt,Dh as u,Ys as ut,kh as v,Za as vt,nh as w,Oh as x,Ph as y,Xa as yt,Bf as z};