@overdeck/desktop 0.65.0 → 0.66.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 (344) hide show
  1. package/package.json +1 -1
  2. package/server/{acceptance-criteria-BgED6Izb.js → acceptance-criteria-CNfqZWHE.js} +1 -1
  3. package/server/activity-CElPNdhJ.js +2 -0
  4. package/server/{activity-CVRFYPg-.js → activity-h2Q-pMa7.js} +4 -4
  5. package/server/{agent-pane-io-8U_dsHCf.js → agent-pane-io-CXPX0Kq3.js} +43 -5
  6. package/server/agent-pane-io-H-50g3Ze.js +2 -0
  7. package/server/{agent-state-service-CZjmcB3_.js → agent-state-service-CJB8_8Bp.js} +2 -2
  8. package/server/{agent-state-service-hbWznp6M.js → agent-state-service-Cs_Z_oHX.js} +1 -1
  9. package/server/{agent-status-events-HU33uOJc.js → agent-status-events-DfYAcfpo.js} +1 -1
  10. package/server/{agents-DfEYd_I0.js → agents-C9oho7kE.js} +3 -3
  11. package/server/{agents-CKFhKqJp.js → agents-DebP6rx9.js} +56 -46
  12. package/server/{agents-DNkpVGda.js → agents-dwMmsEQT.js} +2 -2
  13. package/server/archive-planning-DflA6GM1.js +2 -0
  14. package/server/{archive-planning-BvwP8nTs.js → archive-planning-vbycG6oX.js} +2 -2
  15. package/server/{artifact-index-jobs-CFe2p3St.js → artifact-index-jobs-C73RHIUN.js} +1 -1
  16. package/server/{auto-merge-eligibility-De2WgmQS.js → auto-merge-eligibility-f1D8TwAj.js} +1 -1
  17. package/server/{auto-merge-eligibility-DmUQEAws.js → auto-merge-eligibility-is6bTkrA.js} +1 -1
  18. package/server/{auto-spawn-consent-DRgQbl8k.js → auto-spawn-consent-BxXl-3y7.js} +2 -2
  19. package/server/{backend-inventory-CjCALqY9.js → backend-inventory-DsbeKiYY.js} +2 -2
  20. package/server/{backend-inventory-HZnm8K3m.js → backend-inventory-tUXKfgL_.js} +1 -1
  21. package/server/{backlog-auto-trigger-BZ9HqOh5.js → backlog-auto-trigger-EIBVGK3_.js} +2 -2
  22. package/server/checkpoint-worker.js +1 -1
  23. package/server/{checkpoints-BiGSCyKD.js → checkpoints-C-xh-Mv0.js} +1 -1
  24. package/server/{checkpoints-DEk_xKPI.js → checkpoints-SNuYbtl9.js} +1 -1
  25. package/server/{claude-hooks-provision-DOMp0nce.js → claude-hooks-provision-BGL61BFy.js} +1 -1
  26. package/server/{claude-hooks-provision-Cx-iNW3h.js → claude-hooks-provision-D60ldmh3.js} +1 -1
  27. package/server/{claude-settings-overlay-DX8SS3mU.js → claude-settings-overlay-BKk6aPyn.js} +1 -1
  28. package/server/{claude-settings-overlay-tccrSYWh.js → claude-settings-overlay-Z1wvGWrM.js} +1 -1
  29. package/server/{cli-BOQWA-ux.js → cli-CfYEyYsr.js} +3 -3
  30. package/server/cli-DHZ5Ecrt.js +2 -0
  31. package/server/{closed-issue-reaper-g1xev2lv.js → closed-issue-reaper-DkGIkI3v.js} +1 -1
  32. package/server/{closed-issue-reaper-DnaFCYJk.js → closed-issue-reaper-tjnA5V8Z.js} +3 -3
  33. package/server/{codex-BE1w7ARL.js → codex-BrY7aOvP.js} +2 -2
  34. package/server/{codex-CVOd_JEs.js → codex-vuXHqT53.js} +1 -1
  35. package/server/{conflict-gate-Domf8Fvr.js → conflict-gate-CPbG8VXI.js} +2 -2
  36. package/server/{constants-ZsF6FhcR.js → constants-DEItMRn6.js} +1 -1
  37. package/server/{conversation-compaction-Dm4_bCqZ.js → conversation-compaction-BLDpoKfB.js} +5 -5
  38. package/server/{conversation-compaction-sKyT07L1.js → conversation-compaction-D1aR4ytx.js} +1 -1
  39. package/server/{conversation-delivery-Dn6b4mUU.js → conversation-delivery-C0Q7Ew-t.js} +17 -17
  40. package/server/{conversation-liveness-DJzPiGPO.js → conversation-liveness-DO3e-N73.js} +1 -1
  41. package/server/{conversation-liveness-Cq4TNxqa.js → conversation-liveness-g3nFofTZ.js} +2 -2
  42. package/server/{conversation-pull-requests-Bu30dOQv.js → conversation-pull-requests-VQwME1F1.js} +1 -1
  43. package/server/{conversation-reads-CGepvSWx.js → conversation-reads-0fCsCPQe.js} +8 -8
  44. package/server/{conversation-reads-D-UfsYqf.js → conversation-reads-lMO8cWqw.js} +1 -1
  45. package/server/{conversation-runtime-DA_Famk_.js → conversation-runtime-Bh4Wj05k.js} +1 -1
  46. package/server/{conversations-search-CDvHCyYe.js → conversations-search-CS0COdna.js} +1 -1
  47. package/server/{cpu-psi-BN99YdGz.js → cpu-psi-DvzVl1bx.js} +1 -1
  48. package/server/{daemon-BX8hAPTC.js → daemon-DMVuHx-i.js} +2 -2
  49. package/server/daemon-d62dV_pO.js +2 -0
  50. package/server/{dag-DC0niH7i.js → dag-PPL-MAx0.js} +1 -1
  51. package/server/{dangerous-git-ops-GKdOQbOe.js → dangerous-git-ops-BcSMn_cv.js} +1 -1
  52. package/server/dashboard-db-worker.js +4 -4
  53. package/server/{deacon-swarm-record-4FGgybnL.js → deacon-swarm-record-BenMf1-5.js} +1 -1
  54. package/server/deacon.js +4 -4
  55. package/server/{derived-issue-state-BtoFumna.js → derived-issue-state-BaGJkxQq.js} +2 -2
  56. package/server/{derived-issue-state-DnKs1TXS.js → derived-issue-state-BqhN4lOl.js} +1 -1
  57. package/server/{derived-issue-state-CCHbqKjW.js → derived-issue-state-CmvMPi-R.js} +4 -4
  58. package/server/{derived-issue-state-QLhfZgf5.js → derived-issue-state-Dz7ti1og.js} +2 -2
  59. package/server/{dist-B5cmD5rC.js → dist-B-6_eqmp.js} +1 -1
  60. package/server/dist-rCsp8VVx.js +3 -0
  61. package/server/{dod-C6qNQ8O3.js → dod-BJP9kMFG.js} +1 -1
  62. package/server/{done-preflight-Bu3KGCAV.js → done-preflight-ZQMI79O0.js} +1 -1
  63. package/server/{done-preflight-BvmOQ64R.js → done-preflight-oy6Tja5C.js} +1 -1
  64. package/server/{ensure-devcontainer-HQ3fQD5V.js → ensure-devcontainer-CollbMTo.js} +2 -2
  65. package/server/ensure-devcontainer-bvZTPcBb.js +2 -0
  66. package/server/evict-LT5Wbo6F.js +2 -0
  67. package/server/{evict-Dhzce_bB.js → evict-l0JJZ11s.js} +2 -2
  68. package/server/{feedback-target-C6lpafxM.js → feedback-target-B0XBJvkz.js} +1 -1
  69. package/server/{feedback-target-DmQ249DE.js → feedback-target-BYLtF8vX.js} +3 -3
  70. package/server/{feedback-writer-pF7pA9Ei.js → feedback-writer-XmR1ZtVC.js} +1 -1
  71. package/server/{feedback-writer-DSEPHMwz.js → feedback-writer-g9cmlhQU.js} +1 -1
  72. package/server/{flywheel-Ib4Qp5x6.js → flywheel-C-t-XYUt.js} +3 -3
  73. package/server/{flywheel-merge-order-BjbLhtpF.js → flywheel-merge-order-qRslbYK3.js} +2 -2
  74. package/server/{format-QXO0qqJo.js → format-3trt48Iz.js} +1 -1
  75. package/server/{from-ufsGrQUf.js → from-Cdjxc_Sy.js} +1 -1
  76. package/server/{generation-ship-a14Tkc5B.js → generation-ship-BTyy05vO.js} +1 -1
  77. package/server/{harness-binary-DtPw6bEJ.js → harness-binary-BaN9N-sG.js} +2 -2
  78. package/server/harness-binary-DFBkr1Wg.js +2 -0
  79. package/server/{harness-resolve-BfOivkUY.js → harness-resolve-CimEYcpG.js} +4 -4
  80. package/server/{harness-resolve-PDc4GGnM.js → harness-resolve-DclBRYRh.js} +1 -1
  81. package/server/{herdr-agent-terminals-ffj8Zg3X.js → herdr-agent-terminals-Dm4HnKF7.js} +1 -1
  82. package/server/infer-tracker-BJR_ATzw.js +2 -0
  83. package/server/infer-tracker-CwOO7_gU.js +237 -0
  84. package/server/{issue-lifecycle-BlE7L0r7.js → issue-lifecycle-CmbQlAqW.js} +8 -8
  85. package/server/{issue-lifecycle-Y8IGkADf.js → issue-lifecycle-Dt9AFW70.js} +1 -1
  86. package/server/{issue-pause-9vXZZkOc.js → issue-pause-kvPBItCx.js} +5 -5
  87. package/server/{issue-service-singleton-DxTRf-RV.js → issue-service-singleton-BbERjqoV.js} +1 -1
  88. package/server/{issue-service-singleton-QPDr49TB.js → issue-service-singleton-DwYi9Oie.js} +3 -3
  89. package/server/{kimi-code-AcOc8X0U.js → kimi-code-DNNwP6FT.js} +1 -1
  90. package/server/{label-cleanup-CIoPmmbd.js → label-cleanup-C7weaJlZ.js} +2 -2
  91. package/server/{launch-DSEY_mt2.js → launch-DF_WD2-a.js} +10 -7
  92. package/server/{launch-DCAI36Nq.js → launch-DlClnoCc.js} +1 -1
  93. package/server/{launcher-generator-BofB3FX_.js → launcher-generator-COHAIhyH.js} +2 -2
  94. package/server/{legacy-tldr-cleanup-DJX9V9s4.js → legacy-tldr-cleanup-RqGuveuz.js} +1 -1
  95. package/server/{lifecycle-BT3aegwk.js → lifecycle-BHcU1hPs.js} +4 -4
  96. package/server/{linear-mcp-auth-ChV8Aqu4.js → linear-mcp-auth-C0qzNK0H.js} +1 -1
  97. package/server/{linear-mcp-auth-COqdLkXb.js → linear-mcp-auth-JIDCfEz0.js} +3 -3
  98. package/server/{memory-governor-BQg4GOEF.js → memory-governor-C3T769G6.js} +6 -6
  99. package/server/{merge-BS-9EAg0.js → merge-DaJul9Xt.js} +1 -1
  100. package/server/{merge-agent-CVjeg02H.js → merge-agent-C2UtoeTe.js} +1 -1
  101. package/server/{merge-agent-CkEA7spe.js → merge-agent-CCs-JQhC.js} +10 -10
  102. package/server/{merge-batch-CSWibuAl.js → merge-batch-BBxSLbaz.js} +1 -1
  103. package/server/merge-gate-3O9zdlWW.js +2 -0
  104. package/server/{merge-gate-LOtvWv5K.js → merge-gate-D5zTeaC0.js} +2 -2
  105. package/server/merge-ops-BP9-OIjU.js +2 -0
  106. package/server/{merge-ready-set-C0enElWu.js → merge-ready-set-C5TMtdGy.js} +1 -1
  107. package/server/{merge-ready-set-8yRGoXfN.js → merge-ready-set-DlKHumrb.js} +2 -2
  108. package/server/{merge-train-ClvHbVeP.js → merge-train-BOKRD6nt.js} +1 -1
  109. package/server/{merge-train-CfvTn1fw.js → merge-train-Cx7vXfxi.js} +2 -2
  110. package/server/{merge-train-Cee9LY5p.js → merge-train-Dg5cr8mS.js} +19 -19
  111. package/server/{merge-train-deps-BCvx9OJh.js → merge-train-deps-D1MTGotL.js} +3 -3
  112. package/server/messaging-Cbhf7pAu.js +2 -0
  113. package/server/{multipart-parser-Divdcrf4.js → multipart-parser-fgcPeL-R.js} +2 -2
  114. package/server/node_modules/.package-lock.json +1 -1
  115. package/server/package-lock.json +2 -2
  116. package/server/package.json +1 -1
  117. package/server/{pipeline-BxDHIXwk.js → pipeline-CZPx_h0w.js} +1 -1
  118. package/server/pipeline-membership-BbdiZQ2g.js +171 -0
  119. package/server/pipeline-membership-LZVPTNzz.js +2 -0
  120. package/server/{policy-context-De_w57FT.js → policy-context-CYqNhQra.js} +1 -1
  121. package/server/{policy-context-DlF2pBlT.js → policy-context-CebkQTkr.js} +2 -2
  122. package/server/{preemption-BseBG1Lx.js → preemption-D15-OfS-.js} +3 -3
  123. package/server/{prerequisites-report-D4DsEecP.js → prerequisites-report-BpRfGeIQ.js} +3 -3
  124. package/server/{project-pipelines-BV_6EeMm.js → project-pipelines-C0eawMQd.js} +1 -1
  125. package/server/{project-resource-refresh-queue-Dsha4mgg.js → project-resource-refresh-queue-DmNcMWIW.js} +1 -1
  126. package/server/{project-resource-refresh-queue-BD7xaiwB.js → project-resource-refresh-queue-Dx1QPkGs.js} +13 -173
  127. package/server/public/assets/{abnfDiagram-VCTEODGH-a5JXGj2O.js → abnfDiagram-VCTEODGH-Bkh8Qhhf.js} +1 -1
  128. package/server/public/assets/{ar-SA-G6X2FPQ2-DfwESDRS.js → ar-SA-G6X2FPQ2-Duv-fSqg.js} +1 -1
  129. package/server/public/assets/{architectureDiagram-5GKGNRK7-CNqDlS6j.js → architectureDiagram-5GKGNRK7-vm7gsvBp.js} +1 -1
  130. package/server/public/assets/{az-AZ-76LH7QW2-DcXSBniP.js → az-AZ-76LH7QW2-CqalVsAI.js} +1 -1
  131. package/server/public/assets/{bg-BG-XCXSNQG7-C9L0gaeE.js → bg-BG-XCXSNQG7-KojQTSIf.js} +1 -1
  132. package/server/public/assets/{bn-BD-2XOGV67Q-B53MN52O.js → bn-BD-2XOGV67Q-CGLJg39W.js} +1 -1
  133. package/server/public/assets/{ca-ES-6MX7JW3Y-BTZPNvIz.js → ca-ES-6MX7JW3Y-BG9DUCtc.js} +1 -1
  134. package/server/public/assets/{chunk-EIO257PC-S1ZezR1y.js → chunk-EIO257PC-vUssjuTB.js} +1 -1
  135. package/server/public/assets/{chunk-IMKFNOWR-CFhbID1F.js → chunk-IMKFNOWR-Dy5lrR0k.js} +1 -1
  136. package/server/public/assets/{chunk-SHT3W25Y-vRJiIXR_.js → chunk-SHT3W25Y-B1Ej75VE.js} +1 -1
  137. package/server/public/assets/{chunk-SVP7TREG-D-Pw_X2t.js → chunk-SVP7TREG-BBLmHGKS.js} +1 -1
  138. package/server/public/assets/{chunk-TICWLB2K-DzeVkrx_.js → chunk-TICWLB2K-BYF1_eFX.js} +1 -1
  139. package/server/public/assets/{classDiagram-ZZMXUADV-BYD5DQer.js → classDiagram-ZZMXUADV-BFooIsVI.js} +1 -1
  140. package/server/public/assets/{classDiagram-v2-VYDZK3BY-BYD5DQer.js → classDiagram-v2-VYDZK3BY-BFooIsVI.js} +1 -1
  141. package/server/public/assets/{cs-CZ-2BRQDIVT-CNtIRKDO.js → cs-CZ-2BRQDIVT-B7KdIXZX.js} +1 -1
  142. package/server/public/assets/{cynefinDiagram-5FMLGOSQ-BdxptoBH.js → cynefinDiagram-5FMLGOSQ-B74BPf3L.js} +1 -1
  143. package/server/public/assets/{da-DK-5WZEPLOC-CFH9B_XA.js → da-DK-5WZEPLOC-D4z-FQo3.js} +1 -1
  144. package/server/public/assets/{dagre-GXQ25YYZ-8A4ks-g0.js → dagre-GXQ25YYZ-CzGQ9RBh.js} +1 -1
  145. package/server/public/assets/{de-DE-XR44H4JA-SSAwqM2T.js → de-DE-XR44H4JA-BLHcSSpk.js} +1 -1
  146. package/server/public/assets/{diagram-S7CK7UJ4-BiEABFvq.js → diagram-S7CK7UJ4-BLVIehtN.js} +1 -1
  147. package/server/public/assets/{diagram-UQ7AKVKN-CbAQm8rt.js → diagram-UQ7AKVKN-CWBxQLwX.js} +1 -1
  148. package/server/public/assets/{diagram-VX7I27RA-CX6cTJ6m.js → diagram-VX7I27RA-D-nhHjqI.js} +1 -1
  149. package/server/public/assets/{diagram-Z3DM3KII-CUJMn-73.js → diagram-Z3DM3KII-t-PkDqPd.js} +1 -1
  150. package/server/public/assets/{dist-DB46JHIp.js → dist-7NqkUyWp.js} +4 -4
  151. package/server/public/assets/{ebnfDiagram-PWID7BFC-vIgmpIpC.js → ebnfDiagram-PWID7BFC-BqLhIpq3.js} +1 -1
  152. package/server/public/assets/{el-GR-BZB4AONW-CEWaQ14U.js → el-GR-BZB4AONW-CpB4PJtL.js} +1 -1
  153. package/server/public/assets/{en-B4ZKOASM-DPbmc81o.js → en-B4ZKOASM-BokeIfhD.js} +1 -1
  154. package/server/public/assets/{erDiagram-RLTQ6QDP-Bx76fbpv.js → erDiagram-RLTQ6QDP-CwsmK2oF.js} +1 -1
  155. package/server/public/assets/{es-ES-U4NZUMDT-D98PwSTw.js → es-ES-U4NZUMDT-7pdvQy8R.js} +1 -1
  156. package/server/public/assets/{eu-ES-A7QVB2H4-Covb8Ol-.js → eu-ES-A7QVB2H4-BvMoCige.js} +1 -1
  157. package/server/public/assets/{fa-IR-HGAKTJCU-Dtd-fEqq.js → fa-IR-HGAKTJCU-oqb9ngcA.js} +1 -1
  158. package/server/public/assets/{fi-FI-Z5N7JZ37-hfxveRFy.js → fi-FI-Z5N7JZ37-BWCKhxHc.js} +1 -1
  159. package/server/public/assets/{flowDiagram-HODETNUW-DfUL9mV5.js → flowDiagram-HODETNUW-BFLMpZi8.js} +1 -1
  160. package/server/public/assets/{fr-FR-RHASNOE6-SFarC5-9.js → fr-FR-RHASNOE6-lIqYd1Kh.js} +1 -1
  161. package/server/public/assets/{ganttDiagram-EL5Y4UJY-BWhqn10r.js → ganttDiagram-EL5Y4UJY-_hCoOnvJ.js} +1 -1
  162. package/server/public/assets/{gl-ES-HMX3MZ6V-B5E2hTiL.js → gl-ES-HMX3MZ6V-BuMMBxGa.js} +1 -1
  163. package/server/public/assets/{he-IL-6SHJWFNN-CtPUdyTg.js → he-IL-6SHJWFNN-CASskgj6.js} +1 -1
  164. package/server/public/assets/{hi-IN-IWLTKZ5I-Dno5smSQ.js → hi-IN-IWLTKZ5I-V8xvo9N_.js} +1 -1
  165. package/server/public/assets/{hu-HU-A5ZG7DT2-6fM9o4Vm.js → hu-HU-A5ZG7DT2-Dwz2tW9D.js} +1 -1
  166. package/server/public/assets/{id-ID-SAP4L64H-DqHxJ0od.js → id-ID-SAP4L64H-CsAKnonA.js} +1 -1
  167. package/server/public/assets/image-GAAHSSAO-DlRrB5ro.js +1 -0
  168. package/server/public/assets/{index-BAHYSdai.js → index-uxuGUUZm.js} +9 -9
  169. package/server/public/assets/{infoDiagram-27XIBGKW-B6REiikV.js → infoDiagram-27XIBGKW-Bq35vHxL.js} +1 -1
  170. package/server/public/assets/{ishikawaDiagram-5VMMS53U-CJ4FcDTi.js → ishikawaDiagram-5VMMS53U-BP8VkFPc.js} +1 -1
  171. package/server/public/assets/{it-IT-JPQ66NNP-COf0Mlpu.js → it-IT-JPQ66NNP-yPqYjuhl.js} +1 -1
  172. package/server/public/assets/{ja-JP-DBVTYXUO-CnmSZoYJ.js → ja-JP-DBVTYXUO-SIGkDKhH.js} +1 -1
  173. package/server/public/assets/{kaa-6HZHGXH3-psdaC7_Y.js → kaa-6HZHGXH3-DxnCb5Kc.js} +1 -1
  174. package/server/public/assets/{kab-KAB-ZGHBKWFO-DHcsec5D.js → kab-KAB-ZGHBKWFO-CVCxey_p.js} +1 -1
  175. package/server/public/assets/{kanban-definition-UXKFOSKX-CWOzrzwB.js → kanban-definition-UXKFOSKX-Cj2TVfn0.js} +1 -1
  176. package/server/public/assets/{kk-KZ-P5N5QNE5-ChxI9E6E.js → kk-KZ-P5N5QNE5-M9YAeME3.js} +1 -1
  177. package/server/public/assets/{km-KH-HSX4SM5Z-B75b52bE.js → km-KH-HSX4SM5Z-D3AhWnhV.js} +1 -1
  178. package/server/public/assets/{ko-KR-MTYHY66A-DS6CvLDO.js → ko-KR-MTYHY66A-Or_gIXhD.js} +1 -1
  179. package/server/public/assets/{ku-TR-6OUDTVRD-BS6Z0LpR.js → ku-TR-6OUDTVRD-DzxrabDk.js} +1 -1
  180. package/server/public/assets/{linear-DI0By7Db.js → linear-gEGsxSj1.js} +1 -1
  181. package/server/public/assets/{lt-LT-XHIRWOB4-DB6tYnhK.js → lt-LT-XHIRWOB4-_nyDG8BQ.js} +1 -1
  182. package/server/public/assets/{lv-LV-5QDEKY6T-Gz9wx9bk.js → lv-LV-5QDEKY6T-BuFYWU7T.js} +1 -1
  183. package/server/public/assets/{mindmap-definition-YA3MSWOX-CoXi3FPw.js → mindmap-definition-YA3MSWOX-D1eSwBX7.js} +1 -1
  184. package/server/public/assets/{mr-IN-CRQNXWMA-DmdIEQlN.js → mr-IN-CRQNXWMA-DYDxiULS.js} +1 -1
  185. package/server/public/assets/{my-MM-5M5IBNSE-CEZvJNBx.js → my-MM-5M5IBNSE-CESrtCUE.js} +1 -1
  186. package/server/public/assets/{nb-NO-T6EIAALU-CE-qhpnk.js → nb-NO-T6EIAALU-D89JFLrD.js} +1 -1
  187. package/server/public/assets/{nl-NL-IS3SIHDZ-CKhfMYRs.js → nl-NL-IS3SIHDZ-B5fTIJ0f.js} +1 -1
  188. package/server/public/assets/{nn-NO-6E72VCQL-_Q0hO_YM.js → nn-NO-6E72VCQL-BlZxpLDl.js} +1 -1
  189. package/server/public/assets/{oc-FR-POXYY2M6-BP_GWpdw.js → oc-FR-POXYY2M6-c2a5nnpF.js} +1 -1
  190. package/server/public/assets/{pa-IN-N4M65BXN-ImDjqKw6.js → pa-IN-N4M65BXN-DV1xiyB6.js} +1 -1
  191. package/server/public/assets/{pegDiagram-XKGWAZYB-D1tXITHn.js → pegDiagram-XKGWAZYB-BVNV8u8v.js} +1 -1
  192. package/server/public/assets/percentages-BXMCSKIN-CCSzzLCW.js +1 -0
  193. package/server/public/assets/{pieDiagram-E7YTZNPT-DNCuFpai.js → pieDiagram-E7YTZNPT-DgQFaD11.js} +1 -1
  194. package/server/public/assets/{pl-PL-T2D74RX3-yCxLpvKz.js → pl-PL-T2D74RX3-BYEPnwpR.js} +1 -1
  195. package/server/public/assets/{prod-DsNBMWxO.js → prod-DWloE-Tf.js} +7 -7
  196. package/server/public/assets/{pt-BR-5N22H2LF-CqNEOY9w.js → pt-BR-5N22H2LF-VzuifI42.js} +1 -1
  197. package/server/public/assets/{pt-PT-UZXXM6DQ-DBw4f0lS.js → pt-PT-UZXXM6DQ-Grmv30e9.js} +1 -1
  198. package/server/public/assets/{quadrantDiagram-AXDQQJYC-Bci1oSYb.js → quadrantDiagram-AXDQQJYC-431IKFV-.js} +1 -1
  199. package/server/public/assets/{railroadDiagram-O6MQD6OU-ikFAVJUY.js → railroadDiagram-O6MQD6OU-Borx2fG3.js} +1 -1
  200. package/server/public/assets/{requirementDiagram-BXWQKSXE-DKTszgVJ.js → requirementDiagram-BXWQKSXE-B_ifxbXC.js} +1 -1
  201. package/server/public/assets/{ro-RO-JPDTUUEW-BqgARQks.js → ro-RO-JPDTUUEW-BCcW97bo.js} +1 -1
  202. package/server/public/assets/{ru-RU-B4JR7IUQ-Q6Ic_n8I.js → ru-RU-B4JR7IUQ-jud8t1VI.js} +1 -1
  203. package/server/public/assets/{sankeyDiagram-P5KCCOFB-DWatmen5.js → sankeyDiagram-P5KCCOFB-BLpv-ZD0.js} +1 -1
  204. package/server/public/assets/{sequenceDiagram-WJ2MYXX4-J7gSm17h.js → sequenceDiagram-WJ2MYXX4-DAtQj3zB.js} +1 -1
  205. package/server/public/assets/{si-LK-N5RQ5JYF-ZVr3vkVm.js → si-LK-N5RQ5JYF-CslAaa-5.js} +1 -1
  206. package/server/public/assets/{sk-SK-C5VTKIMK-BSQsNJSS.js → sk-SK-C5VTKIMK-C9NvC7DU.js} +1 -1
  207. package/server/public/assets/{sl-SI-NN7IZMDC-CP8Z1otw.js → sl-SI-NN7IZMDC-Cy3n7hfM.js} +1 -1
  208. package/server/public/assets/{stateDiagram-D77RDMKH-yMPWEYtq.js → stateDiagram-D77RDMKH-oH2hEoN4.js} +1 -1
  209. package/server/public/assets/{stateDiagram-v2-MP3YSRHH-F5EGnPR_.js → stateDiagram-v2-MP3YSRHH-CIbAgOVy.js} +1 -1
  210. package/server/public/assets/subset-shared.chunk-Dba6DKdi.js +1 -0
  211. package/server/public/assets/{subset-worker.chunk-LpMaC50m.js → subset-worker.chunk-D5tg61BR.js} +1 -1
  212. package/server/public/assets/{sv-SE-XGPEYMSR-D8mOTDra.js → sv-SE-XGPEYMSR-DYf-SlR7.js} +1 -1
  213. package/server/public/assets/{swimlanes-42K2YHIH-JPQx_4qn.js → swimlanes-42K2YHIH-Do3SoYnq.js} +1 -1
  214. package/server/public/assets/{swimlanesDiagram-VR7AAH4N-CtNlg2el.js → swimlanesDiagram-VR7AAH4N-BYc814ml.js} +1 -1
  215. package/server/public/assets/{ta-IN-2NMHFXQM-ih9dhd8j.js → ta-IN-2NMHFXQM-iGF2eo5t.js} +1 -1
  216. package/server/public/assets/{th-TH-HPSO5L25-BhmRG3ne.js → th-TH-HPSO5L25-CGfN7mnR.js} +1 -1
  217. package/server/public/assets/{timeline-definition-24CTP7MA-lLCs5kg1.js → timeline-definition-24CTP7MA-DUI_xi15.js} +1 -1
  218. package/server/public/assets/{tr-TR-DEFEU3FU-B5teU_eL.js → tr-TR-DEFEU3FU-C1btuwU_.js} +1 -1
  219. package/server/public/assets/{uk-UA-QMV73CPH-CsUaR7s6.js → uk-UA-QMV73CPH-DLoTLQOx.js} +1 -1
  220. package/server/public/assets/{vennDiagram-4TSXK5OY-CsO1kQiW.js → vennDiagram-4TSXK5OY-DioINyLf.js} +1 -1
  221. package/server/public/assets/{vi-VN-M7AON7JQ-qfVnGZto.js → vi-VN-M7AON7JQ-CBwbwrm4.js} +1 -1
  222. package/server/public/assets/{wardleyDiagram-VM6X3IG4-C2ajkJrW.js → wardleyDiagram-VM6X3IG4-gd0gikXq.js} +1 -1
  223. package/server/public/assets/{xychartDiagram-S5SC5T6Z-oJOShKfW.js → xychartDiagram-S5SC5T6Z-Bx86zaAl.js} +1 -1
  224. package/server/public/assets/{zh-CN-LNUGB5OW-vDDEdkjv.js → zh-CN-LNUGB5OW-BcRNKoOf.js} +1 -1
  225. package/server/public/assets/{zh-HK-E62DVLB3-Fcvngm0F.js → zh-HK-E62DVLB3-Cu_ESPq6.js} +1 -1
  226. package/server/public/assets/{zh-TW-RAJ6MFWO-BCuionzc.js → zh-TW-RAJ6MFWO-CHnOC09j.js} +1 -1
  227. package/server/public/index.html +1 -1
  228. package/server/queries-qqOXiaNr.js +2 -0
  229. package/server/{ready-timeout-failure-C45bsjI2.js → ready-timeout-failure-BwzL5OKo.js} +2 -2
  230. package/server/{rebuild-stack-uaOTI93a.js → rebuild-stack-BtpTM6VR.js} +3 -3
  231. package/server/rebuild-stack-FjChJ9yi.js +3 -0
  232. package/server/{release-engine-C5d610mi.js → release-engine-Y29fEWE7.js} +2 -2
  233. package/server/{release-set-BFsZCA0J.js → release-set-BacZ1N_f.js} +1 -1
  234. package/server/{remote-xutkDygz.js → remote-BUaz6B3t.js} +2 -2
  235. package/server/{remote-qoNG2iir.js → remote-Day75qqe.js} +2 -2
  236. package/server/{remote-agents-CJYoW12q.js → remote-agents-BlqgB9dc.js} +1 -1
  237. package/server/{remote-agents-9UKtOTeT.js → remote-agents-D6G8Z0T_.js} +3 -3
  238. package/server/{requirements-tNHrKKgl.js → requirements-DM6TvCsN.js} +1 -1
  239. package/server/{requirements-COv0qjkH.js → requirements-GXRVCopE.js} +1 -1
  240. package/server/{resolver-Did8ZX_j.js → resolver-D6SskqKx.js} +1 -1
  241. package/server/{resolver-CAP4HecA.js → resolver-TNBoD1Lh.js} +2 -2
  242. package/server/resume-BvqNBf96.js +2 -0
  243. package/server/{review-agent-C6_zRhE-.js → review-agent-BS5R2OP1.js} +17 -17
  244. package/server/{review-agent-CTNzg6ag.js → review-agent-D7b3qt2U.js} +2 -2
  245. package/server/{review-artifacts-DFXkCDKn.js → review-artifacts-CwnJeObv.js} +2 -2
  246. package/server/{review-context-2LAh97tE.js → review-context-BXW1m3vK.js} +1 -1
  247. package/server/{review-convoy-BE7hwRKU.js → review-convoy-7EL6lofH.js} +9 -9
  248. package/server/{review-convoy-D4ddjcsE.js → review-convoy-BNYVD3y4.js} +1 -1
  249. package/server/{review-monitor-BRSWLITW.js → review-monitor-BoxMGLwm.js} +1 -1
  250. package/server/{review-request-route-fgWQMyrT.js → review-request-route-CMR7xtJK.js} +2 -2
  251. package/server/{review-rounds-wYEYRB2e.js → review-rounds-BrPtQK9g.js} +1 -1
  252. package/server/{review-rounds-C8S_nYSs.js → review-rounds-CcXAeFDu.js} +1 -1
  253. package/server/{review-synthesis-recovery-DKnQIwwI.js → review-synthesis-recovery-BVuPGjZM.js} +7 -7
  254. package/server/{review-verdict-feedback-CGHG6ZkU.js → review-verdict-feedback-Blt-Rdbt.js} +5 -5
  255. package/server/{rollup-Bm6X7jIb.js → rollup-8hDNviZE.js} +2 -2
  256. package/server/{rollup-C9m7LkEy.js → rollup-Cf7vF55-.js} +1 -1
  257. package/server/{runtime-command-D0JVmWKZ.js → runtime-command-0C3oTZGN.js} +5 -5
  258. package/server/runtime-command-D91mhWSL.js +2 -0
  259. package/server/runtimes-B7zJfZXo.js +6 -0
  260. package/server/{runtimes-DUvSjnkK.js → runtimes-CiPufB1e.js} +9 -9
  261. package/server/{sequencer-agent-BGwo_hJY.js → sequencer-agent-C_RaZl3z.js} +4 -4
  262. package/server/server.js +164 -249
  263. package/server/{service-DKHnfIwb.js → service-Bn8Zn0WW.js} +36 -36
  264. package/server/{session-fork-CaUxe-sI.js → session-fork-CKpcJBY3.js} +1 -1
  265. package/server/{settings-5VVqbwVL.js → settings-DNxbkedU.js} +1 -1
  266. package/server/settings-DeJQpBJZ.js +2 -0
  267. package/server/{ship-log-CfuRUZaI.js → ship-log-DhPEIcrG.js} +1 -1
  268. package/server/{ship-log-CRk1pL0V.js → ship-log-Di-_dljC.js} +1 -1
  269. package/server/{smart-compaction-BA2YGYS7.js → smart-compaction-CVIjvKaC.js} +2 -2
  270. package/server/{smart-compaction-ni-rHctf.js → smart-compaction-mz6E9fph.js} +1 -1
  271. package/server/{spawn-planning-session-Dp2FsjWk.js → spawn-planning-session-D9vDkQVz.js} +2 -2
  272. package/server/{spawn-planning-session-38jno6va.js → spawn-planning-session-DEr2g-vN.js} +9 -9
  273. package/server/{specialist-completion-DfoJQPHz.js → specialist-completion-ThQ5mCYp.js} +1 -1
  274. package/server/{specialists-DCUqID3m.js → specialists--u4Nwkwy.js} +1 -1
  275. package/server/{specialists-DPjE2JBt.js → specialists-BsiHHXL7.js} +51 -51
  276. package/server/{specialists-Dhqnld3A.js → specialists-C5WxILVV.js} +9 -9
  277. package/server/{specialists-BOMH7wlq.js → specialists-ChpiIuS7.js} +1 -1
  278. package/server/{src-DEWY9s_G.js → src-Bjf3_TJI.js} +7 -7
  279. package/server/{src-CUtp-SJF.js → src-Dc_h_m1_.js} +3 -3
  280. package/server/{strike-completion-OPcaVqFd.js → strike-completion-CIQA9E-C.js} +2 -2
  281. package/server/strike-completion-PiFiEtoo.js +2 -0
  282. package/server/{subagents-DNw4YyMa.js → subagents-P7wfucdb.js} +2 -2
  283. package/server/{substrate-stats-DuuksQHp.js → substrate-stats-0PCKLsMv.js} +18 -18
  284. package/server/summary-fork--LXvyQuT.js +3 -0
  285. package/server/{summary-fork-BfuGi-S2.js → summary-fork-DQGtPP_x.js} +5 -5
  286. package/server/supervisor-DRm9uLsZ.js +2 -0
  287. package/server/{supervisor-CWskvoz3.js → supervisor-De-GYL91.js} +1 -1
  288. package/server/{sync-startup-gate-Cz-taE5H.js → sync-startup-gate-BfacT-bh.js} +1 -1
  289. package/server/{system-health-service-7C9fafx7.js → system-health-service-CjdWgKic.js} +3 -3
  290. package/server/{system-health-service-SB_Kjxqf.js → system-health-service-Cqpct_Qo.js} +1 -1
  291. package/server/{system-prerequisites-N5usDkOl.js → system-prerequisites-Caf37eBm.js} +2 -2
  292. package/server/{system-prerequisites-CJzu1FQH.js → system-prerequisites-G9se0Lms.js} +1 -1
  293. package/server/{teardown-workspace-BOnPHDQi.js → teardown-workspace-Dvwa4r5M.js} +7 -7
  294. package/server/termination-DYiDx_bB.js +2 -0
  295. package/server/{test-agent-queue-D3koTErW.js → test-agent-queue-BZ57BL-z.js} +3 -3
  296. package/server/{test-verdict-DcQHIB36.js → test-verdict-DoCOnudE.js} +1 -1
  297. package/server/{test-verdict-D5MJ__S5.js → test-verdict-XI4egwYk.js} +1 -1
  298. package/server/{token-BXOsGOq0.js → token-BVSQ0ZbH.js} +1 -1
  299. package/server/{transcript-turn-DxkkFudJ.js → transcript-turn-yL1_qVmT.js} +1 -1
  300. package/server/{types-D4H9A_IK.js → types-8Bdo_m9Z.js} +1 -1
  301. package/server/{uat-train-qJFsN-X4.js → uat-train-BI6lNv6X.js} +11 -11
  302. package/server/{uat-train-C3g4eTwu.js → uat-train-BqMuW417.js} +1 -1
  303. package/server/{validation-BX4n3p5b.js → validation-B0CMIi5c.js} +2 -2
  304. package/server/{validation-C1j7--xs.js → validation-UgpT2GVW.js} +1 -1
  305. package/server/{verification-escalation-BOuG6ixX.js → verification-escalation-8_JfF7-z.js} +3 -3
  306. package/server/{verification-escalation-C76ZbMod.js → verification-escalation-DAjaXHwo.js} +1 -1
  307. package/server/{verification-runner-BMtIaVjU.js → verification-runner-D0DG7ixm.js} +10 -10
  308. package/server/{verification-runner-C-sxcxTO.js → verification-runner-D8-ijYmm.js} +2 -2
  309. package/server/{vtt-parser-DSX4wASE.js → vtt-parser-uNggfu87.js} +1 -1
  310. package/server/{work-agent-prompt-p9ir8Hid.js → work-agent-prompt-BNUi27LZ.js} +2 -2
  311. package/server/workflows-Dr-Yo76E.js +2 -0
  312. package/server/{workflows-DzA62y5W.js → workflows-kIv_z7zJ.js} +8 -8
  313. package/server/{workspace-manager-Nljndsty.js → workspace-manager-D0auAuId.js} +2 -2
  314. package/server/{workspace-manager-yEOe-AK7.js → workspace-manager-t2ylzCn0.js} +2 -2
  315. package/server/{workspaces-DVWUbrua.js → workspaces-C7sOgLNZ.js} +42 -42
  316. package/server/{worktree-ops-BvwkJJ--.js → worktree-ops-Cenxxhk2.js} +1 -1
  317. package/server/{worktree-ops-DzDaxzI6.js → worktree-ops-D_IXGBtP.js} +8 -8
  318. package/server/activity-H6Jf6jYF.js +0 -2
  319. package/server/agent-pane-io-BmNbvGUo.js +0 -2
  320. package/server/archive-planning-BJck5ngN.js +0 -2
  321. package/server/cli-DVDU4QF2.js +0 -2
  322. package/server/daemon-CWmWlc4E.js +0 -2
  323. package/server/dist-BGSAS-U9.js +0 -3
  324. package/server/ensure-devcontainer-C_OTsIz6.js +0 -2
  325. package/server/evict-CgFggY65.js +0 -2
  326. package/server/harness-binary-CF3OHJwR.js +0 -2
  327. package/server/merge-gate-Bq6XDCW9.js +0 -2
  328. package/server/merge-ops-C2DJ5UJh.js +0 -2
  329. package/server/messaging-CKpa4quh.js +0 -2
  330. package/server/public/assets/image-GAAHSSAO-CFdI_QVJ.js +0 -1
  331. package/server/public/assets/percentages-BXMCSKIN-BzJ4SOUv.js +0 -1
  332. package/server/public/assets/subset-shared.chunk-Crnl6u-o.js +0 -1
  333. package/server/queries-XNzQnDjP.js +0 -2
  334. package/server/rebuild-stack-CJBh6Pa6.js +0 -3
  335. package/server/resume-BRxpAyj3.js +0 -2
  336. package/server/runtime-command-BkQQs0N2.js +0 -2
  337. package/server/runtimes-D68npgJJ.js +0 -6
  338. package/server/settings-CFLNK2bY.js +0 -2
  339. package/server/strike-completion-DyPF_uhD.js +0 -2
  340. package/server/summary-fork-Dm46AXqo.js +0 -3
  341. package/server/supervisor-daYV0xlI.js +0 -2
  342. package/server/termination-DTOwIt3S.js +0 -2
  343. package/server/workflows-Dp8qhcha.js +0 -2
  344. /package/server/{merge-rebase-Cf3Dr76u.js → merge-rebase-D1nUZmH_.js} +0 -0
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-CWQ4byU-.js","assets/chunk-BO2N2NFS-BhwfcR9y.js","assets/rolldown-runtime-C0FnF6B9.js","assets/jsx-runtime-DSr1VPkp.js","assets/react-dom-DDW_C3zj.js","assets/clsx-9mC1utHq.js","assets/html-void-elements-DKER9wWT.js","assets/preload-helper-BZ1Pz5am.js","assets/styles-DkK0ymA2.css","assets/angular-html-cDdt99o9.js","assets/html-CnSmHL-e.js","assets/javascript-B3ZoUvGD.js","assets/css-DHP299pV.js","assets/angular-ts-6irXudWm.js","assets/scss-B7HLuD1K.js","assets/apl-B8d8Vz5e.js","assets/xml-BgwO9svv.js","assets/java-CCLYh7Ws.js","assets/json-DYyUca0x.js","assets/astro-Bg_Wz6Z2.js","assets/typescript-ITQieXu3.js","assets/postcss-BXeXVLqQ.js","assets/tsx-D0-aSICp.js","assets/blade-r67qM8DN.js","assets/html-derivative-DJ4gxBQC.js","assets/sql-BAPossRw.js","assets/bsl-BkkzgIyY.js","assets/sdbl-bTVj8UrX.js","assets/c-mSN2GbH4.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/cobol-BWrJmEve.js","assets/coffee-C17FjuDx.js","assets/cpp-DuLqMNGY.js","assets/regexp-723CALth.js","assets/glsl-C3yOxx6A.js","assets/crystal-DItxLjbf.js","assets/shellscript-DoDh9O3W.js","assets/edge-hRXDlD2t.js","assets/elixir-oZZERfp2.js","assets/elm-D_TZK0Oc.js","assets/erb-BqbaQSzs.js","assets/ruby-dl7o7a85.js","assets/haml-D8bc4mST.js","assets/graphql-DlruBr94.js","assets/jsx-Cb6Vub3Y.js","assets/lua-tuq8Rev2.js","assets/yaml-BnkSoqfe.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-C0sCabJj.js","assets/gdshader-CBce3t8t.js","assets/gdscript-Cp2uCuqX.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-CuqI2PUc.js","assets/glimmer-js-BEliQnII.js","assets/glimmer-ts-COGUPgS1.js","assets/hack-DaHVb6ft.js","assets/handlebars-DqwzwOTk.js","assets/http-Dy2ncae7.js","assets/hurl-Cb5XgwOM.js","assets/csv-Dx-8-gkx.js","assets/hxml-B0Qn7Nwc.js","assets/haxe-OTjmBuCE.js","assets/jinja-BGGFsaqr.js","assets/jison-C7uQeUlv.js","assets/julia-BWHbVzQy.js","assets/r-yAZWIVFP.js","assets/just-wi8yPAJS.js","assets/perl-CrwHgQCL.js","assets/latex-DElmv1zH.js","assets/tex-DgW53hUi.js","assets/liquid-DAik6A0c.js","assets/marko-d0Yv3Yj_.js","assets/less-DVTAwKKz.js","assets/mdc-COIjL5tp.js","assets/nextflow-Bbiyy34d.js","assets/nextflow-groovy-Dc_ddanL.js","assets/nginx-nAXs0UmH.js","assets/nim-DVG0-ig8.js","assets/php-A_l-HRpS.js","assets/pug-CbTch1oj.js","assets/qml-DaaPxMrD.js","assets/razor-CWjPPkfn.js","assets/csharp-Ct8U2NOr.js","assets/rst-EKFmAutQ.js","assets/cmake-Bj61d0ZC.js","assets/sas-CnHIAVlE.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-DYrWla-w.js","assets/soy-DPLowEo3.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-uikMS13-.js","assets/surrealql-Dg_RLHhg.js","assets/svelte-C3pZB89g.js","assets/templ-BDPwZuN2.js","assets/go-BJwz_mda.js","assets/ts-tags-B7JG1dII.js","assets/twig-MNumDvuo.js","assets/vue-DMyn4zP-.js","assets/vue-html-d0F-gcUX.js","assets/vue-vine-RX8vlWVe.js","assets/stylus-B6D30XZt.js","assets/xsl-Ci-Eh2uW.js","assets/PlanMapViewer-C2My95rb.js","assets/esm-CS-GuPAr.js","assets/prod-DsNBMWxO.js","assets/Combination-CAD5_Cio.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-CWQ4byU-.js","assets/chunk-BO2N2NFS-BhwfcR9y.js","assets/rolldown-runtime-C0FnF6B9.js","assets/jsx-runtime-DSr1VPkp.js","assets/react-dom-DDW_C3zj.js","assets/clsx-9mC1utHq.js","assets/html-void-elements-DKER9wWT.js","assets/preload-helper-BZ1Pz5am.js","assets/styles-DkK0ymA2.css","assets/angular-html-cDdt99o9.js","assets/html-CnSmHL-e.js","assets/javascript-B3ZoUvGD.js","assets/css-DHP299pV.js","assets/angular-ts-6irXudWm.js","assets/scss-B7HLuD1K.js","assets/apl-B8d8Vz5e.js","assets/xml-BgwO9svv.js","assets/java-CCLYh7Ws.js","assets/json-DYyUca0x.js","assets/astro-Bg_Wz6Z2.js","assets/typescript-ITQieXu3.js","assets/postcss-BXeXVLqQ.js","assets/tsx-D0-aSICp.js","assets/blade-r67qM8DN.js","assets/html-derivative-DJ4gxBQC.js","assets/sql-BAPossRw.js","assets/bsl-BkkzgIyY.js","assets/sdbl-bTVj8UrX.js","assets/c-mSN2GbH4.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/cobol-BWrJmEve.js","assets/coffee-C17FjuDx.js","assets/cpp-DuLqMNGY.js","assets/regexp-723CALth.js","assets/glsl-C3yOxx6A.js","assets/crystal-DItxLjbf.js","assets/shellscript-DoDh9O3W.js","assets/edge-hRXDlD2t.js","assets/elixir-oZZERfp2.js","assets/elm-D_TZK0Oc.js","assets/erb-BqbaQSzs.js","assets/ruby-dl7o7a85.js","assets/haml-D8bc4mST.js","assets/graphql-DlruBr94.js","assets/jsx-Cb6Vub3Y.js","assets/lua-tuq8Rev2.js","assets/yaml-BnkSoqfe.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-C0sCabJj.js","assets/gdshader-CBce3t8t.js","assets/gdscript-Cp2uCuqX.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-CuqI2PUc.js","assets/glimmer-js-BEliQnII.js","assets/glimmer-ts-COGUPgS1.js","assets/hack-DaHVb6ft.js","assets/handlebars-DqwzwOTk.js","assets/http-Dy2ncae7.js","assets/hurl-Cb5XgwOM.js","assets/csv-Dx-8-gkx.js","assets/hxml-B0Qn7Nwc.js","assets/haxe-OTjmBuCE.js","assets/jinja-BGGFsaqr.js","assets/jison-C7uQeUlv.js","assets/julia-BWHbVzQy.js","assets/r-yAZWIVFP.js","assets/just-wi8yPAJS.js","assets/perl-CrwHgQCL.js","assets/latex-DElmv1zH.js","assets/tex-DgW53hUi.js","assets/liquid-DAik6A0c.js","assets/marko-d0Yv3Yj_.js","assets/less-DVTAwKKz.js","assets/mdc-COIjL5tp.js","assets/nextflow-Bbiyy34d.js","assets/nextflow-groovy-Dc_ddanL.js","assets/nginx-nAXs0UmH.js","assets/nim-DVG0-ig8.js","assets/php-A_l-HRpS.js","assets/pug-CbTch1oj.js","assets/qml-DaaPxMrD.js","assets/razor-CWjPPkfn.js","assets/csharp-Ct8U2NOr.js","assets/rst-EKFmAutQ.js","assets/cmake-Bj61d0ZC.js","assets/sas-CnHIAVlE.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-DYrWla-w.js","assets/soy-DPLowEo3.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-uikMS13-.js","assets/surrealql-Dg_RLHhg.js","assets/svelte-C3pZB89g.js","assets/templ-BDPwZuN2.js","assets/go-BJwz_mda.js","assets/ts-tags-B7JG1dII.js","assets/twig-MNumDvuo.js","assets/vue-DMyn4zP-.js","assets/vue-html-d0F-gcUX.js","assets/vue-vine-RX8vlWVe.js","assets/stylus-B6D30XZt.js","assets/xsl-Ci-Eh2uW.js","assets/PlanMapViewer-C2My95rb.js","assets/esm-CS-GuPAr.js","assets/prod-DWloE-Tf.js","assets/Combination-CAD5_Cio.js"])))=>i.map(i=>d[i]);
2
2
  import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-C0FnF6B9.js";import{n as a,t as o}from"./jsx-runtime-DSr1VPkp.js";import{t as s}from"./react-dom-DDW_C3zj.js";import{$ as c,$n as l,$r as u,$t as d,A as f,Ai as p,An as m,Ar as h,At as g,B as _,Bi as v,Bn as y,Br as b,Bt as x,C as S,Ci as C,Cn as w,Cr as T,Ct as E,D,Di as O,Dn as k,Dr as A,Dt as j,E as ee,Ei as M,En as N,Er as P,Et as te,F as ne,Fi as re,Fn as ie,Fr as ae,Ft as oe,G as se,Gi as ce,Gn as le,Gr as ue,Gt as de,H as fe,Hi as pe,Hn as me,Hr as he,Ht as ge,I as _e,Ii as ve,In as ye,Ir as be,It as xe,J as Se,Jn as Ce,Jr as we,Jt as Te,K as Ee,Ki as De,Kn as Oe,Kr as ke,Kt as Ae,L as je,Li as Me,Ln as Ne,Lr as Pe,Lt as Fe,M as Ie,Mi as Le,Mn as Re,Mr as ze,Mt as Be,N as Ve,Ni as He,Nn as Ue,Nr as We,Nt as Ge,O as Ke,Oi as qe,On as Je,Or as Ye,Ot as Xe,P as Ze,Pi as Qe,Pn as $e,Pr as et,Pt as tt,Q as nt,Qn as rt,Qr as it,Qt as at,R as ot,Ri as st,Rn as ct,Rr as lt,Rt as ut,S as dt,Si as ft,Sn as pt,Sr as mt,St as ht,T as gt,Ti as _t,Tn as vt,Tr as yt,Tt as bt,U as xt,Ui as St,Un as Ct,Ur as eee,Ut as wt,V as Tt,Vi as Et,Vn as Dt,Vr as Ot,Vt as kt,W as At,Wi as jt,Wn as Mt,Wr as Nt,Wt as Pt,X as tee,Xn as nee,Xr as ree,Xt as iee,Y as Ft,Yn as aee,Yr as oee,Yt as It,Z as see,Zn as cee,Zr as lee,Zt as uee,_ as Lt,_i as dee,_n as fee,_r as pee,_t as mee,a as hee,ai as gee,an as _ee,ar as vee,at as yee,b as bee,bi as xee,bn as See,br as Cee,bt as wee,c as Tee,ci as Eee,cn as Dee,cr as Oee,ct as kee,d as Aee,di as Rt,dn as jee,dr as Mee,dt as Nee,ei as Pee,en as Fee,er as Iee,et as Lee,f as Ree,fi as zt,fn as zee,fr as Bt,ft as Bee,g as Vee,gi as Hee,gn as Uee,gr as Wee,gt as Vt,h as Gee,hi as Kee,hn as Ht,hr as qee,ht as Ut,i as Jee,ii as Yee,in as Xee,ir as Zee,it as Qee,j as Wt,ji as Gt,jn as $ee,jr as ete,jt as tte,k as nte,ki as rte,kn as ite,kr as ate,kt as ote,l as ste,li as Kt,ln as cte,lr as lte,lt as ute,m as qt,mi as F,mn as dte,mr as fte,mt as pte,ni as mte,nn as hte,nr as gte,nt as _te,o as Jt,oi as Yt,on as vte,or as yte,ot as bte,p as xte,pi as Xt,pn as Zt,pr as Ste,pt as Cte,q as Qt,qi as $t,qn as wte,qr as Tte,qt as en,r as tn,ri as Ete,rn as nn,rr as Dte,rt as rn,s as Ote,si as kte,sn as an,sr as Ate,st as jte,t as Mte,ti as Nte,tn as Pte,tr as Fte,tt as on,u as sn,ui as Ite,un as Lte,ur as Rte,ut as zte,v as Bte,vi as Vte,vn as Hte,vr as Ute,vt as Wte,w as Gte,wi as Kte,wn as qte,wr as Jte,wt as Yte,x as Xte,xi as Zte,xn as Qte,xr as $te,xt as cn,y as ene,yi as tne,yn as nne,yr as rne,yt as ine,z as ane,zi as ln,zn as one,zr as sne,zt as cne}from"./PlanMapViewer-C2My95rb.js";import{n as lne,r as une,t as un}from"./esm-CS-GuPAr.js";import{a as dne,d as fne,f as dn,i as pne,n as fn,o as mne,p as hne,r as gne,s as _ne,t as vne}from"./clsx-9mC1utHq.js";import{a as yne,c as bne,f as xne,n as Sne,o as Cne,r as wne,s as Tne,t as Ene,u as pn}from"./html-void-elements-DKER9wWT.js";import{t as I}from"./preload-helper-BZ1Pz5am.js";import{a as Dne,c as One,d as kne,i as Ane,l as jne,n as Mne,o as Nne,r as Pne,s as Fne,t as Ine,u as Lne}from"./Combination-CAD5_Cio.js";import{C as Rne,E as mn,S as zne,T as hn,a as gn,b as Bne,c as _n,d as Vne,g as vn,h as Hne,i as Une,l as Wne,m as Gne,n as yn,o as Kne,r as qne,s as Jne,t as Yne,u as bn,v as Xne,w as Zne,y as xn}from"./src-C5ud8Oe-.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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Qne=i((e=>{var t=s();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),$ne=class extends Kte{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:M(t,n.data),hasPreviousPage:O(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},ere=class extends qe{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||tre(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=rte({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),Gt.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function tre(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var nre=class extends He{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new ere({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Sn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Sn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Sn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Sn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Gt.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Me(t,e))}findAll(e={}){return this.getAll().filter(t=>Me(e,t))}notify(e){Gt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Gt.batch(()=>Promise.all(e.map(e=>e.continue().catch(ln))))}};function Sn(e){return e.options.scope?.id}var rre=class extends He{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),St(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&re(t.mutationKey)!==re(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??tre();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Gt.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function ire(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var are=class extends He{#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,Gt.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||!St(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(ire(e,n).forEach(e=>{e.destroy()}),ire(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){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(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.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=Et(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||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 Kte(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&Gt.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},ore=class extends He{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??ve(r,t),a=this.get(i);return a||(a=new _t({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){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Gt.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=>st(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>st(e,t)):t}notify(e){Gt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Gt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Gt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},sre=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new ore,this.#t=e.mutationCache||new nre,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Le.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=p.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(pe(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=Qe(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Gt.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;Gt.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Gt.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=Gt.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(ln).catch(ln)}invalidateQueries(e,t={}){return Gt.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=Gt.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(ln)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(ln)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(pe(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(pe(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ln).catch(ln)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ln).catch(ln)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return p.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(re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{v(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(re(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{v(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||=ve(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===ce&&(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()}},L=n(a(),1);function cre({queries:e,...t},n){let r=$t(n),i=C(),a=ft(),o=t.subscribed!==!1,s=L.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:o?`optimistic`:void 0,t}),[e,r,i,o]);s.forEach(e=>{Hee(e);let t=r.getQueryCache().get(e.queryHash);tne(e,a,t)}),Zte(a);let[c]=L.useState(()=>new are(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;L.useSyncExternalStore(L.useCallback(e=>f?c.subscribe(Gt.batchCalls(e)):ln,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),L.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Vte(s[t],e))?l.flatMap((e,t)=>{let n=s[t];if(n&&Vte(n,e)){let e=new Kte(r,n);return dee(n,e,a)}return[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&xee({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m)throw m.error;return u(d())}function lre(e,t){let n=$t(t),r=n.getQueryCache();return L.useSyncExternalStore(L.useCallback(e=>r.subscribe(Gt.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function Cn(e,t){let n=$t(t),[r]=L.useState(()=>new rre(n,e));L.useEffect(()=>{r.setOptions(e)},[r,e]);let i=L.useSyncExternalStore(L.useCallback(e=>r.subscribe(Gt.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=L.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(ln)},[r]);if(i.error&&jt(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function ure(e,t){return Kee(e,$ne,t)}var dre=n(Qne(),1),wn=`u`>typeof window?window:void 0,Tn=`u`>typeof globalThis?globalThis:wn,En=Tn?.navigator,Dn=Tn?.document,On=Tn?.location,kn=Tn?.fetch,fre=Tn?.XMLHttpRequest&&`withCredentials`in new Tn.XMLHttpRequest?Tn.XMLHttpRequest:void 0,pre=Tn?.AbortController,mre=Tn?.CompressionStream,An=En?.userAgent;function hre(){return!(!wn||!1===wn.navigator.onLine)}var jn=typeof globalThis<`u`?globalThis:wn;jn&&typeof self>`u`&&(jn.self=jn),jn&&typeof File>`u`&&(jn.File=function(){});var Mn=wn??{},gre=`0.9.0`,Nn={DEBUG:!1,LIB_VERSION:gre,LIB_NAME:`browser-common`,JS_SDK_VERSION:gre},Pn=function(e){return e.AnonymousId=`anonymous_id`,e.DistinctId=`distinct_id`,e.Props=`props`,e.EnablePersonProcessing=`enable_person_processing`,e.PersonMode=`person_mode`,e.FeatureFlagDetails=`feature_flag_details`,e.FeatureFlags=`feature_flags`,e.FeatureFlagPayloads=`feature_flag_payloads`,e.BootstrapFeatureFlagDetails=`bootstrap_feature_flag_details`,e.BootstrapFeatureFlags=`bootstrap_feature_flags`,e.BootstrapFeatureFlagPayloads=`bootstrap_feature_flag_payloads`,e.OverrideFeatureFlags=`override_feature_flags`,e.Queue=`queue`,e.AiQueue=`ai_queue`,e.AiCaptureQueue=`ai_capture_queue`,e.LogsQueue=`logs_queue`,e.OptedOut=`opted_out`,e.SessionId=`session_id`,e.SessionStartTimestamp=`session_start_timestamp`,e.SessionLastTimestamp=`session_timestamp`,e.PersonProperties=`person_properties`,e.GroupProperties=`group_properties`,e.InstalledAppBuild=`installed_app_build`,e.InstalledAppVersion=`installed_app_version`,e.SessionReplay=`session_replay`,e.PushRegistered=`push_registered`,e.SessionReplayEventTriggerActivatedSession=`session_replay_event_trigger_activated_session`,e.SurveyLastSeenDate=`survey_last_seen_date`,e.SurveysInProgress=`surveys_in_progress`,e.SurveysSeen=`surveys_seen`,e.Surveys=`surveys`,e.RemoteConfig=`remote_config`,e.FlagsEndpointWasHit=`flags_endpoint_was_hit`,e.DeviceId=`device_id`,e}({}),_re=function(e){return e.GZipJS=`gzip-js`,e.Base64=`base64`,e}({}),vre=[`$snapshot`,`$pageview`,`$pageleave`,`$set`,`survey dismissed`,`survey sent`,`survey shown`,`$identify`,`$groupidentify`,`$create_alias`,`$$client_ingestion_warning`,`$web_experiment_applied`,`$feature_enrollment_update`,`$feature_flag_called`],yre=[`token`];function Fn(e,t){return e.indexOf(t)!==-1}var In=function(e){return e.trim()},bre=function(e){return e.replace(/^\$/,``)};function xre(e){let t=[];return JSON.stringify(e,function(e,n){if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n==`object`){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(n))return`[Circular]`;t.push(n)}return n}})??`null`}var Sre=Object.prototype,Cre=Sre.hasOwnProperty,Ln=Sre.toString,Rn=Array.isArray||function(e){return Ln.call(e)===`[object Array]`},zn=e=>typeof e==`function`,Bn=e=>e===Object(e)&&!Rn(e),Vn=e=>{if(Bn(e)){for(let t in e)if(Cre.call(e,t))return!1;return!0}return!1},Hn=e=>e===void 0,Un=e=>Ln.call(e)==`[object String]`,Wn=e=>Un(e)&&e.trim().length===0,Gn=e=>e===null,Kn=e=>Hn(e)||Gn(e),qn=e=>Ln.call(e)==`[object Number]`&&e==e,Jn=e=>qn(e)&&e>0,Yn=e=>Ln.call(e)===`[object Boolean]`,wre=e=>Fn(vre,e),Tre=e=>Fn(yre,e);function Ere(e){return typeof e!=`object`||!e}function Xn(e,t){return{}.toString.call(e)===`[object ${t}]`}function Zn(e){switch({}.toString.call(e)){case`[object Error]`:case`[object Exception]`:case`[object DOMException]`:case`[object DOMError]`:case`[object WebAssembly.Exception]`:return!0;default:return Dre(e,Error)}}function Qn(e){return`u`>typeof Event&&Dre(e,Event)}function Dre(e,t){try{return e instanceof t}catch{return!1}}var Ore=[!0,`true`,1,`1`,`yes`],$n=e=>Fn(Ore,e),kre=[!1,`false`,0,`0`,`no`];function Are(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function er(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Are(a,r,i,o,s,`next`,e)}function s(e){Are(a,r,i,o,s,`throw`,e)}o(void 0)})}}var jre=`amazonbot,amazonproductbot,app.hypefactors.com,applebot,archive.org_bot,awariobot,backlinksextendedbot,baiduspider,bingbot,bingpreview,chrome-lighthouse,dataforseobot,deepscan,duckduckbot,facebookexternal,facebookcatalog,http://yandex.com/bots,hubspot,ia_archiver,leikibot,linkedinbot,meta-externalagent,mj12bot,msnbot,nessus,petalbot,pinterestbot,prerender,rogerbot,screaming frog,sebot-wa,sitebulb,slackbot,slurp,trendictionbot,turnitin,twitterbot,vercel-screenshot,vercelbot,yahoo! slurp,yandexbot,zoombot,bot.htm,bot.php,(bot;,bot/,crawler,ahrefsbot,ahrefssiteaudit,semrushbot,siteauditbot,splitsignalbot,gptbot,oai-searchbot,chatgpt-user,perplexitybot,better uptime bot,sentryuptimebot,uptimerobot,headlesschrome,cypress,google-hoteladsverifier,adsbot-google,apis-google,duplexweb-google,feedfetcher-google,google favicon,google web preview,google-read-aloud,googlebot,googleother,google-cloudvertexbot,googleweblight,mediapartners-google,storebot-google,google-inspectiontool,bytespider`.split(`,`),Mre=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return jre.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})};function tr(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),qn(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),tr(i??n,t,n,r))}var Nre=class{constructor(e){this.C={},this.I=e.I,this.R=tr(e.bucketSize,0,100,e.$),this.A=tr(e.refillRate,0,this.R,e.$),this.O=tr(e.refillInterval,0,864e5,e.$)}F(e,t){let n=Math.floor((t-e.lastAccess)/this.O);n>0&&(e.tokens=Math.min(e.tokens+n*this.A,this.R),e.lastAccess+=n*this.O)}consumeRateLimit(e){var t;let n=Date.now(),r=String(e),i=this.C[r];return i?this.F(i,n):(i={tokens:this.R,lastAccess:n},this.C[r]=i),i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.I)==null||t.call(this,e)),i.tokens===0)}stop(){this.C={}}},nr=`Mobile`,rr=`Android`,ir=`Tablet`,Pre=`Android Tablet`,Fre=`iPad`,Ire=`Apple Watch`,ar=`Safari`,or=`BlackBerry`,Lre=`Samsung Internet`,sr=`Chrome`,Rre=`Chrome iOS`,zre=`Internet Explorer`,Bre=`Internet Explorer Mobile`,Vre=`Opera`,Hre=`Microsoft Edge`,cr=`Firefox`,Ure=`Firefox iOS`,lr=`Nintendo`,ur=`PlayStation`,dr=`Xbox`,Wre=`Android Mobile`,Gre=`Mobile Safari`,Kre=`Windows`,qre=`Windows Phone`,Jre=`Nokia`,Yre=`Ouya`,Xre=`Generic `+nr.toLowerCase(),Zre=`Generic `+ir.toLowerCase(),Qre=`Konqueror`,$re=`Oculus Browser`,eie=`Vivaldi`,tie=`Yandex`,nie=`Whale`,rie=`DuckDuckGo`,iie=`Pale Moon`,aie=`Waterfox`,oie=`Brave`,sie=`Claude`,cie=`Codex`,lie=`ChatGPT`,uie=`Google Search App`,die=RegExp(`Version/(\\d+(\\.\\d+)?)`),fie=RegExp(`(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)`),pie=new RegExp(dr,`i`),mie=RegExp(`PlayStation \\w+`,`i`),hie=RegExp(`Nintendo \\w+`,`i`),gie=RegExp(`BlackBerry|PlayBook|BB10`,`i`),_ie={"NT3.51":`NT 3.11`,"NT4.0":`NT 4.0`,"5.0":`2000`,5.1:`XP`,5.2:`XP`,"6.0":`Vista`,6.1:`7`,6.2:`8`,6.3:`8.1`,6.4:`10`,"10.0":`10`},vie=function(e,t,n,r){return t||=``,function(e){return e?.brave?oie:null}(n)||(r?.detectGoogleSearchApp&&Fn(e,`GSA/`)?uie:Fn(e,` OPR/`)&&Fn(e,`Mini`)?`Opera Mini`:Fn(e,` OPR/`)?Vre:gie.test(e)?or:Fn(e,`IEMobile`)||Fn(e,`WPDesktop`)?Bre:Fn(e,`OculusBrowser`)?$re:Fn(e,`SamsungBrowser`)?Lre:Fn(e,`Edge`)||Fn(e,`Edg/`)?Hre:Fn(e,`Vivaldi/`)?eie:Fn(e,`YaBrowser/`)?tie:Fn(e,`Whale/`)?nie:Fn(e,`DuckDuckGo/`)||Fn(e,`Ddg/`)?rie:Fn(e,`Claude/`)?sie:Fn(e,`Codex/`)?cie:Fn(e,`ChatGPT/`)?lie:Fn(e,`FBIOS`)?`Facebook Mobile`:Fn(e,`UCWEB`)||Fn(e,`UCBrowser`)?`UC Browser`:Fn(e,`CriOS`)?Rre:Fn(e,`CrMo`)||Fn(e,sr)?sr:Fn(e,rr)&&Fn(e,ar)?Wre:Fn(e,`FxiOS`)?Ure:Fn(e.toLowerCase(),Qre.toLowerCase())?Qre:Fn(e,`Brave/`)?oie:((e,t)=>t&&Fn(t,`Apple`)||function(e){return Fn(e,ar)&&!Fn(e,sr)&&!Fn(e,rr)}(e))(e,t)?Fn(e,nr)?Gre:ar:Fn(e,`PaleMoon/`)?iie:Fn(e,`Waterfox/`)?aie:Fn(e,cr)?cr:Fn(e,`MSIE`)||Fn(e,`Trident/`)?zre:Fn(e,`Gecko`)?cr:``)},yie={[Bre]:[RegExp(`rv:(\\d+(\\.\\d+)?)`)],[Hre]:[RegExp(`Edge?\\/(\\d+(\\.\\d+)?)`)],[sr]:[RegExp(`(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)`)],[Rre]:[RegExp(`CriOS\\/(\\d+(\\.\\d+)?)`)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)`)],[ar]:[die],[Gre]:[die],[Vre]:[RegExp(`(Opera|OPR)\\/(\\d+(\\.\\d+)?)`)],[cr]:[RegExp(`Firefox\\/(\\d+(\\.\\d+)?)`)],[Ure]:[RegExp(`FxiOS\\/(\\d+(\\.\\d+)?)`)],[Qre]:[RegExp(`Konqueror[:/]?(\\d+(\\.\\d+)?)`,`i`)],[or]:[RegExp(`BlackBerry (\\d+(\\.\\d+)?)`),die],[Wre]:[RegExp(`android\\s(\\d+(\\.\\d+)?)`,`i`)],[Lre]:[RegExp(`SamsungBrowser\\/(\\d+(\\.\\d+)?)`)],[$re]:[RegExp(`OculusBrowser\\/(\\d+(\\.\\d+)?)`)],[eie]:[RegExp(`Vivaldi\\/(\\d+(\\.\\d+)?)`)],[tie]:[RegExp(`YaBrowser\\/(\\d+(\\.\\d+)?)`)],[nie]:[RegExp(`Whale\\/(\\d+(\\.\\d+)?)`)],[oie]:[RegExp(`Brave\\/(\\d+(\\.\\d+)?)`)],[sie]:[fie],[cie]:[fie],[lie]:[fie],[rie]:[RegExp(`(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)`)],[iie]:[RegExp(`PaleMoon\\/(\\d+(\\.\\d+)?)`)],[aie]:[RegExp(`Waterfox\\/(\\d+(\\.\\d+)?)`)],[uie]:[RegExp(`GSA\\/(\\d+(\\.\\d+)?)`)],[zre]:[RegExp(`(rv:|MSIE )(\\d+(\\.\\d+)?)`)],Mozilla:[RegExp(`rv:(\\d+(\\.\\d+)?)`)]},bie=function(e,t,n,r){let i=yie[vie(e,t,n,r)];if(Hn(i))return null;for(let t=0;i.length>t;t++){let n=e.match(i[t]);if(n)return parseFloat(n[n.length-2])}return null},xie=[[RegExp(`Xbox; Xbox (.*?)[);]`,`i`),e=>[dr,e&&e[1]||``]],[new RegExp(lr,`i`),[lr,``]],[new RegExp(ur,`i`),[ur,``]],[gie,[or,``]],[new RegExp(Kre,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[qre,``];if(new RegExp(nr).test(t)&&!/IEMobile\b/.test(t))return[`Windows Mobile`,``];let n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){let e=_ie[n[1]]||``;return/arm/i.test(t)&&(e=`RT`),[Kre,e]}return[Kre,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[`iOS`,[e[3],e[4],e[5]||`0`].join(`.`)]:[`iOS`,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t=``;return e&&e.length>=3&&(t=Hn(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`),e=>e&&e[2]?[rr,[e[2],e[3],e[4]||`0`].join(`.`)]:[rr,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{let t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[`Chrome OS`,``]],[/Linux|debian/i,[`Linux`,``]]],Sie=function(e){for(let t=0;xie.length>t;t++){let[n,r]=xie[t],i=n.exec(e),a=i&&(zn(r)?r(i,e):r);if(a)return a}return[``,``]},Cie=function(e){return hie.test(e)?lr:mie.test(e)?ur:pie.test(e)?dr:new RegExp(Yre,`i`).test(e)?Yre:RegExp(`(Windows Phone|WPDesktop)`,`i`).test(e)?qre:/iPad/.test(e)?Fre:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Ire:gie.test(e)?or:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Jre,`i`).test(e)?Jre:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?`Kindle Fire`:/(Android|ZTE)/i.test(e)?new RegExp(nr).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?rr:Pre:RegExp(`(pda|Mobile)`,`i`).test(e)?Xre:new RegExp(ir,`i`).test(e)&&!RegExp(`Tablet pc`,`i`).test(e)?Zre:``},wie=function(e,t){let n=Cie(e);return n===Fre||n===Pre||n===`Kobo`||n===`Kindle Fire`||n===Zre?ir:n===lr||n===dr||n===ur||n===Yre?`Console`:n===Ire?`Wearable`:n?nr:t?.userAgentDataPlatform===`Android`&&(t?.maxTouchPoints??0)>0?600>Math.min((r=t?.screenWidth)??0,(i=t?.screenHeight)??0)/((a=t?.devicePixelRatio)??1)?nr:ir:`Desktop`;var r,i,a},Tie=/\bFBAV\/(\d+(?:\.\d+)*)/i,Eie=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,`Instagram`],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,`Threads`],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,`Messenger`,Tie],[/\bFBAN\/EMA\b/i,`Facebook Lite`,Tie],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,`Facebook`,Tie],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,`LinkedIn`],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,`Twitter`],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,`TikTok`,/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,`WeChat`],[/\bLine\/(\d+(?:\.\d+)*)?/i,`Line`],[/\bGSA\/(\d+(?:\.\d+)*)?/i,`Google`],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,`Pinterest`],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,`WhatsApp`],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,`Snapchat`],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,`Bing`],[/\bNAVER\(inapp; search;/i,`Naver`,/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,`KakaoTalk`]],Die=`[Truncated]`,fr=`[Unserializable]`;function pr(e){let t=``;for(let n=0;e.length>n;n++){let r=e.charCodeAt(n);if(55296>r||r>56319)t+=56320>r||r>57343?e[n]:`�`;else{let r=e.charCodeAt(n+1);56320>r||r>57343?t+=`�`:(t+=e[n]+e[n+1],n++)}}return t}function Oie(e,t){if(!t)return e;let n=[];try{n=Object.keys(t)}catch{n=[]}for(let r of n){let n;try{n=t[r]}catch{n=fr}Object.defineProperty(e,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}return e}var mr=3e5,kie=class{record(e){if(e.kind===`too-large`)return;if(e.kind!==`retry-later`)return void this.reset();if(!e.retryAfterMs)return;let t=this.isOpen(),n=Date.now(),r=Math.min(e.retryAfterMs,mr);if(!t)return this.ts=n,void(this.es=n+r);this.es=Math.max(this.es,Math.min(n+r,this.ts+mr))}remainingMs(){let e=Date.now();if(this.ts-5e3>e)return this.reset(),0;let t=Math.min(mr,Math.max(0,this.es-e));return t===0&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}},Aie=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function jie(e,t){return typeof(n=e)==`string`&&Aie.test(n)?e:t();var n}function Mie(e,t){let n=Error(t);try{Object.defineProperty(n,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function hr(e){return e&&e.split(`#`)[0]}function Nie(e){try{return e()}catch{return}}function Pie(e,t){let n=setTimeout(e,t);return n!=null&&n.unref&&n?.unref(),n}function Fie(e,t,n){return Iie.apply(this,arguments)}function Iie(){return(Iie=er(function*(e,t,n){let r;try{return yield Promise.race([e,new Promise((e,i)=>{r=Pie(()=>{try{n?.(),e()}catch(e){i(e)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}var Lie,Rie,zie;function Bie(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return zie&&n.length===Rie||(Rie=n.length,zie=n.reduce((n,r)=>{Lie||={};let i=Lie[r];if(i)n[i[0]]=i[1];else{let i=e(r);for(let e=i.length-1;e>=0;e--){let a=i[e]?.filename,o=t[r];if(a&&o){n[a]=o,Lie[r]=[a,o];break}}}return n},{})),zie}function gr(e){return gr=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},gr(e)}function Vie(e,t,n){return(t=function(e){var t=function(e){if(gr(e)!=`object`||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,`string`);if(gr(n)!=`object`)return n;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}(e);return gr(t)==`symbol`?t:t+``}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function R(e){for(var t=1;arguments.length>t;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Hie(Object(n),!0).forEach(function(t){Vie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hie(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Uie=class{constructor(e,t,n=[]){this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t={}){let n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return er(function*(){for(let n of e)n.stacktrace&&n.stacktrace.frames&&Rn(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e})()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){let n,r;if(e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null)try{r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch{}return R(R({},e),{},{cause:n,stack:r,errors:e.errors?.map(e=>this.parseStacktrace(e,t))})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(let n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return er(function*(){let n=e;for(let e of t.modifiers)n=yield e(n);return n})()}convertToExceptionList(e,t){let n=[],r=(e,i,a)=>{let o=n.length,s=i===void 0?R(R({type:typeof t.type==`string`&&t.type.length>0?t.type:`generic`},typeof t.handled==`boolean`?{handled:t.handled}:t.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof t.synthetic==`boolean`?t.synthetic:e.synthetic,exception_id:o}):{type:`chained`,source:a,synthetic:e.synthetic,exception_id:o,parent_id:i},c={type:e.type,value:e.value,mechanism:s};e.stack&&(c.stacktrace={type:`raw`,frames:e.stack}),n.push(c),e.cause&&r(e.cause,o,`cause`);for(let t of e.errors??[])r(t,o,`member`)};return r(e),n}buildParsingContext(e){return{chunkIdMap:Bie(this.stackParser),skipFirstLines:e.skipFirstLines??1}}getAggregateErrors(e){try{if(Zn(e)){let t=Object.getPrototypeOf(e);for(let n=0;t&&100>n;n++){let n=Object.getOwnPropertyDescriptor(t,`constructor`)?.value;if(typeof n==`function`&&n.name===`AggregateError`){let t=e.errors;return Rn(t)?t:void 0}t=Object.getPrototypeOf(t)}}}catch{}}buildCoercingContext(e,t,n=0){let r=0,i=0,a=!1,o=new Set,s=[],c={},l=(e,t,n=0)=>{let l=u(t,n),d=l.apply;if(l.apply=t=>{s.push(e);try{return d(t)}finally{s.pop()}},n>4||n>0&&s.indexOf(e)!==-1)return this.coerceFallback(l);let f=typeof e==`object`&&!!e||typeof e==`function`;if(n===0&&r>=50||f&&o.has(e))return;f&&o.add(e),n===0&&r++;let p=this.getAggregateErrors(e),m,h;a||=!!p;try{if(m=this.applyCoercers(e,l),!m)throw c}catch(e){if(e===c)return void(n===0&&r--);if(!a)throw e;m=this.coerceFallback(l)}if(!p||r>=50)return m;try{h=p.length}catch{return m}if(!Number.isInteger(h)||0>h||h>4294967295)return m;let g=[];for(let e=0;50>r&&1e3>i&&h>e;e++){let n;i++;try{n=l.next(p[e])}catch{r++,n=this.coerceFallback(u(t+1))}n&&g.push(n)}return R(R({},m),{},{errors:g})},u=(n,r=0)=>R(R({},t),{},{syntheticException:n==0?t.syntheticException:void 0,mechanism:n==0?e:{},apply(e){let t=l(e,n,r+1);if(!t)throw c;return t},next:e=>l(e,n+1)}),d=u(n);return R(R({},d),{},{apply:e=>l(e,n)??this.coerceFallback(d)})}},Wie=/^([a-z][a-z0-9.+-]+):/i,Gie=[`http`,`https`,`file`,`blob`,`app`,`capacitor`,`ionic`,`webpack`,`webpack-internal`,`ng`];function Kie(e){if(!e||e===`<anonymous>`)return!1;let t=Wie.exec(e);return!t||Gie.includes(t[1].toLowerCase())}function _r(e,t,n,r,i){let a={platform:e,filename:t,function:n===`<anonymous>`?`?`:n,in_app:Kie(t)};return Hn(r)||(a.lineno=r),Hn(i)||(a.colno=i),a}var qie=(e,t)=>{let n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?`?`:e.split(`@`)[0],n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Jie=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Yie=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Xie=/\((\S*)(?::(\d+))(?::(\d+))\)/,Zie=(e,t)=>{let n=Jie.exec(e);if(n){let[,e,r,i]=n;return _r(t,e,`?`,+r,+i)}let r=Yie.exec(e);if(r){if(r[2]&&r[2].indexOf(`eval`)===0){let e=Xie.exec(r[2]);e&&(r[2]=e[1],r[3]=e[2],r[4]=e[3])}let[e,n]=qie(r[1]||`?`,r[2]);return _r(t,n,e,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},Qie=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,$ie=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,eae=(e,t)=>{let n=Qie.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){let e=$ie.exec(n[3]);e&&(n[1]=n[1]||`eval`,n[3]=e[1],n[4]=e[2],n[5]=``)}let e=n[3],r=n[1]||`?`;return[r,e]=qie(r,e),_r(t,e,r,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},tae=/\(error: (.*)\)/;function vr(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function nae(e){for(let t=1;10>=t;t++){let n=e.length-2*t;if(0>n)break;let r=!0;for(let i=0;t>i;i++)if(!vr(e[n+i],e[n+t+i])){r=!1;break}if(r){for(let r=0;t>r;r++)e[n+r]=e[n+t+r];return e.length=n+t,{start:n,length:t}}}}function rae(e,t){let n=t.start+t.length,r=aae(e,t);r&&e.splice(n+r===e.length?n:t.start,r)}function iae(e,t){let n=t.start;for(;n>0&&vr(e[n-1],e[n-1+t.length]);)n--;return t.start-n}function aae(e,t){let n=t.start+t.length,r=n;for(;e.length>r&&vr(e[r],e[r-t.length]);)r++;return r-n}function oae(e,t){let n=t[0],r=e.length-(n?iae(e,n):0);for(let n of t)r-=aae(e,n);return r}function sae(e,t,n){for(let r=0;e.length>r;r++){let i=e[(t+r)%e.length],a=e[(n+r)%e.length];if(i!==a)return a>i}return!1}var cae=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){let n=Un(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){let t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?`${t}: ${e.message}`:t}isDOMException(e){return Xn(e,`DOMException`)}isDOMError(e){return Xn(e,`DOMError`)}},lae=class{match(e){return Zn(e)}coerce(e,t){let n=this.getStack(e),r=n===void 0?t.syntheticException?.stack:void 0,i=!!r;return{type:this.getType(e),value:this.getMessage(e,t),stack:n??r,cause:e.cause?t.next(e.cause):void 0,synthetic:i}}getType(e){return e.name||e.constructor.name}getMessage(e,t){let n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){try{let t=e.stacktrace;if(typeof t==`string`&&t.length>0)return t;let n=e.stack;return typeof n==`string`&&n.length>0?n:void 0}catch{return}}},uae=class{match(e){return!!Xn(e,`ErrorEvent`)&&(e.error!=null||this.ur(e))}coerce(e,t){if(e.error!=null)return t.apply(e.error);let n=t.apply(e.message);return R(R({},n),{},{stack:this.cr(e)??n.stack,synthetic:!0})}ur(e){return Un(e.message)&&e.message.length>0}cr(e){let t=e,n=t.lineno??0,r=t.colno??0;if(Un(t.filename)&&t.filename.length!==0&&n!==0)return`Error\n at ${t.filename}:${n}:${r}`}},dae=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,fae=class{match(e){return typeof e==`string`}coerce(e,t){let[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){let t=`Error`,n=e,r=e.match(dae);return r&&(t=r[1],n=r[2]),[t,n]}},pae=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function mae(e,t=40){let n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(let e=n.length;e>0;e--){let r=n.slice(0,e).join(`, `);if(t>=r.length)return e===n.length?r:r.length>t?`${r.slice(0,t)}...`:r}return``}var hae=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){let n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:this.getStack(e)??t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){if(Qn(e))return e.constructor.name;let t=`name`in e?e.name:void 0;return Un(t)&&!Wn(t)?t:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){let t=`'${e.name}' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '${e.message}'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;let t=this.getObjectClassName(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${mae(e)}`}isSeverityLevel(e){return Un(e)&&!Wn(e)&&pae.indexOf(e)>=0}getStack(e){try{return Un(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:Un(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(let t in e)if({}.hasOwnProperty.call(e,t)){let n=e[t];if(Zn(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},gae=class{match(e){return Qn(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${mae(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},_ae=class{match(e){return Ere(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},vae=class{match(e){return Xn(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Qn(e))return!1;try{let t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){let n=this.getUnhandledRejectionReason(e);return Ere(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: ${String(n)}`,stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},yr=`$message`,br=`$timestamp`,yae=new Set([yr,br]),bae={enabled:!0,max_bytes:32768};function xr(e){return e?{enabled:e.enabled??bae.enabled,max_bytes:Sae(e.max_bytes,bae.max_bytes)}:R({},bae)}var xae=class{constructor(e){this.ns=[],this.ss=0,this.Rr=xr(e)}setConfig(e){this.Rr=xr(e),this.rs()}add(e){let t=function(e){let t;try{t=xre(e)}catch{return}try{let e=JSON.parse(t);if(!Bn(e))return;let n=e,r=n[yr],i=n[br];return!Un(r)||r.trim().length===0||!Un(i)&&!qn(i)?void 0:{step:n,json:t}}catch{return}}(e);if(!t)return;let n=function(e){if(`u`>typeof TextEncoder)return new TextEncoder().encode(e).length;let t=encodeURIComponent(e),n=0;for(let e=0;t.length>e;e++)t[e]===`%`?(n+=1,e+=2):n+=1;return n}(t.json);n>this.Rr.max_bytes||(this.ns.push({step:t.step,bytes:n}),this.ss+=n,this.rs())}getAttachable(){return this.ns.map(e=>e.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Rr.max_bytes&&this.ns.length>0;){let e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function Sae(e,t){if(!qn(e)||1/0===e||-1/0===e)return t;let n=Math.floor(e);return 0>n?t:n}var Cae=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}};function wae(e){return typeof e==`string`||e}function Tae(e){return typeof e==`string`?e:void 0}var Eae=`$feature_flag.$feature_flag_response.$feature_flag_has_experiment.$feature_flag_id.$feature_flag_version.$feature_flag_reason.$feature_flag_request_id.$feature_flag_evaluated_at.$feature_flag_error.locally_evaluated.$groups.$process_person_profile.$geoip_disable.$current_url.$pathname.$referring_domain.utm_source.utm_medium.utm_campaign.utm_content.utm_term.gad_source.mc_cid.gclid.gclsrc.dclid.gbraid.wbraid.fbclid.msclkid.twclid.li_fat_id.igshid.ttclid.rdt_cid.epik.qclid.sccid.irclid._kx.$session_id.$window_id.$lib.$lib_version.$device_id.$is_server`.split(`.`),Dae=`NativeGzipValidationError`,Oae=e=>e.length>=2&&e[0]===31&&e[1]===139,kae=(e,t)=>e===_re.GZipJS||t===_re.GZipJS||t===`gzip`,Aae=e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`,Sr,Cr=e=>{throw Mie(Dae,`Native gzip produced invalid output: ${e}`)},jae=(Mae=er(function*(e,t){18>e.size&&Cr(`too-short`);let n=new Uint8Array(yield e.slice(0,10).arrayBuffer());Oae(n)&&n[2]===8||Cr(`invalid-header`);let r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{let t=(()=>{if(Sr)return Sr;Sr=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;Sr[e]=t>>>0}return Sr})(),n=4294967295;for(let r=0;e.length>r;r++)n=t[255&(n^e[r])]^n>>>8;return(4294967295^n)>>>0})(t)&&Cr(`invalid-crc`);let i=t.length>>>0;r.getUint32(4,!0)!==i&&Cr(`invalid-size`)}),function(e,t){return Mae.apply(this,arguments)}),Mae;function Nae(){return Nae=er(function*(e,t=!0,n){try{let t=new TextEncoder().encode(e),n=new globalThis.CompressionStream(`gzip`),i=n.writable.getWriter(),a=i.write(t).then(()=>i.close()).catch((r=er(function*(e){try{yield i.abort(e)}catch{}throw e}),function(e){return r.apply(this,arguments)})),o=new Response(n.readable).blob(),[s]=yield Promise.all([o,a]);return yield jae(s,t),s}catch(e){if(n?.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}var r}),Nae.apply(this,arguments)}function Pae(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;a.length>r;r++)t.includes(n=a[r])||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Fae={}.propertyIsEnumerable;function wr(e,t){try{return Rae(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function Iae(e,t,n,r){if(0>=n.remainingNodes)return{stringValue:Die};if(n.remainingNodes--,Yn(e))return{boolValue:e};if(typeof e==`bigint`)return function(e,t){let n=e.toString(),r=BigInt(`9223372036854775808`);return e>=r||-r>e?(t?.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}(e,t);if(typeof e==`number`){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>`u`)return{stringValue:String(e)};let n=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(t?.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}return{doubleValue:e}}if(typeof e==`string`)return{stringValue:pr(e)};if(typeof e==`function`)return{stringValue:`[Function]`};if(typeof e==`symbol`)return{stringValue:String(e)};if(typeof e==`object`&&e){if(n.ancestors.has(e))return{stringValue:`[Circular]`};if(r>=20)return{stringValue:Die};if(e instanceof Date){let t=e.getTime(),n=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:typeof n==`string`?pr(n):String(n)}}n.ancestors.add(e);try{try{let i=e.toJSON;if(typeof i==`function`)return Iae(i.call(e),t,n,r+1)}catch{}return Rn(e)?{arrayValue:{values:Lae(e,t,n,r+1)}}:{kvlistValue:{values:Rae(e,t,n,r+1)}}}finally{n.ancestors.delete(e)}}return{stringValue:pr(String(e))}}function Lae(e,t,n,r){let i=[],a=Math.min(e.length,1e3),o=0;for(;a>o&&n.remainingNodes>0;o++)try{let a=o in e?e[o]:void 0;if(Kn(a))continue;i.push(Iae(a,t,n,r))}catch{i.push({stringValue:fr})}return e.length>o&&i.push({stringValue:Die}),i}function Rae(e,t,n,r){let i=[];for(let a in e)if(Fae.call(e,a)){if(!a){t?.debug(`Dropping an attribute with an empty key`);continue}if(i.length>=1e3||0>=n.remainingNodes){t?.debug(`Attributes truncated: the value exceeds the OTLP encoder budget`);break}try{let o=e[a];if(Gn(o)||Hn(o))continue;i.push({key:pr(a),value:Iae(o,t,n,r)})}catch{i.push({key:pr(a),value:{stringValue:fr}})}}return i}function zae(e,t,n){return R(R(R(R({},Oie({},e.resourceAttributes)),{},{"service.name":e.serviceName||`unknown_service`},e.environment&&{"deployment.environment":e.environment}),e.serviceVersion&&{"service.version":e.serviceVersion}),{},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}var Bae=[`service.name`,`deployment.environment`,`service.version`,`telemetry.sdk.name`,`telemetry.sdk.version`];function Vae(e,t){let n=Oie({},e),r={};for(let e of Bae)({}).hasOwnProperty.call(n,e)&&(r[e]=n[e],delete n[e]);return[...wr(n,t),...wr(r,t)]}var Hae={darwin:`macOS`,win32:`Windows`,cygwin:`Windows`,linux:`Linux`,android:`Android`,freebsd:`FreeBSD`,openbsd:`OpenBSD`,netbsd:`NetBSD`,sunos:`SunOS`,aix:`AIX`,haiku:`Haiku`,"Mac OS X":`macOS`},Uae={trace:{text:`TRACE`,number:1},debug:{text:`DEBUG`,number:5},info:{text:`INFO`,number:9},warn:{text:`WARN`,number:13},error:{text:`ERROR`,number:17},fatal:{text:`FATAL`,number:21}},Wae=Uae.info;function Gae(e){try{return pr(String(e))}catch{return fr}}function Kae(e,t,n,r){let{text:i,number:a}=Uae[e.level||`info`]||Wae,o=function(e=Date.now()){return String(e)+`000000`}(qn(r)?r:void 0),s={};t.distinctId&&(s.posthogDistinctId=t.distinctId),t.sessionId&&(s.sessionId=t.sessionId),t.windowId&&(s[`window.id`]=t.windowId),Kn(t.sessionStartTimestamp)||(s.sessionStartTimestamp=String(t.sessionStartTimestamp)),Kn(t.lastActivityTimestamp)||(s.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(s[`url.full`]=t.currentUrl),t.screenName&&(s[`screen.name`]=t.screenName),t.appState&&(s[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(s.feature_flags=t.activeFeatureFlags);let c=R({},s),l=e.attributes;if(l){let e=[];try{e=Object.keys(l)}catch{e=[]}for(let t of e){let e;try{e=l[t]}catch{e=fr}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}let u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:a,severityText:i,body:{stringValue:Gae(e.body)},attributes:wr(c,n)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),Hn(e.trace_flags)||(u.flags=e.trace_flags),u}function qae(e,t,n){return zae(e,t,n)}function Jae(e,t,n,r){return{resourceLogs:[{resource:{attributes:Vae(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}var Yae=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.hs}arm(e){this.clear(),this.us=Date.now()+e,this.hs=Pie(()=>{this.hs=void 0,this.ls()},e)}armNoEarlierThan(e){this.hs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.hs&&=(clearTimeout(this.hs),void 0)}};function Xae(){return .75+.5*Math.random()}function Zae(e,t,n,r){let i=e*2**Math.min(Math.max(0,t-1),6);return Math.round((r===void 0?i:Math.min(i,Math.max(r,e)))*n)}var Qae=class{constructor(e,t,n,r,i,a=()=>Promise.resolve(),o){this._instance=e,this.Rr=t,this.$=n,this.cs=r,this.ds=i,this.vs=a,this.fs=o,this.ps=new Yae(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new kie,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!1,this.Ts=t.maxBufferSize,this.Is=Math.max(t.maxQueueSize??t.maxBufferSize,t.maxBufferSize),this.Ms=t.flushIntervalMs,this.Es=t.maxBatchRecordsPerPost,this.Ps=t.rateCapWindowMs,this.Rs=t.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(Pn.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Rr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(e,t){if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;let n=this.Os(e);if(n===null)return;if(!n.body)return void this.$.info(`Log was rejected in beforeSend function`);if(!this.Ds())return;let r={record:Kae(n,t?.context??this.cs(),this.$,t?.occurredAtMs)};this.ds(()=>this.Ls(r))}Os(e){let t=this.Rr.beforeSend;if(!t)return e;let n=Rn(t)?t:[t],r=e;for(let e of n)try{let t=e(r);if(!t)return this.$.info(`Log was rejected in beforeSend function`),null;r=t}catch(e){return this.$.error(`Error in beforeSend function for log:`,e),null}return r}Ds(){if(this.Rs===void 0)return!0;let e=Date.now(),t=e-this.xs;return this.Ps>t&&t>=0||(this.xs=e,this.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||=(this.$.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),!0),!1)}flush(){var e=this;return er(function*(){if(!e._instance.isDisabled)return e.ys||=e.Ns().finally(()=>{e.ys=null}),e.ys})()}Ns(){var e=this;return er(function*(){e.ps.clear();let t=e._instance.getPersistedProperty(Pn.LogsQueue)??[];if(t.length===0)return;let n=t.length,r=0;for(;t.length>0&&n>r;){let n=e._s;e.bs=0;let i=Math.min(t.length,e.Es),a=t.slice(0,i),o=Jae(a.map(e=>e.record),e.qs(),e.fs??e._instance.getLibraryId(),e._instance.getLibraryVersion()),s=yield e._instance.js(o);if(e._s!==n)return;if(s.kind===`too-large`&&a.length>1)e.Es=Math.max(1,Math.floor(a.length/2)),e.$.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else if(e.ws.record(s),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),s.kind===`retry-later`||(s.kind===`too-large`?e.$.warn(`Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further.`):s.kind===`ok`&&e.Rr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Rr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(a.length),t=e._instance.getPersistedProperty(Pn.LogsQueue)??[],r+=a.length,s.kind===`fatal`))throw s.error}})()}Bs(e){var t=this;return er(function*(){let n=Math.max(0,e-t.bs),r=t._instance.getPersistedProperty(Pn.LogsQueue)??[];t._instance.setPersistedProperty(Pn.LogsQueue,r.slice(n)),yield t.vs()})()}qs(){return qae(this.Rr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){if(this._instance.optedOut)return;let t=this._instance.getPersistedProperty(Pn.LogsQueue)??[];this.Is>t.length||(t.shift(),this.bs++,this.$.info(`Logs queue is full, dropping oldest record.`)),t.push(e),this._instance.setPersistedProperty(Pn.LogsQueue,t),this.Ts>t.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(Zae(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){let e=this._instance.getPersistedProperty(Pn.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return er(function*(){t.ps.clear();let n=t.flush().catch(()=>{});e===void 0?yield n:yield Fie(n,e)})()}flushWithTimeout(e){var t=this;return er(function*(){let n=t.flush();yield Fie(n,e,()=>{n.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=Xae(),this.$.error(`PostHog logs flush failed:`,e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}},$ae=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function eoe(e){return String(e)+`000000`}function toe(e,t,n,r){let i=``;return r&&(i=Object.keys(r).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(r[e])}`).join(`,`)),`${e}\0${t}\0${n??``}\0${i}`}var noe=class{constructor(e,t,n){this._instance=e,this.Rr=t,this.$=n,this.zs=new Map,this.ps=new Yae(()=>this.flush().catch(e=>{this.$.error(`Metrics flush failed:`,e)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new kie,this.ks=0,this.Ss=1,this.Gs=0}count(e,t=1,n){this.Zs({name:e,type:`count`,value:t,unit:n?.unit,attributes:n?.attributes})}gauge(e,t,n){this.Zs({name:e,type:`gauge`,value:t,unit:n?.unit,attributes:n?.attributes})}histogram(e,t,n){this.Zs({name:e,type:`histogram`,value:t,unit:n?.unit,attributes:n?.attributes})}flush(){var e=this;let t=this.ys,n=function(){var n=er(function*(){t&&(yield t.catch(()=>{})),yield e.Qs()});return function(){return n.apply(this,arguments)}}()().finally(()=>{this.ys===n&&(this.ys=null)});return this.ys=n,n}drainWindow(){if(this.zs.size===0)return null;let e=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(e){if(this._instance.isDisabled||this._instance.optedOut)return;let t=this.Os(e);if(t===null)return;if(!t.name||typeof t.name!=`string`)return void this.$.warn(`Dropping metric with empty name`);if(typeof t.value!=`number`||!Number.isFinite(t.value))return void this.$.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type===`count`&&0>t.value)return void this.$.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let n,r;try{n=t.attributes?R({},t.attributes):void 0,r=toe(t.type,t.name,t.unit,n)}catch(e){this.$.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e);return}let i=this.zs.get(r);if(!i){if(!this.Ks())return;i={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.zs.set(r,i)}let a=this.Ws.get(t.name);a===void 0?this.Ws.set(t.name,t.type):a===t.type||this.Vs.has(t.name)||(this.Vs.add(t.name),this.$.warn(`Metric name '${t.name}' is already used as a ${a}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(i,t.value),this.Fs()}Ks(){return this.Rr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.$.warn(`Metric series cap reached (${this.Rr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(e,t){switch(e.type){case`count`:e.total=(e.total??0)+t;break;case`gauge`:e.last=t;break;case`histogram`:{e.hist||={count:0,sum:0,min:t,max:t,bucketCounts:Array($ae.length+1).fill(0)};let n=e.hist;n.count+=1,n.sum+=t,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.bucketCounts[function(e,t){for(let n=0;t.length>n;n++)if(t[n]>=e)return n;return t.length}(t,$ae)]+=1;break}}}Os(e){let t=this.Rr.beforeSend;if(!t)return e;let n=Rn(t)?t:[t],r=e;for(let e of n)try{let t=e(r);if(!t)return this.$.info(`Metric was rejected in beforeSend function`),null;r=t}catch(e){return this.$.error(`Error in beforeSend function for metric:`,e),null}return r}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(Zae(this.Rr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var e=this;return er(function*(){if(e.ps.clear(),e.zs.size===0)return;let t=e.zs;e.zs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;let n=e.Gs,r=yield e._instance.Ys(e.Js(t));if(n===e.Gs)switch(e.ws.record(r),r.kind===`retry-later`?(e.ks++,e.Ss=Xae()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.Hs()),r.kind){case`ok`:return;case`retry-later`:e.ho(t),e.ps.armNoEarlierThan(e.Hs());return;case`too-large`:e.$.warn(`Metrics batch exceeded the server size limit and was dropped`);return;case`fatal`:e.$.error(`Failed to send metrics batch:`,r.error);return}})()}Js(e){return t=this.vo(e),n=function(e,t,n){return zae(e,t,n)}(this.Rr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Vae(n)},scopeMetrics:[{scope:{name:r,version:i},metrics:t}]}]};var t,n,r,i}vo(e){let t=eoe(Date.now()),n=new Map;for(let r of e.values()){let e=toe(r.type,r.name,r.unit,void 0),i=n.get(e);i||(i=R({name:r.name},r.unit&&{unit:r.unit}),r.type===`count`?i.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type===`gauge`?i.gauge={dataPoints:[]}:i.histogram={aggregationTemporality:1,dataPoints:[]},n.set(e,i));let a=wr(r.attributes??{},this.$),o=eoe(r.windowStartMs);if(r.type===`count`){let e={attributes:a,startTimeUnixNano:o,timeUnixNano:t,asDouble:r.total??0};i.sum.dataPoints.push(e)}else if(r.type===`gauge`){let e={attributes:a,timeUnixNano:t,asDouble:r.last??0};i.gauge.dataPoints.push(e)}else r.hist&&i.histogram.dataPoints.push({attributes:a,startTimeUnixNano:o,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:$ae})}return Array.from(n.values())}ho(e){for(let[t,n]of e){let e=this.zs.get(t);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,n.windowStartMs),e.type){case`count`:e.total=(e.total??0)+(n.total??0);break;case`gauge`:break;case`histogram`:if(n.hist){if(e.hist){e.hist.count+=n.hist.count,e.hist.sum+=n.hist.sum,e.hist.min=Math.min(e.hist.min,n.hist.min),e.hist.max=Math.max(e.hist.max,n.hist.max);for(let t=0;e.hist.bucketCounts.length>t;t++)e.hist.bucketCounts[t]+=n.hist.bucketCounts[t]}else e.hist=n.hist}}else this.Ks()&&this.zs.set(t,n)}}},roe=(e,{debugEnabled:t}={})=>{let n={N(n,...r){wn&&(Nn.DEBUG||wn.POSTHOG_DEBUG||t)&&!Hn(wn.console)&&wn.console&&(`__rrweb_original__`in wn.console[n]?wn.console[n].__rrweb_original__:wn.console[n])(e,...r)},debug(...e){n.N(`debug`,...e)},info(...e){n.N(`log`,...e)},warn(...e){n.N(`warn`,...e)},error(...e){n.N(`error`,...e)},critical(...t){console.error(e,...t)},uninitializedWarning(e){n.error(`You must initialize PostHog before calling ${e}`)},createLogger:(t,n)=>roe(`${e} ${t}`,n)};return n},Tr=roe(`[PostHog.js]`),Er=Tr.createLogger,ioe=Er(`[ExternalScriptsLoader]`),Dr=e=>{let t=Dn?.querySelectorAll(`script`);if(t){for(let n=0;t.length>n;n++)if(t[n].src===e||t[n].getAttribute(`src`)===e)return t[n]}},Or=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return ioe.warn(`${t} was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);let r=Dr(t);if(r){if(r.__posthog_loading_callback_fired)return n();let e=r.__posthog_loading_error;return e?n(e):(r.addEventListener(`load`,e=>{r.__posthog_loading_callback_fired=!0,n(void 0,e)}),void r.addEventListener(`error`,e=>{r.__posthog_loading_error=e,n(e)}))}let i=()=>{if(!Dn)return n(`document not found`);if(Dr(t))return Or(e,t,n);let r=Dn.createElement(`script`);if(r.type=`text/javascript`,r.crossOrigin=`anonymous`,r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,n(void 0,e)},r.onerror=e=>{r.__posthog_loading_error=e,n(e)},e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)Dn.head.appendChild(r);else{let e=Dn.querySelectorAll(`body > script`);var i;e.length>0?(i=e[0].parentNode)==null||i.insertBefore(r,e[0]):Dn.body.appendChild(r)}};Dn?.body?i():Dn?.addEventListener(`DOMContentLoaded`,i)},kr={},aoe=(e,t)=>{let n=`/static/${t}.js?v=${e.version}`;if(t===`toolbar`){let e=3e5;n=`${n}&t=${Math.floor(Date.now()/e)*e}`}return e.requestRouter.endpointFor(`assets`,n)};Mn.__PosthogExtensions__=Mn.__PosthogExtensions__||{},Mn.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t===`remote-config`){Or(e,e.requestRouter.endpointFor(`assets`,`/array/${e.config.token}/config.js`),n);return}let r=e.config.strict_script_versioning;if(r){let i=e.requestRouter.endpointFor(`assets`,`/static/${e.version}/${t}.js`),a=kr[i];if(r===`fallback`&&a){if(Dr(a))return void Or(e,a,n);delete kr[i]}Or(e,i,r===`fallback`?(r,a)=>{if(r){if(typeof r==`string`)n(r);else{var o;let r=aoe(e,t);kr[i]=r;let a=Dr(i);a==null||(o=a.parentNode)==null||o.removeChild(a),Or(e,r,n)}}else n(void 0,a)}:n);return}Or(e,aoe(e,t),n)},Mn.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{Or(e,e.requestRouter.endpointFor(`api`,t),n)},Nn.DEBUG=!1,Nn.LIB_VERSION=`1.434.13`,Nn.LIB_NAME=`web`;var Ar=Nn,ooe=`$people_distinct_id`,jr=`distinct_id`,Mr=`$device_id`,Nr=`$device_model`,Pr=`__alias`,soe=`__cmpns`,coe=`$fbc`,Fr=`$fbc_persistence`,loe=`$fbp`,Ir=`$fbp_persistence`,uoe=`__timers`,doe=`$autocapture_disabled_server_side`,foe=`$heatmaps_enabled_server_side`,poe=`$exception_capture_enabled_server_side`,moe=`$error_tracking_suppression_rules`,hoe=`$error_tracking_capture_extension_exceptions`,goe=`$web_vitals_enabled_server_side`,_oe=`$dead_clicks_enabled_server_side`,voe=`$product_tours_enabled_server_side`,yoe=`$logs_capture_enabled_server_side`,boe=`$web_vitals_allowed_metrics`,Lr=`$session_recording_remote_config`,xoe=`$session_recording_enabled_server_side`,Soe=`$replay_sample_rate`,Coe=`$replay_override_sampling`,woe=`$replay_override_linked_flag`,Toe=`$replay_override_url_trigger`,Eoe=`$replay_override_event_trigger`,Rr=`$sesid`,Doe=`$session_is_sampled`,Ooe=`$session_past_minimum_duration`,koe=`$session_recording_url_trigger_activated_session`,Aoe=`$session_recording_event_trigger_activated_session`,joe=`$debug_first_full_snapshot_timestamp`,Moe=`$sess_rec_flush_size`,zr=`$enabled_feature_flags`,Br=`$active_feature_flags`,Noe=`$early_access_features`,Vr=`$feature_flag_details`,Hr=`$feature_flag_payloads`,Ur=`$feature_flag_request_id`,Wr=`$minimal_flag_called_events`,Gr=`$override_feature_flags`,Kr=`$override_feature_flag_payloads`,qr=`$stored_person_properties`,Jr=`$stored_group_properties`,Poe=`$groups`,Foe=`$surveys`,Yr=`$surveys_loaded_at`,Ioe=`$surveys_activated`,Loe=`$surveys_activated_session`,Roe=`$surveys_activated_timestamps`,zoe=`ph_product_tours`,Boe=`$product_tours_activated`,Voe=`$product_tours_activated_session`,Hoe=`$conversations_widget_session_id`,Uoe=`$conversations_ticket_id`,Woe=`$conversations_widget_state`,Goe=`$conversations_user_traits`,Xr=`$flag_call_reported`,Zr=`$flag_call_reported_session_id`,Qr=`$feature_flag_errors`,$r=`$feature_flag_evaluated_at`,ei=`$user_state`,ti=`$client_session_props`,Koe=`$capture_rate_limit`,qoe=`$initial_campaign_params`,Joe=`$initial_referrer_info`,ni=`$initial_person_info`,ri=`$epp`,ii=`$posthog_cookieless`,Yoe=`$cookieless_mode`,Xoe=`$sdk_debug_extensions_init_method`,Zoe=`$sdk_debug_extensions_init_time_ms`,Qoe=`$sdk_debug_recording_script_not_loaded`,$oe=`$sdk_debug_replay_stale_config`,ese=`$sdk_debug_replay_event_trigger_status`,tse=`$sdk_debug_replay_linked_flag_trigger_status`,nse=`$sdk_debug_replay_matched_recording_trigger_groups`,rse=`$sdk_debug_replay_pending_trigger_conditions`,ise=`$sdk_debug_replay_remote_trigger_matching_config`,ase=`$sdk_debug_replay_trigger_groups_count`,ose=`$sdk_debug_replay_url_trigger_status`,sse=`$session_recording_start_reason`,ai=`PostHog loadExternalDependency extension not found.`,oi=`anonymous`,si=`identified`,cse=`identified_only`,ci=`visibilitychange`,li=`beforeunload`,ui=`$pageview`,lse=`$pageleave`,use=`$identify`,dse=`$groupidentify`;function di(e,t){Rn(e)&&e.forEach(t)}function fi(e,t){if(!Kn(e)){if(Rn(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,n)=>t(e,n));else for(let n in e)Cre.call(e,n)&&t(e[n],n)}}var pi=function(e,...t){for(let n of t)for(let t in n)n[t]!==void 0&&(e[t]=n[t]);return e};function mi(e){let t=Object.keys(e),n=t.length,r=Array(n);for(;n--;)r[n]=[t[n],e[t[n]]];return r}var fse=function(e){return function(...t){try{return e.apply(this,t)}catch(e){Tr.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),Tr.critical(e)}}},hi=function(e){let t={};return fi(e,function(e,n){(Un(e)&&e.length>0||qn(e))&&(t[n]=e)}),t};function pse(e){let t=R({},e);for(let n of[`name`,`message`,`stack`,`cause`,`errors`])try{n in e&&(t[n]=e[n])}catch{}return t}var mse=[`herokuapp.com`,`vercel.app`,`netlify.app`];function hse(e){let t=e?.hostname;if(!Un(t))return!1;let n=t.split(`.`).slice(-2).join(`.`);for(let e of mse)if(n===e)return!1;return!0}function gi(e,t,n,r){let{capture:i=!1,passive:a=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:a})}function _i(e){return e.name===`ph_toolbar_internal`}var vi=e=>{if(Dn){try{let t=e+`=`,n=Dn.cookie.split(`;`).filter(e=>e.length);for(let e=0;n.length>e;e++){let r=n[e];for(;r.charAt(0)==` `;)r=r.substring(1,r.length);if(r.indexOf(t)===0)return decodeURIComponent(r.substring(t.length,r.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return qn(e)&&isFinite(e)&&Math.floor(e)===e});var gse=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/256,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){let e=``;for(let t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let t=0;16>t;t++){let n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},_se=class{generate(){let e=this.generateOrAbort();if(!Hn(e))return e;{this.Ct=0;let e=this.generateOrAbort();if(Hn(e))throw Error(`Could not generate UUID after timestamp reset`);return e}}generateOrAbort(){let e=(()=>{let e=Date.now();return qn(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.Mt();else{if(this.Ct>=e+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return gse.fromFieldsV7(this.Ct,Math.trunc(this.It/2**30),this.It&2**30-1,this.Tt.nextUint32())}Mt(){this.It=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.It=0,this.Tt=new yse}},vse=e=>{if(`u`>typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};wn&&!Hn(wn.crypto)&&crypto.getRandomValues&&(vse=e=>crypto.getRandomValues(e));var yse=class{nextUint32(){return this.Rt.length>this.$t||(vse(this.Rt),this.$t=0),this.Rt[this.$t++]}constructor(){this.Rt=new Uint32Array(8),this.$t=1/0}},bse,yi=()=>xse().toString(),xse=()=>(bse||=new _se).generate(),bi=``,Sse=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,xi=null,Si={Et(){if(!Gn(xi))return xi;if(xi=!1,Dn)try{let e=`__ph_cookie_support_${yi()}`;Si.At(e,`xyz`),xi=vi(e)===`"xyz"`,Si.Lt(e)}catch{xi=!1}return xi},Pt(e){Tr.error(`cookieStore error: `+e)},Ot:vi,Dt(e){let t;try{t=JSON.parse(Si.Ot(e))||{}}catch{}return t},At(e,t,n,r,i){if(!Dn)return!1;try{let a=``,o=``,s=function(e,t){if(t){let t=function(e,t=Dn){if(bi)return bi;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;let n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+yi();for(;!bi&&r--;){let e=n.slice(r).join(`.`),a=i+`=1;domain=.`+e+`;path=/`;t.cookie=a+`;max-age=3`,t.cookie.includes(i)&&(t.cookie=a+`;max-age=0`,bi=e)}return bi}(e);if(!t){let n=(e=>{let t=e.match(Sse);return t?t[0]:``})(e);n!==t&&Tr.info(`Warning: cookie subdomain discovery mismatch`,n,t),t=n}return t?`; domain=.`+t:``}return``}(Dn.location.hostname,r);if(n){let e=new Date;e.setTime(e.getTime()+864e5*n),a=`; expires=`+e.toUTCString()}i&&(o=`; secure`);let c=e+`=`+encodeURIComponent(JSON.stringify(t))+a+`; SameSite=Lax; path=/`+s+o;return c.length>3686.4&&Tr.warn(`cookieStore warning: large cookie, len=`+c.length),Dn.cookie=c,!0}catch{return!1}},Lt(e,t){if(Dn?.cookie&&(!t||!Gn(vi(e))))try{Si.At(e,``,-1,t)}catch{return}}},Cse=null,Ci={Et(){if(!Gn(Cse))return Cse;let e=!0;if(Hn(wn))e=!1;else try{let t=`__mplssupport__`;Ci.At(t,`xyz`),Ci.Ot(t)!==`"xyz"`&&(e=!1),Ci.Lt(t)}catch{e=!1}return e||Tr.error(`localStorage unsupported; falling back to cookie store`),Cse=e,e},Pt(e){Tr.error(`localStorage error: `+e)},Ot(e){try{return wn?.localStorage.getItem(e)}catch(e){Ci.Pt(e)}return null},Dt(e){try{return JSON.parse(Ci.Ot(e))||{}}catch{}return null},At(e,t){try{return wn?.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Ci.Pt(e)}return!1},Lt(e){try{wn?.localStorage.removeItem(e)}catch(e){Ci.Pt(e)}}},wse=[qr,Br,zr,Vr,Hr,Ur,$r,Qr,Xr],wi=[Mr,jr,Rr,Doe,ri,ni,Fr,ei],Ti=e=>e+`_cpm`,Tse=[`__proto__`,`constructor`,`prototype`],Ese=e=>{if(!Bn(e))return{};let t={};return Object.keys(e).forEach(n=>{Tse.indexOf(n)===-1&&(t[n]=e[n])}),t},Dse=(e,t=[])=>{let n={};return[...wi,...t].forEach(t=>{let r=e[t];Hn(r)||Gn(r)||r===``||(n[t]=r)}),n},Ose=e=>{let t=5381,n=2166136261;for(let r=0;e.length>r;r++){let i=e.charCodeAt(r);t=33*t^i,n=Math.imul(n^i,16777619)}return e.length.toString(36)+`.`+(t>>>0).toString(36)+`.`+(n>>>0).toString(36)},kse=(e,t)=>({p:t,f:Ose(JSON.stringify(e))}),Ase=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{let n=Si.Dt(Ti(e)),r=n?.f===Ose(t)&&Rn(n.p);return{properties:r?n.p:[],isValid:r}}catch{return{properties:[],isValid:!1}}},jse=(e,t)=>t+`|`+(Si.Ot(Ti(e))||``),Ei={},Mse={Et:()=>!0,Pt(e){Tr.error(`memoryStorage error: `+e)},Ot:e=>e in Ei?Ei[e]:null,Dt:e=>e in Ei?Ei[e]:null,At:(e,t)=>(Ei[e]=t,!0),Lt(e){delete Ei[e]}},Di=null,Oi={Et(){if(!Gn(Di))return Di;if(Di=!0,Hn(wn))Di=!1;else try{let e=`__support__`;Oi.At(e,`xyz`),Oi.Ot(e)!==`"xyz"`&&(Di=!1),Oi.Lt(e)}catch{Di=!1}return Di},Pt(e){Tr.error(`sessionStorage error: `,e)},Ot(e){try{return wn?.sessionStorage.getItem(e)}catch(e){Oi.Pt(e)}return null},Dt(e){try{return JSON.parse(Oi.Ot(e))||null}catch{}return null},At(e,t){try{return wn?.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Oi.Pt(e)}return!1},Lt(e){try{wn?.sessionStorage.removeItem(e)}catch(e){Oi.Pt(e)}}},Nse=class{constructor(e){this._instance=e}get Rr(){return this._instance.config}get consent(){return this.Lo()?0:this.No}isOptedOut(){return this.Rr.cookieless_mode===`always`||this.isRejected()||this.consent===-1&&this.Rr.cookieless_mode===`on_reject`}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Rr.opt_out_capturing_by_default}optInOut(e){this.qo.At(this.jo,+!!e,this.Rr.cookie_expiration,this.Rr.cross_subdomain_cookie,this.Rr.secure_cookie)}reset(){this.qo.Lt(this.jo,this.Rr.cross_subdomain_cookie)}get jo(){let{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:`__ph_opt_in_out_`+e)}get No(){let e=this.qo.Ot(this.jo);return $n(e)?1:Fn(kre,e)?0:-1}get qo(){let e=this.Rr.opt_out_capturing_persistence_type,t=e===`localStorage`?Ci:Si,n=t.Et()?t:Mse;if(!this.Bo||this.Bo!==n){this.Bo=n;let t=e===`localStorage`?Si:Ci;t.Ot(this.jo)&&(this.Bo.Ot(this.jo)||this.optInOut($n(t.Ot(this.jo))),t.Lt(this.jo,this.Rr.cross_subdomain_cookie))}return this.Bo}Lo(){return!!this.Rr.respect_dnt&&[En?.doNotTrack,En?.msDoNotTrack,Mn.doNotTrack,En?.globalPrivacyControl].some(e=>$n(e))}};function Pse(e,t){var n;let r=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!zn(r))return t;try{let e=r(t);return Un(e)&&e?e:t}catch(e){return Tr.error(`Error in get_current_url, falling back to window.location.href`,e),t}}function Fse(e){return e instanceof Element&&(e.id===`__POSTHOG_TOOLBAR__`||!!e.closest?.call(e,`.toolbar-global-fade-container`))}function ki(e){return!!e&&e.nodeType===1}function Ai(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Ise(e){return!!e&&e.nodeType===3}function Lse(e){return!!e&&e.nodeType===11&&ki(e.host)}function Rse(e){return e?In(e).split(/\s+/):[]}function zse(e,t){let n=function(e){var t;let n=wn==null||(t=wn.location)==null?void 0:t.href;return Hn(n)?void 0:Pse(e,n)}(t);return!!(n&&e&&e.some(e=>n.match(e)))}function ji(e){let t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return Rse(t)}function Bse(e){return Kn(e)?null:In(e).split(/(\s+)/).filter(e=>Ii(e)).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function Mi(e){let t=``;return Pi(e)&&!Fi(e)&&e.childNodes&&e.childNodes.length&&fi(e.childNodes,function(e){Ise(e)&&e.textContent&&(t+=Bse(e.textContent)??``)}),In(t)}function Ni(e){return Hn(e.target)?e.srcElement||null:e.target?.shadowRoot?e.composedPath()[0]||null:e.target||null}var Vse=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function Hse(e,t){let n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!n&&n.call(e,t)}catch{return!1}}function Use(e,t){if(Hn(t))return!0;for(let n of e)if(t.some(e=>Hse(n,e)))return!0;return!1}function Wse(e){let t=e.parentNode;return!(!t||!ki(t))&&t}var Gse=[`.ph-no-autocapture`,`[data-ph-no-autocapture]`],Kse=[`next`,`previous`,`prev`,`>`,`<`],qse=[...Kse,`+`,`-`,`−`,`–`],Jse=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Yse=[`.ph-no-rageclick`,`.ph-no-capture`],Xse=[``,`text`,`search`,`email`,`password`,`url`,`tel`,`number`];function Zse(e,t){if(!wn||Qse(e))return!1;let n,r,i;var a;if(Yn(t)?(n=!!t&&Yse,r=void 0,i=!1):(n=t?.css_selector_ignorelist??Yse,r=t?.content_ignorelist,i=(a=t?.ignore_text_selection)!=null&&a),!1===n||i&&function(e){return!(!e||!ki(e))&&(!!Ai(e,`textarea`)||(Ai(e,`input`)?Fn(Xse,(e.getAttribute(`type`)||``).toLowerCase()):function(e){if(e.isContentEditable)return!0;let t=e.getAttribute?.call(e,`contenteditable`);return t===`true`||t===``}(e)))}(e))return!1;let{targetElementList:o}=$se(e,!1);return!function(e,t){if(!1===e||Hn(e))return!1;let n;if(!0===e)n=Kse;else{if(!Rn(e))return!1;if(e.length>10)return Tr.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map(e=>e.toLowerCase())}return t.some(({safeText:e,ariaLabel:t})=>n.some(n=>Jse(e,n)||Jse(t,n)))}(r,o.map(e=>({safeText:Mi(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``})))&&!Use(o,n)}var Qse=e=>!e||Ai(e,`html`)||!ki(e),$se=(e,t)=>{if(!wn||Qse(e))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1,r=[e],i=e;for(;i.parentNode&&!Ai(i,`body`);){if(Lse(i.parentNode)){r.push(i.parentNode.host),i=i.parentNode.host;continue}let e=Wse(i);if(!e)break;if(t||Vse.indexOf(e.tagName.toLowerCase())>-1)n=!0;else try{let t=wn.getComputedStyle(e);t&&t.getPropertyValue(`cursor`)===`pointer`&&(n=!0)}catch{}r.push(e),i=e}return{parentIsUsefulElement:n,targetElementList:r}};function Pi(e){let t=new Set,n=0;for(let r=e;r.parentNode&&!Ai(r,`body`);r=r.parentNode){if(n++>=1e3||t.has(r))return!1;t.add(r);let e=ji(r);if(Fn(e,`ph-sensitive`)||Fn(e,`ph-no-capture`))return!1}if(Fn(ji(e),`ph-include`))return!0;let r=e.type||``;if(Un(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}let i=e.name||e.id||``;return!Un(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,``))}function Fi(e){return!!(Ai(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||Ai(e,`select`)||Ai(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var ece=RegExp(`^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$`),tce=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,nce=[16,15,14,13],rce=RegExp(`^(\\d{3}-?\\d{2}-?\\d{4})$`),ice=RegExp(`(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))`,`g`),ace=/[0-9A-Za-z_]/;function oce(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let i=e.charCodeAt(r)-48;n&&(i*=2,i>9&&(i-=9)),t+=i,n=!n}return t%10==0}function Ii(e,t=!0){return!(Kn(e)||Un(e)&&(e=In(e),(t?ece.test((e||``).replace(/[- ]/g,``)):function(e){let t;for(tce.lastIndex=0;t=tce.exec(e);){let e=t[2];if(!e)continue;let n=e.replace(/[- ]/g,``);for(let e=0;n.length>e;e++)for(let t of nce){let r=e+t;if(n.length>=r){let t=n.slice(e,r);if(ece.test(t)&&oce(t))return!0}}}return!1}(e))||(t?rce.test(e):function(e){let t;for(ice.lastIndex=0;t=ice.exec(e);){let e=t[1],n=t[3];if(!(e&&n&&ace.test(e)&&ace.test(n)))return!0}return!1}(e))))}function sce(e){let t=Mi(e);return t=`${t} ${cce(e)}`.trim(),Ii(t)?t:``}function cce(e){let t=``;return e&&e.childNodes&&e.childNodes.length&&fi(e.childNodes,function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{let n=Mi(e);t=`${t} ${n}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${cce(e)}`.trim())}catch(e){Tr.error(`[AutoCapture]`,e)}}),t}function lce(e){return e.replace(/"|\\"/g,`\\"`)}function uce(e){let t=e.attr__class;if(t)return Rn(t)?t:Rse(t)}var Li=Er(`[Dead Clicks]`),dce=()=>!0,fce=e=>{let t=!!e.instance.persistence?.get_property(_oe),n=e.instance.config.capture_dead_clicks;return Yn(n)?n:!!Bn(n)||t},pce=class{get lazyLoadedDeadClicksAutocapture(){return this.Ho}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;`captureDeadClicks`in t&&(this.instance.persistence&&this.instance.persistence.register({[_oe]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.zo(()=>{this.Uo()}):this.stop()}zo(e){var t,n;Mn.__PosthogExtensions__?.initDeadClicksAutocapture?e():(t=Mn.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this.instance,`dead-clicks-autocapture`,t=>{t?Li.error(`failed to load script`,t):e()})}Uo(){if(Dn){if(!this.Ho&&Mn.__PosthogExtensions__?.initDeadClicksAutocapture){let e=Bn(this.instance.config.capture_dead_clicks)?R({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Ho=Mn.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Ho.start(Dn),Li.info(`starting...`)}}else Li.error("`document` not found. Cannot start.")}stop(){this.Ho&&(this.Ho.stop(),this.Ho=void 0,Li.info(`stopping...`))}},Ri=Er(`[SegmentIntegration]`);function mce(e,t,n=!0){let r=e.config.segment;if(!r)return t();let{analytics:i,filterProperties:a}=(e=>zn(e.register))(o=r)?{analytics:o}:o;var o;(function(e,t,n,r){let i=t=>{let i=()=>t.anonymousId()||yi();e.config.get_device_id=i,r&&t.id()&&(e.register({distinct_id:t.id(),$device_id:i()}),e.persistence.set_property(ei,si)),n(r?void 0:t.anonymousId()||void 0)},a=t.user();`then`in a&&zn(a.then)?a.then(i):i(a)})(e,i,n=>{i.register(((e,t,{filterProperties:n}={})=>{typeof Promise<`u`&&Promise.resolve||Ri.warn(`This browser does not have Promise support, and can not use the segment integration`);let r=(r,i)=>{if(!i)return r;let a=!!t&&r.event.anonymousId===t&&!r.event.userId;a||r.event.userId||r.event.anonymousId===e.get_distinct_id()||(Ri.info(`No userId set, resetting PostHog`),e.reset()),a||(t=void 0),r.event.userId&&r.event.userId!==e.get_distinct_id()&&(Ri.info(`UserId set, identifying with PostHog`),e.identify(r.event.userId));let o=e.calculateEventProperties(i,r.event.properties);if(!Kn(n)){let e=r.event.properties||{},t={};for(let n of Object.keys(o))Cre.call(e,n)||(t[n]=o[n]);let i=((e,t)=>{let n=Rn(e)?e:[e],r=R({},t);for(let e of n)try{if(r=e(r),Kn(r))return null}catch(e){return Ri.error(`Error in Segment filterProperties:`,e),null}return r})(n,t);if(Kn(i))return r;o=i}return r.event.properties=Object.assign({},o,r.event.properties),r};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded(){return!0},load(){return Promise.resolve()},track(e){return r(e,e.event.event)},page(e){return r(e,ui)},identify(e){return r(e,use)},screen(e){return r(e,`$screen`)}}})(e,n,{filterProperties:a})).then(()=>{t()},e=>{Ri.error(`Failed to register the Segment integration`,e),t()})},n)}var hce=`posthog-js`;function gce(e,{organization:t,projectId:n,prefix:r,severityAllowList:i=[`error`],sendExceptionsToPostHog:a=!0}={}){return o=>{if(i!==`*`&&!i.includes(o.level)||!e.__loaded)return o;o.tags||={};let s=e.requestRouter.endpointFor(`ui`,`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags[`PostHog Person URL`]=s,e.sessionRecordingStarted()&&(o.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));let c=o.exception?.values||[],l=c.map(e=>R(R({},e),{},{stacktrace:e.stacktrace?R(R({},e.stacktrace),{},{type:`raw`,frames:(e.stacktrace.frames||[]).map(e=>R(R({},e),{},{platform:`web:javascript`}))}):void 0})),u={$exception_message:c[0]?.value||o.message,$exception_type:c[0]?.type,$exception_level:o.level,$exception_list:l,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:c[0]?.value||o.message,$sentry_exception_type:c[0]?.type,$sentry_tags:o.tags};var d;return t&&n&&(u.$sentry_url=(r||`https://sentry.io/organizations/`)+t+`/issues/?project=`+n+`&query=`+o.event_id),a&&((d=e.exceptions)==null||d.sendExceptionEvent(u)),o}}var _ce=class{constructor(e,t,n,r,i,a){this.name=hce,this.setupOnce=function(o){o(gce(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},vce=class{constructor(e){this.Wo=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength||n.crossTabAdoption)&&(Tr.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.Vo=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Go()}Go(){this.Zo=this._instance.sessionManager?.onSessionId(this.Wo)}destroy(){var e;(e=this.Zo)==null||e.call(this),this.Zo=void 0}doPageView(e,t){let n=this.Qo(e,t);return this.Vo={pathname:wn?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this.Qo(e,this.Vo?.pageViewId)}doEvent(){return{$pageview_id:this.Vo?.pageViewId}}Qo(e,t){let n=this.Vo;if(!n)return{$pageview_id:t};let r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:n,maxContentHeight:a,lastContentY:o,maxContentY:s}=i;if(!(Hn(e)||Hn(t)||Hn(n)||Hn(a)||Hn(o)||Hn(s))){e=Math.ceil(e),t=Math.ceil(t),n=Math.ceil(n),a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s);let i=e>1?tr(t/e,0,1,Tr):1,c=e>1?tr(n/e,0,1,Tr):1,l=a>1?tr(o/a,0,1,Tr):1,u=a>1?tr(s/a,0,1,Tr):1;r=pi(r,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:i,$prev_pageview_max_scroll:n,$prev_pageview_max_scroll_percentage:c,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:l,$prev_pageview_max_content:s,$prev_pageview_max_content_percentage:u})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},zi=[`flags`,`surveys`],yce={[ooe]:{exposure:`hidden`},[Pr]:{exposure:`hidden`},[soe]:{exposure:`hidden`},[uoe]:{exposure:`hidden`},[Fr]:{exposure:`hidden`},[Ir]:{exposure:`hidden`},[doe]:{exposure:`event`},[foe]:{exposure:`hidden`},[yoe]:{exposure:`hidden`},[poe]:{exposure:`event`},[moe]:{exposure:`hidden`},[hoe]:{exposure:`event`},[goe]:{exposure:`event`},[_oe]:{exposure:`event`},[voe]:{exposure:`hidden`},[boe]:{exposure:`event`},[Lr]:{exposure:`hidden`},[xoe]:{exposure:`hidden`},[Rr]:{exposure:`hidden`},[Doe]:{exposure:`event`},[Soe]:{exposure:`event`,shouldSkipFromEventProperties:e=>Gn(e)},[Ooe]:{exposure:`event`},[koe]:{exposure:`event`},[Aoe]:{exposure:`event`},[joe]:{exposure:`event`},[Moe]:{exposure:`hidden`},[zr]:{exposure:`hidden`,storageGroup:`flags`},[Br]:{exposure:`hidden`,storageGroup:`flags`},[Noe]:{exposure:`hidden`},[Vr]:{exposure:`hidden`,storageGroup:`flags`},[Hr]:{exposure:`hidden`,storageGroup:`flags`},[Ur]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[Wr]:{exposure:`hidden`,storageGroup:`flags`},[Gr]:{exposure:`hidden`},[Kr]:{exposure:`hidden`},[qr]:{exposure:`hidden`},[Jr]:{exposure:`hidden`},[Foe]:{exposure:`hidden`,storageGroup:`surveys`},[Yr]:{exposure:`hidden`,storageGroup:`surveys`,volatile:!0},[Ioe]:{exposure:`event`},[Loe]:{exposure:`hidden`},[Roe]:{exposure:`hidden`},[zoe]:{exposure:`hidden`},[Boe]:{exposure:`hidden`},[Voe]:{exposure:`hidden`},[Hoe]:{exposure:`event`},[Uoe]:{exposure:`event`},[Woe]:{exposure:`event`},[Goe]:{exposure:`event`},[Xr]:{exposure:`hidden`},[Zr]:{exposure:`hidden`},[Poe]:{exposure:`event`},[Qr]:{exposure:`hidden`},[$r]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[ei]:{exposure:`hidden`},[ti]:{exposure:`hidden`},[Koe]:{exposure:`hidden`},[qoe]:{exposure:`hidden`},[Joe]:{exposure:`hidden`},[ni]:{exposure:`hidden`},[ri]:{exposure:`hidden`},[Coe]:{exposure:`event`},[woe]:{exposure:`event`},[Toe]:{exposure:`event`},[Eoe]:{exposure:`event`},[Xoe]:{exposure:`event`},[Zoe]:{exposure:`event`},[Qoe]:{exposure:`event`},[$oe]:{exposure:`event`},[ese]:{exposure:`event`},[tse]:{exposure:`event`},[nse]:{exposure:`event`},[rse]:{exposure:`event`},[ise]:{exposure:`event`},[ase]:{exposure:`event`},[ose]:{exposure:`event`},[sse]:{exposure:`event`}},bce=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],Bi=e=>{let t=yce[e];if(t)return t;for(let[t,n]of bce)if(e.indexOf(t)===0)return n},Vi=(e,t)=>{try{let n;return JSON.stringify(e,(e,t)=>Zn(t)?(n??=new WeakMap,n.has(t)||n.set(t,pse(t)),n.get(t)):typeof t==`bigint`?t.toString():t,t)}catch{return xre(e)}},Hi=e=>{let t=Dn?.createElement(`a`);return Hn(t)?null:(t.href=e,t)},Ui=function(e,t){let n=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),r;for(let e=0;n.length>e;e++){let i=n[e].split(`=`);if(i[0]===t){r=i;break}}if(!Rn(r)||2>r.length)return``;{let e=r[1];try{e=decodeURIComponent(e)}catch{Tr.error(`Skipping decoding for malformed query param: `+e)}return e.replace(/\+/g,` `)}},Wi=function(e,t,n){if(!e||!t||!t.length)return e;let r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[];for(let e=0;c.length>e;e++){let r=c[e].split(`=`);Rn(r)&&(t.includes(r[0])?l.push(r[0]+`=`+n):l.push(c[e]))}let u=s;return o!=null&&(u+=`?`+l.join(`&`)),i!=null&&(u+=`#`+i),u},Gi=function(e,t){let n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},xce=(e,t)=>e>=t&&hre(),Sce=(e,t,n,r)=>{if(e===0){if(hre()){let e=t+1;return e===n&&r(),e}return t}return 0},Ki=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],Cce=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...Ki],qi=`<masked>`,wce=[`li_fat_id`];function Tce(e,t,n){if(!Dn)return{};let r=t?[...Ki,...n||[]]:[],i=Ece(Wi(Dn.URL,r,qi),e);return pi(function(){let e={};return fi(wce,function(t){let n=vi(t);e[t]=n||null}),e}(),i)}function Ece(e,t){let n=Cce.concat(t||[]),r={};return fi(n,function(t){let n=Ui(e,t);r[t]=n||null}),r}function Dce(e){let t=function(e){return e?e.search(`https?://(.*)google.([^/?]*)`)===0?`google`:e.search(`https?://(.*)bing.com`)===0?`bing`:e.search(`https?://(.*)yahoo.com`)===0?`yahoo`:e.search(`https?://(.*)duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,r={};if(!Gn(t)){r.$search_engine=t;let e=Dn?Ui(Dn.referrer,n):``;e.length&&(r.ph_keyword=e)}return r}function Oce(){return navigator.language||navigator.userLanguage}function kce(){let e=Oce();return typeof e==`string`?e.split(`-`)[0]:void 0}var Ji=`$direct`;function Ace(){return Dn?.referrer||Ji}function jce(e,t,n=!1){let r=e?[...Ki,...t||[]]:[],i=(n?hr(On?.href):On?.href)?.substring(0,1e3);return{r:Ace().substring(0,1e3),u:i?Wi(i,r,qi):void 0}}function Mce(e,t=!1){let{r:n,u:r}=e,i=t?hr(r):r,a={$referrer:n,$referring_domain:n==null?void 0:n==Ji?Ji:Hi(n)?.host};if(i){a.$current_url=i;let e=Hi(i);a.$host=e?.host,a.$pathname=e?.pathname,pi(a,Ece(i))}return n&&pi(a,Dce(n)),a}function Nce(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Pce(){try{return new Date().getTimezoneOffset()}catch{return}}var Fce={flags:$r,surveys:Yr},Ice=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Yi=e=>`${e}_cookie_identity_change_pending`,Xi=e=>{let t=``,n=0;for(let r of e){let e=encodeURIComponent(JSON.stringify(r).slice(1,-1)).length;if(n+e>1e3)break;t+=r,n+=e}return t},Zi=`main`,Qi=[zr,Br,Vr,Hr,Ur,$r,Wr,qr],Lce=e=>Qi.indexOf(e)!==-1,Rce=[Fr,Ir],zce=e=>Rce.indexOf(e)!==-1,$i=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},ea=e=>{if(!e)return{};let t=JSON.parse(e);return Bn(t)?t:{}},Bce=(e,t)=>{fi(e,(n,r)=>{let i=Bi(r);i&&i.exposure!==`event`||{}.hasOwnProperty.call(t,r)||delete e[r]})},Vce=class{constructor(e,t,n=!0){if(this.Jo={},this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=!1,this.ea=!1,this.ia=new Map,this.na=!1,this.sa=!1,this.ra=!1,this.oa=new Set,this.aa=new Set,this.Rr=e,this.la=n,this.props={},this.ua=void 0,this.ha=(e=>{let t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(e),this.qo=this.ca(e),this.Yo=this.da(e),this.load(),this.va(),e.debug&&Tr.info(`Persistence loaded`,e.persistence,R({},this.props)),this.update_config(e,e,t),this.save(),wn){let e=()=>this.flush();gi(wn,`beforeunload`,e,{capture:!1}),gi(wn,`pagehide`,e,{capture:!1}),this.fa=e=>{if(this.Ko&&(!e.storageArea||e.storageArea===wn?.localStorage)&&e.key){if(e.key!==this.ha){if(this.Yo){let t=zi.find(t=>e.key===this.pa(t));t&&this.ga(e.key,t)}}else this.ga(e.key,Zi)}},gi(wn,`storage`,this.fa)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{let n=this.ia.get(e);if(!Lce(e)||!0===n)return;if(!0===t)return void this.ma(e,!0);let r=new Set(n||[]);t.forEach(e=>r.add(e)),r.size&&this.ma(e,r)})}onCrossTabFeatureFlagChange(e){return this.aa.add(e),()=>this.aa.delete(e)}destroy(){this.fa&&wn&&(wn.removeEventListener(`storage`,this.fa),this.fa=void 0),this.aa.clear()}ga(e,t,n=!0){if(this.mi)return!1;let r,i;try{if(i=Ci.Ot(e),Gn(i)){let e=this.ya(t);return e.storageValue=null,t!==Zi&&(e.persisted=!1),!1}r=ea(i)}catch{return!1}let a=t===Zi?r:Ci.Dt(this.ha);if(a&&this.ba(a))return!1;let o=this._a(r,t,n);return t===Zi&&this.Yo&&!$i(this.wa().main,r)||this.ka(r,t,!0,i),o}ba(e){let t=this.props[jr],n=e[jr];return!Hn(t)&&!Hn(n)&&t!==n}ka(e,t,n,r){let i=this.ya(t);i.storageValue=r,t!==Zi&&(i.persisted=n);try{i.fingerprint=this.Sa(e,t)}catch{i.fingerprint=void 0}}_a(e,t,n){let r=!1;return Qi.forEach(n=>{let i=Bi(n)?.storageGroup;if(t===Zi&&this.Yo&&i||t!==Zi&&i!==t)return;let a=n in e,o=this.xa(n,a?e[n]:void 0),s=this.ia.has(n)?n in this.props:a;s===n in this.props&&$i(o,this.props[n])||(s?this.Ca(n,o,!1):this.$a(n,!1),r=!0)}),r&&n&&this.aa.forEach(e=>e()),r}Ta(){if(!this.Ko)return!1;try{this.ra=!1;let e=Ci.Ot(this.ha),t=this.ya(Zi),n,r=!1,i=!1;if(e!==t.storageValue){if(Gn(e))t.storageValue=null;else{if(n=ea(e),this.ra=!this.sa&&this.ba(n),this.ra)return!1;i=this._a(n,Zi,!1),!this.Yo||$i(this.wa().main,n)?this.ka(n,Zi,!0,e):t.storageValue=e,r=!0}}return this.Yo&&zi.forEach(e=>{let t=Ci.Ot(this.pa(e)),a=this.ya(e),o=n||{},s=r&&Qi.some(t=>Bi(t)?.storageGroup===e&&t in o);if(t===a.storageValue&&!s)return;if(Gn(t))return a.storageValue=null,a.persisted=!1,void(s&&(i=this._a(o,e,!1)||i));let c=ea(t);i=this._a(c,e,!1)||i,this.ka(c,e,!0,t)}),i}catch{return!1}}ma(e,t){this.ia.set(e,t);let n=Bi(e);n!=null&&n.volatile||(this.ya((this.Yo?n?.storageGroup:void 0)||Zi).fingerprint=void 0,this.Ia(e))}Ma(){Qi.forEach(e=>this.ia.set(e,!0))}va(){if(this.Ko)try{let e=Ci.Ot(this.ha),t=ea(e);this.ya(Zi).storageValue=e,Qi.forEach(e=>{let n=this.Yo?Bi(e)?.storageGroup:void 0,r=n?Ci.Ot(this.pa(n)):null;if(n){let e=this.ya(n);e.storageValue=r,e.persisted=!Gn(r)}let i=n&&!Gn(r)?ea(r):t;e in this.props?this.Ea(e,i[e],this.props[e]):e in i&&this.ma(e,!0)})}catch{}}xa(e,t){let n=this.ia.get(e);if(!n)return t;if(!0===n)return this.props[e];if(e===`$active_feature_flags`){let r=new Set(Rn(t)?t:[]),i=new Set(Rn(this.props[e])?this.props[e]:[]);return n.forEach(e=>i.has(e)?r.add(e):r.delete(e)),Array.from(r)}let r=Bn(t)?R({},t):{},i=Bn(this.props[e])?this.props[e]:{};return n.forEach(e=>{e in i?r[e]=i[e]:delete r[e]}),r}Ea(e,t,n){if(!Lce(e))return;let r=this.ia.get(e);if(!0===r)return;let i=t;if(this.Ko)try{let t=this.Yo?Bi(e)?.storageGroup:void 0,n=t?this.pa(t):this.ha;i=ea(Ci.Ot(n))[e]}catch{}let a=new Set(r||[]);if(e===`$active_feature_flags`){if(!Hn(t)&&!Rn(t)||!Hn(i)&&!Rn(i)||!Rn(n))return void this.ma(e,!0);let r=new Set(t||[]),o=new Set(i||[]),s=new Set(n);new Set([...r,...s]).forEach(e=>{r.has(e)!==s.has(e)&&a.add(e)}),a.forEach(e=>{o.has(e)===s.has(e)&&a.delete(e)})}else{if(!Bn(n))return void($i(i,n)?this.ia.delete(e):this.ma(e,!0));{if(!Hn(t)&&!Bn(t)||Hn(t)&&Vn(n)&&Hn(i))return void this.ma(e,!0);let r=Bn(t)?t:{},o=Bn(i)?i:{};new Set([...Object.keys(r),...Object.keys(n)]).forEach(e=>{e in r==e in n&&$i(r[e],n[e])||a.add(e)}),a.forEach(e=>{e in o==e in n&&$i(o[e],n[e])&&a.delete(e)})}}a.size?this.ma(e,a):this.ia.delete(e)}Pa(){let e=this.Rr?.persistence_save_debounce_ms;return qn(e)&&e>0?e:0}Ra(e){if(this.Rr.cookieWinsOnConflict&&this.Rr.persistence.toLowerCase()===`localstorage+cookie`){if(e)try{let t=Dse(e,this.Rr.cookie_persisted_properties||[]),n=kse(t,this.Rr.cookie_persisted_properties||[]),r=JSON.stringify(t)+`|`+JSON.stringify(n),i=Si.Ot(this.ha)||void 0;i&&jse(this.ha,i)===r&&(this.Aa=r,this.Fa=i)}catch{}else try{let e=Si.Ot(this.ha)||void 0;this.Aa=e?jse(this.ha,e):void 0,this.Fa=e}catch{}}}syncCookieProperties(){return this.Oa(this.Rr)}Oa(e,t=!1){if(this.mi&&!t||this.ea||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!==`localstorage+cookie`)return!1;let n;try{n=Si.Ot(this.ha)||void 0}catch{}if(!n||n===this.Fa)return!1;let r=jse(this.ha,n),i;try{i=Ese(JSON.parse(n))}catch{return!1}if((Si.Ot(this.ha)||void 0)!==n)return!1;this.Aa=r,this.Fa=n;let a=Ase(this.ha,n),o=[...wi,...a.properties],s={};if(Object.keys(i).forEach(e=>{let t=i[e];(Hn(t)||Gn(t)||t===``||e===`$user_state`&&t!==`anonymous`&&t!==`identified`)&&(s[e]=!0,delete i[e])}),Vn(i))return!1;let c=`distinct_id`in i||i.$user_state===`anonymous`||i.$user_state===`identified`,l=this.props,u=l[jr],d=l[ei],f=pi({},l);[...wi,...e.cookie_persisted_properties||[]].forEach(e=>{if(o.indexOf(e)!==-1&&!(e in i)&&!s[e]&&(c||e!==`distinct_id`&&e!==`$user_state`)){let t=f[e];(a.isValid||wi.indexOf(e)===-1||!1!==t&&t!==0)&&delete f[e]}}),this.props=pi(f,i),Qi.forEach(e=>{let t=e in this.props;e in l===t&&$i(l[e],this.props[e])||(t?this.Ea(e,l[e],this.props[e]):this.ma(e,!0))}),!c||`$user_state`in i||`$user_state`in this.props||this.Ca(ei,oi);let p=this.props[jr],m=this.props[ei];return!c||p===u&&m===d||(this.sa=!0,this.ta=!0,Oi.At(Yi(this.ha),!0),this.$a(qr),this.$a(Br),this.$a(zr),this.$a(Vr),this.$a(Hr),this.$a(Ur),this.$a($r),this.$a(Qr),this.$a(Xr),m!==`anonymous`||d!==`identified`&&i.$user_state!==`anonymous`&&(Hn(u)||p===u)||(Bce(this.props,i),this.$a(Jr)),m===`identified`?this.props.$user_id=p:delete this.props.$user_id,this.$a(Pr)),!0}consumeCookieIdentityChange(){let e=Yi(this.ha),t=this.ta||!!Oi.Ot(e);return this.ta=!1,t&&Oi.Lt(e),t}Da(e=!1){return!(this.ea||this.mi&&!e||!this.Rr.cookieWinsOnConflict||this.Rr.persistence.toLowerCase()!==`localstorage+cookie`||(this.ea=!0,0))}La(){this.ea&&(Hn(this.Na)||(clearTimeout(this.Na),this.Na=void 0),delete this.Jo[Zi],this.qa(!0))}ja(e=!0){if(this.ea)try{e?this.La():Hn(this.Na)||(clearTimeout(this.Na),this.Na=void 0)}finally{this.ea=!1}}isDisabled(){return!!this.mi}ca(e){Ice.indexOf(e.persistence.toLowerCase())===-1&&(Tr.critical(`Unknown persistence type `+e.persistence+`; falling back to localStorage+cookie`),e.persistence=`localStorage+cookie`);let t=((e=[],t=!1)=>{let n=[...wi,...e];return R(R({},Ci),{},{Dt(e){try{let r,i={};try{r=Si.Ot(e)||void 0,i=r?Ese(JSON.parse(r)):{}}catch{}let a=JSON.parse(Ci.Ot(e)||`{}`),o;if(t){let t=Ase(e,r),s=[...wi,...t.properties],c={};Object.keys(i).forEach(e=>{let t=i[e];Gn(t)||t===``||e===`$user_state`&&t!==`anonymous`&&t!==`identified`||(c[e]=t)});let l=`distinct_id`in c||c.$user_state===`anonymous`||c.$user_state===`identified`;if(Object.keys(c).length>0){let e=a[jr],r=a.$user_state??oi;n.forEach(e=>{if(s.indexOf(e)!==-1&&!(e in i)&&(l||e!==`distinct_id`&&e!==`$user_state`)){let n=a[e];(t.isValid||wi.indexOf(e)===-1||!1!==n&&n!==0)&&delete a[e]}}),!l||`$user_state`in i||`$user_state`in a||(a[ei]=oi),!l||(`distinct_id`in c?c[jr]:a[jr])===e&&(`$user_state`in c?c[ei]:a[ei])===r||(wse.forEach(e=>delete a[e]),c.$user_state===`identified`&&`distinct_id`in c?a.$user_id=c[jr]:delete a.$user_id,c.$user_state!==`identified`&&(delete a[Poe],delete a[Jr]),delete a.__alias)}o=pi(a,c)}else o=pi(i,a);return Ci.At(e,o),o}catch{}return null},At(n,r,i,a,o,s){let c=Ci.At(n,r,void 0,void 0,s);try{let l=Dse(r,e);if(Object.keys(l).length){if(t){let t=Ti(n),u=kse(l,e);if(Si.At(t,u,i,a,o,s),Si.Ot(t)!==JSON.stringify(u)){Si.Lt(t,a);let e=Dse(r);return Si.At(n,e,i,a,o,s),c}}Si.At(n,l,i,a,o,s)}}catch(e){Ci.Pt(e)}return c},Lt(e,t){try{wn?.localStorage.removeItem(e),Si.Lt(e,t),Si.Lt(Ti(e),t)}catch(e){Ci.Pt(e)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),n,r=!1,i=!1,a=e.persistence.toLowerCase();return a===`localstorage`&&Ci.Et()?(n=Ci,i=!0):a===`localstorage+cookie`&&t.Et()?(n=t,i=!0,r=!0):a===`sessionstorage`&&Oi.Et()?n=Oi:a===`memory`?n=Mse:a===`cookie`&&Si.Et()?(n=Si,r=!0):t.Et()?(n=t,i=!0,r=!0):Si.Et()?(n=Si,r=!0):n=Mse,this.Ko=i,this.Xo=r,n}pa(e){return`${this.ha}__${e}`}da(e){return this.Ko&&!!e.split_storage}properties(){let e={};return fi(this.props,(t,n)=>{let r=Bi(n);if(!r||r.exposure===`event`){var i;if(r!=null&&(i=r.shouldSkipFromEventProperties)!=null&&i.call(r,t))return;e[n]=t}}),e}load(e=!1){if(this.mi&&!e)return;let t=this.Rr.cookieWinsOnConflict&&this.Rr.persistence.toLowerCase()===`localstorage+cookie`,n=t?Ci.Dt(this.ha):null,r={};if(t)try{r=Ese(Si.Dt(this.ha)),fi(r,(e,t)=>{(Hn(e)||Gn(e)||e===``)&&delete r[t]})}catch{}let i=this.qo.Dt(this.ha);if(i&&(this.props=pi({},i)),this.Yo&&this.Ba(),t&&i){let e=n?.[jr],t=n?.$user_state??oi,a=i[jr],o=i.$user_state??oi;if(a!==e||o!==t){this.ta=!0,Oi.At(Yi(this.ha),!0);let n=pi({},this.props);wse.forEach(e=>delete n[e]),o!==`anonymous`||t!==`identified`&&r.$user_state!==`anonymous`&&(Hn(e)||a===e)||(Bce(n,r),delete n[Jr]),this.props=n;let i=new Set;wse.forEach(e=>{let t=Bi(e)?.storageGroup;t&&i.add(t)}),i.forEach(e=>{let t={};fi(this.props,(n,r)=>{Bi(r)?.storageGroup===e&&(t[r]=n)}),Vn(t)?(Ci.Lt(this.pa(e)),this.Jo[e]={}):Ci.At(this.pa(e),t)&&(this.Jo[e]={persisted:!0,fingerprint:this.Sa(t,e)})})}}Oi.Ot(Yi(this.ha))&&(this.ta=!0)}Ba(){for(let e of zi){let t=Ci.Dt(this.pa(e));if(t&&!Vn(t)){let n=this.ya(e);n.persisted=!0,this.Ha(e)||(n.fingerprint=this.Sa(t,e)),this.za(e,t)||pi(this.props,t)}}}Ha(e){return Object.keys(this.props).some(t=>Bi(t)?.storageGroup===e)}za(e,t){let n=Fce[e];if(!n)return!1;let r=t[n],i=this.props[n];return qn(r)&&qn(i)&&i>r}refreshKey(e){if(this.mi||this.oa.has(e))return;let t=this.Yo?Bi(e)?.storageGroup:void 0,n=t?Ci.Dt(this.pa(t)):this.qo.Dt(this.ha);if(n&&e in n)this.Ca(e,n[e],!1);else{if(t){let t=this.qo.Dt(this.ha);if(t&&e in t)return void this.Ca(e,t[e],!1)}this.$a(e,!1)}}save(){if(this.mi)return;let e=this.Pa();e>0?Hn(this.Na)&&(this.Na=setTimeout(()=>{this.Na=void 0,this.qa()},e)):this.qa()}flush(){Hn(this.Na)||(clearTimeout(this.Na),this.Na=void 0,this.qa())}qa(e=!1){if(this.mi||this.ea&&!e)return;e||(this.syncCookieProperties(),this.Rr.cookieWinsOnConflict&&this.Rr.persistence.toLowerCase()===`localstorage+cookie`||Rce.forEach(e=>this.refreshKey(e)));let t=!e&&!this.na;t||(this.ra=!1);let n=!!t&&this.Ta();if(this.ra)return void(this.Rr.debug&&Tr.warn(`skipping persistence write because storage belongs to a different distinct ID`));if(this.Yo)return this.Ua(),void(n&&this.aa.forEach(e=>e()));let r=this.Wa(this.qo,this.ha,this.props,Zi);r===`written`&&this.Ra(this.props),r!==`failed`&&(this.ia.clear(),this.sa=!1,this.oa.clear()),n&&this.aa.forEach(e=>e())}Ua(){let{main:e,groups:t}=this.wa(),n=this.Wa(this.qo,this.ha,e,Zi);n===`written`&&this.Ra(e),n!==`failed`&&(this.sa=!1,this.oa.clear(),Qi.forEach(e=>{var t;(t=Bi(e))!=null&&t.storageGroup||this.ia.delete(e)}));for(let e of zi){let n=t[e];if(Vn(n)&&!this.Jo[e]?.persisted){Qi.forEach(t=>{Bi(t)?.storageGroup===e&&this.ia.delete(t)});continue}let r=this.Wa(Ci,this.pa(e),n,e);r!==`failed`&&Qi.forEach(t=>{let n=Bi(t);n?.storageGroup!==e||r!==`written`&&n.volatile||this.ia.delete(t)})}}wa(){let e={},t={flags:{},surveys:{}};return fi(this.props,(n,r)=>{let i=Bi(r)?.storageGroup;i?t[i][r]=n:e[r]=n}),{main:e,groups:t}}Sa(e,t){if(t===Zi)return JSON.stringify(e)+`|`+this.Va+`|`+this.Ga+`|`+this.Za;let n={};return fi(e,(e,t)=>{n[t]=Bi(t)?.volatile?`__volatile__`:e}),JSON.stringify(n)}Wa(e,t,n,r){let i=this.ya(r);if(r!==Zi&&!i.dirty&&!Hn(i.fingerprint))return`skipped`;let a;try{if(a=this.Sa(n,r),a===i.fingerprint)return i.dirty=!1,`skipped`}catch{a=void 0}return e.At(t,n,this.Va,this.Ga,this.Za,this.Rr.debug)?(i.dirty=!1,r!==Zi&&(i.persisted=!0),Hn(a)||(i.fingerprint=a),this.Ko&&(i.storageValue=Ci.Ot(t)),`written`):(this.Rr.debug&&Tr.warn(`failed to persist storage entry "${t}"; will retry on next save`),`failed`)}remove({keepGroupEntries:e=!1}={}){if(this.Ma(),Hn(this.Na)||(clearTimeout(this.Na),this.Na=void 0),this.qo.Lt(this.ha,!1),this.qo.Lt(this.ha,!0),!e&&this.la)for(let e of zi)Ci.Lt(this.pa(e));e?delete this.Jo[Zi]:this.Jo={},this.Aa=void 0,this.Fa=void 0}clear(){this.remove(),this.props={}}register_once(e,t,n){if(Bn(e)){this.syncCookieProperties(),Hn(t)&&(t=`None`),this.Va=Hn(n)?this.Qa:n;let r=!1;if(fi(e,(e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.Ca(n,e),r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(Bn(e)){this.syncCookieProperties(),this.Va=Hn(t)?this.Qa:t;let n=!1;if(fi(e,(t,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==t||Bn(t)||Rn(t))&&(this.Ca(r,t),n=!0)}),n)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();let t=typeof e==`string`?[e]:e,n=!1;for(let e of t)e in this.props&&(this.$a(e),n=!0);n&&this.save()}update_campaign_params(){let e=Dn?.URL;if(e===this.ua)return;let t=Tce(this.Rr.custom_campaign_params,this.Rr.mask_personal_data_properties,this.Rr.custom_personal_data_properties),n=!Vn(hi(t));return n&&this.register(t),this.ua=e,n?t:void 0}update_search_keyword(){this.register(function(){let e=Dn?.referrer;return e?Dce(e):{}}())}update_referrer_info(){this.register_once({$referrer:Ace(),$referring_domain:Dn?.referrer&&Hi(Dn.referrer)?.host||Ji},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;let e=jce(this.Rr.mask_personal_data_properties,this.Rr.custom_personal_data_properties,this.Rr.disable_capture_url_hashes);this.register_once({[ni]:this.Xo?{r:Xi(e.r),u:e.u?Xi(e.u):void 0}:e},void 0)}get_initial_props(){let e={};fi([Joe,qoe],t=>{let n=this.props[t];n&&fi(n,function(t,n){e[`$initial_`+bre(n)]=t})});let t=this.props[ni];return t&&pi(e,function(e,t=!1){let n=Mce(e,t),r={};return fi(n,function(e,t){r[`$initial_${bre(t)}`]=e}),r}(t,this.Rr.disable_capture_url_hashes)),e}safe_merge(e){return fi(this.props,function(t,n){n in e||(e[n]=t)}),e}update_config(e,t,n){let r=e.persistence!==t.persistence,i=!((e,t)=>{if(e.length!==t.length)return!1;let n=[...e].sort(),r=[...t].sort();return n.every((e,t)=>e===r[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),a=r||i,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,s=e.disable_persistence||!!n,c=!!this.mi&&!s;s||this.Oa(t,c),this.Rr=e,!s&&(r||i||o)&&(this.Aa=void 0,this.Fa=void 0,this.Oa(R(R({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),c));let l=a||o?this.ca(e):this.qo;this.Ja();let u=this.da(e),d=a||u!==this.Yo,f=!s&&(d||e.cross_subdomain_cookie!==this.Ga||e.secure_cookie!==this.Za)&&this.Da(c);this.na=d;try{if(this.Qa=this.Va=e.cookie_expiration,this.set_disabled(s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){let e=this.props;this.clear(),this.qo=l,this.Yo=u,this.props=e,this.save()}else o&&(this.qo=l,s||(delete this.Jo[Zi],this.qa()))}finally{this.na=!1,f&&this.ja()}}Ja(){let e=this.props[ni];if(!this.Xo||!Bn(e)||typeof e.r!=`string`)return;let t=Xi(e.r),n=typeof e.u==`string`?Xi(e.u):e.u;t===e.r&&n===e.u||this.Ca(ni,R(R({},e),{},{r:t,u:n}))}set_disabled(e){this.mi=e,this.mi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ga&&(this.Ga=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Za&&(this.Za=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){let n=this.props.__timers||{};n[e]=t,this.Ca(uoe,n),this.save()}remove_event_timer(e){let t=this.props.__timers||{},n=t[e];return Hn(n)||(delete t[e],this.Ca(uoe,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this.Ca(e,t),this.save()}Ca(e,t,n=!0){var r;let i=this.props[e];this.props[e]=t,n&&(e!==`distinct_id`&&e!==`$user_state`||i===t||(this.sa=!0),zce(e)&&!$i(i,t)&&this.oa.add(e),this.Ea(e,i,t),(r=Bi(e))!=null&&r.volatile||this.Ia(e))}$a(e,t=!0){delete this.props[e],t&&(Lce(e)&&this.ma(e,!0),zce(e)&&this.oa.add(e),this.Ia(e))}Ia(e){let t=Bi(e)?.storageGroup;t&&(this.ya(t).dirty=!0)}ya(e){return this.Jo[e]||(this.Jo[e]={})}},ta={GZipJS:`gzip-js`,Base64:`base64`},na={Activation:`events`,Cancellation:`cancelEvents`},ra={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},ia={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},aa={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`,SURVEY_LANGUAGE:`$survey_language`},oa={Popover:`popover`,Inline:`inline`};function sa(e){let t=!0;return{dispose(){if(t){t=!1;let n=e();n&&zn(n.then)&&n.then(void 0,()=>{})}}}}var Hce={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},Uce={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},Wce=Er(`[RateLimiter]`),Gce=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{let t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Wce.info(`${e||`events`} is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4})}catch(e){Wce.warn(`could not rate limit - continuing. Error: "${e?.message}"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=new Date().getTime(),a=this.instance.persistence?.get_property(`$capture_rate_limit`)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);let o=1>a.tokens;if(o||e||(a.tokens=Math.max(0,a.tokens-1)),o&&!e){let e=(qn(a.dropped)?a.dropped:0)+1;a.dropped=e,!this.lastEventRateLimited&&this.Ka(e)&&(a.dropped=0)}return this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(`$capture_rate_limit`,a),{isRateLimited:o,remainingTokens:a.tokens}}Xa(e){let t=this.instance.config.property_denylist;return!Rn(t)||!t.includes(e)}Ya(){if(this.Xa(`$current_url`)&&this.Xa(`$pathname`)&&On?.pathname)return`${On.origin??``}${On.pathname}`}Ka(e){var t;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=this.Ya(),a=this.Xa(`$session_id`)?(t=this.instance).get_session_id?.call(t):void 0,o=[`${e} event(s) dropped since the last warning`,i?`triggered on ${i}`:void 0,a?`session ${a}`:void 0].filter(Boolean).join(`, `);return!!this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited: ${o}. Config is set to ${r} events per second and ${n} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){let t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},ca=Er(`[RemoteConfig]`),Kce=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=Mn._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}tl(e){var t,n;Mn.__PosthogExtensions__?.loadExternalDependency?(t=Mn.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`remote-config`,()=>e(this.remoteConfig)):e()}el(e){this._instance._send_request({method:`GET`,url:this._instance.requestRouter.endpointFor(`assets`,`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return ca.info(`Using preloaded remote config`,this.remoteConfig),void this.il(this.remoteConfig);if(this._instance.nl())return void ca.warn(`Remote config is disabled. Falling back to local config.`);this.tl(e=>{if(!e)return ca.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.el(e=>{this.il(e.json,e)});this.il(e)})}catch(e){ca.error(`Error loading remote config`,e),this.il()}}il(e,t){!e&&t&&(t.statusCode===0?t.error||ca.warn(`Failed to fetch remote config from PostHog.`):ca.error(`Failed to fetch remote config from PostHog.`));try{this._instance.il(e?{ok:!0,config:e}:{ok:!1})}catch(e){ca.error(`Error applying remote config`,e)}if(!1!==e?.hasFeatureFlags&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var n;(n=this._instance.featureFlags)==null||n.ensureFlagsLoaded()}catch(e){ca.error(`Error loading feature flags`,e)}}},la=Uint8Array,ua=Uint16Array,da=Uint32Array,qce=new la([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Jce=new la([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Yce=new la([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xce=function(e,t){for(var n=new ua(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new da(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},Zce=Xce(qce,2),Qce=Zce[1];Zce[0][28]=258,Qce[258]=28;for(var $ce=Xce(Jce,0)[1],ele=new ua(32768),fa=0;32768>fa;++fa){var pa=(43690&fa)>>>1|(21845&fa)<<1;ele[fa]=((65280&(pa=(61680&(pa=(52428&pa)>>>2|(13107&pa)<<2))>>>4|(3855&pa)<<4))>>>8|(255&pa)<<8)>>>1}var ma=function(e,t,n){for(var r=e.length,i=0,a=new ua(t);r>i;++i)++a[e[i]-1];var o,s=new ua(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new ua(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[ele[d]>>>c]=l}else for(o=new ua(r),i=0;r>i;++i)o[i]=ele[s[e[i]-1]++]>>>15-e[i];return o},ha=new la(288);for(fa=0;144>fa;++fa)ha[fa]=8;for(fa=144;256>fa;++fa)ha[fa]=9;for(fa=256;280>fa;++fa)ha[fa]=7;for(fa=280;288>fa;++fa)ha[fa]=8;var ga=new la(32);for(fa=0;32>fa;++fa)ga[fa]=5;var tle=ma(ha,9,0),nle=ma(ga,5,0),rle=function(e){return(e/8|0)+(7&e&&1)},ile=function(e,t,n){(t==null||0>t)&&(t=0),(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof ua?ua:e instanceof da?da:la)(n-t);return r.set(e.subarray(t,n)),r},_a=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},va=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},ale=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new la(0),0];if(i==1){var o=new la(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new ua(f+1),m=ole(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var y=a[r].s;t>p[y]?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return[new la(p),m]},ole=function(e,t,n){return e.s==-1?Math.max(ole(e.l,t,n+1),ole(e.r,t,n+1)):t[e.s]=n},sle=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ua(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},ya=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},ba=function(e,t,n){var r=n.length,i=rle(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},cle=function(e,t,n,r,i,a,o,s,c,l,u){_a(t,u++,n),++i[256];for(var d=ale(i,15),f=d[0],p=d[1],m=ale(a,15),h=m[0],g=m[1],_=sle(f),v=_[0],y=_[1],b=sle(h),x=b[0],S=b[1],C=new ua(19),w=0;v.length>w;++w)C[31&v[w]]++;for(w=0;x.length>w;++w)C[31&x[w]]++;for(var T=ale(C,7),E=T[0],D=T[1],O=19;O>4&&!E[Yce[O-1]];--O);var k,A,j,ee,M=l+5<<3,N=ya(i,ha)+ya(a,ga)+o,P=ya(i,f)+ya(a,h)+o+14+3*O+ya(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(N>=M&&P>=M)return ba(t,u,e.subarray(c,c+l));if(_a(t,u,1+(N>P)),u+=2,N>P){k=ma(f,p,0),A=f,j=ma(h,g,0),ee=h;var te=ma(E,D,0);for(_a(t,u,y-257),_a(t,u+5,S-1),_a(t,u+10,O-4),u+=14,w=0;O>w;++w)_a(t,u+3*w,E[Yce[w]]);u+=3*O;for(var ne=[v,x],re=0;2>re;++re){var ie=ne[re];for(w=0;ie.length>w;++w)_a(t,u,te[ae=31&ie[w]]),u+=E[ae],ae>15&&(_a(t,u,ie[w]>>>5&127),u+=ie[w]>>>12)}}else k=tle,A=ha,j=nle,ee=ga;for(w=0;s>w;++w)if(r[w]>255){var ae;va(t,u,k[257+(ae=r[w]>>>18&31)]),u+=A[ae+257],ae>7&&(_a(t,u,r[w]>>>23&31),u+=qce[ae]);var oe=31&r[w];va(t,u,j[oe]),u+=ee[oe],oe>3&&(va(t,u,r[w]>>>5&8191),u+=Jce[oe])}else va(t,u,k[r[w]]),u+=A[r[w]];return va(t,u,k[256]),u+A[256]},lle=new da([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ule=new la(0),dle=function(){for(var e=new da(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),fle=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function ple(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=dle[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l,u=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new la(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=ba(c,l,e.subarray(u,d)):(c[u]=a,l=ba(c,l,e.subarray(u,o)))}else{for(var f=lle[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new ua(32768),_=new ua(h+1),v=Math.ceil(n/3),y=2*v,b=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&h},x=new da(25e3),S=new ua(288),C=new ua(32),w=0,T=0,E=(u=0,0),D=0,O=0;o>u;++u){var k=b(u),A=32767&u,j=_[k];if(g[A]=j,_[k]=A,u>=D){var ee=o-u;if((w>7e3||E>24576)&&ee>423){l=cle(e,c,0,x,S,C,T,E,O,u-O,l),E=w=T=0,O=u;for(var M=0;286>M;++M)S[M]=0;for(M=0;30>M;++M)C[M]=0}var N=2,P=0,te=m,ne=A-j&32767;if(ee>2&&k==b(u-ne))for(var re=Math.min(p,ee)-1,ie=Math.min(32767,u),ae=Math.min(258,ee);ie>=ne&&--te&&A!=j;){if(e[u+N]==e[u+N-ne]){for(var oe=0;ae>oe&&e[u+oe]==e[u+oe-ne];++oe);if(oe>N){if(N=oe,P=ne,oe>re)break;var se=Math.min(ne,oe-2),ce=0;for(M=0;se>M;++M){var le=u-ne+M+32768&32767,ue=le-g[le]+32768&32767;ue>ce&&(ce=ue,j=le)}}}ne+=(A=j)-(j=g[A])+32768&32767}if(P){x[E++]=268435456|Qce[N]<<18|$ce[P];var de=31&Qce[N],fe=31&$ce[P];T+=qce[de]+Jce[fe],++S[257+de],++C[fe],D=u+N,++w}else x[E++]=e[u],++S[e[u]]}}l=cle(e,c,a,x,S,C,T,E,O,u-O,l),a||(l=ba(c,l,ule))}return ile(s,0,r+rle(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c,!l)),d=u.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&fle(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(u,t),fle(u,d-8,n.d()),fle(u,d-4,r),u}var mle=!!fre||!!kn,hle=new WeakMap,gle=`text/plain`,_le=0,xa=!1,vle=(e,t)=>{let[n,r]=e.split(`#`),[i,a]=n.split(`?`);if(!a)return e;let o=a.split(`&`).filter(e=>e.split(`=`)[0]!==t).join(`&`);return`${i}${o?`?${o}`:``}${r?`#${r}`:``}`},Sa=(e,t,n=!0)=>{let[r,i]=e.split(`?`),a=R({},t),o=i?.split(`&`).map(e=>{var t;let[r,i]=e.split(`=`),o=n&&(t=a[r])!=null?t:i;return delete a[r],`${r}=${o}`})??[],s=function(e,t=`&`){let n,r,i=[];return fi(e,function(e,t){Hn(e)||Hn(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)}),i.join(t)}(a);return s&&o.push(s),o.length>0?`${r}?${o.join(`&`)}`:r},Ca=e=>{if(e.sl)return e.sl;let{data:t,compression:n}=e;if(!t)return;if(n===ta.GZipJS){let e=ple(function(e){var t=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var n=new la(e.length+(e.length>>>1)),r=0,i=function(e){n[r++]=e},a=0;t>a;++a){if(r+5>n.length){var o=new la(r+8+(t-a<<1));o.set(n),n=o}var s=e.charCodeAt(a);128>s?i(s):2048>s?(i(192|s>>>6),i(128|63&s)):s>55295&&57344>s?(i(240|(s=65536+(1047552&s)|1023&e.charCodeAt(++a))>>>18),i(128|s>>>12&63),i(128|s>>>6&63),i(128|63&s)):(i(224|s>>>12),i(128|s>>>6&63),i(128|63&s))}return ile(n,0,r)}(Vi(t)),{mtime:0});return{contentType:gle,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(n===ta.Base64){let e=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:Vi(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))))}(Vi(t)));return{contentType:`application/x-www-form-urlencoded`,body:e,estimatedSize:new Blob([e]).size}}let r=Vi(t);return{contentType:`application/json`,body:r,estimatedSize:new Blob([r]).size}},yle=e=>{let t=()=>e.transport===`sendBeacon`?{url:Sa(e.url,{compression:ta.Base64}),encodedBody:Ca(R(R({},e),{},{compression:ta.Base64,sl:void 0}))}:{url:vle(e.url,`compression`),encodedBody:Ca(R(R({},e),{},{compression:void 0,sl:void 0}))},n;try{n=Ca(e)}catch(n){if(kae(e.compression,Ui(e.url,`compression`)))return Tr.error(`Failed to gzip request body, sending uncompressed payload`,n),t();throw n}return n&&kae(e.compression,Ui(e.url,`compression`))&&!((r=n.body)instanceof ArrayBuffer?Oae(new Uint8Array(r)):ArrayBuffer.isView(r)&&Oae(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(xa=!0,t()):{url:e.url,encodedBody:n};var r},ble=e=>{try{return yle(e)}catch(n){var t;Tr.error(n),(t=e.callback)==null||t.call(e,{statusCode:0,error:n});return}},xle=function(){var e=er(function*(e){let t=yield function(e){return Nae.apply(this,arguments)}(Vi(e.data),Ar.DEBUG,{rethrow:!0});if(!t)return e;let n=yield t.arrayBuffer();return R(R({},e),{},{sl:{contentType:gle,body:n,estimatedSize:n.byteLength}})});return function(t){return e.apply(this,arguments)}}(),Sle=/Failed to fetch|NetworkError|Load failed/i,Cle=e=>e?.name===`TypeError`&&Sle.test(e?.message||``),wle=e=>{try{let t=function(e,t=Date.now()){if(typeof e!=`string`||!e)return;let n=e.trim(),r=/^\d+\s*,/.test(n)?n.slice(0,n.indexOf(`,`)).trim():n;if(/^\d+$/.test(r)){let e=1e3*Math.min(Number(r),300);return e>0?e:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(r))return;let i=/^\w{3} \w{3} /.test(r)?r+` GMT`:r,a=Date.parse(i)-t;return Number.isFinite(a)&&a>0?Math.min(a,mr):void 0}(e());return Hn(t)?void 0:Math.min(t,3e4)}catch{return}},Tle=e=>{let t=ble(e);if(!t)return;let n=new fre;hle.set(n,!0);let{url:r,encodedBody:i}=t;n.open(e.method||`GET`,r,!0);let{contentType:a,body:o}=i??{};fi(e.headers,function(e,t){n.setRequestHeader(t,e)}),a&&n.setRequestHeader(`Content-Type`,a),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var t;let r={statusCode:n.status,text:n.responseText};if(n.status===200)try{r.json=JSON.parse(n.responseText)}catch{}(t=e.callback)==null||t.call(e,r,wle(()=>n.getResponseHeader(`Retry-After`)))}},n.send(o)},Ele=e=>{let t=ble(e);if(!t)return;let{url:n,encodedBody:r}=t,{contentType:i,body:a,estimatedSize:o}=r??{},s=new Headers;fi(e.headers,function(e,t){s.append(t,e)}),i&&s.append(`Content-Type`,i);let c=null,l=!1;if(pre){let t=new pre;c={signal:t.signal,timeout:setTimeout(()=>{l=!0;try{t.abort(Mie(`AbortError`,`PostHog request timed out`+((n=e.timeout)?` after ${n}ms`:``)))}catch(e){d(e)}var n},e.timeout)}}let u=!1,d=t=>{var n;u||(u=!0,l&&t?.name===`AbortError`||Cle(t)?Tr.warn(t):Tr.error(t),(n=e.callback)==null||n.call(e,{statusCode:0,error:t}))},f=0,p=()=>{_le-=f,f=0,c&&clearTimeout(c.timeout)};try{let t=R({method:e?.method||`GET`,headers:s,referrerPolicy:`strict-origin`,body:a,signal:c?.signal},e.fetchOptions),r=o??(Hn(a)?0:void 0);t.keepalive=t.method===`POST`&&!e.rl&&!1!==t.keepalive&&t.body===a&&!Hn(r)&&r>=0&&52428.8>_le+r,t.keepalive&&(f=r,_le+=f),kn(n,t).then(t=>t.text().then(n=>{var r;if(u)return;let i={statusCode:t.status,text:n};if(t.status===200)try{i.json=JSON.parse(n)}catch(e){Tr.error(e)}u=!0,p(),(r=e.callback)==null||r.call(e,i,wle(()=>t.headers.get(`Retry-After`)))})).catch(e=>{p(),d(e)}).finally(p)}catch(e){p(),d(e)}},wa=e=>{try{let{url:t,encodedBody:n}=yle(e),{contentType:r,body:i,estimatedSize:a}=n??{};if(!i)return;let o=i instanceof Blob?i:new Blob([i],{type:r});if(En.sendBeacon(t,o))return;let s=Rn(e.data)?e.data:e.data?.batch;if(Rn(s)&&s.length>1&&(a??0)>16384){let t=Math.ceil(s.length/2),n=t=>Rn(e.data)?t:R(R({},e.data),{},{batch:t});wa(R(R({},e),{},{data:n(s.slice(0,t))})),wa(R(R({},e),{},{data:n(s.slice(t))}));return}Tr.warn(`Beacon of ~${a??0} bytes was rejected by the browser, falling back to ${kn?`fetch`:`XHR`}`),kn?Ele(R(R({},e),{},{rl:!0})):Tle(e)}catch(e){Tr.warn(`Beacon send failed`,e)}},Dle=(e,t,n,r)=>{let i=r===`query`?t===`POST`?`sent_at`:`_`:void 0;return Sa(n===ta.GZipJS?vle(e,`compression`):e,R(R({},i?{[i]:Date.now().toString()}:{}),n===ta.GZipJS?{}:{compression:n}))},Ole=(()=>{let e=[];return kn&&e.push({transport:`fetch`,method:Ele}),fre&&e.push({transport:`XHR`,method:Tle}),En!=null&&En.sendBeacon&&e.push({transport:`sendBeacon`,method:wa}),e})(),kle=!mle&&An?.indexOf(`MSIE`)===-1&&An?.indexOf(`Mozilla`)===-1;function Ale(e,t,n){var r,i;n&&(t=R(R({},t),{},{callback:e=>n(e)})),e.__loaded?kle?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&((r=t.callback)==null||r.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=R(R({},e.config.request_headers),t.headers),t.compression=t.compression===`best-available`?e.compression??t.compressionFallback:t.compression,(Hn(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=[`sendBeacon`]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((e,t)=>{let n=R(R({},e),{},{callback:t??(t=>e.callback?.call(e,t))});n.timeout=n.timeout||6e4;let r=n.transport??`fetch`;r===`sendBeacon`&&Hn(n.compression)&&n.data&&(n.compression=ta.Base64),n.method===`POST`&&n.data&&(n.timestampMode===`capture-body`?n.data=(e=>{var t;let n=(Rn(e)?e:[e]).map(e=>R(R({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),r=n[0];return{api_key:(r==null||(t=r.properties)==null?void 0:t.token)??r?.token,batch:n,sent_at:new Date().toISOString()}})(n.data):n.timestampMode===`body`&&(n.data=((e,t=new Date().toISOString())=>Rn(e)?e.map(e=>R(R({},e),{},{sent_at:t})):R(R({},e),{},{sent_at:t}))(n.data))),n.url=Dle(n.url,n.method,n.compression,n.timestampMode);let i=Ole.filter(e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport)),a=function(e,t){for(let n=0;e.length>n;n++)if(t(e[n]))return e[n]}(i,e=>e.transport===r)?.method??i[0].method;if(!a)throw Error(`No available transport method`);let o=e=>{try{a(e)}catch(e){var t;Cle(e)?Tr.warn(e):Tr.error(e),(t=n.callback)==null||t.call(n,{statusCode:0,error:e})}};r!==`sendBeacon`&&!n.preferSyncCompression&&n.data&&n.compression===ta.GZipJS&&mre&&typeof Promise<`u`&&!xa?xle(n).then(e=>{o(e)}).catch(t=>{if(Aae(t))return xa=!0,void o(R(R({},n),{},{compression:void 0,url:Dle(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return Aae(e)||t===Dae})(t)&&(xa=!0),o(n)}):o(n)})(t,(r,i)=>{var a,o,s;e.rateLimiter.checkForLimiting(r),400>r.statusCode||(a=(o=e.config).on_request_error)==null||a.call(o,r),n?n(r,i):(s=t.callback)==null||s.call(t,r)})):t.fireCallbackOnDrop&&((i=t.callback)==null||i.call(t,{statusCode:0}))}var jle=class{constructor(e,t){this.ol=!0,this.al=[],this.ll=tr(t?.flush_interval_ms||3e3,250,5e3,Tr.createLogger(`flush interval`),3e3),this.ul=e}enqueue(e){this.al.push(e),this.hl||this.cl()}unload(){this.dl();let e=this.al.length>0?this.vl():{},t=Object.values(e);[...t.filter(e=>e.url.indexOf(`/e`)===0),...t.filter(e=>e.url.indexOf(`/e`)!==0)].map(e=>{this.fl(e,`sendBeacon`)})}enable(){this.ol=!1,this.cl()}cl(){this.ol||(this.hl=setTimeout(()=>{if(this.dl(),this.al.length>0){let e=this.vl();for(let t in e)this.fl(e[t])}},this.ll))}fl(e,t){try{this.ul(e,t)}catch(e){Tr.error(e)}}dl(){clearTimeout(this.hl),this.hl=void 0}vl(){let e={};return fi(this.al,t=>{var n;let r=t,i=((r?r.batchKey:null)||r.url)+(r.batchGroup?`:${r.batchGroup}`:``);Hn(e[i])&&(e[i]=R(R({},r),{},{data:[]})),(n=e[i].data)==null||n.push(r.data)}),this.al=[],e}},Mle=[`retriesPerformedSoFar`],Nle=class{constructor(e){this._instance=e,this.pl=!1,this.gl=3e3,this.al=[],this.al=[],this.ml=!0,this.resume()}resume(){if(!Hn(wn)&&`onLine`in wn.navigator){if(this.ml=wn.navigator.onLine,this.yl)return;this.yl=()=>{this.ml=!0,this.bl()},this._l=()=>{this.ml=!1},gi(wn,`online`,this.yl),gi(wn,`offline`,this._l)}}get length(){return this.al.length}retriableRequest(e,t){let{retriesPerformedSoFar:n}=e,r=Pae(e,Mle);Jn(n)&&(r.url=Sa(r.url,{retry_count:n})),Ale(this._instance,t?R(R({},r),{},{transport:t}):r,(e,t)=>{var i;if(e.statusCode!==200&&(400>e.statusCode||e.statusCode>=500)){if((e.statusCode===0?3:10)>(n??0))return void this.Ls(R({retriesPerformedSoFar:n},r),t);e.statusCode===0&&Tr.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${n??0} retries.`)}(i=r.callback)==null||i.call(r,e)})}Ls(e,t){let n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;let r=Math.max(function(e){let t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=(Math.random()-.5)*(r-n);return Math.ceil(r+i)}(n),t??0),i=Date.now()+r;this.al.push({retryAt:i,requestOptions:e});let a=`Enqueued failed request for retry in ${r}`;navigator.onLine||(a+=` (Browser is offline)`),Tr.warn(a),this.pl||(this.pl=!0,this.wl())}wl(){if(this.kl&&clearTimeout(this.kl),this.al.length===0)return this.pl=!1,void(this.kl=void 0);this.kl=setTimeout(()=>{this.ml&&this.al.length>0&&this.bl(),this.wl()},this.gl)}bl(){let e=Date.now(),t=[],n=this.al.filter(n=>e>n.retryAt||(t.push(n),!1));if(this.al=t,n.length>0)for(let{requestOptions:e}of n)this.retriableRequest(e)}unload(){this.kl&&=(clearTimeout(this.kl),void 0),this.pl=!1,Hn(wn)||(this.yl&&=(wn.removeEventListener(`online`,this.yl),void 0),this._l&&=(wn.removeEventListener(`offline`,this._l),void 0));for(let{requestOptions:e}of this.al)try{this._instance._send_request(R(R({},e),{},{transport:`sendBeacon`}))}catch(e){Tr.error(e)}this.al=[]}},Ple=class{constructor(e){this._instance=e,this.Sl=()=>{this.xl||={};let e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.xl.lastScrollY=Math.ceil(t),this.xl.maxScrollY=Math.max(t,this.xl.maxScrollY??0),this.xl.maxScrollHeight=Math.max(n,this.xl.maxScrollHeight??0),this.xl.lastContentY=r,this.xl.maxContentY=Math.max(r,this.xl.maxContentY??0),this.xl.maxContentHeight=Math.max(i,this.xl.maxContentHeight??0)}}get Cl(){return this._instance.config.scroll_root_selector}getContext(){return this.xl}resetContext(){let e=this.xl;return this.xl=void 0,setTimeout(this.Sl,0),e}startMeasuringScrollPosition(){gi(wn,`scroll`,this.Sl,{capture:!0}),gi(wn,`scrollend`,this.Sl,{capture:!0}),gi(wn,`resize`,this.Sl)}scrollElement(){if(this.Cl){let t=Rn(this.Cl)?this.Cl:[this.Cl];for(let n of t){var e;let t=wn==null||(e=wn.document)==null?void 0:e.querySelector(n);if(t)return t}return}var t;return wn==null||(t=wn.document)==null?void 0:t.documentElement}$l(e){var t,n;let r=e===`y`?`scrollTop`:`scrollLeft`;if(this.Cl){let e=this.scrollElement();return e&&e[r]||0}return wn?e===`y`?wn.scrollY||wn.pageYOffset||((t=wn.document)==null||(t=t.documentElement)==null?void 0:t.scrollTop)||0:wn.scrollX||wn.pageXOffset||((n=wn.document)==null||(n=n.documentElement)==null?void 0:n.scrollLeft)||0:0}scrollY(){return this.$l(`y`)}scrollX(){return this.$l(`x`)}},Fle=e=>jce(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes),Ile=class{constructor(e,t,n,r){this.Be=e=>{let t=this.Tl();if(t&&t.sessionId===e)return;let n={sessionId:e,props:this.Il(this._instance)};this.Ml.register({[ti]:n})},this._instance=e,this.El=t,this.Ml=n,this.Il=r||Fle,this.El.onSessionId(this.Be)}Tl(){return this.Ml.props[ti]}getSetOnceProps(){let e=this.Tl()?.props;return e?`r`in e?Mce(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){let e={};return fi(hi(this.getSetOnceProps()),(t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_${bre(n)}`]=t}),e}},Ta=class{on(e,t){return this.Pl[e]||(this.Pl[e]=[]),this.Pl[e].push(t),()=>{this.Pl[e]=this.Pl[e].filter(e=>e!==t)}}emit(e,t){for(let n of this.Pl[e]||[])n(t);for(let n of this.Pl[`*`]||[])n(e,t)}constructor(){this.Pl={}}},Ea=Er(`[SessionId]`),Lle=864e5,Rle=class{on(e,t){return this.Rl.on(e,t)}constructor(e,t,n){var r;if(this.Al=null,this.Fl=null,this.Ol=[],this.Dl=void 0,this.Ll=!1,this.Rl=new Ta,this.Nl=(e,t)=>!(!Jn(e)||!Jn(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===`always`)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Rr=e.config,this.Ml=e.persistence,this.He=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.ql=void 0,this._sessionActivityTimestamp=null,this.jl=t||yi,this.Bl=n||yi;let i=this.Rr.persistence_name||this.Rr.token;if(this._sessionTimeoutMs=1e3*tr(this.Rr.session_idle_timeout_seconds||1800,60,36e3,Ea.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Hl(),this.zl=`ph_`+i+`_window_id`,this.Ul=`ph_`+i+`_primary_window_exists`,this.Wl()){let e=Oi.Dt(this.zl),t=Oi.Dt(this.Ul);e&&!t?this.He=e:Oi.Lt(this.zl),Oi.At(this.Ul,!0)}(r=this.Rr.bootstrap)!=null&&r.sessionID&&this.setBootstrapSessionId(this.Rr.bootstrap.sessionID),this.Vl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Hn(this.Ol)&&(this.Ol=[]),this.Ol.push(e),this.Xt&&e(this.Xt,this.He),()=>{this.Ol=this.Ol.filter(t=>t!==e)}}Wl(){return this.Rr.persistence!==`memory`&&!this.Ml.mi&&Oi.Et()}Gl(e){e!==this.He&&(this.He=e,this.Wl()&&Oi.At(this.zl,e))}Zl(){return this.He?this.He:this.Wl()?Oi.Dt(this.zl):null}Ql(e){let t=this.Al;return!Gn(t)&&!Gn(e)&&5e3>Math.abs(e-t)}Jl(e,t,n){let r=t!==this._sessionActivityTimestamp,i=e===this.Xt&&n===this._sessionStartTimestamp;this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.Xt=e,i&&!r||i&&this.Ql(t)||(this.Al=t,this.Ml.register({[Rr]:[t,e,n]}))}Kl(){let e=this.Rr?.persistence_save_debounce_ms;return Jn(e)&&e>0}Xl(){this.Kl()?this.Ml.refreshKey(Rr):(this.Ml.flush(),this.Ml.load())}Yl(){if(Gn(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Al)return;this.Xl();let[,e,t]=this.tu();e===this.Xt&&t===this._sessionStartTimestamp&&(this.Al=this._sessionActivityTimestamp,this.Ml.register({[Rr]:[this._sessionActivityTimestamp,this.Xt??null,this._sessionStartTimestamp]}),this.Ml.flush())}eu(){let[e]=this.tu(),t=Jn(e)?e:0,n=Jn(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,n)}iu(e){return this.Xl(),this.Nl(e,this.eu())}tu(){let e=this.Ml.props[Rr];return Rn(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Al=null,this.ql=void 0,clearTimeout(this.nu),this.nu=void 0,this.Jl(null,null,null)}setBootstrapSessionId(e,t=!1){let n=((e,t=new Date().getTime())=>{try{let n=(e=>{let t=e.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})(e);return n>t+6e4?void Ea.error(`Bootstrap sessionID cannot be in the future`):n}catch(e){Ea.error(`Invalid sessionID in bootstrap`,e);return}})(e);return!Hn(n)&&(t?this.ql={sessionId:e,sessionStartTimestamp:n}:this.Jl(e,new Date().getTime(),n),!0)}destroy(){this.Ll=!0,this.Yl(),clearTimeout(this.nu),this.nu=void 0,this.Dl&&wn&&(wn.removeEventListener(li,this.Dl,{capture:!1}),this.Dl=void 0),this.Ol=[]}Vl(){this.Dl=()=>{this.Yl(),this.Wl()&&Oi.Lt(this.Ul)},gi(wn,li,this.Dl,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,n=!1){if(this.Rr.cookieless_mode===`always`)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);let r=t||new Date().getTime(),i=this.Xt;if(n)this.Fl=r;else if(Gn(this.Fl)||this.Fl>r||r-this.Fl>=1e3){var a,o;(a=(o=this.Ml).syncCookieProperties)==null||a.call(o),this.Fl=r}let[,s,c]=this.tu(),l=!Hn(i)&&s!==i,u=this.eu(),d=this.Zl(),f=this.ql,p=!!f&&(f.sessionStartTimestamp>r+6e4||r-f.sessionStartTimestamp>Lle),m=f?p:Jn(c)&&Math.abs(r-c)>Lle,h=!1,g=l,_=!s||!!f,v=s,y=!_&&!e&&this.Nl(r,u);if(y&&(y=this.iu(r),y||Ea.info(`cross-tab refresh kept the session alive`,{sessionId:s}),[,s,c]=this.tu(),y||(_=!s||!!f)),_||y||m){g=!1;let e=f&&!p;s=e?f.sessionId:this.jl(),d=this.Bl(),Ea.info(`new session ID assigned`,{sessionId:s,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:_,activityTimeout:y,sessionPastMaximumLength:m}}),c=e?f.sessionStartTimestamp:r,this.ql=void 0,h=!0}else d||(d=this.Bl(),h=!0),g||=s!==v,g&&(Ea.info(`adopted cross-tab session id`,{sessionId:s,windowId:d}),h=!0);let b=Jn(u)&&e&&!m?u:r,x=Jn(c)?c:new Date().getTime();this.Gl(d),this.Jl(s,b,x),e||this.Hl();let S={noSessionId:_,activityTimeout:y,sessionPastMaximumLength:m,crossTabAdoption:g};return h&&this.Ol.forEach(e=>e(s,d,S)),{sessionId:s,windowId:d,sessionStartTimestamp:x,changeReason:h?S:void 0,lastActivityTimestamp:u}}Hl(){this.Ll||(clearTimeout(this.nu),this.nu=setTimeout(()=>{if(!this.Ll){if(this.iu(new Date().getTime())){let e=this.Xt;this.resetSessionId(),this.Rl.emit(`forcedIdleReset`,{idleSessionId:e})}else this.Hl()}},1.1*this.sessionTimeoutMs))}},zle=function(e,t){if(!e)return!1;let n=e.userAgent;if(n&&Mre(n,t))return!0;try{let n=e?.userAgentData;if(n?.brands&&n.brands.some(e=>Mre(e?.brand,t)))return!0}catch{}return!!e.webdriver};function Ble(){return(Ble=er(function*(){let e=En?.userAgentData;if(e?.getHighEntropyValues)try{let t=(yield e.getHighEntropyValues([`model`]))?.model;return Un(t)&&t.length>0?t:void 0}catch(e){Tr.info(`Unable to resolve $device_model from userAgentData.getHighEntropyValues`,e);return}})).apply(this,arguments)}function Vle(e,t){let n=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(n=`$survey_${t}/${e.id}/${e.current_iteration}`),n}function Hle(e){var t;return!!((t=e.conditions)!=null&&(t=t.events)!=null&&(t=t.values)!=null&&t.length)}var Da=(e,t)=>{if(!(e=>{try{new RegExp(e)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},Oa=e=>e.toLowerCase(),Ule={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>Da(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!Da(t,e))),icontains:(e,t)=>t.map(Oa).some(t=>e.map(Oa).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(Oa).every(t=>e.map(Oa).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{let n=parseFloat(t);return!isNaN(n)&&e.some(e=>n>parseFloat(e))}),lt:(e,t)=>t.some(t=>{let n=parseFloat(t);return!isNaN(n)&&e.some(e=>n<parseFloat(e))})};function Wle(e,t){return!e||Object.entries(e).every(([e,n])=>{let r=t?.[e];if(r==null)return!1;let i=Ule[n.operator];return!!i&&i(n.values.map(String),[String(r)])})}function ka(e,t,n){return Vi({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Aa=`custom`,Gle=`i.posthog.com`,Kle=/^\/static\//,qle=[`/s/`,`/e/`,`/i/`],Jle=class{constructor(e){this.su={},this.instance=e}get apiHost(){let e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){let e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){let e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.${Gle}`,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.su[this.apiHost]||(this.su[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`us`:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`eu`:Aa),this.su[this.apiHost]}ru(e){if(!Kle.test(e))return;let t=this.instance.config.asset_host;return typeof t==`string`&&t.trim().replace(/\/$/,``)||void 0}ou(e){let t=Hi(e);return t?t.protocol+`//`+t.host+t.pathname:void 0}au(e,t,n){if(e===`ui`)return n;let r=n,i=this.instance.config.rewriteRequestPath;if(i){let e=Hi(n)?.href||n;r=i(new URL(e)).toString()}if(i&&e===`api`&&qle.some(e=>t.indexOf(e)===0)){let e=this.ou(r);if(e){let t=this.apiHost,n=this.lu;n?.apiHost===t&&n.rewriteRequestPath===i||(n={apiHost:t,rewriteRequestPath:i,urls:new Set},this.lu=n),n.urls.add(e)}}return r}isIngestionEndpoint(e){let t=this.lu,n=this.ou(e);return t?.apiHost===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!n&&t.urls.has(n)}endpointFor(e,t=``){if(t&&=t[0]===`/`?t:`/${t}`,e===`ui`)return this.au(e,t,this.uiHost+t);if(e===`flags`)return this.au(e,t,this.flagsApiHost+t);if(e===`assets`){let n=this.ru(t);if(n)return this.au(e,t,`${n}${t}`)}if(this.region===Aa)return this.au(e,t,this.apiHost+t);let n=Gle+t;switch(e){case`assets`:return this.au(e,t,`https://${this.region}-assets.${n}`);case`api`:return this.au(e,t,`https://${this.region}.${n}`)}}},ja=Er(`[Surveys]`),Yle=e=>{try{let t=(e=>((e,t)=>`seenSurvey_${function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id}(t)}`)(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,`true`)}catch(e){ja.error(`Failed to persist survey seen state`,e)}},Xle=[ra.Popover,ra.Widget,ra.API],Zle={ignoreConditions:!1,ignoreDelay:!1,displayType:oa.Popover},Qle=Er(`[PostHog ExternalIntegrations]`),$le={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},eue=class{constructor(e){this._instance=e}zo(e,t){var n,r;(n=Mn.__PosthogExtensions__)==null||(r=n.loadExternalDependency)==null||r.call(n,this._instance,e,e=>{if(e)return Qle.error(`failed to load script`,e);t()})}startIfEnabledOrStop(){for(let[r,i]of Object.entries(this._instance.config.integrations??{})){var e,t,n;i&&!((e=Mn.__PosthogExtensions__)!=null&&(e=e.integrations)!=null&&e[r])&&this.zo($le[r],()=>{var e;(e=Mn.__PosthogExtensions__)==null||(e=e.integrations)==null||(e=e[r])==null||e.start(this._instance)}),!i&&(t=Mn.__PosthogExtensions__)!=null&&(t=t.integrations)!=null&&t[r]&&((n=Mn.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[r])==null||n.stop())}}},tue=class{constructor(e,t){this.$=e,this.wo=t,this.uu=new Map,this.Io=!1}add(e){var t=this;return er(function*(){if(t.Io)throw Error(`Cannot add an extension to a disposed ExtensionRuntime`);if(t.uu.has(e.name))throw Error(`Browser extension "${e.name}" is already registered`);t.uu.set(e.name,e);try{let n=e.setup(t.wo);n&&(yield n)}catch(n){let r=t.uu.get(e.name)===e;r&&t.uu.delete(e.name),t.$.error(`Failed to set up browser extension "${e.name}"`,n),r&&t.hu(e)}})()}getExtension(e){return this.uu.get(e)}dispose(){if(this.Io)return;this.Io=!0;let e=Array.from(this.uu.values()).reverse();this.uu.clear();for(let t of e)this.hu(t)}hu(e){try{let t=e.dispose?.call(e);t&&zn(t.then)&&t.then(void 0,t=>{this.$.error(`Failed to dispose browser extension "${e.name}"`,t)})}catch(t){this.$.error(`Failed to dispose browser extension "${e.name}"`,t)}}},nue=class{constructor(e){this._instance=e}initialize(){}get(e){let t=this._instance.persistence;if(typeof e==`string`)return t?.get_property(e);let n={};for(let r of e){let e=t?.get_property(r);Hn(e)||(n[r]=e)}return n}set(e,t){var n;(n=this._instance.persistence)==null||n.register(typeof e==`string`?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)==null||t.unregister(e)}},rue=`extensionsRemoteConfig`,iue=class{constructor(e){this.instance=e,this.Io=!1,this.$=Tr,this.cu=e.du,this.kv=new nue(e),this.onEvent=e=>sa(this.instance.on(`eventCaptured`,t=>{try{e({event:t.event,properties:t.properties})}catch(e){this.$.error(`Browser extension event listener failed`,e)}})),this.onRemoteConfig=e=>{if(this.Io)return sa(()=>{});let t=t=>{try{e(t)}catch(e){this.$.error(`Browser extension remote config listener failed`,e)}},n=this.instance.vu.on(rue,t);return this.cu&&t(this.cu),sa(n)},this.fu=new tue(Tr.createLogger(`[BrowserExtensions]`),this)}get logger(){return this.$}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){return this.instance.get_property(`$device_id`)??this.distinctId}get deviceId(){let e=this.instance.get_property(Mr);return typeof e==`string`?e:void 0}get library(){return{name:Ar.LIB_NAME,version:Ar.LIB_VERSION}}get initialPersonProperties(){return this.instance.persistence?.get_initial_props()??{}}get groups(){return this.instance.getGroups()}get session(){try{let e=this.instance.sessionManager?.checkAndGetSessionAndWindowId(!0);return{sessionId:e?.sessionId??``,windowId:e?.windowId??``,sessionStartTimestamp:e?.sessionStartTimestamp??0}}catch{return{sessionId:``,windowId:``,sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this.fu.add(e)}getExtension(e){return this.fu.getExtension(e)}capture(e,t,n){n?this.instance.capture(e,t,{timestamp:n.timestamp,uuid:n.uuid,$set:n.set,$set_once:n.setOnce}):this.instance.capture(e,t)}registerDynamicEventProperties(e){return sa(this.instance.pu(e))}handleRemoteConfig(e){this.Io||(this.cu=e,this.instance.vu.emit(rue,e))}sendRequest(e){var t=this;return er(function*(e,n={}){let r=t.instance.requestRouter.endpointFor(n.target??`api`,e),i={method:n.method,url:n.query?Sa(r,n.query):r,data:n.body,headers:n.headers,timeout:n.timeoutMs,fireCallbackOnDrop:!0,transport:n.transport,compression:n.compression,compressionFallback:n.target===`flags`&&n.compression===`best-available`?_re.Base64:void 0,timestampMode:n.sentAt};return n.transport===`sendBeacon`?(t.instance._send_request(i),{statusCode:202}):new Promise(e=>{i.callback=e,t.instance._send_request(i)})}).apply(this,arguments)}dispose(){this.Io||(this.Io=!0,this.fu.dispose())}},Ma={},Na=0,Pa=()=>{},aue=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,Fa=`Surveys module not available`,oue=`sanitize_properties is deprecated. Use before_send instead`,sue=`Invalid value for property_denylist config: `,cue=/^[A-Za-z0-9_-]{1,400}$/,lue=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,uue=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,due=[`token`,`distinct_id`,Yoe],Ia=`posthog`,fue=e=>{let t={};return e&&e!==`unset`?(`2025-11-30`>e||(t.strictMinimumDuration=!0),`2026-05-30`>e||(t.canvasCapture={resolutionScale:.6}),`2026-06-25`>e||(t.streamNetworkBody=!0),`2026-08-30`>e||(t.captureJsonLd=!0),t):t},La=e=>{var t;return R({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,asset_host:null,token:``,autocapture:!0,cross_subdomain_cookie:hse(Dn?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:Pa,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:e??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:On&&Un(On?.search)&&On.search.indexOf(`__posthog_debug=true`)!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:`fallback`,enable_recording_console_log:void 0,secure_cookie:(wn==null||(t=wn.location)==null?void 0:t.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(e){Tr.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:cse,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:Pa},(e=>({rageclick:e&&e>=`2026-05-30`?{content_ignorelist:qse,ignore_text_selection:!0}:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:fue(e),external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>=`2026-05-30`?250:0,split_storage:!(!e||`2026-05-30`>e),detect_google_search_app:!(!e||`2026-05-30`>e),disable_capture_url_hashes:!(!e||`2026-06-25`>e),cookieWinsOnConflict:!(!e||e===`unset`||`2026-08-29`>e)}))(e))},pue=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`__preview_disable_beacon`,`disable_beacon`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`],[`__preview_cookie_wins_on_conflict`,`cookieWinsOnConflict`]],mue=e=>{let t={};for(let[n,r]of pue)Hn(e[n])||(t[r]=e[n]);let n=pi({},t,e),r=e.__preview_external_dependency_versioned_paths;return Hn(r)||(Hn(e.strict_script_versioning)&&(n.strict_script_versioning=!!r),Un(r)&&Hn(e.asset_host)&&(n.asset_host=r)),Rn(e.property_blacklist)&&(Hn(e.property_denylist)?n.property_denylist=e.property_blacklist:Rn(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Tr.error(sue+e.property_denylist)),n},hue=class{constructor(){this.__forceAllowLocalhost=!1}get gu(){return this.__forceAllowLocalhost}set gu(e){Tr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Ra=class e{mu(e){if(!e)return;let t=this.uu.indexOf(e);t!==-1&&this.uu.splice(t,1)}yu(e,t){var n;return this.mu(e),this.uu.push(t),(n=t.initialize)==null||n.call(t),t}bu(){return this.config.cookieless_mode===`always`||this.config.cookieless_mode===`on_reject`&&this.consent.isRejected()}_u(){if(this.wu||this.config.reuseAnonymousId||this.config.segment||this.bu())return;let e=this.config.persistence===`memory`||this.config.persistence===`sessionStorage`;if(!e&&!this.config.disable_persistence||this.ku)return;let t,n,r;e?(t=`persistence is set to '${this.config.persistence}'`,n=this.config.persistence===`memory`?`on every page load`:`for every new browser tab or window`,r=`Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId.`):(t=`persistence is disabled (disable_persistence is true)`,n=`on every page load`,r=`Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId.`),this.wu=!0,console.warn(`[PostHog.js]`,`${t} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${n}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${r}`)}Su(){if(this.bu()||this.get_distinct_id()!==`$posthog_cookieless`)return;let e=this.persistence;if(!e)return;this.xu()||e.load(!0);let t=this.get_distinct_id();if(!t||t===`$posthog_cookieless`){let t=this.config.get_device_id(yi());this.register({distinct_id:t,$device_id:t}),e.set_property(ei,oi)}this.Cu()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.$u=!1,this.Tu=!1,this.webPerformance=new hue,this.Iu=!1,this.version=Ar.LIB_VERSION,this.Mu=new Set,this.Eu=``,this.vu=new Ta,this.uu=[],this.Pu=[],this.ku=!1,this.wu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=La(),this.SentryIntegration=_ce,this.sentryIntegration=e=>function(e,t){let n=gce(e,t);return{name:hce,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Ru=!1,this.Au=null,this.Fu=null,this.Ou=null,this.scrollManager=new Ple(this),this.pageViewManager=new vce(this),this.rateLimiter=new Gce(this),this.requestRouter=new Jle(this),this.consent=new Nse(this),this.externalIntegrations=new eue(this);let t=e.__defaultExtensionClasses??{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.metrics=t.metrics&&new t.metrics(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,n)=>{let r=Un(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{let r=Un(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,e=>Tr.info(`send "${e?.event}"`,e))}init(t,n,r){if(r&&r!==Ia){let i=Ma[r]??new e;return i._init(t,n,r),Ma[r]=i,Ma[Ia][r]=i,i}return this._init(t,n,r)}_init(e,t={},n){var r;let i=Un(e)?e.trim():``;if(!i)return Tr.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return i===this.config?.token?console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`):console.warn(`[PostHog.js]`,`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${i}', { ... }, 'project2')`),this;this.__loaded=!0,this.config=La(t.defaults),t.debug=this.Du(t.debug),this.Lu=t,this.Nu=[],t.person_profiles?this.Fu=t.person_profiles:t.process_person&&(this.Fu=t.process_person);let a=La(t.defaults),o=mue(t),s=pi({},a,o,{name:n,token:i});Bn(a.rageclick)&&Bn(o.rageclick)&&(s.rageclick=pi({},a.rageclick,o.rageclick)),Bn(a.session_recording)&&Bn(o.session_recording)&&(s.session_recording=pi({},a.session_recording,o.session_recording)),this.set_config(s),this.config.on_xhr_error&&Tr.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=t.disable_compression?void 0:ta.GZipJS;let c=this.xu();if(this.persistence=new Vce(this.config,c),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Vce(R(R({},this.config),{},{persistence:`sessionStorage`}),c,!1),this.Eu=`ph_`+(this.config.persistence_name||this.config.token)+`_session_registered_properties`,this.config.persistence!==`memory`&&!c&&Oi.Et()){let e=Oi.Dt(this.Eu);Rn(e)&&e.forEach(e=>{Un(e)&&this.Mu.add(e)})}else Oi.Lt(this.Eu);let l=R({},this.persistence.props),u=R({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.qu=new jle((e,t)=>this.ju(e,t),this.config.request_queue_config),this.Bu=new Nle(this),this.__request_queue=[];let d=this.bu();d||(this.sessionManager=new Rle(this),this.sessionPropsManager=new Ile(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,n)=>{(n!=null&&n.activityTimeout||n!=null&&n.sessionPastMaximumLength||n!=null&&n.crossTabAdoption)&&this.Hu()})),this.zu(),this.config.__preview_deferred_init_extensions?(Tr.info(`Deferring extension initialization to improve startup performance`),setTimeout(()=>{this.Uu(d)},0)):(Tr.info(`Initializing extensions synchronously`),this.Uu(d)),Ar.DEBUG=Ar.DEBUG||this.config.debug,Ar.DEBUG&&Tr.info(`Starting in debug mode`,{this:this,config:t,thisC:R({},this.config),p:l,s:u}),this.config.identity_distinct_id&&!((r=t.bootstrap)!=null&&r.distinctID)&&(t.bootstrap=R(R({},t.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));let f=t.bootstrap?.distinctID;if(this.ku=!!f&&!Wn(f),t.bootstrap?.distinctID){let e=t.bootstrap.distinctID,n=this.get_distinct_id(),r=this.persistence.get_property(ei);if(t.bootstrap.isIdentifiedID&&n!=null&&n!==e&&r===`anonymous`)this.identify(e);else if(t.bootstrap.isIdentifiedID&&n!=null&&n!==e&&r===`identified`)Tr.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{let n=this.config.get_device_id(yi()),r=t.bootstrap.isIdentifiedID?n:e;this.persistence.set_property(ei,t.bootstrap.isIdentifiedID?si:oi),this.register({distinct_id:e,$device_id:r})}}if(d)this.register_once({distinct_id:ii,$device_id:null},``);else if(!this.get_distinct_id()){let e=this.config.get_device_id(yi());this.register_once({distinct_id:e,$device_id:e},``),this.persistence.set_property(ei,oi)}return gi(wn,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),gi(wn,`pageshow`,()=>{var e;this.$u=!1,this.Tu||(e=this.Bu)==null||e.resume()}),t.segment?mce(this,()=>this.Wu()):this.Wu(),zn(this.config._onCapture)&&this.config._onCapture!==Pa&&(Tr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,e=>this.config._onCapture(e.event,e))),this.config.ip&&Tr.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||function(){return Ble.apply(this,arguments)}().then(e=>{e&&this.register({[Nr]:e})}).catch(Pa),this}Vu(e){let t=e;return Un(t.name)&&zn(t.setup)}Gu(e,t){this.Vu(e)?t.push(()=>{this.Zu().add(e).catch(()=>e.dispose?.call(e)).catch(t=>{Tr.error(`Failed to dispose browser extension "${e.name}"`,t)})}):this.uu.push(e)}zu(){let t=this.config.__extensionClasses?.featureFlags??e.__defaultExtensionClasses?.featureFlags;var n,r,i;t&&(this.featureFlags&&this.featureFlags instanceof t||((n=this.Qu)==null||n.call(this),this.Qu=void 0,this.featureFlags=new t(this)),zn(this.featureFlags.onReloading)&&zn(this.featureFlags.setup)?this.Qu||(this.Qu=this.featureFlags.onReloading(()=>{this.vu.emit(`featureFlagsReloading`,!0)}),this.Zu().add(this.featureFlags)):(r=(i=this.featureFlags).initialize)==null||r.call(i))}Uu(t){let n=performance.now(),r=R(R({},e.__defaultExtensionClasses),this.config.__extensionClasses),i=[];r.exceptions&&this.uu.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.uu.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.uu.push(this.tracingHeaders=new r.tracingHeaders(this)),r.siteApps&&this.uu.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.uu.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),r.autocapture&&this.Gu(this.autocapture=new r.autocapture(this),i),r.surveys&&this.Gu(this.surveys=this.surveys??new r.surveys(this),i),r.logs&&this.Gu(this.logs=this.logs??new r.logs(this),i),r.metrics&&this.uu.push(this.metrics=this.metrics??new r.metrics(this)),r.conversations&&this.uu.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.uu.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.uu.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.uu.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.uu.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.uu.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,fce)),r.toolbar&&this.uu.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.uu.push(this.experiments=this.experiments??new r.experiments(this)),this.uu.forEach(e=>{e.initialize&&i.push(()=>{var t;(t=e.initialize)==null||t.call(e)})}),i.push(()=>{if(this.Ju){let e=this.Ju;this.Ju=void 0,this.uu.forEach(t=>t.onRemoteConfig?.call(t,e))}}),this.Ku(i,n)}Ku(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this.Ku(e,t)},0);let n=e.shift();if(n)try{n()}catch(e){Tr.error(`Error initializing extension:`,e)}}let n=Math.round(performance.now()-t);this.register_for_session({[Xoe]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[Zoe]:n}),this.config.__preview_deferred_init_extensions&&Tr.info(`PostHog extensions initialized (${n}ms)`)}il(e){var t;if(!Dn||!Dn.body)return Tr.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout(()=>{this.il(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Ju=e),this.du=e,this.compression=void 0,e.ok){var n;let t=e.config;t.supportedCompression&&!this.config.disable_compression&&(this.compression=Fn(t.supportedCompression,ta.GZipJS)?ta.GZipJS:Fn(t.supportedCompression,ta.Base64)?ta.Base64:void 0),(n=t.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=t.analytics.endpoint)}this.set_config({person_profiles:this.Fu?this.Fu:cse}),(t=this.Xu)==null||t.handleRemoteConfig(e),this.uu.forEach(t=>t.onRemoteConfig?.call(t,e))}Wu(){try{this.config.loaded(this)}catch(e){Tr.critical("`loaded` function failed",e)}if(this.Yu(),this.config.internal_or_test_user_hostname&&On?.hostname){let e=On.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.bu())&&this.th()},1),this.eh=new Kce(this),this.eh.load()}Yu(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.qu)==null||e.enable())}_dom_loaded(){this.is_capturing()&&di(this.__request_queue,e=>this.ju(e)),this.__request_queue=[],this.Yu()}_handle_unload(){var e,t,n,r,i,a;this.$u=!0,(e=this.surveys)==null||(t=e.handlePageUnload)==null||t.call(e),(n=this.metrics)==null||n.flush(`sendBeacon`),this.config.request_batching?(this.ih()&&this.capture(lse),(r=this.logs)==null||r.flushLogs(`sendBeacon`),(i=this.qu)==null||i.unload(),(a=this.Bu)==null||a.unload()):this.ih()&&this.capture(lse,null,{transport:`sendBeacon`})}_send_request(e){Ale(this,e)}ju(e,t){this.Bu?this.Bu.retriableRequest(e,t):this._send_request(t?R(R({},e),{},{transport:t}):e)}_execute_array(e){Na++;try{let t,n=[],r=[],i=[];di(e,e=>{if(e){if(t=e[0],Rn(t))i.push(e);else if(zn(e))try{e.call(this)}catch(t){Tr.error(`Error executing queued PostHog call`,e,t)}else Rn(e)&&t===`alias`?n.push(e):Rn(e)&&t.indexOf(`capture`)!==-1&&zn(this[t])?i.push(e):r.push(e)}});let a=function(e,t){di(e,function(e){try{if(Rn(e[0])){let n=t;fi(e,function(e){n=n[e[0]].apply(n,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){Tr.error(`Error executing queued PostHog call`,e,t)}})};a(n,this),a(r,this),a(i,this)}finally{Na--}}push(t){if(Na>0&&Rn(t)&&Un(t[0])){let n=e.prototype[t[0]];zn(n)&&n.apply(this,t.slice(1));return}this._execute_array([t])}get nh(){return{property:coe,persistenceKey:Fr,cookieName:`_fbc`,pattern:lue,register:(e,t)=>this.persistence?.register({[Fr]:{value:e,delivered:t}}),unregister:()=>this.persistence?.unregister(Fr)}}get sh(){return{property:loe,persistenceKey:Ir,cookieName:`_fbp`,pattern:uue,register:(e,t)=>this.persistence?.register({[Ir]:{value:e,delivered:t}}),unregister:()=>this.persistence?.unregister(Ir)}}rh(e){let t=this.persistence?.get_property(e.persistenceKey);return Un(t)&&e.pattern.test(t)?{value:t,delivered:!1}:Bn(t)&&Un(t.value)&&e.pattern.test(t.value)?{value:t.value,delivered:!0===t.delivered}:void 0}oh(e,t,n){return t===n?.value?{value:t,pending:!n.delivered}:(e.register(t,!1),{value:t,pending:!0})}ah(e){if(!this.config.save_campaign_params||this.bu())return;let t=vi(e.cookieName);return Un(t)&&e.pattern.test(t)?t:void 0}uh(e,t,n,r){if(!this.persistence)return;let i=this.nh;this.persistence.refreshKey(i.persistenceKey);let a=this.rh(i);if(r)return void i.unregister();if(n)return Un(t)&&lue.test(t)?this.oh(i,t,a):void i.unregister();let o=Un(e)&&cue.test(e)?e:void 0,s=this.ah(i);return s&&((e,t,n)=>{let r=e.split(`.`);if(t)return r[3]===t;if(!n)return!0;let i=n.value.split(`.`);return r[3]===i[3]||Number(r[2])>Number(i[2])})(s,o,a)?this.oh(i,s,a):o?a?.value.split(`.`)[3]===o?{value:a.value,pending:!a.delivered}:this.oh(i,`fb.1.${Date.now()}.${o}`,a):a?{value:a.value,pending:!a.delivered}:void 0}hh(e,t,n){if(!this.persistence)return;let r=this.sh;this.persistence.refreshKey(r.persistenceKey);let i=this.rh(r);if(n)return void r.unregister();if(t)return Un(e)&&uue.test(e)?this.oh(r,e,i):void r.unregister();let a=this.ah(r);return a?this.oh(r,a,i):i?{value:i.value,pending:!i.delivered}:void 0}dh(e,t){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);let n=this.rh(e);n?.value!==t||n.delivered||e.register(t,!0)}capture(e,t,n){if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.qu))return void Tr.uninitializedWarning(`posthog.capture`);if(!this.is_capturing())return;if(Hn(e)||!Un(e))return void Tr.error(`No event name provided to posthog.capture`);this.Su();let r=!this.config.opt_out_useragent_filter&&this._is_bot();if(r&&!this.config.__preview_capture_bot_pageviews)return;let i=n?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(i?.isRateLimited)return void Tr.critical(`This capture call is ignored due to client rate limiting.`);let a;t!=null&&t.$current_url&&!Un(t?.$current_url)&&(Tr.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.fh||Tr.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(a=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();let o=new Date,s=n?.timestamp||o,c=jie(n?.uuid,yi),l={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},s,c)};e===`$pageview`&&this.config.__preview_capture_bot_pageviews&&r&&(l.event=`$bot_pageview`,l.properties.$browser_type=`bot`),i&&(l.properties.$lib_rate_limit_remaining_tokens=i.remainingTokens);let u=e===`$feature_flag_called`&&!1===l.properties.$feature_flag_has_experiment&&!0===this.get_property(`$minimal_flag_called_events`);n!=null&&n.$set&&!u&&(l.$set=n?.$set);let d=Bn(t?.$set)?t.$set:void 0,f=Rn(t?.$unset)?t.$unset:[],p=n?.$unset||[],m=e=>{var t;let r=!!n?.$set&&e in n.$set;return{hasProvided:r||!!d&&e in d,provided:r?n==null||(t=n.$set)==null?void 0:t[e]:d?.[e],unset:f.indexOf(e)!==-1||p.indexOf(e)!==-1}},h=m(coe),g=m(loe),_=[{channel:this.nh,hasProvided:h.hasProvided,update:this.uh(a?.fbclid,h.provided,h.hasProvided,h.unset)},{channel:this.sh,hasProvided:g.hasProvided,update:this.hh(g.provided,g.hasProvided,g.unset)}];for(let{channel:e,hasProvided:t,update:n}of _)n&&!0===l.properties.$process_person_profile&&n.pending&&!t&&!u&&(l.$set=R({[e.property]:n.value},l.$set));let v=n?.$unset;v&&(l.$unset=v);let y=u?void 0:this.ph(n?.$set_once,e!==dse,e===use);if(y&&(l.$set_once=y),n!=null&&n._noTruncate||(b=this.config.properties_string_max_length,l=function(e,t){let n=new Set;return function e(r,i){if(r!==Object(r))return t?t(r):r;if(n.has(r))return;let a;if(n.add(r),Rn(r))a=[],di(r,t=>{a.push(e(t))});else{let t={};fi(Zn(r)?pse(r):r,(r,i)=>{n.has(r)||(t[i]=e(r,i))}),a=t}return a}(e)}(l,e=>Un(e)?e.slice(0,b):e)),l.timestamp=s,Hn(n?.timestamp)||(l.properties.$event_time_override_provided=!0,l.properties.$event_time_override_system_time=o),u&&(l.properties=((e,t=[])=>{let n={},r=t=>{e[t]!==void 0&&(n[t]=e[t])};return Eae.forEach(r),t.forEach(r),n})(l.properties,due)),e===ia.DISMISSED||e===ia.SENT){let n=t?.[aa.SURVEY_ID],r=t?.[aa.SURVEY_ITERATION];Yle({id:n,current_iteration:r}),l.$set=R(R({},l.$set),{},{[Vle({id:n,current_iteration:r},e===ia.SENT?`responded`:`dismissed`)]:!0})}else e===ia.SHOWN&&(l.$set=R(R({},l.$set),{},{[aa.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var b;if(e===Hce.SHOWN){let e=t?.[Uce.TOUR_TYPE];e&&(l.$set=R(R({},l.$set),{},{[`${Uce.TOUR_LAST_SEEN_DATE}/${e}`]:new Date().toISOString()}))}let x=R(R({},l.properties.$set),l.$set);if(Vn(x)||this.setPersonPropertiesForFlags(x),!Kn(this.config.before_send)){let e=this.Os(l);if(!e)return;l=e,l.uuid=jie(l.uuid,yi)}let S=_.filter(({channel:e,update:t})=>{let n=l.$set?.[e.property]??(Bn(l.properties?.$set)?l.properties.$set[e.property]:void 0);return t?.pending&&n===t.value});this.vu.emit(`eventCaptured`,l);let C=n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),w=n?._batchKey===`recordings`||/\/s\/(?:\?|$)/.test(C),T=R(R(R({method:`POST`,url:C,data:l,compression:`best-available`,preferSyncCompression:n?.send_instantly,timestampMode:w?`body`:`capture-body`,batchKey:n?._batchKey},w&&l.properties?.$session_id?{batchGroup:l.properties.$session_id+(l.properties.$window_id?`-${l.properties.$window_id}`:``)}:{}),n?.transport?{transport:n.transport}:{}),S.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(let{channel:e,update:t}of S)this.dh(e,t.value)}}:{});if(!this.config.request_batching||n&&!n?._batchKey||n?.send_instantly||S.length){let e;!T.transport&&!T.callback&&Vn(this.config.request_headers??{})&&this.$u&&(e=`sendBeacon`),this.ju(T,e)}else this.qu.enqueue(T);return l}_addCaptureHook(e){return this.on(`eventCaptured`,t=>e(t.event,t))}getExtension(e){return this.Xu?.getExtension(e)}Zu(){return this.Xu??=new iue(this)}pu(e){this.Pu.push(e);let t=!0;return()=>{if(!t)return;t=!1;let n=this.Pu.indexOf(e);n!==-1&&this.Pu.splice(n,1)}}gh(e=!0){var t,n;return!!this.persistence?.consumeCookieIdentityChange()&&(this.Ou=null,this.persistence.get_property(`$user_state`)===`anonymous`&&((n=this.sessionPersistence)==null||n.clear(),this.Mu.clear(),this.mh()),(t=this.featureFlags)==null||t.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,t,n,r,i){if(n||=new Date,!this.persistence||!this.sessionPersistence)return t;this.persistence.syncCookieProperties(),this.gh();let a=i?void 0:this.persistence.remove_event_timer(e),o=R({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.bu()&&(o[Yoe]=!0),e===`$snapshot`){let e=R(R({},this.persistence.properties()),this.sessionPersistence.properties());return o.distinct_id=e.distinct_id,(!Un(o.distinct_id)&&!qn(o.distinct_id)||Wn(o.distinct_id))&&Tr.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),o}let s=function(e,t,n,r=!1){var i,a,o;if(!An)return{};let s=e?[...Ki,...t||[]]:[],[c,l]=Sie(An),[u,d]=function(e){for(let t=0;Eie.length>t;t++){let[n,r,i]=Eie[t],a=e.match(n);if(a)return[r,(i&&e.match(i)||a)?.[1]||``]}return[``,``]}(An),f=function(){return(`u`>typeof navigator?navigator:void 0)?.brave?{brave:!0}:{}}(),p={};Hn(n)||(p.detectGoogleSearchApp=n);let m={},h=(i=navigator)==null||(i=i.userAgentData)==null?void 0:i.platform,g=navigator?.maxTouchPoints,_=wn==null||(a=wn.screen)==null?void 0:a.width,v=wn==null||(o=wn.screen)==null?void 0:o.height,y=wn?.devicePixelRatio;Hn(h)||(m.userAgentDataPlatform=h),Hn(g)||(m.maxTouchPoints=g),Hn(_)||(m.screenWidth=_),Hn(v)||(m.screenHeight=v),Hn(y)||(m.devicePixelRatio=y);let b=pi(hi({$os:c,$os_version:l,$browser:vie(An,navigator.vendor,f,p),$webview_app:u,$webview_app_version:d,$device:Cie(An),$device_type:wie(An,m),$timezone:Nce(),$timezone_offset:Pce()}),{$current_url:Wi(r?hr(On?.href):On?.href,s,qi),$host:On?.host,$pathname:On?.pathname,$raw_user_agent:An.length>1e3?An.substring(0,997)+`...`:An,$browser_version:bie(An,navigator.vendor,f,p),$browser_language:Oce(),$browser_language_prefix:kce(),$screen_height:wn?.screen.height,$screen_width:wn?.screen.width,$viewport_height:wn?.innerHeight,$viewport_width:wn?.innerWidth,$lib:Nn.LIB_NAME,$lib_version:Nn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Nn.SDK_DIST_CHANNEL&&(b.$sdk_dist_channel=Nn.SDK_DIST_CHANNEL),b}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){let{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(i,n.getTime(),!0);o.$session_id=e,o.$window_id=t}this.sessionPropsManager&&pi(o,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&pi(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=this.Bu?.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}let c;if(this.requestRouter.region===Aa&&(o.$lib_custom_api_host=this.config.api_host),c=e!==`$pageview`||i?e!==`$pageleave`||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,r),o=pi(o,c),e===`$pageview`&&Dn&&(o.title=Dn.title),!Hn(a)){let e=n.getTime()-a;o.$duration=parseFloat((e/1e3).toFixed(3))}An&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?`bot`:`browser`);let l=this.persistence.properties(),u=this.sessionPersistence.properties(),d=o.$groups,f=l.$groups;Bn(d)&&!Vn(d)&&(o.$groups=R(R({},Bn(f)?f:{}),d)),fi([`$referrer`,`$referring_domain`],e=>{e in l&&delete u[e]});let p={};if(this.Pu.length>0)for(let e of this.Pu.slice())try{pi(p,e())}catch(e){Tr.error(`Failed to produce browser extension event properties`,e)}o=pi({},s,l,u,R(R({},p),o)),o.$is_identified=this._isIdentified(),Rn(this.config.property_denylist)?fi(this.config.property_denylist,function(e){delete o[e]}):Tr.error(sue+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);let m=this.config.sanitize_properties;m&&(Tr.error(oue),o=m(o,e));let h=this.yh();return o.$process_person_profile=h,h&&!i&&this.bh(`_calculate_event_properties`),o}ph(e,t=!0,n=!1){if(!this.persistence||!this.yh()||this.Iu&&!n)return e;let r=this.persistence.get_initial_props(),i=this.sessionPropsManager?.getSetOnceProps(),a=pi({},r,i||{},e||{}),o=this.config.sanitize_properties;return o&&(Tr.error(oue),a=o(a,`$set_once`)),t&&(this.Iu=!0),Vn(a)?void 0:a}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t,n;(t=this.persistence)==null||t.syncCookieProperties(),this.gh(),(n=this.sessionPersistence)==null||n.register(e),Object.keys(e).forEach(e=>this.Mu.add(e)),this.mh()}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e),this.Mu.delete(e),this.mh()}_h(e,t){this.register({[e]:t})}Hu(){this.Mu.forEach(e=>{var t;(t=this.sessionPersistence)==null||t.unregister(e)}),this.Mu.clear(),this.mh()}mh(){if(!this.Eu)return;if(this.config.persistence===`memory`||this.sessionPersistence?.mi||!Oi.Et())return void Oi.Lt(this.Eu);let e=[];this.Mu.forEach(t=>e.push(t)),e.length>0?Oi.At(this.Eu,e):Oi.Lt(this.Eu)}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}getAllFeatureFlags(){return this.featureFlags?.getAllFeatureFlags()??[]}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)??t?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t=!1,n){return this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.vu.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Fa}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Fa})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Fa})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t=Zle){var n;(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:Fa}}canRenderSurveyAsync(e,t=!1){return this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:Fa})}wh(e){return!e||Wn(e)?(Tr.critical(`Unique user id has not been set in posthog.identify`),!1):e===`$posthog_cookieless`?(Tr.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(Tr.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return Tr.uninitializedWarning(`posthog.identify`);if(qn(e)&&(e=e.toString(),Tr.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),!this.wh(e)||!this.bh(`posthog.identify`))return;this.Su();let r=this.get_distinct_id(),i=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,a=this.gh(!1),o=this.persistence.Da(),s=!1;try{let r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(`$device_id`)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(`__alias`)&&(this.unregister(Pr),this.register({distinct_id:e}));let o=(this.persistence.get_property(`$user_state`)||`anonymous`)===oi,l=e!==r,u=!l&&o;if(l&&o){var c;let i=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:r};this.persistence.set_property(ei,si),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.La(),this.capture(`$identify`,i,{$set:t||{},$set_once:n||{}})&&(this.Ou=ka(e,t,n)),(c=this.featureFlags)==null||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:r)}else if(u){this.persistence.set_property(ei,si);let r=t||{},i=n||{};this.setPersonPropertiesForFlags({$set:r,$set_once:i},!1),this.config.cookieWinsOnConflict&&this.persistence.La(),this.capture(`$set`,{$set:r,$set_once:i})&&(this.Ou=ka(e,t,n))}else(t||n)&&this.setPersonProperties(t,n);l||i||a?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(Xr)):u&&(t||n)&&this.reloadFeatureFlags(),s=!0}finally{o&&this.persistence.ja(s)}}setPersonProperties(e,t){if(!e&&!t||!this.bh(`posthog.setPersonProperties`))return;let n=ka(this.get_distinct_id(),e,t);this.Ou===n?Tr.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}})&&(this.Ou=n))}unsetPersonProperties(e){var t;let n=(Rn(e)?e:[e]).filter(e=>Un(e)&&e.length>0);n.length!==0&&this.bh(`posthog.unsetPersonProperties`)&&((t=this.featureFlags)==null||t.unsetPersonPropertiesForFlags(n,!0),this.capture(`$set`,{$unset:n}),this.Ou=null)}group(e,t,n){var r;if(!e||!t)return void Tr.error(`posthog.group requires a group type and group key`);(r=this.persistence)==null||r.syncCookieProperties(),this.gh();let i=this.getGroups(),a=i[e]!==t;if(a&&this.resetGroupPropertiesForFlags(e),this.register({$groups:R(R({},i),{},{[e]:t})}),(a||n)&&this.yh()){let r={$group_type:e,$group_key:t};n&&(r.$group_set=n),this.capture(dse,r)}n&&this.setGroupPropertiesForFlags({[e]:n}),a&&!n&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var n;(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;(t=this.featureFlags)==null||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var n;this.bh(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){let t=Yn(e)?e:e?.resetDeviceID,n=Yn(e)||e==null?void 0:e.bootstrap;this.kh(t,!1,n)}kh(e,t=!1,n){var r,i,a,o,s;if(Tr.info(`reset`),!this.__loaded)return Tr.uninitializedWarning(`posthog.reset`);let c=n?.sessionID;this.config.bootstrap=n||this.Lu?.bootstrap||{},(r=this.featureFlags)==null||(i=r.updateConfig)==null||i.call(r,this.config,this.nl());let l=this.get_property(Mr),u=this.get_property(Nr),d=this.get_property(Lr);(a=this.sessionRecording)==null||a.flushBeforeIdentityReset();let f=this.is_capturing();this.consent.reset(),t||!f||this.is_capturing()||console.warn(`[PostHog.js]`,"reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");let p=(o=this.persistence)==null||(s=o.Da)==null?void 0:s.call(o),m=!1;try{var h,g,_,v,y,b,x,S,C,w,T,E;if((h=this.persistence)==null||h.clear(),(g=this.sessionPersistence)==null||g.clear(),this.Mu.clear(),this.mh(),Hn(d)||(w=this.persistence)==null||w.register({$session_recording_remote_config:d}),(_=this.surveys)==null||_.reset(),(v=this.featureFlags)==null||v.reset(),(y=this.conversations)==null||y.reset(),(b=this.logs)==null||b.reset(),(x=this.metrics)==null||x.reset(),(S=this.persistence)==null||S.set_property(`$user_state`,`anonymous`),(C=this.sessionManager)==null||C.resetSessionId(),this.Ou=null,this.config.cookieless_mode===`always`)this.register_once({distinct_id:ii,$device_id:null},``);else{let t=this.config.get_device_id(yi());this.register_once({distinct_id:t,$device_id:e?t:l},``),e||Hn(u)||this.register({[Nr]:u})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),n&&(n.distinctID&&!this.bu()&&((E=this.persistence)==null||E.set_property(`$user_state`,n.isIdentifiedID?`identified`:`anonymous`),this.register({distinct_id:n.distinctID})),(T=this.featureFlags)==null||T.initialize(),!Kn(c)&&!this.sessionManager?.setBootstrapSessionId(c,!0))){let e=R({},n);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,m=!0}finally{var D,O;p&&((D=this.persistence)==null||(O=D.ja)==null||O.call(D,m))}this.reloadFeatureFlags()}shutdown(e){var t=this;return er(function*(){var e,n,r,i,a,o,s,c;if(t.__loaded){t.Tu=!0,t.Zu().dispose(),(e=t.sessionRecording)==null||e.dispose(),(n=t.logs)==null||n.flushLogs(`sendBeacon`),(r=t.metrics)==null||r.flush(`sendBeacon`),(i=t.metrics)==null||i.dispose(),(a=t.qu)==null||a.unload(),(o=t.Bu)==null||o.unload();try{var l;(l=t.featureFlags)==null||l.destroy()}catch(e){Tr.error(`Error while destroying feature flags`,e)}(s=t.persistence)==null||s.destroy(),(c=t.sessionPersistence)==null||c.destroy()}else Tr.uninitializedWarning(`posthog.shutdown`)})()}setIdentity(e,t){var n;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.Sh()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)==null||e.xh()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;let{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor(`ui`,`/project/${this.config.token}/replay/${t}`);if(e?.withTimestamp&&n){let t=e.timestampLookBack??10;if(!n)return r;r+=`?t=${Math.max(Math.floor((new Date().getTime()-n)/1e3)-t,0)}`}return r}alias(e,t){return e===this.get_property(`$people_distinct_id`)?(Tr.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.bh(`posthog.alias`)?(Hn(t)&&(t=this.get_distinct_id()),e===t?(Tr.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this._h(Pr,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){let t=R({},this.config);if(Bn(e)){var n,r,i,a,o,s,c,l,u,d,f,p,m,h;pi(this.config,mue(e));let _=this.xu();(n=this.persistence)==null||n.update_config(this.config,t,_),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Vce(R(R({},this.config),{},{persistence:`sessionStorage`}),_,!1);let v=this.Du(this.config.debug);var g;Yn(v)&&(this.config.debug=v),Yn(this.config.debug)&&(this.config.debug?(Ar.DEBUG=!0,Ci.Et()&&Ci.At(`ph_debug`,!0),Tr.info(`set_config`,{config:e,oldConfig:t,newConfig:R({},this.config)})):(Ar.DEBUG=!1,Ci.Et()&&Ci.Lt(`ph_debug`))),(r=this.featureFlags)==null||(i=r.updateConfig)==null||i.call(r,this.config,this.nl()),(a=this.exceptionObserver)==null||a.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(s=this.metrics)==null||s.onConfigChange(),(c=this.sessionRecording)==null||c.startIfEnabledOrStop(),(l=this.tracingHeaders)==null||l.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(d=this.heatmaps)==null||d.startIfEnabled(),(`capture_pageview`in e||`disable_capture_url_hashes`in e)&&((g=this.historyAutocapture)==null||g.startIfEnabledOrStop()),(f=this.exceptionObserver)==null||f.startIfEnabledOrStop(),(p=this.deadClicksAutocapture)==null||p.startIfEnabledOrStop(),(m=this.surveys)==null||m.loadIfEnabled(),this.Cu(),(h=this.externalIntegrations)==null||h.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&mce(this,Pa,!1)}}_overrideSDKInfo(e,t){Ar.LIB_NAME=e,Ar.LIB_VERSION=t}startSessionRecording(e){let t=!0===e,n={sampling:t||!!e?.sampling,linked_flag:t||!!e?.linked_flag,url_trigger:t||!!e?.url_trigger,event_trigger:t||!!e?.event_trigger};var r,i,a,o,s;Object.values(n).some(Boolean)&&((r=this.sessionManager)==null||r.checkAndGetSessionAndWindowId(),n.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),n.linked_flag&&((a=this.sessionRecording)==null||a.overrideLinkedFlag()),n.url_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger(`url`)),n.event_trigger&&((s=this.sessionRecording)==null||s.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){return!!this.sessionRecording?.started}captureException(e,t){try{if(!this.exceptions)return;let n=this.exceptions.buildProperties(e,{handled:!0,syntheticException:Error(`PostHog syntheticException`)});return this.exceptions.sendExceptionEvent(R(R({},n),t))}catch{return}}addExceptionStep(e,t){var n;(n=this.exceptions)==null||n.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??e.Ch}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){let e=this.config.name??Ia;return e!==Ia&&(e=`posthog.`+e),e}_isIdentified(){return this.persistence?.get_property(`$user_state`)===`identified`||this.sessionPersistence?.get_property(`$user_state`)===`identified`}yh(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===`identified_only`&&!this._isIdentified()&&Vn(this.getGroups())&&!((e=this.persistence)!=null&&(e=e.props)!=null&&e.__alias)&&!((t=this.persistence)!=null&&(t=t.props)!=null&&t.$epp))}ih(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&!!this.config.capture_pageview}createPersonProfile(){this.yh()||this.bh(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.bh(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}bh(e){return this.config.person_profiles===`never`?(Tr.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this._u(),this._h(ri,!0),!0)}xu(){if(this.config.cookieless_mode===`always`)return!0;let e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==`on_reject`)}Cu(){let e=this.xu();var t,n,r;return this.is_capturing()||(t=this.logs)==null||t.$h(),this.persistence?.mi!==e&&((n=this.persistence)==null||n.set_disabled(e)),this.sessionPersistence?.mi!==e&&((r=this.sessionPersistence)==null||r.set_disabled(e)),e&&(this.Mu.clear(),this.mh()),e}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==`always`){if(this.bu()){var r,i,a;(r=this.sessionRecording)==null||r.dispose({discardBufferedEvents:!0}),this.kh(!0,!0),(i=this.sessionManager)==null||i.destroy(),(a=this.pageViewManager)==null||a.destroy(),this.sessionManager=new Rle(this),this.pageViewManager=new vce(this),this.persistence&&(this.sessionPropsManager=new Ile(this,this.sessionManager,this.persistence));let t=this.config.__extensionClasses?.sessionRecording??e.__defaultExtensionClasses?.sessionRecording;var o,s;t&&(this.sessionRecording=this.yu(this.sessionRecording,new t(this)),this.du&&((o=this.sessionRecording)==null||(s=o.onRemoteConfig)==null||s.call(o,this.du)))}var c;this.consent.optInOut(!0),this.Cu(),this.Yu(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==`on_reject`&&((c=this.surveys)==null||c.loadIfEnabled()),(Hn(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture(t?.captureEventName??`$opt_in`,t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.th()}else Tr.warn(aue)}opt_out_capturing(){if(this.config.cookieless_mode===`always`)return void Tr.warn(aue);let e=this.config.cookieless_mode===`on_reject`?this.sessionRecording:void 0;var t,n;e?.dispose({discardBufferedEvents:!0}),this.config.cookieless_mode===`on_reject`&&this.consent.isOptedIn()&&this.kh(!0,!0),this.consent.optInOut(!1),this.Cu(),this.config.cookieless_mode===`on_reject`&&(this.register({distinct_id:ii,$device_id:null}),this.mu(e),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.th(),this.Yu())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){let e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===`always`||(this.config.cookieless_mode===`on_reject`?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Cu()}_is_bot(){return En?zle(En,this.config.custom_blocked_useragents):void 0}th(){Dn&&(Dn.visibilityState===`visible`?this.Ru||(this.Ru=!0,this.capture(ui,{title:Dn.title},{send_instantly:!0}),this.Au&&=(Dn.removeEventListener(ci,this.Au),null)):this.Au||(this.Au=this.th.bind(this),gi(Dn,ci,this.Au)))}debug(e){!1===e?(wn?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(wn?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}nl(){let e=this.Lu||{};return`advanced_disable_flags`in e?!!e.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(Tr.warn(`Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version.`),!0):function(e,t,n,r,i){let a=t in e&&!Kn(e[t]),o=n in e&&!Kn(e[n]);return a?e[t]:!!o&&(i&&i.warn(`Config field '${n}' is deprecated. Please use '${t}' instead. The old field will be removed in a future major version.`),e[n])}(e,`advanced_disable_flags`,`advanced_disable_decide`,0,Tr):!!this.config.advanced_disable_flags}Os(e){if(Kn(this.config.before_send))return e;let t=Object.keys(e.properties??{}).filter(Tre),n=Rn(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(let t of n)try{if(r=t(r),Kn(r)){let t=`Event '${e.event}' was rejected in beforeSend function`;return wre(e.event)?Tr.warn(`${t}. This can cause unexpected behavior.`):Tr.info(t),null}r.properties&&!Vn(r.properties)||Tr.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return Tr.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(let n of t)if(r.properties&&Kn(r.properties[n]))return Tr.warn(`Event '${e.event}' had its '${n}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){return this.pageViewManager.Vo?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Du(e){let t=Yn(e)&&!e,n=Ci.Et()&&Ci.Ot(`ph_debug`)===`true`;return!t&&(!!n||e)}};Ra.__defaultExtensionClasses={},Ra.Ch=(()=>{let e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(let n=0;t.length>n;n++)e.prototype[t[n]]=fse(e.prototype[t[n]])}(Ra,[`identify`]);var gue=class{constructor(e){this.disabled=!1===e;let t=Bn(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;let r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},za=`$copy_autocapture`,Ba=Er(`[AutoCapture]`);function Va(e,t){return t.length>e?t.slice(0,e)+`...`:t}function _ue(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!ki(t));return t}function vue(e,{e:t,maskAllElementAttributes:n,maskAllText:r,elementAttributeIgnoreList:i,elementsChainAsString:a,disableCaptureUrlHashes:o}){if(!ki(e))return{props:{}};let s=[e],c=new Set([e]),l=e;for(;l.parentNode&&!Ai(l,`body`)&&1e3>s.length;){if(Lse(l.parentNode)){let e=l.parentNode.host;if(c.has(e))break;c.add(e),s.push(e),l=e;continue}if(!ki(l.parentNode)||c.has(l.parentNode))break;c.add(l.parentNode),s.push(l.parentNode),l=l.parentNode}let u=t.type===`click`&&e.namespaceURI===`http://www.w3.org/2000/svg`?s.findIndex(e=>Ai(e,`button`)||Ai(e,`a`)):-1;u>0&&(r||=s.slice(0,u+1).some(e=>!Pi(e)||Fi(e)));let d=[],f={},p,m=!1,h=!1;if(fi(s,e=>{let t=Pi(e);if(Ai(e,`a`)&&!n&&!i?.includes(`href`)){let n=e.getAttribute(`href`);m=!!(t&&n&&Ii(n))&&(o?hr(n):n)}Fn(ji(e),`ph-no-capture`)&&(h=!0),d.push(function(e,t,n,r,i=!1){let a=e.tagName.toLowerCase(),o={tag_name:a};Vse.indexOf(a)>-1&&!n&&(o.$el_text=a.toLowerCase()===`a`||a.toLowerCase()===`button`?Va(1024,sce(e)):Va(1024,Mi(e)));let s=ji(e);t||r!=null&&r.includes(`class`)||0>=s.length||(o.classes=s.filter(function(e){return e!==``})),fi(e.attributes,function(n){var a;if((!Fi(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&!r?.includes(n.name)&&!t&&Ii(n.value)&&(!Un(a=n.name)||a.substring(0,10)!==`_ngcontent`&&a.substring(0,7)!==`_nghost`)){let e=n.value;n.name===`class`&&(e=Rse(e).join(` `)),o[`attr__`+n.name]=Va(1024,n.name===`href`&&i?hr(e):e)}});let c=1,l=1,u=e;for(;u=_ue(u);)c++,u.tagName===e.tagName&&l++;return o.nth_child=c,o.nth_of_type=l,o}(e,n,r,i,o)),fi(function(e){if(!Pi(e))return{};let t={};return fi(e.attributes,function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){let n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&Ii(r)&&(t[n]=r)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(f,t)||(f[t]=e)})}),h)return{props:{},explicitNoCapture:h};if(u>0&&(e=s[u],d.splice(0,u)),r||(d[0].$el_text=Ai(e,`a`)||Ai(e,`button`)?sce(e):Mi(e)),m){var g;d[0].attr__href=m;let e=Hi(m)?.host,t=wn==null||(g=wn.location)==null?void 0:g.host;e&&t&&e!==t&&(p=m)}return{props:pi((v=t.type,{$event_type:v,$ce_version:1}),a?{}:{$elements:d},{$elements_chain:(_=d,Rn(_)?function(e){return e.map(e=>{let t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class){e.attr_class.sort();for(let n of e.attr_class)t+=`.${n.replace(/"/g,``)}`}let n=R(R(R(R({},e.text?{text:e.text}:{}),{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return mi(n).sort(([e],[t])=>function(e,t){return t>e?-1:+(e>t)}(e,t)).forEach(([e,t])=>r[lce(e.toString())]=lce(t.toString())),t+=`:`,t+=mi(r).map(([e,t])=>`${e}="${t}"`).join(``),t}).join(`;`)}(function(e){return e.map(e=>{let t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:uce(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return mi(e).filter(([e])=>e.indexOf(`attr__`)===0).forEach(([e,n])=>t.attributes[e]=n),t})}(_)):``)},d[0]?.$el_text?{$el_text:d[0]?.$el_text}:{},p&&t.type===`click`?{$external_click_url:p}:{},f),target:e};var _,v}var yue=class{fo(){this.po=void 0,clearTimeout(this.mo),this.mo=void 0}yo(e){if(!Pi(e))return!0;let t=this.bo().css_selector_ignorelist??Gse,n=new Set,r=e;for(;r;){if(n.size>=1e3||n.has(r))return!0;n.add(r);let e=r,i=ji(e);if(Fn(i,`ph-no-capture`)||Fn(i,`ph-sensitive`)||Fi(e)||t.some(t=>Hse(e,t)))return!0;let a=r.parentNode;r=Lse(a)?a.host:a&&ki(a)?a:null}return!1}_o(e){if(!this.isEnabled||e.type===`pointercancel`)return void this.fo();if(e.type===`pointerdown`){this.fo();let t=Ni(e);e.isPrimary&&e.button===0&&!e.ctrlKey&&t&&ki(t)&&(this.po={target:t,excluded:this.yo(t),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:this.wo?.distinctId});return}let t=this.po;t&&(e.pointerId!==t.id||Math.abs(e.clientX-t.x)>5||Math.abs(e.clientY-t.y)>5?this.fo():e.type===`pointerup`&&(t.released=!0,this.mo=setTimeout(()=>this.fo(),0)))}ko(e){let t=this.po;this.fo();let n=Ni(e);if(t?.released&&t.target.isConnected&&t.distinctId===this.wo?.distinctId&&e.pointerId===t.id&&(e.detail>0||e.pointerType===`touch`||e.pointerType===`pen`)&&e.button===0&&5>=Math.abs(e.clientX-t.x)&&5>=Math.abs(e.clientY-t.y)&&n&&(Ai(n,`html`)||Ai(n,`body`))){if(t.excluded)return null;let e=this.bo().css_selector_ignorelist??Gse;return[n,Dn?.documentElement,Dn?.body].some(t=>{if(!t)return!1;let n=ji(t);return Fn(n,`ph-no-capture`)||Fn(n,`ph-sensitive`)||!Pi(t)||Fi(t)||e.some(e=>Hse(t,e))})?null:t.target}}constructor(e){this.So=e,this.name=`autocapture`,this.xo=!1,this.Co=null,this.$o=!1,this.To=!1,this.Rr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Io=!1,this.So.refresh(this.Rr),this.rageclicks=new gue(this.Rr.rageclick),this.Mo=null}setup(e){this.Eo(),this.wo=e;let t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.Io?t.dispose():(this.Po=t,this.startIfEnabled())}dispose(){var e;this.Io||(this.Io=!0,this.wo=void 0,(e=this.Po)==null||e.dispose(),this.Po=void 0,this.Ro())}bo(){return this.So.refresh(this.Rr),this.Rr}Eo(){return this.bo(),this.Rr.url_allowlist=this.Rr.url_allowlist?.map(e=>new RegExp(e)),this.Rr.url_ignorelist=this.Rr.url_ignorelist?.map(e=>new RegExp(e)),this.Rr}Ao(){if(!this.isBrowserSupported())return void Ba.info(`Disabling Automatic Event Collection because this browser is not supported`);if(!wn||!Dn)return;let e=this.Fo=e=>{e||=wn?.event;try{if(e.type===`blur`)return void this.fo();if(e.type.indexOf(`pointer`)===0)return void this._o(e);let t=e.type===`click`?this.ko(e):void 0;if(Gn(t))return;this.Oo(e,`$autocapture`,t)}catch(e){Ba.error(`Failed to capture event`,e)}};if(gi(wn,`blur`,e),gi(Dn,`submit`,e,{capture:!0}),gi(Dn,`change`,e,{capture:!0}),gi(Dn,`click`,e,{capture:!0}),fi([`pointerdown`,`pointermove`,`pointerup`,`pointercancel`],t=>{gi(Dn,t,e,{capture:!0})}),this.bo().capture_copied_text){let e=this.Do=e=>{e||=wn?.event;try{this.Oo(e,za)}catch(e){Ba.error(`Failed to capture clipboard event`,e)}};gi(Dn,`copy`,e,{capture:!0}),gi(Dn,`cut`,e,{capture:!0}),gi(Dn,`paste`,e,{capture:!0})}}Ro(){this.fo(),this.Fo&&=(wn?.removeEventListener(`blur`,this.Fo),fi([`pointerdown`,`pointermove`,`pointerup`,`pointercancel`],e=>{Dn?.removeEventListener(e,this.Fo,!0)}),Dn?.removeEventListener(`submit`,this.Fo,!0),Dn?.removeEventListener(`change`,this.Fo,!0),Dn?.removeEventListener(`click`,this.Fo,!0),void 0),this.Do&&=(Dn?.removeEventListener(`copy`,this.Do,!0),Dn?.removeEventListener(`cut`,this.Do,!0),Dn?.removeEventListener(`paste`,this.Do,!0),void 0),this.xo=!1}startIfEnabled(){this.isEnabled||this.fo(),!this.Io&&this.wo&&this.isEnabled&&!this.xo&&(this.Ao(),this.xo=!0)}onRemoteConfig(e){if(this.Io)return;if(this.$o=!0,!e.ok)return void this.startIfEnabled();let t=e.config;t.elementsChainAsString&&(this.To=t.elementsChainAsString);let n=t.autocapture_opt_out;var r;Yn(n)&&((r=this.wo)==null||r.kv.set(`$autocapture_disabled_server_side`,n),this.Co=n),this.startIfEnabled()}setElementSelectors(e){this.Mo=e}getElementSelectors(e,t){var n;let r=[];return(n=this.Mo)==null||n.forEach(n=>{(Dn?.querySelectorAll(n))?.forEach(i=>{e!==i&&t!==i||Fn(r,n)||r.push(n)})}),r}get isEnabled(){if(this.Io)return!1;let e=this.wo?.kv.get(doe),t=this.Co,n=this.bo();if(!n.remoteRequestsDisabled&&!this.$o)return!1;let r=n.remoteRequestsDisabled&&!this.$o;if(Gn(t)&&!Yn(e)&&!r)return!1;let i=this.Co??!!e;return!!n.enabled&&!i}Oo(e,t=`$autocapture`,n){if(!this.isEnabled)return void this.fo();let r=n||Ni(e);Ise(r)&&(r=r.parentNode||null);let i=this.Eo();var a;t===`$autocapture`&&e.type===`click`&&e instanceof MouseEvent&&i.rageclick&&(a=this.rageclicks)!=null&&a.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&Zse(r,i.rageclick)&&this.Oo(e,`$rageclick`,n);let o=t===za,s=o?R(R({},i),{},{dom_event_allowlist:void 0}):i;if(r&&function(e,t,n,r,i,a){if(!wn||Qse(e)||n?.url_allowlist&&!zse(n.url_allowlist,a)||n?.url_ignorelist&&zse(n.url_ignorelist,a))return!1;if(n?.dom_event_allowlist){let e=n.dom_event_allowlist;if(e&&!e.some(e=>t.type===e))return!1}let{parentIsUsefulElement:o,targetElementList:s}=$se(e,r);if(!function(e,t){let n=t?.element_allowlist;if(Hn(n))return!0;for(let t of e)if(n.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(s,n)||!Use(s,n?.css_selector_allowlist)||Use(s,n?.css_selector_ignorelist??Gse))return!1;try{let n=wn.getComputedStyle(e);if(n&&n.getPropertyValue(`cursor`)===`pointer`&&t.type===`click`)return!0}catch{}let c=e.tagName.toLowerCase();switch(c){case`html`:return!1;case`form`:return(i||[`submit`]).indexOf(t.type)>=0;case`input`:case`select`:case`textarea`:return(i||[`change`,`click`]).indexOf(t.type)>=0;default:return o?(i||[`click`]).indexOf(t.type)>=0:(i||[`click`]).indexOf(t.type)>=0&&(Vse.indexOf(c)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,s,o,o?[`copy`,`cut`,`paste`]:void 0,{config:{get_current_url:i.getCurrentUrl}})){var c;let{props:n,explicitNoCapture:a,target:o}=vue(r,{e,maskAllElementAttributes:i.maskAllElementAttributes,maskAllText:i.maskAllText,elementAttributeIgnoreList:i.element_attribute_ignorelist,elementsChainAsString:this.To,disableCaptureUrlHashes:i.disableCaptureUrlHashes});if(a)return!1;let s=this.getElementSelectors(r,o);if(s&&s.length>0&&(n.$element_selectors=s),t===za){let t=e.type||`clipboard`;if(t!==`paste`){var l;let e=wn==null||(l=wn.getSelection())==null?void 0:l.toString(),t=Bse(e);if(!t)return!1;n.$selected_content=t,n.$clipboard_text_length=e?.length??0}n.$copy_type=t}return(c=this.wo)==null||c.capture(t,n),!0}}isBrowserSupported(){return zn(Dn?.querySelectorAll)}},bue=class{constructor(e){this._instance=e}refresh(e){let t=this._instance.config,n=Bn(t.autocapture)?t.autocapture:void 0;e.enabled=!!t.autocapture,e.rageclick=t.rageclick,e.maskAllElementAttributes=t.mask_all_element_attributes,e.maskAllText=t.mask_all_text,e.disableCaptureUrlHashes=t.disable_capture_url_hashes,e.getCurrentUrl=t.get_current_url,e.remoteRequestsDisabled=this._instance.nl(),e.url_allowlist=n?.url_allowlist,e.url_ignorelist=n?.url_ignorelist,e.dom_event_allowlist=n?.dom_event_allowlist,e.element_allowlist=n?.element_allowlist,e.css_selector_allowlist=n?.css_selector_allowlist,e.css_selector_ignorelist=n?.css_selector_ignorelist,e.element_attribute_ignorelist=n?.element_attribute_ignorelist,e.capture_copied_text=n?.capture_copied_text}},Ha=Er(`[ExceptionAutocapture]`),xue=()=>{},Sue=e=>{if(zn(e))return e.__posthog_layer__??e.__rrweb_layer__};function Ua(e,t,n){try{if(!(t in e))return xue;let r={next:e[t]},i=n(function(...e){return r.next.apply(this,e)});return zn(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),e[t]=i,()=>{if(e[t]===i)return void(e[t]=r.next);let n=e[t],a=Sue(n);for(;a;){if(a.next===i)return void(a.next=r.next);n=a.next,a=Sue(n)}}}catch{return xue}}var Cue=Er(`[TracingHeaders]`),Wa=Er(`[Web Vitals]`),wue=9e5,Tue=[`CLS`,`FCP`,`INP`,`LCP`],Eue=[`INP`,`LCP`],Due=[`interactionTarget`,`interactionType`,`inputDelay`,`processingDuration`,`presentationDelay`,`loadState`,`target`,`url`,`timeToFirstByte`,`resourceLoadDelay`,`resourceLoadDuration`,`elementRenderDelay`,`largestShiftTarget`,`largestShiftTime`,`largestShiftValue`,`firstByteToFCP`],Oue=`disabled`,kue=`lazy_loading`,Ga=Er(`[SessionRecording]`),Aue=Er(`[Heatmaps]`);function jue(e){return Bn(e)&&`clientX`in e&&`clientY`in e&&qn(e.clientX)&&qn(e.clientY)}var Ka=Er(`[Product Tours]`),Mue=e=>!e.config.disable_product_tours&&!!e.persistence?.get_property(voe),Nue=[`$set_once`,`$set`],qa=Er(`[SiteApps]`),Pue=`Error while initializing PostHog app with config id `,Fue=(e,t)=>e?.then?e.then(t):t(e),Ja=`SDK is not enabled or survey functionality is not yet loaded`,Iue=`Disabled. Not loading surveys.`,Lue=class{constructor(e,t){this.So=e,this.Th=t,this.name=`surveys`,this._surveyEventReceiver=null,this._surveyManager=null,this.Ih=!1,this.Mh=[],this.Eh=null,this.Ph=null,this.Io=!1,this.Rh=new Set,this.onRemoteConfig=e=>{if(this.Io||this.Rr.disableSurveys)return;if(!e.ok)return ja.warn(`Remote config unavailable. Not loading surveys.`);let t=e.config.surveys;if(Kn(t))return ja.warn(`Flags not loaded yet. Not loading surveys.`);this.Ah=Yn(t)?t:t.length>0,ja.info(`flags response received, isSurveysEnabled: ${this.Ah}`),this.loadIfEnabled()}}setup(e){if(!this.Io)return this.Fh=e,Fue(e.kv.initialize(),()=>{if(this.Fh!==e||this.Io)return;this.Fh=void 0,this.wo=e;let t=e.onRemoteConfig(this.onRemoteConfig);this.Io?t.dispose():(this.Po=t,this.loadIfEnabled())})}dispose(){var e,t,n,r;this.Io||(this.Io=!0,this.Fh=void 0,this.wo=void 0,(e=this.Po)==null||e.dispose(),this.Po=void 0,(t=this._surveyEventReceiver)==null||t.dispose(),this._surveyEventReceiver=null,(n=this._surveyManager)==null||(r=n.dispose)==null||r.call(n),this._surveyManager=null,this.Mh=[],this.Eh=null,this.Rh.forEach(e=>clearTimeout(e)),this.Rh.clear())}get Rr(){return this.So.get()}initialize(){this.loadIfEnabled()}reset(){var e,t;(e=this._surveyManager)==null||(t=e.clearInMemoryInProgressSurveyState)==null||t.call(e);try{var n;(n=this._surveyEventReceiver)==null||n.reset(),localStorage.removeItem(`lastSeenSurveyDate`);let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);(n!=null&&n.startsWith(`seenSurvey_`)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach(e=>localStorage.removeItem(e))}catch{}}loadIfEnabled(){if(this.Io||!this.wo)return;let e=this.Rr;if(this._surveyManager)return;if(this.Ih)return void ja.info(`Already initializing surveys, skipping...`);if(e.disableSurveys)return void ja.info(Iue);if(e.cookielessMode&&this.So.isOptedOut())return void ja.info(`Not loading surveys in cookieless mode without consent.`);let t=this.So.getExtensions();if(!t)return void ja.error(`PostHog Extensions not found.`);if(Hn(this.Ah)&&!e.advancedEnableSurveys)return;let n=this.Ah||e.advancedEnableSurveys;this.Ih=!0;try{let e=t.generateSurveys;if(e)return this.Oh(e,n),void(this.Ih=!1);let r=t.loadExternalDependency;if(!r)return this.Dh(ai),void(this.Ih=!1);r(e=>{try{if(this.Io)return;let t=this.So.getExtensions();e||!t?.generateSurveys?this.Dh(`Could not load surveys script`,e):this.Oh(t.generateSurveys,n)}finally{this.Ih=!1}})}catch(e){throw this.Ih=!1,this.Dh(`Error initializing surveys`,e),e}}Oh(e,t){this.Io||(this._surveyManager=e(t),this._surveyEventReceiver=this.So.createEventReceiver(),ja.info(`Surveys loaded successfully`),this.Lh({isLoaded:!0}))}Dh(e,t){ja.error(e,t),this.Lh({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Mh.push(e),this._surveyManager&&this.Lh({isLoaded:!0}),()=>{this.Mh=this.Mh.filter(t=>t!==e)}}getSurveys(e,t=!1){let n=this.wo??this.Th;if(!n||this.Io)return;if(this.Rr.disableSurveys)return ja.info(Iue),e([]);let r=n.kv.get(Foe);if(r&&!t)return e(r,{isLoaded:!0}),void(this.Nh()&&this.getSurveys(()=>{},!0));if(this.Eh)return void this.Eh.then(({surveys:t,context:n})=>{this.Io||e(t,n)}).catch(e=>ja.error(`Error in survey callback`,e));let i=this.qh(`/api/surveys/`,{method:`GET`,query:{token:n.projectToken},sentAt:`query`,timeoutMs:this.Rr.requestTimeoutMs}).then(e=>{try{return this.jh(n,e)}catch(e){return ja.error(`Error processing surveys response`,e),this.jh(n,{statusCode:0,error:e})}},e=>this.jh(n,{statusCode:0,error:e}));this.Eh=i;let a=()=>{this.Eh===i&&(this.Eh=null)};i.then(t=>{a(),this.Io||e(t.surveys,t.context)},a).catch(e=>ja.error(`Error in survey callback`,e))}qh(e,t){let n=this.wo;return n?n.sendRequest(e,t):new Promise(e=>e({statusCode:0,error:Error(Ja)}))}jh(e,t){if(this.Io)return{surveys:[],context:{isLoaded:!1,error:Ja}};let n=t.statusCode;if(n!==200||!t.json){let e=`Surveys API could not be loaded, status: ${n}`;return n===0?t.error||ja.warn(e):ja.error(e),this.Ph=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this.Ph=null;let r=t.json.surveys||[],i=r.filter(e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(Hle(e)||function(e){var t;return!!((t=e.conditions)!=null&&(t=t.actions)!=null&&(t=t.values)!=null&&t.length)}(e)));var a;return i.length>0&&((a=this._surveyEventReceiver)==null||a.register(i)),e.kv.set({[Foe]:r,[Yr]:Date.now()}),{surveys:r,context:{isLoaded:!0}}}Nh(){return this.Bh()&&!this.Eh&&!this.Hh()}Bh(){let e=(this.wo??this.Th)?.kv.get(Yr);return qn(e)&&Date.now()-e>3e5}Hh(){return qn(this.Ph)&&3e5>Date.now()-this.Ph}markSurveyAsSeen(e,t){Yle({id:e,current_iteration:t?.iteration??null});try{localStorage.setItem(`lastSeenSurveyDate`,new Date().toISOString())}catch{}}Lh(e){for(let t of this.Mh)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){ja.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t=!1){if(!Kn(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);ja.warn(`init was not called`)}zh(e){let t=null;return this.getSurveys(n=>{t=n.find(t=>t.id===e)??null}),t}Uh(e){if(Kn(this._surveyManager))return{eligible:!1,reason:Ja};let t=typeof e==`string`?this.zh(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}Wh(e){if(!this.So.isCapturing())return{eligible:!1,reason:`PostHog is not capturing, so a survey response cannot be recorded`};if(Kn(this._surveyManager))return{eligible:!1,reason:Ja};let t=typeof e==`string`?this.zh(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(Kn(this._surveyManager))return ja.warn(`init was not called`),{visible:!1,disabledReason:Ja};let t=this.Wh(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Kn(this._surveyManager)?(ja.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:Ja})):new Promise(n=>{this.getSurveys(t=>{let r=t.find(t=>t.id===e)??null;if(r){let e=this.Wh(r);n({visible:e.eligible,disabledReason:e.reason})}else n({visible:!1,disabledReason:`Survey not found`})},t)})}renderSurvey(e,t,n){if(!this.So.isCapturing())return;if(Kn(this._surveyManager))return void ja.warn(`init was not called`);let r=typeof e==`string`?this.zh(e):e;if(!r?.id)return void ja.warn(`Survey not found`);if(!Xle.includes(r.type))return void ja.warn(`Surveys of type ${r.type} cannot be rendered in the app`);let i=Dn?.querySelector(t);if(i){if(r.appearance?.surveyPopupDelaySeconds){ja.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);let e=setTimeout(()=>{var t;this.Rh.delete(e),!this.Io&&this.So.isCapturing()&&(ja.info(`Rendering survey ${r.id} with delay of ${r.appearance?.surveyPopupDelaySeconds} seconds`),(t=this._surveyManager)==null||t.renderSurvey(r,i,n),ja.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);this.Rh.add(e);return}this._surveyManager.renderSurvey(r,i,n)}else ja.warn(`Survey element not found`)}displaySurvey(e,t){var n;if(!this.So.isCapturing())return;if(Kn(this._surveyManager))return void ja.warn(`init was not called`);let r=this.zh(e);if(!r)return void ja.warn(`Survey not found`);let i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=R(R({},r),{},{appearance:R(R({},r.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==oa.Popover&&t.initialResponses&&ja.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){let e=this.Uh(r);if(!e.eligible)return void ja.warn(`Survey is not eligible to be displayed: `,e.reason)}t.displayType===oa.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}cancelPendingSurvey(e){Kn(this._surveyManager)?ja.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;(e=this._surveyManager)==null||(t=e.handlePageUnload)==null||t.call(e)}};function Ya(e,t,n){if(Kn(e))return!1;switch(n){case`exact`:return e===t;case`contains`:{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(n,`i`).test(e)}case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var Rue=class{constructor(e){this._instance=e,this.Vh=new Set,this.Gh=new Set,this.Zh=new Ta,this.Qh=(e,t)=>this.Jh(e,t)&&this.Kh(e,t)&&this.Xh(e,t)&&this.Yh(e,t),this.Jh=(e,t)=>!t?.event||e?.event===t?.event}init(){Hn(this._instance?._addCaptureHook)||(this.tc=this._instance?._addCaptureHook((e,t)=>{this.on(e,t)}))}dispose(){var e;(e=this.tc)==null||e.call(this),this.tc=void 0,this.Zh=new Ta}register(e){if(!Hn(this._instance?._addCaptureHook)&&(e.forEach(e=>{var t;this.Vh.add(e),(t=e.steps)==null||t.forEach(e=>{this.Gh.add(e?.event||``)})}),this._instance?.autocapture)){let e=new Set;this.Vh.forEach(t=>{var n;(n=t.steps)==null||n.forEach(t=>{t!=null&&t.selector&&e.add(t.selector)})}),this._instance.autocapture.setElementSelectors(e)}}replace(e){this.Vh.clear(),this.Gh.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.Gh.has(e)||this.Gh.has(t.event))&&this.Vh.forEach(e=>{this.ec(t,e)&&this.Zh.emit(`actionCaptured`,e.name)})}nc(e){this.onAction(`actionCaptured`,t=>e(t))}ec(e,t){if(t?.steps==null)return!1;for(let n of t.steps)if(this.Qh(e,n))return!0;return!1}onAction(e,t){return this.Zh.on(e,t)}Kh(e,t){if(t?.url){var n;let r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!Ya(r,t.url,t.url_matching||`contains`))return!1}return!0}Xh(e,t){return!!this.sc(e,t)&&!!this.rc(e,t)&&!!this.oc(e,t)}sc(e,t){var n;if(!t?.href)return!0;let r=this.ac(e);if(r.length>0)return r.some(e=>Ya(e.href,t.href,t.href_matching||`exact`));let i=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!i&&Ya(function(e){let t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:``}(i),t.href,t.href_matching||`exact`)}rc(e,t){var n;if(!t?.text)return!0;let r=this.ac(e);if(r.length>0)return r.some(e=>Ya(e.text,t.text,t.text_matching||`exact`)||Ya(e.$el_text,t.text,t.text_matching||`exact`));let i=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!i&&(a=function(e){let t=[],n=/(?::|")text="(.*?)"/g,r;for(;!Kn(r=n.exec(e));)t.includes(r[1])||t.push(r[1]);return t}(i),o=t.text,s=t.text_matching||`exact`,a.some(e=>Ya(e,o,s)));var a,o,s}oc(e,t){var n,r;if(!t?.selector||(e==null||(n=e.properties)==null?void 0:n.$element_selectors)?.includes(t.selector))return!0;let i=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&i)try{return new RegExp(t.selector_regex).test(i)}catch{return!1}return!1}ac(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Yh(e,t){return!t?.properties||t.properties.length===0||Wle(t.properties.reduce((e,t)=>{let n=Rn(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e},{}),e?.properties)}},zue=class{constructor(e){var t,n;this.lc=[],this._instance=e,this.uc=new Map,this.hc=new Map,this.cc=new Map,this.dc=(t=this._instance)==null||(n=t.onSessionId)==null?void 0:n.call(t,e=>this.vc(e))}fc(e){return!1}gc(){return null}mc(e){}yc(){}bc(e,t){return!!e&&Wle(e.propertyFilters,t?.properties)}_c(e,t){let n=new Map;return e.forEach(e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach(t=>{if(t?.name){let r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}})}),n}wc(e,t,n){let r=(n===na.Activation?this.uc:this.hc).get(e),i=[];return this.kc(e=>{i=e.filter(e=>r?.includes(e.id))}),i.filter(r=>{var i;let a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find(t=>t.name===e);return this.bc(a,t)})}register(e){this.Sc(e,!1)}replace(e){this.Sc(e,!0)}Sc(e,t){Hn(this._instance?._addCaptureHook)||(this.xc(e,t),this.Cc(e,t))}Cc(e,t){let n=e.filter(e=>{var t;return(t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length});var r;if(t&&this.cc.clear(),n.length===0)return void(t&&((r=this.$c)==null||r.replace([])));this.$c||(this.$c=new Rue(this._instance),this.$c.init(),this.$c.nc(e=>this.onAction(e)));let i=[];n.forEach(e=>{var t;(t=e.conditions)==null||(t=t.actions)==null||t.values.forEach(t=>{if(i.push(t),t.name){let n=this.cc.get(t.name)??[];n.includes(e.id)||n.push(e.id),this.cc.set(t.name,n)}})}),t?this.$c.replace(i):this.$c.register(i)}Tc(e,t){t.forEach((t,n)=>{let r=e.get(n)??[];t.forEach(e=>{r.includes(e)||r.push(e)}),e.set(n,r)})}xc(e,t){let n=e.filter(e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0}),r=e.filter(e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}),i=this._c(e,na.Activation),a=this._c(e,na.Cancellation);t?(this.uc=i,this.hc=a):(this.Tc(this.uc,i),this.Tc(this.hc,a)),(n.length!==0||r.length!==0)&&(this.tc??=this._instance?._addCaptureHook((e,t)=>{this.onEvent(e,t)}))}onEvent(e,t){var n,r;let i=this.Ic(),a=(t==null||(n=t.properties)==null?void 0:n.$survey_id)||(t==null||(r=t.properties)==null?void 0:r.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){let t=this.Mc(e,a);if(t===`consume`)return i.info(`event consumed activated item, removing it`,{event:e,itemId:a}),void this.Ec([a]);if(t===`persist`)return i.info(`shown item promoted to persisted activation`,{event:e,itemId:a}),this.Pc(a),void this.Rc([a])}if(this.hc.has(e)){let n=this.wc(e,t,na.Cancellation);n.length>0&&(i.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:n.map(e=>e.id)}),this.Ec(n.map(e=>e.id)),n.forEach(e=>this.Ac(e.id)))}if(!this.uc.has(e))return;i.info(`event name matched`,{event:e,eventPayload:t,items:this.uc.get(e)});let o=this.wc(e,t,na.Activation);this.Fc(o.map(e=>e.id))}onAction(e){this.cc.has(e)&&this.Fc(this.cc.get(e)||[])}Fc(e){var t,n;if(e.length===0)return;let r=!!((t=this._instance)!=null&&(n=t.get_session_id)!=null&&n.call(t)),i=[];for(let t of e)r&&this.fc(t)?this.Pc(t)&&this.Oc(t):i.push(t);i.length>0&&(this.lc=[...new Set([...this.lc,...i])]),this.Ic().info(`updating activated items`,{activatedItems:this.getActivatedIds()})}Pc(e){this.lc=this.lc.filter(t=>t!==e);let t=this.Dc();return!t.includes(e)&&(this.Lc([...t,e]),this.Nc(),!0)}Ec(e){let t=new Set(e);this.lc=this.lc.filter(e=>!t.has(e));let n=this.qc(),r=n.filter(e=>!t.has(e));r.length!==n.length&&(this.Lc(r),r.length===0&&this.jc()),this.Rc(e)}Bc(){var e;let t=this.gc();if(!t)return{};let n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return n&&typeof n==`object`?n:{}}Oc(e){if(!this.gc())return;let t=this.Bc();this.mc(R(R({},t),{},{[e]:Date.now()}))}Rc(e){if(!this.gc())return;let t=this.Bc(),n={},r=!1;for(let[i,a]of Object.entries(t))e.includes(i)?r=!0:n[i]=a;r&&(Vn(n)?this.yc():this.mc(n))}Hc(){this.gc()&&this.yc()}getActivationTimestamp(e){if(!this.Dc().includes(e))return;let t=this.Bc()[e];return qn(t)?t:void 0}qc(){var e;let t=this.zc();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}Dc(){var e,t,n;let r=this.qc();if(r.length===0)return[];let i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.Uc()],a=(t=this._instance)==null||(n=t.get_session_id)==null?void 0:n.call(t);return a&&i===a?r:[]}Nc(){var e,t;let n=(e=this._instance)==null||(t=e.get_session_id)==null?void 0:t.call(e);n&&this.Wc(n)}jc(){this.Vc()}vc(e){var t;let n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.Uc()];if(n&&n!==e){let e=this.qc(),t=this.Bc();e.length>0&&(this.Lc([]),e.filter(e=>qn(t[e])).forEach(e=>this.Ac(e))),this.jc(),this.Hc()}}getActivatedIds(){return[...new Set([...this.Dc(),...this.lc])].filter(e=>!this.Gc(e))}dispose(){var e,t,n;(e=this.dc)==null||e.call(this),this.dc=void 0,(t=this.tc)==null||t.call(this),this.tc=void 0,(n=this.$c)==null||n.dispose(),this.$c=void 0}reset(){this.lc=[],this.qc().length>0&&this.Lc([]),this.jc(),this.Hc()}getEventToItemsMap(){return this.uc}Zc(){return this.$c}},Bue=class extends zue{constructor(e){super(e)}zc(){return Ioe}Uc(){return Loe}gc(){return Roe}mc(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated_timestamps:e})}yc(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(`$surveys_activated_timestamps`)}fc(e){var t;let n;this.kc(t=>{n=t.find(t=>t.id===e)});let r=n==null||(t=n.appearance)==null?void 0:t.surveyPopupDelaySeconds;return qn(r)&&r>0}Qc(){return ia.SHOWN}kc(e){var t;(t=this._instance)==null||t.getSurveys(e)}Ac(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}Ic(){return ja}Lc(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated:e})}Wc(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated_session:e})}Vc(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(`$surveys_activated_session`)}Gc(){return!1}Mc(e,t){let n;return this.kc(e=>{n=e.find(e=>e.id===t)}),!n||function(e){var t;return Hle(e)&&!!((t=e.conditions)!=null&&(t=t.events)!=null&&t.repeatedActivation)||e.schedule===`always`}(n)?e===ia.SHOWN?`consume`:`ignore`:e===ia.SHOWN?`persist`:e===ia.DISMISSED||e===ia.SENT?`consume`:`ignore`}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Vue=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e==`string`)return this._instance.get_property(e);let t={};for(let n of e){let e=this._instance.get_property(n);Hn(e)||(t[n]=e)}return t}set(e,t){this._instance.register(typeof e==`string`?{[e]:t}:e)}remove(e){typeof e==`string`?this._instance.unregister(e):e.forEach(e=>this._instance.unregister(e))}},Hue=class{constructor(e){this._instance=e}get(){let e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){let e=Mn?.__PosthogExtensions__;if(!e)return;let{generateSurveys:t,loadExternalDependency:n}=e;return{generateSurveys:t?e=>t(this._instance,e):void 0,loadExternalDependency:n?e=>n(this._instance,`surveys`,e):void 0}}createEventReceiver(){return new Bue(this._instance)}},Uue=wn?.location?Gi(wn.location.hash,`__posthog`)||Gi(location.hash,`state`):null,Wue=`_postHogToolbarParams`,Gue=Er(`[Toolbar]`),Kue=Er(`[FeatureFlags]`),que=class{constructor(e,t=!1){this.Jc=!1,this.update(e,t)}update(e,t){this.Kc=((e,t)=>({bootstrap:{featureFlags:e.bootstrap?.featureFlags??void 0,featureFlagPayloads:e.bootstrap?.featureFlagPayloads??void 0},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:e.remote_config_refresh_interval_ms??3e5,idleRefreshBackoff:Hn(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,e.feature_flag_request_max_retries??1),compression:e.disable_compression?void 0:`best-available`,evaluationContexts:e.evaluation_contexts??e.evaluation_environments??[],flagKeys:Rn(e.flag_keys)?e.flag_keys:void 0}))(e,t),!e.evaluation_environments||e.evaluation_contexts||this.Jc||(Kue.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.Jc=!0),Hn(e.flag_keys)||Rn(e.flag_keys)||Kue.error(`Invalid flag_keys found:`,e.flag_keys,`Expected array of non-empty strings`)}get(){return this.Kc}},Jue=Er(`[FeatureFlags]`),Xa=Er(`[FeatureFlags]`,{debugEnabled:!0}),Yue=`" failed. Feature flags didn't load in time.`,Xue=[502,504],Zue=[`click`,`keydown`,`wheel`,`touchstart`,`pointerdown`],Que=`connection_error`,$ue=e=>{let t={};for(let n=0;e.length>n;n++)t[e[n]]=!0;return t},ede=e=>{let t={};for(let[n,r]of mi(e||{}))r&&(t[n]=r);return t},tde=e=>Zn(e)&&(e.name===`RangeError`&&e.message.indexOf(`Maximum call stack size exceeded`)===0||e.name===`InternalError`&&e.message===`too much recursion`),Za=Er(`[Error tracking]`),nde=`webkit-masked-url:`,rde=[{value:`isolatedAPI.contexts.topHostname`,exact:!1},{value:`No response from target`,exact:!0}],ide=[`chrome-extension://`,`moz-extension://`,`safari-extension:`,`safari-web-extension:`,nde],ade=[`__firefox__`,`__gCrWeb`],ode=`Refusing to render web experiment since the viewer is a likely bot`,sde={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>Da(t,e),not_regex:(e,t)=>!Da(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Qa=Er(`[Conversations]`),$a=`Conversations not available yet.`;function cde(e,t){let n=e?.flushIntervalMs??3e3,r=e?.maxBufferSize??100,i=t?.consoleCapture?void 0:e?.maxLogsPerInterval??1e3,a=Hn(i)?Math.max(r,2048):Math.max(r,i),o=R(R({},function(){let e=``,t=``;try{let n=En?.userAgent;n&&([e,t]=Sie(n))}catch{}return function(e,t){let n=function(e){if(e)return{}.hasOwnProperty.call(Hae,e)?Hae[e]:e}(e);return R(R({},n?{"os.name":n}:{}),t?{"os.version":t}:{})}(e,t)}()),e?.resourceAttributes);return{serviceName:o?.[`service.name`]??e?.serviceName??t?.serviceNameDefault,serviceVersion:o?.[`service.version`]??e?.serviceVersion,environment:o?.[`deployment.environment`]??e?.environment,resourceAttributes:o,beforeSend:e?.beforeSend,flushIntervalMs:n,maxBufferSize:r,maxQueueSize:a,maxBatchRecordsPerPost:100,rateCapWindowMs:n,maxLogsPerInterval:i,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var lde=[`debug`,`log`,`warn`,`error`,`info`],ude=e=>{for(;e?.__rrweb_original__;)e=e.__rrweb_original__;return e},dde=`console`,fde=`__posthogHandledLogsRequestError`,pde=(e,t)=>{let n=e instanceof Error?e:Error(t);return n[fde]=!0,n},mde=e=>!!e&&typeof e==`object`&&!0===e[fde],eo=Er(`[NetworkMetrics]`),hde=()=>{var e;return wn!=null&&(e=wn.performance)!=null&&e.now?wn.performance.now():Date.now()},gde={"http:":80,"https:":443},_de=new Set([`CONNECT`,`DELETE`,`GET`,`HEAD`,`OPTIONS`,`PATCH`,`POST`,`PUT`,`TRACE`]),vde=(e,t)=>{let n=String(t);return{method:String(e).toUpperCase(),url:Hi(n)?.href||n}},yde=(e,t,n,r,i,a,o=!1)=>{try{var s;let c=i();if(!c)return;let l=n||void 0,u=hde()-r,d=Hi(t.url);if(d&&d.protocol!==`http:`&&d.protocol!==`https:`)return;let f={url:d?.href||t.url,method:t.method},p=zn(c.name)?c.name(f):Un(c.name)?c.name:`http.client.request.duration`;if(!p)return;let m=o&&!l?void 0:((e,t)=>e?400>e?void 0:String(e):t?.name||`_OTHER`)(l,a),h=R(R(R(R(R({},(e=>{let t=_de.has(e)?e:`_OTHER`;return R({"http.request.method":t},t===`_OTHER`&&e!==t?{"http.request.method_original":e}:{})})(f.method)),d?(e=>{return{"server.address":e.hostname.startsWith(`[`)&&e.hostname.endsWith(`]`)?e.hostname.slice(1,-1):e.hostname,"server.port":Number(e.port)||gde[e.protocol],"url.scheme":e.protocol.slice(0,-1),"url.template":(t=e.pathname,t.split(`/`).map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?`:id`:e).join(`/`))};var t})(d):{}),l?{"http.response.status_code":l}:{}),m?{"error.type":m}:{}),c.attributes?.call(c,f,{status:l,durationMs:u}));(s=e.metrics)==null||s.histogram(p,u,{unit:`ms`,attributes:h})}catch(e){eo.error(`Failed to record network metric`,e)}},bde=()=>{},xde=(e,t)=>zn(wn?.fetch)?Ua(wn,`fetch`,n=>function(...r){let i=hde(),a=n.apply(this,r);if(!t())return a;try{let[n,o]=r,s=vde(o?.method??n?.method??`GET`,n?.url??n);return a.then(n=>(yde(e,s,n?.status,i,t,void 0,!0),n),n=>{throw yde(e,s,void 0,i,t,n),n})}catch(e){return eo.error(`Failed to observe fetch`,e),a}}):bde,Sde=(e,t)=>{var n;let r=wn==null||(n=wn.XMLHttpRequest)==null?void 0:n.prototype;if(!r)return bde;let i=new WeakMap,a=Ua(r,`open`,e=>function(...t){try{hle.has(this)||i.set(this,vde(t[0],t[1]))}catch(e){eo.error(`Failed to observe XHR open`,e)}return e.apply(this,t)}),o=Ua(r,`send`,n=>function(...r){let a;try{let n=i.get(this);if(n&&t()){let r=hde();a=()=>{this.removeEventListener(`loadend`,a),yde(e,n,this.status,r,t)},gi(this,`loadend`,a)}}catch(e){eo.error(`Failed to observe XHR send`,e)}try{return n.apply(this,r)}catch(e){throw a&&this.removeEventListener(`loadend`,a),e}});return()=>{a(),o()}},to={featureFlags:class{constructor(e){this.name=`featureFlags`,this.Xc=!1,this.featureFlagEventHandlers=[],this.$=Jue,this.Yc={},this.td={},this.ed=[],this.nd=!1,this.sd=!1,this.rd=0,this.od=!1,this.ad=!1,this.ld=!1,this.ud=!1,this.hd=0,this.dd=!1,this.an=()=>{let e=this.vd();this.hd=0,e&&this.reloadFeatureFlags()},this.fd=()=>{let e=this.pd,t=this.gd??e;Hn(e)||Hn(t)||this.Rr.remoteRequestsDisabled||!Dn||Dn.visibilityState===`hidden`||Date.now()-(this.md??0)<t||(this.gd=this.dd||!this.Rr.idleRefreshBackoff?e:Math.min(2*t,36e5),this.dd=!1,this.reloadFeatureFlags(),this.yd())},this.bd=()=>{this.dd&&this.gd===this.pd||this._d()},this.ln=()=>{Dn?.visibilityState===`visible`&&this._d()},`get`in e?this.So=e:(this._instance=e,this.wd=new que(e.config,e.nl()),this.So=this.wd)}updateConfig(e,t){var n;(n=this.wd)==null||n.update(e,t),this.wo&&this.kd()}setup(e){return this.Fh=e,this.$=e.logger.createLogger(`[FeatureFlags]`),Fue(e.kv.initialize(),()=>{this.Fh===e&&(this.Fh=void 0,this.wo=e,this.Sd(e))})}Sd(e){var t;if(this.wo===e)return wn&&gi(wn,`online`,this.an),this.kd(),this.xd=e.registerDynamicEventProperties(()=>this.Cd()?this.Yc:this.td),this.$d=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.onCrossTabFeatureFlagChange(()=>{this.Td(),this.Id(),this.Md()}),this.Id(),this.initialize()}_d(){this.dd=!0,this.gd=this.pd,this.fd()}kd(){let e=this.Rr.refreshIntervalMs,t=!this.Rr.remoteRequestsDisabled&&Dn&&!Hn(e)&&e>0?e:void 0;this.Rr.idleRefreshBackoff||(this.gd=t),t!==this.pd&&(this.Ed(),Hn(t)||(this.pd=t,this.gd=t,this.yd(),Dn!=null&&Dn.addEventListener&&(gi(Dn,ci,this.ln),di(Zue,e=>{gi(Dn,e,this.bd,{capture:!0})}))))}yd(){Hn(this.pd)||(Hn(this.Pd)||clearInterval(this.Pd),this.md=Date.now(),this.Pd=setInterval(this.fd,this.pd))}Ed(){var e;Hn(this.Pd)||(clearInterval(this.Pd),this.Pd=void 0,Dn==null||(e=Dn.removeEventListener)==null||e.call(Dn,`visibilitychange`,this.ln),di(Zue,e=>{var t;Dn==null||(t=Dn.removeEventListener)==null||t.call(Dn,e,this.bd,{capture:!0})})),this.pd=void 0,this.gd=void 0,this.dd=!1,this.md=void 0}destroy(){this.Rd()}dispose(){this.Rd()}Rd(){var e,t;this.Ed(),this.rd++,this.ad=!1,this.Fh=void 0,this.wo&&=(this.Ad(),(e=this.xd)==null||e.dispose(),this.xd=void 0,(t=this.$d)==null||t.call(this),this.$d=void 0,this.ed=[],wn?.removeEventListener(`online`,this.an),void 0)}get Rr(){return this.So.get()}Fd(e){return this.Od&&e in this.Od?this.Od[e]:this.wo?.kv.get(e)}Td(){return!!this.Od&&(this.Od=void 0,!0)}Dd(){return!Hn(this.wo?.kv.get(`$enabled_feature_flags`))&&this.Td()}At(e){this.Ld(()=>this.wo?.kv.set(e))}Nd(e,t,n){if(!this._instance?.persistence||!e.$enabled_feature_flags)return;let r=this.Fd(`$enabled_feature_flags`)||{},i=e.$enabled_feature_flags||{},a=t.flags||t.featureFlags,o=t.flags?Object.entries(t.flags).filter(([,e])=>!e?.failed).map(([e])=>e):[],s=!!t.errorsWhileComputingFlags&&!!t.flags,c=s?o:n&&!Rn(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(r),...Object.keys(i)])),l=this.Fd(`$feature_flag_payloads`)||{},u=e.$feature_flag_payloads||{},d=s||n?c:Array.from(new Set([...Object.keys(l),...Object.keys(u)])),f=!s&&!n,p=!!f||c,m=!!f||d,h={[Br]:p,[zr]:p,[Hr]:m};e.$feature_flag_details&&(h[Vr]=p);for(let t of[Ur,$r,Wr])Hn(e[t])||(h[t]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(h)}Lt(e){this.Ld(()=>this.wo?.kv.remove(e))}Ld(e){try{e()}catch(e){this.$.error(`Failed to update feature flag persistence`,e)}}Id(){let e={};for(let t of[Br,Hr,Ur,Gr]){let n=this.Fd(t);Hn(n)||(e[t]=n)}this.Yc=e;let t=R({},e),n=this.Fd(zr);if(n)for(let[e,r]of Object.entries(n))t[`$feature/${e}`]=r;this.td=t}Cd(){let e=this.Rr.cacheTtlMs;if(!e||0>=e)return!1;let t=this.Fd($r);return typeof t!=`number`||Date.now()-t>e}qd(){return!!this.Cd()&&(this.ud||this.sd||(this.ud=!0,this.$.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}jd(){let e=this.Rr.evaluationContexts;return e?.length?e.filter(e=>{let t=e&&typeof e==`string`&&e.trim().length>0;return t||this.$.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t}):[]}Bd(){let e=this.Rr.flagKeys;if(!Hn(e))return e.filter(e=>{let t=e&&typeof e==`string`&&e.trim().length>0;return t||this.$.error(`Invalid flag key found:`,e,`Expected non-empty string`),t})}initialize(){let e=this.Rr,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){let n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter(e=>!Hn(t[e])).reduce((e,n)=>(e[n]=t[n],e),{}),i=Object.keys(n).filter(e=>r[e]).reduce((e,t)=>(e[t]=n[t],e),{});return this.Hd({featureFlags:r,featureFlagPayloads:i},void 0,{persist:!1})}}updateFlags(e,t,n){var r,i;let a=n?.merge&&(r=this.Fd(`$enabled_feature_flags`))!=null?r:{},o=n?.merge&&(i=this.Fd(`$feature_flag_payloads`))!=null?i:{},s=R(R({},a),e),c=R(R({},o),t),l={};for(let[e,t]of Object.entries(s))l[e]={key:e,enabled:wae(t),variant:Tae(t),reason:void 0,metadata:Hn(c?.[e])?void 0:{id:0,version:void 0,description:void 0,payload:c[e]}};this.Hd({flags:l})}get hasLoadedFlags(){return this.nd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){let e=this.Fd(Vr),t=this.Fd(Gr),n=this.Fd(Kr);if(!n&&!t)return e||{};let r=pi({},e||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(let e of i){var a;let i=r[e],s=t?.[e],c=Hn(s)?(a=i?.enabled)!=null&&a:!!s,l=Hn(s)?i?.variant:typeof s==`string`?s:void 0,u=n?.[e],d=R(R({},i),{},{enabled:c,variant:c?l??i?.variant:void 0});var o;c!==i?.enabled&&(d.original_enabled=i?.enabled),l!==i?.variant&&(d.original_variant=i?.variant),u&&(d.metadata=R(R({},i?.metadata),{},{payload:u,original_payload:i==null||(o=i.metadata)==null?void 0:o.payload})),r[e]=d}return this.Xc||=(this.$.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getAllFeatureFlags(){let e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(n=>{let r=e[n];return{key:n,enabled:wae(r),variant:Tae(r),payload:Cae(t[n])}})}getFlagVariants(){let e=this.Fd(zr),t=this.Fd(Gr);if(!t)return e||{};let n=pi({},e||{}),r=Object.keys(t);for(let e=0;r.length>e;e++)n[r[e]]=t[r[e]];return this.Xc||=(this.$.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){let e=this.Fd(Hr),t=this.Fd(Kr);if(!t)return e||{};let n=pi({},e||{}),r=Object.keys(t);for(let e=0;r.length>e;e++)n[r[e]]=t[r[e]];return this.Xc||=(this.$.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.od||this.Rr.featureFlagsDisabled||this.vd()||(this.sd&&(this.ad=!0),this.zd||=(this.ed.slice().forEach(e=>{try{e()}catch(e){this.$.error(`Error while running feature flags reloading callback`,e)}}),setTimeout(()=>{this.Ud()},5)))}Ad(){clearTimeout(this.zd),this.zd=void 0}onReloading(e){return this.ed.push(e),()=>{this.ed=this.ed.filter(t=>t!==e)}}ensureFlagsLoaded(){this.nd||this.sd||this.zd||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.od=e}resetFlagCallReported(){this.Lt(Xr)}Ud(e){this.Ad();let t=this.wo;if(!t||this.Rr.remoteRequestsDisabled||this.vd())return;if(this.sd)return void(this.ad=!0);let n={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:R(R(R({},t.initialPersonProperties),this.Fd(`$stored_person_properties`)||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.Fd(Jr),timezone:Nce()};Hn(t.deviceId)||(n.$device_id=t.deviceId),(e!=null&&e.disableFlags||this.Rr.featureFlagsDisabled)&&(n.disable_flags=!0);let r=this.jd();r.length&&(n.evaluation_contexts=r);let i=this.Bd();Hn(i)||(n.flag_keys=i);let a=this.Rr.onlyEvaluateSurveyFeatureFlags,o=`/flags/?v=2`+(a?`&only_evaluate_survey_feature_flags=true`:``),s=this.rd;this.sd=!0;let c=()=>{this.ad&&(this.ad=!1,this.Ud())},l=e=>{let t=e.json??{},r=e.statusCode!==200;if(this.sd=!1,s!==this.rd)return void c();if(this.Wd(e.statusCode),r||this.ad||(this.$anon_distinct_id=void 0),n.disable_flags&&!this.ad)return;this.ld=!r;let i=[];e.error?i.push(e.error instanceof Error&&e.error.name===`AbortError`?`timeout`:e.error instanceof Error?Que:`unknown_error`):e.statusCode!==200&&i.push(`api_error_${e.statusCode}`),t.errorsWhileComputingFlags&&i.push(`errors_while_computing_flags`);let o=!!t.quotaLimited?.includes(`feature_flags`);o&&i.push(`quota_limited`),this.At({[Qr]:i}),o?this.$.warn(`You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.`):n.disable_flags||this.Hd(t,r,{partialResponse:a}),c()},u=e=>{this.sd=!1,s===this.rd?(this.At({[Qr]:[Que]}),this.$.error(`Feature flag request failed`,e),this.Dd()&&this.Md(!0),c()):c()},d=this.Rr.requestMaxRetries,f=()=>d>0&&s===this.rd,p=()=>{if(s!==this.rd||!this.wo||this.Rr.remoteRequestsDisabled)return this.sd=!1,void c();try{t.sendRequest(o,{target:`flags`,method:`POST`,body:n,compression:this.Rr.compression,sentAt:`body`,timeoutMs:this.Rr.requestTimeoutMs}).then(e=>{if((e=>Xue.includes(e.statusCode)||(e=>e.statusCode===0&&e.error instanceof Error&&e.error.name===`AbortError`)(e))(e)&&f())return d--,void setTimeout(p,500);l(e)}).catch(u)}catch(e){u(e)}};p()}vd(){return xce(this.hd,3)}Wd(e){this.hd=Sce(e,this.hd,3,()=>this.$.warn(`Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.`))}getFeatureFlag(e,t={}){if(t.fresh&&!this.ld)return;if(!(this.nd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn(`getFeatureFlag for key "`+e+Yue);if(this.qd())return;let n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this.ld)return;if(!(this.nd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn(`getFeatureFlagResult for key "`+e+Yue);if(this.qd())return;let n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.Fd(`$feature_flag_request_id`)||void 0,c=this.Fd(`$feature_flag_evaluated_at`)||void 0,l,u=this.Fd(`$flag_call_reported`)||{};if(this.Rr.deduplicateCallsPerSession){let e=this.wo?.session.sessionId,t=this.Fd(Zr);e&&e!==t&&(u={},l=e)}if(t.send_event||!(`send_event`in t)){if(e in u&&u[e].includes(o))l&&this.At({[Xr]:u,[Zr]:l});else{var d,f,p,m,h,g,_,v;Rn(u[e])?u[e].push(o):u[e]=[o],this.At(R({[Xr]:u},l?{[Zr]:l}:{}));let t=this.getFeatureFlagDetails(e),n=[...this.Fd(`$feature_flag_errors`)??[]];Hn(i)&&n.push(`flag_missing`);let r={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a??null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((d=this.Rr.bootstrap)==null||(d=d.featureFlags)==null?void 0:d[e])??null,$feature_flag_bootstrapped_payload:((f=this.Rr.bootstrap)==null||(f=f.featureFlagPayloads)==null?void 0:f[e])??null,$used_bootstrap_value:!this.ld};Hn(t==null||(p=t.metadata)==null?void 0:p.has_experiment)||(r.$feature_flag_has_experiment=t.metadata.has_experiment),Hn(t==null||(m=t.metadata)==null?void 0:m.version)||(r.$feature_flag_version=t.metadata.version);let b=(t==null||(h=t.reason)==null?void 0:h.description)??(t==null||(g=t.reason)==null?void 0:g.code);var y;b&&(r.$feature_flag_reason=b),t!=null&&(_=t.metadata)!=null&&_.id&&(r.$feature_flag_id=t.metadata.id),Hn(t?.original_variant)&&Hn(t?.original_enabled)||(r.$feature_flag_original_response=Hn(t.original_variant)?t.original_enabled:t.original_variant),t!=null&&(v=t.metadata)!=null&&v.original_payload&&(r.$feature_flag_original_payload=t==null||(y=t.metadata)==null?void 0:y.original_payload),n.length&&(r.$feature_flag_error=n.join(`,`)),this.Vd(r)}}else l&&this.At({[Xr]:u,[Zr]:l});return r?{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:Cae(a)}:void 0}Vd(e){try{var t;(t=this.wo)==null||t.capture(`$feature_flag_called`,e)}catch(e){this.$.error(`Failed to capture feature flag call`,e)}}getRemoteConfigPayload(e,t){this.Gd(e,t)}Gd(e,t){var n=this;return er(function*(){let r=n.wo;if(!r)return;let i={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},a=n.jd();a.length&&(i.evaluation_contexts=a);let o=n.Bd(),s;Hn(o)||(i.flag_keys=o);try{s=(yield r.sendRequest(`/flags/?v=2`,{target:`flags`,method:`POST`,body:i,compression:n.Rr.compression,sentAt:`body`,timeoutMs:n.Rr.requestTimeoutMs})).json?.featureFlagPayloads?.[e]||void 0}catch(e){n.$.error(`Remote config feature flag request failed`,e);return}try{t(s)}catch(e){n.$.error(`Remote config feature flag callback failed`,e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.ld)return t.defaultValue;if(!(this.nd||this.getFlags()&&this.getFlags().length>0))return this.$.warn(`isFeatureEnabled for key "`+e+Yue),t.defaultValue;let n=this.getFeatureFlag(e,t);return Hn(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,n){this.Hd(e,t,n)}Hd(e,t,n){if(!this.wo)return;this.nd=!0;let r=((e,t={},n={},r={},i,a=Jue)=>{let o=((e,t)=>{let n=e.flags;if(n){let t=Object.fromEntries(Object.keys(n).map(e=>[e,n[e].variant??n[e].enabled])),r=Object.fromEntries(Object.keys(n).filter(e=>n[e].enabled).filter(e=>!Hn(n[e].metadata?.payload)).map(e=>[e,n[e].metadata?.payload]));return R(R({},e),{},{featureFlags:t,featureFlagPayloads:r})}return e.featureFlags&&t.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e,a),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(!c)return;let u=e.requestId,d=e.evaluatedAt;if(Rn(c)){a.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);let e={};if(c)for(let t=0;c.length>t;t++)e[c[t]]=!0;return{[Br]:c,[zr]:e,[Wr]:!1}}let f=c,p=l,m=s;if(i?.partialResponse){let e=Object.keys(f),i=p||{};f=R(R({},t),f),p=R(R({},n),i),e.forEach(e=>{e in i||p==null||delete p[e]}),m=R(R({},r),m)}else if(e.errorsWhileComputingFlags){if(s){let e=new Set(Object.keys(s).filter(e=>!s[e]?.failed));f=R(R({},t),Object.fromEntries(Object.entries(f).filter(([t])=>e.has(t))));let i=Object.fromEntries(Object.entries(p||{}).filter(([t])=>e.has(t)));p=R(R({},n),i),e.forEach(e=>{e in i||p==null||delete p[e]}),m=R(R({},r),Object.fromEntries(Object.entries(m||{}).filter(([t])=>e.has(t))))}else f=R(R({},t),f),p=R(R({},n),p),m=R(R({},r),m)}return R(R({[Br]:Object.keys(ede(f)),[zr]:f||{},[Hr]:p||{},[Vr]:m||{},[Wr]:!0===e.minimalFlagCalledEvents},u?{[Ur]:u}:{}),d?{[$r]:d}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.$);if(r){if(!1===n?.persist){let e=!Hn(this.wo.kv.get(zr));this.Od=r,e||this.At(r)}else this.Td(),this.Nd(r,e,!!n?.partialResponse),this.At(r)}else t&&this.Dd();t||(this.ud=!1),this.Md(t)}override(e,t=!1){this.$.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.Zd(e)}Zd(e){if(this.wo){if(!1===e)return this.Lt([Gr,Kr]),this.Md(),void Xa.info(`All overrides cleared`);if(Rn(e))return this.At({[Gr]:$ue(e)}),this.Md(),void Xa.info(`Flag overrides set`,{flags:e});if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var t;let n=e;this.Xc=!!((t=n.suppressWarning)!=null&&t);let r={},i=n.flags,a=n.payloads;i&&(r[Gr]=Rn(i)?$ue(i):i),a&&(r[Kr]=a),Object.keys(r).length&&this.At(r),!1===i&&!1===a?this.Lt([Gr,Kr]):!1===i?this.Lt(Gr):!1===a&&this.Lt(Kr),this.Md(),!1===i?Xa.info(`Flag overrides cleared`):i&&Xa.info(`Flag overrides set`,{flags:i}),!1===a?Xa.info(`Payload overrides cleared`):a&&Xa.info(`Payload overrides set`,{payloads:a});return}if(e&&typeof e==`object`)return this.At({[Gr]:e}),this.Md(),void Xa.info(`Flag overrides set`,{flags:e});this.$.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}else this.$.warn(`posthog.featureFlags.overrideFeatureFlags called before feature flags were ready`)}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.nd){let{flags:t,flagVariants:n}=this.Qd();try{e(t,n)}catch(e){this.$.error(`Error while running feature flags callback`,e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;let i=(this.Fd(`$early_access_features`)||[]).find(t=>t.flagKey===e),a={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n);let s=R(R({},this.getFlagVariants()),{},{[e]:t});(r=this._instance)==null||(r=r.persistence)==null||r.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(a)}),this.At({[Br]:Object.keys(ede(s)),[zr]:s,[qr]:R(R({},this.Fd(`$stored_person_properties`)||{}),a)}),this.Md();try{var c;(c=this.wo)==null||c.capture(`$feature_enrollment_update`,o)}catch(e){this.$.error(`Failed to capture early access feature enrollment`,e)}}getEarlyAccessFeatures(e,t=!1,n){let r=this.Fd(Noe);!r||t?this.Jd(e,n):e(r)}Jd(e,t){var n=this;return er(function*(){let r=n.wo;if(!r)return;let i=t?`&${t.map(e=>`stage=${e}`).join(`&`)}`:``,a;try{let e=yield r.sendRequest(`/api/early_access_features/?token=${r.projectToken}${i}`,{target:`api`,method:`GET`,sentAt:`query`});if(!e.json)return;a=e.json.earlyAccessFeatures,n.At({[Noe]:a})}catch(e){n.$.error(`Early access feature request failed`,e);return}try{e(a)}catch(e){n.$.error(`Early access feature callback failed`,e)}})()}Qd(){let e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,n)=>(e[n]=t[n],e),{})}}Md(e){this.Id();let{flags:t,flagVariants:n}=this.Qd();this.featureFlagEventHandlers.forEach(r=>{try{r(t,n,{errorsLoading:e})}catch(e){this.$.error(`Error while running feature flags callback`,e)}})}setPersonPropertiesForFlags(e,t=!0){this.Kd(e,t)}Kd(e,t=!0){let n=this.Fd(`$stored_person_properties`)||{},r=e?.$set||(e?.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(let e in i)({}).hasOwnProperty.call(i,e)&&(e in n||(a[e]=i[e]));this.At({[qr]:R(R(R({},n),a),r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){let n=R({},this.Fd(`$stored_person_properties`)||{});e.forEach(e=>{delete n[e]}),this.At({[qr]:n}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Lt(qr),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){let n=this.Fd(`$stored_group_properties`)||{},r=R({},n);for(let t of Object.keys(e))r[t]=R(R({},n[t]),e[t]);this.At({[Jr]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){let t=this.Fd(`$stored_group_properties`)||{};this.At({[Jr]:R(R({},t),{},{[e]:{}})})}else this.Lt(Jr)}reset(){this.rd++,this.ad=!1,this.Yc={},this.td={},this.Od=void 0,this.nd=!1,this.od=!1,this.ld=!1,this.$anon_distinct_id=void 0,this.Ad(),this.Xc=!1,this.hd=0}}},Cde={sessionRecording:class{get Rr(){return this._instance.config}get Ml(){return this._instance.persistence}get started(){return!!this.Xd?.isStarted}get status(){return this.Yd===`awaiting_config`||this.Yd===`missing_config`?this.Yd:this.Xd?.status??this.Yd}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.Yd=Oue,this.tv=void 0,this.ev=!1,this.Xe=(()=>{var e,t;if(!Dn?.visibilityState||Dn.visibilityState===`visible`)return!0;let n=wn==null||(e=wn.performance)==null||(t=e.getEntriesByType)==null?void 0:t.call(e,`visibility-state`);return!n?.length||n.some(e=>e.name===`visible`)})(),this.ln=()=>{var e,t;Dn?.visibilityState===`visible`&&(this.Xe=!0,(e=this.Xd)==null||(t=e.setDocumentWasEverVisible)==null||t.call(e,!0))},!this._instance.sessionManager)throw Ga.error(`started without valid sessionManager`),Error(`[SessionRecording] started without valid sessionManager. This is a bug.`);if(this.Rr.cookieless_mode===`always`)throw Error(`[SessionRecording] cannot be used with cookieless_mode="always"`);Dn!=null&&Dn.addEventListener&&gi(Dn,`visibilitychange`,this.ln)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.ev=!0,Dn==null||(t=Dn.removeEventListener)==null||t.call(Dn,`visibilitychange`,this.ln),e?this.iv(!0):this.stopRecording()}get nv(){let e=!!this._instance.get_property(`$session_recording_remote_config`)?.enabled,t=!this.Rr.disable_session_recording,n=this.Rr.disable_session_recording||this._instance.consent.isOptedOut();return wn&&e&&t&&!n}startIfEnabledOrStop(e){if(this.ev||this.nv&&this.Xd?.isStarted)return;let t=!Hn(Object.assign)&&!Hn(Array.from);this.nv&&t?(this.sv(e),Ga.info(`starting`)):(this.Yd=Oue,this.stopRecording())}sv(e){var t;if(this.nv){if(this.Yd!==`awaiting_config`&&this.Yd!==`missing_config`&&(this.Yd=kue),Mn!=null&&(t=Mn.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&Mn.__PosthogExtensions__?.initSessionRecording)this.rv(e);else{var n,r;let t=this._instance.sessionManager;(n=Mn.__PosthogExtensions__)==null||(r=n.loadExternalDependency)==null||r.call(n,this._instance,this.ov,n=>{if(!this.ev&&this.nv&&this._instance.sessionManager===t)return n?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Ga.error(`could not load recorder`,n)):void this.rv(e);this.Yd=`disabled`})}}}stopRecording(){var e,t;(e=this.tv)==null||e.call(this),this.tv=void 0,(t=this.Xd)==null||t.stop()}iv(e=!1){var t,n;(t=this.tv)==null||t.call(this),this.tv=void 0,(n=this.Xd)==null||n.discard({discardProducerEvents:e})}av(){var e,t;(e=this.Ml)==null||e.unregister(`$session_is_sampled`),(t=this.Ml)==null||t.unregister(`$replay_sample_rate`)}lv(e,t){if(Kn(e))return null;let n=qn(e)?e:parseFloat(e);return typeof(r=n)!=`number`||!Number.isFinite(r)||0>r||r>1?(Ga.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):n;var r}uv(e){if(this.Ml){var t;let n=this.Ml,r=()=>{let t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.lv(this.Rr.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.lv(t?.sampleRate,`remote config sampleRate`),a=r??i;Kn(a)&&this.av();let o=t?.minimumDurationMilliseconds;n.register({[Lr]:R(R({cache_timestamp:Date.now(),enabled:!!t},t),{},{networkPayloadCapture:R({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:Hn(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.tv)==null||t.call(this),this.tv=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){let t=e.ok?e.config:void 0;t&&`sessionRecording`in t?!1===t.sessionRecording?(this.uv(t),this.iv()):(this.uv(t),this.startIfEnabledOrStop()):(this.Yd===`awaiting_config`&&(this.Yd=`missing_config`,this._instance.register_for_session({[$oe]:!0}),Ga.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t=`log`){this.Xd?.log?this.Xd.log(e,t):Ga.warn(`log called before recorder was ready`)}get ov(){var e,t;let n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Lr);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}hv(){let e=this._instance.get_property(Lr);if(!e)return!1;let t;try{t=typeof e==`object`?e:JSON.parse(e)}catch(e){return Ga.warn(`persisted remote config for session recording is invalid and will be ignored`,e),!1}return!Kn(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}rv(e){var t,n;if(!this.ev&&this.nv&&this._instance.sessionManager){if(!Mn.__PosthogExtensions__?.initSessionRecording)return Ga.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[Qoe]:!0});if(this.Xd||(this.Xd=Mn.__PosthogExtensions__?.initSessionRecording(this._instance,this.Xe),this.Xd._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.hv()){if(this.Yd===`missing_config`||this.Yd===`awaiting_config`)return;this.Yd=`awaiting_config`,Ga.info(`persisted remote config is stale, requesting fresh config before starting`),new Kce(this._instance).load();return}this.Yd=kue,(t=(n=this.Xd).setDocumentWasEverVisible)==null||t.call(n,this.Xe),this.Xd.start(e)}else this.Yd=Oue}onRRwebEmit(e){var t,n;(t=this.Xd)==null||(n=t.onRRwebEmit)==null||n.call(t,e)}overrideLinkedFlag(){var e,t;this.Xd||(t=this.Ml)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Xd)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Xd||(t=this.Ml)==null||t.register({$replay_override_sampling:!0}),(e=this.Xd)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.Xd||(n=this.Ml)==null||n.register({[e===`url`?`$replay_override_url_trigger`:`$replay_override_event_trigger`]:!0}),(t=this.Xd)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.Xd?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){return!!this.Xd?.tryAddCustomEvent(e,t)}flushBeforeIdentityReset(){var e,t;(e=this.Xd)==null||(t=e.flushBeforeIdentityReset)==null||t.call(e)}}},wde={autocapture:class extends yue{constructor(e){super(new bue(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this.dv=this.vv()}initialize(){this.startIfEnabled()}get isEnabled(){let e=this.fv();return!!(e.path||e.search||this.pv(e))}startIfEnabled(){this.isEnabled&&(Tr.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.dv=this.vv(),this.startIfEnabled()}stop(){this.gv&&this.gv(),this.gv=void 0,this.mv&&this.mv(),this.mv=void 0,Tr.info(`History API monitoring stopped`)}monitorHistoryChanges(){wn&&wn.history&&(this.yv(`pushState`),this.yv(`replaceState`),this.bv(),this.pv()&&this._v())}yv(e){if(!wn||wn.history[e]?.__posthog_wrapped__)return;let t=this;Ua(wn.history,e,n=>function(r,i,a){n.call(this,r,i,a),t.wv(e)})}vv(){let e=wn?.location;if(e?.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}fv(){let e=this._instance.config.capture_pageview;return e===`history_change`?{path:!0}:Bn(e)?e:{}}pv(e=this.fv()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}Sv(e){let t=this.fv(),n=this.dv;return!(!n||!(t.path&&e.pathname!==n.pathname||t.search&&e.search!==n.search||this.pv(t)&&e.hash!==n.hash))}wv(e){try{let t=this.vv();if(!t)return;this.Sv(t)&&this._instance.capture(ui,{navigation_type:e}),this.dv=t}catch(t){Tr.error(`Error capturing ${e} pageview`,t)}}bv(){if(this.gv)return;let e=()=>{this.wv(`popstate`)};gi(wn,`popstate`,e),this.gv=()=>{wn&&wn.removeEventListener(`popstate`,e)}}_v(){if(this.mv)return;let e=()=>{this.wv(`hashchange`)};gi(wn,`hashchange`,e),this.mv=()=>{wn&&wn.removeEventListener(`hashchange`,e)}}},heatmaps:class{get Rr(){return this.instance.config}constructor(e){this.xv=!1,this.xo=!1,this.Cv=null,this.instance=e,this.xv=!!this.instance.persistence?.props[foe],this.rageclicks=new gue(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return Bn(this.Rr.capture_heatmaps)&&this.Rr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Rr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Kn(this.Rr.capture_heatmaps)?Kn(this.Rr.enable_heatmaps)?this.xv:this.Rr.enable_heatmaps:!1!==this.Rr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.xo)return;Aue.info(`starting...`),this.$v(),this.ln()}else clearInterval(this.Cv??void 0),this.Tv(),this.getAndClearBuffer()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`heatmaps`in t))return;let n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[foe]:n}),this.xv=n,this.startIfEnabled()}getAndClearBuffer(){let e=this.Rt;return this.Rt=void 0,e}Iv(e){jue(e.originalEvent)&&this.Tr(e.originalEvent,`deadclick`)}ln(){this.Cv&&clearInterval(this.Cv),this.Cv=Dn?.visibilityState===`visible`?setInterval(this.bl.bind(this),this.flushIntervalMilliseconds):null}$v(){wn&&Dn&&(this.Mv=this.bl.bind(this),gi(wn,li,this.Mv),this.Ev=e=>this.Tr(e||wn?.event),gi(Dn,`click`,this.Ev,{capture:!0}),this.Pv=e=>this.Rv(e||wn?.event),gi(Dn,`mousemove`,this.Pv,{capture:!0}),this.Av=new pce(this.instance,dce,this.Iv.bind(this)),this.Av.startIfEnabledOrStop(),this.Fv=this.ln.bind(this),gi(Dn,ci,this.Fv),this.xo=!0)}Tv(){var e;wn&&Dn&&(this.Mv&&wn.removeEventListener(li,this.Mv),this.Ev&&Dn.removeEventListener(`click`,this.Ev,{capture:!0}),this.Pv&&Dn.removeEventListener(`mousemove`,this.Pv,{capture:!0}),this.Fv&&Dn.removeEventListener(ci,this.Fv),clearTimeout(this.Ov),(e=this.Av)==null||e.stop(),this.xo=!1)}Dv(e,t){let n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(e,t,n){let r=e;for(;r&&ki(r)&&!Ai(r,`body`);){if(r===n)return!1;let e;try{e=(r.ownerDocument?.defaultView??wn)?.getComputedStyle(r).position}catch{return!1}if(Fn(t,e))return!0;r=Wse(r)}return!1}(Ni(e),[`fixed`,`sticky`],i);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}Tr(e,t=`click`){var n;if(Fse(e.target)||!jue(e))return;let r=this.Dv(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Zse(Ni(e),this.instance.config.rageclick)&&this.Zs(R(R({},r),{},{type:`rageclick`})),this.Zs(r)}Rv(e){!Fse(e.target)&&jue(e)&&(clearTimeout(this.Ov),this.Ov=setTimeout(()=>{this.Zs(this.Dv(e,`mousemove`))},500))}Zs(e){if(!wn)return;let t=this.Rr.disable_capture_url_hashes?hr(wn.location.href):wn.location.href,n=this.Rr.custom_personal_data_properties,r=Wi(t,this.Rr.mask_personal_data_properties?[...Ki,...n||[]]:[],qi);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(e)}bl(){this.Rt&&!Vn(this.Rt)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:pce,webVitalsAutocapture:class{constructor(e){this._instance=e,this.xv=!1,this.xo=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Lv=()=>{clearTimeout(this.Nv),this.Nv=void 0,this.Rt.metrics.length!==0&&(this._instance.capture(`$web_vitals`,R({$current_url:this.Rt.url},this.Rt.metrics.reduce((e,t)=>R(R({},e),{},{[`$web_vitals_${t.name}_event`]:R({},t),[`$web_vitals_${t.name}_value`]:t.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.qv=e=>{if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Kn(e?.name)||Kn(e?.value))return void Wa.error(`Invalid metric received`,e);let t=typeof e.navigationURL==`string`?e.navigationURL:void 0,n=this.jv(t);if(Hn(n))return;let r=qn(e.navigationId)||typeof e.navigationId==`string`?`navigation:${e.navigationId}`:`url:${n}`;if(this.Bv&&e.value>=this.Bv)return void Wa.error(`Ignoring metric with value >= `+this.Bv,e);this.Rt.navigationKey!==r&&(this.Lv(),this.Nv=setTimeout(this.Lv,this.flushToCaptureTimeoutMs)),Hn(this.Rt.navigationKey)&&(this.Rt.navigationKey=r,this.Rt.url=n),this.Rt.firstMetricTimestamp=Hn(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;let i=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0),a=R(R(R({},e),t?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete a.entries,Bn(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){let t={};for(let n of Due){let r=n===`url`&&typeof e.attribution[n]==`string`?this.jv(e.attribution[n]):e.attribution[n];Hn(r)||(t[n]=r)}a.attribution=t}else delete a.attribution;Hn(i)||(a.$session_id=i.sessionId,a.$window_id=i.windowId),this.Rt.metrics.push(a),this.Rt.metrics.length===this.allowedMetrics.length&&this.Lv()},this.Hv=()=>{if(this.xo)return;let e,t,n,r,i=!1,a=Mn.__PosthogExtensions__,o=a?.postHogWebVitalsCallbacksByFlavor,s=o?.[this.zv]||(this.zv===`web-vitals`&&Hn(o)?a?.postHogWebVitalsCallbacks:void 0);if(!Hn(s)){let a=s.withoutAttribution,o=this.attributionMetrics;i=!Hn(a),e=o.indexOf(`LCP`)>-1?s.onLCP:a?.onLCP||s.onLCP,t=o.indexOf(`CLS`)>-1?s.onCLS:a?.onCLS||s.onCLS,n=o.indexOf(`FCP`)>-1?s.onFCP:a?.onFCP||s.onFCP,r=o.indexOf(`INP`)>-1?s.onINP:a?.onINP||s.onINP}if(!(e&&t&&n&&r))return void Wa.error(`web vitals callbacks not loaded - not starting`);let c={reportSoftNavs:this.useSoftNavs},l=i&&this.attributionMetrics.indexOf(`INP`)>-1?R(R({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.qv.bind(this),c),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.qv.bind(this),c),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.qv.bind(this),c),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.qv.bind(this),l),this.xo=!0},this.xv=!!this._instance.persistence?.props[goe],this.startIfEnabled()}get Uv(){return this._instance.config.capture_performance}get allowedMetrics(){let e=Bn(this.Uv)?this.Uv?.web_vitals_allowed_metrics:void 0;return Kn(e)?this._instance.persistence?.props.$web_vitals_allowed_metrics||Tue:e}get flushToCaptureTimeoutMs(){return(Bn(this.Uv)?this.Uv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){let e=Bn(this.Uv)?this.Uv.web_vitals_attribution:void 0;return Yn(e)?e?Tue:[]:Rn(e)?e:Eue}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){let e=Bn(this.Uv)?this.Uv.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Bv(){let e=Bn(this.Uv)&&qn(this.Uv.__web_vitals_max_value)?this.Uv.__web_vitals_max_value:wue;return e>0&&6e4>=e?wue:e}get isEnabled(){let e=On?.protocol;if(e!==`http:`&&e!==`https:`)return Wa.info(`Web Vitals are disabled on non-http/https protocols`),!1;let t=Bn(this.Uv)?this.Uv.web_vitals:Yn(this.Uv)?this.Uv:void 0;return Yn(t)?t:this.xv}startIfEnabled(){this.isEnabled&&!this.xo&&(Wa.info(`enabled, starting...`),this.zo(this.Hv))}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`capturePerformance`in t))return;let n=Bn(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=Bn(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[goe]:n}),this._instance.persistence.register({[boe]:r})),this.xv=n,this.startIfEnabled()}get zv(){return this.useSoftNavs?this.useAttribution?`web-vitals-with-attribution-soft-navs`:`web-vitals-soft-navs`:this.useAttribution?`web-vitals-with-attribution`:`web-vitals`}zo(e){var t;let n=Mn.__PosthogExtensions__,r=this.zv,i=n?.postHogWebVitalsCallbacksByFlavor;i?.[r]||r===`web-vitals`&&Hn(i)&&n?.postHogWebVitalsCallbacks?e():n==null||(t=n.loadExternalDependency)==null||t.call(n,this._instance,r,t=>{t?Wa.error(`failed to load script`,t):e()})}jv(e){let t=e||wn?.location.href;if(!t)return void Wa.error(`Could not determine current URL`);let n=this._instance.config.disable_capture_url_hashes?hr(t):t,r=this._instance.config.custom_personal_data_properties;return Wi(n,this._instance.config.mask_personal_data_properties?[...Ki,...r||[]]:[],qi)}}},Tde={exceptionObserver:class{constructor(e){this.Hv=()=>{if(!wn||!this.isEnabled||!Mn.__PosthogExtensions__?.errorWrappingFunctions)return;let e=Mn.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,t=Mn.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=Mn.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Wv&&this.Rr.capture_unhandled_errors&&(this.Wv=e(this.captureException.bind(this))),!this.Vv&&this.Rr.capture_unhandled_rejections&&(this.Vv=t(this.captureException.bind(this))),!this.Gv&&this.Rr.capture_console_errors&&(this.Gv=n(this.captureException.bind(this)))}catch(e){Ha.error(`failed to start`,e),this.Zv()}},this._instance=e,this.Qv=!!this._instance.persistence?.props[poe],this.wt=new Nre(R(R({},function(e={}){return{refillRate:e.exceptionRateLimiterRefillRate??e.__exceptionRateLimiterRefillRate??1,bucketSize:e.exceptionRateLimiterBucketSize??e.__exceptionRateLimiterBucketSize??10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:Ha})),this.Rr=this.Jv(),this.startIfEnabledOrStop()}Jv(){let e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Bn(e)?t=R(R({},t),e):(Hn(e)?this.Qv:e)&&(t=R(R({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Rr.capture_console_errors||this.Rr.capture_unhandled_errors||this.Rr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ha.info(`enabled`),this.Zv(),this.zo(this.Hv)):this.Zv()}zo(e){var t,n;Mn.__PosthogExtensions__?.errorWrappingFunctions?e():(t=Mn.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`exception-autocapture`,t=>{if(t)return Ha.error(`failed to load script`,t);e()})}Zv(){var e,t,n;(e=this.Wv)==null||e.call(this),this.Wv=void 0,(t=this.Vv)==null||t.call(this),this.Vv=void 0,(n=this.Gv)==null||n.call(this),this.Gv=void 0}onRemoteConfig(e){if(!e.ok)return;let t=e.config;`autocaptureExceptions`in t&&(this.Qv=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[poe]:this.Qv}),this.Rr=this.Jv(),this.startIfEnabledOrStop())}onConfigChange(){this.Rr=this.Jv()}captureException(e){try{var t,n;let r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;if(this.wt.consumeRateLimit(r))return void Ha.info(`Skipping exception capture because of client rate limiting.`,{exception:r});(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}catch{}}},exceptions:class{constructor(e){this.Kv=[],this.Xv=new Uie([new cae,new vae,new uae,new lae,new gae,new hae,new fae,new _ae],function(e,...t){return(n,r=0)=>{let i=[],a=n.split(`
3
3
  `),o=Math.min(a.length,r+1e3),s=[];for(let n=r;o>n;n++){let r=a[n];if(r.length>1024)continue;let o=tae.test(r)?r.replace(tae,`$1`):r;if(!o.match(/\S*Error: /)){for(let n of t){let t=n(o,e);if(t){i.push(t);let e=nae(i);if(e){for(let t=s.length-1;t>=0;t--){let n=s[t];if(e.start>=n.start+n.length)break;s.pop()}s.push(e)}break}}if(oae(i,s)>=50)break}}let c=[...s].sort((e,t)=>t.start-e.start),l=c[c.length-1];if(l){let e=iae(i,l);i.splice(l.start-e,e);for(let t of c)t.start-=e}for(let e of c)rae(i,e);return s.some(e=>e.start===0&&i.length===e.length)&&function(e){let t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`),n=0;for(let e=1;t.length>e;e++)sae(t,e,n)&&(n=e);e.push(...e.splice(0,n))}(i),function(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return R(R({},e),{},{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||`?`});var n})}(i)}}(`web:javascript`,Zie,eae)),this._instance=e,this.Kv=this._instance.persistence?.get_property(`$error_tracking_suppression_rules`)??[],this.Yv=xr(this.tf()),this.ef=new xae(this.Yv)}onConfigChange(){this.Yv=xr(this.tf()),this.ef.setConfig(this.Yv)}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`errorTracking`in t))return;let n=t.errorTracking?.suppressionRules??[],r=t.errorTracking?.captureExtensionExceptions;this.Kv=n,this._instance.persistence&&this._instance.persistence.register({[moe]:this.Kv,[hoe]:r})}get if(){var e;let t=!!this._instance.get_property(hoe);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.Xv.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.Yv.enabled)try{if(!Un(e)||e.trim().length===0)return void Za.warn(`Ignoring exception step because message must be a non-empty string`);let{sanitizedProperties:n,droppedKeys:r}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};let t=[];return{sanitizedProperties:Object.keys(e).reduce((n,r)=>yae.has(r)?(t.push(r),n):(n[r]=e[r],n),{}),droppedKeys:t}}(this.nf(t));r.length>0&&Za.warn(`Ignoring reserved exception step fields`,{droppedKeys:r}),this.ef.add(R({[yr]:e,[br]:new Date().toISOString()},n))}catch(e){Za.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{let t=e.$exception_list;if(this.sf(t)){if(this.rf(t))return this.af(`Exception dropped: matched a suppression rule`),void Za.info(`Skipping exception capture because a suppression rule matched`);if(!this.if&&this.lf(t))return this.af(`Exception dropped: thrown by a browser extension`),void Za.info(`Skipping exception capture because it was thrown by an extension`);if(!this.if&&this.uf(t))return this.af(`Exception dropped: thrown by an injected browser script`),void Za.info(`Skipping exception capture because it was thrown by an injected browser script`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.hf(t))return this.af(`Exception dropped: thrown by the PostHog SDK`),void Za.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}let n=this.Yv.enabled&&Kn(e.$exception_steps)?this.cf(e):e,r=function(){let e=globalThis._posthogReleaseId;return typeof e==`string`&&e.length>0?e:void 0}();r&&(n.$release_id=r);try{let e=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,fh:!0});return e&&this.ef.clear(),e}catch(e){tde(e)||Za.error(`Failed to capture exception event. Dropping this exception.`,e),this.ef.clear();return}}catch(e){tde(e)||Za.error(`Failed to process exception event. Ignoring this exception.`,e);return}}cf(e){try{let t=this.ef.getAttachable();return t.length===0?e:R(R({},e),{},{$exception_steps:t})}catch(t){return Za.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}af(e){this.Yv.enabled&&this.ef.add({[yr]:e,[br]:new Date().toISOString()})}nf(e){return Bn(e)?R({},e):{}}tf(){return this._instance.config.error_tracking?.exception_steps??{}}rf(e){if(e.length===0)return!1;try{let t=e.reduce((e,{type:t,value:n})=>(Un(t)&&t.length>0&&e.$exception_types.push(t),Un(n)&&n.length>0&&e.$exception_values.push(n),e),{$exception_types:[],$exception_values:[]});return this.Kv.some(e=>{let n=e.values.map(e=>{let n=Ule[e.operator],r=t[e.key];if(!n||!r)return!1;let i=Rn(e.value)?e.value:[e.value];return i.length>0&&n(i,r)});return e.type===`OR`?n.some(Boolean):n.every(Boolean)})}catch(e){return Za.warn(`Failed to evaluate suppression rules. Capturing the exception.`,e),!1}}lf(e){let t=e.flatMap(e=>e.stacktrace?.frames??[]),n=t.filter(({filename:e})=>!!e&&ide.some(t=>e.startsWith(t)));return n.length!==0&&(!n.every(({filename:e})=>!!e&&e.startsWith(nde))||e.some(({type:e,value:t})=>e===`NoResponse`||Un(t)&&rde.some(({value:e,exact:n})=>n?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!t?.startsWith(nde)))}uf(e){return e.some(({value:e})=>Un(e)&&ade.some(t=>e.includes(t)))}hf(e){if(e.length>0){var t,n;let r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}sf(e){return!Kn(e)&&Rn(e)}}},Ede=R({productTours:class{get Ml(){return this._instance.persistence}constructor(e){this.df=null,this.vf=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(`productTours`in t){var n;if(this.Ml&&this.Ml.register({[voe]:!!t.productTours}),!Mue(this._instance))return!this.df&&Kn(this.Ml?.props.ph_product_tours)||Ka.info(`product tours disabled; stopping and clearing cached tours`),(n=this.df)==null||n.stop(),this.df=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.df&&Mue(this._instance)&&this.zo(()=>this.ff())}zo(e){var t,n;Mn.__PosthogExtensions__?.generateProductTours?e():(t=Mn.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`product-tours`,t=>{t?Ka.error(`Could not load product tours script`,t):e()})}ff(){var e;!this.df&&(e=Mn.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.df=Mn.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(Rn(this.vf)&&!t)return void e(this.vf,{isLoaded:!0});let n=this.Ml;if(n){let r=n.props[zoe];if(Rn(r)&&!t)return this.vf=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=${this._instance.config.token}`),method:`GET`,timestampMode:`query`,callback:t=>{if(!Mue(this._instance))return void e([],{isLoaded:!0});let r=t.statusCode;if(r!==200||!t.json){let n=`Product Tours API could not be loaded, status: ${r}`;r===0?t.error||Ka.warn(n):Ka.error(n),e([],{isLoaded:!1,error:n});return}let i=Rn(t.json.product_tours)?t.json.product_tours:[];this.vf=i,n&&n.register({[zoe]:i}),e(i,{isLoaded:!0})}})}getActiveProductTours(e){Kn(this.df)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.df.getActiveProductTours(e)}showProductTour(e){var t;(t=this.df)==null||t.showTourById(e)}previewTour(e){this.df?this.df.previewTour(e):this.zo(()=>{var t;this.ff(),(t=this.df)==null||t.previewTour(e)})}dismissProductTour(){var e;(e=this.df)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.df)==null||e.nextStep()}previousStep(){var e;(e=this.df)==null||e.previousStep()}clearCache(){var e;this.vf=null,(e=this.Ml)==null||e.unregister(`ph_product_tours`)}resetTour(e){var t;(t=this.df)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.df)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.df)==null||t.cancelPendingTour(e)}}},to),Dde={siteApps:class{constructor(e){this._instance=e,this.pf=0,this.gf=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}mf(e,t){if(!t)return;let n=this.globalsForEvent(t);this.gf.push(n),this.gf.length>1e3&&(this.gf=this.gf.slice(10))}get siteAppLoaders(){var e;return(e=Mn._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){let e=this._instance._addCaptureHook(this.mf.bind(this));this.yf=()=>{e(),this.gf=[],this.yf=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);let t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(let[e,i]of Object.entries(r))t[e]={id:n[e],type:e,properties:i};let{$set_once:i,$set:a}=e;return{event:R(R({},Pae(e,Nue)),{},{properties:R(R(R({},e.properties),a?{$set:R(R({},e.properties?.$set??{}),a)}:{}),i?{$set_once:R(R({},e.properties?.$set_once??{}),i)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}bf(e){let t=e.tagName?.toLowerCase();return t===`style`&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(qa.error(`prepare_external_dependency_stylesheet returned null`),null):t===`script`&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(qa.error(`prepare_external_dependency_script returned null`),null):e}_f(){var e;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};let t=Dn?.defaultView,n=t==null||(e=t.Node)==null?void 0:e.prototype;if(!t||!n)return()=>{};if(this.pf++,this.wf)return this.kf();let r=[],i=this,a=new WeakSet,o=(e,t,n)=>{if(!e?.[t])return;let i=e[t];e[t]=n(i),r.push(()=>{e[t]=i})},s=e=>{if(a.has(e))return e;let t=i.bf(e);return t&&a.add(t),t},c=e=>e.map(e=>typeof e==`string`?e:s(e)).filter(e=>!Gn(e));return o(n,`appendChild`,e=>function(t){let n=s(t);return n?e.call(this,n):t}),o(n,`insertBefore`,e=>function(t,n){let r=s(t);return r?e.call(this,r,n):t}),o(n,`replaceChild`,e=>function(t,n){let r=s(t);return r?e.call(this,r,n):n}),[t.Element?.prototype,t.Document?.prototype,t.DocumentFragment?.prototype].forEach(e=>{o(e,`append`,e=>function(...t){return e.apply(this,c(t))}),o(e,`prepend`,e=>function(...t){return e.apply(this,c(t))})}),[t.Element?.prototype,t.CharacterData?.prototype,t.DocumentType?.prototype].forEach(e=>{o(e,`before`,e=>function(...t){return e.apply(this,c(t))}),o(e,`after`,e=>function(...t){return e.apply(this,c(t))}),o(e,`replaceWith`,e=>function(...t){let n=c(t);return t.length&&!n.length?void 0:e.apply(this,n)})}),o(t.Element?.prototype,`insertAdjacentElement`,e=>function(t,n){let r=s(n);return r?e.call(this,t,r):null}),this.wf=()=>{r.forEach(e=>e()),this.wf=void 0},this.kf()}kf(){let e=!1;return()=>{var t;e||(e=!0,this.pf--,this.pf===0&&((t=this.wf)==null||t.call(this)))}}Sf(e,t=!0){let n=this._f();try{let r=e(n);return t&&n(),r}catch(e){throw n(),e}}setupSiteApp(e){let t=this.apps[e.id],n=()=>{var n;!t.errored&&this.gf.length&&(qa.info(`Processing ${this.gf.length} events for site app with id ${e.id}`),this.gf.forEach(e=>this.Sf(()=>t.processEvent?.call(t,e))),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&((n=this.yf)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,qa.info(`Site app with id ${e.id} ${i?`loaded`:`errored`}`),r&&n()};try{let{processEvent:n}=this.Sf(t=>e.init({posthog:this._instance,callback(e){t(),i(e)}}),!1);n&&(t.processEvent=n),r=!0}catch(t){qa.error(Pue+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){qa.error(`Error while processing buffered events PostHog app with config id ${e.id}`,n),t.errored=!0}}xf(){let e=this.siteAppLoaders||[];for(let t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(let t of e)this.setupSiteApp(t)}Cf(e){if(Object.keys(this.apps).length===0)return;let t=this.globalsForEvent(e);for(let n of Object.values(this.apps))try{this.Sf(()=>n.processEvent?.call(n,t))}catch(t){qa.error(`Error while processing event ${e.event} for site app ${n.id}`,t)}}onRemoteConfig(e){var t;if(this.siteAppLoaders?.length)return this.isEnabled?(this.xf(),void this._instance.on(`eventCaptured`,e=>this.Cf(e))):void qa.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((t=this.yf)==null||t.call(this),!e.ok)return;let n=e.config;if(n.siteApps?.length){if(this.isEnabled)for(let{id:e,url:t}of n.siteApps){var r,i;Mn[`__$$ph_site_app_${e}`]=this._instance,(r=Mn.__PosthogExtensions__)==null||(i=r.loadSiteApp)==null||i.call(r,this._instance,t,t=>{if(t)return qa.error(Pue+e,t)})}else qa.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}}},Ode={tracingHeaders:class{constructor(e){this._instance=e,this.$f=void 0,this.Tf=void 0,this.If=void 0,this.Hv=()=>{let e=this.Mf();var t,n;e?(Hn(this.$f)&&(this.$f=(t=Mn.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),Hn(this.Tf)&&(this.Tf=(n=Mn.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null?void 0:n._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Zv()}}initialize(){this.startIfEnabledOrStop()}zo(e){var t,n;Mn.__PosthogExtensions__?.tracingHeadersPatchFns?e():(t=Mn.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`tracing-headers`,t=>{if(t)return Cue.error(`failed to load script`,t);e()})}Ef(){return this._instance.config.tracing_headers??this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}Mf(){let e=this.Ef();return Rn(e)?(Rn(this.If)?this.If.splice(0,this.If.length,...e):this.If=[...e],e.length>0?this.If:void 0):(Rn(this.If)&&this.If.splice(0),this.If=e||void 0,this.If)}Zv(){var e,t;(e=this.$f)==null||e.call(this),(t=this.Tf)==null||t.call(this),this.$f=void 0,this.Tf=void 0}startIfEnabledOrStop(){this.Mf()?this.zo(this.Hv):this.Zv()}}},kde=R({surveys:class extends Lue{constructor(e){var t;super(new Hue(e),(t=e,{get projectToken(){return t.config.token},kv:new Vue(t)})),this._instance=e}qh(e,t){let n=t.query?Sa(e,t.query):e;return new Promise(e=>{this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor(t.target??`api`,n),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:e})})}}},to),Ade={toolbar:class{constructor(e){this.instance=e}Pf(e){Mn.ph_toolbar_state=e}Rf(){return Mn.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,n=void 0){if(_i(this.instance.config)||!wn||!Dn)return!1;e??=wn.location,n??=wn.history;try{if(!t){try{wn.localStorage.setItem(`test`,`test`),wn.localStorage.removeItem(`test`)}catch{return!1}t=wn?.localStorage}let r=Uue||Gi(e.hash,`__posthog`)||Gi(e.hash,`state`),i,a=r?Nie(()=>JSON.parse(atob(decodeURIComponent(r))))||Nie(()=>JSON.parse(decodeURIComponent(r))):null;return a&&a.action===`ph_authorize`?(i=a,i.source=`url`,i&&Object.keys(i).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,``,e.pathname+e.search):e.hash=``)):(i=JSON.parse(t.getItem(Wue)||`{}`),i.source=`localstorage`,delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}Af(e){let t=Mn.ph_load_toolbar||Mn.ph_load_editor;!Kn(t)&&zn(t)?t(e,this.instance):Gue.warn(`No toolbar load function found`)}loadToolbar(e){let t=!!Dn?.getElementById(`__POSTHOG_TOOLBAR__`);if(!wn||t)return!1;let n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=R(R({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(wn.localStorage.setItem(Wue,JSON.stringify(R(R({},r),{},{source:void 0}))),this.Rf()===2)this.Af(r);else if(this.Rf()===0){var i,a;this.Pf(1),(i=Mn.__PosthogExtensions__)==null||(a=i.loadExternalDependency)==null||a.call(i,this.instance,`toolbar`,e=>{if(e)return Gue.error(`[Toolbar] Failed to load`,e),void this.Pf(0);this.Pf(2),this.Af(r)}),gi(wn,`turbolinks:load`,()=>{this.Pf(0),this.loadToolbar(r)})}return!0}Ff(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,n=void 0){return this.maybeLoadToolbar(e,t,n)}}},jde=R({experiments:class e{get Rr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(t=!1)=>{this.getWebExperiments(t=>{e.Of(`retrieved web experiments from the server`),this.Df=new Map,t.forEach(t=>{if(t.feature_flag_key){var n;this.Df&&(e.Of(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(n=this.Df)==null||n.set(t.feature_flag_key,t));let r=this._instance.getFeatureFlag(t.feature_flag_key);Un(r)&&t.variants[r]&&this.Lf(t.name,r,t.variants[r].transforms)}else if(t.variants)for(let n in t.variants){let r=t.variants[n];e.Nf(r,this._instance)&&this.Lf(t.name,n,r.transforms)}})},t)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(t){if(this._is_bot())e.Of(ode);else if(!this.Rr.disable_web_experiments){if(Kn(this.Df))return this.Df=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.Of(`applying feature flags`,t),t.forEach(e=>{if(this.Df&&this.Df?.has(e)){let t=this._instance.getFeatureFlag(e),n=this.Df?.get(e);t&&n!=null&&n.variants[t]&&this.Lf(n.name,t,n.variants[t].transforms)}})}}previewWebExperiment(){let t=e.getWindowLocation();if(t?.search){let n=Ui(t?.search,`__experiment_id`),r=Ui(t?.search,`__experiment_variant`);n&&r&&(e.Of(`previewing web experiments ${n} && ${r}`),this.getWebExperiments(e=>{this.qf(parseInt(n),r,e)},!1,!0))}}loadIfEnabled(){this.Rr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Rr.disable_web_experiments&&!n)return e([]);let r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=${this.Rr.token}`),method:`GET`,timestampMode:`query`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}qf(t,n,r){let i=r.filter(e=>e.id===t);i&&i.length>0&&(e.Of(`Previewing web experiment [${i[0].name}] with variant [${n}]`),this.Lf(i[0].name,n,i[0].variants[n].transforms))}static Nf(t,n){return!Kn(t.conditions)&&e.jf(t,n)&&e.Bf(t)}static jf(t,n){if(Kn(t.conditions)||Kn(t.conditions?.url))return!0;let r=e.getWindowLocation();if(r){let e=Pse(n,r.href);return!t.conditions?.url||sde[t.conditions?.urlMatchType??`icontains`](t.conditions.url,e)}return!1}static getWindowLocation(){return wn?.location}static Bf(e){if(Kn(e.conditions)||Kn(e.conditions?.utm))return!0;let t=Tce();if(t.utm_source){var n,r,i,a,o,s,c,l;let u=!((n=e.conditions)!=null&&(n=n.utm)!=null&&n.utm_campaign)||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=!((i=e.conditions)!=null&&(i=i.utm)!=null&&i.utm_source)||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=!((o=e.conditions)!=null&&(o=o.utm)!=null&&o.utm_medium)||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=!((c=e.conditions)!=null&&(c=c.utm)!=null&&c.utm_term)||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static Of(e,...t){Tr.info(`[WebExperiments] ${e}`,t)}Lf(t,n,r){this._is_bot()?e.Of(ode):n===`control`?e.Of(`Control variants leave the page unmodified.`):r.forEach(r=>{r.selector&&(e.Of(`applying transform of variant ${n} for experiment ${t} `,r),(document?.querySelectorAll(r.selector))?.forEach(e=>{let t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)}))})}_is_bot(){return En&&this._instance?zle(En,this.Rr.custom_blocked_useragents):void 0}}},to),Mde={conversations:class{constructor(e){this._instance=e,this.Hf=void 0,this._conversationsManager=null,this.zf=!1,this.ne=null,this.Uf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this.Wf=e.ok,!e.ok))return;let t=e.config.conversations;Kn(t)||(Yn(t)?this.Hf=t:(this.Hf=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Hf=void 0,this.ne=null,this.Wf=void 0,this.Uf=!1}loadIfEnabled(){if(this._conversationsManager||this.zf||this._instance.config.disable_conversations||_i(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;let e=Mn?.__PosthogExtensions__;if(e&&!Hn(this.Hf)&&this.Hf){if(this.ne&&this.ne.token){this.zf=!0;try{let t=e.initConversations;if(t)return this.Vf(t),void(this.zf=!1);let n=e.loadExternalDependency;if(!n)return void this.Gf(ai);n(this._instance,`conversations`,t=>{t||!e.initConversations?this.Gf(`Could not load conversations script`,t):this.Vf(e.initConversations),this.zf=!1})}catch(e){this.Gf(`Error initializing conversations`,e),this.zf=!1}}else Qa.error(`Conversations enabled but missing token in remote config.`)}}Vf(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.Uf=!1,Qa.info(`Conversations loaded successfully`)}catch(e){this.Gf(`Error completing conversations initialization`,e)}else Qa.error(`Cannot complete initialization: remote config is null`)}Gf(e,t){Qa.error(e,t),this._conversationsManager=null,this.zf=!1,this.Uf=!0}show(){this._conversationsManager?this._conversationsManager.show():Qa.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Hf&&!Gn(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?`disabled_by_config`:_i(this._instance.config)?`disabled_for_toolbar`:this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?`consent_opted_out`:!1===this.Wf?`remote_config_failed`:Hn(this.Hf)?this.Wf?`disabled_in_project`:`remote_config_pending`:this.Hf?Kn(this.ne)||!this.ne.token?`missing_token`:Mn?.__PosthogExtensions__?this.zf?`initializing`:this.Uf?`load_failed`:`not_loaded`:`extensions_unavailable`:`disabled_in_project`}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return er(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(Qa.warn($a),null)})()}getMessages(e,t){var n=this;return er(function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(Qa.warn($a),null)})()}markAsRead(e){var t=this;return er(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Qa.warn($a),null)})()}getTickets(e){var t=this;return er(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Qa.warn($a),null)})()}requestRestoreLink(e){var t=this;return er(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Qa.warn($a),null)})()}restoreFromToken(e){var t=this;return er(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Qa.warn($a),null)})()}restoreFromUrlToken(){var e=this;return er(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Qa.warn($a),null)})()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}Sh(){var e;(e=this._conversationsManager)==null||e.setIdentity()}xh(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},Nde={logs:class{constructor(e){var t;this._instance=e,this.name=`logs`,this.Zf=!1,this.Qf=!1,this.Jf=!1,this.$=Er(`[logs]`),this.Kf=R(R({},this.$),{},{error:(...e)=>{e.some(mde)||this.$.error(...e)}}),this.al=[],this.Xf=[],this.hd=0,this.Io=!1,this.Yf=[],this.tp=[],this.ep=!1,this.np=!1,this.sp=()=>{var e,t;this.Io||(this.hd=0,(e=this.rp)==null||e.onReconnect(),(t=this.op)==null||t.onReconnect())},this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Zf=!0),wn&&gi(wn,`online`,this.sp)}ap(e,t,n,r){var i;let a=cde((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new Qae(this.lp(e,t),a,this.Kf,()=>this.up(),e=>e(),void 0,r),a]}hp(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;var n;return this.rp&&this.cp===t||((n=this.rp)==null||n.reset(),this.cp=t,[this.rp,this.dp]=this.ap(()=>this.al,e=>{this.al=e})),this.rp}vp(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;var n;return this.op&&this.fp===t||((n=this.op)==null||n.reset(),this.fp=t,[this.op,this.pp]=this.ap(()=>this.Xf,e=>{this.Xf=e},{serviceNameDefault:`posthog-browser-logs`,consoleCapture:!0},dde)),this.op}setup(e){var t;if(this.Io)return;this.wo=e,(t=this._instance)!=null&&(t=t.config)!=null&&(t=t.logs)!=null&&t.captureConsoleLogs&&(this.Zf=!0),(this.Zf||this.gp()&&this.mp())&&this.yp();let n=!1,r=e.onRemoteConfig(e=>{n=e.ok&&!0===e.config.logs?.captureConsoleLogs,this.onRemoteConfig(e)});this.Io?r.dispose():(this.Po=r,n||this.loadIfEnabled())}dispose(){var e,t,n,r;this.Io||(this.Io=!0,this.bp(),(e=this.Po)==null||e.dispose(),this.Po=void 0,this.wo=void 0,this.Jf=!1,wn?.removeEventListener(`online`,this.sp),(t=this._p)==null||t.call(this),this._p=void 0,(n=this.rp)==null||n.reset(),(r=this.op)==null||r.reset())}onRemoteConfig(e){var t;if(this.Io)return;let n=e.ok?e.config.logs?.captureConsoleLogs:void 0;Kn(n)?this.wp():((t=this._instance)==null||(t=t.persistence)==null||t.register({$logs_capture_enabled_server_side:!!n}),n?(this.Zf=!0,this.Qf||this.yp(),this.loadIfEnabled()):this.wp())}reset(){var e,t,n,r;this.bp(),(e=this.rp)==null||e.clearQueue(),this.al=[],(t=this.rp)==null||t.reset(),(n=this.op)==null||n.clearQueue(),this.Xf=[],(r=this.op)==null||r.reset(),this.hd=0}captureLog(e){this.Io||this.hp().captureLog(e)}captureConsoleLog(e){this.Io||this.vp().captureLog(e)}captureBufferedConsoleLog(e,t,n){this.Io||this.vp().captureLog(e,{context:t,occurredAtMs:n})}mp(){var e;return!!((e=this._instance)!=null&&(e=e.persistence)!=null&&(e=e.props)!=null&&e[yoe])}gp(){var e,t,n;return!((e=this._instance)!=null&&(t=e.nl)!=null&&t.call(e))||!!((n=Mn._POSTHOG_REMOTE_CONFIG)!=null&&(n=n[this._instance.config.token])!=null&&n.config)}$h(){var e;this.bp(),(e=this.op)==null||e.clearQueue(),this.Xf=[]}wp(){this.Zf||this.bp()}yp(){var e;if(this.ep||!Mn?.console)return;let t=cde((e=this._instance)==null||(e=e.config)==null?void 0:e.logs).maxBufferSize,n=!0;this.tp.push(()=>{n=!1});for(let e of lde){let r;try{r=ude(Mn.console[e])}catch{continue}r&&this.tp.push(Ua(Mn.console,e,i=>{let a=(...r)=>{try{n&&this.kp(e,r,t)}catch{}return i.apply(Mn.console,r)};return a.__rrweb_original__=r,a}))}this.ep=!0,this.Sp=setTimeout(()=>{this.bp()},3e4)}kp(e,t,n){if(this.ep&&!this.np&&t.length!==0){if(this._instance?.is_capturing()){if(n>this.Yf.length){this.np=!0;try{this.Yf.push({level:e,args:t,occurredAtMs:Date.now(),context:this.up()})}finally{this.np=!1}}}else this.bp()}}bp(){if(this.Yf=[],this.ep){this.ep=!1,this.Sp&&=(clearTimeout(this.Sp),void 0);for(let e of this.tp)e();this.tp=[]}}xp(){let e=this.Yf;return this.bp(),e}get logger(){return this.Cp||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.Cp}flushLogs(e){e?this.$p(e):(this.rp&&this.rp.flush().catch(e=>this.Tp(e)),this.op&&this.op.flush().catch(e=>this.Tp(e)))}Tp(e){mde(e)||this.$.error(`PostHog logs flush failed:`,e)}loadIfEnabled(){if(this.Io||!this.Zf||this.Qf||this.Jf)return;let e=Mn?.__PosthogExtensions__;if(!e)return this.$.error(`PostHog Extensions not found.`),void this.bp();let t=e.loadExternalDependency;if(!t)return this.$.error(ai),void this.bp();this.Jf=!0;try{t(this._instance,`logs`,t=>{if(this.Jf=!1,this.Io||!this.Zf)return;let n=e.logs;if(t||!n?.initializeLogs)this.$.error(`Could not load logs script`,t),this.bp();else{let e=this.xp();var r;this._p=n.initializeLogs(this.wo??this._instance),this.Qf=!0,e.length>0&&((r=n.replayConsoleBuffer)==null||r.call(n,this.wo??this._instance,e))}})}catch(e){throw this.Jf=!1,e}}lp(e,t){let n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:t=>t===Pn.LogsQueue?e():void 0,setPersistedProperty(e,n){e===Pn.LogsQueue&&t(n??[])},js:e=>this.js(e),getLibraryId:()=>Ar.LIB_NAME,getLibraryVersion:()=>Ar.LIB_VERSION}}js(e){return new Promise(t=>{if(xce(this.hd,3))return void t({kind:`fatal`,error:pde(void 0,`logs endpoint is unreachable, dropping batch`)});let n=!1,r=e=>{n||(n=!0,clearTimeout(i),t(e))},i=setTimeout(()=>{this.$.warn(`Logs request timed out before receiving a response`),r({kind:`retry-later`,error:pde(void 0,`logs request timed out`)})},9e4);this._instance._send_request({method:`POST`,url:this.Ip(),data:e,compression:`best-available`,batchKey:`logs`,fireCallbackOnDrop:!0,callback:e=>{let t=e.statusCode;this.Mp(t),t>=200&&300>t?r({kind:`ok`}):t===413?r({kind:`too-large`}):t!==0&&t!==408&&t!==429&&500>t?r({kind:`fatal`,error:Error(`logs request failed with status ${t}`)}):t===0?(e.error||this.$.warn(`Logs request failed before receiving an HTTP response`),r({kind:`retry-later`,error:pde(e.error,`logs request failed before receiving an HTTP response`)})):r({kind:`retry-later`,error:e.error??Error(`logs request failed with status ${t}`)})}})})}Mp(e){(e!==0||this._instance.__loaded)&&(this.hd=Sce(e,this.hd,3,()=>this.$.warn(`Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.`)))}$p(e){this.al.length>0&&this.Ep(e,this.al,this.dp,Ar.LIB_NAME,e=>{this.al=e}),this.Xf.length>0&&this.Ep(e,this.Xf,this.pp,dde,e=>{this.Xf=e})}Ep(e,t,n,r,i){if(t.length===0)return;let a=t.map(e=>e.record);i([]);let o=Jae(a,qae(n,Ar.LIB_NAME,Ar.LIB_VERSION),r,Ar.LIB_VERSION);this._instance._send_request({method:`POST`,url:this.Ip(),data:o,compression:`best-available`,batchKey:`logs`,transport:e})}Ip(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token)}up(){var e;let t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){let{sessionId:e,windowId:n,sessionStartTimestamp:r,lastActivityTimestamp:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=e,t.windowId=n,Kn(r)||(t.sessionStartTimestamp=r),Kn(i)||(t.lastActivityTimestamp=i)}if(Mn!=null&&(e=Mn.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?hr(Mn.location.href):Mn.location.href),this._instance.featureFlags){let e=this._instance.featureFlags.getFlags();e&&e.length>0&&(t.activeFeatureFlags=e)}return t}}},Pde={metrics:class{constructor(e){this._instance=e,this.$=Er(`[metrics]`),this.Io=!1}initialize(){this.onConfigChange()}onConfigChange(){if(this.Io)return;let e=!!this._instance.config.metrics?.network;e&&!this.Pp?this.Pp=(e=>{let t=!0,n=()=>t?(e=>{let t=e.config.metrics?.network;return!0===t?{}:t||void 0})(e):void 0,r=xde(e,n),i=Sde(e,n);return()=>{t=!1,r(),i()}})(this._instance):!e&&this.Pp&&(this.Pp(),this.Pp=void 0)}hp(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;var n;return this.rp&&this.cp===t||((n=this.rp)==null||n.reset(),this.cp=t,this.rp=new noe(this.lp(),function(e){let t=e?.resourceAttributes;return{serviceName:t?.[`service.name`]??e?.serviceName,serviceVersion:t?.[`service.version`]??e?.serviceVersion,environment:t?.[`deployment.environment`]??e?.environment,resourceAttributes:t,beforeSend:e?.beforeSend,flushIntervalMs:e?.flushIntervalMs??1e4,maxSeriesPerFlush:e?.maxSeriesPerFlush??1e3}}(t),this.$)),this.rp}count(e,t=1,n){this.hp().count(e,t,n)}gauge(e,t,n){this.hp().gauge(e,t,n)}histogram(e,t,n){this.hp().histogram(e,t,n)}flush(e){if(!this.rp)return Promise.resolve();if(e){let t=this.rp.drainWindow();return t&&this.Ys(t,e),Promise.resolve()}return this.rp.flush().catch(e=>this.$.error(`PostHog metrics flush failed:`,e))}reset(){var e;(e=this.rp)==null||e.reset()}dispose(){var e,t;this.Io=!0,(e=this.Pp)==null||e.call(this),this.Pp=void 0,(t=this.rp)==null||t.reset()}lp(){let e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Ys:e=>t.Ys(e),getLibraryId:()=>Ar.LIB_NAME,getLibraryVersion:()=>Ar.LIB_VERSION}}Ys(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,clearTimeout(a),n(e))},a=setTimeout(()=>i({kind:`retry-later`,error:Error(`metrics request timed out`)}),9e4);this._instance._send_request(R(R({method:`POST`,url:this.Rp(),data:e,compression:`best-available`,batchKey:`metrics`},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){let t=e.statusCode;i(t>=200&&300>t?{kind:`ok`}:t===413?{kind:`too-large`}:t!==0&&t!==408&&t!==429&&500>t?{kind:`fatal`,error:Error(`metrics request failed with status ${t}`)}:{kind:`retry-later`,error:e.error??Error(`metrics request failed with status ${t}`)})}}))})}Rp(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/metrics`)+`?token=`+encodeURIComponent(this._instance.config.token)}}};Ra.__defaultExtensionClasses=R({},R(R(R(R(R(R(R(R(R(R(R(R(R({},to),Cde),wde),Tde),Ede),Dde),kde),Ode),Ade),jde),Mde),Nde),Pde));var no=function(){Ar.SDK_DIST_CHANNEL=`npm`;let e=Ma[Ia]=new Ra;return function(){function e(){e.done||(e.done=!0,kle=!1,fi(Ma,function(e){e._dom_loaded()}))}Dn?.addEventListener?Dn.readyState===`complete`?e():gi(Dn,`DOMContentLoaded`,e,{capture:!1}):wn&&Tr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}(),Fde=!1,Ide=[`campaign`,`pathname`,`referrer`,`referring_domain`,`session_entry`,`url`],Lde=new Set([`dclid`,`epik`,`fbclid`,`gclid`,`gclsrc`,`igshid`,`irclid`,`li_fat_id`,`mc_cid`,`msclkid`,`rdt_cid`,`ttclid`,`twclid`]);function Rde(e){if(!e)return e;let t={...e};for(let e of Object.keys(t)){let n=e.toLowerCase().replace(/^\$/,``);(n.startsWith(`utm_`)||Lde.has(n)||Ide.some(e=>n.includes(e)))&&delete t[e]}return t}function zde(e){if(!e)return null;let t=Rde(e.properties)??{};if(e.event===`$exception`){for(let e of Object.keys(t))e.startsWith(`$exception_`)&&e!==`$exception_level`&&delete t[e];t.$exception_list=[{type:`OverdeckTelemetryException`,value:`Overdeck browser operation failed`}]}return{...e,properties:t,$set:Rde(e.$set),$set_once:Rde(e.$set_once)}}async function Bde(){try{let e=await fetch(`/api/settings`);if(!e.ok)return;let t=await e.json();if((t.telemetry?.effectiveEnabled??t.telemetry?.enabled)===!1)return;no.init(`phc_pwvHeDutnCmAm8tZh5hRaQ7mMoho3T9gb4t4qRjK2Zjt`,{api_host:`https://us.i.posthog.com`,person_profiles:`identified_only`,autocapture:!1,capture_pageview:!1,capture_pageleave:!1,capture_exceptions:{capture_unhandled_errors:!0,capture_unhandled_rejections:!0,capture_console_errors:!1},before_send:zde,get_current_url:()=>`https://overdeck.invalid/`,save_campaign_params:!1,save_referrer:!1,disable_session_recording:!0,disable_surveys:!0}),t.telemetry?.installId&&no.register({install_id:t.telemetry.installId}),t.telemetry?.operatorHash?no.register({operatorHash:t.telemetry.operatorHash}):no.unregister(`operatorHash`),Fde=!0}catch{}}function ro(e,t){Fde&&no.capture(e,t)}function Vde(e,t){let n=Error(`Overdeck ${t.action} operation failed`);return n.name=`OverdeckTelemetryException`,n.stack=void 0,n}function io(e,t){Fde&&no.captureException(Vde(e,t),t)}function Hde(e){return e<=0?`0`:e<=2?`1-2`:e<=5?`3-5`:e<=10?`6-10`:`11+`}var ao=Xt(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Ude=Xt(`Anchor`,[[`path`,{d:`M12 22V8`,key:`qkxhtm`}],[`path`,{d:`M5 12H2a10 10 0 0 0 20 0h-3`,key:`1hv3nh`}],[`circle`,{cx:`12`,cy:`5`,r:`3`,key:`rqqgnr`}]]),oo=Xt(`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`}]]),Wde=Xt(`ArrowLeftRight`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),Gde=Xt(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Kde=Xt(`ArrowRightLeft`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),qde=Xt(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Jde=Xt(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),so=Xt(`BarChart3`,[[`path`,{d:`M3 3v18h18`,key:`1s2lah`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Yde=Xt(`Beaker`,[[`path`,{d:`M4.5 3h15`,key:`c7n0jr`}],[`path`,{d:`M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3`,key:`m1uhx7`}],[`path`,{d:`M6 14h12`,key:`4cwo0f`}]]),Xde=Xt(`BellOff`,[[`path`,{d:`M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5`,key:`o7mx20`}],[`path`,{d:`M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7`,key:`16f1lm`}],[`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`,key:`qgo35s`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Zde=Xt(`Bell`,[[`path`,{d:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9`,key:`1qo2s2`}],[`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`,key:`qgo35s`}]]),Qde=Xt(`BookOpenCheck`,[[`path`,{d:`M8 3H2v15h7c1.7 0 3 1.3 3 3V7c0-2.2-1.8-4-4-4Z`,key:`1i8u0n`}],[`path`,{d:`m16 12 2 2 4-4`,key:`mdajum`}],[`path`,{d:`M22 6V3h-6c-2.2 0-4 1.8-4 4v14c0-1.7 1.3-3 3-3h7v-2.3`,key:`jb5l51`}]]),co=Xt(`BookOpen`,[[`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`,key:`vv98re`}],[`path`,{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`,key:`1cyq3y`}]]),$de=Xt(`BookText`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20`,key:`t4utmx`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}]]),efe=Xt(`Bookmark`,[[`path`,{d:`m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z`,key:`1fy3hk`}]]),lo=Xt(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),uo=Xt(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),tfe=Xt(`Brush`,[[`path`,{d:`m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08`,key:`1styjt`}],[`path`,{d:`M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z`,key:`z0l1mu`}]]),nfe=Xt(`Bug`,[[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M9 7.13v-1a3.003 3.003 0 1 1 6 0v1`,key:`d7y7pr`}],[`path`,{d:`M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6`,key:`xs1cw7`}],[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M6.53 9C4.6 8.8 3 7.1 3 5`,key:`32zzws`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`M3 21c0-2.1 1.7-3.9 3.8-4`,key:`4p0ekp`}],[`path`,{d:`M20.97 5c0 2.1-1.6 3.8-3.5 4`,key:`18gb23`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M17.2 17c2.1.1 3.8 1.9 3.8 4`,key:`k3fwyw`}]]),fo=Xt(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),po=Xt(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),mo=Xt(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ho=Xt(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),rfe=Xt(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ife=Xt(`ChevronsLeft`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),afe=Xt(`ChevronsRight`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),go=Xt(`CircleAlert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),_o=Xt(`CircleCheckBig`,[[`path`,{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`,key:`g774vq`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),vo=Xt(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ofe=Xt(`CircleDot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),yo=Xt(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),sfe=Xt(`CirclePause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),bo=Xt(`CircleStop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,key:`1wrtvo`}]]),cfe=Xt(`CircleUserRound`,[[`path`,{d:`M18 20a6 6 0 0 0-12 0`,key:`1qehca`}],[`circle`,{cx:`12`,cy:`10`,r:`4`,key:`1h16sb`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),xo=Xt(`CircleX`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),So=Xt(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),lfe=Xt(`ClipboardCheck`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),Co=Xt(`ClipboardList`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),wo=Xt(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),To=Xt(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),ufe=Xt(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),dfe=Xt(`Columns2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),Eo=Xt(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Do=Xt(`Container`,[[`path`,{d:`M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z`,key:`1t2lqe`}],[`path`,{d:`M10 21.9V14L2.1 9.1`,key:`o7czzq`}],[`path`,{d:`m10 14 11.9-6.9`,key:`zm5e20`}],[`path`,{d:`M14 19.8v-8.1`,key:`159ecu`}],[`path`,{d:`M18 17.5V9.4`,key:`11uown`}]]),Oo=Xt(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),ko=Xt(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),Ao=Xt(`DollarSign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),jo=Xt(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),ffe=Xt(`DraftingCompass`,[[`circle`,{cx:`12`,cy:`5`,r:`2`,key:`f1ur92`}],[`path`,{d:`m3 21 8.02-14.26`,key:`1ssaw4`}],[`path`,{d:`m12.99 6.74 1.93 3.44`,key:`iwagvd`}],[`path`,{d:`M19 12c-3.87 4-10.13 4-14 0`,key:`1tsu18`}],[`path`,{d:`m21 21-2.16-3.84`,key:`vylbct`}]]),pfe=Xt(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),mfe=Xt(`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`}]]),Mo=Xt(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),hfe=Xt(`EyeOff`,[[`path`,{d:`M9.88 9.88a3 3 0 1 0 4.24 4.24`,key:`1jxqfv`}],[`path`,{d:`M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68`,key:`9wicm4`}],[`path`,{d:`M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61`,key:`1jreej`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),No=Xt(`Eye`,[[`path`,{d:`M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z`,key:`rwhkz3`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),gfe=Xt(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),_fe=Xt(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),Po=Xt(`FileCode`,[[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z`,key:`1mlx9k`}]]),vfe=Xt(`FileCog`,[[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m3.2 12.9-.9-.4`,key:`1i3dj5`}],[`path`,{d:`m3.2 15.1-.9.4`,key:`1fvgj0`}],[`path`,{d:`M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5`,key:`1yo3oz`}],[`path`,{d:`m4.9 11.2-.4-.9`,key:`otmhb9`}],[`path`,{d:`m4.9 16.8-.4.9`,key:`1b8z07`}],[`path`,{d:`m7.5 10.3-.4.9`,key:`11k65u`}],[`path`,{d:`m7.5 17.7-.4-.9`,key:`431x55`}],[`path`,{d:`m9.7 12.5-.9.4`,key:`87sjan`}],[`path`,{d:`m9.7 15.5-.9-.4`,key:`khqm91`}],[`circle`,{cx:`6`,cy:`14`,r:`3`,key:`a1xfv6`}]]),yfe=Xt(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),bfe=Xt(`FileJson`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),xfe=Xt(`FileSearch`,[[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3`,key:`ms7g94`}],[`path`,{d:`m9 18-1.5-1.5`,key:`1j6qii`}],[`circle`,{cx:`5`,cy:`14`,r:`3`,key:`ufru5t`}]]),Fo=Xt(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Sfe=Xt(`FileX`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]),Cfe=Xt(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Io=Xt(`Filter`,[[`polygon`,{points:`22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3`,key:`1yg77f`}]]),Lo=Xt(`Flag`,[[`path`,{d:`M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z`,key:`i9b6wo`}],[`line`,{x1:`4`,x2:`4`,y1:`22`,y2:`15`,key:`1cm3nv`}]]),Ro=Xt(`FlaskConical`,[[`path`,{d:`M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2`,key:`pzvekw`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}],[`path`,{d:`M7 16h10`,key:`wp8him`}]]),wfe=Xt(`FolderClosed`,[[`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`}],[`path`,{d:`M2 10h20`,key:`1ir3d8`}]]),Tfe=Xt(`FolderInput`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),zo=Xt(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Efe=Xt(`FolderPlus`,[[`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`}]]),Bo=Xt(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Vo=Xt(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Ho=Xt(`Gem`,[[`path`,{d:`M6 3h12l4 6-10 13L2 9Z`,key:`1pcd5k`}],[`path`,{d:`M11 3 8 9l4 13 4-13-3-6`,key:`1fcu3u`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),Uo=Xt(`GitBranchPlus`,[[`path`,{d:`M6 3v12`,key:`qpgusn`}],[`path`,{d:`M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`1d02ji`}],[`path`,{d:`M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`chk6ph`}],[`path`,{d:`M15 6a9 9 0 0 0-9 9`,key:`or332x`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),Wo=Xt(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Go=Xt(`GitCommitHorizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),Dfe=Xt(`GitCompare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),Ko=Xt(`GitFork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),qo=Xt(`GitMerge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),Ofe=Xt(`GitPullRequestClosed`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`m21 3-6 6`,key:`16nqsk`}],[`path`,{d:`m21 9-6-6`,key:`9j17rh`}],[`path`,{d:`M18 11.5V15`,key:`65xf6f`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]]),kfe=Xt(`GitPullRequestDraft`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M18 6V5`,key:`1oao2s`}],[`path`,{d:`M18 11v-1`,key:`11c8tz`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),Jo=Xt(`GitPullRequest`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),Afe=Xt(`Github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),Yo=Xt(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),jfe=Xt(`GripVertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Mfe=Xt(`Hammer`,[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]]),Nfe=Xt(`HeartPulse`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}],[`path`,{d:`M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`1uw2ng`}]]),Xo=Xt(`History`,[[`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`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Pfe=Xt(`Hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),Zo=Xt(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),Ffe=Xt(`Infinity`,[[`path`,{d:`M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z`,key:`1z0uae`}]]),Qo=Xt(`Info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Ife=Xt(`KeyRound`,[[`path`,{d:`M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z`,key:`167ctg`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),$o=Xt(`Key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),es=Xt(`Layers`,[[`path`,{d:`m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z`,key:`8b97xw`}],[`path`,{d:`m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65`,key:`dd6zsq`}],[`path`,{d:`m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65`,key:`ep9fru`}]]),Lfe=Xt(`LayoutGrid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Rfe=Xt(`Link2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),zfe=Xt(`ListChecks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),ts=Xt(`ListOrdered`,[[`line`,{x1:`10`,x2:`21`,y1:`6`,y2:`6`,key:`76qw6h`}],[`line`,{x1:`10`,x2:`21`,y1:`12`,y2:`12`,key:`16nom4`}],[`line`,{x1:`10`,x2:`21`,y1:`18`,y2:`18`,key:`u3jurt`}],[`path`,{d:`M4 6h1v4`,key:`cnovpq`}],[`path`,{d:`M4 10h2`,key:`16xx2s`}],[`path`,{d:`M6 18H4c0-1 2-2 2-3s-1-1.5-2-1`,key:`m9a95d`}]]),ns=Xt(`ListTodo`,[[`rect`,{x:`3`,y:`5`,width:`6`,height:`6`,rx:`1`,key:`1defrl`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),Bfe=Xt(`ListTree`,[[`path`,{d:`M21 12h-8`,key:`1bmf0i`}],[`path`,{d:`M21 6H8`,key:`1pqkrb`}],[`path`,{d:`M21 18h-8`,key:`1tm79t`}],[`path`,{d:`M3 6v4c0 1.1.9 2 2 2h3`,key:`1ywdgy`}],[`path`,{d:`M3 10v6c0 1.1.9 2 2 2h3`,key:`2wc746`}]]),rs=Xt(`List`,[[`line`,{x1:`8`,x2:`21`,y1:`6`,y2:`6`,key:`7ey8pc`}],[`line`,{x1:`8`,x2:`21`,y1:`12`,y2:`12`,key:`rjfblc`}],[`line`,{x1:`8`,x2:`21`,y1:`18`,y2:`18`,key:`c3b1m8`}],[`line`,{x1:`3`,x2:`3.01`,y1:`6`,y2:`6`,key:`1g7gq3`}],[`line`,{x1:`3`,x2:`3.01`,y1:`12`,y2:`12`,key:`1pjlvk`}],[`line`,{x1:`3`,x2:`3.01`,y1:`18`,y2:`18`,key:`28t2mc`}]]),is=Xt(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),as=Xt(`Lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Vfe=Xt(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),Hfe=Xt(`MemoryStick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]),Ufe=Xt(`Menu`,[[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}],[`line`,{x1:`4`,x2:`20`,y1:`6`,y2:`6`,key:`1owob3`}],[`line`,{x1:`4`,x2:`20`,y1:`18`,y2:`18`,key:`yk5zj1`}]]),Wfe=Xt(`MessageCircleQuestion`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Gfe=Xt(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Kfe=Xt(`MessageSquarePlus`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}]]),qfe=Xt(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),os=Xt(`MessageSquare`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),Jfe=Xt(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2z`,key:`jj09z8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Yfe=Xt(`MicOff`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M18.89 13.23A7.12 7.12 0 0 0 19 12v-2`,key:`80xlxr`}],[`path`,{d:`M5 10v2a7 7 0 0 0 12 5`,key:`p2k8kg`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),ss=Xt(`Mic`,[[`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`,key:`131961`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),Xfe=Xt(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),cs=Xt(`MonitorSmartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),Zfe=Xt(`Monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Qfe=Xt(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),ls=Xt(`Network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),$fe=Xt(`Package`,[[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),epe=Xt(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),tpe=Xt(`PanelLeftClose`,[[`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`}]]),npe=Xt(`PanelLeftOpen`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),rpe=Xt(`PanelRightClose`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),ipe=Xt(`PanelRightOpen`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),ape=Xt(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),ope=Xt(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),us=Xt(`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`}]]),spe=Xt(`PinOff`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),cpe=Xt(`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`}]]),ds=Xt(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),fs=Xt(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),lpe=Xt(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),upe=Xt(`Rocket`,[[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z`,key:`m3kijz`}],[`path`,{d:`m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z`,key:`1fmvmk`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0`,key:`1f8sc4`}],[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}]]),ps=Xt(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),dpe=Xt(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),fpe=Xt(`Route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),ppe=Xt(`Rows2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]]),mpe=Xt(`Rows3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),hpe=Xt(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),ms=Xt(`Scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]),hs=Xt(`ScrollText`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),gs=Xt(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),gpe=Xt(`SendHorizontal`,[[`path`,{d:`m3 3 3 9-3 9 19-9Z`,key:`1aobqy`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),_pe=Xt(`Send`,[[`path`,{d:`m22 2-7 20-4-9-9-4Z`,key:`1q3vgg`}],[`path`,{d:`M22 2 11 13`,key:`nzbqef`}]]),vpe=Xt(`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`}]]),ype=Xt(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),_s=Xt(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),bpe=Xt(`Share2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),xpe=Xt(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),vs=Xt(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ys=Xt(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Spe=Xt(`ShipWheel`,[[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}],[`path`,{d:`M12 2v7.5`,key:`1e5rl5`}],[`path`,{d:`m19 5-5.23 5.23`,key:`1ezxxf`}],[`path`,{d:`M22 12h-7.5`,key:`le1719`}],[`path`,{d:`m19 19-5.23-5.23`,key:`p3fmgn`}],[`path`,{d:`M12 14.5V22`,key:`dgcmos`}],[`path`,{d:`M10.23 13.77 5 19`,key:`qwopd4`}],[`path`,{d:`M9.5 12H2`,key:`r7bup8`}],[`path`,{d:`M10.23 10.23 5 5`,key:`k2y7lj`}],[`circle`,{cx:`12`,cy:`12`,r:`2.5`,key:`ix0uyj`}]]),Cpe=Xt(`SkipForward`,[[`polygon`,{points:`5 4 15 12 5 20 5 4`,key:`16p6eg`}],[`line`,{x1:`19`,x2:`19`,y1:`5`,y2:`19`,key:`futhcm`}]]),wpe=Xt(`Skull`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`path`,{d:`M8 20v2h8v-2`,key:`ded4og`}],[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M16 20a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20`,key:`xq9p5u`}]]),Tpe=Xt(`SlidersHorizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),Epe=Xt(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Dpe=Xt(`Snowflake`,[[`line`,{x1:`2`,x2:`22`,y1:`12`,y2:`12`,key:`1dnqot`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`m20 16-4-4 4-4`,key:`rquw4f`}],[`path`,{d:`m4 8 4 4-4 4`,key:`12s3z9`}],[`path`,{d:`m16 4-4 4-4-4`,key:`1tumq1`}],[`path`,{d:`m8 20 4-4 4 4`,key:`9p200w`}]]),Ope=Xt(`Space`,[[`path`,{d:`M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1`,key:`lt2kga`}]]),bs=Xt(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),kpe=Xt(`SquareSplitHorizontal`,[[`path`,{d:`M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3`,key:`lubmu8`}],[`path`,{d:`M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3`,key:`1ag34g`}],[`line`,{x1:`12`,x2:`12`,y1:`4`,y2:`20`,key:`1tx1rr`}]]),Ape=Xt(`SquareSplitVertical`,[[`path`,{d:`M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3`,key:`1pi83i`}],[`path`,{d:`M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3`,key:`ido5k7`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),jpe=Xt(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),xs=Xt(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Mpe=Xt(`StarOff`,[[`path`,{d:`M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43`,key:`16m0ql`}],[`path`,{d:`M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91`,key:`1vt8nq`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),Ss=Xt(`Star`,[[`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`,key:`8f66p6`}]]),Npe=Xt(`SunMoon`,[[`path`,{d:`M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4`,key:`1fu5g2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.9 4.9 1.4 1.4`,key:`b9915j`}],[`path`,{d:`m17.7 17.7 1.4 1.4`,key:`qc3ed3`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.3 17.7-1.4 1.4`,key:`5gca6`}],[`path`,{d:`m19.1 4.9-1.4 1.4`,key:`wpu9u6`}]]),Ppe=Xt(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Fpe=Xt(`Tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Cs=Xt(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),Ipe=Xt(`ThumbsUp`,[[`path`,{d:`M7 10v12`,key:`1qc93n`}],[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}]]),Lpe=Xt(`ToggleLeft`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`8`,cy:`12`,r:`2`,key:`1nvbw3`}]]),Rpe=Xt(`ToggleRight`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`16`,cy:`12`,r:`2`,key:`4ma0v8`}]]),ws=Xt(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),zpe=Xt(`TrendingUp`,[[`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`,key:`126l90`}],[`polyline`,{points:`16 7 22 7 22 13`,key:`kwv8wd`}]]),Ts=Xt(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Bpe=Xt(`Undo`,[[`path`,{d:`M3 7v6h6`,key:`1v2h90`}],[`path`,{d:`M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13`,key:`1r6uu6`}]]),Vpe=Xt(`Unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),Hpe=Xt(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Upe=Xt(`Users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`,key:`1da9ce`}]]),Es=Xt(`Volume2`,[[`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`,key:`16drj5`}],[`path`,{d:`M15.54 8.46a5 5 0 0 1 0 7.07`,key:`ltjumu`}],[`path`,{d:`M19.07 4.93a10 10 0 0 1 0 14.14`,key:`1kegas`}]]),Wpe=Xt(`Workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),Gpe=Xt(`WrapText`,[[`line`,{x1:`3`,x2:`21`,y1:`6`,y2:`6`,key:`4m8b97`}],[`path`,{d:`M3 12h15a3 3 0 1 1 0 6h-4`,key:`1cl7v7`}],[`polyline`,{points:`16 16 14 18 16 20`,key:`1jznyi`}],[`line`,{x1:`3`,x2:`10`,y1:`18`,y2:`18`,key:`1h33wv`}]]),Ds=Xt(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]),Os=Xt(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),ks=Xt(`Zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),z=o(),Kpe=(0,L.createContext)(null);function As(){let e=(0,L.useContext)(Kpe);if(!e)throw Error(`useConfirm must be used within DialogProvider`);return e.confirm}function js(){let e=(0,L.useContext)(Kpe);if(!e)throw Error(`useAlert must be used within DialogProvider`);return e.alert}var qpe=0;function Jpe(){let[e,t]=(0,L.useState)(0);return(0,L.useEffect)(()=>(qpe+=1,t(qpe),()=>{--qpe}),[]),e}function Ype({children:e,onDismiss:t}){let n=Jpe(),[r,i]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{requestAnimationFrame(()=>i(!0))},[]),(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,z.jsx)(`div`,{className:`fixed inset-0 bg-black/32 backdrop-blur-sm flex items-center justify-center z-[100]`,onClick:t,style:{"--nested-dialogs":n},children:(0,z.jsx)(`div`,{className:`bg-popover text-popover-foreground rounded-2xl border border-border shadow-lg w-full max-w-md mx-4 transition-all duration-200 ease-in-out ${r?`scale-100 opacity-100`:`scale-[0.98] opacity-0`}`,style:{transform:`scale(${r?`calc(1 - 0.1 * ${n})`:`0.98`})`},onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-modal":`true`,children:e})})}function Xpe({options:e,onConfirm:t,onCancel:n}){let r=(0,L.useRef)(null),i=(0,L.useRef)(null),[a,o]=(0,L.useState)(``),s=e.variant===`destructive`,c=!!e.requiredText,l=!c||a===e.requiredText;return(0,L.useEffect)(()=>{s?r.current?.focus():i.current?.focus()},[s]),(0,z.jsxs)(Ype,{onDismiss:n,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-6 py-4 border-b border-border`,children:[s?(0,z.jsx)(Ts,{className:`w-5 h-5 text-destructive shrink-0`}):(0,z.jsx)(Qo,{className:`w-5 h-5 text-info shrink-0`}),(0,z.jsx)(`h3`,{id:`dialog-title`,className:`text-lg font-semibold text-foreground`,children:e.title})]}),(0,z.jsxs)(`div`,{className:`px-6 py-5 space-y-3`,children:[(0,z.jsx)(`p`,{id:`dialog-message`,className:`text-sm text-foreground whitespace-pre-line select-text cursor-text`,children:e.message}),c?(0,z.jsxs)(`label`,{className:`block text-xs text-muted-foreground`,children:[`Type `,(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.requiredText}),` to confirm`,(0,z.jsx)(`input`,{className:`mt-1 w-full rounded border border-border bg-background px-2 py-1.5 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,value:a,onChange:e=>o(e.target.value),"aria-label":`Confirmation text`,autoFocus:!0})]}):null]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-6 py-4 border-t border-border`,children:[(0,z.jsx)(`button`,{ref:r,onClick:n,className:`px-4 py-2 rounded-lg text-sm bg-secondary text-secondary-foreground hover:bg-secondary/80 transition-colors`,children:e.cancelLabel||`Cancel`}),(0,z.jsx)(`button`,{ref:i,onClick:t,disabled:!l,className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${s?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:e.confirmLabel||`Confirm`})]})]})}function Zpe({options:e,onClose:t}){let n=(0,L.useRef)(null);(0,L.useEffect)(()=>{n.current?.focus()},[]);let r={info:(0,z.jsx)(Qo,{className:`w-5 h-5 text-info shrink-0`}),error:(0,z.jsx)(xo,{className:`w-5 h-5 text-destructive shrink-0`}),success:(0,z.jsx)(_o,{className:`w-5 h-5 text-success shrink-0`})},i=e.variant||`info`;return(0,z.jsxs)(Ype,{onDismiss:t,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-border`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r[i],(0,z.jsx)(`h3`,{id:`alert-title`,className:`text-lg font-semibold text-foreground`,children:e.title||(i===`error`?`Error`:i===`success`?`Success`:`Notice`)})]}),(0,z.jsx)(`button`,{onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,z.jsx)(Os,{className:`w-5 h-5`})})]}),(0,z.jsx)(`div`,{className:`px-6 py-5`,children:(0,z.jsx)(`p`,{id:`alert-message`,className:`text-sm text-foreground whitespace-pre-line select-text cursor-text`,children:e.message})}),(0,z.jsx)(`div`,{className:`flex items-center justify-end px-6 py-4 border-t border-border`,children:(0,z.jsx)(`button`,{ref:n,onClick:t,className:`px-4 py-2 rounded-lg text-sm bg-primary text-primary-foreground hover:bg-primary/90 transition-colors font-medium`,children:`OK`})})]})}function Qpe({children:e}){let[t,n]=(0,L.useState)(null),r=(0,L.useRef)(null),i=(0,L.useCallback)(()=>{r.current&&=(r.current.resolve(!1),null)},[]),a=(0,L.useCallback)(e=>(i(),new Promise(t=>{let i={type:`confirm`,options:e,resolve:t};r.current=i,n(i)})),[i]),o=(0,L.useCallback)(e=>(i(),new Promise(t=>{let i={type:`alert`,options:e,resolve:()=>t()};r.current=i,n(i)})),[i]),s=(0,L.useCallback)(()=>{t?.resolve(!0),r.current=null,n(null)},[t]),c=(0,L.useCallback)(()=>{t?.resolve(!1),r.current=null,n(null)},[t]),l=(0,L.useCallback)(()=>{t?.resolve(!1),r.current=null,n(null)},[t]);return(0,z.jsxs)(Kpe.Provider,{value:{confirm:a,alert:o},children:[e,t?.type===`confirm`&&(0,z.jsx)(Xpe,{options:t.options,onConfirm:s,onCancel:c}),t?.type===`alert`&&(0,z.jsx)(Zpe,{options:t.options,onClose:l})]})}var Ms=n(s(),1),$pe=e=>{switch(e){case`success`:return nme;case`info`:return ime;case`warning`:return rme;case`error`:return ame;default:return null}},eme=Array(12).fill(0),tme=({visible:e,className:t})=>L.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},L.createElement(`div`,{className:`sonner-spinner`},eme.map((e,t)=>L.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),nme=L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},L.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),rme=L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},L.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),ime=L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},L.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),ame=L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},L.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ome=L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},L.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),L.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),sme=()=>{let[e,t]=L.useState(document.hidden);return L.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},cme=1,Ns=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:cme++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0||e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=e instanceof Promise?e:e(),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],L.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(ume(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description;this.create({id:n,type:`error`,message:r,description:a})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description;this.create({id:n,type:`success`,message:r,description:a})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description;this.create({id:n,type:`error`,message:r,description:a})}}).finally(()=>{var e;i&&(this.dismiss(n),n=void 0),(e=t.finally)==null||e.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||cme++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},lme=(e,t)=>{let n=t?.id||cme++;return Ns.addToast({title:e,...t,id:n}),n},ume=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,B=Object.assign(lme,{success:Ns.success,info:Ns.info,warning:Ns.warning,error:Ns.error,custom:Ns.custom,message:Ns.message,promise:Ns.promise,dismiss:Ns.dismiss,loading:Ns.loading},{getHistory:()=>Ns.toasts,getToasts:()=>Ns.getActiveToasts()});function dme(e,{insertAt:t}={}){if(!e||typeof document>`u`)return;let n=document.head||document.getElementsByTagName(`head`)[0],r=document.createElement(`style`);r.type=`text/css`,t===`top`&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}dme(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
4
4
  `);function Ps(e){return e.label!==void 0}var fme=3,pme=`32px`,mme=`16px`,hme=4e3,gme=356,_me=14,vme=20,yme=200;function Fs(...e){return e.filter(Boolean).join(` `)}function bme(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var xme=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,loadingIcon:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`,pauseWhenPageIsHidden:D}=e,[O,k]=L.useState(null),[A,j]=L.useState(null),[ee,M]=L.useState(!1),[N,P]=L.useState(!1),[te,ne]=L.useState(!1),[re,ie]=L.useState(!1),[ae,oe]=L.useState(!1),[se,ce]=L.useState(0),[le,ue]=L.useState(0),de=L.useRef(n.duration||y||hme),fe=L.useRef(null),pe=L.useRef(null),me=c===0,he=c+1<=o,ge=n.type,_e=n.dismissible!==!1,ve=n.className||``,ye=n.descriptionClassName||``,be=L.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),xe=L.useMemo(()=>n.closeButton??p,[n.closeButton,p]),Se=L.useMemo(()=>n.duration||y||hme,[n.duration,y]),Ce=L.useRef(0),we=L.useRef(0),Te=L.useRef(0),Ee=L.useRef(null),[De,Oe]=b.split(`-`),ke=L.useMemo(()=>s.reduce((e,t,n)=>n>=be?e:e+t.height,0),[s,be]),Ae=sme(),je=n.invert||t,Me=ge===`loading`;we.current=L.useMemo(()=>be*x+ke,[be,ke]),L.useEffect(()=>{de.current=Se},[Se]),L.useEffect(()=>{M(!0)},[]),L.useEffect(()=>{let e=pe.current;if(e){let t=e.getBoundingClientRect().height;return ue(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),L.useLayoutEffect(()=>{if(!ee)return;let e=pe.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ue(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[ee,n.title,n.description,a,n.id]);let Ne=L.useCallback(()=>{P(!0),ce(we.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},yme)},[n,d,a,we]);L.useEffect(()=>{if(n.promise&&ge===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||D&&Ae?(()=>{if(Te.current<Ce.current){let e=new Date().getTime()-Ce.current;de.current-=e}Te.current=new Date().getTime()})():de.current!==1/0&&(Ce.current=new Date().getTime(),e=setTimeout(()=>{var e;(e=n.onAutoClose)==null||e.call(n,n),Ne()},de.current)),()=>clearTimeout(e)},[u,i,n,ge,D,Ae,Ne]),L.useEffect(()=>{n.delete&&Ne()},[Ne,n.delete]);function Pe(){return T!=null&&T.loading?L.createElement(`div`,{className:Fs(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":ge===`loading`},T.loading):S?L.createElement(`div`,{className:Fs(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":ge===`loading`},S):L.createElement(tme,{className:Fs(w?.loader,n?.classNames?.loader),visible:ge===`loading`})}return L.createElement(`li`,{tabIndex:0,ref:pe,className:Fs(_,ve,w?.toast,n?.classNames?.toast,w?.default,w?.[ge],n?.classNames?.[ge]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":ee,"data-promise":!!n.promise,"data-swiped":ae,"data-removed":N,"data-visible":he,"data-y-position":De,"data-x-position":Oe,"data-index":c,"data-front":me,"data-swiping":te,"data-dismissible":_e,"data-type":ge,"data-invert":je,"data-swipe-out":re,"data-swipe-direction":A,"data-expanded":!!(u||C&&ee),style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${N?se:we.current}px`,"--initial-height":C?`auto`:`${le}px`,...m,...n.style},onDragEnd:()=>{ne(!1),k(null),Ee.current=null},onPointerDown:e=>{Me||!_e||(fe.current=new Date,ce(we.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(ne(!0),Ee.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e;if(re||!_e)return;Ee.current=null;let t=Number(pe.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),r=Number(pe.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),i=new Date().getTime()-fe.current?.getTime(),a=O===`x`?t:r,o=Math.abs(a)/i;if(Math.abs(a)>=vme||o>.11){ce(we.current),(e=n.onDismiss)==null||e.call(n,n),j(O===`x`?t>0?`right`:`left`:r>0?`down`:`up`),Ne(),ie(!0),oe(!1);return}ne(!1),k(null)},onPointerMove:t=>{var n,r;if(!Ee.current||!_e||window.getSelection()?.toString().length>0)return;let i=t.clientY-Ee.current.y,a=t.clientX-Ee.current.x,o=e.swipeDirections??bme(b);!O&&(Math.abs(a)>1||Math.abs(i)>1)&&k(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0};O===`y`?(o.includes(`top`)||o.includes(`bottom`))&&(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)&&(s.y=i):O===`x`&&(o.includes(`left`)||o.includes(`right`))&&(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)&&(s.x=a),(Math.abs(s.x)>0||Math.abs(s.y)>0)&&oe(!0),(n=pe.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=pe.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},xe&&!n.jsx?L.createElement(`button`,{"aria-label":E,"data-disabled":Me,"data-close-button":!0,onClick:Me||!_e?()=>{}:()=>{var e;Ne(),(e=n.onDismiss)==null||e.call(n,n)},className:Fs(w?.closeButton,n?.classNames?.closeButton)},T?.close??ome):null,n.jsx||(0,L.isValidElement)(n.title)?n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title:L.createElement(L.Fragment,null,ge||n.icon||n.promise?L.createElement(`div`,{"data-icon":``,className:Fs(w?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Pe():null,n.type===`loading`?null:n.icon||T?.[ge]||$pe(ge)):null,L.createElement(`div`,{"data-content":``,className:Fs(w?.content,n?.classNames?.content)},L.createElement(`div`,{"data-title":``,className:Fs(w?.title,n?.classNames?.title)},typeof n.title==`function`?n.title():n.title),n.description?L.createElement(`div`,{"data-description":``,className:Fs(v,ye,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),(0,L.isValidElement)(n.cancel)?n.cancel:n.cancel&&Ps(n.cancel)?L.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{var t,r;Ps(n.cancel)&&_e&&((r=(t=n.cancel).onClick)==null||r.call(t,e),Ne())},className:Fs(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,(0,L.isValidElement)(n.action)?n.action:n.action&&Ps(n.action)?L.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{var t,r;Ps(n.action)&&((r=(t=n.action).onClick)==null||r.call(t,e),!e.defaultPrevented&&Ne())},className:Fs(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null))};function Sme(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function Cme(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?mme:pme;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var wme=(0,L.forwardRef)(function(e,t){let{invert:n,position:r=`bottom-right`,hotkey:i=[`altKey`,`KeyT`],expand:a,closeButton:o,className:s,offset:c,mobileOffset:l,theme:u=`light`,richColors:d,duration:f,style:p,visibleToasts:m=fme,toastOptions:h,dir:g=Sme(),gap:_=_me,loadingIcon:v,icons:y,containerAriaLabel:b=`Notifications`,pauseWhenPageIsHidden:x}=e,[S,C]=L.useState([]),w=L.useMemo(()=>Array.from(new Set([r].concat(S.filter(e=>e.position).map(e=>e.position)))),[S,r]),[T,E]=L.useState([]),[D,O]=L.useState(!1),[k,A]=L.useState(!1),[j,ee]=L.useState(u===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:u),M=L.useRef(null),N=i.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),P=L.useRef(null),te=L.useRef(!1),ne=L.useCallback(e=>{C(t=>{var n;return(n=t.find(t=>t.id===e.id))!=null&&n.delete||Ns.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return L.useEffect(()=>Ns.subscribe(e=>{if(e.dismiss){C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t));return}setTimeout(()=>{Ms.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),L.useEffect(()=>{if(u!==`system`){ee(u);return}if(u===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?ee(`dark`):ee(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{ee(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{ee(e?`dark`:`light`)}catch(e){console.error(e)}})}},[u]),L.useEffect(()=>{S.length<=1&&O(!1)},[S]),L.useEffect(()=>{let e=e=>{var t,n;i.every(t=>e[t]||e.code===t)&&(O(!0),(t=M.current)==null||t.focus()),e.code===`Escape`&&(document.activeElement===M.current||(n=M.current)!=null&&n.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),L.useEffect(()=>{if(M.current)return()=>{P.current&&(P.current.focus({preventScroll:!0}),P.current=null,te.current=!1)}},[M.current]),L.createElement(`section`,{ref:t,"aria-label":`${b} ${N}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,r)=>{let[i,u]=t.split(`-`);return S.length?L.createElement(`ol`,{key:t,dir:g===`auto`?Sme():g,tabIndex:-1,ref:M,className:s,"data-sonner-toaster":!0,"data-theme":j,"data-y-position":i,"data-lifted":D&&S.length>1&&!a,"data-x-position":u,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${gme}px`,"--gap":`${_}px`,...p,...Cme(c,l)},onBlur:e=>{te.current&&!e.currentTarget.contains(e.relatedTarget)&&(te.current=!1,P.current&&=(P.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||te.current||(te.current=!0,P.current=e.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{k||O(!1)},onDragEnd:()=>O(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},S.filter(e=>!e.position&&r===0||e.position===t).map((r,i)=>L.createElement(xme,{key:r.id,icons:y,index:i,toast:r,defaultRichColors:d,duration:h?.duration??f,className:h?.className,descriptionClassName:h?.descriptionClassName,invert:n,visibleToasts:m,closeButton:h?.closeButton??o,interacting:k,position:t,style:h?.style,unstyled:h?.unstyled,classNames:h?.classNames,cancelButtonStyle:h?.cancelButtonStyle,actionButtonStyle:h?.actionButtonStyle,removeToast:ne,toasts:S.filter(e=>e.position==r.position),heights:T.filter(e=>e.position==r.position),setHeights:E,expandByDefault:a,gap:_,loadingIcon:v,expanded:D,pauseWhenPageIsHidden:x,swipeDirections:e.swipeDirections}))):null}))});function Is(e,t={}){let{timeoutMs:n=2e4,signal:r,...i}=t,a=AbortSignal.timeout(n);return fetch(e,{...i,signal:r?AbortSignal.any([r,a]):a})}var Tme={[Symbol.iterator](){return Eme}},Eme={next(){return{done:!0,value:void 0}}},Dme=()=>Tme,Ome=Kt(2,(e,t)=>Object.hasOwn(e,t)),kme=e=>Object.keys(e),Ame=e=>Kt(2,(t,n)=>{for(let r of kme(t))if(!Ome(n,r)||!e(t[r],n[r]))return!1;return!0}),jme=e=>{let t=Ame(e);return(e,n)=>t(e,n)&&t(n,e)},Ls=new WeakMap,Mme=`~effect/data/Redacted`,Nme=e=>Yt(e,Mme),Pme=(e,t)=>{let n=Object.create(Fme);return t?.label&&(n.label=t.label),Ls.set(n,e),n},Fme={[Mme]:{_A:e=>e},label:void 0,...oee,toJSON(){return this.toString()},toString(){return`<redacted${kte(this.label)?`:`+this.label:``}>`},[gee](){return Ete(Ls.get(this))},[mte](e){return Nme(e)&&Nte(Ls.get(this),Ls.get(e))}},Ime=P,Lme=A,Rme=Ye,zme=h,Bme=ate,Vme=ete,Hme=`~effect/FiberSet`,Ume=e=>Yt(e,Hme),Wme={[Hme]:Hme,[Symbol.iterator](){return this.state._tag===`Closed`?Dme():this.state.backing[Symbol.iterator]()},...oee,toJSON(){return{_id:`FiberMap`,state:this.state}}},Gme=(e,t)=>{let n=Object.create(Wme);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},Kme=()=>tt(ie(()=>Gme(new Set,fte())),e=>$e(()=>{let t=e.state;if(t._tag===`Closed`)return Ct;e.state={_tag:`Closed`};let n=t.backing;return Rme(n).pipe(Ste(e.deferred))})),qme=-1,Jme=et(ze($te,We(qme))),Yme=Kt(e=>Ume(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(qme);return}e.state.backing.has(t)||(e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),rne(r)&&(n?.propagateInterruption===!0?!Jme(r.cause):!T(r.cause))&&Bt(e.deferred,r))}))}),Xme=function(){let e;return()=>(e===void 0&&(e=Qte(hte)),e)}(),Zme=e=>()=>an(kt(),t=>{let n=pt(t);return(t,r)=>{if(e.state._tag===`Closed`)return Xme();let i=n(t,r);return Yme(e,i),i}}),Qme=e=>Mee(e.deferred),$me=`~effect/ManagedRuntime`,ehe=(e,t)=>{let n=t?.memoMap??l(),r=lte(`parallel`),i=Ate(r,`sequential`),a={onFiberStart:Bme(r)},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,s,c=le(t=>(s||=Qte(ye(cee(e,n,i),e=>ie(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),Te(Ime(s)))),u={[$me]:$me,memoMap:n,scope:r,contextEffect:c,cachedContext:void 0,context(){return u.cachedContext===void 0?w(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return w(u.disposeEffect)},disposeEffect:$e(()=>(u.contextEffect=Pt(`ManagedRuntime disposed`),u.cachedContext=void 0,yte(u.scope,Cee))),runFork(e,t){return u.cachedContext===void 0?Qte(Rs(u,e),o(t)):pt(u.cachedContext)(e,o(t))},runCallback(e,t){return u.cachedContext===void 0?nne(Rs(u,e),o(t)):See(u.cachedContext)(e,o(t))},runSyncExit(e){return u.cachedContext===void 0?Je(Rs(u,e)):ite(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?k(Rs(u,e)):m(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?qte(Rs(u,e),o(t)):vt(u.cachedContext)(e,o(t))},runPromise(e,t){return u.cachedContext===void 0?w(Rs(u,e),o(t)):N(u.cachedContext)(e,o(t))}};return u};function Rs(e,t){return en(e.contextEffect,e=>Ht(t,e))}var the=Symbol.for(`~effect/http/Headers`),zs=Object.create(null);Object.defineProperties(zs,{[the]:{value:the},[u]:{value(e){return she(this,b(e,che))}},toJSON:{value(){return it(this)}},[mte]:{value(e){return rhe(this,e)}},[gee]:{value(){return Yee(this)}},toString:{value:ree.toString},[lee]:{value:ree[lee]}});var nhe=e=>Object.assign(Object.create(zs),e),rhe=jme(Pee()),ihe=Object.create(zs),ahe=e=>{if(e===void 0)return ihe;if(Symbol.iterator in e){let t=Object.create(zs);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(zs);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},ohe=Kt(2,(e,t)=>{let n=nhe(e);return Object.assign(n,t),n}),she=Kt(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=Pme(e[r]))}else for(let r in e)t.test(r)&&(n[r]=Pme(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),che=be(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),lhe=`~effect/http/HttpClientError`,uhe=class e extends Vt(lhe)({_tag:Xe(`HttpError`),kind:mee([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:j(Ut)}){static fromHttpClientError(t){return new e({_tag:`HttpError`,kind:t.reason._tag,cause:t.reason})}},dhe=`~effect/socket/Socket`,fhe=Pe(`effect/socket/Socket`),phe=e=>fhe.of({[dhe]:dhe,runRaw:e.runRaw,run:e.run??((t,n)=>e.runRaw(e=>typeof e==`string`?t(mhe.encode(e)):e instanceof Uint8Array?t(e):t(new Uint8Array(e)),n)),runString:e.runString??(e.run?(t,n)=>e.run(e=>t(hhe.decode(e)),n):(t,n)=>e.runRaw(e=>typeof e==`string`?t(e):e instanceof Uint8Array?t(hhe.decode(e)):t(hhe.decode(new Uint8Array(e))),n)),writer:e.writer}),mhe=new TextEncoder,hhe=new TextDecoder,ghe=`~effect/socket/Socket/CloseEvent`,_he=e=>Yt(e,ghe),Bs=`~effect/socket/Socket/SocketError`,vhe=e=>Yt(e,Bs),yhe=class extends Vt(`effect/socket/Socket/SocketReadError`)({_tag:Xe(`SocketReadError`),cause:Ut}){message=`An error occurred during Read`},bhe=class extends Vt(`effect/socket/Socket/SocketWriteError`)({_tag:Xe(`SocketWriteError`),cause:Ut}){message=`An error occurred during Write`},Vs=class extends Vt(`effect/socket/Socket/SocketOpenError`)({_tag:Xe(`SocketOpenError`),kind:mee([`Unknown`,`Timeout`]),cause:Ut}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},Hs=class extends Vt(`effect/socket/Socket/SocketCloseError`)({_tag:Xe(`SocketCloseError`),code:wee,closeReason:j(cn)}){static filterClean(e){return function(t){return Us.is(t)&&t.reason._tag===`SocketCloseError`&&e(t.reason.code)?ue(t.reason):eee(t)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},xhe=E([yhe,bhe,Vs,Hs]),Us=class extends ht(Bs)(`SocketError`,{_tag:Xe(`SocketError`),reason:xhe}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[Bs]=Bs;static is(e){return vhe(e)}message=this.reason.message},She=e=>!0,Che=class extends Pe()(`~effect/socket/Socket/WebSocket`){},whe=class extends Pe()(`@effect/platform/Socket/WebSocketConstructor`){},The=gte(whe)((e,t)=>new globalThis.WebSocket(e,t)),Ehe=(e,t)=>whe.use(n=>Dhe(tt((typeof e==`string`?Ue(e):e).pipe(an(e=>n(e,t?.protocols))),e=>ie(()=>e.close(1e3))),t)),Dhe=(e,t)=>le(n=>{let r,i=Vme(!1),a=n.context,o=t?.closeCodeIsError??She,s=(n,s)=>$ee(It(function*(a){let c=yield*Kme().pipe(Rte(a)),l=yield*Rte(e,a),u=yield*Uee(Zme(c)(),Che,l),d=!1;function f(e){if(e.data instanceof Blob){let t=en(dte(()=>e.data.arrayBuffer()),e=>{let t=n(new Uint8Array(e));return Xee(t)?t:Ct});return u(t)}let t=n(e.data);Xee(t)&&u(t)}function p(e){l.removeEventListener(`message`,f),l.removeEventListener(`close`,m),Bt(c.deferred,Ae(new Us({reason:d?new yhe({cause:e}):new Vs({kind:`Unknown`,cause:e})})))}function m(e){let t=typeof e.code==`number`?e.code:1001;l.removeEventListener(`message`,f),l.removeEventListener(`error`,p),Bt(c.deferred,Ae(new Us({reason:new Hs({code:t,closeReason:e.reason})})))}if(l.addEventListener(`close`,m,{once:!0}),l.addEventListener(`error`,p,{once:!0}),l.addEventListener(`message`,f),l.readyState!==1){let e=fte();l.addEventListener(`open`,()=>{d=!0,Bt(e,Ct)},{once:!0}),yield*Mee(e).pipe(y({duration:t?.openTimeout??1e4,orElse:()=>Ae(new Us({reason:new Vs({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))}),fee(Qme(c)))}return d=!0,r=l,i.openUnsafe(),s?.onOpen&&(yield*s.onOpen),yield*x(Qme(c),Hs.filterClean(e=>!o(e)),()=>Ct)})).pipe(Dt(e=>he(a,e)),de(ie(()=>{i.closeUnsafe(),r=void 0}))),c=Ue(e=>i.whenOpen(ie(()=>{let t=r;_he(e)?t.close(e.code,e.reason):t.send(e)})));return Ue(phe({runRaw:s,writer:c}))}),Ohe=Ite(Ehe,rt(fhe)),khe=class extends Pe()(`effect/workers/Transferable/Collector`){},Ahe=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return khe.of({addAllUnsafe:t,addAll:e=>ie(()=>t(e)),readUnsafe:n,read:ie(n),clearUnsafe:r,clear:ie(r)})},jhe=E([class extends Vt(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:Xe(`WorkerSpawnError`),message:cn,cause:j(Ut)}){},class extends Vt(`effect/workers/WorkerError/WorkerSendError`)({_tag:Xe(`WorkerSendError`),message:cn,cause:j(Ut)}){},class extends Vt(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:Xe(`WorkerReceiveError`),message:cn,cause:j(Ut)}){},class extends Vt(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:Xe(`WorkerUnknownError`),message:cn,cause:j(Ut)}){}]),Mhe=`~effect/rpc/RpcClientError`,Nhe=class extends Vt(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:Xe(`RpcClientDefect`),message:cn,cause:Ut}){},Phe=class extends Vt(Mhe)({_tag:Xe(`RpcClientError`),reason:E([jhe,xhe,uhe,Nhe])}){[Mhe]=Mhe;get message(){return`${this.reason._tag}: ${this.reason.message}`}},Ws=e=>typeof e==`bigint`?e:BigInt(e),Fhe={_tag:`Ping`},Ihe;try{Ihe=new TextDecoder}catch{}var Gs,Ks,qs=0,Lhe=[],Rhe=Lhe,zhe=0,Js={},Ys,Xs,Zs=0,Qs=0,$s,ec,tc=[],nc,Bhe={useRecords:!1,mapsAsObjects:!0},Vhe=class{},Hhe=new Vhe;Hhe.name=`MessagePack 0xC1`;var rc=!1,Uhe=2,Whe=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(Gs)return mge(()=>(hge(),this?this.unpack(t,n):e.prototype.unpack.call(Bhe,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(Ks=n.end||t.length,qs=n.start||0):(qs=0,Ks=n>-1?n:t.length),zhe=0,Qs=0,Xs=null,Rhe=Lhe,$s=null,Gs=t;try{nc=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){throw Gs=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(Js=this,this.structures)return Ys=this.structures,ic(n);(!Ys||Ys.length>0)&&(Ys=[])}else Js=Bhe,(!Ys||Ys.length>0)&&(Ys=[]);return ic(n)}unpackMultiple(e,t){let n,r=0;try{rc=!0;let i=e.length,a=this?this.unpack(e,i):uc.unpack(e,i);if(t){if(t(a,r,qs)===!1)return;for(;qs<i;)if(r=qs,t(ic(),r,qs)===!1)return}else{for(n=[a];qs<i;)r=qs,n.push(ic());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{rc=!1,hge()}}_mergeStructures(e,t){this._onLoadedStructures&&(e=this._onLoadedStructures(e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function ic(e){try{if(!Js.trusted&&!rc){let e=Ys.sharedLength||0;e<Ys.length&&(Ys.length=e)}let t;if(Js._readStruct&&Gs[qs]<64&&Gs[qs]>=32?(t=Js._readStruct(Gs,qs,Ks),Gs=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),qs=Ks):t=ac(),$s&&=(qs=$s.postBundlePosition,null),rc&&(Ys.restoreStructures=null),qs==Ks)Ys&&Ys.restoreStructures&&Ghe(),Ys=null,Gs=null,ec&&=null;else if(qs>Ks)throw Error(`Unexpected end of MessagePack data`);else if(!rc){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw Ys&&Ys.restoreStructures&&Ghe(),hge(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||qs>Ks)&&(e.incomplete=!0),e}}function Ghe(){for(let e in Ys.restoreStructures)Ys[e]=Ys.restoreStructures[e];Ys.restoreStructures=null}function ac(){let e=Gs[qs++];if(e<160){if(e<128){if(e<64)return e;{let t=Ys[e&63]||Js.getStructures&&Yhe()[e&63];return t?(t.read||=qhe(t,e&63),t.read()):e}}if(e<144){if(e-=128,Js.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=sge();e===`__proto__`&&(e=`__proto_`),t[e]=ac()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(ac(),ac());return t}}{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=ac();return Js.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(Qs>=qs)return Xs.slice(qs-Zs,(qs+=t)-Zs);if(Qs==0&&Ks<140){let e=t<16?cc(t):rge(t);if(e!=null)return e}return Xhe(t)}{let t;switch(e){case 192:return null;case 193:return $s?(t=ac(),t>0?$s[1].slice($s.position1,$s.position1+=t):$s[0].slice($s.position0,$s.position0-=t)):Hhe;case 194:return!1;case 195:return!0;case 196:if(t=Gs[qs++],t===void 0)throw Error(`Unexpected end of buffer`);return age(t);case 197:return t=nc.getUint16(qs),qs+=2,age(t);case 198:return t=nc.getUint32(qs),qs+=4,age(t);case 199:return lc(Gs[qs++]);case 200:return t=nc.getUint16(qs),qs+=2,lc(t);case 201:return t=nc.getUint32(qs),qs+=4,lc(t);case 202:if(t=nc.getFloat32(qs),Js.useFloat32>2){let e=gge[(Gs[qs]&127)<<1|Gs[qs+1]>>7];return qs+=4,(e*t+(t>0?.5:-.5)>>0)/e}return qs+=4,t;case 203:return t=nc.getFloat64(qs),qs+=8,t;case 204:return Gs[qs++];case 205:return t=nc.getUint16(qs),qs+=2,t;case 206:return t=nc.getUint32(qs),qs+=4,t;case 207:return Js.int64AsType===`number`?(t=nc.getUint32(qs)*4294967296,t+=nc.getUint32(qs+4)):Js.int64AsType===`string`?t=nc.getBigUint64(qs).toString():Js.int64AsType===`auto`?(t=nc.getBigUint64(qs),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=nc.getBigUint64(qs),qs+=8,t;case 208:return nc.getInt8(qs++);case 209:return t=nc.getInt16(qs),qs+=2,t;case 210:return t=nc.getInt32(qs),qs+=4,t;case 211:return Js.int64AsType===`number`?(t=nc.getInt32(qs)*4294967296,t+=nc.getUint32(qs+4)):Js.int64AsType===`string`?t=nc.getBigInt64(qs).toString():Js.int64AsType===`auto`?(t=nc.getBigInt64(qs),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=nc.getBigInt64(qs),qs+=8,t;case 212:if(t=Gs[qs++],t==114)return lge(Gs[qs++]&63);{let e=tc[t];if(e)return e.read?(qs++,e.read(ac())):e.noBuffer?(qs++,e()):e(Gs.subarray(qs,++qs));throw Error(`Unknown extension `+t)}case 213:return t=Gs[qs],t==114?(qs++,lge(Gs[qs++]&63,Gs[qs++])):lc(2);case 214:return lc(4);case 215:return lc(8);case 216:return lc(16);case 217:return t=Gs[qs++],Qs>=qs?Xs.slice(qs-Zs,(qs+=t)-Zs):Zhe(t);case 218:return t=nc.getUint16(qs),qs+=2,Qs>=qs?Xs.slice(qs-Zs,(qs+=t)-Zs):Qhe(t);case 219:return t=nc.getUint32(qs),qs+=4,Qs>=qs?Xs.slice(qs-Zs,(qs+=t)-Zs):$he(t);case 220:return t=nc.getUint16(qs),qs+=2,tge(t);case 221:return t=nc.getUint32(qs),qs+=4,tge(t);case 222:return t=nc.getUint16(qs),qs+=2,nge(t);case 223:return t=nc.getUint32(qs),qs+=4,nge(t);default:if(e>=224)return e-256;throw e===void 0?ege():Error(`Unknown MessagePack token `+e)}}}var Khe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function qhe(e,t){function n(){if(n.count++>Uhe){let r;try{r=e.read=Function(`r`,`return function(){return `+(Js.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:Khe.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(ac)}catch{return Uhe=1/0,n()}return e.read0=r,e.highByte===0&&(e.read=Jhe(t,e.read)),r()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=ac()}return Js.freezeData?Object.freeze(r):r}return n.count=0,e.read0=n,e.highByte===0?Jhe(t,n):n}var Jhe=(e,t)=>function(){let n=Gs[qs++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=Ys[r]||Yhe()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=qhe(i,e),i.read()};function Yhe(){let e=mge(()=>(Gs=null,Js.getStructures()));return Ys=Js._mergeStructures(e,Ys)}var Xhe=oc,Zhe=oc,Qhe=oc,$he=oc;function oc(e){let t;if(e<16&&(t=cc(e)))return t;if(e>64&&Ihe)return Ihe.decode(Gs.subarray(qs,qs+=e));let n=qs+e,r=[];for(t=``;qs<n;){let e=Gs[qs++];if(!(e&128))r.push(e);else if((e&224)==192){if(e<194||qs>=n||(Gs[qs]&192)!=128)r.push(65533);else{let t=Gs[qs++]&63;r.push((e&31)<<6|t)}}else if((e&240)==224){let t=qs<n?Gs[qs]:0;if(qs>=n||(t&192)!=128||e===224&&t<160||e===237&&t>=160)r.push(65533);else if(qs++,qs>=n||(Gs[qs]&192)!=128)r.push(65533);else{let n=Gs[qs++]&63;r.push((e&31)<<12|(t&63)<<6|n)}}else if((e&248)==240){let t=qs<n?Gs[qs]:0;if(e>244||qs>=n||(t&192)!=128||e===240&&t<144||e===244&&t>=144)r.push(65533);else if(qs++,qs>=n||(Gs[qs]&192)!=128)r.push(65533);else{let i=Gs[qs++]&63;if(qs>=n||(Gs[qs]&192)!=128)r.push(65533);else{let n=Gs[qs++]&63,a=(e&7)<<18|(t&63)<<12|i<<6|n;a-=65536,r.push(a>>>10&1023|55296),r.push(56320|a&1023)}}}else r.push(65533);r.length>=4096&&(t+=sc.apply(String,r),r.length=0)}return r.length>0&&(t+=sc.apply(String,r)),t}function ege(){let e=Error(`Unexpected end of MessagePack data`);return e.incomplete=!0,e}function tge(e){if(e>Ks-qs)throw ege();let t=Array(e);for(let n=0;n<e;n++)t[n]=ac();return Js.freezeData?Object.freeze(t):t}function nge(e){if(e>(Ks-qs)/2)throw ege();if(Js.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=sge();e===`__proto__`&&(e=`__proto_`),t[e]=ac()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(ac(),ac());return t}}var sc=String.fromCharCode;function rge(e){let t=qs,n=Array(e);for(let r=0;r<e;r++){let e=Gs[qs++];if((e&128)>0){qs=t;return}n[r]=e}return sc.apply(String,n)}function cc(e){if(e<4){if(e<2){if(e===0)return``;{let e=Gs[qs++];if((e&128)>1){--qs;return}return sc(e)}}{let t=Gs[qs++],n=Gs[qs++];if((t&128)>0||(n&128)>0){qs-=2;return}if(e<3)return sc(t,n);let r=Gs[qs++];if((r&128)>0){qs-=3;return}return sc(t,n,r)}}{let t=Gs[qs++],n=Gs[qs++],r=Gs[qs++],i=Gs[qs++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){qs-=4;return}if(e<6){if(e===4)return sc(t,n,r,i);{let e=Gs[qs++];if((e&128)>0){qs-=5;return}return sc(t,n,r,i,e)}}if(e<8){let a=Gs[qs++],o=Gs[qs++];if((a&128)>0||(o&128)>0){qs-=6;return}if(e<7)return sc(t,n,r,i,a,o);let s=Gs[qs++];if((s&128)>0){qs-=7;return}return sc(t,n,r,i,a,o,s)}{let a=Gs[qs++],o=Gs[qs++],s=Gs[qs++],c=Gs[qs++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){qs-=8;return}if(e<10){if(e===8)return sc(t,n,r,i,a,o,s,c);{let e=Gs[qs++];if((e&128)>0){qs-=9;return}return sc(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=Gs[qs++],u=Gs[qs++];if((l&128)>0||(u&128)>0){qs-=10;return}if(e<11)return sc(t,n,r,i,a,o,s,c,l,u);let d=Gs[qs++];if((d&128)>0){qs-=11;return}return sc(t,n,r,i,a,o,s,c,l,u,d)}{let l=Gs[qs++],u=Gs[qs++],d=Gs[qs++],f=Gs[qs++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){qs-=12;return}if(e<14){if(e===12)return sc(t,n,r,i,a,o,s,c,l,u,d,f);{let e=Gs[qs++];if((e&128)>0){qs-=13;return}return sc(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=Gs[qs++],m=Gs[qs++];if((p&128)>0||(m&128)>0){qs-=14;return}if(e<15)return sc(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=Gs[qs++];if((h&128)>0){qs-=15;return}return sc(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function ige(){let e=Gs[qs++],t;if(e<192)t=e-160;else switch(e){case 217:t=Gs[qs++];break;case 218:t=nc.getUint16(qs),qs+=2;break;case 219:t=nc.getUint32(qs),qs+=4;break;default:throw Error(`Expected string`)}return oc(t)}function age(e){return Js.copyBuffers?Uint8Array.prototype.slice.call(Gs,qs,qs+=e):Gs.subarray(qs,qs+=e)}function lc(e){let t=Gs[qs++];if(tc[t]){let n;return tc[t](Gs.subarray(qs,n=qs+=e),e=>{qs=e;try{return ac()}finally{qs=n}})}throw Error(`Unknown extension type `+t)}var oge=Array(4096);function sge(){let e=Gs[qs++];if(e>=160&&e<192){if(e-=160,Qs>=qs)return Xs.slice(qs-Zs,(qs+=e)-Zs);if(!(Qs==0&&Ks<180))return Xhe(e)}else return qs--,cge(ac());let t=(e<<5^(e>1?nc.getUint16(qs):e>0?Gs[qs]:0))&4095,n=oge[t],r=qs,i=qs+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=nc.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=Gs[r++],a!=n[o++]){r=1879048192;break}if(r===i)return qs=r,n.string;i-=3,r=qs}for(n=[],oge[t]=n,n.bytes=e;r<i;)a=nc.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=Gs[r++],n.push(a);let s=e<16?cc(e):rge(e);return s==null?n.string=Xhe(e):n.string=s}function cge(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(Js.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var lge=(e,t)=>{let n=ac().map(cge),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=Ys[e];return i&&(i.isShared||rc)&&((Ys.restoreStructures||(Ys.restoreStructures=[]))[e]=i),Ys[e]=n,n.read=qhe(n,r),(n.read0||n.read)()};tc[0]=()=>{},tc[0].noBuffer=!0,tc[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=BigInt(64),n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var uge={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};tc[101]=()=>{let e=ac();if(!uge[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return uge[e[0]](e[1],{cause:e[2]})},tc[105]=e=>{if(Js.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=nc.getUint32(qs-4);ec||=new Map;let n=Gs[qs],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&Gs[qs+1]===115?new Set:{};let i={target:r};ec.set(t,i);let a=ac();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},tc[112]=e=>{if(Js.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=nc.getUint32(qs-4),n=ec.get(t);return n.used=!0,n.target},tc[115]=()=>new Set(ac());var dge=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),fge=typeof globalThis==`object`?globalThis:window;tc[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=dge[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new fge[r](n)},tc[120]=()=>{let e=ac();return new RegExp(e[0],e[1])};var pge=[];tc[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=qs;return qs+=t-e.length,$s=pge,$s=[ige(),ige()],$s.position0=0,$s.position1=0,$s.postBundlePosition=qs,qs=n,ac()},tc[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function mge(e){Js&&Js._onSaveState&&Js._onSaveState();let t=Ks,n=qs,r=zhe,i=Zs,a=Qs,o=Xs,s=Rhe,c=ec,l=$s,u=new Uint8Array(Gs.slice(0,Ks)),d=Ys,f=Ys.slice(0,Ys.length),p=Js,m=rc,h=e();return Ks=t,qs=n,zhe=r,Zs=i,Qs=a,Xs=o,Rhe=s,ec=c,$s=l,Gs=u,rc=m,Ys=d,Ys.splice(0,Ys.length,...f),Js=p,nc=new DataView(Gs.buffer,Gs.byteOffset,Gs.byteLength),h}function hge(){Gs=null,ec=null,Ys=null}var gge=Array(147);for(let e=0;e<256;e++)gge[e]=+(`1e`+Math.floor(45.15-e*.30103));var uc=new Whe({useRecords:!1});uc.unpack,uc.unpackMultiple,uc.unpack;var _ge={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4),Whe.SUPPORTS_STRUCT_HOOKS=!0;var dc;try{dc=new TextEncoder}catch{}var vge,yge,fc=typeof Buffer<`u`,pc=fc?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,bge=fc?Buffer:Uint8Array,xge=fc?4294967296:2144337920,mc,hc,gc,_c=0,vc,yc=null,Sge=21760,Cge=/[\u0080-\uFFFF]/,bc=Symbol(`record-id`),wge=class extends Whe{constructor(e){super(e),this.offset=0;let t,n,r,i,a=bge.prototype.utf8Write?function(e,t){return mc.utf8Write(e,t,mc.byteLength-t)}:dc&&dc.encodeInto?function(e,t){return dc.encodeInto(e,mc.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],h=0,g=0;this.pack=this.encode=function(e,a){if(mc||(mc=new pc(8192),gc=mc.dataView||(mc.dataView=new DataView(mc.buffer,0,8192)),_c=0),vc=mc.length-10,vc-_c<2048?(mc=new pc(mc.length),gc=mc.dataView||(mc.dataView=new DataView(mc.buffer,0,mc.length)),vc=mc.length-10,_c=0):_c=_c+7&2147483640,t=_c,a&2048&&(_c+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(yc=[],yc.size=1/0):yc=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[bc]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o._writeStruct&&e&&typeof e==`object`?e.constructor===Object?w(e):e.constructor!==Map&&!Array.isArray(e)&&!yge.some(t=>e instanceof t)?w(o.useToJSON!==!1&&e.toJSON?e.toJSON():e):y(e):y(e);let n=yc;if(yc&&Dge(t,y,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(gc.setUint32(n.position+t,gc.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&gc.setUint32(n.position+t,gc.getUint32(n.position+t)+a),_c+=e.length*6,_c>vc&&T(_c),o.offset=_c;let s=Ege(mc.subarray(t,_c),e);return i=null,s}return o.offset=_c,a&512?(mc.start=t,mc.end=_c,mc):mc.subarray(t,_c)}catch(e){throw c=e,e}finally{if(r&&(_(),n&&o.saveStructures)){let n=r.sharedLength||0,i=mc.subarray(t,_c),s=(o._prepareStructures||Oge)(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?(r.uninitialized=!0,o.pack(e,a)):(o.lastNamedStructuresLength=n,mc.length>1073741824&&(mc=null),i)}mc.length>1073741824&&(mc=null),a&1024&&(_c=t)}};let _=()=>{g<10&&g++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),h>1e4)r.transitions=null,g=0,h=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][bc]=0;m=[]}},v=e=>{var t=e.length;t<16?mc[_c++]=144|t:t<65536?(mc[_c++]=220,mc[_c++]=t>>8,mc[_c++]=t&255):(mc[_c++]=221,gc.setUint32(_c,t),_c+=4);for(let n=0;n<t;n++)y(e[n])},y=e=>{_c>vc&&(mc=T(_c));var n=typeof e,r;if(n===`string`){let n=e.length;if(yc&&n>=4&&n<4096){if((yc.size+=n)>Sge){let e,n=(yc[0]?yc[0].length*3+yc[1].length:0)+10;_c+n>vc&&(mc=T(_c+n));let r;yc.position?(r=yc,mc[_c]=200,_c+=3,mc[_c++]=98,e=_c-t,_c+=4,Dge(t,y,0),gc.setUint16(e+t-3,_c-t-e)):(mc[_c++]=214,mc[_c++]=98,e=_c-t,_c+=4),yc=[``,``],yc.previous=r,yc.size=0,yc.position=e}let r=Cge.test(e);yc[+!r]+=e,mc[_c++]=193,y(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(_c+o>vc&&(mc=T(_c+o)),n<64||!a){let t,a,o,s=_c+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?mc[s++]=a:a<2048?(mc[s++]=a>>6|192,mc[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,mc[s++]=a>>18|240,mc[s++]=a>>12&63|128,mc[s++]=a>>6&63|128,mc[s++]=a&63|128):(mc[s++]=a>>12|224,mc[s++]=a>>6&63|128,mc[s++]=a&63|128);r=s-_c-i}else r=a(e,_c+i);r<32?mc[_c++]=160|r:r<256?(i<2&&mc.copyWithin(_c+2,_c+1,_c+1+r),mc[_c++]=217,mc[_c++]=r):r<65536?(i<3&&mc.copyWithin(_c+3,_c+2,_c+2+r),mc[_c++]=218,mc[_c++]=r>>8,mc[_c++]=r&255):(i<5&&mc.copyWithin(_c+5,_c+3,_c+3+r),mc[_c++]=219,gc.setUint32(_c,r),_c+=4),_c+=r}else if(n===`number`){if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this._writeStruct?mc[_c++]=e:e<256?(mc[_c++]=204,mc[_c++]=e):e<65536?(mc[_c++]=205,mc[_c++]=e>>8,mc[_c++]=e&255):(mc[_c++]=206,gc.setUint32(_c,e),_c+=4);else if(e>>0===e)e>=-32?mc[_c++]=256+e:e>=-128?(mc[_c++]=208,mc[_c++]=e+256):e>=-32768?(mc[_c++]=209,gc.setInt16(_c,e),_c+=2):(mc[_c++]=210,gc.setInt32(_c,e),_c+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){mc[_c++]=202,gc.setFloat32(_c,e);let n;if(t<4||(n=e*gge[(mc[_c]&127)<<1|mc[_c+1]>>7])>>0===n){_c+=4;return}_c--}mc[_c++]=203,gc.setFloat64(_c,e),_c+=8}}else if(n===`object`||n===`function`){if(!e)mc[_c++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||(i.idsToInsert=[])).push(n),mc[_c++]=214,mc[_c++]=112,gc.setUint32(_c,n.id),_c+=4;return}i.set(e,{offset:_c-t})}let a=e.constructor;if(a===Object)C(e);else if(a===Array)v(e);else if(a===Map){if(this.mapAsEmptyObject)mc[_c++]=128;else{r=e.size,r<16?mc[_c++]=128|r:r<65536?(mc[_c++]=222,mc[_c++]=r>>8,mc[_c++]=r&255):(mc[_c++]=223,gc.setUint32(_c,r),_c+=4);for(let[t,n]of e)y(t),y(n)}}else{for(let t=0,n=vge.length;t<n;t++){let n=yge[t];if(e instanceof n){let n=vge[t];if(n.write){n.type&&(mc[_c++]=212,mc[_c++]=n.type,mc[_c++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?v(e):C(e):y(t);return}let r=mc,i=gc,a=_c;mc=null;let o;try{o=n.pack.call(this,e,e=>(mc=r,r=null,_c+=e,_c>vc&&T(_c),{target:mc,targetView:gc,position:_c-e}),y)}finally{r&&(mc=r,gc=i,_c=a,vc=mc.length-10)}o&&(o.length+_c>vc&&T(o.length+_c),_c=Tge(o,mc,_c,n.type));return}}if(Array.isArray(e))v(e);else{if(o.useToJSON!==!1&&e.toJSON){let t=e.toJSON();if(t!==e)return y(t)}if(n===`function`)return y(this.writeFunction&&this.writeFunction(e));C(e)}}}}else if(n===`boolean`)mc[_c++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)mc[_c++]=211,gc.setBigInt64(_c,e);else if(e<0x10000000000000000&&e>0)mc[_c++]=207,gc.setBigUint64(_c,e);else if(this.largeBigIntToFloat)mc[_c++]=203,gc.setFloat64(_c,Number(e));else if(this.largeBigIntToString)return y(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),fc)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+_c>vc&&T(n.length+_c),_c=Tge(n,mc,_c,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);_c+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?mc[_c++]=192:(mc[_c++]=212,mc[_c++]=0,mc[_c++]=0);else throw Error(`Unknown type: `+n)},b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?mc[_c++]=128|n:n<65536?(mc[_c++]=222,mc[_c++]=n>>8,mc[_c++]=n&255):(mc[_c++]=223,gc.setUint32(_c,n),_c+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);y(isNaN(n)?r:n),y(e[r])}else for(let i=0;i<n;i++)y(r=t[i]),y(e[r])}:e=>{mc[_c++]=222;let n=_c-t;_c+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(y(t),y(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);mc[n+++t]=r>>8,mc[n+t]=r&255},x=this.useRecords===!1?b:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||(r.transitions=Object.create(null)),a=_c++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==_c?(_c--,E(i,c,u)):D(i,c,a,u),o=!0,i=l[s]}y(e[s])}if(!o){let n=i[bc];n?mc[a+t]=n:D(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||(r.transitions=Object.create(null)),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[bc];a?a>=96&&d?(mc[_c++]=((a-=96)&31)+96,mc[_c++]=a>>5):mc[_c++]=a:E(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&y(e[t])},S=typeof this.useRecords==`function`&&this.useRecords,C=S?e=>{S(e)?x(e):b(e)}:x,w=e=>{let i=o._writeStruct(e,mc,t,_c,r,T,(e,t,r)=>{if(r)return n=!0;_c=t;let i=mc;return y(e),_(),i===mc?_c:{position:_c,targetView:gc,target:mc}});if(i===0)return C(e);_c=i},T=e=>{let n;if(e>16777216){if(e-t>xge)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min(xge,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,mc.length-1)>>12)+1<<12;let r=new pc(n);return gc=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,mc.length),mc.copy?mc.copy(r,0,t,e):r.set(mc.slice(t,e)),_c-=t,t=0,vc=r.length-10,mc=r},E=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[bc]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(mc[_c++]=(a&31)+96,mc[_c++]=o):mc[_c++]=a):(o>=0?(mc[_c++]=213,mc[_c++]=114,mc[_c++]=(a&31)+96,mc[_c++]=o):(mc[_c++]=212,mc[_c++]=114,mc[_c++]=a),i&&(h+=g*i),m.length>=u&&(m.shift()[bc]=0),m.push(e),y(t))},D=(e,n,r,i)=>{let a=mc,o=_c,s=vc,c=t;mc=hc,_c=0,t=0,mc||(hc=mc=new pc(8192)),vc=mc.length-10,E(e,n,i),hc=mc;let l=_c;if(mc=a,_c=o,vc=s,t=c,l>1){let e=_c+l-1;e>vc&&T(e);let n=r+t;mc.copyWithin(n+l,n+1,_c),mc.set(hc.slice(0,l),n),_c=e}else mc[r+t]=hc[0]}}useBuffer(e){mc=e,mc.dataView||(mc.dataView=new DataView(mc.buffer,mc.byteOffset,mc.byteLength)),gc=mc.dataView,_c=0}set position(e){_c=e}get position(){return _c}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};yge=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Vhe],vge=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?xc(e,16,t):Sc(fc?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==bge&&this.moreTypes?xc(e,dge.indexOf(n.name),t):Sc(e,t)}},{pack(e,t){this.moreTypes?xc(e,17,t):Sc(fc?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function xc(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function Sc(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function Tge(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function Ege(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function Dge(e,t,n){if(yc.length>0){gc.setUint32(yc.position+e,_c+n-yc.position-e),yc.stringsPosition=_c-e;let r=yc;yc=null,t(r[0]),t(r[1])}}function Oge(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}wge.SUPPORTS_STRUCT_HOOKS=!0;var kge=new wge({useRecords:!1});kge.pack,kge.pack;var{NEVER:Age,ALWAYS:jge,DECIMAL_ROUND:Mge,DECIMAL_FIT:Nge}=_ge,Cc=class extends Pe()(`effect/rpc/RpcSerialization`){},Pge=Cc.of({contentType:`application/json`,includesFraming:!1,makeUnsafe:()=>{let e=new TextDecoder;return{decode:t=>{let n=JSON.parse(typeof t==`string`?t:e.decode(t));return Array.isArray(n)?n:[n]},encode:e=>JSON.stringify(e)}}}),Fge=gte(Cc)(Pge),Ige=e=>$e(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>ge(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),Ct});return an(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return Fee(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*Ht($e(()=>i(e)),t)}return yield*jee(cte,()=>(t.delete(e),r.delete(e),Ct))})}}))}),Lge=BigInt(0),Rge=It(function*(e,t){let n=t?.spanPrefix??`RpcClient`,r=t?.supportsAck??!0,i=t?.disableTracing??!1,a=t?.generateRequestId??(()=>Lge++),o=yield*kt(),s=b(o,Dte),c=new Map,l=!1;yield*Zee(s,le(e=>(l=!0,u(Ute(e.id)))));let u=It(function*(e){for(let[t,n]of c)c.delete(t),n._tag===`Queue`?yield*e._tag===`Success`?tte(n.queue):Be(n.queue,e.cause):n.resume(e)}),d=e=>{let r=zte(e.successSchema),a=m(e);return(o,s)=>{let c=s?.headers?ahe(s.headers):ihe,l=s?.context??sne();if(!r){let r=t=>f(e,a,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return i?r(void 0):me(`${n}.${e._tag}`,{attributes:t.spanAttributes},r)}let u=p(e,a,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:Cte(an(u,Nee))}},f=(e,n,r,i,o,s,u)=>le(d=>{if(l)return hte;let f=a(),p=n(e=>t.onFromClient({message:e,context:s,discard:u}),{_tag:`Request`,id:f,tag:e._tag,payload:i,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:ohe(d.getRef(Uge),o)});if(u)return p;let m;return zee(Fe(t=>{let n={_tag:`Effect`,rpc:e,context:s,resume(e){t(e),m&&!m.pollUnsafe()&&d.currentDispatcher.scheduleTask(()=>{m.interruptUnsafe(d.id)},0)}};c.set(f,n),m=p.pipe(r?Oe(r,{captureStackTrace:!1}):Rt,pt(d.context)),m.addObserver(e=>{if(e._tag===`Failure`)return t(e)})}),e=>(c.delete(f),oe(Lme(m),h(f,Array.from(e),s))))}),p=It(function*(e,r,o,s,u,d){if(l)return yield*hte;let f=i?void 0:yield*vte(`${n}.${e._tag}`,{attributes:t.spanAttributes}),p=zme(),m=a(),_=Ot(p.context,Dte);yield*vee(_,e=>c.has(m)?(c.delete(m),h(m,rne(e)?Array.from(Jte(e.cause)):[],d)):Ct);let v=yield*g(u);return c.set(m,{_tag:`Queue`,rpc:e,queue:v,scope:_,context:d}),yield*r(e=>t.onFromClient({message:e,context:d,discard:!1}),{_tag:`Request`,id:m,tag:e._tag,payload:o,...f?{traceId:f.traceId,spanId:f.spanId,sampled:f.sampled}:{},headers:ohe(p.getRef(Uge),s)}).pipe(f?Oe(f,{captureStackTrace:!1}):Rt,ut(e=>Be(v,e)),nn,at(_,{startImmediately:!0})),v}),m=e=>{let t=[];for(let n of e.middlewares.values()){let e=o.mapUnsafe.get(`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},h=(e,n,r)=>Fe(i=>{let a=zme();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r,discard:!1}).pipe(one(1e3),pt(a.context)).addObserver(()=>{i(Ct)})}),_=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,i=c.get(n);return!i||i._tag!==`Queue`?Ct:Ge(i.queue,e.values).pipe(r?en(()=>t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:i.context,discard:!1})):Rt,ut(e=>Be(i.queue,e)))}case`Exit`:{let t=e.requestId,n=c.get(t);return n?(c.delete(t),n._tag===`Effect`?(n.resume(e.exit),Ct):e.exit._tag===`Success`?tte(n.queue):Be(n.queue,e.exit.cause)):Ct}case`Defect`:return u(qee(e.defect));case`ClientEnd`:return Ct}},v;if(t.flatten){let t=new Map;v=function(n,r,i){let a=t.get(n);return a||(a=d(e.requests.get(n)),t.set(n,a)),a(r,i)}}else v={},e.requests.forEach(e=>{v[e._tag]=d(e)});return{client:v,write:_}}),zge=0,Bge=It(function*(e,t){let n=zge++,{run:r,send:i,supportsAck:a,supportsTransferables:o}=yield*wc,s=new Map,{client:c,write:l}=yield*Rge(e,{...t,supportsAck:a,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),a=o?Ahe():void 0,c=zme(),l={rpc:r,context:a?lt(c.context,khe,a):c.context,schemas:Hge(r)};return s.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(Ht(l.context),Zt,en(e=>i(n,{...t,id:String(t.id),payload:e,headers:Object.entries(t.headers)},a&&a.readUnsafe())))}case`Ack`:return s.get(t.requestId)?i(n,{_tag:`Ack`,requestId:String(t.requestId)}):Ct;case`Interrupt`:return s.get(t.requestId)?(s.delete(t.requestId),i(n,{_tag:`Interrupt`,requestId:String(t.requestId)})):Ct;case`Eof`:return Ct}}});return yield*r(n,e=>{switch(e._tag){case`Chunk`:{let t=Ws(e.requestId),n=s.get(t);return!n||ke(n.schemas.decodeChunk)?Ct:n.schemas.decodeChunk.value(e.values).pipe(Ht(n.context),Zt,en(t=>l({_tag:`Chunk`,clientId:0,requestId:Ws(e.requestId),values:t})),Lte(t=>l({_tag:`Exit`,clientId:0,requestId:Ws(e.requestId),exit:pee(t)})))}case`Exit`:{let t=Ws(e.requestId),n=s.get(t);return n?(s.delete(t),n.schemas.decodeExit(e.exit).pipe(Ht(n.context),Zt,Dee({onSuccess:e=>l({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>l({_tag:`Exit`,clientId:0,requestId:t,exit:pee(e)})}))):Ct}case`Defect`:return l({_tag:`Defect`,clientId:0,defect:Yge(e.defect)});case`ClientProtocolError`:{let t=Wee(e.error);return iee(s.keys(),e=>l({_tag:`Exit`,clientId:0,requestId:e,exit:t}))}default:return Ct}}).pipe(ut(_ee),nn,d),c}),Vge=new WeakMap,Hge=e=>{let t=Vge.get(e);if(t!==void 0)return t;let n=ute(e.successSchema);return t={decodeChunk:we(n,e=>bt(ote(Wte(e.success)))),encodePayload:te(ote(e.payloadSchema)),decodeExit:bt(ote(kee(e)))},Vge.set(e,t),t},Uge=be(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>ihe}),wc=class extends Pe()(`effect/rpc/RpcClient/Protocol`){static make=Ige},Wge=e=>wc.make(It(function*(t,n){let r=yield*fhe,i=yield*Cc,a=yield*Re(Jge),o=new Map,s=yield*r.writer,c=i.makeUnsafe(),l=yield*Kge(s(c.encode(Fhe))),u,f=$e(()=>(u=void 0,Tte(a)?a.value.onConnect:Ct)),p=e=>iee(n,n=>t(n,e));return yield*$e(()=>(c=i.makeUnsafe(),l.reset(),r.runRaw(e=>{try{let n=c.decode(e);if(n.length===0)return;let r=0;return Mt({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return l.onPong(),Ct;if(`requestId`in e){let n=o.get(e.requestId);if(n!==void 0)return e._tag===`Exit`&&o.delete(e.requestId),t(n,e)}return p(e)},step:Eee})}catch(e){return p({_tag:`ClientProtocolError`,error:new Phe({reason:new Nhe({message:`Error decoding message`,cause:e})})})}},{onOpen:f}).pipe(fee(en(l.timeout,()=>Ae(new Us({reason:new Vs({kind:`Timeout`,cause:Error(`ping timeout`)})}))))))).pipe(en(()=>Ae(new Us({reason:new Hs({code:1e3})}))),Tte(a)?de(a.value.onDisconnect):Rt,Ne(t=>{let n=mt(t),r=Nt(n);return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?Ct:(u=new Phe({reason:r?n.success.reason:new Nhe({message:`Unknown socket error`,cause:yt(t)})}),p({_tag:`ClientProtocolError`,error:u}))}),Hte(e?.retryPolicy??Gge),xe({module:`RpcClient`,method:`makeProtocolSocket`}),d),{send(e,t){if(u)return Ae(u);t._tag===`Request`&&o.set(t.id,e);let n=c.encode(t);return n===void 0?Ct:Zt(s(n))},supportsAck:!0,supportsTransferables:!1}})),Gge=Ce(500,1.5).pipe(wte(nee(5e3))),Kge=It(function*(e){let t=!0,n=Vme();return yield*$e(()=>t?(t=!1,e):n.open).pipe(wt(`5 seconds`),Pte,uee,nn,d),{timeout:n.await,reset:()=>{t=!0,n.closeUnsafe()},onPong:()=>{t=!0}}}),qge=e=>rt(wc)(Wge(e)),Jge=class extends Pe()(`effect/rpc/RpcClient/ConnectionHooks`){},Yge=Yte(Ut),Tc=un((e,t)=>({serverReachable:!0,streamLive:!1,restarting:!1,sessionAuthFailed:!1,hasSnapshot:!1,lastLiveAt:null,reconnect:null,setServerReachable:t=>e({serverReachable:t}),setStreamLive:(t,n)=>e(t?{streamLive:t,hasSnapshot:!0,lastLiveAt:n??Date.now()}:{streamLive:t}),setRestarting:t=>e({restarting:t}),setSessionAuthFailed:t=>e({sessionAuthFailed:t}),markSnapshotCached:t=>e(e=>({hasSnapshot:!0,lastLiveAt:e.lastLiveAt??t})),registerReconnect:t=>e({reconnect:t}),requestReconnect:()=>t().reconnect?.()}));function Ec(e){return e.restarting?`restarting`:e.sessionAuthFailed?`unauthorized`:e.serverReachable?e.streamLive?`live`:`delayed`:`unreachable`}function Dc(){return Tc(Ec)}function Oc(e){return e===`unreachable`||e===`restarting`||e===`unauthorized`}function Xge(){return Oc(Ec(Tc.getState()))}var Zge=`Can't reach the Overdeck server — available again when it reconnects.`;function Qge(e){return!e.hasSnapshot&&Oc(Ec(e))}var $ge=3e3;async function e_e(e=fetch){let t=new AbortController,n,r=new Promise(e=>{n=setTimeout(()=>{t.abort(),e(!1)},$ge)}),i=(async()=>{try{let n=await(await e(`/api/health`,{signal:t.signal,cache:`no-store`})).json();return typeof n==`object`&&!!n&&typeof n.status==`string`}catch{return!1}})();try{return await Promise.race([i,r])}finally{clearTimeout(n)}}var t_e=class extends Error{sessionUrl;constructor(e){super(`Dashboard session mint was refused (HTTP 401) at ${e}`),this.sessionUrl=e,this.name=`DashboardSessionUnauthorizedError`}},n_e=Bge(se);function r_e(e){return e||`${window.location.protocol===`https:`?`wss`:`ws`}://${window.location.host}/ws/rpc`}function i_e(e){let t=new URL(r_e(e));return t.protocol=t.protocol===`wss:`?`https:`:`http:`,t.pathname=`/api/dashboard/session`,t.search=``,t.hash=``,t.toString()}function a_e(e){let t=i_e(e);return new URL(t).host===window.location.host?[t]:[t,new URL(`/api/dashboard/session`,window.location.origin).toString()]}var o_e=null,s_e=null;function c_e(){if(typeof window>`u`)return null;let e=window.location.hash.replace(/^#/,``);if(!e)return null;let t=new URLSearchParams(e),n=t.get(`overdeck_token`)??t.get(`token`);if(!n)return null;t.delete(`overdeck_token`),t.delete(`token`);let r=t.toString();return window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${r?`#${r}`:``}`),n}function l_e(){if(typeof window>`u`)return null;let e=window.location.hash.replace(/^#/,``);if(!e)return null;let t=new URLSearchParams(e),n=t.get(`pair`);if(!n)return null;t.delete(`pair`);let r=t.toString();return window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${r?`#${r}`:``}`),n}var u_e=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`DashboardPairingError`}};async function d_e(e,t){let n=new URL(i_e(e));n.pathname=`/api/pairing/exchange`;let r=typeof navigator<`u`&&navigator.platform?navigator.platform:`unknown`,i=await fetch(n.toString(),{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({credential:t,label:`Browser on ${r}`,delivery:`cookie`})});if(i.ok)return;let a=await i.json().catch(()=>null);throw new u_e(`Pairing failed: ${typeof a?.error==`string`?a.error:`HTTP ${i.status}`}`,i.status)}function kc(e){if(typeof window>`u`)return Promise.resolve();let t=c_e(),n=l_e();return o_e??=(n?d_e(e,n):Promise.resolve()).then(()=>Promise.all(a_e(e).map(async e=>{let n=await fetch(e,{method:`POST`,credentials:`include`,headers:t?{"x-overdeck-internal-token":t}:void 0});if(n.status===401)throw new t_e(e);if(!n.ok)throw Error(`Dashboard session bootstrap failed: HTTP ${n.status}`);let r=await n.json().catch(()=>null);return typeof r?.csrfToken==`string`?r.csrfToken:null}))).then(e=>{s_e=e.find(e=>e!==null)??null,Tc.getState().setSessionAuthFailed(!1)}).catch(e=>{throw o_e=null,e instanceof t_e&&Tc.getState().setSessionAuthFailed(!0),e}),o_e}async function Ac(e){if(await kc(e),!s_e)throw Error(`Dashboard CSRF token unavailable`);return{"Content-Type":`application/json`,"x-overdeck-csrf-token":s_e}}function f_e(e){let t=Ohe(r_e(e)).pipe(Fte(The));return qge({retryTransientErrors:!0}).pipe(Fte(Iee(t,Fge)))}var p_e=1e4;function m_e(e){return Math.min(500*2**(Math.max(1,Math.floor(e))-1),p_e)}var h_e=ae(500),g_e=ae(p_e);function __e(e=h_e){return Ce(e).pipe(wte(nee(g_e)),aee)}function v_e(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}var y_e=class{runtime;clientScope;clientPromise;disposed=!1;constructor(e){this.runtime=ehe(f_e(e)),this.clientScope=this.runtime.runSync(Oee()),this.clientPromise=kc(e).then(()=>this.runtime.runPromise(Rte(this.clientScope)(n_e)))}async request(e){if(this.disposed)throw Error(`WsTransport disposed`);let t=await this.clientPromise;return this.runtime.runPromise($e(()=>e(t)))}async requestStream(e,t){if(this.disposed)throw Error(`WsTransport disposed`);let n=await this.clientPromise;await this.runtime.runPromise(Bee(e(n),e=>ie(()=>{try{t(e)}catch{}})))}subscribe(e,t,n){if(this.disposed)return()=>void 0;let r=!0,i=null,a=n?.retryDelay??h_e,o=n?.onReconnect,s=n?.onRetry,c=!1,l=0,u=()=>{if(!r)return;let n=Mc();i=n.runtime.runCallback(dte(()=>n.clientPromise).pipe(en(n=>Bee(e(n),e=>ie(()=>{if(r){if(c&&(c=!1,l=0,o))try{o()}catch{}try{t(e)}catch{}}}))),cne(e=>Ae(Error(v_e(e)))),ct(e=>ie(()=>{if(r){c=!0,l+=1;try{s?.(l)}catch{}console.warn(`[WsTransport] subscription error, retrying:`,v_e(e))}})),Hte(__e(a)),uee),{onExit:e=>{if(r&&rne(e)){c=!0,l+=1;try{s?.(l)}catch{}console.warn(`[WsTransport] subscription exited, reconnecting with fresh transport`),b_e(n),setTimeout(u,m_e(l))}}})};return u(),()=>{r=!1,i?.()}}dispose(){this.disposed=!0,this.runtime.runSync(yte(this.clientScope,Cee)),this.runtime.dispose()}},jc=null;function Mc(){return jc||=new y_e,jc}function b_e(e){jc&&(e&&e!==jc||(jc.dispose(),jc=null))}function x_e({request:e,isOpen:t,onConfirm:n,onDeny:r,onClose:i}){return!t||!e?null:(0,z.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,z.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-2xl w-full max-w-md mx-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning`}),(0,z.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Confirmation Required`})]}),(0,z.jsx)(`button`,{onClick:i,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,z.jsx)(Os,{className:`w-5 h-5`})})]}),(0,z.jsxs)(`div`,{className:`p-4 space-y-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground mb-1`,children:`Agent:`}),(0,z.jsx)(`p`,{className:`text-base text-foreground font-medium`,children:e.agentId})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground mb-1`,children:`Action:`}),(0,z.jsx)(`p`,{className:`text-base text-foreground font-medium`,children:e.action})]}),e.details&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground mb-1`,children:`Details:`}),(0,z.jsx)(`p`,{className:`text-sm text-foreground bg-card/50 p-2 rounded border border-border`,children:e.details})]}),(0,z.jsx)(`div`,{className:`mt-4 p-3 badge-bg-warning border badge-border-warning rounded`,children:(0,z.jsx)(`p`,{className:`text-sm text-warning-foreground`,children:`⚠️ This action cannot be undone. Please confirm that you want to proceed.`})})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 py-3 border-t border-border bg-card/30`,children:[(0,z.jsx)(`button`,{onClick:r,className:`px-4 py-2 rounded text-sm bg-popover text-foreground hover:bg-card transition-colors`,children:`Deny`}),(0,z.jsx)(`button`,{onClick:n,className:`px-4 py-2 rounded text-sm bg-warning text-warning-foreground hover:bg-warning/90 transition-colors font-medium`,children:`Confirm`})]})]})})}var S_e=typeof navigator<`u`&&navigator.platform.includes(`Mac`),C_e=S_e?`⌘⇧.`:`Ctrl+Shift+.`,w_e=`pan:emergency-stop-open`;function T_e(){window.dispatchEvent(new CustomEvent(w_e))}async function E_e(){let e=await fetch(`/api/cloister/emergency-stop`,{method:`POST`});if(!e.ok)throw Error(`Emergency stop request failed`);let t=await e.json();return{killed:t.killedAgents??[],unconfirmed:t.unconfirmedAgents??[]}}async function D_e(){try{let{killed:e,unconfirmed:t}=await E_e(),n=`Auto-resume frozen — clear the Deacon / flywheel pause when you want agents to run again.`;return t.length>0?B.warning(`Emergency STOP: stopped ${e.length}; ${t.length} could not be confirmed stopped: ${t.join(`, `)}. ${n}`):B.success(`Emergency STOP: killed ${e.length} agent${e.length===1?``:`s`}. ${n}`),!0}catch(e){return B.error(e instanceof Error?e.message:`Emergency stop failed`),!1}}function O_e(){let[e,t]=(0,L.useState)(!1),[n,r]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let e=e=>{(S_e?e.metaKey:e.ctrlKey)&&e.shiftKey&&(e.code===`Period`||e.key===`.`||e.key===`>`)&&(e.preventDefault(),t(!0))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),(0,L.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(w_e,e),()=>window.removeEventListener(w_e,e)},[]);let i=(0,L.useCallback)(async()=>{r(!0);try{await D_e()&&t(!1)}finally{r(!1)}},[]);return(0,L.useEffect)(()=>{if(!e)return;let r=e=>{e.key===`Enter`?(e.preventDefault(),n||i()):e.key===`Escape`&&(e.preventDefault(),n||t(!1))};return document.addEventListener(`keydown`,r,!0),()=>document.removeEventListener(`keydown`,r,!0)},[e,n,i]),e?(0,Ms.createPortal)((0,z.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-black/60`,role:`alertdialog`,"aria-modal":`true`,"aria-label":`Emergency stop all agents`,onClick:()=>{n||t(!1)},children:(0,z.jsxs)(`div`,{className:`w-[440px] max-w-[90vw] rounded-xl border badge-border-destructive bg-card p-5 shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-destructive`,children:[(0,z.jsx)(bo,{className:`h-5 w-5`}),(0,z.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Emergency STOP — kill all agents?`})]}),(0,z.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-muted-foreground`,children:[`Immediately kills `,(0,z.jsx)(`strong`,{children:`every running agent`}),` across all harnesses (Claude Code, Pi, Codex) and freezes Deacon + flywheel auto-resume so nothing re-spawns. Agents can be resumed later — this does not delete any work.`]}),(0,z.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>t(!1),disabled:n,className:`px-3 py-1.5 rounded text-xs bg-popover text-foreground hover:bg-card disabled:opacity-50`,children:[`Cancel `,(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`(Esc)`})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void i(),disabled:n,className:`px-3 py-1.5 rounded text-xs bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:opacity-50`,children:n?`Stopping…`:`Stop all agents (Enter)`})]})]})}),document.body):null}function k_e({request:e,isOpen:t,issueId:n,isSubmitting:r=!1,onAllow:i,onDeny:a}){return!t||!e?null:(0,z.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm`,children:(0,z.jsxs)(`div`,{className:`w-full max-w-2xl overflow-hidden rounded-xl border border-warning/30 bg-card shadow-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-5 py-4`,children:[(0,z.jsx)(`div`,{className:`rounded-full bg-warning/15 p-2`,children:(0,z.jsx)(xpe,{className:`h-5 w-5 text-warning-foreground`})}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Tool Permission Required`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Claude is waiting for an operator decision before it can continue.`})]})]}),(0,z.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[(0,z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Agent`}),(0,z.jsx)(`p`,{className:`font-mono text-sm text-foreground`,children:e.agentId})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Issue`}),(0,z.jsx)(`p`,{className:`font-mono text-sm text-foreground`,children:n??`Unknown`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Tool`}),(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.toolName})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Requested at`}),(0,z.jsx)(`p`,{className:`text-sm text-foreground`,children:new Date(e.createdAt).toLocaleString()})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Description`}),(0,z.jsx)(`div`,{className:`rounded-lg border border-border bg-background/60 px-3 py-2 text-sm text-foreground`,children:e.description})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Arguments`}),(0,z.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-lg border border-border bg-background/80 p-3 text-xs text-foreground whitespace-pre-wrap break-words`,children:e.inputPreview||`No input preview provided.`})]}),(0,z.jsx)(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-sm text-warning-foreground`,children:`This decision applies only to this pending Claude permission prompt. Overdeck can currently send only allow or deny for channel permissions.`})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-3 border-t border-border bg-card/40 px-5 py-4`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:a,disabled:r,className:`rounded-md border border-border bg-popover px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-card disabled:cursor-not-allowed disabled:opacity-60`,children:`Deny`}),(0,z.jsxs)(`button`,{type:`button`,onClick:i,disabled:r,className:`inline-flex items-center gap-2 rounded-md bg-warning px-4 py-2 text-sm font-semibold text-warning-foreground transition-colors hover:bg-warning/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[r&&(0,z.jsx)(is,{className:`h-4 w-4 animate-spin`}),`Allow`]})]})]})})}var A_e={"allow-once":`Allow once`,"allow-always":`Allow always`,deny:`Deny`};function Nc({label:e,children:t}){return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t]})}var j_e=`rounded-md border border-border bg-popover px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-card disabled:cursor-not-allowed disabled:opacity-60`,M_e=`inline-flex items-center gap-2 rounded-md bg-warning px-4 py-2 text-sm font-semibold text-warning-foreground transition-colors hover:bg-warning/90 disabled:cursor-not-allowed disabled:opacity-60`;function N_e({subject:e,isOpen:t,isSubmitting:n=!1,confirming:r=!1,onAnswer:i,onOpenTerminal:a,onDismiss:o}){if(!t||!e)return null;let s=e.pendingPermission,c=n||r;return(0,z.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm`,children:(0,z.jsxs)(`div`,{role:`dialog`,"aria-label":`Permission needed`,className:`w-full max-w-2xl overflow-hidden rounded-xl border border-warning/30 bg-card shadow-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-5 py-4`,children:[(0,z.jsx)(`div`,{className:`rounded-full bg-warning/15 p-2`,children:(0,z.jsx)(xpe,{className:`h-5 w-5 text-warning-foreground`})}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Permission needed`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Claude Code is waiting for a permission answer before it can continue.`})]})]}),(0,z.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[(0,z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,z.jsx)(Nc,{label:`Conversation`,children:(0,z.jsx)(`p`,{className:`text-sm text-foreground`,children:e.title??e.conversationName})}),(0,z.jsx)(Nc,{label:`Agent`,children:(0,z.jsx)(`p`,{className:`text-sm text-foreground`,children:s.agentLabel})}),(0,z.jsx)(Nc,{label:`Tool`,children:(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:s.toolName??s.header??`Unknown tool`})})]}),s.clipped&&s.inputPreview&&(0,z.jsx)(Nc,{label:`Command (start)`,children:(0,z.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-border bg-background/80 p-3 font-mono text-xs text-foreground`,children:s.inputPreview})}),s.detailLines.length>0&&(0,z.jsx)(Nc,{label:s.clipped?`On screen`:`Command`,children:(0,z.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-border bg-background/80 p-3 font-mono text-xs text-foreground`,children:s.detailLines.join(`
@@ -1480,7 +1480,7 @@ The first edit matching the preferences will be applied.`),items:{type:`string`}
1480
1480
  `)};let a=await i.provideRenameEdits(this.model,this.position,e,r);return a?a.rejectReason?this._provideRenameEdits(e,t+1,n.concat(a.rejectReason),r):a:this._provideRenameEdits(e,t+1,n.concat(H(1380,`No result.`)),r)}};async function k2n(e,t,n,r){let i=new O2n(t,n,e),a=await i.resolveRenameLocation(NF.None);return a?.rejectReason?{edits:[],rejectReason:a.rejectReason}:i.provideRenameEdits(r,NF.None)}var b5=class{static{D2n=this}static{this.ID=`editor.contrib.renameController`}static get(e){return e.getContribution(D2n.ID)}constructor(e,t,n,r,i,a,o,s){this.editor=e,this._instaService=t,this._notificationService=n,this._bulkEditService=r,this._progressService=i,this._logService=a,this._configService=o,this._languageFeaturesService=s,this._disposableStore=new W,this._cts=new FF,this._renameWidget=this._disposableStore.add(this._instaService.createInstance(S2n,this.editor,[`acceptRenameInput`,`acceptRenameInputWithPreview`]))}dispose(){this._disposableStore.dispose(),this._cts.dispose(!0)}async run(){let e=this._logService.trace.bind(this._logService,`[rename]`);if(this._cts.dispose(!0),this._cts=new FF,!this.editor.hasModel()){e(`editor has no model`);return}let t=this.editor.getPosition(),n=new O2n(this.editor.getModel(),t,this._languageFeaturesService.renameProvider);if(!n.hasProvider()){e(`skeleton has no provider`);return}let r=new f2(this.editor,5,void 0,this._cts.token),i;try{e(`resolving rename location`);let t=n.resolveRenameLocation(r.token);this._progressService.showWhile(t,250),i=await t,e(`resolved rename location`)}catch(n){n instanceof nP?e(`resolve rename location cancelled`,JSON.stringify(n,null,` `)):(e(`resolve rename location failed`,n instanceof Error?n:JSON.stringify(n,null,` `)),(typeof n==`string`||qX(n))&&E2.get(this.editor)?.showMessage(n||H(1381,`An unknown error occurred while resolving rename location`),t));return}finally{r.dispose()}if(!i){e(`returning early - no loc`);return}if(i.rejectReason){e(`returning early - rejected with reason: ${i.rejectReason}`,i.rejectReason),E2.get(this.editor)?.showMessage(i.rejectReason,t);return}if(r.token.isCancellationRequested){e(`returning early - cts1 cancelled`);return}let a=new f2(this.editor,5,i.range,this._cts.token),o=this.editor.getModel(),s=this._languageFeaturesService.newSymbolNamesProvider.all(o),c=await Promise.all(s.map(async e=>[e,await e.supportsAutomaticNewSymbolNamesTriggerKind??!1])),l=(e,t)=>{let n=c.slice();return e===jI.Automatic&&(n=n.filter(([e,t])=>t)),n.map(([n])=>n.provideNewSymbolNames(o,i.range,e,t))};e(`creating rename input field and awaiting its result`);let u=this._bulkEditService.hasPreviewHandler()&&this._configService.getValue(this.editor.getModel().uri,`editor.rename.enablePreview`),d=await this._renameWidget.getInput(i.range,i.text,u,s.length>0?l:void 0,a);if(e(`received response from rename input field`),typeof d==`boolean`){e(`returning early - rename input field response - ${d}`),d&&this.editor.focus(),a.dispose();return}this.editor.focus(),e(`requesting rename edits`);let f=FL(n.provideRenameEdits(d.newName,a.token),a.token).then(async t=>{if(!t){e(`returning early - no rename edits result`);return}if(!this.editor.hasModel()){e(`returning early - no model after rename edits are provided`);return}if(t.rejectReason){e(`returning early - rejected with reason: ${t.rejectReason}`),this._notificationService.info(t.rejectReason);return}this.editor.setSelection(J.fromPositions(this.editor.getSelection().getPosition())),e(`applying edits`),this._bulkEditService.apply(t,{editor:this.editor,showPreview:d.wantsPreview,label:H(1382,`Renaming '{0}' to '{1}'`,i?.text,d.newName),code:`undoredo.rename`,quotableLabel:H(1383,`Renaming {0} to {1}`,i?.text,d.newName),respectAutoSaveConfig:!0,reason:Xq.rename()}).then(t=>{e(`edits applied`),t.ariaSummary&&WH(H(1384,`Successfully renamed '{0}' to '{1}'. Summary: {2}`,i.text,d.newName,t.ariaSummary))}).catch(t=>{e(`error when applying edits ${JSON.stringify(t,null,` `)}`),this._notificationService.error(H(1385,`Rename failed to apply edits`)),this._logService.error(t)})},t=>{e(`error when providing rename edits`,JSON.stringify(t,null,` `)),this._notificationService.error(H(1386,`Rename failed to compute edits`)),this._logService.error(t)}).finally(()=>{a.dispose()});return e(`returning rename operation`),this._progressService.showWhile(f,250),f}acceptRenameInput(e){this._renameWidget.acceptInput(e)}cancelRenameInput(){this._renameWidget.cancelInput(!0,`cancelRenameInput command`)}focusNextRenameSuggestion(){this._renameWidget.focusNextRenameSuggestion()}focusPreviousRenameSuggestion(){this._renameWidget.focusPreviousRenameSuggestion()}};b5=D2n=E2n([y5(1,kz),y5(2,MK),y5(3,CQ),y5(4,LQ),y5(5,wB),y5(6,mH),y5(7,hH)],b5);var A2n=class extends kB{constructor(){super({id:`editor.action.rename`,label:U(1388,`Rename Symbol`),precondition:Wz.and($.writable,$.hasRenameProvider),kbOpts:{kbExpr:$.editorTextFocus,primary:60,weight:100},contextMenuOpts:{group:`1_modification`,order:1.1},canTriggerInlineEdits:!0})}runCommand(e,t){let n=e.get(jz),[r,i]=Array.isArray(t)&&t||[void 0,void 0];return dI.isUri(r)&&q.isIPosition(i)?n.openCodeEditor({resource:r},n.getActiveCodeEditor()).then(e=>{e&&(e.setPosition(i),e.invokeWithinContext(t=>(this.reportTelemetry(t,e),this.run(t,e))))},$N):super.runCommand(e,t)}run(e,t){let n=e.get(wB),r=b5.get(t);return r?(n.trace(`[RenameAction] got controller, running...`),r.run()):(n.trace(`[RenameAction] returning early - controller missing`),Promise.resolve())}};IB(b5.ID,b5,4),PB(A2n);var j2n=OB.bindToContribution(b5.get);NB(new j2n({id:`acceptRenameInput`,precondition:v5,handler:e=>e.acceptRenameInput(!1),kbOpts:{weight:199,kbExpr:Wz.and($.focus,Wz.not(`isComposing`)),primary:3}})),NB(new j2n({id:`acceptRenameInputWithPreview`,precondition:Wz.and(v5,Wz.has(`config.editor.rename.enablePreview`)),handler:e=>e.acceptRenameInput(!0),kbOpts:{weight:199,kbExpr:Wz.and($.focus,Wz.not(`isComposing`)),primary:2051}})),NB(new j2n({id:`cancelRenameInput`,precondition:v5,handler:e=>e.cancelRenameInput(),kbOpts:{weight:199,kbExpr:$.focus,primary:9,secondary:[1033]}})),fB(class extends dB{constructor(){super({id:`focusNextRenameSuggestion`,title:{...U(1389,`Focus Next Rename Suggestion`)},precondition:v5,keybinding:[{primary:18,weight:199}]})}run(e){let t=e.get(jz).getFocusedCodeEditor();if(!t)return;let n=b5.get(t);n&&n.focusNextRenameSuggestion()}}),fB(class extends dB{constructor(){super({id:`focusPreviousRenameSuggestion`,title:{...U(1390,`Focus Previous Rename Suggestion`)},precondition:v5,keybinding:[{primary:16,weight:199}]})}run(e){let t=e.get(jz).getFocusedCodeEditor();if(!t)return;let n=b5.get(t);n&&n.focusPreviousRenameSuggestion()}}),MB(`_executeDocumentRenameProvider`,function(e,t,n,...r){let[i]=r;gP(typeof i==`string`);let{renameProvider:a}=e.get(hH);return k2n(a,t,n,i)}),MB(`_executePrepareRename`,async function(e,t,n){let{renameProvider:r}=e.get(hH),i=await new O2n(t,n,r).resolveRenameLocation(NF.None);if(i?.rejectReason)throw Error(i.rejectReason);return i}),tB.as(aV.Configuration).registerConfiguration({id:`editor`,properties:{"editor.rename.enablePreview":{scope:6,description:H(1387,`Enable/disable the ability to preview changes before renaming`),default:!0,type:`boolean`}}});var M2n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},N2n=function(e,t){return function(n,r){t(n,r,e)}},x5=class extends G{static{this.ID=`editor.sectionHeaderDetector`}constructor(e,t,n){super(),this.editor=e,this.languageConfigurationService=t,this.editorWorkerService=n,this.decorations=this.editor.createDecorationsCollection(),this.options=this.createOptions(e.getOption(81)),this.computePromise=null,this.currentOccurrences={},this._register(e.onDidChangeModel(t=>{this.currentOccurrences={},this.options=this.createOptions(e.getOption(81)),this.stop(),this.computeSectionHeaders.schedule(0)})),this._register(e.onDidChangeModelLanguage(t=>{this.currentOccurrences={},this.options=this.createOptions(e.getOption(81)),this.stop(),this.computeSectionHeaders.schedule(0)})),this._register(t.onDidChange(t=>{let n=this.editor.getModel()?.getLanguageId();n&&t.affects(n)&&(this.currentOccurrences={},this.options=this.createOptions(e.getOption(81)),this.stop(),this.computeSectionHeaders.schedule(0))})),this._register(e.onDidChangeConfiguration(t=>{(!this.options||t.hasChanged(81))&&(this.options=this.createOptions(e.getOption(81)),this.updateDecorations([]),this.stop(),this.computeSectionHeaders.schedule(0))})),this._register(this.editor.onDidChangeModelContent(e=>{this.computeSectionHeaders.schedule()})),this._register(e.onDidChangeModelTokens(e=>{this.computeSectionHeaders.isScheduled()||this.computeSectionHeaders.schedule(1e3)})),this.computeSectionHeaders=this._register(new HL(()=>{this.findSectionHeaders()},250)),this.computeSectionHeaders.schedule(0)}createOptions(e){if(!e||!this.editor.hasModel())return;let t=this.editor.getModel().getLanguageId();if(!t)return;let n=this.languageConfigurationService.getLanguageConfiguration(t).comments,r=this.languageConfigurationService.getLanguageConfiguration(t).foldingRules;if(n||r?.markers)return{foldingRules:r,markSectionHeaderRegex:e.markSectionHeaderRegex,findMarkSectionHeaders:e.showMarkSectionHeaders,findRegionSectionHeaders:e.showRegionSectionHeaders}}findSectionHeaders(){if(!this.editor.hasModel()||!this.options?.findMarkSectionHeaders&&!this.options?.findRegionSectionHeaders)return;let e=this.editor.getModel();if(e.isDisposed()||e.isTooLargeForSyncing())return;let t=e.getVersionId();this.editorWorkerService.findSectionHeaders(e.uri,this.options).then(n=>{e.isDisposed()||e.getVersionId()!==t||this.updateDecorations(n)})}updateDecorations(e){let t=this.editor.getModel();t&&(e=e.filter(e=>{if(!e.shouldBeInComments)return!0;let n=t.validateRange(e.range),r=t.tokenization.getLineTokens(n.startLineNumber),i=r.findTokenIndexAtOffset(n.startColumn-1),a=r.getStandardTokenType(i);return r.getLanguageId(i)===t.getLanguageId()&&a===1}));let n=Object.values(this.currentOccurrences).map(e=>e.decorationId),r=e.map(e=>P2n(e));this.editor.changeDecorations(t=>{let i=t.deltaDecorations(n,r);this.currentOccurrences={};for(let t=0,n=i.length;t<n;t++){let n={sectionHeader:e[t],decorationId:i[t]};this.currentOccurrences[n.decorationId]=n}})}stop(){this.computeSectionHeaders.cancel(),this.computePromise&&=(this.computePromise.cancel(),null)}dispose(){super.dispose(),this.stop(),this.decorations.clear()}};x5=M2n([N2n(1,fV),N2n(2,j$)],x5);function P2n(e){return{range:e.range,options:aY.createDynamic({description:`section-header`,stickiness:3,collapseOnReplaceEdit:!0,minimap:{color:void 0,position:1,sectionHeaderStyle:e.hasSeparatorLine?2:1,sectionHeaderText:e.text}})}}IB(x5.ID,x5,1);function F2n(e){for(let t=0,n=e.length;t<n;t+=4){let n=e[t+0],r=e[t+1],i=e[t+2],a=e[t+3];e[t+0]=a,e[t+1]=i,e[t+2]=r,e[t+3]=n}}function I2n(e){let t=new Uint8Array(e.buffer,e.byteOffset,e.length*4);return t0t()||F2n(t),ZL.wrap(t)}function L2n(e){let t=new Uint32Array(R2n(e)),n=0;if(t[n++]=e.id,e.type===`full`)t[n++]=1,t[n++]=e.data.length,t.set(e.data,n),n+=e.data.length;else{t[n++]=2,t[n++]=e.deltas.length;for(let r of e.deltas)t[n++]=r.start,t[n++]=r.deleteCount,r.data?(t[n++]=r.data.length,t.set(r.data,n),n+=r.data.length):t[n++]=0}return I2n(t)}function R2n(e){let t=0;if(t+=2,e.type===`full`)t+=1+e.data.length;else{t+=1,t+=3*e.deltas.length;for(let n of e.deltas)n.data&&(t+=n.data.length)}return t}function S5(e){return e&&!!e.data}function z2n(e){return e&&Array.isArray(e.edits)}var B2n=class{constructor(e,t,n){this.provider=e,this.tokens=t,this.error=n}};function V2n(e,t){return e.has(t)}function H2n(e,t){let n=e.orderedGroups(t);return n.length>0?n[0]:[]}async function U2n(e,t,n,r,i){let a=H2n(e,t),o=await Promise.all(a.map(async e=>{let a,o=null;try{a=await e.provideDocumentSemanticTokens(t,e===n?r:null,i)}catch(e){o=e,a=null}return(!a||!S5(a)&&!z2n(a))&&(a=null),new B2n(e,a,o)}));for(let e of o){if(e.error)throw e.error;if(e.tokens)return e}return o.length>0?o[0]:null}function W2n(e,t){let n=e.orderedGroups(t);return n.length>0?n[0]:null}var G2n=class{constructor(e,t){this.provider=e,this.tokens=t}};function K2n(e,t){return e.has(t)}function q2n(e,t){let n=e.orderedGroups(t);return n.length>0?n[0]:[]}async function J2n(e,t,n,r){let i=q2n(e,t),a=await Promise.all(i.map(async e=>{let i;try{i=await e.provideDocumentRangeSemanticTokens(t,n,r)}catch(e){eP(e),i=null}return(!i||!S5(i))&&(i=null),new G2n(e,i)}));for(let e of a)if(e.tokens)return e;return a.length>0?a[0]:null}Vz.registerCommand(`_provideDocumentSemanticTokensLegend`,async(e,...t)=>{let[n]=t;gP(n instanceof dI);let r=e.get(Mz).getModel(n);if(!r)return;let{documentSemanticTokensProvider:i}=e.get(hH),a=W2n(i,r);return a?a[0].getLegend():e.get(Bz).executeCommand(`_provideDocumentRangeSemanticTokensLegend`,n)}),Vz.registerCommand(`_provideDocumentSemanticTokens`,async(e,...t)=>{let[n]=t;gP(n instanceof dI);let r=e.get(Mz).getModel(n);if(!r)return;let{documentSemanticTokensProvider:i}=e.get(hH);if(!V2n(i,r))return e.get(Bz).executeCommand(`_provideDocumentRangeSemanticTokens`,n,r.getFullModelRange());let a=await U2n(i,r,null,null,NF.None);if(!a)return;let{provider:o,tokens:s}=a;if(!s||!S5(s))return;let c=L2n({id:0,type:`full`,data:s.data});return s.resultId&&o.releaseDocumentSemanticTokens(s.resultId),c}),Vz.registerCommand(`_provideDocumentRangeSemanticTokensLegend`,async(e,...t)=>{let[n,r]=t;gP(n instanceof dI);let i=e.get(Mz).getModel(n);if(!i)return;let{documentRangeSemanticTokensProvider:a}=e.get(hH),o=q2n(a,i);if(o.length===0)return;if(o.length===1)return o[0].getLegend();if(!r||!J.isIRange(r))return console.warn(`provideDocumentRangeSemanticTokensLegend might be out-of-sync with provideDocumentRangeSemanticTokens unless a range argument is passed in`),o[0].getLegend();let s=await J2n(a,i,J.lift(r),NF.None);if(s)return s.provider.getLegend()}),Vz.registerCommand(`_provideDocumentRangeSemanticTokens`,async(e,...t)=>{let[n,r]=t;gP(n instanceof dI),gP(J.isIRange(r));let i=e.get(Mz).getModel(n);if(!i)return;let{documentRangeSemanticTokensProvider:a}=e.get(hH),o=await J2n(a,i,J.lift(r),NF.None);if(o&&o.tokens)return L2n({id:0,type:`full`,data:o.tokens.data})});var Y2n=`editor.semanticHighlighting`;function C5(e,t,n){let r=n.getValue(Y2n,{overrideIdentifier:e.getLanguageId(),resource:e.uri})?.enabled;return typeof r==`boolean`?r:t.getColorTheme().semanticHighlighting}var X2n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},w5=function(e,t){return function(n,r){t(n,r,e)}},T5,Z2n=class extends G{constructor(e,t,n,r,i,a){super(),this._watchers=new mB;let o=t=>{this._watchers.get(t.uri)?.dispose(),this._watchers.set(t.uri,new Q2n(t,e,n,i,a))},s=(e,t)=>{t.dispose(),this._watchers.delete(e.uri)},c=()=>{for(let e of t.getModels()){let t=this._watchers.get(e.uri);C5(e,n,r)?t||o(e):t&&s(e,t)}};t.getModels().forEach(e=>{C5(e,n,r)&&o(e)}),this._register(t.onModelAdded(e=>{C5(e,n,r)&&o(e)})),this._register(t.onModelRemoved(e=>{let t=this._watchers.get(e.uri);t&&s(e,t)})),this._register(r.onDidChangeConfiguration(e=>{e.affectsConfiguration(`editor.semanticHighlighting`)&&c()})),this._register(n.onDidColorThemeChange(c))}dispose(){UP(this._watchers.values()),this._watchers.clear(),super.dispose()}};Z2n=X2n([w5(0,qY),w5(1,Mz),w5(2,XG),w5(3,ZB),w5(4,HY),w5(5,hH)],Z2n);var Q2n=class extends G{static{T5=this}static{this.REQUEST_MIN_DELAY=300}static{this.REQUEST_MAX_DELAY=2e3}constructor(e,t,n,r,i){super(),this._semanticTokensStylingService=t,this._isDisposed=!1,this._model=e,this._provider=i.documentSemanticTokensProvider,this._debounceInformation=r.for(this._provider,`DocumentSemanticTokens`,{min:T5.REQUEST_MIN_DELAY,max:T5.REQUEST_MAX_DELAY}),this._fetchDocumentSemanticTokens=this._register(new HL(()=>this._fetchDocumentSemanticTokensNow(),T5.REQUEST_MIN_DELAY)),this._currentDocumentResponse=null,this._currentDocumentRequestCancellationTokenSource=null,this._documentProvidersChangeListeners=[],this._providersChangedDuringRequest=!1,this._register(this._model.onDidChangeContent(()=>{this._fetchDocumentSemanticTokens.isScheduled()||this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._register(this._model.onDidChangeAttached(()=>{this._fetchDocumentSemanticTokens.isScheduled()||this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._register(this._model.onDidChangeLanguage(()=>{this._currentDocumentResponse&&=(this._currentDocumentResponse.dispose(),null),this._currentDocumentRequestCancellationTokenSource&&=(this._currentDocumentRequestCancellationTokenSource.cancel(),null),this._setDocumentSemanticTokens(null,null,null,[]),this._fetchDocumentSemanticTokens.schedule(0)}));let a=()=>{UP(this._documentProvidersChangeListeners),this._documentProvidersChangeListeners=[];for(let t of this._provider.all(e))typeof t.onDidChange==`function`&&this._documentProvidersChangeListeners.push(t.onDidChange(()=>{if(this._currentDocumentRequestCancellationTokenSource){this._providersChangedDuringRequest=!0;return}this._fetchDocumentSemanticTokens.schedule(0)}))};a(),this._register(this._provider.onDidChange(()=>{a(),this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._register(n.onDidColorThemeChange(e=>{this._setDocumentSemanticTokens(null,null,null,[]),this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._fetchDocumentSemanticTokens.schedule(0)}dispose(){this._currentDocumentResponse&&=(this._currentDocumentResponse.dispose(),null),this._currentDocumentRequestCancellationTokenSource&&=(this._currentDocumentRequestCancellationTokenSource.cancel(),null),UP(this._documentProvidersChangeListeners),this._documentProvidersChangeListeners=[],this._setDocumentSemanticTokens(null,null,null,[]),this._isDisposed=!0,super.dispose()}_fetchDocumentSemanticTokensNow(){if(this._currentDocumentRequestCancellationTokenSource)return;if(!V2n(this._provider,this._model)){this._currentDocumentResponse&&this._model.tokenization.setSemanticTokens(null,!1);return}if(!this._model.isAttachedToEditor())return;let e=new FF,t=this._currentDocumentResponse?this._currentDocumentResponse.provider:null,n=this._currentDocumentResponse&&this._currentDocumentResponse.resultId||null,r=U2n(this._provider,this._model,t,n,e.token);this._currentDocumentRequestCancellationTokenSource=e,this._providersChangedDuringRequest=!1;let i=[],a=this._model.onDidChangeContent(e=>{i.push(e)}),o=new XP(!1);r.then(e=>{if(this._debounceInformation.update(this._model,o.elapsed()),this._currentDocumentRequestCancellationTokenSource=null,a.dispose(),!e)this._setDocumentSemanticTokens(null,null,null,i);else{let{provider:t,tokens:n}=e,r=this._semanticTokensStylingService.getStyling(t);this._setDocumentSemanticTokens(t,n||null,r,i)}},e=>{e&&(tP(e)||typeof e.message==`string`&&e.message.indexOf(`busy`)!==-1)||$N(e),this._currentDocumentRequestCancellationTokenSource=null,a.dispose(),(i.length>0||this._providersChangedDuringRequest)&&(this._fetchDocumentSemanticTokens.isScheduled()||this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model)))})}static _copy(e,t,n,r,i){i=Math.min(i,n.length-r,e.length-t);for(let a=0;a<i;a++)n[r+a]=e[t+a]}_setDocumentSemanticTokens(e,t,n,r){let i=this._currentDocumentResponse,a=()=>{(r.length>0||this._providersChangedDuringRequest)&&!this._fetchDocumentSemanticTokens.isScheduled()&&this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))};if(this._currentDocumentResponse&&=(this._currentDocumentResponse.dispose(),null),this._isDisposed){e&&t&&e.releaseDocumentSemanticTokens(t.resultId);return}if(!e||!n){this._model.tokenization.setSemanticTokens(null,!1);return}if(!t){this._model.tokenization.setSemanticTokens(null,!0),a();return}if(z2n(t)){if(!i){this._model.tokenization.setSemanticTokens(null,!0);return}if(t.edits.length===0)t={resultId:t.resultId,data:i.data};else{let e=0;for(let n of t.edits)e+=(n.data?n.data.length:0)-n.deleteCount;let r=i.data,a=new Uint32Array(r.length+e),o=r.length,s=a.length;for(let e=t.edits.length-1;e>=0;e--){let c=t.edits[e];if(c.start>r.length){n.warnInvalidEditStart(i.resultId,t.resultId,e,c.start,r.length),this._model.tokenization.setSemanticTokens(null,!0);return}let l=o-(c.start+c.deleteCount);l>0&&(T5._copy(r,o-l,a,s-l,l),s-=l),c.data&&(T5._copy(c.data,0,a,s-c.data.length,c.data.length),s-=c.data.length),o=c.start}o>0&&T5._copy(r,0,a,0,o),t={resultId:t.resultId,data:a}}}if(S5(t)){this._currentDocumentResponse=new $2n(e,t.resultId,t.data);let i=ivn(t,n,this._model.getLanguageId());if(r.length>0)for(let e of r)for(let t of i)for(let n of e.changes)t.applyEdit(n.range,n.text);this._model.tokenization.setSemanticTokens(i,!0)}else this._model.tokenization.setSemanticTokens(null,!0);a()}};Q2n=T5=X2n([w5(1,qY),w5(2,XG),w5(3,HY),w5(4,hH)],Q2n);var $2n=class{constructor(e,t,n){this.provider=e,this.resultId=t,this.data=n}dispose(){this.provider.releaseDocumentSemanticTokens(this.resultId)}};x0(Z2n);var e4n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},E5=function(e,t){return function(n,r){t(n,r,e)}},D5=class extends G{static{this.ID=`editor.contrib.viewportSemanticTokens`}constructor(e,t,n,r,i,a){super(),this._semanticTokensStylingService=t,this._themeService=n,this._configurationService=r,this._editor=e,this._provider=a.documentRangeSemanticTokensProvider,this._debounceInformation=i.for(this._provider,`DocumentRangeSemanticTokens`,{min:100,max:500}),this._tokenizeViewport=this._register(new HL(()=>this._tokenizeViewportNow(),100)),this._outstandingRequests=[],this._rangeProvidersChangeListeners=[];let o=()=>{this._editor.hasModel()&&this._tokenizeViewport.schedule(this._debounceInformation.get(this._editor.getModel()))},s=()=>{if(this._cleanupProviderListeners(),this._editor.hasModel()){let e=this._editor.getModel();for(let t of this._provider.all(e)){let e=t.onDidChange?.(()=>{this._cancelAll(),o()});e&&this._rangeProvidersChangeListeners.push(e)}}};this._register(this._editor.onDidScrollChange(()=>{o()})),this._register(this._editor.onDidChangeModel(()=>{s(),this._cancelAll(),o()})),this._register(this._editor.onDidChangeModelLanguage(()=>{s(),this._cancelAll(),o()})),this._register(this._editor.onDidChangeModelContent(e=>{this._cancelAll(),o()})),s(),this._register(this._provider.onDidChange(()=>{s(),this._cancelAll(),o()})),this._register(this._configurationService.onDidChangeConfiguration(e=>{e.affectsConfiguration(`editor.semanticHighlighting`)&&(this._cancelAll(),o())})),this._register(this._themeService.onDidColorThemeChange(()=>{this._cancelAll(),o()})),o()}dispose(){this._cleanupProviderListeners(),super.dispose()}_cleanupProviderListeners(){UP(this._rangeProvidersChangeListeners),this._rangeProvidersChangeListeners=[]}_cancelAll(){for(let e of this._outstandingRequests)e.cancel();this._outstandingRequests=[]}_removeOutstandingRequest(e){for(let t=0,n=this._outstandingRequests.length;t<n;t++)if(this._outstandingRequests[t]===e){this._outstandingRequests.splice(t,1);return}}_tokenizeViewportNow(){if(!this._editor.hasModel())return;let e=this._editor.getModel();if(e.tokenization.hasCompleteSemanticTokens())return;if(!C5(e,this._themeService,this._configurationService)){e.tokenization.hasSomeSemanticTokens()&&e.tokenization.setSemanticTokens(null,!1);return}if(!K2n(this._provider,e)){e.tokenization.hasSomeSemanticTokens()&&e.tokenization.setSemanticTokens(null,!1);return}let t=this._editor.getVisibleRangesPlusViewportAboveBelow();this._outstandingRequests=this._outstandingRequests.concat(t.map(t=>this._requestRange(e,t)))}_requestRange(e,t){let n=e.getVersionId(),r=PL(n=>Promise.resolve(J2n(this._provider,e,t,n))),i=new XP(!1);return r.then(r=>{if(this._debounceInformation.update(e,i.elapsed()),!r||!r.tokens||e.isDisposed()||e.getVersionId()!==n)return;let{provider:a,tokens:o}=r,s=this._semanticTokensStylingService.getStyling(a);e.tokenization.setPartialSemanticTokens(t,ivn(o,s,e.getLanguageId()))}).then(()=>this._removeOutstandingRequest(r),()=>this._removeOutstandingRequest(r)),r}};D5=e4n([E5(1,qY),E5(2,XG),E5(3,ZB),E5(4,HY),E5(5,hH)],D5),IB(D5.ID,D5,1);var t4n=class{constructor(e=!0){this.selectSubwords=e}provideSelectionRanges(e,t){let n=[];for(let r of t){let t=[];n.push(t),this.selectSubwords&&this._addInWordRanges(t,e,r),this._addWordRanges(t,e,r),this._addWhitespaceLine(t,e,r),t.push({range:e.getFullModelRange()})}return n}_addInWordRanges(e,t,n){let r=t.getWordAtPosition(n);if(!r)return;let{word:i,startColumn:a}=r,o=n.column-a,s=o,c=o,l=0;for(;s>=0;s--){let e=i.charCodeAt(s);if(s!==o&&(e===95||e===45)||ZI(e)&&QI(l))break;l=e}for(s+=1;c<i.length;c++){let e=i.charCodeAt(c);if(QI(e)&&ZI(l)||e===95||e===45)break;l=e}s<c&&e.push({range:new J(n.lineNumber,a+s,n.lineNumber,a+c)})}_addWordRanges(e,t,n){let r=t.getWordAtPosition(n);r&&e.push({range:new J(n.lineNumber,r.startColumn,n.lineNumber,r.endColumn)})}_addWhitespaceLine(e,t,n){t.getLineLength(n.lineNumber)>0&&t.getLineFirstNonWhitespaceColumn(n.lineNumber)===0&&t.getLineLastNonWhitespaceColumn(n.lineNumber)===0&&e.push({range:new J(n.lineNumber,1,n.lineNumber,t.getLineMaxColumn(n.lineNumber))})}},n4n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},r4n=function(e,t){return function(n,r){t(n,r,e)}},i4n,a4n=class e{constructor(e,t){this.index=e,this.ranges=t}mov(t){let n=this.index+(t?1:-1);if(n<0||n>=this.ranges.length)return this;let r=new e(n,this.ranges);return r.ranges[n].equalsRange(this.ranges[this.index])?r.mov(t):r}},O5=class{static{i4n=this}static{this.ID=`editor.contrib.smartSelectController`}static get(e){return e.getContribution(i4n.ID)}constructor(e,t){this._editor=e,this._languageFeaturesService=t,this._ignoreSelection=!1}dispose(){this._selectionListener?.dispose()}async run(e){if(!this._editor.hasModel())return;let t=this._editor.getSelections(),n=this._editor.getModel();if(this._state||await l4n(this._languageFeaturesService.selectionRangeProvider,n,t.map(e=>e.getPosition()),this._editor.getOption(129),NF.None).then(e=>{if(BN(e)&&e.length===t.length&&this._editor.hasModel()&&LN(this._editor.getSelections(),t,(e,t)=>e.equalsSelection(t))){for(let n=0;n<e.length;n++)e[n]=e[n].filter(e=>e.containsPosition(t[n].getStartPosition())&&e.containsPosition(t[n].getEndPosition())),e[n].unshift(t[n]);this._state=e.map(e=>new a4n(0,e)),this._selectionListener?.dispose(),this._selectionListener=this._editor.onDidChangeCursorPosition(()=>{this._ignoreSelection||(this._selectionListener?.dispose(),this._state=void 0)})}}),!this._state)return;this._state=this._state.map(t=>t.mov(e));let r=this._state.map(e=>gI.fromPositions(e.ranges[e.index].getStartPosition(),e.ranges[e.index].getEndPosition()));this._ignoreSelection=!0;try{this._editor.setSelections(r)}finally{this._ignoreSelection=!1}}};O5=i4n=n4n([r4n(1,hH)],O5);var o4n=class extends kB{constructor(e,t){super(t),this._forward=e}async run(e,t){let n=O5.get(t);n&&await n.run(this._forward)}},s4n=class extends o4n{constructor(){super(!0,{id:`editor.action.smartSelect.expand`,label:U(1400,`Expand Selection`),precondition:void 0,kbOpts:{kbExpr:$.editorTextFocus,primary:1553,mac:{primary:3345,secondary:[1297]},weight:100},menuOpts:{menuId:aB.MenubarSelectionMenu,group:`1_basic`,title:H(1398,`&&Expand Selection`),order:2}})}};Vz.registerCommandAlias(`editor.action.smartSelect.grow`,`editor.action.smartSelect.expand`);var c4n=class extends o4n{constructor(){super(!1,{id:`editor.action.smartSelect.shrink`,label:U(1401,`Shrink Selection`),precondition:void 0,kbOpts:{kbExpr:$.editorTextFocus,primary:1551,mac:{primary:3343,secondary:[1295]},weight:100},menuOpts:{menuId:aB.MenubarSelectionMenu,group:`1_basic`,title:H(1399,`&&Shrink Selection`),order:3}})}};IB(O5.ID,O5,4),PB(s4n),PB(c4n);async function l4n(e,t,n,r,i){let a=e.all(t).concat(new t4n(r.selectSubwords));a.length===1&&a.unshift(new wXn);let o=[],s=[];for(let e of a)o.push(Promise.resolve(e.provideSelectionRanges(t,n,i)).then(e=>{if(BN(e)&&e.length===n.length)for(let t=0;t<n.length;t++){s[t]||(s[t]=[]);for(let r of e[t])J.isIRange(r.range)&&J.containsPosition(r.range,n[t])&&s[t].push(J.lift(r.range))}},eP));return await Promise.all(o),s.map(e=>{if(e.length===0)return[];e.sort((e,t)=>q.isBefore(e.getStartPosition(),t.getStartPosition())?1:q.isBefore(t.getStartPosition(),e.getStartPosition())||q.isBefore(e.getEndPosition(),t.getEndPosition())?-1:+!!q.isBefore(t.getEndPosition(),e.getEndPosition()));let n=[],i;for(let t of e)(!i||J.containsRange(t,i)&&!J.equalsRange(t,i))&&(n.push(t),i=t);if(!r.selectLeadingAndTrailingWhitespace)return n;let a=[n[0]];for(let e=1;e<n.length;e++){let r=n[e-1],i=n[e];if(i.startLineNumber!==r.startLineNumber||i.endLineNumber!==r.endLineNumber){let e=new J(r.startLineNumber,t.getLineFirstNonWhitespaceColumn(r.startLineNumber),r.endLineNumber,t.getLineLastNonWhitespaceColumn(r.endLineNumber));e.containsRange(r)&&!e.equalsRange(r)&&i.containsRange(e)&&!i.equalsRange(e)&&a.push(e);let n=new J(r.startLineNumber,1,r.endLineNumber,t.getLineMaxColumn(r.endLineNumber));n.containsRange(r)&&!n.equalsRange(e)&&i.containsRange(n)&&!i.equalsRange(n)&&a.push(n)}a.push(i)}return a})}Vz.registerCommand(`_executeSelectionRangeProvider`,async function(e,...t){let[n,r]=t;gP(dI.isUri(n)),gP(D1t(r,e=>q.isIPosition(e)));let i=e.get(hH).selectionRangeProvider,a=await e.get(Nz).createModelReference(n);try{return l4n(i,a.object.textEditorModel,r.map(q.lift),{selectLeadingAndTrailingWhitespace:!0,selectSubwords:!0},NF.None)}finally{a.dispose()}});var u4n=Object.freeze({View:U(1638,`View`),Help:U(1639,`Help`),Test:U(1640,`Test`),File:U(1641,`File`),Preferences:U(1642,`Preferences`),Developer:U(1643,`Developer`)}),d4n=class extends jB{constructor(){super({id:`editor.action.toggleStickyScroll`,title:{...U(1448,`Toggle Editor Sticky Scroll`),mnemonicTitle:H(1444,`&&Toggle Editor Sticky Scroll`)},metadata:{description:U(1449,`Toggle/enable the editor sticky scroll which shows the nested scopes at the top of the viewport`)},category:u4n.View,toggled:{condition:Wz.equals(`config.editor.stickyScroll.enabled`,!0),title:H(1445,`Sticky Scroll`),mnemonicTitle:H(1446,`&&Sticky Scroll`)},menu:[{id:aB.CommandPalette},{id:aB.MenubarAppearanceMenu,group:`4_editor`,order:3},{id:aB.StickyScrollContext}]})}async runEditorCommand(e,t){let n=e.get(ZB),r=!n.getValue(`editor.stickyScroll.enabled`),i=C8.get(t)?.isFocused();n.updateValue(`editor.stickyScroll.enabled`,r),i&&t.focus()}},k5=100,f4n=class extends jB{constructor(){super({id:`editor.action.focusStickyScroll`,title:{...U(1450,`Focus Editor Sticky Scroll`),mnemonicTitle:H(1447,`&&Focus Editor Sticky Scroll`)},precondition:Wz.and(Wz.has(`config.editor.stickyScroll.enabled`),$.stickyScrollVisible),menu:[{id:aB.CommandPalette}]})}runEditorCommand(e,t){C8.get(t)?.focus()}},p4n=class extends jB{constructor(){super({id:`editor.action.selectNextStickyScrollLine`,title:U(1451,`Select the next editor sticky scroll line`),precondition:$.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:k5,primary:18}})}runEditorCommand(e,t){C8.get(t)?.focusNext()}},m4n=class extends jB{constructor(){super({id:`editor.action.selectPreviousStickyScrollLine`,title:U(1452,`Select the previous sticky scroll line`),precondition:$.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:k5,primary:16}})}runEditorCommand(e,t){C8.get(t)?.focusPrevious()}},h4n=class extends jB{constructor(){super({id:`editor.action.goToFocusedStickyScrollLine`,title:U(1453,`Go to the focused sticky scroll line`),precondition:$.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:k5,primary:3}})}runEditorCommand(e,t){C8.get(t)?.goToFocused()}},g4n=class extends jB{constructor(){super({id:`editor.action.selectEditor`,title:U(1454,`Select Editor`),precondition:$.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:k5,primary:9}})}runEditorCommand(e,t){C8.get(t)?.selectEditor()}};IB(C8.ID,C8,1),fB(d4n),fB(f4n),fB(m4n),fB(p4n),fB(h4n),fB(g4n);var _4n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},A5=function(e,t){return function(n,r){t(n,r,e)}},v4n=class{constructor(e,t,n,r,i,a,o){this.range=e,this.insertText=t,this.filterText=n,this.additionalTextEdits=r,this.command=i,this.gutterMenuLinkAction=a,this.completion=o}},y4n=class extends c0t{constructor(e,t,n,r,i,a){super(i.disposable),this.model=e,this.line=t,this.word=n,this.completionModel=r,this._suggestMemoryService=a}canBeReused(e,t,n){return this.model===e&&this.line===t&&this.word.word.length>0&&this.word.startColumn===n.startColumn&&this.word.endColumn<n.endColumn&&this.completionModel.getIncompleteProvider().size===0}get items(){let e=[],{items:t}=this.completionModel,n=this._suggestMemoryService.select(this.model,{lineNumber:this.line,column:this.word.endColumn+this.completionModel.lineContext.characterCountDelta},t),r=BP.slice(t,n),i=BP.slice(t,0,n),a=5;for(let t of BP.concat(r,i)){if(t.score===LX.Default)continue;let n=new J(t.editStart.lineNumber,t.editStart.column,t.editInsertEnd.lineNumber,t.editInsertEnd.column+this.completionModel.lineContext.characterCountDelta),r=t.completion.insertTextRules&&t.completion.insertTextRules&4?{snippet:t.completion.insertText}:t.completion.insertText;e.push(new v4n(n,r,t.filterTextLow??t.labelLow,t.completion.additionalTextEdits,t.completion.command,t.completion.action,t)),a-->=0&&t.resolve(NF.None)}return e}};y4n=_4n([A5(5,Q6)],y4n);var b4n=class extends G{constructor(e,t,n,r){super(),this._languageFeatureService=e,this._clipboardService=t,this._suggestMemoryService=n,this._editorService=r,this._store.add(e.inlineCompletionsProvider.register(`*`,this))}async provideInlineCompletions(e,t,n,r){if(n.selectedSuggestionInfo)return;let i;for(let t of this._editorService.listCodeEditors())if(t.getModel()===e){i=t;break}if(!i)return;let a=i.getOption(102);if(T6.isAllOff(a))return;e.tokenization.tokenizeIfCheap(t.lineNumber);let o=e.tokenization.getLineTokens(t.lineNumber),s=o.getStandardTokenType(o.findTokenIndexAtOffset(Math.max(t.column-1-1,0)));if(T6.valueFor(a,s)!==`inline`)return;let c=e.getWordAtPosition(t),l;if(c?.word||(l=this._getTriggerCharacterInfo(e,t)),!c?.word&&!l||(c||=e.getWordUntilPosition(t),c.endColumn!==t.column))return;let u,d=e.getValueInRange(new J(t.lineNumber,1,t.lineNumber,t.column));if(!l&&this._lastResult?.canBeReused(e,t.lineNumber,c)){let e=new EXn(d,t.column-this._lastResult.word.endColumn);this._lastResult.completionModel.lineContext=e,this._lastResult.acquire(),u=this._lastResult}else{let n=await Nqn(this._languageFeatureService.completionProvider,e,t,new jqn(void 0,i8.createSuggestFilter(i).itemKind,l?.providers),l&&{triggerKind:1,triggerCharacter:l.ch},r),a;n.needsClipboard&&(a=await this._clipboardService.readText());let o=new DXn(n.items,t.column,new EXn(d,0),TXn.None,i.getOption(134),i.getOption(128),{boostFullMatch:!1,firstMatchCanBeWeak:!1},a);u=new y4n(e,t.lineNumber,c,o,n,this._suggestMemoryService)}return this._lastResult=u,u}handleItemDidShow(e,t){t.completion.resolve(NF.None)}disposeInlineCompletions(e){e.release()}_getTriggerCharacterInfo(e,t){let n=e.getValueInRange(J.fromPositions({lineNumber:t.lineNumber,column:t.column-1},t)),r=new Set;for(let t of this._languageFeatureService.completionProvider.all(e))t.triggerCharacters?.includes(n)&&r.add(t);if(r.size!==0)return{providers:r,ch:n}}};b4n=_4n([A5(0,hH),A5(1,h0),A5(2,Q6),A5(3,jz)],b4n),x0(b4n),PB(class extends kB{constructor(){super({id:`editor.action.forceRetokenize`,label:U(1532,`Developer: Force Retokenize`),precondition:void 0})}run(e,t){if(!t.hasModel())return;let n=t.getModel();n.tokenization.resetTokenization();let r=new XP;n.tokenization.forceTokenization(n.getLineCount()),r.stop(),console.log(`tokenization took ${r.elapsed()}`)}}),fB(class e extends dB{static{this.ID=`editor.action.toggleTabFocusMode`}constructor(){super({id:e.ID,title:U(1530,`Toggle Tab Key Moves Focus`),precondition:void 0,keybinding:{primary:2091,mac:{primary:1323},weight:100},metadata:{description:U(1531,`Determines whether the tab key moves focus around the workbench or inserts the tab character in the current editor. This is also called tab trapping, tab navigation, or tab focus mode.`)},f1:!0})}run(){let e=!XH.getTabFocusMode();XH.setTabFocusMode(e),WH(e?H(1528,`Pressing Tab will now move focus to the next focusable element`):H(1529,`Pressing Tab will now insert the tab character`))}});var x4n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},S4n=function(e,t){return function(n,r){t(n,r,e)}},C4n=class extends G{get enabled(){return this._enabled}set enabled(e){e?(this.el.setAttribute(`aria-disabled`,`false`),this.el.tabIndex=0,this.el.style.pointerEvents=`auto`,this.el.style.opacity=`1`,this.el.style.cursor=`pointer`,this._enabled=!1):(this.el.setAttribute(`aria-disabled`,`true`),this.el.tabIndex=-1,this.el.style.pointerEvents=`none`,this.el.style.opacity=`0.4`,this.el.style.cursor=`default`,this._enabled=!0),this._enabled=e}constructor(e,t,n={},r,i){super(),this._link=t,this._hoverService=r,this._enabled=!0,this.el=uz(e,mz(`a.monaco-link`,{tabIndex:t.tabIndex??0,href:t.href},t.label)),this.hoverDelegate=n.hoverDelegate??$Q(`mouse`),this.setTooltip(t.title),this.el.setAttribute(`role`,`button`);let a=this._register(new WW(this.el,`click`)),o=this._register(new WW(this.el,`keypress`)),s=ZP.chain(o.event,e=>e.map(e=>new AL(e)).filter(e=>e.keyCode===3)),c=this._register(new WW(this.el,PW.Tap)).event;this._register(FW.addTarget(this.el));let l=ZP.any(a.event,s,c);this._register(l(e=>{this.enabled&&(cz.stop(e,!0),n?.opener?n.opener(this._link.href):i.open(this._link.href,{allowCommands:!0}))})),this.enabled=!0}setTooltip(e){!this.hover&&e?this.hover=this._register(this._hoverService.setupManagedHover(this.hoverDelegate,this.el,e)):this.hover&&this.hover.update(e)}};C4n=x4n([S4n(3,iX),S4n(4,nQ)],C4n);var w4n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},T4n=function(e,t){return function(n,r){t(n,r,e)}},E4n=26,D4n=class extends G{constructor(e,t){super(),this._editor=e,this.instantiationService=t,this.banner=this._register(this.instantiationService.createInstance(O4n))}hide(){this._editor.setBanner(null,0),this.banner.clear()}show(e){this.banner.show({...e,onClose:()=>{this.hide(),e.onClose?.()}}),this._editor.setBanner(this.banner.element,E4n)}};D4n=w4n([T4n(1,kz)],D4n);var O4n=class extends G{constructor(e,t){super(),this.instantiationService=e,this.markdownRendererService=t,this.element=mz(`div.editor-banner`),this.element.tabIndex=0}getAriaLabel(e){if(e.ariaLabel)return e.ariaLabel;if(typeof e.message==`string`)return e.message}getBannerMessage(e){if(typeof e==`string`){let t=mz(`span`);return t.innerText=e,t}return this.markdownRendererService.render(e).element}clear(){BR(this.element)}show(e){BR(this.element);let t=this.getAriaLabel(e);t&&this.element.setAttribute(`aria-label`,t);let n=uz(this.element,mz(`div.icon-container`));n.setAttribute(`aria-hidden`,`true`),e.icon&&n.appendChild(mz(`div${zz.asCSSSelector(e.icon)}`));let r=uz(this.element,mz(`div.message-container`));if(r.setAttribute(`aria-hidden`,`true`),r.appendChild(this.getBannerMessage(e.message)),this.messageActionsContainer=uz(this.element,mz(`div.message-actions-container`)),e.actions)for(let t of e.actions)this._register(this.instantiationService.createInstance(C4n,this.messageActionsContainer,{...t,tabIndex:-1},{}));let i=uz(this.element,mz(`div.action-container`));this.actionBar=this._register(new O$(i)),this.actionBar.push(this._register(new Pz(`banner.close`,H(1533,`Close Banner`),zz.asClassName(BAn),!0,()=>{typeof e.onClose==`function`&&e.onClose()})),{icon:!0,label:!1}),this.actionBar.setFocusable(!1)}};O4n=w4n([T4n(0,kz),T4n(1,rQ)],O4n);var k4n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},j5=function(e,t){return function(n,r){t(n,r,e)}},A4n=r0(`extensions-warning-message`,vI.warning,H(1534,`Icon shown with a warning message in the extensions editor.`)),M5=class extends G{static{this.ID=`editor.contrib.unicodeHighlighter`}constructor(e,t,n,r){super(),this._editor=e,this._editorWorkerService=t,this._workspaceTrustService=n,this._highlighter=null,this._bannerClosed=!1,this._updateState=e=>{if(e&&e.hasMore){if(this._bannerClosed)return;let t=Math.max(e.ambiguousCharacterCount,e.nonBasicAsciiCharacterCount,e.invisibleCharacterCount),n;if(e.nonBasicAsciiCharacterCount>=t)n={message:H(1535,`This document contains many non-basic ASCII unicode characters`),command:new W4n};else if(e.ambiguousCharacterCount>=t)n={message:H(1536,`This document contains many ambiguous unicode characters`),command:new N5};else if(e.invisibleCharacterCount>=t)n={message:H(1537,`This document contains many invisible unicode characters`),command:new U4n};else throw Error(`Unreachable`);this._bannerController.show({id:`unicodeHighlightBanner`,message:n.message,icon:A4n,actions:[{label:n.command.shortLabel,href:`command:${n.command.desc.id}`}],onClose:()=>{this._bannerClosed=!0}})}else this._bannerController.hide()},this._bannerController=this._register(r.createInstance(D4n,e)),this._register(this._editor.onDidChangeModel(()=>{this._bannerClosed=!1,this._updateHighlighter()})),this._options=e.getOption(142),this._register(n.onDidChangeTrust(e=>{this._updateHighlighter()})),this._register(e.onDidChangeConfiguration(t=>{t.hasChanged(142)&&(this._options=e.getOption(142),this._updateHighlighter())})),this._updateHighlighter()}dispose(){this._highlighter&&=(this._highlighter.dispose(),null),super.dispose()}_updateHighlighter(){if(this._updateState(null),this._highlighter&&=(this._highlighter.dispose(),null),!this._editor.hasModel())return;let e=j4n(this._workspaceTrustService.isWorkspaceTrusted(),this._options);if([e.nonBasicASCII,e.ambiguousCharacters,e.invisibleCharacters].every(e=>e===!1))return;let t={nonBasicASCII:e.nonBasicASCII,ambiguousCharacters:e.ambiguousCharacters,invisibleCharacters:e.invisibleCharacters,includeComments:e.includeComments,includeStrings:e.includeStrings,allowedCodePoints:Object.keys(e.allowedCharacters).map(e=>e.codePointAt(0)),allowedLocales:Object.keys(e.allowedLocales).map(e=>e===`_os`?CV.NumberFormat().value.resolvedOptions().locale:e===`_vscode`?Z1t:e)};this._highlighter=this._editorWorkerService.canComputeUnicodeHighlights(this._editor.getModel().uri)?new M4n(this._editor,t,this._updateState,this._editorWorkerService):new N4n(this._editor,t,this._updateState)}getDecorationInfo(e){return this._highlighter?this._highlighter.getDecorationInfo(e):null}};M5=k4n([j5(1,j$),j5(2,RCn),j5(3,kz)],M5);function j4n(e,t){return{nonBasicASCII:t.nonBasicASCII===`inUntrustedWorkspace`?!e:t.nonBasicASCII,ambiguousCharacters:t.ambiguousCharacters,invisibleCharacters:t.invisibleCharacters,includeComments:t.includeComments===`inUntrustedWorkspace`?!e:t.includeComments,includeStrings:t.includeStrings===`inUntrustedWorkspace`?!e:t.includeStrings,allowedCharacters:t.allowedCharacters,allowedLocales:t.allowedLocales}}var M4n=class extends G{constructor(e,t,n,r){super(),this._editor=e,this._options=t,this._updateState=n,this._editorWorkerService=r,this._model=this._editor.getModel(),this._decorations=this._editor.createDecorationsCollection(),this._updateSoon=this._register(new HL(()=>this._update(),250)),this._register(this._editor.onDidChangeModelContent(()=>{this._updateSoon.schedule()})),this._updateSoon.schedule()}dispose(){this._decorations.clear(),super.dispose()}_update(){if(this._model.isDisposed())return;if(!this._model.mightContainNonBasicASCII()){this._decorations.clear();return}let e=this._model.getVersionId();this._editorWorkerService.computedUnicodeHighlights(this._model.uri,this._options).then(t=>{if(this._model.isDisposed()||this._model.getVersionId()!==e)return;this._updateState(t);let n=[];if(!t.hasMore)for(let e of t.ranges)n.push({range:e,options:B4n.instance.getDecorationFromOptions(this._options)});this._decorations.set(n)})}getDecorationInfo(e){if(!this._decorations.has(e))return null;let t=this._editor.getModel();return hK(t,e)?{reason:z4n(t.getValueInRange(e.range),this._options),inComment:gK(t,e),inString:_K(t,e)}:null}};M4n=k4n([j5(3,j$)],M4n);var N4n=class extends G{constructor(e,t,n){super(),this._editor=e,this._options=t,this._updateState=n,this._model=this._editor.getModel(),this._decorations=this._editor.createDecorationsCollection(),this._updateSoon=this._register(new HL(()=>this._update(),250)),this._register(this._editor.onDidLayoutChange(()=>{this._updateSoon.schedule()})),this._register(this._editor.onDidScrollChange(()=>{this._updateSoon.schedule()})),this._register(this._editor.onDidChangeHiddenAreas(()=>{this._updateSoon.schedule()})),this._register(this._editor.onDidChangeModelContent(()=>{this._updateSoon.schedule()})),this._updateSoon.schedule()}dispose(){this._decorations.clear(),super.dispose()}_update(){if(this._model.isDisposed())return;if(!this._model.mightContainNonBasicASCII()){this._decorations.clear();return}let e=this._editor.getVisibleRanges(),t=[],n={ranges:[],ambiguousCharacterCount:0,invisibleCharacterCount:0,nonBasicAsciiCharacterCount:0,hasMore:!1};for(let t of e){let e=etn.computeUnicodeHighlights(this._model,this._options,t);for(let t of e.ranges)n.ranges.push(t);n.ambiguousCharacterCount+=n.ambiguousCharacterCount,n.invisibleCharacterCount+=n.invisibleCharacterCount,n.nonBasicAsciiCharacterCount+=n.nonBasicAsciiCharacterCount,n.hasMore=n.hasMore||e.hasMore}if(!n.hasMore)for(let e of n.ranges)t.push({range:e,options:B4n.instance.getDecorationFromOptions(this._options)});this._updateState(n),this._decorations.set(t)}getDecorationInfo(e){if(!this._decorations.has(e))return null;let t=this._editor.getModel(),n=t.getValueInRange(e.range);return hK(t,e)?{reason:z4n(n,this._options),inComment:gK(t,e),inString:_K(t,e)}:null}},P4n=H(1538,`Configure Unicode Highlight Options`),F4n=class{constructor(e,t){this._editor=e,this._markdownRendererService=t,this.hoverOrdinal=5}computeSync(e,t){if(!this._editor.hasModel()||e.type!==1)return[];let n=this._editor.getModel(),r=this._editor.getContribution(M5.ID);if(!r)return[];let i=[],a=new Set,o=300;for(let e of t){let t=r.getDecorationInfo(e);if(!t)continue;let s=n.getValueInRange(e.range).codePointAt(0),c=L4n(s),l;switch(t.reason.kind){case 0:l=dL(t.reason.confusableWith)?H(1539,`The character {0} could be confused with the ASCII character {1}, which is more common in source code.`,c,L4n(t.reason.confusableWith.codePointAt(0))):H(1540,`The character {0} could be confused with the character {1}, which is more common in source code.`,c,L4n(t.reason.confusableWith.codePointAt(0)));break;case 1:l=H(1541,`The character {0} is invisible.`,c);break;case 2:l=H(1542,`The character {0} is not a basic ASCII character.`,c)}if(a.has(l))continue;a.add(l);let u={codePoint:s,reason:t.reason,inComment:t.inComment,inString:t.inString},d=H(1543,`Adjust settings`),f=Myn(G4n.ID,u),p=new GX(``,!0).appendMarkdown(l).appendText(` `).appendLink(f,d,P4n);i.push(new H4(this,e.range,[p],!1,o++))}return i}renderHoverParts(e,t){return gHn(e,t,this._editor,this._markdownRendererService)}getAccessibleContent(e){return e.contents.map(e=>e.value).join(`
1481
1481
  `)}};F4n=k4n([j5(1,rQ)],F4n);function I4n(e){return`U+${e.toString(16).padStart(4,`0`)}`}function L4n(e){let t=`\`${I4n(e)}\``;return gL.isInvisibleCharacter(e)||(t+=` "${`${R4n(e)}`}"`),t}function R4n(e){return e===96?"`` ` ``":"`"+String.fromCodePoint(e)+"`"}function z4n(e,t){return etn.computeUnicodeHighlightReason(e,t)}var B4n=class e{constructor(){this.map=new Map}static{this.instance=new e}getDecorationFromOptions(e){return this.getDecoration(!e.includeComments,!e.includeStrings)}getDecoration(e,t){let n=`${e}${t}`,r=this.map.get(n);return r||(r=aY.createDynamic({description:`unicode-highlight`,stickiness:1,className:`unicode-highlight`,showIfCollapsed:!0,overviewRuler:null,minimap:null,hideInCommentTokens:e,hideInStringTokens:t}),this.map.set(n,r)),r}},V4n=class extends kB{constructor(){super({id:N5.ID,label:U(1552,`Disable highlighting of characters in comments`),precondition:void 0}),this.shortLabel=H(1544,`Disable Highlight In Comments`)}async run(e,t,n){let r=e.get(ZB);r&&this.runAction(r)}async runAction(e){await e.updateValue(OF.includeComments,!1,2)}},H4n=class extends kB{constructor(){super({id:N5.ID,label:U(1553,`Disable highlighting of characters in strings`),precondition:void 0}),this.shortLabel=H(1545,`Disable Highlight In Strings`)}async run(e,t,n){let r=e.get(ZB);r&&this.runAction(r)}async runAction(e){await e.updateValue(OF.includeStrings,!1,2)}},N5=class e extends dB{static{this.ID=`editor.action.unicodeHighlight.disableHighlightingOfAmbiguousCharacters`}constructor(){super({id:e.ID,title:U(1554,`Disable highlighting of ambiguous characters`),precondition:void 0,f1:!1}),this.shortLabel=H(1546,`Disable Ambiguous Highlight`)}async run(e,t,n){let r=e.get(ZB);r&&this.runAction(r)}async runAction(e){await e.updateValue(OF.ambiguousCharacters,!1,2)}},U4n=class e extends dB{static{this.ID=`editor.action.unicodeHighlight.disableHighlightingOfInvisibleCharacters`}constructor(){super({id:e.ID,title:U(1555,`Disable highlighting of invisible characters`),precondition:void 0,f1:!1}),this.shortLabel=H(1547,`Disable Invisible Highlight`)}async run(e,t,n){let r=e.get(ZB);r&&this.runAction(r)}async runAction(e){await e.updateValue(OF.invisibleCharacters,!1,2)}},W4n=class e extends dB{static{this.ID=`editor.action.unicodeHighlight.disableHighlightingOfNonBasicAsciiCharacters`}constructor(){super({id:e.ID,title:U(1556,`Disable highlighting of non basic ASCII characters`),precondition:void 0,f1:!1}),this.shortLabel=H(1548,`Disable Non ASCII Highlight`)}async run(e,t,n){let r=e.get(ZB);r&&this.runAction(r)}async runAction(e){await e.updateValue(OF.nonBasicASCII,!1,2)}},G4n=class e extends dB{static{this.ID=`editor.action.unicodeHighlight.showExcludeOptions`}constructor(){super({id:e.ID,title:U(1557,`Show Exclude Options`),precondition:void 0,f1:!1})}async run(e,t){let{codePoint:n,reason:r,inString:i,inComment:a}=t,o=String.fromCodePoint(n),s=e.get(_Q),c=e.get(ZB);function l(e){return gL.isInvisibleCharacter(e)?H(1549,`Exclude {0} (invisible character) from being highlighted`,I4n(e)):H(1550,`Exclude {0} from being highlighted`,`${I4n(e)} "${o}"`)}let u=[];if(r.kind===0)for(let e of r.notAmbiguousInLocales)u.push({label:H(1551,`Allow unicode characters that are more common in the language "{0}".`,e),run:async()=>{q4n(c,[e])}});if(u.push({label:l(n),run:()=>K4n(c,[n])}),a){let e=new V4n;u.push({label:e.label,run:async()=>e.runAction(c)})}else if(i){let e=new H4n;u.push({label:e.label,run:async()=>e.runAction(c)})}function d(e){return typeof e.desc.title==`string`?e.desc.title:e.desc.title.value}if(r.kind===0){let e=new N5;u.push({label:d(e),run:async()=>e.runAction(c)})}else if(r.kind===1){let e=new U4n;u.push({label:d(e),run:async()=>e.runAction(c)})}else if(r.kind===2){let e=new W4n;u.push({label:d(e),run:async()=>e.runAction(c)})}else J4n(r);let f=await s.pick(u,{title:P4n});f&&await f.run()}};async function K4n(e,t){let n=e.getValue(OF.allowedCharacters),r;r=typeof n==`object`&&n?n:{};for(let e of t)r[String.fromCodePoint(e)]=!0;await e.updateValue(OF.allowedCharacters,r,2)}async function q4n(e,t){let n=e.inspect(OF.allowedLocales).user?.value,r;r=typeof n==`object`&&n?Object.assign({},n):{};for(let e of t)r[e]=!0;await e.updateValue(OF.allowedLocales,r,2)}function J4n(e){throw Error(`Unexpected value: ${e}`)}fB(N5),fB(U4n),fB(W4n),fB(G4n),IB(M5.ID,M5,1),h4.register(F4n);var Y4n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},X4n=function(e,t){return function(n,r){t(n,r,e)}},Z4n=`ignoreUnusualLineTerminators`;function Q4n(e,t,n){e.setModelProperty(t.uri,Z4n,n)}function $4n(e,t){return e.getModelProperty(t.uri,Z4n)}var P5=class extends G{static{this.ID=`editor.contrib.unusualLineTerminatorsDetector`}constructor(e,t,n){super(),this._editor=e,this._dialogService=t,this._codeEditorService=n,this._isPresentingDialog=!1,this._config=this._editor.getOption(143),this._register(this._editor.onDidChangeConfiguration(e=>{e.hasChanged(143)&&(this._config=this._editor.getOption(143),this._checkForUnusualLineTerminators())})),this._register(this._editor.onDidChangeModel(()=>{this._checkForUnusualLineTerminators()})),this._register(this._editor.onDidChangeModelContent(e=>{e.isUndoing||this._checkForUnusualLineTerminators()})),this._checkForUnusualLineTerminators()}async _checkForUnusualLineTerminators(){if(this._config===`off`||!this._editor.hasModel())return;let e=this._editor.getModel();if(!e.mightContainUnusualLineTerminators()||$4n(this._codeEditorService,e)===!0||this._editor.getOption(104))return;if(this._config===`auto`){e.removeUnusualLineTerminators(this._editor.getSelections());return}if(this._isPresentingDialog)return;let t;try{this._isPresentingDialog=!0,t=await this._dialogService.confirm({title:H(1558,`Unusual Line Terminators`),message:H(1559,`Detected unusual line terminators`),detail:H(1560,`The file '{0}' contains one or more unusual line terminator characters, like Line Separator (LS) or Paragraph Separator (PS).
1482
1482
 
1483
- It is recommended to remove them from the file. This can be configured via \`editor.unusualLineTerminators\`.`,xB(e.uri)),primaryButton:H(1561,`&&Remove Unusual Line Terminators`),cancelButton:H(1562,`Ignore`)})}finally{this._isPresentingDialog=!1}if(!t.confirmed){Q4n(this._codeEditorService,e,!0);return}e.removeUnusualLineTerminators(this._editor.getSelections())}};P5=Y4n([X4n(1,PY),X4n(2,jz)],P5),IB(P5.ID,P5,1);var e3n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},t3n=function(e,t){return function(n,r){t(n,r,e)}},n3n=class{constructor(){this.selector={language:`*`}}provideDocumentHighlights(e,t,n){let r=[],i=e.getWordAtPosition({lineNumber:t.lineNumber,column:t.column});if(!i)return Promise.resolve(r);if(!e.isDisposed())return e.findMatches(i.word,!0,!1,!0,oF,!1).map(e=>({range:e.range,kind:OI.Text}))}provideMultiDocumentHighlights(e,t,n,r){let i=new mB,a=e.getWordAtPosition({lineNumber:t.lineNumber,column:t.column});if(!a)return Promise.resolve(i);for(let t of[e,...n]){if(t.isDisposed())continue;let e=t.findMatches(a.word,!0,!1,!0,oF,!1).map(e=>({range:e.range,kind:OI.Text}));e&&i.set(t.uri,e)}return i}},r3n=class extends G{constructor(e){super(),this._register(e.documentHighlightProvider.register(`*`,new n3n)),this._register(e.multiDocumentHighlightProvider.register(`*`,new n3n))}};r3n=e3n([t3n(0,hH)],r3n);var i3n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},F5=function(e,t){return function(n,r){t(n,r,e)}},I5,a3n,o3n=new Qz(`hasWordHighlights`,!1);function s3n(e,t,n,r){return zL(e.ordered(t).map(e=>()=>Promise.resolve(e.provideDocumentHighlights(t,n,r)).then(void 0,eP)),e=>e!=null).then(e=>{if(e){let n=new mB;return n.set(t.uri,e),n}return new mB})}function c3n(e,t,n,r,i){return zL(e.ordered(t).map(e=>()=>{let a=i.filter(e=>qen(e)).filter(t=>tX(e.selector,t.uri,t.getLanguageId(),!0,void 0,void 0)>0);return Promise.resolve(e.provideMultiDocumentHighlights(t,n,a,r)).then(void 0,eP)}),e=>e!=null)}var l3n=class{constructor(e,t,n){this._model=e,this._selection=t,this._wordSeparators=n,this._wordRange=this._getCurrentWordRange(e,t),this._result=null}get result(){return this._result||=PL(e=>this._compute(this._model,this._selection,this._wordSeparators,e)),this._result}_getCurrentWordRange(e,t){let n=e.getWordAtPosition(t.getPosition());return n?new J(t.startLineNumber,n.startColumn,t.startLineNumber,n.endColumn):null}cancel(){this.result.cancel()}},u3n=class extends l3n{constructor(e,t,n,r){super(e,t,n),this._providers=r}_compute(e,t,n,r){return s3n(this._providers,e,t.getPosition(),r).then(e=>e||new mB)}},d3n=class extends l3n{constructor(e,t,n,r,i){super(e,t,n),this._providers=r,this._otherModels=i}_compute(e,t,n,r){return c3n(this._providers,e,t.getPosition(),r,this._otherModels).then(e=>e||new mB)}};function f3n(e,t,n,r){return new u3n(t,n,r,e)}function p3n(e,t,n,r,i){return new d3n(t,n,r,e,i)}MB(`_executeDocumentHighlights`,async(e,t,n)=>(await s3n(e.get(hH).documentHighlightProvider,t,n,NF.None))?.get(t.uri));var m3n=class{static{I5=this}static{this.storedDecorationIDs=new mB}static{this.query=null}constructor(e,t,n,r,i,a,o,s){this.toUnhook=new W,this.workerRequestTokenId=0,this.workerRequestCompleted=!1,this.workerRequestValue=new mB,this.lastCursorPositionChangeTime=0,this.renderDecorationsTimer=void 0,this.runDelayer=this.toUnhook.add(new IL(50)),this.editor=e,this.providers=t,this.multiDocumentProviders=n,this.codeEditorService=a,this.textModelService=i,this.configurationService=o,this.logService=s,this._hasWordHighlights=o3n.bindTo(r),this._ignorePositionChangeEvent=!1,this.occurrencesHighlightEnablement=this.editor.getOption(90),this.occurrencesHighlightDelay=this.configurationService.getValue(`editor.occurrencesHighlightDelay`),this.model=this.editor.getModel(),this.toUnhook.add(e.onDidChangeCursorPosition(e=>{this._ignorePositionChangeEvent||this.occurrencesHighlightEnablement!==`off`&&this.runDelayer.trigger(()=>{this._onPositionChanged(e)})})),this.toUnhook.add(e.onDidFocusEditorText(e=>{this.occurrencesHighlightEnablement!==`off`&&(this.workerRequest||this.runDelayer.trigger(()=>{this._run()}))})),this.toUnhook.add(e.onDidChangeModelContent(e=>{YL(this.model.uri,`output`)||this._stopAll()})),this.toUnhook.add(e.onDidChangeModel(e=>{!e.newModelUrl&&e.oldModelUrl?this._stopSingular():I5.query&&this._run()})),this.toUnhook.add(e.onDidChangeConfiguration(e=>{let t=this.editor.getOption(90);if(this.occurrencesHighlightEnablement!==t)switch(this.occurrencesHighlightEnablement=t,t){case`off`:this._stopAll();break;case`singleFile`:this._stopAll(I5.query?.modelInfo?.modelURI);break;case`multiFile`:I5.query&&this._run(!0);break;default:console.warn(`Unknown occurrencesHighlight setting value:`,t)}})),this.toUnhook.add(this.configurationService.onDidChangeConfiguration(e=>{if(e.affectsConfiguration(`editor.occurrencesHighlightDelay`)){let e=o.getValue(`editor.occurrencesHighlightDelay`);this.occurrencesHighlightDelay!==e&&(this.occurrencesHighlightDelay=e)}})),this.toUnhook.add(e.onDidBlurEditorWidget(()=>{let e=this.codeEditorService.getFocusedCodeEditor();e?e.getModel()?.uri.scheme===JL.vscodeNotebookCell&&this.editor.getModel()?.uri.scheme!==JL.vscodeNotebookCell&&this._stopAll():this._stopAll()})),this.decorations=this.editor.createDecorationsCollection(),this.workerRequestTokenId=0,this.workerRequest=null,this.workerRequestCompleted=!1,this.lastCursorPositionChangeTime=0,this.renderDecorationsTimer=void 0,I5.query&&this._run()}hasDecorations(){return this.decorations.length>0}restore(e){this.occurrencesHighlightEnablement!==`off`&&(this.runDelayer.cancel(),this.runDelayer.trigger(()=>{this._run(!1,e)}))}stop(){this.occurrencesHighlightEnablement!==`off`&&this._stopAll()}_getSortedHighlights(){return this.decorations.getRanges().sort(J.compareRangesUsingStarts)}moveNext(){let e=this._getSortedHighlights(),t=(e.findIndex(e=>e.containsPosition(this.editor.getPosition()))+1)%e.length,n=e[t];try{this._ignorePositionChangeEvent=!0,this.editor.setPosition(n.getStartPosition()),this.editor.revealRangeInCenterIfOutsideViewport(n);let r=this._getWord();r&&WH(`${this.editor.getModel().getLineContent(n.startLineNumber)}, ${t+1} of ${e.length} for '${r.word}'`)}finally{this._ignorePositionChangeEvent=!1}}moveBack(){let e=this._getSortedHighlights(),t=(e.findIndex(e=>e.containsPosition(this.editor.getPosition()))-1+e.length)%e.length,n=e[t];try{this._ignorePositionChangeEvent=!0,this.editor.setPosition(n.getStartPosition()),this.editor.revealRangeInCenterIfOutsideViewport(n);let r=this._getWord();r&&WH(`${this.editor.getModel().getLineContent(n.startLineNumber)}, ${t+1} of ${e.length} for '${r.word}'`)}finally{this._ignorePositionChangeEvent=!1}}_removeSingleDecorations(){if(!this.editor.hasModel())return;let e=I5.storedDecorationIDs.get(this.editor.getModel().uri);e&&(this.editor.removeDecorations(e),I5.storedDecorationIDs.delete(this.editor.getModel().uri),this.decorations.length>0&&(this.decorations.clear(),this._hasWordHighlights.set(!1)))}_removeAllDecorations(e){let t=this.codeEditorService.listCodeEditors(),n=[];for(let r of t){if(!r.hasModel()||bB(r.getModel().uri,e))continue;let t=I5.storedDecorationIDs.get(r.getModel().uri);if(!t)continue;r.removeDecorations(t),n.push(r.getModel().uri);let i=L5.get(r);i?.wordHighlighter&&i.wordHighlighter.decorations.length>0&&(i.wordHighlighter.decorations.clear(),i.wordHighlighter.workerRequest=null,i.wordHighlighter._hasWordHighlights.set(!1))}for(let e of n)I5.storedDecorationIDs.delete(e)}_stopSingular(){this._removeSingleDecorations(),this.editor.hasTextFocus()&&(this.editor.getModel()?.uri.scheme!==JL.vscodeNotebookCell&&I5.query?.modelInfo?.modelURI.scheme!==JL.vscodeNotebookCell?(I5.query=null,this._run()):I5.query?.modelInfo&&(I5.query.modelInfo=null)),this.renderDecorationsTimer!==void 0&&(clearTimeout(this.renderDecorationsTimer),this.renderDecorationsTimer=void 0),this.workerRequest!==null&&(this.workerRequest.cancel(),this.workerRequest=null),this.workerRequestCompleted||=(this.workerRequestTokenId++,!0)}_stopAll(e){this._removeAllDecorations(e),this.renderDecorationsTimer!==void 0&&(clearTimeout(this.renderDecorationsTimer),this.renderDecorationsTimer=void 0),this.workerRequest!==null&&(this.workerRequest.cancel(),this.workerRequest=null),this.workerRequestCompleted||=(this.workerRequestTokenId++,!0)}_onPositionChanged(e){if(this.occurrencesHighlightEnablement===`off`){this._stopAll();return}if(e.source!==`api`&&e.reason!==3){this._stopAll();return}this._run()}_getWord(){let e=this.editor.getSelection(),t=e.startLineNumber,n=e.startColumn;return this.model.isDisposed()?null:this.model.getWordAtPosition({lineNumber:t,column:n})}getOtherModelsToHighlight(e){if(!e)return[];if(e.uri.scheme===JL.vscodeNotebookCell){let t=[],n=this.codeEditorService.listCodeEditors();for(let r of n){let n=r.getModel();n&&n!==e&&n.uri.scheme===JL.vscodeNotebookCell&&t.push(n)}return t}let t=[],n=this.codeEditorService.listCodeEditors();for(let r of n){if(!pPn(r))continue;let n=r.getModel();n&&e===n.modified&&t.push(n.modified)}if(t.length)return t;if(this.occurrencesHighlightEnablement===`singleFile`)return[];for(let r of n){let n=r.getModel();n&&n!==e&&t.push(n)}return t}async _run(e,t){if(this.editor.hasTextFocus()){let e=this.editor.getSelection();if(!e||e.startLineNumber!==e.endLineNumber){I5.query=null,this._stopAll();return}let t=e.startColumn,n=e.endColumn,r=this._getWord();if(!r||r.startColumn>t||r.endColumn<n){I5.query=null,this._stopAll();return}I5.query={modelInfo:{modelURI:this.model.uri,selection:e}}}else if(!I5.query){this._stopAll();return}if(this.lastCursorPositionChangeTime=new Date().getTime(),bB(this.editor.getModel().uri,I5.query.modelInfo?.modelURI)){if(!e){let e=this.decorations.getRanges();for(let t of e)if(t.containsPosition(this.editor.getPosition()))return}this._stopAll(e?this.model.uri:void 0);let n=++this.workerRequestTokenId;this.workerRequestCompleted=!1;let r=this.getOtherModelsToHighlight(this.editor.getModel());if(!I5.query||!I5.query.modelInfo)return;let i=await this.textModelService.createModelReference(I5.query.modelInfo.modelURI);try{this.workerRequest=this.computeWithModel(i.object.textEditorModel,I5.query.modelInfo.selection,r),this.workerRequest?.result.then(e=>{n===this.workerRequestTokenId&&(this.workerRequestCompleted=!0,this.workerRequestValue=e||[],this._beginRenderDecorations(t??this.occurrencesHighlightDelay))},$N)}catch(e){this.logService.error(`Unexpected error during occurrence request. Log: `,e)}finally{i.dispose()}}else if(this.model.uri.scheme===JL.vscodeNotebookCell){let e=++this.workerRequestTokenId;if(this.workerRequestCompleted=!1,!I5.query||!I5.query.modelInfo)return;let n=await this.textModelService.createModelReference(I5.query.modelInfo.modelURI);try{this.workerRequest=this.computeWithModel(n.object.textEditorModel,I5.query.modelInfo.selection,[this.model]),this.workerRequest?.result.then(n=>{e===this.workerRequestTokenId&&(this.workerRequestCompleted=!0,this.workerRequestValue=n||[],this._beginRenderDecorations(t??this.occurrencesHighlightDelay))},$N)}catch(e){this.logService.error(`Unexpected error during occurrence request. Log: `,e)}finally{n.dispose()}}}computeWithModel(e,t,n){return n.length?p3n(this.multiDocumentProviders,e,t,this.editor.getOption(148),n):f3n(this.providers,e,t,this.editor.getOption(148))}_beginRenderDecorations(e){let t=new Date().getTime(),n=this.lastCursorPositionChangeTime+e;t>=n?(this.renderDecorationsTimer=void 0,this.renderDecorations()):this.renderDecorationsTimer=setTimeout(()=>{this.renderDecorations()},n-t)}renderDecorations(){this.renderDecorationsTimer=void 0;let e=this.codeEditorService.listCodeEditors();for(let t of e){let e=L5.get(t);if(!e)continue;let n=[],r=t.getModel()?.uri;if(r&&this.workerRequestValue.has(r)){let i=I5.storedDecorationIDs.get(r),a=this.workerRequestValue.get(r);if(a)for(let e of a)e.range&&n.push({range:e.range,options:j0n(e.kind)});let o=[];t.changeDecorations(e=>{o=e.deltaDecorations(i??[],n)}),I5.storedDecorationIDs=I5.storedDecorationIDs.set(r,o),n.length>0&&(e.wordHighlighter?.decorations.set(n),e.wordHighlighter?._hasWordHighlights.set(!0))}}this.workerRequest=null}dispose(){this._stopSingular(),this.toUnhook.dispose()}};m3n=I5=i3n([F5(4,Nz),F5(5,jz),F5(6,ZB),F5(7,wB)],m3n);var L5=class extends G{static{a3n=this}static{this.ID=`editor.contrib.wordHighlighter`}static get(e){return e.getContribution(a3n.ID)}constructor(e,t,n,r,i,a,o){super(),this._wordHighlighter=null;let s=()=>{e.hasModel()&&!e.getModel().isTooLargeForTokenization()&&e.getModel().uri.scheme!==JL.accessibleView&&(this._wordHighlighter=new m3n(e,n.documentHighlightProvider,n.multiDocumentHighlightProvider,t,i,r,a,o))};this._register(e.onDidChangeModel(e=>{this._wordHighlighter&&=(!e.newModelUrl&&e.oldModelUrl?.scheme!==JL.vscodeNotebookCell&&this.wordHighlighter?.stop(),this._wordHighlighter.dispose(),null),s()})),s()}get wordHighlighter(){return this._wordHighlighter}saveViewState(){return!!(this._wordHighlighter&&this._wordHighlighter.hasDecorations())}moveNext(){this._wordHighlighter?.moveNext()}moveBack(){this._wordHighlighter?.moveBack()}restoreViewState(e){this._wordHighlighter&&e&&this._wordHighlighter.restore(250)}dispose(){this._wordHighlighter&&=(this._wordHighlighter.dispose(),null),super.dispose()}};L5=a3n=i3n([F5(1,$z),F5(2,hH),F5(3,jz),F5(4,Nz),F5(5,ZB),F5(6,wB)],L5);var h3n=class extends kB{constructor(e,t){super(t),this._isNext=e}run(e,t){let n=L5.get(t);n&&(this._isNext?n.moveNext():n.moveBack())}},g3n=class extends h3n{constructor(){super(!0,{id:`editor.action.wordHighlight.next`,label:U(1572,`Go to Next Symbol Highlight`),precondition:o3n,kbOpts:{kbExpr:$.editorTextFocus,primary:65,weight:100}})}},_3n=class extends h3n{constructor(){super(!1,{id:`editor.action.wordHighlight.prev`,label:U(1573,`Go to Previous Symbol Highlight`),precondition:o3n,kbOpts:{kbExpr:$.editorTextFocus,primary:1089,weight:100}})}},v3n=class extends kB{constructor(){super({id:`editor.action.wordHighlight.trigger`,label:U(1574,`Trigger Symbol Highlight`),precondition:void 0,kbOpts:{kbExpr:$.editorTextFocus,primary:0,weight:100}})}run(e,t,n){let r=L5.get(t);r&&r.restoreViewState(!0)}};IB(L5.ID,L5,0),PB(g3n),PB(_3n),PB(v3n),x0(r3n);var R5=class extends OB{constructor(e){super(e),this._inSelectionMode=e.inSelectionMode,this._wordNavigationType=e.wordNavigationType}runEditorCommand(e,t,n){if(!t.hasModel())return;let r=wV(t.getOption(148),t.getOption(147)),i=t.getModel(),a=t.getSelections(),o=a.length>1,s=a.map(e=>{let t=new q(e.positionLineNumber,e.positionColumn),n=this._move(r,i,t,this._wordNavigationType,o);return this._moveTo(e,n,this._inSelectionMode)});if(i.pushStackElement(),t._getViewModel().setCursorStates(`moveWordCommand`,3,s.map(e=>eG.fromModelSelection(e))),s.length===1){let e=new q(s[0].positionLineNumber,s[0].positionColumn);t.revealPosition(e,0)}}_moveTo(e,t,n){return n?new gI(e.selectionStartLineNumber,e.selectionStartColumn,t.lineNumber,t.column):new gI(t.lineNumber,t.column,t.lineNumber,t.column)}},z5=class extends R5{_move(e,t,n,r,i){return pG.moveWordLeft(e,t,n,r,i)}},B5=class extends R5{_move(e,t,n,r,i){return pG.moveWordRight(e,t,n,r)}},y3n=class extends z5{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:`cursorWordStartLeft`,precondition:void 0})}},b3n=class extends z5{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:`cursorWordEndLeft`,precondition:void 0})}},x3n=class extends z5{constructor(){super({inSelectionMode:!1,wordNavigationType:1,id:`cursorWordLeft`,precondition:void 0,kbOpts:{kbExpr:Wz.and($.textInputFocus,Wz.and(QH,p1)?.negate()),primary:2063,mac:{primary:527},weight:100}})}},S3n=class extends z5{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:`cursorWordStartLeftSelect`,precondition:void 0})}},C3n=class extends z5{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:`cursorWordEndLeftSelect`,precondition:void 0})}},w3n=class extends z5{constructor(){super({inSelectionMode:!0,wordNavigationType:1,id:`cursorWordLeftSelect`,precondition:void 0,kbOpts:{kbExpr:Wz.and($.textInputFocus,Wz.and(QH,p1)?.negate()),primary:3087,mac:{primary:1551},weight:100}})}},T3n=class extends z5{constructor(){super({inSelectionMode:!1,wordNavigationType:3,id:`cursorWordAccessibilityLeft`,precondition:void 0})}_move(e,t,n,r,i){return super._move(wV(MF.wordSeparators.defaultValue,e.intlSegmenterLocales),t,n,r,i)}},E3n=class extends z5{constructor(){super({inSelectionMode:!0,wordNavigationType:3,id:`cursorWordAccessibilityLeftSelect`,precondition:void 0})}_move(e,t,n,r,i){return super._move(wV(MF.wordSeparators.defaultValue,e.intlSegmenterLocales),t,n,r,i)}},D3n=class extends B5{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:`cursorWordStartRight`,precondition:void 0})}},O3n=class extends B5{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:`cursorWordEndRight`,precondition:void 0,kbOpts:{kbExpr:Wz.and($.textInputFocus,Wz.and(QH,p1)?.negate()),primary:2065,mac:{primary:529},weight:100}})}},k3n=class extends B5{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:`cursorWordRight`,precondition:void 0})}},A3n=class extends B5{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:`cursorWordStartRightSelect`,precondition:void 0})}},j3n=class extends B5{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:`cursorWordEndRightSelect`,precondition:void 0,kbOpts:{kbExpr:Wz.and($.textInputFocus,Wz.and(QH,p1)?.negate()),primary:3089,mac:{primary:1553},weight:100}})}},M3n=class extends B5{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:`cursorWordRightSelect`,precondition:void 0})}},N3n=class extends B5{constructor(){super({inSelectionMode:!1,wordNavigationType:3,id:`cursorWordAccessibilityRight`,precondition:void 0})}_move(e,t,n,r,i){return super._move(wV(MF.wordSeparators.defaultValue,e.intlSegmenterLocales),t,n,r,i)}},P3n=class extends B5{constructor(){super({inSelectionMode:!0,wordNavigationType:3,id:`cursorWordAccessibilityRightSelect`,precondition:void 0})}_move(e,t,n,r,i){return super._move(wV(MF.wordSeparators.defaultValue,e.intlSegmenterLocales),t,n,r,i)}},V5=class extends OB{constructor(e){super({canTriggerInlineEdits:!0,...e}),this._whitespaceHeuristics=e.whitespaceHeuristics,this._wordNavigationType=e.wordNavigationType}runEditorCommand(e,t,n){let r=e?.get(fV);if(!t.hasModel()||!r)return;let i=wV(t.getOption(148),t.getOption(147)),a=t.getModel(),o=t.getSelections(),s=t.getOption(10),c=t.getOption(15),l=r.getLanguageConfiguration(a.getLanguageId()).getAutoClosingPairs(),u=t._getViewModel(),d=o.map(e=>new aG(this._delete({wordSeparators:i,model:a,selection:e,whitespaceHeuristics:this._whitespaceHeuristics,autoClosingDelete:t.getOption(13),autoClosingBrackets:s,autoClosingQuotes:c,autoClosingPairs:l,autoClosedCharacters:u.getCursorAutoClosedCharacters()},this._wordNavigationType),``));t.pushUndoStop(),t.executeCommands(this.id,d),t.pushUndoStop()}},F3n=class extends V5{_delete(e,t){return pG.deleteWordLeft(e,t)||new J(1,1,1,1)}},I3n=class extends V5{_delete(e,t){let n=pG.deleteWordRight(e,t);if(n)return n;let r=e.model.getLineCount(),i=e.model.getLineMaxColumn(r);return new J(r,i,r,i)}},L3n=class extends F3n{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:0,id:`deleteWordStartLeft`,precondition:$.writable})}},R3n=class extends F3n{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:2,id:`deleteWordEndLeft`,precondition:$.writable})}},z3n=class extends F3n{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:0,id:`deleteWordLeft`,precondition:$.writable,kbOpts:{kbExpr:$.textInputFocus,primary:2049,mac:{primary:513},weight:100}})}},B3n=class extends I3n{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:0,id:`deleteWordStartRight`,precondition:$.writable})}},V3n=class extends I3n{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:2,id:`deleteWordEndRight`,precondition:$.writable})}},H3n=class extends I3n{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:2,id:`deleteWordRight`,precondition:$.writable,kbOpts:{kbExpr:$.textInputFocus,primary:2068,mac:{primary:532},weight:100}})}},U3n=class extends kB{constructor(){super({id:`deleteInsideWord`,precondition:$.writable,label:U(1575,`Delete Word`)})}run(e,t,n){if(!t.hasModel())return;let r=wV(t.getOption(148),t.getOption(147)),i=t.getModel(),a=t.getSelections().map(e=>new aG(pG.deleteInsideWord(r,i,e),``));t.pushUndoStop(),t.executeCommands(this.id,a),t.pushUndoStop()}};NB(new y3n),NB(new b3n),NB(new x3n),NB(new S3n),NB(new C3n),NB(new w3n),NB(new D3n),NB(new O3n),NB(new k3n),NB(new A3n),NB(new j3n),NB(new M3n),NB(new T3n),NB(new E3n),NB(new N3n),NB(new P3n),NB(new L3n),NB(new R3n),NB(new z3n),NB(new B3n),NB(new V3n),NB(new H3n),PB(U3n);var W3n=class extends V5{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:0,id:`deleteWordPartLeft`,precondition:$.writable,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:769},weight:100}})}_delete(e,t){return mG.deleteWordPartLeft(e)||new J(1,1,1,1)}},G3n=class extends V5{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:2,id:`deleteWordPartRight`,precondition:$.writable,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:788},weight:100}})}_delete(e,t){let n=mG.deleteWordPartRight(e);if(n)return n;let r=e.model.getLineCount(),i=e.model.getLineMaxColumn(r);return new J(r,i,r,i)}},K3n=class extends R5{_move(e,t,n,r,i){return mG.moveWordPartLeft(e,t,n,i)}},q3n=class extends K3n{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:`cursorWordPartLeft`,precondition:void 0,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:783},weight:100}})}};Vz.registerCommandAlias(`cursorWordPartStartLeft`,`cursorWordPartLeft`);var J3n=class extends K3n{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:`cursorWordPartLeftSelect`,precondition:void 0,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:1807},weight:100}})}};Vz.registerCommandAlias(`cursorWordPartStartLeftSelect`,`cursorWordPartLeftSelect`);var Y3n=class extends R5{_move(e,t,n,r,i){return mG.moveWordPartRight(e,t,n)}},X3n=class extends Y3n{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:`cursorWordPartRight`,precondition:void 0,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:785},weight:100}})}},Z3n=class extends Y3n{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:`cursorWordPartRightSelect`,precondition:void 0,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:1809},weight:100}})}};NB(new W3n),NB(new G3n),NB(new q3n),NB(new J3n),NB(new X3n),NB(new Z3n);var Q3n=class extends G{static{this.ID=`editor.contrib.readOnlyMessageController`}constructor(e){super(),this.editor=e,this._register(this.editor.onDidAttemptReadOnlyEdit(()=>this._onDidAttemptReadOnlyEdit()))}_onDidAttemptReadOnlyEdit(){let e=E2.get(this.editor);if(e&&this.editor.hasModel()){let t=this.editor.getOptions().get(105);t||=this.editor.isSimpleWidget?new GX(H(1378,`Cannot edit in read-only input`)):new GX(H(1379,`Cannot edit in read-only editor`)),e.showMessage(t,this.editor.getPosition())}}};IB(Q3n.ID,Q3n,2);var $3n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},e6n=function(e,t){return function(n,r){t(n,r,e)}},t6n=class extends G{constructor(e,t,n){super(),this._textModel=e,this._languageFeaturesService=t,this._outlineModelService=n,this._currentModel=FR(this,void 0);let r=H0(`documentSymbolProvider.onDidChange`,this._languageFeaturesService.documentSymbolProvider.onDidChange),i=H0(`_textModel.onDidChangeContent`,ZP.debounce(e=>this._textModel.onDidChangeContent(e),()=>void 0,100));this._register(wR(async(e,t)=>{r.read(e),i.read(e);let n=t.add(new yMn),a=await this._outlineModelService.getOrCreate(this._textModel,n.token);t.isDisposed||this._currentModel.set(a,void 0)}))}getBreadcrumbItems(e,t){let n=this._currentModel.read(t);if(!n)return[];let r=n.asListOfDocumentSymbols().filter(t=>e.contains(t.range.startLineNumber)&&!e.contains(t.range.endLineNumber));return r.sort(g1t(qN(e=>e.range.endLineNumber-e.range.startLineNumber,JN))),r.map(e=>({name:e.name,kind:e.kind,startLineNumber:e.range.startLineNumber}))}};t6n=$3n([e6n(1,hH),e6n(2,v6)],t6n),i2.setBreadcrumbsSourceFactory((e,t)=>t.createInstance(t6n,e));var n6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},r6n=function(e,t){return function(n,r){t(n,r,e)}},H5=class extends G{static{this.ID=`editor.contrib.floatingToolbar`}constructor(e,t,n,r){super();let i=this._register(X0(e)),a=this._register(r.createMenu(aB.EditorContent,e.contextKeyService)),o=AR(this,a.onDidChange,()=>a.getActions().length===0);this._register(xR(e=>{if(o.read(e))return;let r=vz(`div.floating-menu-overlay-widget`);r.root.style.height=`28px`;let a=t.createInstance(t2,r.root,aB.EditorContent,{actionViewItemProvider:(e,r)=>{if(!(e instanceof uB))return;let i=n.lookupKeybinding(e.id);if(i)return t.createInstance(class extends D${updateLabel(){this.options.label&&this.label&&(this.label.textContent=`${this._commandAction.label} (${i.getLabel()})`)}},e,{...r,keybindingNotRenderedWithLabel:!0})},hiddenItemStrategy:0,menuOptions:{shouldForwardArgs:!0},telemetrySource:`editor.overlayToolbar`,toolbarOptions:{primaryGroup:()=>!0,useSeparatorsInPrimaryActions:!0}});e.store.add(a),e.store.add(xR(e=>{let t=i.model.read(e);a.context=t?.uri})),e.store.add(i.createOverlayWidget({allowEditorOverflow:!1,domNode:r.root,minContentWidthInPx:s$(0),position:s$({preference:1})}))}))}};H5=n6n([r6n(1,kz),r6n(2,UK),r6n(3,oB)],H5),IB(H5.ID,H5,1);var i6n=class extends G{static{this.ID=`editor.contrib.iPadShowKeyboard`}constructor(e){super(),this.editor=e,this.widget=null,FP&&(this._register(e.onDidChangeConfiguration(()=>this.update())),this.update())}update(){let e=!this.editor.getOption(104);!this.widget&&e?this.widget=new a6n(this.editor):this.widget&&!e&&(this.widget.dispose(),this.widget=null)}dispose(){super.dispose(),this.widget&&=(this.widget.dispose(),null)}},a6n=class e extends G{static{this.ID=`editor.contrib.ShowKeyboardWidget`}constructor(e){super(),this.editor=e,this._domNode=document.createElement(`textarea`),this._domNode.className=`iPadShowKeyboard`,this._register(X(this._domNode,`touchstart`,e=>{this.editor.focus()})),this._register(X(this._domNode,`focus`,e=>{this.editor.focus()})),this.editor.addOverlayWidget(this)}dispose(){this.editor.removeOverlayWidget(this),super.dispose()}getId(){return e.ID}getDomNode(){return this._domNode}getPosition(){return{preference:1}}};IB(i6n.ID,i6n,3);var o6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},s6n=function(e,t){return function(n,r){t(n,r,e)}},c6n,U5=class extends G{static{c6n=this}static{this.ID=`editor.contrib.inspectTokens`}static get(e){return e.getContribution(c6n.ID)}constructor(e,t,n){super(),this._editor=e,this._languageService=n,this._widget=null,this._register(this._editor.onDidChangeModel(e=>this.stop())),this._register(this._editor.onDidChangeModelLanguage(e=>this.stop())),this._register(NI.onDidChange(e=>this.stop())),this._register(this._editor.onKeyUp(e=>e.keyCode===9&&this.stop()))}dispose(){this.stop(),super.dispose()}launch(){this._widget||this._editor.hasModel()&&(this._widget=new f6n(this._editor,this._languageService))}stop(){this._widget&&=(this._widget.dispose(),null)}};U5=c6n=o6n([s6n(1,l0),s6n(2,QB)],U5);var l6n=class extends kB{constructor(){super({id:`editor.action.inspectTokens`,label:jCn.inspectTokensAction,alias:`Developer: Inspect Tokens`,precondition:void 0})}run(e,t){U5.get(t)?.launch()}};function u6n(e){let t=``;for(let n=0,r=e.length;n<r;n++){let r=e.charCodeAt(n);switch(r){case 9:t+=`→`;break;case 32:t+=`·`;break;default:t+=String.fromCharCode(r)}}return t}function d6n(e,t){let n=NI.get(t);if(n)return n;let r=e.encodeLanguageId(t);return{getInitialState:()=>bH,tokenize:(e,n,r)=>Wnn(t,r),tokenizeEncoded:(e,t,n)=>xH(r,n)}}var f6n=class e extends G{static{this._ID=`editor.contrib.inspectTokensWidget`}constructor(e,t){super(),this.allowEditorOverflow=!0,this._editor=e,this._languageService=t,this._model=this._editor.getModel(),this._domNode=document.createElement(`div`),this._domNode.className=`tokens-inspect-widget`,this._tokenizationSupport=d6n(this._languageService.languageIdCodec,this._model.getLanguageId()),this._compute(this._editor.getPosition()),this._register(this._editor.onDidChangeCursorPosition(e=>this._compute(this._editor.getPosition()))),this._editor.addContentWidget(this)}dispose(){this._editor.removeContentWidget(this),super.dispose()}getId(){return e._ID}_compute(e){let t=this._getTokensAtLine(e.lineNumber),n=0;for(let r=t.tokens1.length-1;r>=0;r--){let i=t.tokens1[r];if(e.column-1>=i.offset){n=r;break}}let r=0;for(let n=t.tokens2.length>>>1;n>=0;n--)if(e.column-1>=t.tokens2[n<<1]){r=n;break}let i=this._model.getLineContent(e.lineNumber),a=``;if(n<t.tokens1.length){let e=t.tokens1[n].offset,r=n+1<t.tokens1.length?t.tokens1[n+1].offset:i.length;a=i.substring(e,r)}fz(this._domNode,mz(`h2.tm-token`,void 0,u6n(a),mz(`span.tm-token-length`,void 0,`${a.length} ${a.length===1?`char`:`chars`}`))),uz(this._domNode,mz(`hr.tokens-inspect-separator`,{style:`clear:both`}));let o=(r<<1)+1<t.tokens2.length?this._decodeMetadata(t.tokens2[(r<<1)+1]):null;uz(this._domNode,mz(`table.tm-metadata-table`,void 0,mz(`tbody`,void 0,mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`language`),mz(`td.tm-metadata-value`,void 0,`${o?o.languageId:`-?-`}`)),mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`token type`),mz(`td.tm-metadata-value`,void 0,`${o?this._tokenTypeToString(o.tokenType):`-?-`}`)),mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`font style`),mz(`td.tm-metadata-value`,void 0,`${o?this._fontStyleToString(o.fontStyle):`-?-`}`)),mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`foreground`),mz(`td.tm-metadata-value`,void 0,`${o?Z.Format.CSS.formatHex(o.foreground):`-?-`}`)),mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`background`),mz(`td.tm-metadata-value`,void 0,`${o?Z.Format.CSS.formatHex(o.background):`-?-`}`))))),uz(this._domNode,mz(`hr.tokens-inspect-separator`)),n<t.tokens1.length&&uz(this._domNode,mz(`span.tm-token-type`,void 0,t.tokens1[n].type)),this._editor.layoutContentWidget(this)}_decodeMetadata(e){let t=NI.getColorMap(),n=SH.getLanguageId(e),r=SH.getTokenType(e),i=SH.getFontStyle(e),a=SH.getForeground(e),o=SH.getBackground(e);return{languageId:this._languageService.languageIdCodec.decodeLanguageId(n),tokenType:r,fontStyle:i,foreground:t[a],background:t[o]}}_tokenTypeToString(e){switch(e){case 0:return`Other`;case 1:return`Comment`;case 2:return`String`;case 3:return`RegEx`;default:return`??`}}_fontStyleToString(e){let t=``;return e&1&&(t+=`italic `),e&2&&(t+=`bold `),e&4&&(t+=`underline `),e&8&&(t+=`strikethrough `),t.length===0&&(t=`---`),t}_getTokensAtLine(e){let t=this._getStateBeforeLine(e),n=this._tokenizationSupport.tokenize(this._model.getLineContent(e),!0,t),r=this._tokenizationSupport.tokenizeEncoded(this._model.getLineContent(e),!0,t);return{startState:t,tokens1:n.tokens,tokens2:r.tokens,endState:n.endState}}_getStateBeforeLine(e){let t=this._tokenizationSupport.getInitialState();for(let n=1;n<e;n++)t=this._tokenizationSupport.tokenize(this._model.getLineContent(n),!0,t).endState;return t}getDomNode(){return this._domNode}getPosition(){return{position:this._editor.getPosition(),preference:[2,1]}}};IB(U5.ID,U5,4),PB(l6n);var p6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},m6n=function(e,t){return function(n,r){t(n,r,e)}},W5,h6n=class{static{W5=this}static{this.PREFIX=`?`}constructor(e,t){this.quickInputService=e,this.keybindingService=t,this.registry=tB.as(L$.Quickaccess)}provide(e){let t=new W;return t.add(e.onDidAccept(()=>{let[t]=e.selectedItems;t&&this.quickInputService.quickAccess.show(t.prefix,{preserveValue:!0})})),t.add(e.onDidChangeValue(e=>{let t=this.registry.getQuickAccessProvider(e.substr(W5.PREFIX.length));t&&t.prefix&&t.prefix!==W5.PREFIX&&this.quickInputService.quickAccess.show(t.prefix,{preserveValue:!0})})),e.items=this.getQuickAccessProviders().filter(e=>e.prefix!==W5.PREFIX),t}getQuickAccessProviders(){return this.registry.getQuickAccessProviders().sort((e,t)=>e.prefix.localeCompare(t.prefix)).flatMap(e=>this.createPicks(e))}createPicks(e){return e.helpEntries.map(t=>{let n=t.prefix||e.prefix,r=n||`…`;return{prefix:n,label:r,keybinding:t.commandId?this.keybindingService.lookupKeybinding(t.commandId):void 0,ariaLabel:H(1747,`{0}, {1}`,r,t.description),description:t.description}})}};h6n=W5=p6n([m6n(0,_Q),m6n(1,UK)],h6n),tB.as(L$.Quickaccess).registerQuickAccessProvider({ctor:h6n,prefix:``,helpEntries:[{description:NCn.helpQuickAccessActionLabel}]});var g6n=class{constructor(e){this.options=e,this.rangeHighlightDecorationId=void 0}provide(e,t,n){let r=new W;e.canAcceptInBackground=!!this.options?.canAcceptInBackground,e.matchOnLabel=e.matchOnDescription=e.matchOnDetail=e.sortByLabel=!1;let i=r.add(new KP);return i.value=this.doProvide(e,t,n),r.add(this.onDidActiveTextEditorControlChange(()=>{i.value=void 0,i.value=this.doProvide(e,t)})),r}doProvide(e,t,n){let r=new W,i=this.activeTextEditorControl;if(i&&this.canProvideWithTextEditor(i)){let a={editor:i},o=hPn(i);if(o){let e=i.saveViewState()??void 0;r.add(o.onDidChangeCursorPosition(()=>{e=i.saveViewState()??void 0})),a.restoreViewState=()=>{e&&i===this.activeTextEditorControl&&i.restoreViewState(e)},r.add(zP(t.onCancellationRequested)(()=>a.restoreViewState?.()))}r.add(GP(()=>this.clearDecorations(i))),r.add(this.provideWithTextEditor(a,e,t,n))}else r.add(this.provideWithoutTextEditor(e,t));return r}canProvideWithTextEditor(e){return!0}gotoLocation({editor:e},t){e.setSelection(t.range,`code.jump`),e.revealRangeInCenter(t.range,0),t.preserveFocus||e.focus();let n=e.getModel();n&&`getLineContent`in n&&GH(`${n.getLineContent(t.range.startLineNumber)}`)}getModel(e){return pPn(e)?e.getModel()?.modified:e.getModel()}addDecorations(e,t){e.changeDecorations(e=>{let n=[];this.rangeHighlightDecorationId&&=(n.push(this.rangeHighlightDecorationId.overviewRulerDecorationId),n.push(this.rangeHighlightDecorationId.rangeHighlightId),void 0);let r=[{range:t,options:{description:`quick-access-range-highlight`,className:`rangeHighlight`,isWholeLine:!0}},{range:t,options:{description:`quick-access-range-highlight-overview`,overviewRuler:{color:ZG(Tln),position:TV.Full}}}],[i,a]=e.deltaDecorations(n,r);this.rangeHighlightDecorationId={rangeHighlightId:i,overviewRulerDecorationId:a}})}clearDecorations(e){let t=this.rangeHighlightDecorationId;t&&(e.changeDecorations(e=>{e.deltaDecorations([t.overviewRulerDecorationId,t.rangeHighlightId],[])}),this.rangeHighlightDecorationId=void 0)}},_6n=class e extends g6n{static{this.PREFIX=`:`}static{this.ZERO_BASED_OFFSET_STORAGE_KEY=`gotoLine.useZeroBasedOffset`}constructor(){super({canAcceptInBackground:!0})}get useZeroBasedOffset(){return this.storageService.getBoolean(e.ZERO_BASED_OFFSET_STORAGE_KEY,-1,!1)}set useZeroBasedOffset(t){this.storageService.store(e.ZERO_BASED_OFFSET_STORAGE_KEY,t,-1,0)}provideWithoutTextEditor(e){let t=H(1335,`Open a text editor first to go to a line.`);return e.items=[{label:t}],e.ariaLabel=t,G.None}provideWithTextEditor(t,n,r){let i=t.editor,a=new W;a.add(n.onDidAccept(e=>{let[r]=n.selectedItems;if(r){if(!r.lineNumber)return;this.gotoLocation(t,{range:this.toRange(r.lineNumber,r.column),keyMods:n.keyMods,preserveFocus:e.inBackground}),e.inBackground||n.hide()}}));let o=()=>{let t=n.value.trim().substring(e.PREFIX.length),{inOffsetMode:r,lineNumber:a,column:o,label:c}=this.parsePosition(i,t);if(s.visible=!!r,n.items=[{lineNumber:a,column:o,label:c}],n.ariaLabel=c,!a){this.clearDecorations(i);return}let l=this.toRange(a,o);i.revealRangeInCenter(l,0),this.addDecorations(i,l)},s=new R$({title:H(1336,`Use Zero-Based Offset`),icon:vI.indexZero,isChecked:this.useZeroBasedOffset,inputActiveOptionBorder:aU(BU),inputActiveOptionForeground:aU(HU),inputActiveOptionBackground:aU(VU)});a.add(s.onChange(()=>{this.useZeroBasedOffset=!this.useZeroBasedOffset,o()})),n.toggles=[s],o(),a.add(n.onDidChangeValue(()=>o()));let c=hPn(i);return c&&c.getOptions().get(76).renderType===2&&(c.updateOptions({lineNumbers:`on`}),a.add(GP(()=>c.updateOptions({lineNumbers:`relative`})))),a}toRange(e=1,t=1){return{startLineNumber:e,startColumn:t,endLineNumber:e,endColumn:t}}parsePosition(e,t){let n=this.getModel(e);if(!n)return{label:H(1337,`Open a text editor first to go to a line.`)};if(t.startsWith(`:`)){let e=parseInt(t.substring(1),10),r=n.getValueLength();if(isNaN(e))return{inOffsetMode:!0,label:this.useZeroBasedOffset?H(1338,`Type a character position to go to (from 0 to {0}).`,r-1):H(1339,`Type a character position to go to (from 1 to {0}).`,r)};{let t=e<0;this.useZeroBasedOffset||(e-=Math.sign(e)),t&&(e+=r);let i=n.getPositionAt(e);return{...i,inOffsetMode:!0,label:H(1340,`Press 'Enter' to go to line {0} at column {1}.`,i.lineNumber,i.column)}}}{let e=t.split(/,|:|#/),r=n.getLineCount(),i=parseInt(e[0]?.trim(),10);if(e.length<1||isNaN(i))return{label:H(1341,`Type a line number to go to (from 1 to {0}).`,r)};i=i>=0?i:r+1+i,i=Math.min(Math.max(1,i),r);let a=n.getLineMaxColumn(i),o=parseInt(e[1]?.trim(),10);return e.length<2||isNaN(o)?{lineNumber:i,column:1,label:e.length<2?H(1342,`Press 'Enter' to go to line {0} or enter : to add a column number.`,i):H(1343,`Press 'Enter' to go to line {0} or enter a column number (from 1 to {1}).`,i,a)}:(o=o>=0?o:a+o,o=Math.min(Math.max(1,o),a),{lineNumber:i,column:o,label:H(1344,`Press 'Enter' to go to line {0} at column {1}.`,i,o)})}}},v6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},y6n=function(e,t){return function(n,r){t(n,r,e)}},G5=class extends _6n{constructor(e,t){super(),this.editorService=e,this.storageService=t,this.onDidActiveTextEditorControlChange=ZP.None}get activeTextEditorControl(){return this.editorService.getFocusedCodeEditor()??void 0}};G5=v6n([y6n(0,jz),y6n(1,bQ)],G5);var b6n=class e extends kB{static{this.ID=`editor.action.gotoLine`}constructor(){super({id:e.ID,label:MCn.gotoLineActionLabel,alias:`Go to Line/Column...`,precondition:void 0,kbOpts:{kbExpr:$.focus,primary:2085,mac:{primary:293},weight:100}})}run(e){e.get(_Q).quickAccess.show(G5.PREFIX)}};PB(b6n),tB.as(L$.Quickaccess).registerQuickAccessProvider({ctor:G5,prefix:G5.PREFIX,helpEntries:[{description:MCn.gotoLineActionLabel,commandId:b6n.ID}]});var x6n=[void 0,[]];function S6n(e,t,n=0,r=0){let i=t;return i.values&&i.values.length>1?C6n(e,i.values,n,r):w6n(e,t,n,r)}function C6n(e,t,n,r){let i=0,a=[];for(let o of t){let[t,s]=w6n(e,o,n,r);if(typeof t!=`number`)return x6n;i+=t,a.push(...s)}return[i,T6n(a)]}function w6n(e,t,n,r){let i=zX(t.original,t.originalLowercase,n,e,e.toLowerCase(),r,{firstMatchCanBeWeak:!0,boostFullMatch:!0});return i?[i[0],OX(i)]:x6n}function T6n(e){let t=e.sort((e,t)=>e.start-t.start),n=[],r;for(let e of t)!r||!E6n(r,e)?(r=e,n.push(e)):(r.start=Math.min(r.start,e.start),r.end=Math.max(r.end,e.end));return n}function E6n(e,t){return!(e.end<t.start||t.end<e.start)}function D6n(e){return e.startsWith(`"`)&&e.endsWith(`"`)}var O6n=` `;function k6n(e){typeof e!=`string`&&(e=``);let t=e.toLowerCase(),{pathNormalized:n,normalized:r,normalizedLowercase:i}=A6n(e),a=n.indexOf(cI)>=0,o=D6n(e),s,c=e.split(O6n);if(c.length>1)for(let e of c){let t=D6n(e),{pathNormalized:n,normalized:r,normalizedLowercase:i}=A6n(e);r&&(s||=[],s.push({original:e,originalLowercase:e.toLowerCase(),pathNormalized:n,normalized:r,normalizedLowercase:i,expectContiguousMatch:t}))}return{original:e,originalLowercase:t,pathNormalized:n,normalized:r,normalizedLowercase:i,values:s,containsPathSeparator:a,expectContiguousMatch:o}}function A6n(e){let t;t=AP?e.replace(/\//g,cI):e.replace(/\\/g,cI);let n=t.replace(/[\*\u2026\s"]/g,``);return{pathNormalized:t,normalized:n,normalizedLowercase:n.toLowerCase()}}function j6n(e){return k6n(Array.isArray(e)?e.map(e=>e.original).join(O6n):e.original)}var M6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},N6n=function(e,t){return function(n,r){t(n,r,e)}},K5,q5=class extends g6n{static{K5=this}static{this.PREFIX=`@`}static{this.SCOPE_PREFIX=`:`}static{this.PREFIX_BY_CATEGORY=`${this.PREFIX}${this.SCOPE_PREFIX}`}constructor(e,t,n=Object.create(null)){super(n),this._languageFeaturesService=e,this._outlineModelService=t,this.options=n,this.options.canAcceptInBackground=!0}provideWithoutTextEditor(e){return this.provideLabelPick(e,H(1345,`To go to a symbol, first open a text editor with symbol information.`)),G.None}provideWithTextEditor(e,t,n,r){let i=e.editor,a=this.getModel(i);return a?this._languageFeaturesService.documentSymbolProvider.has(a)?this.doProvideWithEditorSymbols(e,a,t,n,r):this.doProvideWithoutEditorSymbols(e,a,t,n):G.None}doProvideWithoutEditorSymbols(e,t,n,r){let i=new W;return this.provideLabelPick(n,H(1346,`The active text editor does not provide symbol information.`)),(async()=>{await this.waitForLanguageSymbolRegistry(t,i)&&!r.isCancellationRequested&&i.add(this.doProvideWithEditorSymbols(e,t,n,r))})(),i}provideLabelPick(e,t){e.items=[{label:t,index:0,kind:14}],e.ariaLabel=t}async waitForLanguageSymbolRegistry(e,t){if(this._languageFeaturesService.documentSymbolProvider.has(e))return!0;let n=new GL,r=t.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(()=>{this._languageFeaturesService.documentSymbolProvider.has(e)&&(r.dispose(),n.complete(!0))}));return t.add(GP(()=>n.complete(!1))),n.p}doProvideWithEditorSymbols(e,t,n,r,i){let a=e.editor,o=new W;o.add(n.onDidAccept(t=>{let[r]=n.selectedItems;r&&r.range&&(this.gotoLocation(e,{range:r.range.selection,keyMods:n.keyMods,preserveFocus:t.inBackground}),i?.handleAccept?.(r,t.inBackground),t.inBackground||n.hide())})),o.add(n.onDidTriggerItemButton(({item:t})=>{t&&t.range&&(this.gotoLocation(e,{range:t.range.selection,keyMods:n.keyMods,forceSideBySide:!0}),n.hide())}));let s=this.getDocumentSymbols(t,r),c=o.add(new KP),l=async e=>{c?.value?.cancel(),n.busy=!1,c.value=new FF,n.busy=!0;try{let i=k6n(n.value.substr(K5.PREFIX.length).trim()),a=await this.doGetSymbolPicks(s,i,void 0,c.value.token,t);if(r.isCancellationRequested)return;if(a.length>0){if(n.items=a,e&&i.original.length===0){let t=LV(a,t=>!!(t.type!==`separator`&&t.range&&J.containsPosition(t.range.decoration,e)));t&&(n.activeItems=[t])}}else i.original.length>0?this.provideLabelPick(n,H(1347,`No matching editor symbols`)):this.provideLabelPick(n,H(1348,`No editor symbols`))}finally{r.isCancellationRequested||(n.busy=!1)}};return o.add(n.onDidChangeValue(()=>l(void 0))),l(a.getSelection()?.getPosition()),o.add(n.onDidChangeActive(()=>{let[e]=n.activeItems;e&&e.range&&(a.revealRangeInCenter(e.range.selection,0),this.addDecorations(a,e.range.decoration))})),o}async doGetSymbolPicks(e,t,n,r,i){let a=await e;if(r.isCancellationRequested)return[];let o=t.original.indexOf(K5.SCOPE_PREFIX)===0,s=+!!o,c,l;t.values&&t.values.length>1?(c=j6n(t.values[0]),l=j6n(t.values.slice(1))):c=t;let u,d=this.options?.openSideBySideDirection?.();d&&(u=[{iconClass:d===`right`?zz.asClassName(vI.splitHorizontal):zz.asClassName(vI.splitVertical),tooltip:d===`right`?H(1349,`Open to the Side`):H(1350,`Open to the Bottom`)}]);let f=[];for(let e=0;e<a.length;e++){let r=a[e],o=S3t(r.name),d=`$(${kI.toIcon(r.kind).id}) ${o}`,p=d.length-o.length,m=r.containerName;n?.extraContainerLabel&&(m=m?`${n.extraContainerLabel} • ${m}`:n.extraContainerLabel);let h,g,_,v;if(t.original.length>s){let e=!1;if(c!==t&&([h,g]=S6n(d,{...t,values:void 0},s,p),typeof h==`number`&&(e=!0)),typeof h!=`number`&&([h,g]=S6n(d,c,s,p),typeof h!=`number`))continue;if(!e&&l){if(m&&l.original.length>0&&([_,v]=S6n(m,l)),typeof _!=`number`)continue;typeof h==`number`&&(h+=_)}}let y=r.tags&&r.tags.indexOf(1)>=0;f.push({index:e,kind:r.kind,score:h,label:d,ariaLabel:g4t(r.name,r.kind),description:m,highlights:y?void 0:{label:g,description:v},range:{selection:J.collapseToStart(r.selectionRange),decoration:r.range},uri:i.uri,symbolName:o,strikethrough:y,buttons:u})}let p=f.sort((e,t)=>o?this.compareByKindAndScore(e,t):this.compareByScore(e,t)),m=[];if(o){let e,t,n=0;function r(){t&&typeof e==`number`&&n>0&&(t.label=RI(F6n[e]||P6n,n))}for(let i of p)e===i.kind?n++:(r(),e=i.kind,n=1,t={type:`separator`},m.push(t)),m.push(i);r()}else p.length>0&&(m=[{label:H(1351,`symbols ({0})`,f.length),type:`separator`},...p]);return m}compareByScore(e,t){if(typeof e.score!=`number`&&typeof t.score==`number`)return 1;if(typeof e.score==`number`&&typeof t.score!=`number`)return-1;if(typeof e.score==`number`&&typeof t.score==`number`){if(e.score>t.score)return-1;if(e.score<t.score)return 1}return e.index<t.index?-1:+(e.index>t.index)}compareByKindAndScore(e,t){let n=F6n[e.kind]||P6n,r=F6n[t.kind]||P6n,i=n.localeCompare(r);return i===0?this.compareByScore(e,t):i}async getDocumentSymbols(e,t){let n=await this._outlineModelService.getOrCreate(e,t);return t.isCancellationRequested?[]:n.asListOfDocumentSymbols()}};q5=K5=M6n([N6n(0,hH),N6n(1,v6)],q5);var P6n=H(1352,`properties ({0})`),F6n={5:H(1353,`methods ({0})`),11:H(1354,`functions ({0})`),8:H(1355,`constructors ({0})`),12:H(1356,`variables ({0})`),4:H(1357,`classes ({0})`),22:H(1358,`structs ({0})`),23:H(1359,`events ({0})`),24:H(1360,`operators ({0})`),10:H(1361,`interfaces ({0})`),2:H(1362,`namespaces ({0})`),3:H(1363,`packages ({0})`),25:H(1364,`type parameters ({0})`),1:H(1365,`modules ({0})`),6:H(1366,`properties ({0})`),9:H(1367,`enumerations ({0})`),21:H(1368,`enumeration members ({0})`),14:H(1369,`strings ({0})`),0:H(1370,`files ({0})`),17:H(1371,`arrays ({0})`),15:H(1372,`numbers ({0})`),16:H(1373,`booleans ({0})`),18:H(1374,`objects ({0})`),19:H(1375,`keys ({0})`),7:H(1376,`fields ({0})`),13:H(1377,`constants ({0})`)},I6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},L6n=function(e,t){return function(n,r){t(n,r,e)}},R6n=class extends q5{constructor(e,t,n){super(t,n),this.editorService=e,this.onDidActiveTextEditorControlChange=ZP.None}get activeTextEditorControl(){return this.editorService.getFocusedCodeEditor()??void 0}};R6n=I6n([L6n(0,jz),L6n(1,hH),L6n(2,v6)],R6n);var z6n=class e extends kB{static{this.ID=`editor.action.quickOutline`}constructor(){super({id:e.ID,label:VQ.quickOutlineActionLabel,alias:`Go to Symbol...`,precondition:$.hasDocumentSymbolProvider,kbOpts:{kbExpr:$.focus,primary:3117,weight:100},contextMenuOpts:{group:`navigation`,order:3}})}run(e){e.get(_Q).quickAccess.show(q5.PREFIX,{itemActivation:hQ.NONE})}};PB(z6n),tB.as(L$.Quickaccess).registerQuickAccessProvider({ctor:R6n,prefix:q5.PREFIX,helpEntries:[{description:VQ.quickOutlineActionLabel,prefix:q5.PREFIX,commandId:z6n.ID},{description:VQ.quickOutlineByCategoryActionLabel,prefix:q5.PREFIX_BY_CATEGORY}]});function B6n(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return t}var V6n=class e{constructor(){this.chunkCount=0,this.chunkOccurrences=new Map,this.documents=new Map}calculateScores(e,t){let n=this.computeEmbedding(e),r=new Map,i=[];for(let[e,a]of this.documents){if(t.isCancellationRequested)return[];for(let t of a.chunks){let a=this.computeSimilarityScore(t,n,r);a>0&&i.push({key:e,score:a})}}return i}static termFrequencies(t){return B6n(e.splitTerms(t))}static*splitTerms(e){let t=e=>e.toLowerCase();for(let[n]of e.matchAll(/\b\p{Letter}[\p{Letter}\d]{2,}\b/gu)){yield t(n);let e=n.replace(/([a-z])([A-Z])/g,`$1 $2`).split(/\s+/g);if(e.length>1)for(let n of e)n.length>2&&/\p{Letter}{3,}/gu.test(n)&&(yield t(n))}}updateDocuments(t){for(let{key:e}of t)this.deleteDocument(e);for(let n of t){let t=[];for(let r of n.textChunks){let n=e.termFrequencies(r);for(let e of n.keys())this.chunkOccurrences.set(e,(this.chunkOccurrences.get(e)??0)+1);t.push({text:r,tf:n})}this.chunkCount+=t.length,this.documents.set(n.key,{chunks:t})}return this}deleteDocument(e){let t=this.documents.get(e);if(t){this.documents.delete(e),this.chunkCount-=t.chunks.length;for(let e of t.chunks)for(let t of e.tf.keys()){let e=this.chunkOccurrences.get(t);if(typeof e==`number`){let n=e-1;n<=0?this.chunkOccurrences.delete(t):this.chunkOccurrences.set(t,n)}}}}computeSimilarityScore(e,t,n){let r=0;for(let[i,a]of Object.entries(t)){let t=e.tf.get(i);if(!t)continue;let o=n.get(i);typeof o!=`number`&&(o=this.computeIdf(i),n.set(i,o));let s=t*o;r+=s*a}return r}computeEmbedding(t){let n=e.termFrequencies(t);return this.computeTfidf(n)}computeIdf(e){let t=this.chunkOccurrences.get(e)??0;return t>0?Math.log((this.chunkCount+1)/t):0}computeTfidf(e){let t=Object.create(null);for(let[n,r]of e){let e=this.computeIdf(n);e>0&&(t[n]=r*e)}return t}};function H6n(e){let t=e.slice(0);t.sort((e,t)=>t.score-e.score);let n=t[0]?.score??0;if(n>0)for(let e of t)e.score/=n;return t}var J5;(function(e){e[e.NO_ACTION=0]=`NO_ACTION`,e[e.CLOSE_PICKER=1]=`CLOSE_PICKER`,e[e.REFRESH_PICKER=2]=`REFRESH_PICKER`,e[e.REMOVE_ITEM=3]=`REMOVE_ITEM`})(J5||={});function U6n(e){let t=e;return Array.isArray(t.items)}function W6n(e){let t=e;return!!t.picks&&t.additionalPicks instanceof Promise}var G6n=class extends G{constructor(e,t){super(),this.prefix=e,this.options=t}provide(e,t,n){let r=new W;e.canAcceptInBackground=!!this.options?.canAcceptInBackground,e.matchOnLabel=e.matchOnDescription=e.matchOnDetail=e.sortByLabel=!1;let i,a=r.add(new KP),o=async()=>{i?.dispose(!0),e.busy=!1;let r=a.value=new W;i=r.add(new FF(t));let o=i.token,s=e.value.substring(this.prefix.length);this.options?.shouldSkipTrimPickFilter||(s=s.trim());let c=this._getPicks(s,r,o,n),l=(t,n)=>{let r,i;if(U6n(t)?(r=t.items,i=t.active):r=t,r.length===0){if(n)return!1;(s.length>0||e.hideInput)&&this.options?.noResultsPick&&(r=vP(this.options.noResultsPick)?[this.options.noResultsPick(s)]:[this.options.noResultsPick])}return e.items=r,i&&(e.activeItems=[i]),!0},u=async t=>{let n=!1,r=!1;await Promise.all([(async()=>{typeof t.mergeDelay==`number`&&(await LL(t.mergeDelay),o.isCancellationRequested)||r||(n=l(t.picks,!0))})(),(async()=>{e.busy=!0;try{let r=await t.additionalPicks;if(o.isCancellationRequested)return;let i,a;U6n(t.picks)?(i=t.picks.items,a=t.picks.active):i=t.picks;let s,c;if(U6n(r)?(s=r.items,c=r.active):s=r,s.length>0||!n){let t;if(!a&&!c){let n=e.activeItems[0];n&&i.indexOf(n)!==-1&&(t=n)}l({items:[...i,...s],active:a||c||t})}}finally{o.isCancellationRequested||(e.busy=!1),r=!0}})()])};if(c!==null){if(W6n(c))await u(c);else if(!(c instanceof Promise))l(c);else{e.busy=!0;try{let e=await c;if(o.isCancellationRequested)return;W6n(e)?await u(e):l(e)}finally{o.isCancellationRequested||(e.busy=!1)}}}};r.add(e.onDidChangeValue(()=>o())),o(),r.add(e.onDidAccept(t=>{if(n?.handleAccept){t.inBackground||e.hide(),n.handleAccept?.(e.activeItems[0],t.inBackground);return}let[r]=e.selectedItems;typeof r?.accept==`function`&&(t.inBackground||e.hide(),r.accept(e.keyMods,t))}));let s=async(n,r)=>{if(typeof r.trigger!=`function`)return;let i=r.buttons?.indexOf(n)??-1;if(i>=0){let n=r.trigger(i,e.keyMods),a=typeof n==`number`?n:await n;if(t.isCancellationRequested)return;switch(a){case J5.NO_ACTION:break;case J5.CLOSE_PICKER:e.hide();break;case J5.REFRESH_PICKER:o();break;case J5.REMOVE_ITEM:{let t=e.items.indexOf(r);if(t!==-1){let n=e.items.slice(),r=n.splice(t,1),i=e.activeItems.filter(e=>e!==r[0]),a=e.keepScrollPosition;e.keepScrollPosition=!0,e.items=n,i&&(e.activeItems=i),e.keepScrollPosition=a}break}}}};return r.add(e.onDidTriggerItemButton(({button:e,item:t})=>s(e,t))),r.add(e.onDidTriggerSeparatorButton(({button:e,separator:t})=>s(e,t))),r}};new hB(1e4);var K6n=new hB(1e4);function q6n(e){return Y6n(e,`NFD`,K6n)}var J6n=/[^\u0000-\u0080]/;function Y6n(e,t,n){if(!e)return e;let r=n.get(e);if(r)return r;let i;return i=J6n.test(e)?e.normalize(t):e,n.set(e,i),i}var X6n=(function(){let e=/[\u0300-\u036f]/g;return function(t){return q6n(t).replace(e,``)}})(),Z6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},Y5=function(e,t){return function(n,r){t(n,r,e)}},X5,Z5,Q6n=class extends G6n{static{X5=this}static{this.PREFIX=`>`}static{this.TFIDF_THRESHOLD=.5}static{this.TFIDF_MAX_RESULTS=5}static{this.WORD_FILTER=_X(vX,iyn,Gvn)}constructor(e,t,n,r,i,a){super(X5.PREFIX,e),this.keybindingService=n,this.commandService=r,this.telemetryService=i,this.dialogService=a,this.commandsHistory=this._register(t.createInstance($6n)),this.options=e}async _getPicks(e,t,n,r){let i=await this.getCommandPicks(n);if(n.isCancellationRequested)return[];let a=zP(()=>{let t=new V6n;return t.updateDocuments(i.map(e=>({key:e.commandId,textChunks:[this.getTfIdfChunk(e)]}))),H6n(t.calculateScores(e,n)).filter(e=>e.score>X5.TFIDF_THRESHOLD).slice(0,X5.TFIDF_MAX_RESULTS)}),o=this.normalizeForFiltering(e),s=[];for(let t of i){t.labelNoAccents??=this.normalizeForFiltering(t.label);let r=X5.WORD_FILTER(o,t.labelNoAccents)??void 0,i;if(t.commandAlias&&(t.aliasNoAccents??=this.normalizeForFiltering(t.commandAlias),i=X5.WORD_FILTER(o,t.aliasNoAccents)??void 0),r||i)t.highlights={label:r,detail:this.options.showAlias?i:void 0},s.push(t);else if(e===t.commandId)s.push(t);else if(e.length>=3){let e=a();if(n.isCancellationRequested)return[];let r=e.find(e=>e.key===t.commandId);r&&(t.tfIdfScore=r.score,s.push(t))}}let c=new Map;for(let e of s){let t=c.get(e.label);t?(e.description=e.commandId,t.description=t.commandId):c.set(e.label,e)}s.sort((e,t)=>{if(e.tfIdfScore&&t.tfIdfScore)return e.tfIdfScore===t.tfIdfScore?e.label.localeCompare(t.label):t.tfIdfScore-e.tfIdfScore;if(e.tfIdfScore)return 1;if(t.tfIdfScore)return-1;let n=this.commandsHistory.peek(e.commandId),r=this.commandsHistory.peek(t.commandId);if(n&&r)return n>r?-1:1;if(n)return-1;if(r)return 1;if(this.options.suggestedCommandIds){let n=this.options.suggestedCommandIds.has(e.commandId),r=this.options.suggestedCommandIds.has(t.commandId);if(n&&r)return 0;if(n)return-1;if(r)return 1}let i=e.commandCategory===u4n.Developer.value,a=t.commandCategory===u4n.Developer.value;return i&&!a?1:!i&&a?-1:e.label.localeCompare(t.label)});let l=[],u=!1,d=!0,f=!!this.options.suggestedCommandIds;for(let e=0;e<s.length;e++){let t=s[e];e===0&&this.commandsHistory.peek(t.commandId)&&(l.push({type:`separator`,label:H(1740,`recently used`)}),u=!0),d&&t.tfIdfScore!==void 0&&(l.push({type:`separator`,label:H(1741,`similar commands`)}),d=!1),f&&t.tfIdfScore===void 0&&!this.commandsHistory.peek(t.commandId)&&this.options.suggestedCommandIds?.has(t.commandId)&&(l.push({type:`separator`,label:H(1742,`commonly used`)}),u=!0,f=!1),u&&t.tfIdfScore===void 0&&!this.commandsHistory.peek(t.commandId)&&!this.options.suggestedCommandIds?.has(t.commandId)&&(l.push({type:`separator`,label:H(1743,`other commands`)}),u=!1),l.push(this.toCommandPick(t,r))}return this.hasAdditionalCommandPicks(e,n)?{picks:l,additionalPicks:(async()=>{let t=await this.getAdditionalCommandPicks(i,s,e,n);if(n.isCancellationRequested)return[];let a=t.map(e=>this.toCommandPick(e,r));return d&&a[0]?.type!==`separator`&&a.unshift({type:`separator`,label:H(1744,`similar commands`)}),a})()}:l}toCommandPick(e,t){if(e.type===`separator`)return e;let n=this.keybindingService.lookupKeybinding(e.commandId),r=n?H(1745,`{0}, {1}`,e.label,n.getAriaLabel()):e.label;return{...e,ariaLabel:r,detail:this.options.showAlias&&e.commandAlias!==e.label?e.commandAlias:void 0,keybinding:n,accept:async()=>{this.commandsHistory.push(e.commandId),this.telemetryService.publicLog2(`workbenchActionExecuted`,{id:e.commandId,from:t?.from??`quick open`});try{e.args?.length?await this.commandService.executeCommand(e.commandId,...e.args):await this.commandService.executeCommand(e.commandId)}catch(t){tP(t)||this.dialogService.error(H(1746,`Command '{0}' resulted in an error`,e.label),L2(t))}}}}getTfIdfChunk({label:e,commandAlias:t,commandDescription:n}){let r=e;return t&&t!==e&&(r+=` - ${t}`),n&&n.value!==e&&(r+=` - ${n.value===n.original?n.value:`${n.value} (${n.original})`}`),r}normalizeForFiltering(e){let t=X6n(e);return t.length===e.length?t:(this.telemetryService.publicLog2(`QuickAccess:FilterLengthMismatch`,{originalLength:e.length,normalizedLength:t.length}),e)}};Q6n=X5=Z6n([Y5(1,kz),Y5(2,UK),Y5(3,Bz),Y5(4,pB),Y5(5,PY)],Q6n);var $6n=class extends G{static{Z5=this}static{this.DEFAULT_COMMANDS_HISTORY_LENGTH=50}static{this.PREF_KEY_CACHE=`commandPalette.mru.cache`}static{this.PREF_KEY_COUNTER=`commandPalette.mru.counter`}static{this.counter=1}static{this.hasChanges=!1}constructor(e,t,n){super(),this.storageService=e,this.configurationService=t,this.logService=n,this.configuredCommandsHistoryLength=0,this.updateConfiguration(),this.load(),this.registerListeners()}registerListeners(){this._register(this.configurationService.onDidChangeConfiguration(e=>this.updateConfiguration(e))),this._register(this.storageService.onWillSaveState(e=>{e.reason===xQ.SHUTDOWN&&this.saveState()}))}updateConfiguration(e){(!e||e.affectsConfiguration(`workbench.commandPalette.history`))&&(this.configuredCommandsHistoryLength=Z5.getConfiguredCommandHistoryLength(this.configurationService),Z5.cache&&Z5.cache.limit!==this.configuredCommandsHistoryLength&&(Z5.cache.limit=this.configuredCommandsHistoryLength,Z5.hasChanges=!0))}load(){let e=this.storageService.get(Z5.PREF_KEY_CACHE,0),t;if(e)try{t=JSON.parse(e)}catch(e){this.logService.error(`[CommandsHistory] invalid data: ${e}`)}let n=Z5.cache=new hB(this.configuredCommandsHistoryLength,1);if(t){let e;e=t.usesLRU?t.entries:t.entries.sort((e,t)=>e.value-t.value),e.forEach(e=>n.set(e.key,e.value))}Z5.counter=this.storageService.getNumber(Z5.PREF_KEY_COUNTER,0,Z5.counter)}push(e){Z5.cache&&(Z5.cache.set(e,Z5.counter++),Z5.hasChanges=!0)}peek(e){return Z5.cache?.peek(e)}saveState(){if(!Z5.cache||!Z5.hasChanges)return;let e={usesLRU:!0,entries:[]};Z5.cache.forEach((t,n)=>e.entries.push({key:n,value:t})),this.storageService.store(Z5.PREF_KEY_CACHE,JSON.stringify(e),0,0),this.storageService.store(Z5.PREF_KEY_COUNTER,Z5.counter,0,0),Z5.hasChanges=!1}static getConfiguredCommandHistoryLength(e){let t=e.getValue().workbench?.commandPalette?.history;return typeof t==`number`?t:Z5.DEFAULT_COMMANDS_HISTORY_LENGTH}};$6n=Z5=Z6n([Y5(0,bQ),Y5(1,ZB),Y5(2,wB)],$6n);var e8n=class extends Q6n{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a)}getCodeEditorCommandPicks(){let e=this.activeTextEditorControl;if(!e)return[];let t=[];for(let n of e.getSupportedActions()){let e;n.metadata?.description&&(e=$wn(n.metadata.description)?n.metadata.description:{original:n.metadata.description,value:n.metadata.description}),t.push({commandId:n.id,commandAlias:n.alias,commandDescription:e,label:VX(n.label)||n.id})}return t}},t8n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},Q5=function(e,t){return function(n,r){t(n,r,e)}},$5=class extends e8n{get activeTextEditorControl(){return this.codeEditorService.getFocusedCodeEditor()??void 0}constructor(e,t,n,r,i,a){super({showAlias:!1},e,n,r,i,a),this.codeEditorService=t}async getCommandPicks(){return this.getCodeEditorCommandPicks()}hasAdditionalCommandPicks(){return!1}async getAdditionalCommandPicks(){return[]}};$5=t8n([Q5(0,kz),Q5(1,jz),Q5(2,UK),Q5(3,Bz),Q5(4,pB),Q5(5,PY)],$5);var n8n=class e extends kB{static{this.ID=`editor.action.quickCommand`}constructor(){super({id:e.ID,label:PCn.quickCommandActionLabel,alias:`Command Palette`,precondition:void 0,kbOpts:{kbExpr:$.focus,primary:59,weight:100},contextMenuOpts:{group:`z_commands`,order:1}})}run(e){e.get(_Q).quickAccess.show($5.PREFIX)}};PB(n8n),tB.as(L$.Quickaccess).registerQuickAccessProvider({ctor:$5,prefix:$5.PREFIX,helpEntries:[{description:PCn.quickCommandHelp,commandId:n8n.ID}]});var r8n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},e7=function(e,t){return function(n,r){t(n,r,e)}},i8n=class extends f3{constructor(e,t,n,r,i,a,o){super(!0,e,t,n,r,i,a,o)}};i8n=r8n([e7(1,$z),e7(2,jz),e7(3,MK),e7(4,kz),e7(5,bQ),e7(6,ZB)],i8n),IB(f3.ID,i8n,4),PB(class extends kB{constructor(){super({id:`editor.action.toggleHighContrast`,label:ICn.toggleHighContrast,alias:`Toggle High Contrast Theme`,precondition:void 0}),this._originalThemeName=null}run(e,t){let n=e.get(l0),r=n.getColorTheme();vW(r.type)?(n.setTheme(this._originalThemeName||(yW(r.type)?`vs-dark`:`vs`)),this._originalThemeName=null):(n.setTheme(yW(r.type)?a0:o0),this._originalThemeName=r.themeName)}});var a8n={},o8n={},s8n=class e{static getOrCreate(t){return o8n[t]||(o8n[t]=new e(t)),o8n[t]}constructor(e){this._languageId=e,this._loadingTriggered=!1,this._lazyLoadPromise=new Promise((e,t)=>{this._lazyLoadPromiseResolve=e,this._lazyLoadPromiseReject=t})}load(){return this._loadingTriggered||(this._loadingTriggered=!0,a8n[this._languageId].loader().then(e=>this._lazyLoadPromiseResolve(e),e=>this._lazyLoadPromiseReject(e))),this._lazyLoadPromise}};function c8n(e){let t=e.id;a8n[t]=e,m2.register(e);let n=s8n.getOrCreate(t);m2.registerTokensProviderFactory(t,{create:async()=>(await n.load()).language}),m2.onLanguageEncountered(t,async()=>{let e=await n.load();m2.setLanguageConfiguration(t,e.conf)})}c8n({id:`markdown`,extensions:[`.md`,`.markdown`,`.mdown`,`.mkdn`,`.mkd`,`.mdwn`,`.mdtxt`,`.mdtext`],aliases:[`Markdown`,`markdown`],loader:()=>I(()=>import(`./markdown-Cimd5fb3.js`),[])});function l8n(e){return new Worker(`/assets/editor.worker-O-CH8JUO.js`,{name:e?.name})}self.MonacoEnvironment={getWorker:()=>new l8n},P$t.config({monaco:$In});function u8n({value:e,onChange:t,disabled:n=!1}){return(0,z.jsx)(Z$t,{height:`100%`,language:`markdown`,theme:`vs-dark`,value:e,loading:(0,z.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading editor…`}),options:{ariaLabel:`Context markdown editor`,tabFocusMode:!0,minimap:{enabled:!1},wordWrap:`on`,lineNumbers:`on`,readOnly:n,scrollBeyondLastLine:!1,fontSize:13,padding:{top:16,bottom:16},automaticLayout:!0},onChange:e=>t(e??``)})}var d8n=class extends Error{status;body;constructor(e,t,n){super(e),this.status=t,this.body=n,this.name=`ContextApiError`}},f8n={layers:[`context`,`layers`]};async function p8n(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function m8n(e,t){if(t&&typeof t==`object`){let e=t;if(typeof e.error==`string`)return e.error;if(typeof e.message==`string`)return e.message}return typeof t==`string`&&t.trim()?t:`Context API request failed with status ${e}`}async function t7(e,t){let n={Accept:`application/json`};t.body!==void 0&&(n[`Content-Type`]=`application/json`);let r=await fetch(e,{method:t.method,credentials:`include`,headers:n,body:t.body===void 0?void 0:JSON.stringify(t.body)}),i=await p8n(r);if(!r.ok)throw new d8n(m8n(r.status,i),r.status,i);return i}function h8n(){return t7(`/api/context/layers`,{method:`GET`})}function g8n(e){return t7(`/api/context/preview`,{method:`POST`,body:e})}function _8n(e){return t7(`/api/context/layers`,{method:`PUT`,body:e})}function v8n(e={operation:`sync`}){return t7(`/api/context/sync`,{method:`POST`,body:e})}function y8n(){return F({queryKey:f8n.layers,queryFn:h8n})}function b8n(){return Cn({mutationFn:g8n})}function x8n(){let e=$t();return Cn({mutationFn:_8n,onSuccess:()=>{e.invalidateQueries({queryKey:f8n.layers})}})}function S8n(){let e=$t();return Cn({mutationFn:v8n,onSuccess:()=>{e.invalidateQueries({queryKey:f8n.layers})}})}var C8n={global:`Every project on this machine`,project:`One project, including its workspaces`,workspace:`One issue workspace`},w8n=[[`claude-code`,`Claude Code`],[`codex`,`Codex`],[`ohmypi`,`oh-my-pi`],[`kimi-code`,`Kimi Code`],[`acp`,`ACP`],[`muse`,`Muse`],[`opencode`,`OpenCode`],[`prime-agent`,`Prime Agent`],[`fullPrompt`,`All harnesses`]];function n7(e){switch(e.kind){case`global`:return`global`;case`project`:return`project:${e.projectKey}`;case`workspace`:return`workspace:${e.projectKey}:${e.workspacePath}`}}function T8n(e){switch(e.kind){case`global`:return{kind:`global`};case`project`:return{kind:`project`,projectKey:e.projectKey};case`workspace`:return{kind:`workspace`,projectKey:e.projectKey,workspacePath:e.workspacePath}}}function E8n(e){switch(e.kind){case`global`:return`~/.overdeck/context/global.md`;case`project`:return e.file.includes(`/.pan/`)?`.pan/context/project.md`:`.overdeck/context/project.md`;case`workspace`:return e.file.includes(`/.pan/`)?`.pan/context/workspace.md`:`.overdeck/context/workspace.md`}}function D8n(e){switch(e){case`global`:return`Machine context`;case`project`:return`Project context`;case`workspace`:return`Workspace context`}}function r7(e){return e instanceof Error?e.message:String(e||`Unknown error`)}function O8n({error:e}){return(0,z.jsx)(`div`,{className:`h-full w-full p-6`,children:(0,z.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load context layers: `,r7(e)]})})}function k8n(e){let t=e.layer?n7(e.layer):`preview`;return`${e.level.toUpperCase()} · ${t}: ${e.message}`}function A8n(){let{data:e,isLoading:t,error:n,refetch:r}=y8n(),i=b8n(),a=x8n(),o=S8n(),s=i.mutateAsync,[c,l]=(0,L.useState)(`global`),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)({}),[g,_]=(0,L.useState)(`edit`),[v,y]=(0,L.useState)(`claude-code`),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),[w,T]=(0,L.useState)(null),E=(0,L.useMemo)(()=>e?.workspaces.filter(e=>e.projectKey===u)??[],[e?.workspaces,u]);(0,L.useEffect)(()=>{if(!e)return;let t=e.projects[0]?.projectKey??``;d(n=>e.projects.some(e=>e.projectKey===n)?n:t)},[e]),(0,L.useEffect)(()=>{if(!e)return;let t=E.some(e=>e.path===f);p(t?f:E[0]?.path??``)},[e,E,f]);let D=(0,L.useMemo)(()=>c===`global`?{kind:`global`}:u?c===`project`?{kind:`project`,projectKey:u}:f?{kind:`workspace`,projectKey:u,workspacePath:f}:null:null,[c,u,f]),O=(0,L.useMemo)(()=>{if(!e||!D)return null;let t=n7(D);return e.layers.find(e=>n7(T8n(e))===t)??null},[e,D]),k=(0,L.useMemo)(()=>e?e.layers.flatMap(e=>{let t=T8n(e),n=m[n7(t)];return n===void 0?[]:[{target:t,content:n}]}):[],[e,m]),A=D?n7(D):``,j=O?m[A]??O.content:``,ee=e?.projects.find(e=>e.projectKey===u)??null,M=e?.workspaces.find(e=>e.path===f)??null,N=!!O&&m[A]!==void 0&&m[A]!==O.content,P=a.isPending||o.isPending;(0,L.useEffect)(()=>{if(!D||!O){x(null);return}let e=!1;C(null),x(null);let t=window.setTimeout(()=>{s({operation:`preview`,selectedLayer:D,drafts:k}).then(t=>{e||x(t)}).catch(t=>{e||C(r7(t))})},300);return()=>{e=!0,window.clearTimeout(t)}},[k,s,O,D]);async function te(e){if(D&&O){T(null);try{await a.mutateAsync({operation:`save`,target:D,content:j}),e&&await o.mutateAsync({operation:`sync`}),await r(),h(e=>{let{[A]:t,...n}=e;return n}),B.success(e?`Context saved and outputs refreshed. Applies to new sessions.`:`Context saved. Applies to new sessions.`)}catch(e){let t=r7(e);T(t),B.error(t)}}}if(t)return(0,z.jsx)(`div`,{className:`h-full w-full p-6 text-sm text-muted-foreground`,children:`Loading context layers…`});if(n)return(0,z.jsx)(O8n,{error:n});let ne=b?.previews[v]??``,re=b?.diagnostics??[];return(0,z.jsxs)(`div`,{className:`context-page h-full w-full min-w-0 overflow-auto bg-background text-foreground`,children:[(0,z.jsxs)(`header`,{className:`border-b border-border px-5 py-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Agent context`}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Choose where instructions apply, edit their source, and preview what Overdeck adds to a new session.`}),(0,z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Running conversations keep their existing context. Your CLAUDE.md and AGENTS.md files stay under your control.`})]}),(0,z.jsxs)(`div`,{className:`context-layout`,children:[(0,z.jsxs)(`aside`,{className:`context-sources border-border bg-card/30 p-4`,children:[(0,z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,z.jsx)(`legend`,{className:`mb-2 text-sm font-semibold`,children:`Where should this apply?`}),[`global`,`project`,`workspace`].map(e=>(0,z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md p-2 text-sm hover:bg-muted ${c===e?`bg-accent text-accent-foreground`:``}`,children:[(0,z.jsx)(`input`,{className:`mt-1`,type:`radio`,name:`context-layer-kind`,value:e,"aria-label":D8n(e),checked:c===e,onChange:()=>l(e)}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`block font-medium`,children:D8n(e)}),(0,z.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-muted-foreground`,children:C8n[e]})]})]},e))]}),c!==`global`&&(0,z.jsxs)(`label`,{className:`mt-4 block text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Project`}),(0,z.jsx)(`select`,{className:`mt-1 w-full rounded-md border border-border bg-background px-2 py-2`,value:u,onChange:e=>d(e.target.value),disabled:!e?.projects.length,children:e?.projects.length?e.projects.map(e=>(0,z.jsx)(`option`,{value:e.projectKey,children:e.name},e.projectKey)):(0,z.jsx)(`option`,{value:``,children:`No registered projects`})})]}),c===`workspace`&&(0,z.jsxs)(`label`,{className:`mt-4 block text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Workspace`}),(0,z.jsx)(`select`,{className:`mt-1 w-full rounded-md border border-border bg-background px-2 py-2`,value:f,onChange:e=>p(e.target.value),disabled:!E.length,children:E.length?E.map(e=>(0,z.jsx)(`option`,{value:e.path,children:e.issueId??e.name},e.path)):(0,z.jsx)(`option`,{value:``,children:`No workspaces for this project`})})]}),(0,z.jsxs)(`div`,{className:`mt-5 border-t border-border pt-4 text-xs leading-5 text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:c===`global`?`Keep machine context specific`:c===`project`?`Shared project guidance`:`Generated workspace context`}),(0,z.jsx)(`p`,{className:`mt-1`,children:c===`global`?`Use this for local paths or machine quirks. Rules for every machine belong in bundled rules.`:c===`project`?`Use this for project conventions and requirements. Commit the source file to share it with your team.`:`Overdeck assembles this from issue metadata, memory, and status. It may not exist until a workspace is created.`})]}),(0,z.jsxs)(`details`,{className:`mt-5 border-t border-border pt-4 text-xs leading-5 text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground`,children:`Other instruction sources`}),(0,z.jsx)(`p`,{className:`mt-2`,children:`The preview combines your selected scope with applicable machine context and bundled rules. Project and workspace sources join it when selected.`}),(0,z.jsxs)(`p`,{className:`mt-2`,children:[`Bundled rules live in `,(0,z.jsx)(`code`,{className:`break-all`,children:`sync-sources/rules/`}),`. Each rule in the preview names its source.`]}),(0,z.jsx)(`p`,{className:`mt-2`,children:`Role instructions and the session briefing can add launch context. The harness also loads its own user, project, and organization instructions, memory, and skills. These are not editable here.`})]}),(0,z.jsxs)(`details`,{className:`mt-4 border-t border-border pt-4 text-xs leading-5 text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground`,children:`Generated output files`}),(0,z.jsx)(`p`,{className:`mt-2`,children:`Overdeck passes context at launch. Refresh updates its saved global outputs; it does not rewrite native instruction files or update running conversations.`}),(0,z.jsx)(`ul`,{className:`mt-3 space-y-3`,children:e?.targets.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:e.label}),(0,z.jsx)(`code`,{className:`block break-all`,children:e.path}),(0,z.jsx)(`p`,{children:e.deliveryChannel===`codex-developer-instructions`?`Added as developer instructions.`:`Appended to the session’s system prompt.`}),(0,z.jsx)(`p`,{children:e.exists?`${e.byteCount.toLocaleString()} bytes`:`Created on next refresh.`})]},e.path))}),(0,z.jsx)(`button`,{type:`button`,className:`mt-3 rounded-md border border-border px-3 py-2 text-foreground disabled:opacity-50`,disabled:P||N,onClick:()=>{T(null),o.mutateAsync({operation:`sync`}).then(()=>r()).then(()=>B.success(`Outputs refreshed. Applies to new sessions.`)).catch(e=>T(r7(e)))},children:`Refresh outputs`}),N&&(0,z.jsx)(`p`,{className:`mt-1`,children:`Save your changes before refreshing outputs.`})]})]}),(0,z.jsxs)(`section`,{className:`context-workbench flex min-w-0 flex-col`,children:[(0,z.jsxs)(`header`,{className:`border-b border-border px-5 py-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-base font-semibold`,children:D8n(c)}),O&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:N?`Edited`:`Loaded`})]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:c===`global`?C8n.global:c===`project`?ee?.name??`No project selected`:M?.issueId??M?.name??`No workspace selected`}),O&&(0,z.jsxs)(`details`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer break-all font-mono`,children:E8n(O)}),(0,z.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:O.file}),(0,z.jsx)(`p`,{className:`mt-1`,children:O.exists?`File exists`:`File has not been created yet`})]}),(0,z.jsx)(`div`,{className:`mt-4 flex gap-2`,role:`group`,"aria-label":`Context view`,children:[`edit`,`preview`].map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":g===e,onClick:()=>_(e),className:`rounded-md px-3 py-2 text-sm font-medium ${g===e?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-muted`}`,children:e===`edit`?`Edit source`:`Preview for agent`},e))})]}),(0,z.jsx)(`div`,{className:`context-editor flex-1`,hidden:g!==`edit`,children:O?(0,z.jsx)(u8n,{value:j,disabled:P,onChange:e=>h(t=>({...t,[A]:e}))}):(0,z.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:c===`workspace`?`Create a workspace for this project to edit its context.`:`Register a project in Projects to add project context.`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,hidden:g!==`preview`,children:[(0,z.jsxs)(`div`,{className:`border-b border-border px-5 py-4`,children:[(0,z.jsxs)(`label`,{className:`flex flex-wrap items-center gap-3 text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Preview for`}),(0,z.jsx)(`select`,{className:`rounded-md border border-border bg-background px-3 py-2`,"aria-label":`Preview for`,value:v,onChange:e=>y(e.target.value),children:w8n.map(([e,t])=>(0,z.jsx)(`option`,{value:e,children:t},e))})]}),(0,z.jsxs)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:[N?`Includes your unsaved edits. `:``,`This previews Overdeck’s context layers. It is not a transcript or a complete view of the harness’s system prompt.`]})]}),(0,z.jsx)(`div`,{className:`p-5`,"aria-live":`polite`,children:S?(0,z.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not render preview: `,S,`. Edit the source to try again.`]}):ne?(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-6`,children:ne}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:O?`Rendering preview…`:`Select an available source to preview its context.`})})]}),(0,z.jsx)(`div`,{className:`border-t border-border px-5 py-3 text-xs`,"aria-live":`polite`,children:re.length>0?(0,z.jsx)(`ul`,{className:`space-y-2`,children:re.map((e,t)=>(0,z.jsx)(`li`,{className:e.level===`error`?`text-destructive`:`text-warning-foreground`,children:k8n(e)},`${e.message}-${t}`))}):(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:b?`No validation issues.`:O?`Validation updates with the preview.`:`No source selected.`})}),(0,z.jsxs)(`footer`,{className:`sticky bottom-0 flex flex-wrap items-center justify-between gap-3 border-t border-border bg-background px-5 py-3`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:w?(0,z.jsx)(`span`,{role:`alert`,className:`text-destructive`,children:w}):N?`Unsaved changes`:`No unsaved changes`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-2 text-sm disabled:opacity-50`,disabled:!N||P||!O,onClick:()=>void te(!1),children:a.isPending&&!o.isPending?`Saving…`:`Save`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50`,disabled:!N||P||!O,onClick:()=>void te(!0),children:o.isPending?`Refreshing…`:`Save & refresh outputs`})]})]})]})]})]})}var j8n=!1,M8n=5e3;function N8n(e=j8n){return e?`Browse, search, and edit this project knowledge bundle.`:`View and search here; edit knowledge through /okf author so changes stay PR-gated.`}async function P8n(e){let t=await fetch(`/api/knowledge-viewer/status?project=${encodeURIComponent(e)}`,{credentials:`include`}),n=await t.json();if(!t.ok)throw Error(n.error||`Knowledge viewer status could not be loaded`);return n}async function F8n(e,t){let n=await fetch(`/api/knowledge-viewer/${e}`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({project:t})}),r=await n.json();if(!n.ok)throw Error(r.error||`Knowledge viewer ${e} failed`);return r}function I8n({projectKey:e}){let t=$t(),n=(0,L.useRef)(null),r=(0,L.useRef)(null),[i,a]=(0,L.useState)(`loading`),o=F({queryKey:[`command-deck-projects`],queryFn:Ou,enabled:!e,staleTime:3e4}),s=(0,L.useMemo)(()=>e??o.data?.[0]?.key??null,[e,o.data]),c=F({queryKey:[`knowledge-viewer-status`,s],queryFn:()=>P8n(s),enabled:!!s,refetchInterval:2e3}),l=Cn({mutationFn:()=>F8n(`install`,s),onSuccess:async()=>{n.current=null,await t.invalidateQueries({queryKey:[`knowledge-viewer-status`,s]})}}),u=Cn({mutationFn:()=>F8n(`start`,s),onSuccess:e=>{t.setQueryData([`knowledge-viewer-status`,s],e)}}),d=c.data;(0,L.useEffect)(()=>{if(!s){r.current=null;return}if(d?.running){n.current=null,r.current=s;return}r.current===s&&(n.current=null,r.current=null)},[s,d?.running]),(0,L.useEffect)(()=>{s&&d?.bundleConfigured&&d.installed&&!d.running&&!d.starting&&(n.current===s||u.isPending||(n.current=s,u.mutate()))},[s,u,d]),(0,L.useEffect)(()=>{if(a(`loading`),!d?.running)return;if(d.embeddable===!1||!d.proxyUrl){a(`blocked`);return}let e=window.setTimeout(()=>a(`blocked`),M8n);return()=>window.clearTimeout(e)},[s,d?.embeddable,d?.proxyUrl,d?.running]);let f=(0,L.useCallback)(()=>a(`ready`),[]),p=(0,L.useCallback)(()=>{n.current=s,u.reset(),u.mutate()},[s,u]),m=o.isLoading||!!s&&c.isLoading,h=o.error??c.error??l.error??u.error,g=d?.starting||u.isPending,_=d?.running&&(d.embeddable===!1||!d.proxyUrl||i===`blocked`);return(0,z.jsx)(`main`,{className:`h-full overflow-y-auto bg-background p-6`,"data-testid":`knowledge-page`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6`,children:[(0,z.jsxs)(`header`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(co,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),(0,z.jsx)(`h1`,{className:`text-xl font-medium text-foreground`,children:`Knowledge`})]}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:N8n()})]}),m&&(0,z.jsx)(L8n,{title:`Loading knowledge configuration`}),!m&&!s&&(0,z.jsx)(R8n,{title:`No project is available`,description:`Register a project before opening its knowledge bundle.`}),!m&&h&&(0,z.jsx)(`section`,{className:`rounded-lg bg-card p-6`,role:`alert`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(go,{className:`mt-0.5 h-5 w-5 text-destructive`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Knowledge viewer unavailable`}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:h.message}),d?.bundleConfigured&&d.installed&&(0,z.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 text-sm font-medium text-primary hover:underline`,children:`Retry viewer`})]})]})}),!m&&!h&&d&&!d.bundleConfigured&&(0,z.jsx)(R8n,{title:`No knowledge bundle configured`,description:`Create or connect the project knowledge bundle, then return here.`,command:`/okf init`}),!m&&!h&&d?.bundleConfigured&&!d.installed&&(0,z.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Install the local knowledge viewer`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`OpenKnowledge is installed only after this explicit request. It runs as a separate local program.`}),d.message&&(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl font-mono text-xs text-muted-foreground`,children:d.message}),d.setupPlan?.steps.length?(0,z.jsx)(`ol`,{className:`mt-4 max-w-2xl list-decimal space-y-2 pl-5 text-sm text-muted-foreground`,"data-testid":`knowledge-setup-plan`,children:d.setupPlan.steps.map(e=>(0,z.jsx)(`li`,{children:e},e))}):null,(0,z.jsxs)(`button`,{type:`button`,onClick:()=>l.mutate(),disabled:l.isPending,className:`mt-5 inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-opacity disabled:opacity-50`,children:[l.isPending?(0,z.jsx)(is,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}):(0,z.jsx)(jo,{className:`h-4 w-4`,"aria-hidden":`true`}),l.isPending?`Setting up the viewer`:`Set up the viewer`]})]}),!m&&!h&&d?.bundleConfigured&&d.installed&&g&&(0,z.jsx)(L8n,{title:`Starting knowledge viewer`}),!m&&!h&&d?.bundleConfigured&&d.installed&&!d.running&&!g&&n.current===s&&(0,z.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,"data-testid":`knowledge-viewer-stopped`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Knowledge viewer stopped`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`The local viewer exited before it could reconnect. Restart the read-only snapshot to continue browsing.`}),(0,z.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 text-sm font-medium text-primary hover:underline`,children:`Restart viewer`})]}),!m&&!h&&_&&(0,z.jsx)(`section`,{className:`rounded-lg bg-card p-6`,"data-testid":`knowledge-viewer-blocked`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(go,{className:`mt-0.5 h-5 w-5 text-warning`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Viewer opens in a separate tab`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`The local viewer refused dashboard framing. Open its disposable read-only snapshot directly to browse and search.`}),d.url&&(0,z.jsx)(`a`,{href:d.url,target:`_blank`,rel:`noreferrer`,className:`mt-4 inline-flex text-sm font-medium text-primary hover:underline`,children:`Open viewer`})]})]})}),!m&&!h&&d?.running&&d.proxyUrl&&!_&&(0,z.jsxs)(`section`,{className:`relative flex min-h-[70vh] flex-col overflow-hidden rounded-lg bg-card`,"data-testid":`knowledge-viewer-embedded`,children:[(0,z.jsx)(`div`,{className:`border-b border-border px-4 py-3`,children:(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Read-only snapshot — viewer edits are discarded. Use `,(0,z.jsx)(`span`,{className:`font-mono`,children:`/okf author`}),` for durable changes.`]})}),i===`loading`&&(0,z.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 top-11 z-10 flex items-center justify-center bg-card`,children:(0,z.jsx)(L8n,{title:`Loading knowledge workspace`})}),(0,z.jsx)(`iframe`,{title:`OpenKnowledge viewer`,src:d.proxyUrl,sandbox:`allow-downloads allow-forms allow-popups allow-same-origin allow-scripts`,onLoad:f,onError:()=>a(`blocked`),className:`min-h-[66vh] w-full flex-1 border-0 bg-background`})]})]})})}function L8n({title:e}){return(0,z.jsx)(`section`,{className:`rounded-lg bg-card p-6`,role:`status`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(is,{className:`h-5 w-5 animate-spin text-info`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`This usually takes a few seconds.`})]})]})})}function R8n({title:e,description:t,command:n}){return(0,z.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:t}),n&&(0,z.jsx)(`code`,{className:`mt-4 inline-block rounded-sm bg-muted px-2 py-1 font-mono text-xs text-foreground`,children:n})]})}function z8n({sessions:e,selectedId:t,onSelect:n,hasMore:r=!1,isLoadingMore:i=!1,onLoadMore:a}){let o=(0,L.useRef)(null),s=kv({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>36,overscan:12}),c=s.getVirtualItems();return(0,L.useEffect)(()=>{let t=c.at(-1);t&&r&&!i&&a&&t.index>=e.length-8&&a()},[r,i,a,e.length,c]),(0,z.jsxs)(`div`,{ref:o,className:`flex-1 overflow-auto`,role:`table`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_minmax(14rem,1fr)_8rem_4rem_5rem_7rem] gap-3 border-b border-border bg-background px-3 py-2 text-xs font-medium text-muted-foreground sticky top-0 z-10`,role:`row`,children:[(0,z.jsx)(`div`,{}),(0,z.jsx)(`div`,{children:`Session`}),(0,z.jsx)(`div`,{children:`Model`}),(0,z.jsx)(`div`,{className:`text-right`,children:`Msgs`}),(0,z.jsx)(`div`,{className:`text-right`,children:`Cost`}),(0,z.jsx)(`div`,{children:`Last Active`})]}),(0,z.jsx)(`div`,{style:{height:s.getTotalSize(),position:`relative`},children:c.map(r=>{let i=e[r.index];if(!i)return null;let a=`${i.source}:${i.id}`,o=a===t,s=i.workspacePath??i.jsonlPath??`Unknown session path`,c=s.split(`/`).slice(-2).join(`/`),l=i.conversationTitle??i.conversationName??c,u=i.summary??s;return(0,z.jsxs)(`div`,{role:`row`,"data-session-key":a,onClick:()=>n(o?null:a),className:`absolute left-0 right-0 grid cursor-pointer grid-cols-[1.25rem_minmax(14rem,1fr)_8rem_4rem_5rem_7rem] items-center gap-3 border-b border-border px-3 text-xs transition-colors ${o?`bg-primary/8 border-primary/32`:`hover:bg-card`}`,style:{height:r.size,transform:`translateY(${r.start}px)`},children:[(0,z.jsx)(`div`,{className:`text-center`,children:i.source===`managed-archived`?(0,z.jsx)(Ude,{className:`inline h-3 w-3 text-muted-foreground`}):i.overdeckManaged?(0,z.jsx)(Ss,{className:`inline h-3 w-3 text-primary`}):i.enrichmentLevel>0?(0,z.jsx)(_o,{className:`inline h-3 w-3 text-success`}):(0,z.jsx)(So,{className:`inline h-3 w-3 text-muted-foreground/50`})}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`truncate text-foreground`,title:`${l} — ${u}`,children:l}),u&&(0,z.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:u}),i.source===`managed-archived`?(0,z.jsxs)(`span`,{className:`shrink-0 rounded-sm border border-border bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[`Archived`,i.panIssueId?` · ${i.panIssueId}`:``]}):i.overdeckManaged&&(0,z.jsxs)(`span`,{className:`shrink-0 rounded-sm border border-primary/32 bg-primary/8 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[`Managed`,i.panIssueId?` · ${i.panIssueId}`:``]}),i.harness!==`claude-code`&&(0,z.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border bg-card px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:i.harness})]}),(0,z.jsx)(`div`,{className:`truncate text-muted-foreground`,children:i.primaryModel?i.primaryModel.split(`-`).slice(-2).join(`-`):`—`}),(0,z.jsx)(`div`,{className:`text-right font-mono text-muted-foreground`,children:i.messageCount}),(0,z.jsx)(`div`,{className:`text-right font-mono`,children:i.estimatedCost>0?(0,z.jsxs)(`span`,{className:`text-signal-cost-foreground`,children:[`$`,i.estimatedCost.toFixed(4)]}):(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`—`})}),(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:i.lastTs?B8n(i.lastTs):`—`})]},a)})}),i&&(0,z.jsx)(`div`,{className:`px-3 py-2 text-center text-xs text-muted-foreground`,children:`Loading more…`})]})}function B8n(e){try{let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/864e5);return r===0?`today`:r===1?`yesterday`:r<7?`${r}d ago`:r<30?`${Math.floor(r/7)}w ago`:t.toISOString().slice(0,10)}catch{return e}}async function V8n(e){let t=await fetch(`/api/conversations/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Failed to load conversation: ${t.status}`);return await t.json()}async function H8n(e){let t=await fetch(`/api/discovered-sessions/${e}/messages`);if(t.status===410)throw Error(`TRANSCRIPT_GONE`);if(!t.ok)throw Error(`Failed to load transcript: ${t.status}`);return await t.json()}function U8n(e){return e.conversationName?e.conversationName:e.source===`managed-archived`?String(e.id):e.conversationId??null}function W8n({session:e}){let{resolvedTheme:t}=_p(),n=U8n(e),r=F({queryKey:[`sessions-feed-conversation`,n],queryFn:()=>V8n(n),enabled:n!==null,refetchInterval:5e3}),i=F({queryKey:[`discovered-session-messages`,e.id],queryFn:()=>H8n(e.id),enabled:n===null});return n===null?i.isLoading&&i.data===void 0?(0,z.jsx)(i7,{children:`Loading transcript…`}):i.error instanceof Error&&i.error.message===`TRANSCRIPT_GONE`?(0,z.jsx)(i7,{children:`Transcript file no longer on disk.`}):i.isError||i.data===void 0?(0,z.jsx)(i7,{children:`Couldn’t load this transcript.`}):(0,z.jsx)(zv,{messages:i.data.messages,workLog:i.data.workLog??[],streaming:i.data.streaming??!1,proposedPlan:i.data.proposedPlan,compactBoundaries:i.data.compactBoundaries,resolvedTheme:t,conversationName:e.conversationName??void 0,cwd:e.workspacePath??void 0,issueId:e.panIssueId}):r.isLoading&&r.data===void 0?(0,z.jsx)(i7,{children:`Loading conversation…`}):r.isError||r.data===void 0?(0,z.jsx)(i7,{children:`Couldn’t load this conversation.`}):(0,z.jsx)(oE,{conversation:r.data,viewMode:`conversation`,embedded:!0})}function i7({children:e}){return(0,z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e})}async function G8n(e,t){await Mc().request(n=>n[Ft.enrichSessions]({ids:[e],level:t.tier,confirmed:t.confirmed,...t.model?{model:t.model}:{}}))}async function K8n(e){await Mc().request(t=>t[Ft.embedSessions]({ids:[e]}))}async function q8n(e){if(!e)throw Error(`Archived conversation is missing its name`);let t=await fetch(`/api/conversations/${encodeURIComponent(e)}/unarchive`,{method:`POST`});if(!t.ok)throw Error(`Unarchive failed: ${t.status}`)}function J8n(e,t){let n=typeof e==`object`&&e&&`code`in e?String(e.code??``):``,r=/^COST_THRESHOLD:([^:]+):([^:]+):([^:]+)$/.exec(n);return r?{tier:t.tier,estimatedCost:Number(r[1]),threshold:Number(r[2]),sessionCount:Number(r[3]),model:t.model}:null}function Y8n(e){return{id:e.id,source:`discovered`,harness:e.harness??null,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,summaryDetailed:e.summaryDetailed??null,conversationId:e.conversationId??null,conversationName:e.conversationName??null,conversationTitle:e.conversationTitle??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function X8n(e){return Y8n(await Mc().request(t=>t[Ft.getDiscoveredSession]({id:e})))}function Z8n(e,t){return t?{...e,harness:t.harness??e.harness,jsonlPath:t.jsonlPath??e.jsonlPath,workspacePath:t.workspacePath??e.workspacePath,primaryModel:t.primaryModel??e.primaryModel,messageCount:t.messageCount||e.messageCount,firstTs:t.firstTs??e.firstTs,lastTs:t.lastTs??e.lastTs,estimatedCost:t.estimatedCost||e.estimatedCost,tokenInput:t.tokenInput||e.tokenInput,tokenOutput:t.tokenOutput||e.tokenOutput,toolsUsed:t.toolsUsed.length>0?t.toolsUsed:e.toolsUsed,filesTouched:t.filesTouched.length>0?t.filesTouched:e.filesTouched,tags:t.tags.length>0?t.tags:e.tags,summary:t.summary??e.summary,summaryDetailed:t.summaryDetailed??e.summaryDetailed,enrichmentLevel:t.enrichmentLevel||e.enrichmentLevel,enrichmentFailed:t.enrichmentFailed,panIssueId:t.panIssueId??e.panIssueId}:e}function Q8n({session:e,onClose:t}){let n=$t(),[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(``),s=e.source===`managed-archived`,c=s?e.discoveredId??null:e.id,l=Wt(t=>t.enrichProgressBySessionId[e.id]),{data:u}=F({queryKey:[`discovered-session`,c],queryFn:()=>X8n(c),staleTime:1/0,placeholderData:e,enabled:c!=null}),d=s?Z8n(e,u):u??e,f=d.conversationId??(s?String(d.id):null),p=()=>{n.invalidateQueries({queryKey:[`discovered-session`,e.id]}),n.invalidateQueries({queryKey:[`discovered-sessions`]}),n.invalidateQueries({queryKey:[`sessions-feed`]}),n.invalidateQueries({queryKey:[`sessions-feed-facets`]}),n.invalidateQueries({queryKey:[`discovered-sessions-search`]}),n.invalidateQueries({queryKey:[`discovered-sessions-stats`]})},m=Cn({mutationFn:t=>G8n(e.id,t),onSuccess:()=>{i(null),p()},onError:(e,t)=>{i(J8n(e,t))}}),h=Cn({mutationFn:()=>K8n(e.id),onSuccess:p}),g=Cn({mutationFn:()=>q8n(d.conversationName),onSuccess:()=>{n.invalidateQueries({queryKey:[`archived-conversations`]}),n.invalidateQueries({queryKey:[`sessions-feed`]}),n.invalidateQueries({queryKey:[`sessions-feed-facets`]}),n.invalidateQueries({queryKey:[`conversations`]})}}),_=(e,t)=>(0,z.jsxs)(`div`,{className:`flex gap-2 text-xs py-1 border-b border-border`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground w-28 shrink-0`,children:e}),(0,z.jsx)(`span`,{className:`text-foreground font-mono break-all`,children:t??`—`})]}),v=e=>{let t=a.trim();m.mutate({tier:e,...t?{model:t}:{}})};return(0,z.jsxs)(`div`,{className:`flex flex-col h-full border-l border-border bg-background`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[`Session #`,d.id]}),(0,z.jsx)(`span`,{className:d.overdeckManaged?`rounded border border-primary/32 bg-primary/8 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`:`rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,title:d.overdeckManaged?`Overdeck-managed session`:`Ad-hoc discovered session`,children:d.overdeckManaged?`Managed${d.panIssueId?` · ${d.panIssueId}`:``}`:`Ad-hoc`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f&&(0,z.jsx)(`button`,{onClick:()=>{f&&(window.history.pushState(null,``,qht(String(f))),window.dispatchEvent(new PopStateEvent(`popstate`)))},className:`rounded border border-border px-2 py-1 text-xs text-foreground transition-colors hover:border-border hover:bg-card`,children:`Open in Command Deck`}),(0,z.jsx)(`button`,{onClick:t,"aria-label":`Close session detail`,className:`text-muted-foreground/70 hover:text-foreground transition-colors`,children:(0,z.jsx)(Os,{className:`h-4 w-4`})})]})]}),(0,z.jsxs)(`details`,{open:!0,className:`shrink-0 border-b border-border`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground hover:text-foreground`,children:`Metadata and actions`}),(0,z.jsxs)(`div`,{className:`max-h-[38vh] overflow-auto px-3 py-2 space-y-4`,children:[d.summary&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Summary`}),(0,z.jsx)(`p`,{className:`text-xs text-foreground leading-relaxed`,children:d.summary})]}),d.summaryDetailed&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Detailed`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:d.summaryDetailed})]}),d.tags.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Tags`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.tags.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 bg-muted text-muted-foreground rounded text-[10px]`,children:e},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Metadata`}),_(`Workspace`,d.workspacePath),_(`Model`,d.primaryModel),_(`Messages`,d.messageCount),_(`Input tokens`,d.tokenInput.toLocaleString()),_(`Output tokens`,d.tokenOutput.toLocaleString()),_(`Est. cost`,d.estimatedCost>0?`$${d.estimatedCost.toFixed(6)}`:null),_(`First active`,d.firstTs?$8n(d.firstTs):null),_(`Last active`,d.lastTs?$8n(d.lastTs):null),s&&_(`Archived at`,d.archivedAt?$8n(d.archivedAt):null),d.panIssueId&&_(`Issue`,d.panIssueId),_(`Enrichment`,d.enrichmentLevel===0?`None`:`L${d.enrichmentLevel}`)]}),d.toolsUsed.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Tools Used`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.toolsUsed.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 bg-card text-muted-foreground rounded text-[10px] font-mono`,children:e},e))})]}),d.filesTouched.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Files Touched`}),(0,z.jsx)(`div`,{className:`space-y-1 max-h-28 overflow-auto`,children:d.filesTouched.map(e=>(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-mono break-all`,children:e},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`File`}),(0,z.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,z.jsx)(Mo,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 font-mono break-all`,children:d.jsonlPath??`No JSONL path available`})]})]})]}),(0,z.jsx)(`div`,{className:`px-3 py-2 border-t border-border`,children:s?(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1.5`,children:`Archived conversation`}),(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mb-2`,children:`Restore this conversation to the active Command Deck list.`}),(0,z.jsx)(`button`,{onClick:()=>g.mutate(),disabled:g.isPending||g.isSuccess,className:`rounded bg-warning/12 px-2 py-1 text-xs text-warning-foreground transition-colors hover:bg-warning/16 disabled:opacity-50`,children:g.isPending?`Unarchiving…`:`Unarchive`}),g.isSuccess&&(0,z.jsx)(`div`,{className:`text-[10px] text-success mt-1`,children:`Conversation restored`}),g.isError&&(0,z.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:g.error instanceof Error?g.error.message:`Unarchive failed`})]}):(0,z.jsxs)(z.Fragment,{children:[d.enrichmentLevel<3&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1.5`,children:d.enrichmentFailed?`Enrichment failed — retry:`:`Enrich this session`}),(0,z.jsx)(`div`,{className:`text-[10px] text-warning-foreground/80 mb-1.5`,children:`Sends redacted conversation excerpts to the configured enrichment provider.`}),(0,z.jsxs)(`label`,{className:`mb-2 block text-[10px] text-muted-foreground`,children:[`Custom model`,(0,z.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`Use default provider model`,className:`mt-1 w-full rounded border border-border bg-card px-2 py-1 text-[10px] text-foreground placeholder:text-muted-foreground/70 focus:border-primary focus:outline-none`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d.enrichmentLevel<1&&(0,z.jsxs)(`button`,{onClick:()=>v(1),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(bs,{className:`h-3 w-3`}),`Quick (L1)`]}),d.enrichmentLevel<2&&(0,z.jsxs)(`button`,{onClick:()=>v(2),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(bs,{className:`h-3 w-3 text-muted-foreground`}),`Detailed (L2)`]}),(0,z.jsxs)(`button`,{onClick:()=>v(3),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(bs,{className:`h-3 w-3 text-muted-foreground`}),`Deep (L3)`]})]})]}),m.isPending&&(0,z.jsx)(`div`,{className:`text-[10px] text-primary mt-1`,children:`Enriching…`}),l&&(0,z.jsxs)(`div`,{className:l.success?`text-[10px] text-success mt-1`:`text-[10px] text-destructive mt-1`,children:[`L`,l.level,` `,l.success?`complete`:`failed: ${l.error??`unknown error`}`,` · `,l.model]}),r&&(0,z.jsxs)(`div`,{className:`mt-2 rounded border border-warning/32 bg-warning/8 p-2 text-[10px] text-warning-foreground`,children:[`Estimated cost $`,r.estimatedCost.toFixed(4),` exceeds threshold $`,r.threshold.toFixed(2),` for `,r.sessionCount,` session`,r.sessionCount===1?``:`s`,`.`,(0,z.jsx)(`button`,{onClick:()=>m.mutate({tier:r.tier,confirmed:!0,model:r.model}),disabled:m.isPending,className:`ml-2 rounded bg-warning/12 px-1.5 py-0.5 text-warning-foreground disabled:opacity-50`,children:`Confirm`})]}),m.isError&&!r&&(0,z.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:`Enrichment failed`}),(0,z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-border pt-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Semantic embedding`}),(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70`,children:`Generate or refresh this session's vector index.`})]}),(0,z.jsx)(`button`,{onClick:()=>h.mutate(),disabled:h.isPending,className:`px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:`Embed`})]}),h.isPending&&(0,z.jsx)(`div`,{className:`text-[10px] text-primary mt-1`,children:`Embedding…`}),h.isSuccess&&(0,z.jsx)(`div`,{className:`text-[10px] text-success mt-1`,children:`Embedding complete`}),h.isError&&(0,z.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:`Embedding failed`})]})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,z.jsx)(W8n,{session:d})})]})}function $8n(e){try{return new Date(e).toISOString().replace(`T`,` `).slice(0,16)}catch{return e}}function e5n({isScanning:e,onScan:t,lastResult:n,progress:r}){let i=e||r?.active===!0;return(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?.active?(0,z.jsxs)(`span`,{className:`text-[10px] text-primary font-mono`,children:[r.dirsProcessed,`/`,r.dirsTotal,` files · `,r.sessionsFound,` sessions · `,(r.elapsedMs/1e3).toFixed(1),`s`]}):n&&!i&&(0,z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,n.inserted,` ↑`,n.updated,` ·`,(n.durationMs/1e3).toFixed(1),`s`]}),(0,z.jsxs)(`button`,{onClick:t,disabled:i,className:`flex items-center gap-1.5 rounded px-3 py-1.5 bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 text-xs transition-colors`,children:[(0,z.jsx)(zt,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),i?`Scanning…`:`Scan`]})]})}var t5n=[{label:`All time`,value:``},{label:`Today`,value:`today`},{label:`Last 7 days`,value:`7d`},{label:`Last 30 days`,value:`30d`},{label:`Last 90 days`,value:`90d`}],n5n=[{label:`All`,value:`all`},{label:`Discovered`,value:`discovered`},{label:`Managed-archived`,value:`managed-archived`}];function r5n({filters:e,facets:t,onChange:n}){let r=t.harnesses.some(e=>e.value!==`claude-code`);return(0,z.jsxs)(`div`,{className:`w-48 shrink-0 border-r border-border bg-background p-3 overflow-auto`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:`Filters`}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Source`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n5n.map(t=>{let r=(e.source??`all`)===t.value;return(0,z.jsx)(`button`,{onClick:()=>n(`source`,t.value===`all`?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${r?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:t.label},t.value)})})]}),r&&(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Harness`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.harnesses.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`harness`,e.harness===t.value?void 0:t.value),className:`px-1.5 py-0.5 text-[10px] font-mono transition-colors ${e.harness===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Time range`}),(0,z.jsx)(`select`,{value:e.since??``,onChange:e=>n(`since`,e.target.value||void 0),className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,children:t5n.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:t.timeRanges.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`since`,e.since===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.since===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Workspace path`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-workspaces`,value:e.workspace??``,onChange:e=>n(`workspace`,e.target.value||void 0),placeholder:`e.g. /Projects/myapp`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,z.jsx)(`datalist`,{id:`conversation-workspaces`,children:t.workspaces.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Model`}),(0,z.jsxs)(`select`,{value:e.model??``,onChange:e=>n(`model`,e.target.value||void 0),className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,children:[(0,z.jsx)(`option`,{value:``,children:`All models`}),t.models.map(e=>(0,z.jsxs)(`option`,{value:e.value,children:[e.value,` (`,e.count,`)`]},e.value))]}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.models.slice(0,8).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`model`,e.model===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.model===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Tag`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-tags`,value:e.tag??``,onChange:e=>n(`tag`,e.target.value||void 0),placeholder:`e.g. bugfix`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,z.jsx)(`datalist`,{id:`conversation-tags`,children:t.tags.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tags.slice(0,12).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`tag`,e.tag===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tag===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Tool`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-tools`,value:e.tool??``,onChange:e=>n(`tool`,e.target.value||void 0),placeholder:`e.g. Read`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,z.jsx)(`datalist`,{id:`conversation-tools`,children:t.tools.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tools.slice(0,12).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`tool`,e.tool===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tool===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`File touched`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-files`,value:e.file??``,onChange:e=>n(`file`,e.target.value||void 0),placeholder:`e.g. src/index.ts`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,z.jsx)(`datalist`,{id:`conversation-files`,children:t.files.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.files.slice(0,8).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`file`,e.file===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.file===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Workspace cost`}),(0,z.jsx)(`div`,{className:`space-y-1 max-h-24 overflow-auto`,children:t.workspaces.slice(0,8).map(e=>(0,z.jsxs)(`button`,{onClick:()=>n(`workspace`,e.value),className:`w-full text-left text-[10px] text-muted-foreground hover:text-foreground truncate`,title:e.value,children:[e.count,` · $`,(e.cost??0).toFixed(4),` · `,e.value]},e.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Cost ranges`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.costRanges.map(t=>(0,z.jsxs)(`button`,{onClick:()=>{let r=e.minCost===t.minCost&&e.maxCost===t.maxCost;n(`minCost`,r?void 0:t.minCost),n(`maxCost`,r?void 0:t.maxCost)},className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.minCost===t.minCost&&e.maxCost===t.maxCost?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:`Estimated total $${(t.cost??0).toFixed(4)}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Enrichment levels`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.enrichmentLevels.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`enrichmentLevel`,e.enrichmentLevel===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.enrichmentLevel===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:[`L`,t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,z.jsxs)(`label`,{className:`text-xs text-muted-foreground block`,children:[`Min cost`,(0,z.jsx)(`input`,{type:`number`,step:`0.001`,value:e.minCost??``,onChange:e=>n(`minCost`,e.target.value||void 0),className:`mt-1 w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`})]}),(0,z.jsxs)(`label`,{className:`text-xs text-muted-foreground block`,children:[`Max cost`,(0,z.jsx)(`input`,{type:`number`,step:`0.001`,value:e.maxCost??``,onChange:e=>n(`maxCost`,e.target.value||void 0),className:`mt-1 w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:e.managed===!0,onChange:e=>n(`managed`,e.target.checked?!0:void 0),className:`rounded border-border bg-muted text-primary focus:ring-0`}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Overdeck-managed`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:e.enriched===!0,onChange:e=>n(`enriched`,e.target.checked?!0:void 0),className:`rounded border-border bg-muted text-primary focus:ring-0`}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Enriched only`})]})]}),Object.values(e).some(Boolean)&&(0,z.jsx)(`button`,{onClick:()=>{n(`since`,void 0),n(`harness`,void 0),n(`workspace`,void 0),n(`managed`,void 0),n(`enriched`,void 0),n(`model`,void 0),n(`tag`,void 0),n(`tool`,void 0),n(`file`,void 0),n(`minCost`,void 0),n(`maxCost`,void 0),n(`enrichmentLevel`,void 0)},className:`mt-4 text-[10px] text-muted-foreground/70 hover:text-muted-foreground transition-colors`,children:`Clear filters`})]})}function i5n(e){return`${e.source}:${e.id}`}function a5n(e){let t=new Set,n=[];for(let r of e??[])for(let e of r.rows){let r=i5n(e);t.has(r)||(t.add(r),n.push(e))}return n}function o5n(e){return`${e.source}:${e.id}`}function s5n(e){return{harnesses:[],models:e?.primaryModels.map(e=>({value:e.value,count:e.count}))??[],workspaces:[],tags:e?.tags.map(e=>({value:e.value,count:e.count}))??[],tools:e?.tools.map(e=>({value:e.value,count:e.count}))??[],files:e?.files.map(e=>({value:e.value,count:e.count}))??[],timeRanges:e?.timeBuckets.map(e=>({value:e.value===`24h`?`today`:e.value,label:e.value===`24h`?`Today`:e.value,count:e.count}))??[],costRanges:e?.costBuckets.map(e=>({value:e.value,label:e.value,count:e.count,minCost:e.value===`<$0.10`?void 0:e.value===`$0.10-1`?`0.10`:e.value===`$1-10`?`1`:`10`,maxCost:e.value===`<$0.10`?`0.10`:e.value===`$0.10-1`?`1`:e.value===`$1-10`?`10`:void 0}))??[],enrichmentLevels:e?.enrichmentLevels.map(e=>({value:String(e.value),count:e.count}))??[]}}function c5n(e){let t=new URLSearchParams;return e.harness&&t.set(`harness`,e.harness),e.workspace&&t.set(`workspacePath`,e.workspace),e.since&&t.set(`since`,e.since),e.managed&&t.set(`managed`,`true`),e.enriched&&t.set(`enriched`,`true`),e.model&&t.set(`primaryModel`,e.model),e.tag&&t.set(`tag`,e.tag),e.tool&&t.set(`tool`,e.tool),e.file&&t.set(`file`,e.file),e.minCost&&t.set(`minCost`,e.minCost),e.maxCost&&t.set(`maxCost`,e.maxCost),e.enrichmentLevel&&t.set(`enrichmentLevel`,e.enrichmentLevel),e.source&&e.source!==`all`&&t.set(`source`,e.source),t}function a7(e){let t={},n=e.get(`harness`),r=e.get(`workspacePath`),i=e.get(`primaryModel`),a=e.get(`since`),o=e.get(`managed`),s=e.get(`enriched`),c=e.get(`tag`),l=e.get(`tool`),u=e.get(`file`),d=e.get(`minCost`),f=e.get(`maxCost`),p=e.get(`enrichmentLevel`),m=e.get(`source`),h=e.get(`query`);return n&&(t.harness=n),r&&(t.workspacePath=r),i&&(t.primaryModel=i),a&&(t.since=a),o&&(t.managed=o===`true`),s&&(t.enriched=s===`true`),c&&(t.tags=[c]),l&&(t.tools=[l]),u&&(t.files=[u]),d&&Number.isFinite(Number(d))&&(t.minCost=Number(d)),f&&Number.isFinite(Number(f))&&(t.maxCost=Number(f)),p&&Number.isFinite(Number(p))&&(t.enrichmentLevel=Number(p)),(m===`discovered`||m===`managed-archived`)&&(t.source=m),h&&(t.query=h),t}function l5n(e){return{id:e.id,source:`discovered`,discoveredId:e.id,harness:e.harness??`claude-code`,conversationId:e.conversationId??null,conversationName:e.conversationName??null,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,conversationTitle:e.conversationTitle??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}function u5n(e){return{id:e.id,source:e.source,discoveredId:e.discoveredId??null,harness:e.harness??`claude-code`,conversationId:e.conversationId??null,conversationName:e.conversationName??null,conversationTitle:e.conversationTitle??null,archivedAt:e.archivedAt??null,jsonlPath:e.jsonlPath??null,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[],filesTouched:[],tags:[...e.tags],summary:e.summary??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function d5n(e,t){let n=await Mc().request(n=>n[Ft.listSessionsFeed]({...a7(e),limit:Number(e.get(`limit`)??50),...t?{cursor:t}:{}}));return{rows:n.rows.map(u5n),nextCursor:n.nextCursor??null}}async function f5n(e){return Mc().request(t=>t[Ft.getSessionsFeedFacets]({...a7(e),limit:Number(e.get(`limit`)??50)}))}async function p5n(e,t,n=50,r=0,i=!1){let a=await Mc().request(a=>a[Ft.searchConversations]({...a7(t),query:e,semantic:i,limit:n,offset:r}));return{...a,sessions:a.sessions.map(l5n)}}async function m5n(){let e=await Mc().request(e=>e[Ft.getConversationStats]({}));return{...e,embeddingModels:e.embeddingModels?.map(e=>({...e}))}}async function h5n(e){return Mc().request(t=>t[Ft.getConversationCost](a7(e)))}async function g5n(){return Mc().request(e=>e[Ft.scanConversations]({mode:`system`}))}function _5n({initialSessionKey:e=null}){let t=$t(),n=Wt(Ke),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(e),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(0),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)({}),h=p.source??`all`,g=r.trim(),[_,v]=(0,L.useState)(g),y=h!==`managed-archived`,b=d&&y,x=b?_:``,S=b?``:g,C=c5n(p);(0,L.useEffect)(()=>{if(!b){v(g);return}let e=window.setTimeout(()=>v(g),350);return()=>window.clearTimeout(e)},[b,g]),(0,L.useEffect)(()=>{!y&&d&&(f(!1),u(0))},[y,d]),(0,L.useEffect)(()=>{o(e)},[e]);let w=new URLSearchParams({limit:`100`});for(let[e,t]of C)w.set(e,t);S&&w.set(`query`,S);let T=ure({queryKey:[`sessions-feed`,w.toString()],queryFn:({pageParam:e})=>d5n(w,e),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor??void 0,enabled:!x}),{data:E}=F({queryKey:[`sessions-feed-facets`,w.toString()],queryFn:()=>f5n(w),enabled:!x,staleTime:3e4}),{data:D,isLoading:O}=F({queryKey:[`discovered-sessions-search`,x,C.toString(),l,b],queryFn:()=>p5n(x,C,50,l,b),enabled:!!x}),{data:k}=F({queryKey:[`discovered-sessions-stats`],queryFn:m5n,staleTime:3e4}),{data:A}=F({queryKey:[`discovered-sessions-cost`,C.toString()],queryFn:()=>h5n(C),staleTime:3e4}),j=Cn({mutationFn:g5n,onSuccess:()=>{t.invalidateQueries({queryKey:[`sessions-feed`]}),t.invalidateQueries({queryKey:[`sessions-feed-facets`]}),t.invalidateQueries({queryKey:[`discovered-sessions-stats`]})}}),ee=x?O:T.isLoading,M=a5n(T.data?.pages),N=x?D?.sessions??[]:M,P=a==null?null:N.find(e=>o5n(e)===a)??null,te=s5n(E),ne=[h===`all`?null:{key:`source`,label:`Source: ${h===`discovered`?`Discovered`:`Managed-archived`}`},p.harness?{key:`harness`,label:`Harness: ${p.harness}`}:null,p.workspace?{key:`workspace`,label:`Workspace: ${p.workspace}`}:null,p.model?{key:`model`,label:`Model: ${p.model}`}:null,p.tag?{key:`tag`,label:`Tag: ${p.tag}`}:null,p.tool?{key:`tool`,label:`Tool: ${p.tool}`}:null,p.file?{key:`file`,label:`File: ${p.file}`}:null,p.since?{key:`since`,label:`Since: ${p.since}`}:null,p.managed?{key:`managed`,label:`Managed`}:null,p.enriched?{key:`enriched`,label:`Enriched`}:null,p.minCost?{key:`minCost`,label:`Min cost: $${p.minCost}`}:null,p.maxCost?{key:`maxCost`,label:`Max cost: $${p.maxCost}`}:null,p.enrichmentLevel?{key:`enrichmentLevel`,label:`Enrichment: L${p.enrichmentLevel}`}:null].filter(e=>e!==null);(0,L.useEffect)(()=>{x||a==null||P!=null||!T.hasNextPage||T.isFetchingNextPage||T.fetchNextPage()},[x,T,P,a]);let re=(0,L.useCallback)(e=>{i(e),u(0)},[]),ie=(0,L.useCallback)((e,t)=>{m(n=>({...n,[e]:t})),u(0)},[]),ae=(0,L.useCallback)(e=>{o(e);let t=new URLSearchParams(window.location.search);e?t.set(`session`,e):t.delete(`session`);let n=t.toString();window.history.replaceState(null,``,`${window.location.pathname}${n?`?${n}`:``}`)},[]);return(0,z.jsxs)(`div`,{className:`flex flex-col h-full bg-background text-foreground`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border shrink-0`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-medium text-foreground`,children:`Session History`}),k&&(0,z.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground ml-2`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-foreground font-mono`,children:k.total}),` indexed`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-success font-mono`,children:k.enriched}),` enriched`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-primary font-mono`,children:k.managedCount}),` managed`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`span`,{className:`text-signal-cost-foreground font-mono`,children:[`$`,(A?.totalCost??0).toFixed(4)]}),` est. cost`]})]}),(0,z.jsx)(`div`,{className:`flex-1`}),(0,z.jsxs)(`div`,{className:`relative w-72`,children:[(0,z.jsx)(gs,{className:`absolute left-2.5 top-2 h-3.5 w-3.5 text-muted-foreground`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`Search sessions…`,value:r,onChange:e=>re(e.target.value),className:`w-full bg-card border border-border rounded pl-8 pr-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`})]}),(0,z.jsx)(`button`,{onClick:()=>{y&&(f(e=>!e),u(0))},disabled:!y,className:`px-3 py-1.5 rounded text-xs border transition-colors ${y?b?`bg-signal-review/8 border-signal-review/32 text-signal-review-foreground`:`bg-card border-border text-muted-foreground hover:border-border`:`bg-muted border-border text-muted-foreground/60 cursor-not-allowed`}`,children:b?`Semantic`:`Keyword`}),(0,z.jsxs)(`button`,{onClick:()=>c(e=>!e),className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs border transition-colors ${s?`bg-primary border-primary text-primary-foreground`:`bg-card border-border text-muted-foreground hover:border-border`}`,children:[(0,z.jsx)(Io,{className:`h-3.5 w-3.5`}),`Filters`]}),(0,z.jsx)(e5n,{isScanning:j.isPending,onScan:()=>j.mutate(),lastResult:j.data,progress:n})]}),ne.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-b border-border bg-background shrink-0 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Active filters`}),ne.map(e=>(0,z.jsxs)(`button`,{onClick:()=>{ie(e.key,void 0),e.key===`minCost`&&ie(`maxCost`,void 0),e.key===`maxCost`&&ie(`minCost`,void 0)},className:`px-2 py-1 rounded-sm bg-primary/8 text-primary border border-primary/32 hover:bg-primary hover:text-primary-foreground transition-colors`,children:[e.label,` `,(0,z.jsx)(`span`,{className:`text-primary`,children:`×`})]},e.key)),(0,z.jsx)(`button`,{onClick:()=>m({}),className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Clear all`})]}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[s&&(0,z.jsx)(r5n,{filters:p,facets:te,onChange:ie}),(0,z.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 overflow-hidden ${P?`border-r border-border`:``}`,children:[x&&D?.error&&(0,z.jsxs)(`div`,{className:`px-4 py-2 border-b border-warning/32 bg-warning/8 text-warning-foreground text-xs`,children:[`Semantic search unavailable: `,D.error]}),ee?(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`Loading sessions…`}):N.length===0?(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-32 text-muted-foreground gap-2`,children:[(0,z.jsx)(`span`,{className:`text-sm`,children:`No sessions found`}),!k?.total&&(0,z.jsx)(`span`,{className:`text-xs`,children:`Run a scan to discover Claude Code sessions`})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(z8n,{sessions:N,selectedId:a,onSelect:ae,hasMore:!x&&T.hasNextPage,isLoadingMore:T.isFetchingNextPage,onLoadMore:()=>{T.fetchNextPage()}}),x&&D&&D.total>50&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-border shrink-0 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[l+1,`–`,l+N.length,` of `,D.total,` results`]}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`button`,{disabled:l===0,onClick:()=>u(e=>Math.max(0,e-50)),className:`px-2 py-1 rounded bg-muted hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Prev`}),(0,z.jsx)(`button`,{disabled:l+50>=D.total,onClick:()=>u(e=>e+50),className:`px-2 py-1 rounded bg-muted hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Next`})]})]})]})]}),P&&(0,z.jsx)(`div`,{className:`min-w-[28rem] flex-[1.15] overflow-hidden`,children:(0,z.jsx)(Q8n,{session:P,onClose:()=>ae(null)})})]})]})}function v5n(e){return e===`warming`?(0,z.jsx)(is,{className:`h-4 w-4 animate-spin text-primary`}):e===`ready`?(0,z.jsx)(vo,{className:`h-4 w-4 text-green-500`}):e===`failed`?(0,z.jsx)(go,{className:`h-4 w-4 text-destructive`}):(0,z.jsx)(So,{className:`h-4 w-4 text-muted-foreground`})}function y5n({mode:e,warmupStatus:t,isListening:n,onStart:r,onBackToStaging:i,onReset:a,onToggleMic:o,voiceError:s}){return(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`AutoPreso`}),(0,z.jsx)(`h2`,{className:`mt-1 text-lg font-semibold`,children:`Voice whiteboard`})]}),(0,z.jsx)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs font-medium capitalize text-muted-foreground`,children:e})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-lg px-3 py-2 text-sm font-semibold transition-colors ${n?`bg-destructive text-destructive-foreground`:`bg-primary text-primary-foreground`}`,children:n?`Stop mic`:`Start mic`}),(0,z.jsx)(`button`,{type:`button`,onClick:e===`staging`?r:i,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-foreground hover:bg-accent`,children:e===`staging`?`Go live`:`Back to staging`})]}),(0,z.jsxs)(`div`,{className:`mt-4 rounded-lg bg-muted/40 p-3 text-sm`,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-foreground`,children:[v5n(t),`Warmup: `,(0,z.jsx)(`span`,{className:`capitalize`,children:t})]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The whiteboard agent uses the staged canvas as context before live transcription starts.`})]}),s&&(0,z.jsx)(`div`,{className:`mt-4 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,children:s}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`mt-3 w-full rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Reset session`})]})}function b5n({partialText:e,turns:t}){let n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{n.current?.scrollIntoView({block:`end`})},[e,t]),(0,z.jsxs)(`section`,{className:`min-h-0 flex-1 rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Transcript`}),(0,z.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto pr-1 text-sm`,children:[t.length===0&&!e&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`Spoken turns will appear here while AutoPreso listens.`}),t.map((e,t)=>(0,z.jsxs)(`article`,{className:`rounded-lg bg-muted/40 p-2 text-foreground`,children:[(0,z.jsx)(`time`,{className:`mb-1 block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.timestamp.toLocaleTimeString()}),(0,z.jsx)(`p`,{children:e.text})]},`${e.timestamp.toISOString()}-${t}`)),e&&(0,z.jsx)(`p`,{className:`rounded-lg border border-dashed border-border p-2 italic text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{ref:n})]})]})}var x5n=25e4,S5n=6e3;function C5n(e){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}${e}`}function w5n(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(`staging`),[i,a]=(0,L.useState)(`idle`),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)([]),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(null),g=(0,L.useRef)(null),_=(0,L.useRef)(null),v=(0,L.useRef)(0),y=(0,L.useRef)(null),b=(0,L.useRef)(0),x=(0,L.useRef)(!0),S=(0,L.useRef)(null),C=(0,L.useRef)(null),w=(0,L.useRef)(null),T=(0,L.useRef)(null),E=(0,L.useRef)(null),D=(0,L.useRef)(null),O=(0,L.useCallback)(()=>{g.current?.close();let e=++v.current;(async()=>{try{await kc()}catch{return}if(!x.current||e!==v.current)return;let n=new WebSocket(C5n(`/ws/autopreso`));g.current=n,n.onopen=()=>{b.current=0},n.onmessage=e=>{let n=JSON.parse(String(e.data));(n.type===`whiteboard:snapshot`||n.type===`whiteboard:update`)&&(n.elements&&t(n.elements),n.mode&&r(n.mode),n.warmupStatus&&a(n.warmupStatus))},n.onclose=()=>{if(!x.current||g.current!==n)return;let e=Math.min(1e3*2**b.current,1e4);b.current+=1,y.current=window.setTimeout(O,e)}})()},[]),k=(0,L.useCallback)(e=>{d(!1),e&&_.current?.close(),e&&(_.current=null),w.current?.disconnect(),T.current?.disconnect(),E.current?.disconnect(),C.current?.close(),S.current?.getTracks().forEach(e=>e.stop()),w.current=null,T.current=null,E.current=null,C.current=null,S.current=null,h(null)},[]),A=(0,L.useCallback)(async(e=!0)=>{let t=_.current;k(!1),e&&t?.readyState===WebSocket.OPEN&&(t.send(JSON.stringify({type:`stop`})),await new Promise(e=>{let t=window.setTimeout(e,S5n);D.current=()=>{window.clearTimeout(t),e()}}),D.current=null),k(!0)},[k]);return(0,L.useEffect)(()=>(x.current=!0,O(),()=>{x.current=!1,y.current&&window.clearTimeout(y.current),y.current=null;let e=g.current;g.current=null,e?.close(),A(!1)}),[O,A]),{elements:e,mode:n,warmupStatus:i,partialText:o,committedTurns:c,isListening:u,voiceError:f,startListening:(0,L.useCallback)(async()=>{if(u)return;p(null);let e=null,t=null,n=null,r=null,i=null,a=null;try{await kc(),e=await navigator.mediaDevices.getUserMedia({audio:!0});let o=window.AudioContext;t=new o({sampleRate:24e3}),n=t.createMediaStreamSource(e),r=t.createAnalyser(),i=t.createScriptProcessor(4096,1,1),a=new WebSocket(C5n(`/ws/voice`)),a.binaryType=`arraybuffer`,a.onmessage=e=>{let t=JSON.parse(String(e.data));t.type===`transcript:partial`&&s(t.text),t.type===`transcript:committed`&&(s(``),l(e=>[...e,{text:t.text,timestamp:new Date}].slice(-200))),t.type===`transcript:finalized`&&D.current?.(),t.type===`error`&&p(t.error)},a.onclose=()=>{_.current===a&&A(!1)},i.onaudioprocess=e=>{if(a?.readyState!==WebSocket.OPEN||a.bufferedAmount>x5n)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e+=1){let r=Math.max(-1,Math.min(1,t[e]??0));n[e]=r<0?r*32768:r*32767}a.send(n.buffer)},n.connect(r),r.connect(i),i.connect(t.destination),S.current=e,C.current=t,T.current=n,E.current=r,w.current=i,_.current=a,h(r),d(!0)}catch(o){a?.close(),i?.disconnect(),n?.disconnect(),r?.disconnect(),t?.close(),e?.getTracks().forEach(e=>e.stop()),p(o instanceof Error?o.message:`Unable to start voice input`)}},[u,A]),stopListening:A,analyserNode:m}}var T5n=(0,L.lazy)(async()=>({default:(await I(()=>import(`./prod-DsNBMWxO.js`).then(e=>e.t),__vite__mapDeps([112,2,3,4,111,7,113]))).Excalidraw}));function E5n(){let{elements:e,mode:t,warmupStatus:n,partialText:r,committedTurns:i,isListening:a,voiceError:o,startListening:s,stopListening:c}=w5n(),[l,u]=(0,L.useState)([]),d=(0,L.useRef)(null),f=t===`live`?e:l,p=(0,L.useMemo)(()=>({elements:f}),[f]),m=(0,L.useCallback)(async()=>{await fetch(`/api/autopreso/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({elements:l,screenshotBase64:null})})},[l]),h=(0,L.useCallback)(async()=>{await fetch(`/api/autopreso/back-to-staging`,{method:`POST`})},[]),g=(0,L.useCallback)(async()=>{await fetch(`/api/autopreso/session/reset`,{method:`POST`}),u([]),d.current?.updateScene?.({elements:[]})},[]),_=(0,L.useCallback)(()=>{a?c():s()},[a,s,c]),v=(0,L.useCallback)(e=>{t===`staging`&&u(e)},[t]),y=(0,L.useCallback)(e=>{d.current=e},[]);return(0,L.useEffect)(()=>{t===`live`&&d.current?.updateScene?.({elements:e})},[t,e]),(0,z.jsxs)(`div`,{className:`flex h-full w-full gap-4 overflow-hidden bg-background p-4 text-foreground`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden rounded-xl border border-border bg-card shadow-sm`,children:(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading whiteboard…`}),children:(0,z.jsx)(T5n,{excalidrawAPI:y,initialData:p,onChange:v,viewModeEnabled:t===`live`},t)})}),(0,z.jsxs)(`aside`,{className:`flex w-96 shrink-0 flex-col gap-4 overflow-y-auto`,children:[(0,z.jsx)(y5n,{mode:t,warmupStatus:n,isListening:a,onStart:m,onBackToStaging:h,onReset:g,onToggleMic:_,voiceError:o}),(0,z.jsx)(b5n,{turns:i,partialText:r})]})]})}function o7({fallback:e,children:t}){return Wt(Vee)?(0,z.jsx)(z.Fragment,{children:t}):(0,z.jsx)(z.Fragment,{children:e})}var D5n=`overdeck:ui-mode`,O5n=`overdeck:last-tab`;function k5n(e=typeof window>`u`?void 0:window.localStorage){if(!e)return`simple`;try{let t=e.getItem(D5n);if(t===`simple`||t===`advanced`)return t;let n=e.getItem(O5n)?`advanced`:`simple`;return e.setItem(D5n,n),n}catch{return`simple`}}var s7=un(e=>({mode:k5n(),setMode:t=>{try{window.localStorage.setItem(D5n,t)}catch{}e({mode:t})},simpleIssueId:null,openSimpleIssue:t=>e({simpleIssueId:t}),closeSimpleIssue:()=>e({simpleIssueId:null})}));function A5n(e){if(typeof window>`u`)return;let t=e?`/issues/${encodeURIComponent(e)}`:`/`;window.location.pathname!==t&&window.history.pushState({},``,t)}var c7={home:{greetingFallback:`Hello.`,needsYouTitle:`Needs you`,needsYouSub:`Work pauses until you answer. Everything else keeps going.`,workingTitle:`Working now`,workingSub:`Nothing for you to do on these — you'll be told when they're ready.`,readyTitle:`Ready to merge`,doneTitle:`Finished`,composerPlaceholder:`Ask for anything, or describe what you want built, in plain words…`,chipIn:`In: `,chipNoProject:`Not in a project`,chipAddProject:`Add a project…`,nothingNeedsYou:`Nothing needs you right now. Nice.`,quietEmpty:`Nothing here yet.`},issue:{backToMyWork:`← My work`,composerPlaceholder:`Say something to the agent… (steer it, correct it, ask why)`,composerHint:`Talking to it never interrupts the work — it reads you between tasks.`,answerPlaceholder:`Type your answer…`,answerHint:`One sentence is enough. It continues immediately after you answer.`,whatHappened:`What happened`,advancedDisclosure:`Advanced — the machinery behind this task`,getHelp:`Get help`,steps:[`Started`,`Writing code`,`Checking`,`Ready`],feedTitle:`What it's doing`,waitingOnYou:`waiting on you`,taskStartedPrefix:`Task started · told to `,rawPromptDisclosure:`See the full instructions it was given`,readMore:`Read more`,showLess:`Show less`,pausedWaiting:`Paused — waiting for your answer`,pausedToStart:`Paused — waiting for you to start the work`,sentToAgent:`Sent to the agent`,questionTitle:`It has a question for you`,screenExcerptLabel:`Here's what it's showing on its screen:`,questionAskedPrefix:`Asked `,questionPauseSuffix:`work pauses until you answer — everything else keeps going`,questionAnswerPlaceholder:`Or type your own answer…`,answerSend:`Send answer`,questionOptionsHint:`Pick an option or write one sentence — it continues as soon as you answer.`,answerSentTitle:`Answer sent`,answerSentSub:`It's reading your answer and getting back to work.`,liveLabel:`live`,readyLiveRow:`All checks passed — ready when you are`},mode:{simple:`Simple`,advanced:`Advanced`},setup:{title:`Get set up`,subtitle:`A few things make Overdeck work best. Nothing here stops you from starting.`,hide:`Hide`,setUp:`Set up`,recheck:`Re-check`,claudeDone:`Claude is signed in`,claudeTodo:`Sign in to Claude`,githubDone:`GitHub is connected`,githubTodo:`Connect GitHub`,agentsDone:`Agents can start`,agentsTodo:`Finish setup so agents can start`,terminalsDone:`Plain terminals are ready`,terminalsTodo:`Install the terminal helper`,dockerDone:`Docker is running (optional)`,dockerTodo:`Docker (optional)`,memoryPrefix:`Free memory: `,memoryLow:`New agents may wait for memory to free up.`,runThis:`Run this in a terminal, then re-check:`}};function j5n(){let e=s7(e=>e.mode),t=s7(e=>e.setMode),n=[{id:`simple`,label:c7.mode.simple},{id:`advanced`,label:c7.mode.advanced}];return(0,z.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-lg border border-input`,children:n.map(n=>(0,z.jsx)(`button`,{onClick:()=>t(n.id),className:zc(`px-3 py-1.5 text-xs font-medium transition-colors`,e===n.id?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`),children:n.label},n.id))})}function M5n({state:e,pipelineState:t}){let n=c7.issue.steps,r=pft(t),i=e===`needs-you`;return(0,z.jsx)(`div`,{className:`mt-5 flex`,role:`list`,children:n.map((t,a)=>{let o=a<r||e===`done`,s=a===r&&e!==`done`&&e!==`ready`,c=a===n.length-1;return(0,z.jsxs)(`div`,{role:`listitem`,className:`relative flex-1 pt-3.5 text-center`,children:[(0,z.jsx)(`span`,{className:zc(`absolute left-0 right-0 top-[5px] h-0.5`,a===0&&`left-1/2`,c&&`right-1/2`,o||s?`bg-success`:`bg-muted`)}),(0,z.jsx)(`span`,{className:zc(`absolute left-1/2 top-0 h-3 w-3 -translate-x-1/2 rounded-full border-2`,o&&`border-transparent bg-success`,s&&!i&&`border-transparent bg-info shadow-[0_0_0_3px] shadow-info/25`,s&&i&&`border-transparent bg-warning shadow-[0_0_0_3px] shadow-warning/25`,!o&&!s&&`border-border bg-muted`)}),(0,z.jsx)(`span`,{className:zc(`text-[11.5px]`,o&&`text-success-foreground`,s&&`font-medium text-foreground`,!o&&!s&&`text-muted-foreground`),children:t}),s&&i&&(0,z.jsx)(`span`,{className:`mt-0.5 block text-[10.5px] text-warning-foreground`,children:c7.issue.waitingOnYou})]},t)})})}var N5n={"not-started":{accent:`border-transparent`,iconBg:`bg-muted text-muted-foreground`,icon:(0,z.jsx)(sfe,{size:15})},working:{accent:`border-info`,iconBg:`bg-info/10 text-info-foreground`,icon:(0,z.jsx)(is,{size:15})},"needs-you":{accent:`border-warning`,iconBg:`bg-warning/10 text-warning-foreground`,icon:(0,z.jsx)(yo,{size:15})},ready:{accent:`border-success`,iconBg:`bg-success/10 text-success-foreground`,icon:(0,z.jsx)(fo,{size:15})},done:{accent:`border-transparent`,iconBg:`bg-success/10 text-success-foreground`,icon:(0,z.jsx)(fo,{size:15})}};function P5n({display:e,children:t}){let n=N5n[e.state];return(0,z.jsxs)(`div`,{className:zc(`mt-4 rounded-2xl border-l-[3px] bg-card p-4`,`shadow-[0_1px_2px_rgb(0_0_0/0.05),0_4px_16px_rgb(0_0_0/0.05)] dark:border dark:border-border dark:shadow-none`,n.accent),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`span`,{className:zc(`flex h-8 w-8 flex-none items-center justify-center rounded-full`,n.iconBg),children:n.icon}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[15px] font-medium`,children:e.title}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.sentence})]})]}),t&&(0,z.jsx)(`div`,{className:`mt-3.5 flex flex-wrap items-center gap-2`,children:t})]})}function F5n({completed:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,z.jsx)(`div`,{className:`mt-2.5 h-1 overflow-hidden rounded-full bg-accent`,"aria-label":`${e} of ${t}`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-info`,style:{width:`${n}%`}})})}function l7({children:e,onClick:t,disabled:n,tone:r=`primary`}){return(0,z.jsx)(`button`,{"data-slot":`primary-action`,onClick:t,disabled:n,className:zc(`inline-flex h-9 items-center rounded-lg px-4 text-[13.5px] font-medium text-white transition-opacity`,r===`success`?`bg-success text-[#04120c]`:`bg-primary text-primary-foreground`,n?`cursor-not-allowed opacity-50`:`hover:opacity-90`),children:e})}function u7({children:e,onClick:t,disabled:n}){return(0,z.jsx)(`button`,{onClick:t,disabled:n,className:zc(`inline-flex h-9 items-center rounded-lg border border-input px-4 text-[13.5px] font-medium text-muted-foreground transition-colors`,n?`cursor-not-allowed opacity-50`:`hover:bg-accent hover:text-foreground`),children:e})}var I5n={"claude-code":`Claude Code`,ohmypi:`oh-my-pi`,codex:`Codex`,acp:`ACP`,opencode:`OpenCode`,"kimi-code":`Kimi Code`,muse:`Muse Code`,"prime-agent":`Prime Agent`};function L5n(e){let{mode:t,harness:n,codexAvailable:r}=e,i=[n?{id:n,kind:`agent`,agentName:I5n[n],keys:`↵`}:{id:`agent`,kind:`agent`,keys:`↵`},{id:`terminal`,kind:`terminal`,keys:`⌃↵`}];return r&&n!==`codex`&&i.push({id:`codex`,kind:`agent`,agentName:`Codex`,keys:`⌘⇧↵`}),t===`simple`&&i.push({id:`talk`,kind:`talk`}),i}function R5n(e){return[`I want to discuss a possible task with you first — do not file anything yet.`,``,`The task idea, in my words:`,`"""`,e.trim(),`"""`,``,`Discuss it with me: ask what you need to know, point out what is underspecified or wrong, and help me sharpen it.`,`Only when I explicitly say it is ready (e.g. "file it"), file it as an issue in the tracker with a good title and body based on our discussion, and give me the issue link (e.g. PAN-1234).`].join(`
1483
+ It is recommended to remove them from the file. This can be configured via \`editor.unusualLineTerminators\`.`,xB(e.uri)),primaryButton:H(1561,`&&Remove Unusual Line Terminators`),cancelButton:H(1562,`Ignore`)})}finally{this._isPresentingDialog=!1}if(!t.confirmed){Q4n(this._codeEditorService,e,!0);return}e.removeUnusualLineTerminators(this._editor.getSelections())}};P5=Y4n([X4n(1,PY),X4n(2,jz)],P5),IB(P5.ID,P5,1);var e3n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},t3n=function(e,t){return function(n,r){t(n,r,e)}},n3n=class{constructor(){this.selector={language:`*`}}provideDocumentHighlights(e,t,n){let r=[],i=e.getWordAtPosition({lineNumber:t.lineNumber,column:t.column});if(!i)return Promise.resolve(r);if(!e.isDisposed())return e.findMatches(i.word,!0,!1,!0,oF,!1).map(e=>({range:e.range,kind:OI.Text}))}provideMultiDocumentHighlights(e,t,n,r){let i=new mB,a=e.getWordAtPosition({lineNumber:t.lineNumber,column:t.column});if(!a)return Promise.resolve(i);for(let t of[e,...n]){if(t.isDisposed())continue;let e=t.findMatches(a.word,!0,!1,!0,oF,!1).map(e=>({range:e.range,kind:OI.Text}));e&&i.set(t.uri,e)}return i}},r3n=class extends G{constructor(e){super(),this._register(e.documentHighlightProvider.register(`*`,new n3n)),this._register(e.multiDocumentHighlightProvider.register(`*`,new n3n))}};r3n=e3n([t3n(0,hH)],r3n);var i3n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},F5=function(e,t){return function(n,r){t(n,r,e)}},I5,a3n,o3n=new Qz(`hasWordHighlights`,!1);function s3n(e,t,n,r){return zL(e.ordered(t).map(e=>()=>Promise.resolve(e.provideDocumentHighlights(t,n,r)).then(void 0,eP)),e=>e!=null).then(e=>{if(e){let n=new mB;return n.set(t.uri,e),n}return new mB})}function c3n(e,t,n,r,i){return zL(e.ordered(t).map(e=>()=>{let a=i.filter(e=>qen(e)).filter(t=>tX(e.selector,t.uri,t.getLanguageId(),!0,void 0,void 0)>0);return Promise.resolve(e.provideMultiDocumentHighlights(t,n,a,r)).then(void 0,eP)}),e=>e!=null)}var l3n=class{constructor(e,t,n){this._model=e,this._selection=t,this._wordSeparators=n,this._wordRange=this._getCurrentWordRange(e,t),this._result=null}get result(){return this._result||=PL(e=>this._compute(this._model,this._selection,this._wordSeparators,e)),this._result}_getCurrentWordRange(e,t){let n=e.getWordAtPosition(t.getPosition());return n?new J(t.startLineNumber,n.startColumn,t.startLineNumber,n.endColumn):null}cancel(){this.result.cancel()}},u3n=class extends l3n{constructor(e,t,n,r){super(e,t,n),this._providers=r}_compute(e,t,n,r){return s3n(this._providers,e,t.getPosition(),r).then(e=>e||new mB)}},d3n=class extends l3n{constructor(e,t,n,r,i){super(e,t,n),this._providers=r,this._otherModels=i}_compute(e,t,n,r){return c3n(this._providers,e,t.getPosition(),r,this._otherModels).then(e=>e||new mB)}};function f3n(e,t,n,r){return new u3n(t,n,r,e)}function p3n(e,t,n,r,i){return new d3n(t,n,r,e,i)}MB(`_executeDocumentHighlights`,async(e,t,n)=>(await s3n(e.get(hH).documentHighlightProvider,t,n,NF.None))?.get(t.uri));var m3n=class{static{I5=this}static{this.storedDecorationIDs=new mB}static{this.query=null}constructor(e,t,n,r,i,a,o,s){this.toUnhook=new W,this.workerRequestTokenId=0,this.workerRequestCompleted=!1,this.workerRequestValue=new mB,this.lastCursorPositionChangeTime=0,this.renderDecorationsTimer=void 0,this.runDelayer=this.toUnhook.add(new IL(50)),this.editor=e,this.providers=t,this.multiDocumentProviders=n,this.codeEditorService=a,this.textModelService=i,this.configurationService=o,this.logService=s,this._hasWordHighlights=o3n.bindTo(r),this._ignorePositionChangeEvent=!1,this.occurrencesHighlightEnablement=this.editor.getOption(90),this.occurrencesHighlightDelay=this.configurationService.getValue(`editor.occurrencesHighlightDelay`),this.model=this.editor.getModel(),this.toUnhook.add(e.onDidChangeCursorPosition(e=>{this._ignorePositionChangeEvent||this.occurrencesHighlightEnablement!==`off`&&this.runDelayer.trigger(()=>{this._onPositionChanged(e)})})),this.toUnhook.add(e.onDidFocusEditorText(e=>{this.occurrencesHighlightEnablement!==`off`&&(this.workerRequest||this.runDelayer.trigger(()=>{this._run()}))})),this.toUnhook.add(e.onDidChangeModelContent(e=>{YL(this.model.uri,`output`)||this._stopAll()})),this.toUnhook.add(e.onDidChangeModel(e=>{!e.newModelUrl&&e.oldModelUrl?this._stopSingular():I5.query&&this._run()})),this.toUnhook.add(e.onDidChangeConfiguration(e=>{let t=this.editor.getOption(90);if(this.occurrencesHighlightEnablement!==t)switch(this.occurrencesHighlightEnablement=t,t){case`off`:this._stopAll();break;case`singleFile`:this._stopAll(I5.query?.modelInfo?.modelURI);break;case`multiFile`:I5.query&&this._run(!0);break;default:console.warn(`Unknown occurrencesHighlight setting value:`,t)}})),this.toUnhook.add(this.configurationService.onDidChangeConfiguration(e=>{if(e.affectsConfiguration(`editor.occurrencesHighlightDelay`)){let e=o.getValue(`editor.occurrencesHighlightDelay`);this.occurrencesHighlightDelay!==e&&(this.occurrencesHighlightDelay=e)}})),this.toUnhook.add(e.onDidBlurEditorWidget(()=>{let e=this.codeEditorService.getFocusedCodeEditor();e?e.getModel()?.uri.scheme===JL.vscodeNotebookCell&&this.editor.getModel()?.uri.scheme!==JL.vscodeNotebookCell&&this._stopAll():this._stopAll()})),this.decorations=this.editor.createDecorationsCollection(),this.workerRequestTokenId=0,this.workerRequest=null,this.workerRequestCompleted=!1,this.lastCursorPositionChangeTime=0,this.renderDecorationsTimer=void 0,I5.query&&this._run()}hasDecorations(){return this.decorations.length>0}restore(e){this.occurrencesHighlightEnablement!==`off`&&(this.runDelayer.cancel(),this.runDelayer.trigger(()=>{this._run(!1,e)}))}stop(){this.occurrencesHighlightEnablement!==`off`&&this._stopAll()}_getSortedHighlights(){return this.decorations.getRanges().sort(J.compareRangesUsingStarts)}moveNext(){let e=this._getSortedHighlights(),t=(e.findIndex(e=>e.containsPosition(this.editor.getPosition()))+1)%e.length,n=e[t];try{this._ignorePositionChangeEvent=!0,this.editor.setPosition(n.getStartPosition()),this.editor.revealRangeInCenterIfOutsideViewport(n);let r=this._getWord();r&&WH(`${this.editor.getModel().getLineContent(n.startLineNumber)}, ${t+1} of ${e.length} for '${r.word}'`)}finally{this._ignorePositionChangeEvent=!1}}moveBack(){let e=this._getSortedHighlights(),t=(e.findIndex(e=>e.containsPosition(this.editor.getPosition()))-1+e.length)%e.length,n=e[t];try{this._ignorePositionChangeEvent=!0,this.editor.setPosition(n.getStartPosition()),this.editor.revealRangeInCenterIfOutsideViewport(n);let r=this._getWord();r&&WH(`${this.editor.getModel().getLineContent(n.startLineNumber)}, ${t+1} of ${e.length} for '${r.word}'`)}finally{this._ignorePositionChangeEvent=!1}}_removeSingleDecorations(){if(!this.editor.hasModel())return;let e=I5.storedDecorationIDs.get(this.editor.getModel().uri);e&&(this.editor.removeDecorations(e),I5.storedDecorationIDs.delete(this.editor.getModel().uri),this.decorations.length>0&&(this.decorations.clear(),this._hasWordHighlights.set(!1)))}_removeAllDecorations(e){let t=this.codeEditorService.listCodeEditors(),n=[];for(let r of t){if(!r.hasModel()||bB(r.getModel().uri,e))continue;let t=I5.storedDecorationIDs.get(r.getModel().uri);if(!t)continue;r.removeDecorations(t),n.push(r.getModel().uri);let i=L5.get(r);i?.wordHighlighter&&i.wordHighlighter.decorations.length>0&&(i.wordHighlighter.decorations.clear(),i.wordHighlighter.workerRequest=null,i.wordHighlighter._hasWordHighlights.set(!1))}for(let e of n)I5.storedDecorationIDs.delete(e)}_stopSingular(){this._removeSingleDecorations(),this.editor.hasTextFocus()&&(this.editor.getModel()?.uri.scheme!==JL.vscodeNotebookCell&&I5.query?.modelInfo?.modelURI.scheme!==JL.vscodeNotebookCell?(I5.query=null,this._run()):I5.query?.modelInfo&&(I5.query.modelInfo=null)),this.renderDecorationsTimer!==void 0&&(clearTimeout(this.renderDecorationsTimer),this.renderDecorationsTimer=void 0),this.workerRequest!==null&&(this.workerRequest.cancel(),this.workerRequest=null),this.workerRequestCompleted||=(this.workerRequestTokenId++,!0)}_stopAll(e){this._removeAllDecorations(e),this.renderDecorationsTimer!==void 0&&(clearTimeout(this.renderDecorationsTimer),this.renderDecorationsTimer=void 0),this.workerRequest!==null&&(this.workerRequest.cancel(),this.workerRequest=null),this.workerRequestCompleted||=(this.workerRequestTokenId++,!0)}_onPositionChanged(e){if(this.occurrencesHighlightEnablement===`off`){this._stopAll();return}if(e.source!==`api`&&e.reason!==3){this._stopAll();return}this._run()}_getWord(){let e=this.editor.getSelection(),t=e.startLineNumber,n=e.startColumn;return this.model.isDisposed()?null:this.model.getWordAtPosition({lineNumber:t,column:n})}getOtherModelsToHighlight(e){if(!e)return[];if(e.uri.scheme===JL.vscodeNotebookCell){let t=[],n=this.codeEditorService.listCodeEditors();for(let r of n){let n=r.getModel();n&&n!==e&&n.uri.scheme===JL.vscodeNotebookCell&&t.push(n)}return t}let t=[],n=this.codeEditorService.listCodeEditors();for(let r of n){if(!pPn(r))continue;let n=r.getModel();n&&e===n.modified&&t.push(n.modified)}if(t.length)return t;if(this.occurrencesHighlightEnablement===`singleFile`)return[];for(let r of n){let n=r.getModel();n&&n!==e&&t.push(n)}return t}async _run(e,t){if(this.editor.hasTextFocus()){let e=this.editor.getSelection();if(!e||e.startLineNumber!==e.endLineNumber){I5.query=null,this._stopAll();return}let t=e.startColumn,n=e.endColumn,r=this._getWord();if(!r||r.startColumn>t||r.endColumn<n){I5.query=null,this._stopAll();return}I5.query={modelInfo:{modelURI:this.model.uri,selection:e}}}else if(!I5.query){this._stopAll();return}if(this.lastCursorPositionChangeTime=new Date().getTime(),bB(this.editor.getModel().uri,I5.query.modelInfo?.modelURI)){if(!e){let e=this.decorations.getRanges();for(let t of e)if(t.containsPosition(this.editor.getPosition()))return}this._stopAll(e?this.model.uri:void 0);let n=++this.workerRequestTokenId;this.workerRequestCompleted=!1;let r=this.getOtherModelsToHighlight(this.editor.getModel());if(!I5.query||!I5.query.modelInfo)return;let i=await this.textModelService.createModelReference(I5.query.modelInfo.modelURI);try{this.workerRequest=this.computeWithModel(i.object.textEditorModel,I5.query.modelInfo.selection,r),this.workerRequest?.result.then(e=>{n===this.workerRequestTokenId&&(this.workerRequestCompleted=!0,this.workerRequestValue=e||[],this._beginRenderDecorations(t??this.occurrencesHighlightDelay))},$N)}catch(e){this.logService.error(`Unexpected error during occurrence request. Log: `,e)}finally{i.dispose()}}else if(this.model.uri.scheme===JL.vscodeNotebookCell){let e=++this.workerRequestTokenId;if(this.workerRequestCompleted=!1,!I5.query||!I5.query.modelInfo)return;let n=await this.textModelService.createModelReference(I5.query.modelInfo.modelURI);try{this.workerRequest=this.computeWithModel(n.object.textEditorModel,I5.query.modelInfo.selection,[this.model]),this.workerRequest?.result.then(n=>{e===this.workerRequestTokenId&&(this.workerRequestCompleted=!0,this.workerRequestValue=n||[],this._beginRenderDecorations(t??this.occurrencesHighlightDelay))},$N)}catch(e){this.logService.error(`Unexpected error during occurrence request. Log: `,e)}finally{n.dispose()}}}computeWithModel(e,t,n){return n.length?p3n(this.multiDocumentProviders,e,t,this.editor.getOption(148),n):f3n(this.providers,e,t,this.editor.getOption(148))}_beginRenderDecorations(e){let t=new Date().getTime(),n=this.lastCursorPositionChangeTime+e;t>=n?(this.renderDecorationsTimer=void 0,this.renderDecorations()):this.renderDecorationsTimer=setTimeout(()=>{this.renderDecorations()},n-t)}renderDecorations(){this.renderDecorationsTimer=void 0;let e=this.codeEditorService.listCodeEditors();for(let t of e){let e=L5.get(t);if(!e)continue;let n=[],r=t.getModel()?.uri;if(r&&this.workerRequestValue.has(r)){let i=I5.storedDecorationIDs.get(r),a=this.workerRequestValue.get(r);if(a)for(let e of a)e.range&&n.push({range:e.range,options:j0n(e.kind)});let o=[];t.changeDecorations(e=>{o=e.deltaDecorations(i??[],n)}),I5.storedDecorationIDs=I5.storedDecorationIDs.set(r,o),n.length>0&&(e.wordHighlighter?.decorations.set(n),e.wordHighlighter?._hasWordHighlights.set(!0))}}this.workerRequest=null}dispose(){this._stopSingular(),this.toUnhook.dispose()}};m3n=I5=i3n([F5(4,Nz),F5(5,jz),F5(6,ZB),F5(7,wB)],m3n);var L5=class extends G{static{a3n=this}static{this.ID=`editor.contrib.wordHighlighter`}static get(e){return e.getContribution(a3n.ID)}constructor(e,t,n,r,i,a,o){super(),this._wordHighlighter=null;let s=()=>{e.hasModel()&&!e.getModel().isTooLargeForTokenization()&&e.getModel().uri.scheme!==JL.accessibleView&&(this._wordHighlighter=new m3n(e,n.documentHighlightProvider,n.multiDocumentHighlightProvider,t,i,r,a,o))};this._register(e.onDidChangeModel(e=>{this._wordHighlighter&&=(!e.newModelUrl&&e.oldModelUrl?.scheme!==JL.vscodeNotebookCell&&this.wordHighlighter?.stop(),this._wordHighlighter.dispose(),null),s()})),s()}get wordHighlighter(){return this._wordHighlighter}saveViewState(){return!!(this._wordHighlighter&&this._wordHighlighter.hasDecorations())}moveNext(){this._wordHighlighter?.moveNext()}moveBack(){this._wordHighlighter?.moveBack()}restoreViewState(e){this._wordHighlighter&&e&&this._wordHighlighter.restore(250)}dispose(){this._wordHighlighter&&=(this._wordHighlighter.dispose(),null),super.dispose()}};L5=a3n=i3n([F5(1,$z),F5(2,hH),F5(3,jz),F5(4,Nz),F5(5,ZB),F5(6,wB)],L5);var h3n=class extends kB{constructor(e,t){super(t),this._isNext=e}run(e,t){let n=L5.get(t);n&&(this._isNext?n.moveNext():n.moveBack())}},g3n=class extends h3n{constructor(){super(!0,{id:`editor.action.wordHighlight.next`,label:U(1572,`Go to Next Symbol Highlight`),precondition:o3n,kbOpts:{kbExpr:$.editorTextFocus,primary:65,weight:100}})}},_3n=class extends h3n{constructor(){super(!1,{id:`editor.action.wordHighlight.prev`,label:U(1573,`Go to Previous Symbol Highlight`),precondition:o3n,kbOpts:{kbExpr:$.editorTextFocus,primary:1089,weight:100}})}},v3n=class extends kB{constructor(){super({id:`editor.action.wordHighlight.trigger`,label:U(1574,`Trigger Symbol Highlight`),precondition:void 0,kbOpts:{kbExpr:$.editorTextFocus,primary:0,weight:100}})}run(e,t,n){let r=L5.get(t);r&&r.restoreViewState(!0)}};IB(L5.ID,L5,0),PB(g3n),PB(_3n),PB(v3n),x0(r3n);var R5=class extends OB{constructor(e){super(e),this._inSelectionMode=e.inSelectionMode,this._wordNavigationType=e.wordNavigationType}runEditorCommand(e,t,n){if(!t.hasModel())return;let r=wV(t.getOption(148),t.getOption(147)),i=t.getModel(),a=t.getSelections(),o=a.length>1,s=a.map(e=>{let t=new q(e.positionLineNumber,e.positionColumn),n=this._move(r,i,t,this._wordNavigationType,o);return this._moveTo(e,n,this._inSelectionMode)});if(i.pushStackElement(),t._getViewModel().setCursorStates(`moveWordCommand`,3,s.map(e=>eG.fromModelSelection(e))),s.length===1){let e=new q(s[0].positionLineNumber,s[0].positionColumn);t.revealPosition(e,0)}}_moveTo(e,t,n){return n?new gI(e.selectionStartLineNumber,e.selectionStartColumn,t.lineNumber,t.column):new gI(t.lineNumber,t.column,t.lineNumber,t.column)}},z5=class extends R5{_move(e,t,n,r,i){return pG.moveWordLeft(e,t,n,r,i)}},B5=class extends R5{_move(e,t,n,r,i){return pG.moveWordRight(e,t,n,r)}},y3n=class extends z5{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:`cursorWordStartLeft`,precondition:void 0})}},b3n=class extends z5{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:`cursorWordEndLeft`,precondition:void 0})}},x3n=class extends z5{constructor(){super({inSelectionMode:!1,wordNavigationType:1,id:`cursorWordLeft`,precondition:void 0,kbOpts:{kbExpr:Wz.and($.textInputFocus,Wz.and(QH,p1)?.negate()),primary:2063,mac:{primary:527},weight:100}})}},S3n=class extends z5{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:`cursorWordStartLeftSelect`,precondition:void 0})}},C3n=class extends z5{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:`cursorWordEndLeftSelect`,precondition:void 0})}},w3n=class extends z5{constructor(){super({inSelectionMode:!0,wordNavigationType:1,id:`cursorWordLeftSelect`,precondition:void 0,kbOpts:{kbExpr:Wz.and($.textInputFocus,Wz.and(QH,p1)?.negate()),primary:3087,mac:{primary:1551},weight:100}})}},T3n=class extends z5{constructor(){super({inSelectionMode:!1,wordNavigationType:3,id:`cursorWordAccessibilityLeft`,precondition:void 0})}_move(e,t,n,r,i){return super._move(wV(MF.wordSeparators.defaultValue,e.intlSegmenterLocales),t,n,r,i)}},E3n=class extends z5{constructor(){super({inSelectionMode:!0,wordNavigationType:3,id:`cursorWordAccessibilityLeftSelect`,precondition:void 0})}_move(e,t,n,r,i){return super._move(wV(MF.wordSeparators.defaultValue,e.intlSegmenterLocales),t,n,r,i)}},D3n=class extends B5{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:`cursorWordStartRight`,precondition:void 0})}},O3n=class extends B5{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:`cursorWordEndRight`,precondition:void 0,kbOpts:{kbExpr:Wz.and($.textInputFocus,Wz.and(QH,p1)?.negate()),primary:2065,mac:{primary:529},weight:100}})}},k3n=class extends B5{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:`cursorWordRight`,precondition:void 0})}},A3n=class extends B5{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:`cursorWordStartRightSelect`,precondition:void 0})}},j3n=class extends B5{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:`cursorWordEndRightSelect`,precondition:void 0,kbOpts:{kbExpr:Wz.and($.textInputFocus,Wz.and(QH,p1)?.negate()),primary:3089,mac:{primary:1553},weight:100}})}},M3n=class extends B5{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:`cursorWordRightSelect`,precondition:void 0})}},N3n=class extends B5{constructor(){super({inSelectionMode:!1,wordNavigationType:3,id:`cursorWordAccessibilityRight`,precondition:void 0})}_move(e,t,n,r,i){return super._move(wV(MF.wordSeparators.defaultValue,e.intlSegmenterLocales),t,n,r,i)}},P3n=class extends B5{constructor(){super({inSelectionMode:!0,wordNavigationType:3,id:`cursorWordAccessibilityRightSelect`,precondition:void 0})}_move(e,t,n,r,i){return super._move(wV(MF.wordSeparators.defaultValue,e.intlSegmenterLocales),t,n,r,i)}},V5=class extends OB{constructor(e){super({canTriggerInlineEdits:!0,...e}),this._whitespaceHeuristics=e.whitespaceHeuristics,this._wordNavigationType=e.wordNavigationType}runEditorCommand(e,t,n){let r=e?.get(fV);if(!t.hasModel()||!r)return;let i=wV(t.getOption(148),t.getOption(147)),a=t.getModel(),o=t.getSelections(),s=t.getOption(10),c=t.getOption(15),l=r.getLanguageConfiguration(a.getLanguageId()).getAutoClosingPairs(),u=t._getViewModel(),d=o.map(e=>new aG(this._delete({wordSeparators:i,model:a,selection:e,whitespaceHeuristics:this._whitespaceHeuristics,autoClosingDelete:t.getOption(13),autoClosingBrackets:s,autoClosingQuotes:c,autoClosingPairs:l,autoClosedCharacters:u.getCursorAutoClosedCharacters()},this._wordNavigationType),``));t.pushUndoStop(),t.executeCommands(this.id,d),t.pushUndoStop()}},F3n=class extends V5{_delete(e,t){return pG.deleteWordLeft(e,t)||new J(1,1,1,1)}},I3n=class extends V5{_delete(e,t){let n=pG.deleteWordRight(e,t);if(n)return n;let r=e.model.getLineCount(),i=e.model.getLineMaxColumn(r);return new J(r,i,r,i)}},L3n=class extends F3n{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:0,id:`deleteWordStartLeft`,precondition:$.writable})}},R3n=class extends F3n{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:2,id:`deleteWordEndLeft`,precondition:$.writable})}},z3n=class extends F3n{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:0,id:`deleteWordLeft`,precondition:$.writable,kbOpts:{kbExpr:$.textInputFocus,primary:2049,mac:{primary:513},weight:100}})}},B3n=class extends I3n{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:0,id:`deleteWordStartRight`,precondition:$.writable})}},V3n=class extends I3n{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:2,id:`deleteWordEndRight`,precondition:$.writable})}},H3n=class extends I3n{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:2,id:`deleteWordRight`,precondition:$.writable,kbOpts:{kbExpr:$.textInputFocus,primary:2068,mac:{primary:532},weight:100}})}},U3n=class extends kB{constructor(){super({id:`deleteInsideWord`,precondition:$.writable,label:U(1575,`Delete Word`)})}run(e,t,n){if(!t.hasModel())return;let r=wV(t.getOption(148),t.getOption(147)),i=t.getModel(),a=t.getSelections().map(e=>new aG(pG.deleteInsideWord(r,i,e),``));t.pushUndoStop(),t.executeCommands(this.id,a),t.pushUndoStop()}};NB(new y3n),NB(new b3n),NB(new x3n),NB(new S3n),NB(new C3n),NB(new w3n),NB(new D3n),NB(new O3n),NB(new k3n),NB(new A3n),NB(new j3n),NB(new M3n),NB(new T3n),NB(new E3n),NB(new N3n),NB(new P3n),NB(new L3n),NB(new R3n),NB(new z3n),NB(new B3n),NB(new V3n),NB(new H3n),PB(U3n);var W3n=class extends V5{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:0,id:`deleteWordPartLeft`,precondition:$.writable,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:769},weight:100}})}_delete(e,t){return mG.deleteWordPartLeft(e)||new J(1,1,1,1)}},G3n=class extends V5{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:2,id:`deleteWordPartRight`,precondition:$.writable,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:788},weight:100}})}_delete(e,t){let n=mG.deleteWordPartRight(e);if(n)return n;let r=e.model.getLineCount(),i=e.model.getLineMaxColumn(r);return new J(r,i,r,i)}},K3n=class extends R5{_move(e,t,n,r,i){return mG.moveWordPartLeft(e,t,n,i)}},q3n=class extends K3n{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:`cursorWordPartLeft`,precondition:void 0,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:783},weight:100}})}};Vz.registerCommandAlias(`cursorWordPartStartLeft`,`cursorWordPartLeft`);var J3n=class extends K3n{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:`cursorWordPartLeftSelect`,precondition:void 0,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:1807},weight:100}})}};Vz.registerCommandAlias(`cursorWordPartStartLeftSelect`,`cursorWordPartLeftSelect`);var Y3n=class extends R5{_move(e,t,n,r,i){return mG.moveWordPartRight(e,t,n)}},X3n=class extends Y3n{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:`cursorWordPartRight`,precondition:void 0,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:785},weight:100}})}},Z3n=class extends Y3n{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:`cursorWordPartRightSelect`,precondition:void 0,kbOpts:{kbExpr:$.textInputFocus,primary:0,mac:{primary:1809},weight:100}})}};NB(new W3n),NB(new G3n),NB(new q3n),NB(new J3n),NB(new X3n),NB(new Z3n);var Q3n=class extends G{static{this.ID=`editor.contrib.readOnlyMessageController`}constructor(e){super(),this.editor=e,this._register(this.editor.onDidAttemptReadOnlyEdit(()=>this._onDidAttemptReadOnlyEdit()))}_onDidAttemptReadOnlyEdit(){let e=E2.get(this.editor);if(e&&this.editor.hasModel()){let t=this.editor.getOptions().get(105);t||=this.editor.isSimpleWidget?new GX(H(1378,`Cannot edit in read-only input`)):new GX(H(1379,`Cannot edit in read-only editor`)),e.showMessage(t,this.editor.getPosition())}}};IB(Q3n.ID,Q3n,2);var $3n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},e6n=function(e,t){return function(n,r){t(n,r,e)}},t6n=class extends G{constructor(e,t,n){super(),this._textModel=e,this._languageFeaturesService=t,this._outlineModelService=n,this._currentModel=FR(this,void 0);let r=H0(`documentSymbolProvider.onDidChange`,this._languageFeaturesService.documentSymbolProvider.onDidChange),i=H0(`_textModel.onDidChangeContent`,ZP.debounce(e=>this._textModel.onDidChangeContent(e),()=>void 0,100));this._register(wR(async(e,t)=>{r.read(e),i.read(e);let n=t.add(new yMn),a=await this._outlineModelService.getOrCreate(this._textModel,n.token);t.isDisposed||this._currentModel.set(a,void 0)}))}getBreadcrumbItems(e,t){let n=this._currentModel.read(t);if(!n)return[];let r=n.asListOfDocumentSymbols().filter(t=>e.contains(t.range.startLineNumber)&&!e.contains(t.range.endLineNumber));return r.sort(g1t(qN(e=>e.range.endLineNumber-e.range.startLineNumber,JN))),r.map(e=>({name:e.name,kind:e.kind,startLineNumber:e.range.startLineNumber}))}};t6n=$3n([e6n(1,hH),e6n(2,v6)],t6n),i2.setBreadcrumbsSourceFactory((e,t)=>t.createInstance(t6n,e));var n6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},r6n=function(e,t){return function(n,r){t(n,r,e)}},H5=class extends G{static{this.ID=`editor.contrib.floatingToolbar`}constructor(e,t,n,r){super();let i=this._register(X0(e)),a=this._register(r.createMenu(aB.EditorContent,e.contextKeyService)),o=AR(this,a.onDidChange,()=>a.getActions().length===0);this._register(xR(e=>{if(o.read(e))return;let r=vz(`div.floating-menu-overlay-widget`);r.root.style.height=`28px`;let a=t.createInstance(t2,r.root,aB.EditorContent,{actionViewItemProvider:(e,r)=>{if(!(e instanceof uB))return;let i=n.lookupKeybinding(e.id);if(i)return t.createInstance(class extends D${updateLabel(){this.options.label&&this.label&&(this.label.textContent=`${this._commandAction.label} (${i.getLabel()})`)}},e,{...r,keybindingNotRenderedWithLabel:!0})},hiddenItemStrategy:0,menuOptions:{shouldForwardArgs:!0},telemetrySource:`editor.overlayToolbar`,toolbarOptions:{primaryGroup:()=>!0,useSeparatorsInPrimaryActions:!0}});e.store.add(a),e.store.add(xR(e=>{let t=i.model.read(e);a.context=t?.uri})),e.store.add(i.createOverlayWidget({allowEditorOverflow:!1,domNode:r.root,minContentWidthInPx:s$(0),position:s$({preference:1})}))}))}};H5=n6n([r6n(1,kz),r6n(2,UK),r6n(3,oB)],H5),IB(H5.ID,H5,1);var i6n=class extends G{static{this.ID=`editor.contrib.iPadShowKeyboard`}constructor(e){super(),this.editor=e,this.widget=null,FP&&(this._register(e.onDidChangeConfiguration(()=>this.update())),this.update())}update(){let e=!this.editor.getOption(104);!this.widget&&e?this.widget=new a6n(this.editor):this.widget&&!e&&(this.widget.dispose(),this.widget=null)}dispose(){super.dispose(),this.widget&&=(this.widget.dispose(),null)}},a6n=class e extends G{static{this.ID=`editor.contrib.ShowKeyboardWidget`}constructor(e){super(),this.editor=e,this._domNode=document.createElement(`textarea`),this._domNode.className=`iPadShowKeyboard`,this._register(X(this._domNode,`touchstart`,e=>{this.editor.focus()})),this._register(X(this._domNode,`focus`,e=>{this.editor.focus()})),this.editor.addOverlayWidget(this)}dispose(){this.editor.removeOverlayWidget(this),super.dispose()}getId(){return e.ID}getDomNode(){return this._domNode}getPosition(){return{preference:1}}};IB(i6n.ID,i6n,3);var o6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},s6n=function(e,t){return function(n,r){t(n,r,e)}},c6n,U5=class extends G{static{c6n=this}static{this.ID=`editor.contrib.inspectTokens`}static get(e){return e.getContribution(c6n.ID)}constructor(e,t,n){super(),this._editor=e,this._languageService=n,this._widget=null,this._register(this._editor.onDidChangeModel(e=>this.stop())),this._register(this._editor.onDidChangeModelLanguage(e=>this.stop())),this._register(NI.onDidChange(e=>this.stop())),this._register(this._editor.onKeyUp(e=>e.keyCode===9&&this.stop()))}dispose(){this.stop(),super.dispose()}launch(){this._widget||this._editor.hasModel()&&(this._widget=new f6n(this._editor,this._languageService))}stop(){this._widget&&=(this._widget.dispose(),null)}};U5=c6n=o6n([s6n(1,l0),s6n(2,QB)],U5);var l6n=class extends kB{constructor(){super({id:`editor.action.inspectTokens`,label:jCn.inspectTokensAction,alias:`Developer: Inspect Tokens`,precondition:void 0})}run(e,t){U5.get(t)?.launch()}};function u6n(e){let t=``;for(let n=0,r=e.length;n<r;n++){let r=e.charCodeAt(n);switch(r){case 9:t+=`→`;break;case 32:t+=`·`;break;default:t+=String.fromCharCode(r)}}return t}function d6n(e,t){let n=NI.get(t);if(n)return n;let r=e.encodeLanguageId(t);return{getInitialState:()=>bH,tokenize:(e,n,r)=>Wnn(t,r),tokenizeEncoded:(e,t,n)=>xH(r,n)}}var f6n=class e extends G{static{this._ID=`editor.contrib.inspectTokensWidget`}constructor(e,t){super(),this.allowEditorOverflow=!0,this._editor=e,this._languageService=t,this._model=this._editor.getModel(),this._domNode=document.createElement(`div`),this._domNode.className=`tokens-inspect-widget`,this._tokenizationSupport=d6n(this._languageService.languageIdCodec,this._model.getLanguageId()),this._compute(this._editor.getPosition()),this._register(this._editor.onDidChangeCursorPosition(e=>this._compute(this._editor.getPosition()))),this._editor.addContentWidget(this)}dispose(){this._editor.removeContentWidget(this),super.dispose()}getId(){return e._ID}_compute(e){let t=this._getTokensAtLine(e.lineNumber),n=0;for(let r=t.tokens1.length-1;r>=0;r--){let i=t.tokens1[r];if(e.column-1>=i.offset){n=r;break}}let r=0;for(let n=t.tokens2.length>>>1;n>=0;n--)if(e.column-1>=t.tokens2[n<<1]){r=n;break}let i=this._model.getLineContent(e.lineNumber),a=``;if(n<t.tokens1.length){let e=t.tokens1[n].offset,r=n+1<t.tokens1.length?t.tokens1[n+1].offset:i.length;a=i.substring(e,r)}fz(this._domNode,mz(`h2.tm-token`,void 0,u6n(a),mz(`span.tm-token-length`,void 0,`${a.length} ${a.length===1?`char`:`chars`}`))),uz(this._domNode,mz(`hr.tokens-inspect-separator`,{style:`clear:both`}));let o=(r<<1)+1<t.tokens2.length?this._decodeMetadata(t.tokens2[(r<<1)+1]):null;uz(this._domNode,mz(`table.tm-metadata-table`,void 0,mz(`tbody`,void 0,mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`language`),mz(`td.tm-metadata-value`,void 0,`${o?o.languageId:`-?-`}`)),mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`token type`),mz(`td.tm-metadata-value`,void 0,`${o?this._tokenTypeToString(o.tokenType):`-?-`}`)),mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`font style`),mz(`td.tm-metadata-value`,void 0,`${o?this._fontStyleToString(o.fontStyle):`-?-`}`)),mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`foreground`),mz(`td.tm-metadata-value`,void 0,`${o?Z.Format.CSS.formatHex(o.foreground):`-?-`}`)),mz(`tr`,void 0,mz(`td.tm-metadata-key`,void 0,`background`),mz(`td.tm-metadata-value`,void 0,`${o?Z.Format.CSS.formatHex(o.background):`-?-`}`))))),uz(this._domNode,mz(`hr.tokens-inspect-separator`)),n<t.tokens1.length&&uz(this._domNode,mz(`span.tm-token-type`,void 0,t.tokens1[n].type)),this._editor.layoutContentWidget(this)}_decodeMetadata(e){let t=NI.getColorMap(),n=SH.getLanguageId(e),r=SH.getTokenType(e),i=SH.getFontStyle(e),a=SH.getForeground(e),o=SH.getBackground(e);return{languageId:this._languageService.languageIdCodec.decodeLanguageId(n),tokenType:r,fontStyle:i,foreground:t[a],background:t[o]}}_tokenTypeToString(e){switch(e){case 0:return`Other`;case 1:return`Comment`;case 2:return`String`;case 3:return`RegEx`;default:return`??`}}_fontStyleToString(e){let t=``;return e&1&&(t+=`italic `),e&2&&(t+=`bold `),e&4&&(t+=`underline `),e&8&&(t+=`strikethrough `),t.length===0&&(t=`---`),t}_getTokensAtLine(e){let t=this._getStateBeforeLine(e),n=this._tokenizationSupport.tokenize(this._model.getLineContent(e),!0,t),r=this._tokenizationSupport.tokenizeEncoded(this._model.getLineContent(e),!0,t);return{startState:t,tokens1:n.tokens,tokens2:r.tokens,endState:n.endState}}_getStateBeforeLine(e){let t=this._tokenizationSupport.getInitialState();for(let n=1;n<e;n++)t=this._tokenizationSupport.tokenize(this._model.getLineContent(n),!0,t).endState;return t}getDomNode(){return this._domNode}getPosition(){return{position:this._editor.getPosition(),preference:[2,1]}}};IB(U5.ID,U5,4),PB(l6n);var p6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},m6n=function(e,t){return function(n,r){t(n,r,e)}},W5,h6n=class{static{W5=this}static{this.PREFIX=`?`}constructor(e,t){this.quickInputService=e,this.keybindingService=t,this.registry=tB.as(L$.Quickaccess)}provide(e){let t=new W;return t.add(e.onDidAccept(()=>{let[t]=e.selectedItems;t&&this.quickInputService.quickAccess.show(t.prefix,{preserveValue:!0})})),t.add(e.onDidChangeValue(e=>{let t=this.registry.getQuickAccessProvider(e.substr(W5.PREFIX.length));t&&t.prefix&&t.prefix!==W5.PREFIX&&this.quickInputService.quickAccess.show(t.prefix,{preserveValue:!0})})),e.items=this.getQuickAccessProviders().filter(e=>e.prefix!==W5.PREFIX),t}getQuickAccessProviders(){return this.registry.getQuickAccessProviders().sort((e,t)=>e.prefix.localeCompare(t.prefix)).flatMap(e=>this.createPicks(e))}createPicks(e){return e.helpEntries.map(t=>{let n=t.prefix||e.prefix,r=n||`…`;return{prefix:n,label:r,keybinding:t.commandId?this.keybindingService.lookupKeybinding(t.commandId):void 0,ariaLabel:H(1747,`{0}, {1}`,r,t.description),description:t.description}})}};h6n=W5=p6n([m6n(0,_Q),m6n(1,UK)],h6n),tB.as(L$.Quickaccess).registerQuickAccessProvider({ctor:h6n,prefix:``,helpEntries:[{description:NCn.helpQuickAccessActionLabel}]});var g6n=class{constructor(e){this.options=e,this.rangeHighlightDecorationId=void 0}provide(e,t,n){let r=new W;e.canAcceptInBackground=!!this.options?.canAcceptInBackground,e.matchOnLabel=e.matchOnDescription=e.matchOnDetail=e.sortByLabel=!1;let i=r.add(new KP);return i.value=this.doProvide(e,t,n),r.add(this.onDidActiveTextEditorControlChange(()=>{i.value=void 0,i.value=this.doProvide(e,t)})),r}doProvide(e,t,n){let r=new W,i=this.activeTextEditorControl;if(i&&this.canProvideWithTextEditor(i)){let a={editor:i},o=hPn(i);if(o){let e=i.saveViewState()??void 0;r.add(o.onDidChangeCursorPosition(()=>{e=i.saveViewState()??void 0})),a.restoreViewState=()=>{e&&i===this.activeTextEditorControl&&i.restoreViewState(e)},r.add(zP(t.onCancellationRequested)(()=>a.restoreViewState?.()))}r.add(GP(()=>this.clearDecorations(i))),r.add(this.provideWithTextEditor(a,e,t,n))}else r.add(this.provideWithoutTextEditor(e,t));return r}canProvideWithTextEditor(e){return!0}gotoLocation({editor:e},t){e.setSelection(t.range,`code.jump`),e.revealRangeInCenter(t.range,0),t.preserveFocus||e.focus();let n=e.getModel();n&&`getLineContent`in n&&GH(`${n.getLineContent(t.range.startLineNumber)}`)}getModel(e){return pPn(e)?e.getModel()?.modified:e.getModel()}addDecorations(e,t){e.changeDecorations(e=>{let n=[];this.rangeHighlightDecorationId&&=(n.push(this.rangeHighlightDecorationId.overviewRulerDecorationId),n.push(this.rangeHighlightDecorationId.rangeHighlightId),void 0);let r=[{range:t,options:{description:`quick-access-range-highlight`,className:`rangeHighlight`,isWholeLine:!0}},{range:t,options:{description:`quick-access-range-highlight-overview`,overviewRuler:{color:ZG(Tln),position:TV.Full}}}],[i,a]=e.deltaDecorations(n,r);this.rangeHighlightDecorationId={rangeHighlightId:i,overviewRulerDecorationId:a}})}clearDecorations(e){let t=this.rangeHighlightDecorationId;t&&(e.changeDecorations(e=>{e.deltaDecorations([t.overviewRulerDecorationId,t.rangeHighlightId],[])}),this.rangeHighlightDecorationId=void 0)}},_6n=class e extends g6n{static{this.PREFIX=`:`}static{this.ZERO_BASED_OFFSET_STORAGE_KEY=`gotoLine.useZeroBasedOffset`}constructor(){super({canAcceptInBackground:!0})}get useZeroBasedOffset(){return this.storageService.getBoolean(e.ZERO_BASED_OFFSET_STORAGE_KEY,-1,!1)}set useZeroBasedOffset(t){this.storageService.store(e.ZERO_BASED_OFFSET_STORAGE_KEY,t,-1,0)}provideWithoutTextEditor(e){let t=H(1335,`Open a text editor first to go to a line.`);return e.items=[{label:t}],e.ariaLabel=t,G.None}provideWithTextEditor(t,n,r){let i=t.editor,a=new W;a.add(n.onDidAccept(e=>{let[r]=n.selectedItems;if(r){if(!r.lineNumber)return;this.gotoLocation(t,{range:this.toRange(r.lineNumber,r.column),keyMods:n.keyMods,preserveFocus:e.inBackground}),e.inBackground||n.hide()}}));let o=()=>{let t=n.value.trim().substring(e.PREFIX.length),{inOffsetMode:r,lineNumber:a,column:o,label:c}=this.parsePosition(i,t);if(s.visible=!!r,n.items=[{lineNumber:a,column:o,label:c}],n.ariaLabel=c,!a){this.clearDecorations(i);return}let l=this.toRange(a,o);i.revealRangeInCenter(l,0),this.addDecorations(i,l)},s=new R$({title:H(1336,`Use Zero-Based Offset`),icon:vI.indexZero,isChecked:this.useZeroBasedOffset,inputActiveOptionBorder:aU(BU),inputActiveOptionForeground:aU(HU),inputActiveOptionBackground:aU(VU)});a.add(s.onChange(()=>{this.useZeroBasedOffset=!this.useZeroBasedOffset,o()})),n.toggles=[s],o(),a.add(n.onDidChangeValue(()=>o()));let c=hPn(i);return c&&c.getOptions().get(76).renderType===2&&(c.updateOptions({lineNumbers:`on`}),a.add(GP(()=>c.updateOptions({lineNumbers:`relative`})))),a}toRange(e=1,t=1){return{startLineNumber:e,startColumn:t,endLineNumber:e,endColumn:t}}parsePosition(e,t){let n=this.getModel(e);if(!n)return{label:H(1337,`Open a text editor first to go to a line.`)};if(t.startsWith(`:`)){let e=parseInt(t.substring(1),10),r=n.getValueLength();if(isNaN(e))return{inOffsetMode:!0,label:this.useZeroBasedOffset?H(1338,`Type a character position to go to (from 0 to {0}).`,r-1):H(1339,`Type a character position to go to (from 1 to {0}).`,r)};{let t=e<0;this.useZeroBasedOffset||(e-=Math.sign(e)),t&&(e+=r);let i=n.getPositionAt(e);return{...i,inOffsetMode:!0,label:H(1340,`Press 'Enter' to go to line {0} at column {1}.`,i.lineNumber,i.column)}}}{let e=t.split(/,|:|#/),r=n.getLineCount(),i=parseInt(e[0]?.trim(),10);if(e.length<1||isNaN(i))return{label:H(1341,`Type a line number to go to (from 1 to {0}).`,r)};i=i>=0?i:r+1+i,i=Math.min(Math.max(1,i),r);let a=n.getLineMaxColumn(i),o=parseInt(e[1]?.trim(),10);return e.length<2||isNaN(o)?{lineNumber:i,column:1,label:e.length<2?H(1342,`Press 'Enter' to go to line {0} or enter : to add a column number.`,i):H(1343,`Press 'Enter' to go to line {0} or enter a column number (from 1 to {1}).`,i,a)}:(o=o>=0?o:a+o,o=Math.min(Math.max(1,o),a),{lineNumber:i,column:o,label:H(1344,`Press 'Enter' to go to line {0} at column {1}.`,i,o)})}}},v6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},y6n=function(e,t){return function(n,r){t(n,r,e)}},G5=class extends _6n{constructor(e,t){super(),this.editorService=e,this.storageService=t,this.onDidActiveTextEditorControlChange=ZP.None}get activeTextEditorControl(){return this.editorService.getFocusedCodeEditor()??void 0}};G5=v6n([y6n(0,jz),y6n(1,bQ)],G5);var b6n=class e extends kB{static{this.ID=`editor.action.gotoLine`}constructor(){super({id:e.ID,label:MCn.gotoLineActionLabel,alias:`Go to Line/Column...`,precondition:void 0,kbOpts:{kbExpr:$.focus,primary:2085,mac:{primary:293},weight:100}})}run(e){e.get(_Q).quickAccess.show(G5.PREFIX)}};PB(b6n),tB.as(L$.Quickaccess).registerQuickAccessProvider({ctor:G5,prefix:G5.PREFIX,helpEntries:[{description:MCn.gotoLineActionLabel,commandId:b6n.ID}]});var x6n=[void 0,[]];function S6n(e,t,n=0,r=0){let i=t;return i.values&&i.values.length>1?C6n(e,i.values,n,r):w6n(e,t,n,r)}function C6n(e,t,n,r){let i=0,a=[];for(let o of t){let[t,s]=w6n(e,o,n,r);if(typeof t!=`number`)return x6n;i+=t,a.push(...s)}return[i,T6n(a)]}function w6n(e,t,n,r){let i=zX(t.original,t.originalLowercase,n,e,e.toLowerCase(),r,{firstMatchCanBeWeak:!0,boostFullMatch:!0});return i?[i[0],OX(i)]:x6n}function T6n(e){let t=e.sort((e,t)=>e.start-t.start),n=[],r;for(let e of t)!r||!E6n(r,e)?(r=e,n.push(e)):(r.start=Math.min(r.start,e.start),r.end=Math.max(r.end,e.end));return n}function E6n(e,t){return!(e.end<t.start||t.end<e.start)}function D6n(e){return e.startsWith(`"`)&&e.endsWith(`"`)}var O6n=` `;function k6n(e){typeof e!=`string`&&(e=``);let t=e.toLowerCase(),{pathNormalized:n,normalized:r,normalizedLowercase:i}=A6n(e),a=n.indexOf(cI)>=0,o=D6n(e),s,c=e.split(O6n);if(c.length>1)for(let e of c){let t=D6n(e),{pathNormalized:n,normalized:r,normalizedLowercase:i}=A6n(e);r&&(s||=[],s.push({original:e,originalLowercase:e.toLowerCase(),pathNormalized:n,normalized:r,normalizedLowercase:i,expectContiguousMatch:t}))}return{original:e,originalLowercase:t,pathNormalized:n,normalized:r,normalizedLowercase:i,values:s,containsPathSeparator:a,expectContiguousMatch:o}}function A6n(e){let t;t=AP?e.replace(/\//g,cI):e.replace(/\\/g,cI);let n=t.replace(/[\*\u2026\s"]/g,``);return{pathNormalized:t,normalized:n,normalizedLowercase:n.toLowerCase()}}function j6n(e){return k6n(Array.isArray(e)?e.map(e=>e.original).join(O6n):e.original)}var M6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},N6n=function(e,t){return function(n,r){t(n,r,e)}},K5,q5=class extends g6n{static{K5=this}static{this.PREFIX=`@`}static{this.SCOPE_PREFIX=`:`}static{this.PREFIX_BY_CATEGORY=`${this.PREFIX}${this.SCOPE_PREFIX}`}constructor(e,t,n=Object.create(null)){super(n),this._languageFeaturesService=e,this._outlineModelService=t,this.options=n,this.options.canAcceptInBackground=!0}provideWithoutTextEditor(e){return this.provideLabelPick(e,H(1345,`To go to a symbol, first open a text editor with symbol information.`)),G.None}provideWithTextEditor(e,t,n,r){let i=e.editor,a=this.getModel(i);return a?this._languageFeaturesService.documentSymbolProvider.has(a)?this.doProvideWithEditorSymbols(e,a,t,n,r):this.doProvideWithoutEditorSymbols(e,a,t,n):G.None}doProvideWithoutEditorSymbols(e,t,n,r){let i=new W;return this.provideLabelPick(n,H(1346,`The active text editor does not provide symbol information.`)),(async()=>{await this.waitForLanguageSymbolRegistry(t,i)&&!r.isCancellationRequested&&i.add(this.doProvideWithEditorSymbols(e,t,n,r))})(),i}provideLabelPick(e,t){e.items=[{label:t,index:0,kind:14}],e.ariaLabel=t}async waitForLanguageSymbolRegistry(e,t){if(this._languageFeaturesService.documentSymbolProvider.has(e))return!0;let n=new GL,r=t.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(()=>{this._languageFeaturesService.documentSymbolProvider.has(e)&&(r.dispose(),n.complete(!0))}));return t.add(GP(()=>n.complete(!1))),n.p}doProvideWithEditorSymbols(e,t,n,r,i){let a=e.editor,o=new W;o.add(n.onDidAccept(t=>{let[r]=n.selectedItems;r&&r.range&&(this.gotoLocation(e,{range:r.range.selection,keyMods:n.keyMods,preserveFocus:t.inBackground}),i?.handleAccept?.(r,t.inBackground),t.inBackground||n.hide())})),o.add(n.onDidTriggerItemButton(({item:t})=>{t&&t.range&&(this.gotoLocation(e,{range:t.range.selection,keyMods:n.keyMods,forceSideBySide:!0}),n.hide())}));let s=this.getDocumentSymbols(t,r),c=o.add(new KP),l=async e=>{c?.value?.cancel(),n.busy=!1,c.value=new FF,n.busy=!0;try{let i=k6n(n.value.substr(K5.PREFIX.length).trim()),a=await this.doGetSymbolPicks(s,i,void 0,c.value.token,t);if(r.isCancellationRequested)return;if(a.length>0){if(n.items=a,e&&i.original.length===0){let t=LV(a,t=>!!(t.type!==`separator`&&t.range&&J.containsPosition(t.range.decoration,e)));t&&(n.activeItems=[t])}}else i.original.length>0?this.provideLabelPick(n,H(1347,`No matching editor symbols`)):this.provideLabelPick(n,H(1348,`No editor symbols`))}finally{r.isCancellationRequested||(n.busy=!1)}};return o.add(n.onDidChangeValue(()=>l(void 0))),l(a.getSelection()?.getPosition()),o.add(n.onDidChangeActive(()=>{let[e]=n.activeItems;e&&e.range&&(a.revealRangeInCenter(e.range.selection,0),this.addDecorations(a,e.range.decoration))})),o}async doGetSymbolPicks(e,t,n,r,i){let a=await e;if(r.isCancellationRequested)return[];let o=t.original.indexOf(K5.SCOPE_PREFIX)===0,s=+!!o,c,l;t.values&&t.values.length>1?(c=j6n(t.values[0]),l=j6n(t.values.slice(1))):c=t;let u,d=this.options?.openSideBySideDirection?.();d&&(u=[{iconClass:d===`right`?zz.asClassName(vI.splitHorizontal):zz.asClassName(vI.splitVertical),tooltip:d===`right`?H(1349,`Open to the Side`):H(1350,`Open to the Bottom`)}]);let f=[];for(let e=0;e<a.length;e++){let r=a[e],o=S3t(r.name),d=`$(${kI.toIcon(r.kind).id}) ${o}`,p=d.length-o.length,m=r.containerName;n?.extraContainerLabel&&(m=m?`${n.extraContainerLabel} • ${m}`:n.extraContainerLabel);let h,g,_,v;if(t.original.length>s){let e=!1;if(c!==t&&([h,g]=S6n(d,{...t,values:void 0},s,p),typeof h==`number`&&(e=!0)),typeof h!=`number`&&([h,g]=S6n(d,c,s,p),typeof h!=`number`))continue;if(!e&&l){if(m&&l.original.length>0&&([_,v]=S6n(m,l)),typeof _!=`number`)continue;typeof h==`number`&&(h+=_)}}let y=r.tags&&r.tags.indexOf(1)>=0;f.push({index:e,kind:r.kind,score:h,label:d,ariaLabel:g4t(r.name,r.kind),description:m,highlights:y?void 0:{label:g,description:v},range:{selection:J.collapseToStart(r.selectionRange),decoration:r.range},uri:i.uri,symbolName:o,strikethrough:y,buttons:u})}let p=f.sort((e,t)=>o?this.compareByKindAndScore(e,t):this.compareByScore(e,t)),m=[];if(o){let e,t,n=0;function r(){t&&typeof e==`number`&&n>0&&(t.label=RI(F6n[e]||P6n,n))}for(let i of p)e===i.kind?n++:(r(),e=i.kind,n=1,t={type:`separator`},m.push(t)),m.push(i);r()}else p.length>0&&(m=[{label:H(1351,`symbols ({0})`,f.length),type:`separator`},...p]);return m}compareByScore(e,t){if(typeof e.score!=`number`&&typeof t.score==`number`)return 1;if(typeof e.score==`number`&&typeof t.score!=`number`)return-1;if(typeof e.score==`number`&&typeof t.score==`number`){if(e.score>t.score)return-1;if(e.score<t.score)return 1}return e.index<t.index?-1:+(e.index>t.index)}compareByKindAndScore(e,t){let n=F6n[e.kind]||P6n,r=F6n[t.kind]||P6n,i=n.localeCompare(r);return i===0?this.compareByScore(e,t):i}async getDocumentSymbols(e,t){let n=await this._outlineModelService.getOrCreate(e,t);return t.isCancellationRequested?[]:n.asListOfDocumentSymbols()}};q5=K5=M6n([N6n(0,hH),N6n(1,v6)],q5);var P6n=H(1352,`properties ({0})`),F6n={5:H(1353,`methods ({0})`),11:H(1354,`functions ({0})`),8:H(1355,`constructors ({0})`),12:H(1356,`variables ({0})`),4:H(1357,`classes ({0})`),22:H(1358,`structs ({0})`),23:H(1359,`events ({0})`),24:H(1360,`operators ({0})`),10:H(1361,`interfaces ({0})`),2:H(1362,`namespaces ({0})`),3:H(1363,`packages ({0})`),25:H(1364,`type parameters ({0})`),1:H(1365,`modules ({0})`),6:H(1366,`properties ({0})`),9:H(1367,`enumerations ({0})`),21:H(1368,`enumeration members ({0})`),14:H(1369,`strings ({0})`),0:H(1370,`files ({0})`),17:H(1371,`arrays ({0})`),15:H(1372,`numbers ({0})`),16:H(1373,`booleans ({0})`),18:H(1374,`objects ({0})`),19:H(1375,`keys ({0})`),7:H(1376,`fields ({0})`),13:H(1377,`constants ({0})`)},I6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},L6n=function(e,t){return function(n,r){t(n,r,e)}},R6n=class extends q5{constructor(e,t,n){super(t,n),this.editorService=e,this.onDidActiveTextEditorControlChange=ZP.None}get activeTextEditorControl(){return this.editorService.getFocusedCodeEditor()??void 0}};R6n=I6n([L6n(0,jz),L6n(1,hH),L6n(2,v6)],R6n);var z6n=class e extends kB{static{this.ID=`editor.action.quickOutline`}constructor(){super({id:e.ID,label:VQ.quickOutlineActionLabel,alias:`Go to Symbol...`,precondition:$.hasDocumentSymbolProvider,kbOpts:{kbExpr:$.focus,primary:3117,weight:100},contextMenuOpts:{group:`navigation`,order:3}})}run(e){e.get(_Q).quickAccess.show(q5.PREFIX,{itemActivation:hQ.NONE})}};PB(z6n),tB.as(L$.Quickaccess).registerQuickAccessProvider({ctor:R6n,prefix:q5.PREFIX,helpEntries:[{description:VQ.quickOutlineActionLabel,prefix:q5.PREFIX,commandId:z6n.ID},{description:VQ.quickOutlineByCategoryActionLabel,prefix:q5.PREFIX_BY_CATEGORY}]});function B6n(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return t}var V6n=class e{constructor(){this.chunkCount=0,this.chunkOccurrences=new Map,this.documents=new Map}calculateScores(e,t){let n=this.computeEmbedding(e),r=new Map,i=[];for(let[e,a]of this.documents){if(t.isCancellationRequested)return[];for(let t of a.chunks){let a=this.computeSimilarityScore(t,n,r);a>0&&i.push({key:e,score:a})}}return i}static termFrequencies(t){return B6n(e.splitTerms(t))}static*splitTerms(e){let t=e=>e.toLowerCase();for(let[n]of e.matchAll(/\b\p{Letter}[\p{Letter}\d]{2,}\b/gu)){yield t(n);let e=n.replace(/([a-z])([A-Z])/g,`$1 $2`).split(/\s+/g);if(e.length>1)for(let n of e)n.length>2&&/\p{Letter}{3,}/gu.test(n)&&(yield t(n))}}updateDocuments(t){for(let{key:e}of t)this.deleteDocument(e);for(let n of t){let t=[];for(let r of n.textChunks){let n=e.termFrequencies(r);for(let e of n.keys())this.chunkOccurrences.set(e,(this.chunkOccurrences.get(e)??0)+1);t.push({text:r,tf:n})}this.chunkCount+=t.length,this.documents.set(n.key,{chunks:t})}return this}deleteDocument(e){let t=this.documents.get(e);if(t){this.documents.delete(e),this.chunkCount-=t.chunks.length;for(let e of t.chunks)for(let t of e.tf.keys()){let e=this.chunkOccurrences.get(t);if(typeof e==`number`){let n=e-1;n<=0?this.chunkOccurrences.delete(t):this.chunkOccurrences.set(t,n)}}}}computeSimilarityScore(e,t,n){let r=0;for(let[i,a]of Object.entries(t)){let t=e.tf.get(i);if(!t)continue;let o=n.get(i);typeof o!=`number`&&(o=this.computeIdf(i),n.set(i,o));let s=t*o;r+=s*a}return r}computeEmbedding(t){let n=e.termFrequencies(t);return this.computeTfidf(n)}computeIdf(e){let t=this.chunkOccurrences.get(e)??0;return t>0?Math.log((this.chunkCount+1)/t):0}computeTfidf(e){let t=Object.create(null);for(let[n,r]of e){let e=this.computeIdf(n);e>0&&(t[n]=r*e)}return t}};function H6n(e){let t=e.slice(0);t.sort((e,t)=>t.score-e.score);let n=t[0]?.score??0;if(n>0)for(let e of t)e.score/=n;return t}var J5;(function(e){e[e.NO_ACTION=0]=`NO_ACTION`,e[e.CLOSE_PICKER=1]=`CLOSE_PICKER`,e[e.REFRESH_PICKER=2]=`REFRESH_PICKER`,e[e.REMOVE_ITEM=3]=`REMOVE_ITEM`})(J5||={});function U6n(e){let t=e;return Array.isArray(t.items)}function W6n(e){let t=e;return!!t.picks&&t.additionalPicks instanceof Promise}var G6n=class extends G{constructor(e,t){super(),this.prefix=e,this.options=t}provide(e,t,n){let r=new W;e.canAcceptInBackground=!!this.options?.canAcceptInBackground,e.matchOnLabel=e.matchOnDescription=e.matchOnDetail=e.sortByLabel=!1;let i,a=r.add(new KP),o=async()=>{i?.dispose(!0),e.busy=!1;let r=a.value=new W;i=r.add(new FF(t));let o=i.token,s=e.value.substring(this.prefix.length);this.options?.shouldSkipTrimPickFilter||(s=s.trim());let c=this._getPicks(s,r,o,n),l=(t,n)=>{let r,i;if(U6n(t)?(r=t.items,i=t.active):r=t,r.length===0){if(n)return!1;(s.length>0||e.hideInput)&&this.options?.noResultsPick&&(r=vP(this.options.noResultsPick)?[this.options.noResultsPick(s)]:[this.options.noResultsPick])}return e.items=r,i&&(e.activeItems=[i]),!0},u=async t=>{let n=!1,r=!1;await Promise.all([(async()=>{typeof t.mergeDelay==`number`&&(await LL(t.mergeDelay),o.isCancellationRequested)||r||(n=l(t.picks,!0))})(),(async()=>{e.busy=!0;try{let r=await t.additionalPicks;if(o.isCancellationRequested)return;let i,a;U6n(t.picks)?(i=t.picks.items,a=t.picks.active):i=t.picks;let s,c;if(U6n(r)?(s=r.items,c=r.active):s=r,s.length>0||!n){let t;if(!a&&!c){let n=e.activeItems[0];n&&i.indexOf(n)!==-1&&(t=n)}l({items:[...i,...s],active:a||c||t})}}finally{o.isCancellationRequested||(e.busy=!1),r=!0}})()])};if(c!==null){if(W6n(c))await u(c);else if(!(c instanceof Promise))l(c);else{e.busy=!0;try{let e=await c;if(o.isCancellationRequested)return;W6n(e)?await u(e):l(e)}finally{o.isCancellationRequested||(e.busy=!1)}}}};r.add(e.onDidChangeValue(()=>o())),o(),r.add(e.onDidAccept(t=>{if(n?.handleAccept){t.inBackground||e.hide(),n.handleAccept?.(e.activeItems[0],t.inBackground);return}let[r]=e.selectedItems;typeof r?.accept==`function`&&(t.inBackground||e.hide(),r.accept(e.keyMods,t))}));let s=async(n,r)=>{if(typeof r.trigger!=`function`)return;let i=r.buttons?.indexOf(n)??-1;if(i>=0){let n=r.trigger(i,e.keyMods),a=typeof n==`number`?n:await n;if(t.isCancellationRequested)return;switch(a){case J5.NO_ACTION:break;case J5.CLOSE_PICKER:e.hide();break;case J5.REFRESH_PICKER:o();break;case J5.REMOVE_ITEM:{let t=e.items.indexOf(r);if(t!==-1){let n=e.items.slice(),r=n.splice(t,1),i=e.activeItems.filter(e=>e!==r[0]),a=e.keepScrollPosition;e.keepScrollPosition=!0,e.items=n,i&&(e.activeItems=i),e.keepScrollPosition=a}break}}}};return r.add(e.onDidTriggerItemButton(({button:e,item:t})=>s(e,t))),r.add(e.onDidTriggerSeparatorButton(({button:e,separator:t})=>s(e,t))),r}};new hB(1e4);var K6n=new hB(1e4);function q6n(e){return Y6n(e,`NFD`,K6n)}var J6n=/[^\u0000-\u0080]/;function Y6n(e,t,n){if(!e)return e;let r=n.get(e);if(r)return r;let i;return i=J6n.test(e)?e.normalize(t):e,n.set(e,i),i}var X6n=(function(){let e=/[\u0300-\u036f]/g;return function(t){return q6n(t).replace(e,``)}})(),Z6n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},Y5=function(e,t){return function(n,r){t(n,r,e)}},X5,Z5,Q6n=class extends G6n{static{X5=this}static{this.PREFIX=`>`}static{this.TFIDF_THRESHOLD=.5}static{this.TFIDF_MAX_RESULTS=5}static{this.WORD_FILTER=_X(vX,iyn,Gvn)}constructor(e,t,n,r,i,a){super(X5.PREFIX,e),this.keybindingService=n,this.commandService=r,this.telemetryService=i,this.dialogService=a,this.commandsHistory=this._register(t.createInstance($6n)),this.options=e}async _getPicks(e,t,n,r){let i=await this.getCommandPicks(n);if(n.isCancellationRequested)return[];let a=zP(()=>{let t=new V6n;return t.updateDocuments(i.map(e=>({key:e.commandId,textChunks:[this.getTfIdfChunk(e)]}))),H6n(t.calculateScores(e,n)).filter(e=>e.score>X5.TFIDF_THRESHOLD).slice(0,X5.TFIDF_MAX_RESULTS)}),o=this.normalizeForFiltering(e),s=[];for(let t of i){t.labelNoAccents??=this.normalizeForFiltering(t.label);let r=X5.WORD_FILTER(o,t.labelNoAccents)??void 0,i;if(t.commandAlias&&(t.aliasNoAccents??=this.normalizeForFiltering(t.commandAlias),i=X5.WORD_FILTER(o,t.aliasNoAccents)??void 0),r||i)t.highlights={label:r,detail:this.options.showAlias?i:void 0},s.push(t);else if(e===t.commandId)s.push(t);else if(e.length>=3){let e=a();if(n.isCancellationRequested)return[];let r=e.find(e=>e.key===t.commandId);r&&(t.tfIdfScore=r.score,s.push(t))}}let c=new Map;for(let e of s){let t=c.get(e.label);t?(e.description=e.commandId,t.description=t.commandId):c.set(e.label,e)}s.sort((e,t)=>{if(e.tfIdfScore&&t.tfIdfScore)return e.tfIdfScore===t.tfIdfScore?e.label.localeCompare(t.label):t.tfIdfScore-e.tfIdfScore;if(e.tfIdfScore)return 1;if(t.tfIdfScore)return-1;let n=this.commandsHistory.peek(e.commandId),r=this.commandsHistory.peek(t.commandId);if(n&&r)return n>r?-1:1;if(n)return-1;if(r)return 1;if(this.options.suggestedCommandIds){let n=this.options.suggestedCommandIds.has(e.commandId),r=this.options.suggestedCommandIds.has(t.commandId);if(n&&r)return 0;if(n)return-1;if(r)return 1}let i=e.commandCategory===u4n.Developer.value,a=t.commandCategory===u4n.Developer.value;return i&&!a?1:!i&&a?-1:e.label.localeCompare(t.label)});let l=[],u=!1,d=!0,f=!!this.options.suggestedCommandIds;for(let e=0;e<s.length;e++){let t=s[e];e===0&&this.commandsHistory.peek(t.commandId)&&(l.push({type:`separator`,label:H(1740,`recently used`)}),u=!0),d&&t.tfIdfScore!==void 0&&(l.push({type:`separator`,label:H(1741,`similar commands`)}),d=!1),f&&t.tfIdfScore===void 0&&!this.commandsHistory.peek(t.commandId)&&this.options.suggestedCommandIds?.has(t.commandId)&&(l.push({type:`separator`,label:H(1742,`commonly used`)}),u=!0,f=!1),u&&t.tfIdfScore===void 0&&!this.commandsHistory.peek(t.commandId)&&!this.options.suggestedCommandIds?.has(t.commandId)&&(l.push({type:`separator`,label:H(1743,`other commands`)}),u=!1),l.push(this.toCommandPick(t,r))}return this.hasAdditionalCommandPicks(e,n)?{picks:l,additionalPicks:(async()=>{let t=await this.getAdditionalCommandPicks(i,s,e,n);if(n.isCancellationRequested)return[];let a=t.map(e=>this.toCommandPick(e,r));return d&&a[0]?.type!==`separator`&&a.unshift({type:`separator`,label:H(1744,`similar commands`)}),a})()}:l}toCommandPick(e,t){if(e.type===`separator`)return e;let n=this.keybindingService.lookupKeybinding(e.commandId),r=n?H(1745,`{0}, {1}`,e.label,n.getAriaLabel()):e.label;return{...e,ariaLabel:r,detail:this.options.showAlias&&e.commandAlias!==e.label?e.commandAlias:void 0,keybinding:n,accept:async()=>{this.commandsHistory.push(e.commandId),this.telemetryService.publicLog2(`workbenchActionExecuted`,{id:e.commandId,from:t?.from??`quick open`});try{e.args?.length?await this.commandService.executeCommand(e.commandId,...e.args):await this.commandService.executeCommand(e.commandId)}catch(t){tP(t)||this.dialogService.error(H(1746,`Command '{0}' resulted in an error`,e.label),L2(t))}}}}getTfIdfChunk({label:e,commandAlias:t,commandDescription:n}){let r=e;return t&&t!==e&&(r+=` - ${t}`),n&&n.value!==e&&(r+=` - ${n.value===n.original?n.value:`${n.value} (${n.original})`}`),r}normalizeForFiltering(e){let t=X6n(e);return t.length===e.length?t:(this.telemetryService.publicLog2(`QuickAccess:FilterLengthMismatch`,{originalLength:e.length,normalizedLength:t.length}),e)}};Q6n=X5=Z6n([Y5(1,kz),Y5(2,UK),Y5(3,Bz),Y5(4,pB),Y5(5,PY)],Q6n);var $6n=class extends G{static{Z5=this}static{this.DEFAULT_COMMANDS_HISTORY_LENGTH=50}static{this.PREF_KEY_CACHE=`commandPalette.mru.cache`}static{this.PREF_KEY_COUNTER=`commandPalette.mru.counter`}static{this.counter=1}static{this.hasChanges=!1}constructor(e,t,n){super(),this.storageService=e,this.configurationService=t,this.logService=n,this.configuredCommandsHistoryLength=0,this.updateConfiguration(),this.load(),this.registerListeners()}registerListeners(){this._register(this.configurationService.onDidChangeConfiguration(e=>this.updateConfiguration(e))),this._register(this.storageService.onWillSaveState(e=>{e.reason===xQ.SHUTDOWN&&this.saveState()}))}updateConfiguration(e){(!e||e.affectsConfiguration(`workbench.commandPalette.history`))&&(this.configuredCommandsHistoryLength=Z5.getConfiguredCommandHistoryLength(this.configurationService),Z5.cache&&Z5.cache.limit!==this.configuredCommandsHistoryLength&&(Z5.cache.limit=this.configuredCommandsHistoryLength,Z5.hasChanges=!0))}load(){let e=this.storageService.get(Z5.PREF_KEY_CACHE,0),t;if(e)try{t=JSON.parse(e)}catch(e){this.logService.error(`[CommandsHistory] invalid data: ${e}`)}let n=Z5.cache=new hB(this.configuredCommandsHistoryLength,1);if(t){let e;e=t.usesLRU?t.entries:t.entries.sort((e,t)=>e.value-t.value),e.forEach(e=>n.set(e.key,e.value))}Z5.counter=this.storageService.getNumber(Z5.PREF_KEY_COUNTER,0,Z5.counter)}push(e){Z5.cache&&(Z5.cache.set(e,Z5.counter++),Z5.hasChanges=!0)}peek(e){return Z5.cache?.peek(e)}saveState(){if(!Z5.cache||!Z5.hasChanges)return;let e={usesLRU:!0,entries:[]};Z5.cache.forEach((t,n)=>e.entries.push({key:n,value:t})),this.storageService.store(Z5.PREF_KEY_CACHE,JSON.stringify(e),0,0),this.storageService.store(Z5.PREF_KEY_COUNTER,Z5.counter,0,0),Z5.hasChanges=!1}static getConfiguredCommandHistoryLength(e){let t=e.getValue().workbench?.commandPalette?.history;return typeof t==`number`?t:Z5.DEFAULT_COMMANDS_HISTORY_LENGTH}};$6n=Z5=Z6n([Y5(0,bQ),Y5(1,ZB),Y5(2,wB)],$6n);var e8n=class extends Q6n{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a)}getCodeEditorCommandPicks(){let e=this.activeTextEditorControl;if(!e)return[];let t=[];for(let n of e.getSupportedActions()){let e;n.metadata?.description&&(e=$wn(n.metadata.description)?n.metadata.description:{original:n.metadata.description,value:n.metadata.description}),t.push({commandId:n.id,commandAlias:n.alias,commandDescription:e,label:VX(n.label)||n.id})}return t}},t8n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},Q5=function(e,t){return function(n,r){t(n,r,e)}},$5=class extends e8n{get activeTextEditorControl(){return this.codeEditorService.getFocusedCodeEditor()??void 0}constructor(e,t,n,r,i,a){super({showAlias:!1},e,n,r,i,a),this.codeEditorService=t}async getCommandPicks(){return this.getCodeEditorCommandPicks()}hasAdditionalCommandPicks(){return!1}async getAdditionalCommandPicks(){return[]}};$5=t8n([Q5(0,kz),Q5(1,jz),Q5(2,UK),Q5(3,Bz),Q5(4,pB),Q5(5,PY)],$5);var n8n=class e extends kB{static{this.ID=`editor.action.quickCommand`}constructor(){super({id:e.ID,label:PCn.quickCommandActionLabel,alias:`Command Palette`,precondition:void 0,kbOpts:{kbExpr:$.focus,primary:59,weight:100},contextMenuOpts:{group:`z_commands`,order:1}})}run(e){e.get(_Q).quickAccess.show($5.PREFIX)}};PB(n8n),tB.as(L$.Quickaccess).registerQuickAccessProvider({ctor:$5,prefix:$5.PREFIX,helpEntries:[{description:PCn.quickCommandHelp,commandId:n8n.ID}]});var r8n=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},e7=function(e,t){return function(n,r){t(n,r,e)}},i8n=class extends f3{constructor(e,t,n,r,i,a,o){super(!0,e,t,n,r,i,a,o)}};i8n=r8n([e7(1,$z),e7(2,jz),e7(3,MK),e7(4,kz),e7(5,bQ),e7(6,ZB)],i8n),IB(f3.ID,i8n,4),PB(class extends kB{constructor(){super({id:`editor.action.toggleHighContrast`,label:ICn.toggleHighContrast,alias:`Toggle High Contrast Theme`,precondition:void 0}),this._originalThemeName=null}run(e,t){let n=e.get(l0),r=n.getColorTheme();vW(r.type)?(n.setTheme(this._originalThemeName||(yW(r.type)?`vs-dark`:`vs`)),this._originalThemeName=null):(n.setTheme(yW(r.type)?a0:o0),this._originalThemeName=r.themeName)}});var a8n={},o8n={},s8n=class e{static getOrCreate(t){return o8n[t]||(o8n[t]=new e(t)),o8n[t]}constructor(e){this._languageId=e,this._loadingTriggered=!1,this._lazyLoadPromise=new Promise((e,t)=>{this._lazyLoadPromiseResolve=e,this._lazyLoadPromiseReject=t})}load(){return this._loadingTriggered||(this._loadingTriggered=!0,a8n[this._languageId].loader().then(e=>this._lazyLoadPromiseResolve(e),e=>this._lazyLoadPromiseReject(e))),this._lazyLoadPromise}};function c8n(e){let t=e.id;a8n[t]=e,m2.register(e);let n=s8n.getOrCreate(t);m2.registerTokensProviderFactory(t,{create:async()=>(await n.load()).language}),m2.onLanguageEncountered(t,async()=>{let e=await n.load();m2.setLanguageConfiguration(t,e.conf)})}c8n({id:`markdown`,extensions:[`.md`,`.markdown`,`.mdown`,`.mkdn`,`.mkd`,`.mdwn`,`.mdtxt`,`.mdtext`],aliases:[`Markdown`,`markdown`],loader:()=>I(()=>import(`./markdown-Cimd5fb3.js`),[])});function l8n(e){return new Worker(`/assets/editor.worker-O-CH8JUO.js`,{name:e?.name})}self.MonacoEnvironment={getWorker:()=>new l8n},P$t.config({monaco:$In});function u8n({value:e,onChange:t,disabled:n=!1}){return(0,z.jsx)(Z$t,{height:`100%`,language:`markdown`,theme:`vs-dark`,value:e,loading:(0,z.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading editor…`}),options:{ariaLabel:`Context markdown editor`,tabFocusMode:!0,minimap:{enabled:!1},wordWrap:`on`,lineNumbers:`on`,readOnly:n,scrollBeyondLastLine:!1,fontSize:13,padding:{top:16,bottom:16},automaticLayout:!0},onChange:e=>t(e??``)})}var d8n=class extends Error{status;body;constructor(e,t,n){super(e),this.status=t,this.body=n,this.name=`ContextApiError`}},f8n={layers:[`context`,`layers`]};async function p8n(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function m8n(e,t){if(t&&typeof t==`object`){let e=t;if(typeof e.error==`string`)return e.error;if(typeof e.message==`string`)return e.message}return typeof t==`string`&&t.trim()?t:`Context API request failed with status ${e}`}async function t7(e,t){let n={Accept:`application/json`};t.body!==void 0&&(n[`Content-Type`]=`application/json`);let r=await fetch(e,{method:t.method,credentials:`include`,headers:n,body:t.body===void 0?void 0:JSON.stringify(t.body)}),i=await p8n(r);if(!r.ok)throw new d8n(m8n(r.status,i),r.status,i);return i}function h8n(){return t7(`/api/context/layers`,{method:`GET`})}function g8n(e){return t7(`/api/context/preview`,{method:`POST`,body:e})}function _8n(e){return t7(`/api/context/layers`,{method:`PUT`,body:e})}function v8n(e={operation:`sync`}){return t7(`/api/context/sync`,{method:`POST`,body:e})}function y8n(){return F({queryKey:f8n.layers,queryFn:h8n})}function b8n(){return Cn({mutationFn:g8n})}function x8n(){let e=$t();return Cn({mutationFn:_8n,onSuccess:()=>{e.invalidateQueries({queryKey:f8n.layers})}})}function S8n(){let e=$t();return Cn({mutationFn:v8n,onSuccess:()=>{e.invalidateQueries({queryKey:f8n.layers})}})}var C8n={global:`Every project on this machine`,project:`One project, including its workspaces`,workspace:`One issue workspace`},w8n=[[`claude-code`,`Claude Code`],[`codex`,`Codex`],[`ohmypi`,`oh-my-pi`],[`kimi-code`,`Kimi Code`],[`acp`,`ACP`],[`muse`,`Muse`],[`opencode`,`OpenCode`],[`prime-agent`,`Prime Agent`],[`fullPrompt`,`All harnesses`]];function n7(e){switch(e.kind){case`global`:return`global`;case`project`:return`project:${e.projectKey}`;case`workspace`:return`workspace:${e.projectKey}:${e.workspacePath}`}}function T8n(e){switch(e.kind){case`global`:return{kind:`global`};case`project`:return{kind:`project`,projectKey:e.projectKey};case`workspace`:return{kind:`workspace`,projectKey:e.projectKey,workspacePath:e.workspacePath}}}function E8n(e){switch(e.kind){case`global`:return`~/.overdeck/context/global.md`;case`project`:return e.file.includes(`/.pan/`)?`.pan/context/project.md`:`.overdeck/context/project.md`;case`workspace`:return e.file.includes(`/.pan/`)?`.pan/context/workspace.md`:`.overdeck/context/workspace.md`}}function D8n(e){switch(e){case`global`:return`Machine context`;case`project`:return`Project context`;case`workspace`:return`Workspace context`}}function r7(e){return e instanceof Error?e.message:String(e||`Unknown error`)}function O8n({error:e}){return(0,z.jsx)(`div`,{className:`h-full w-full p-6`,children:(0,z.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load context layers: `,r7(e)]})})}function k8n(e){let t=e.layer?n7(e.layer):`preview`;return`${e.level.toUpperCase()} · ${t}: ${e.message}`}function A8n(){let{data:e,isLoading:t,error:n,refetch:r}=y8n(),i=b8n(),a=x8n(),o=S8n(),s=i.mutateAsync,[c,l]=(0,L.useState)(`global`),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)({}),[g,_]=(0,L.useState)(`edit`),[v,y]=(0,L.useState)(`claude-code`),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),[w,T]=(0,L.useState)(null),E=(0,L.useMemo)(()=>e?.workspaces.filter(e=>e.projectKey===u)??[],[e?.workspaces,u]);(0,L.useEffect)(()=>{if(!e)return;let t=e.projects[0]?.projectKey??``;d(n=>e.projects.some(e=>e.projectKey===n)?n:t)},[e]),(0,L.useEffect)(()=>{if(!e)return;let t=E.some(e=>e.path===f);p(t?f:E[0]?.path??``)},[e,E,f]);let D=(0,L.useMemo)(()=>c===`global`?{kind:`global`}:u?c===`project`?{kind:`project`,projectKey:u}:f?{kind:`workspace`,projectKey:u,workspacePath:f}:null:null,[c,u,f]),O=(0,L.useMemo)(()=>{if(!e||!D)return null;let t=n7(D);return e.layers.find(e=>n7(T8n(e))===t)??null},[e,D]),k=(0,L.useMemo)(()=>e?e.layers.flatMap(e=>{let t=T8n(e),n=m[n7(t)];return n===void 0?[]:[{target:t,content:n}]}):[],[e,m]),A=D?n7(D):``,j=O?m[A]??O.content:``,ee=e?.projects.find(e=>e.projectKey===u)??null,M=e?.workspaces.find(e=>e.path===f)??null,N=!!O&&m[A]!==void 0&&m[A]!==O.content,P=a.isPending||o.isPending;(0,L.useEffect)(()=>{if(!D||!O){x(null);return}let e=!1;C(null),x(null);let t=window.setTimeout(()=>{s({operation:`preview`,selectedLayer:D,drafts:k}).then(t=>{e||x(t)}).catch(t=>{e||C(r7(t))})},300);return()=>{e=!0,window.clearTimeout(t)}},[k,s,O,D]);async function te(e){if(D&&O){T(null);try{await a.mutateAsync({operation:`save`,target:D,content:j}),e&&await o.mutateAsync({operation:`sync`}),await r(),h(e=>{let{[A]:t,...n}=e;return n}),B.success(e?`Context saved and outputs refreshed. Applies to new sessions.`:`Context saved. Applies to new sessions.`)}catch(e){let t=r7(e);T(t),B.error(t)}}}if(t)return(0,z.jsx)(`div`,{className:`h-full w-full p-6 text-sm text-muted-foreground`,children:`Loading context layers…`});if(n)return(0,z.jsx)(O8n,{error:n});let ne=b?.previews[v]??``,re=b?.diagnostics??[];return(0,z.jsxs)(`div`,{className:`context-page h-full w-full min-w-0 overflow-auto bg-background text-foreground`,children:[(0,z.jsxs)(`header`,{className:`border-b border-border px-5 py-4`,children:[(0,z.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Agent context`}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Choose where instructions apply, edit their source, and preview what Overdeck adds to a new session.`}),(0,z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Running conversations keep their existing context. Your CLAUDE.md and AGENTS.md files stay under your control.`})]}),(0,z.jsxs)(`div`,{className:`context-layout`,children:[(0,z.jsxs)(`aside`,{className:`context-sources border-border bg-card/30 p-4`,children:[(0,z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,z.jsx)(`legend`,{className:`mb-2 text-sm font-semibold`,children:`Where should this apply?`}),[`global`,`project`,`workspace`].map(e=>(0,z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md p-2 text-sm hover:bg-muted ${c===e?`bg-accent text-accent-foreground`:``}`,children:[(0,z.jsx)(`input`,{className:`mt-1`,type:`radio`,name:`context-layer-kind`,value:e,"aria-label":D8n(e),checked:c===e,onChange:()=>l(e)}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`block font-medium`,children:D8n(e)}),(0,z.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-muted-foreground`,children:C8n[e]})]})]},e))]}),c!==`global`&&(0,z.jsxs)(`label`,{className:`mt-4 block text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Project`}),(0,z.jsx)(`select`,{className:`mt-1 w-full rounded-md border border-border bg-background px-2 py-2`,value:u,onChange:e=>d(e.target.value),disabled:!e?.projects.length,children:e?.projects.length?e.projects.map(e=>(0,z.jsx)(`option`,{value:e.projectKey,children:e.name},e.projectKey)):(0,z.jsx)(`option`,{value:``,children:`No registered projects`})})]}),c===`workspace`&&(0,z.jsxs)(`label`,{className:`mt-4 block text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Workspace`}),(0,z.jsx)(`select`,{className:`mt-1 w-full rounded-md border border-border bg-background px-2 py-2`,value:f,onChange:e=>p(e.target.value),disabled:!E.length,children:E.length?E.map(e=>(0,z.jsx)(`option`,{value:e.path,children:e.issueId??e.name},e.path)):(0,z.jsx)(`option`,{value:``,children:`No workspaces for this project`})})]}),(0,z.jsxs)(`div`,{className:`mt-5 border-t border-border pt-4 text-xs leading-5 text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:c===`global`?`Keep machine context specific`:c===`project`?`Shared project guidance`:`Generated workspace context`}),(0,z.jsx)(`p`,{className:`mt-1`,children:c===`global`?`Use this for local paths or machine quirks. Rules for every machine belong in bundled rules.`:c===`project`?`Use this for project conventions and requirements. Commit the source file to share it with your team.`:`Overdeck assembles this from issue metadata, memory, and status. It may not exist until a workspace is created.`})]}),(0,z.jsxs)(`details`,{className:`mt-5 border-t border-border pt-4 text-xs leading-5 text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground`,children:`Other instruction sources`}),(0,z.jsx)(`p`,{className:`mt-2`,children:`The preview combines your selected scope with applicable machine context and bundled rules. Project and workspace sources join it when selected.`}),(0,z.jsxs)(`p`,{className:`mt-2`,children:[`Bundled rules live in `,(0,z.jsx)(`code`,{className:`break-all`,children:`sync-sources/rules/`}),`. Each rule in the preview names its source.`]}),(0,z.jsx)(`p`,{className:`mt-2`,children:`Role instructions and the session briefing can add launch context. The harness also loads its own user, project, and organization instructions, memory, and skills. These are not editable here.`})]}),(0,z.jsxs)(`details`,{className:`mt-4 border-t border-border pt-4 text-xs leading-5 text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer font-medium text-foreground`,children:`Generated output files`}),(0,z.jsx)(`p`,{className:`mt-2`,children:`Overdeck passes context at launch. Refresh updates its saved global outputs; it does not rewrite native instruction files or update running conversations.`}),(0,z.jsx)(`ul`,{className:`mt-3 space-y-3`,children:e?.targets.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:e.label}),(0,z.jsx)(`code`,{className:`block break-all`,children:e.path}),(0,z.jsx)(`p`,{children:e.deliveryChannel===`codex-developer-instructions`?`Added as developer instructions.`:`Appended to the session’s system prompt.`}),(0,z.jsx)(`p`,{children:e.exists?`${e.byteCount.toLocaleString()} bytes`:`Created on next refresh.`})]},e.path))}),(0,z.jsx)(`button`,{type:`button`,className:`mt-3 rounded-md border border-border px-3 py-2 text-foreground disabled:opacity-50`,disabled:P||N,onClick:()=>{T(null),o.mutateAsync({operation:`sync`}).then(()=>r()).then(()=>B.success(`Outputs refreshed. Applies to new sessions.`)).catch(e=>T(r7(e)))},children:`Refresh outputs`}),N&&(0,z.jsx)(`p`,{className:`mt-1`,children:`Save your changes before refreshing outputs.`})]})]}),(0,z.jsxs)(`section`,{className:`context-workbench flex min-w-0 flex-col`,children:[(0,z.jsxs)(`header`,{className:`border-b border-border px-5 py-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-base font-semibold`,children:D8n(c)}),O&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:N?`Edited`:`Loaded`})]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:c===`global`?C8n.global:c===`project`?ee?.name??`No project selected`:M?.issueId??M?.name??`No workspace selected`}),O&&(0,z.jsxs)(`details`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer break-all font-mono`,children:E8n(O)}),(0,z.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:O.file}),(0,z.jsx)(`p`,{className:`mt-1`,children:O.exists?`File exists`:`File has not been created yet`})]}),(0,z.jsx)(`div`,{className:`mt-4 flex gap-2`,role:`group`,"aria-label":`Context view`,children:[`edit`,`preview`].map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":g===e,onClick:()=>_(e),className:`rounded-md px-3 py-2 text-sm font-medium ${g===e?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-muted`}`,children:e===`edit`?`Edit source`:`Preview for agent`},e))})]}),(0,z.jsx)(`div`,{className:`context-editor flex-1`,hidden:g!==`edit`,children:O?(0,z.jsx)(u8n,{value:j,disabled:P,onChange:e=>h(t=>({...t,[A]:e}))}):(0,z.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:c===`workspace`?`Create a workspace for this project to edit its context.`:`Register a project in Projects to add project context.`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,hidden:g!==`preview`,children:[(0,z.jsxs)(`div`,{className:`border-b border-border px-5 py-4`,children:[(0,z.jsxs)(`label`,{className:`flex flex-wrap items-center gap-3 text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Preview for`}),(0,z.jsx)(`select`,{className:`rounded-md border border-border bg-background px-3 py-2`,"aria-label":`Preview for`,value:v,onChange:e=>y(e.target.value),children:w8n.map(([e,t])=>(0,z.jsx)(`option`,{value:e,children:t},e))})]}),(0,z.jsxs)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:[N?`Includes your unsaved edits. `:``,`This previews Overdeck’s context layers. It is not a transcript or a complete view of the harness’s system prompt.`]})]}),(0,z.jsx)(`div`,{className:`p-5`,"aria-live":`polite`,children:S?(0,z.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not render preview: `,S,`. Edit the source to try again.`]}):ne?(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-6`,children:ne}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:O?`Rendering preview…`:`Select an available source to preview its context.`})})]}),(0,z.jsx)(`div`,{className:`border-t border-border px-5 py-3 text-xs`,"aria-live":`polite`,children:re.length>0?(0,z.jsx)(`ul`,{className:`space-y-2`,children:re.map((e,t)=>(0,z.jsx)(`li`,{className:e.level===`error`?`text-destructive`:`text-warning-foreground`,children:k8n(e)},`${e.message}-${t}`))}):(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:b?`No validation issues.`:O?`Validation updates with the preview.`:`No source selected.`})}),(0,z.jsxs)(`footer`,{className:`sticky bottom-0 flex flex-wrap items-center justify-between gap-3 border-t border-border bg-background px-5 py-3`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:w?(0,z.jsx)(`span`,{role:`alert`,className:`text-destructive`,children:w}):N?`Unsaved changes`:`No unsaved changes`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-2 text-sm disabled:opacity-50`,disabled:!N||P||!O,onClick:()=>void te(!1),children:a.isPending&&!o.isPending?`Saving…`:`Save`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50`,disabled:!N||P||!O,onClick:()=>void te(!0),children:o.isPending?`Refreshing…`:`Save & refresh outputs`})]})]})]})]})]})}var j8n=!1,M8n=5e3;function N8n(e=j8n){return e?`Browse, search, and edit this project knowledge bundle.`:`View and search here; edit knowledge through /okf author so changes stay PR-gated.`}async function P8n(e){let t=await fetch(`/api/knowledge-viewer/status?project=${encodeURIComponent(e)}`,{credentials:`include`}),n=await t.json();if(!t.ok)throw Error(n.error||`Knowledge viewer status could not be loaded`);return n}async function F8n(e,t){let n=await fetch(`/api/knowledge-viewer/${e}`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({project:t})}),r=await n.json();if(!n.ok)throw Error(r.error||`Knowledge viewer ${e} failed`);return r}function I8n({projectKey:e}){let t=$t(),n=(0,L.useRef)(null),r=(0,L.useRef)(null),[i,a]=(0,L.useState)(`loading`),o=F({queryKey:[`command-deck-projects`],queryFn:Ou,enabled:!e,staleTime:3e4}),s=(0,L.useMemo)(()=>e??o.data?.[0]?.key??null,[e,o.data]),c=F({queryKey:[`knowledge-viewer-status`,s],queryFn:()=>P8n(s),enabled:!!s,refetchInterval:2e3}),l=Cn({mutationFn:()=>F8n(`install`,s),onSuccess:async()=>{n.current=null,await t.invalidateQueries({queryKey:[`knowledge-viewer-status`,s]})}}),u=Cn({mutationFn:()=>F8n(`start`,s),onSuccess:e=>{t.setQueryData([`knowledge-viewer-status`,s],e)}}),d=c.data;(0,L.useEffect)(()=>{if(!s){r.current=null;return}if(d?.running){n.current=null,r.current=s;return}r.current===s&&(n.current=null,r.current=null)},[s,d?.running]),(0,L.useEffect)(()=>{s&&d?.bundleConfigured&&d.installed&&!d.running&&!d.starting&&(n.current===s||u.isPending||(n.current=s,u.mutate()))},[s,u,d]),(0,L.useEffect)(()=>{if(a(`loading`),!d?.running)return;if(d.embeddable===!1||!d.proxyUrl){a(`blocked`);return}let e=window.setTimeout(()=>a(`blocked`),M8n);return()=>window.clearTimeout(e)},[s,d?.embeddable,d?.proxyUrl,d?.running]);let f=(0,L.useCallback)(()=>a(`ready`),[]),p=(0,L.useCallback)(()=>{n.current=s,u.reset(),u.mutate()},[s,u]),m=o.isLoading||!!s&&c.isLoading,h=o.error??c.error??l.error??u.error,g=d?.starting||u.isPending,_=d?.running&&(d.embeddable===!1||!d.proxyUrl||i===`blocked`);return(0,z.jsx)(`main`,{className:`h-full overflow-y-auto bg-background p-6`,"data-testid":`knowledge-page`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6`,children:[(0,z.jsxs)(`header`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(co,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),(0,z.jsx)(`h1`,{className:`text-xl font-medium text-foreground`,children:`Knowledge`})]}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:N8n()})]}),m&&(0,z.jsx)(L8n,{title:`Loading knowledge configuration`}),!m&&!s&&(0,z.jsx)(R8n,{title:`No project is available`,description:`Register a project before opening its knowledge bundle.`}),!m&&h&&(0,z.jsx)(`section`,{className:`rounded-lg bg-card p-6`,role:`alert`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(go,{className:`mt-0.5 h-5 w-5 text-destructive`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Knowledge viewer unavailable`}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:h.message}),d?.bundleConfigured&&d.installed&&(0,z.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 text-sm font-medium text-primary hover:underline`,children:`Retry viewer`})]})]})}),!m&&!h&&d&&!d.bundleConfigured&&(0,z.jsx)(R8n,{title:`No knowledge bundle configured`,description:`Create or connect the project knowledge bundle, then return here.`,command:`/okf init`}),!m&&!h&&d?.bundleConfigured&&!d.installed&&(0,z.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Install the local knowledge viewer`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`OpenKnowledge is installed only after this explicit request. It runs as a separate local program.`}),d.message&&(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl font-mono text-xs text-muted-foreground`,children:d.message}),d.setupPlan?.steps.length?(0,z.jsx)(`ol`,{className:`mt-4 max-w-2xl list-decimal space-y-2 pl-5 text-sm text-muted-foreground`,"data-testid":`knowledge-setup-plan`,children:d.setupPlan.steps.map(e=>(0,z.jsx)(`li`,{children:e},e))}):null,(0,z.jsxs)(`button`,{type:`button`,onClick:()=>l.mutate(),disabled:l.isPending,className:`mt-5 inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-opacity disabled:opacity-50`,children:[l.isPending?(0,z.jsx)(is,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}):(0,z.jsx)(jo,{className:`h-4 w-4`,"aria-hidden":`true`}),l.isPending?`Setting up the viewer`:`Set up the viewer`]})]}),!m&&!h&&d?.bundleConfigured&&d.installed&&g&&(0,z.jsx)(L8n,{title:`Starting knowledge viewer`}),!m&&!h&&d?.bundleConfigured&&d.installed&&!d.running&&!g&&n.current===s&&(0,z.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,"data-testid":`knowledge-viewer-stopped`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Knowledge viewer stopped`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`The local viewer exited before it could reconnect. Restart the read-only snapshot to continue browsing.`}),(0,z.jsx)(`button`,{type:`button`,onClick:p,className:`mt-4 text-sm font-medium text-primary hover:underline`,children:`Restart viewer`})]}),!m&&!h&&_&&(0,z.jsx)(`section`,{className:`rounded-lg bg-card p-6`,"data-testid":`knowledge-viewer-blocked`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(go,{className:`mt-0.5 h-5 w-5 text-warning`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Viewer opens in a separate tab`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm text-muted-foreground`,children:`The local viewer refused dashboard framing. Open its disposable read-only snapshot directly to browse and search.`}),d.url&&(0,z.jsx)(`a`,{href:d.url,target:`_blank`,rel:`noreferrer`,className:`mt-4 inline-flex text-sm font-medium text-primary hover:underline`,children:`Open viewer`})]})]})}),!m&&!h&&d?.running&&d.proxyUrl&&!_&&(0,z.jsxs)(`section`,{className:`relative flex min-h-[70vh] flex-col overflow-hidden rounded-lg bg-card`,"data-testid":`knowledge-viewer-embedded`,children:[(0,z.jsx)(`div`,{className:`border-b border-border px-4 py-3`,children:(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Read-only snapshot — viewer edits are discarded. Use `,(0,z.jsx)(`span`,{className:`font-mono`,children:`/okf author`}),` for durable changes.`]})}),i===`loading`&&(0,z.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 top-11 z-10 flex items-center justify-center bg-card`,children:(0,z.jsx)(L8n,{title:`Loading knowledge workspace`})}),(0,z.jsx)(`iframe`,{title:`OpenKnowledge viewer`,src:d.proxyUrl,sandbox:`allow-downloads allow-forms allow-popups allow-same-origin allow-scripts`,onLoad:f,onError:()=>a(`blocked`),className:`min-h-[66vh] w-full flex-1 border-0 bg-background`})]})]})})}function L8n({title:e}){return(0,z.jsx)(`section`,{className:`rounded-lg bg-card p-6`,role:`status`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(is,{className:`h-5 w-5 animate-spin text-info`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`This usually takes a few seconds.`})]})]})})}function R8n({title:e,description:t,command:n}){return(0,z.jsxs)(`section`,{className:`rounded-lg bg-card p-6`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:t}),n&&(0,z.jsx)(`code`,{className:`mt-4 inline-block rounded-sm bg-muted px-2 py-1 font-mono text-xs text-foreground`,children:n})]})}function z8n({sessions:e,selectedId:t,onSelect:n,hasMore:r=!1,isLoadingMore:i=!1,onLoadMore:a}){let o=(0,L.useRef)(null),s=kv({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>36,overscan:12}),c=s.getVirtualItems();return(0,L.useEffect)(()=>{let t=c.at(-1);t&&r&&!i&&a&&t.index>=e.length-8&&a()},[r,i,a,e.length,c]),(0,z.jsxs)(`div`,{ref:o,className:`flex-1 overflow-auto`,role:`table`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_minmax(14rem,1fr)_8rem_4rem_5rem_7rem] gap-3 border-b border-border bg-background px-3 py-2 text-xs font-medium text-muted-foreground sticky top-0 z-10`,role:`row`,children:[(0,z.jsx)(`div`,{}),(0,z.jsx)(`div`,{children:`Session`}),(0,z.jsx)(`div`,{children:`Model`}),(0,z.jsx)(`div`,{className:`text-right`,children:`Msgs`}),(0,z.jsx)(`div`,{className:`text-right`,children:`Cost`}),(0,z.jsx)(`div`,{children:`Last Active`})]}),(0,z.jsx)(`div`,{style:{height:s.getTotalSize(),position:`relative`},children:c.map(r=>{let i=e[r.index];if(!i)return null;let a=`${i.source}:${i.id}`,o=a===t,s=i.workspacePath??i.jsonlPath??`Unknown session path`,c=s.split(`/`).slice(-2).join(`/`),l=i.conversationTitle??i.conversationName??c,u=i.summary??s;return(0,z.jsxs)(`div`,{role:`row`,"data-session-key":a,onClick:()=>n(o?null:a),className:`absolute left-0 right-0 grid cursor-pointer grid-cols-[1.25rem_minmax(14rem,1fr)_8rem_4rem_5rem_7rem] items-center gap-3 border-b border-border px-3 text-xs transition-colors ${o?`bg-primary/8 border-primary/32`:`hover:bg-card`}`,style:{height:r.size,transform:`translateY(${r.start}px)`},children:[(0,z.jsx)(`div`,{className:`text-center`,children:i.source===`managed-archived`?(0,z.jsx)(Ude,{className:`inline h-3 w-3 text-muted-foreground`}):i.overdeckManaged?(0,z.jsx)(Ss,{className:`inline h-3 w-3 text-primary`}):i.enrichmentLevel>0?(0,z.jsx)(_o,{className:`inline h-3 w-3 text-success`}):(0,z.jsx)(So,{className:`inline h-3 w-3 text-muted-foreground/50`})}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`truncate text-foreground`,title:`${l} — ${u}`,children:l}),u&&(0,z.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:u}),i.source===`managed-archived`?(0,z.jsxs)(`span`,{className:`shrink-0 rounded-sm border border-border bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[`Archived`,i.panIssueId?` · ${i.panIssueId}`:``]}):i.overdeckManaged&&(0,z.jsxs)(`span`,{className:`shrink-0 rounded-sm border border-primary/32 bg-primary/8 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[`Managed`,i.panIssueId?` · ${i.panIssueId}`:``]}),i.harness!==`claude-code`&&(0,z.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border bg-card px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:i.harness})]}),(0,z.jsx)(`div`,{className:`truncate text-muted-foreground`,children:i.primaryModel?i.primaryModel.split(`-`).slice(-2).join(`-`):`—`}),(0,z.jsx)(`div`,{className:`text-right font-mono text-muted-foreground`,children:i.messageCount}),(0,z.jsx)(`div`,{className:`text-right font-mono`,children:i.estimatedCost>0?(0,z.jsxs)(`span`,{className:`text-signal-cost-foreground`,children:[`$`,i.estimatedCost.toFixed(4)]}):(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`—`})}),(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:i.lastTs?B8n(i.lastTs):`—`})]},a)})}),i&&(0,z.jsx)(`div`,{className:`px-3 py-2 text-center text-xs text-muted-foreground`,children:`Loading more…`})]})}function B8n(e){try{let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/864e5);return r===0?`today`:r===1?`yesterday`:r<7?`${r}d ago`:r<30?`${Math.floor(r/7)}w ago`:t.toISOString().slice(0,10)}catch{return e}}async function V8n(e){let t=await fetch(`/api/conversations/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Failed to load conversation: ${t.status}`);return await t.json()}async function H8n(e){let t=await fetch(`/api/discovered-sessions/${e}/messages`);if(t.status===410)throw Error(`TRANSCRIPT_GONE`);if(!t.ok)throw Error(`Failed to load transcript: ${t.status}`);return await t.json()}function U8n(e){return e.conversationName?e.conversationName:e.source===`managed-archived`?String(e.id):e.conversationId??null}function W8n({session:e}){let{resolvedTheme:t}=_p(),n=U8n(e),r=F({queryKey:[`sessions-feed-conversation`,n],queryFn:()=>V8n(n),enabled:n!==null,refetchInterval:5e3}),i=F({queryKey:[`discovered-session-messages`,e.id],queryFn:()=>H8n(e.id),enabled:n===null});return n===null?i.isLoading&&i.data===void 0?(0,z.jsx)(i7,{children:`Loading transcript…`}):i.error instanceof Error&&i.error.message===`TRANSCRIPT_GONE`?(0,z.jsx)(i7,{children:`Transcript file no longer on disk.`}):i.isError||i.data===void 0?(0,z.jsx)(i7,{children:`Couldn’t load this transcript.`}):(0,z.jsx)(zv,{messages:i.data.messages,workLog:i.data.workLog??[],streaming:i.data.streaming??!1,proposedPlan:i.data.proposedPlan,compactBoundaries:i.data.compactBoundaries,resolvedTheme:t,conversationName:e.conversationName??void 0,cwd:e.workspacePath??void 0,issueId:e.panIssueId}):r.isLoading&&r.data===void 0?(0,z.jsx)(i7,{children:`Loading conversation…`}):r.isError||r.data===void 0?(0,z.jsx)(i7,{children:`Couldn’t load this conversation.`}):(0,z.jsx)(oE,{conversation:r.data,viewMode:`conversation`,embedded:!0})}function i7({children:e}){return(0,z.jsx)(`div`,{className:`flex h-full min-h-48 items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:e})}async function G8n(e,t){await Mc().request(n=>n[Ft.enrichSessions]({ids:[e],level:t.tier,confirmed:t.confirmed,...t.model?{model:t.model}:{}}))}async function K8n(e){await Mc().request(t=>t[Ft.embedSessions]({ids:[e]}))}async function q8n(e){if(!e)throw Error(`Archived conversation is missing its name`);let t=await fetch(`/api/conversations/${encodeURIComponent(e)}/unarchive`,{method:`POST`});if(!t.ok)throw Error(`Unarchive failed: ${t.status}`)}function J8n(e,t){let n=typeof e==`object`&&e&&`code`in e?String(e.code??``):``,r=/^COST_THRESHOLD:([^:]+):([^:]+):([^:]+)$/.exec(n);return r?{tier:t.tier,estimatedCost:Number(r[1]),threshold:Number(r[2]),sessionCount:Number(r[3]),model:t.model}:null}function Y8n(e){return{id:e.id,source:`discovered`,harness:e.harness??null,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,summaryDetailed:e.summaryDetailed??null,conversationId:e.conversationId??null,conversationName:e.conversationName??null,conversationTitle:e.conversationTitle??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function X8n(e){return Y8n(await Mc().request(t=>t[Ft.getDiscoveredSession]({id:e})))}function Z8n(e,t){return t?{...e,harness:t.harness??e.harness,jsonlPath:t.jsonlPath??e.jsonlPath,workspacePath:t.workspacePath??e.workspacePath,primaryModel:t.primaryModel??e.primaryModel,messageCount:t.messageCount||e.messageCount,firstTs:t.firstTs??e.firstTs,lastTs:t.lastTs??e.lastTs,estimatedCost:t.estimatedCost||e.estimatedCost,tokenInput:t.tokenInput||e.tokenInput,tokenOutput:t.tokenOutput||e.tokenOutput,toolsUsed:t.toolsUsed.length>0?t.toolsUsed:e.toolsUsed,filesTouched:t.filesTouched.length>0?t.filesTouched:e.filesTouched,tags:t.tags.length>0?t.tags:e.tags,summary:t.summary??e.summary,summaryDetailed:t.summaryDetailed??e.summaryDetailed,enrichmentLevel:t.enrichmentLevel||e.enrichmentLevel,enrichmentFailed:t.enrichmentFailed,panIssueId:t.panIssueId??e.panIssueId}:e}function Q8n({session:e,onClose:t}){let n=$t(),[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(``),s=e.source===`managed-archived`,c=s?e.discoveredId??null:e.id,l=Wt(t=>t.enrichProgressBySessionId[e.id]),{data:u}=F({queryKey:[`discovered-session`,c],queryFn:()=>X8n(c),staleTime:1/0,placeholderData:e,enabled:c!=null}),d=s?Z8n(e,u):u??e,f=d.conversationId??(s?String(d.id):null),p=()=>{n.invalidateQueries({queryKey:[`discovered-session`,e.id]}),n.invalidateQueries({queryKey:[`discovered-sessions`]}),n.invalidateQueries({queryKey:[`sessions-feed`]}),n.invalidateQueries({queryKey:[`sessions-feed-facets`]}),n.invalidateQueries({queryKey:[`discovered-sessions-search`]}),n.invalidateQueries({queryKey:[`discovered-sessions-stats`]})},m=Cn({mutationFn:t=>G8n(e.id,t),onSuccess:()=>{i(null),p()},onError:(e,t)=>{i(J8n(e,t))}}),h=Cn({mutationFn:()=>K8n(e.id),onSuccess:p}),g=Cn({mutationFn:()=>q8n(d.conversationName),onSuccess:()=>{n.invalidateQueries({queryKey:[`archived-conversations`]}),n.invalidateQueries({queryKey:[`sessions-feed`]}),n.invalidateQueries({queryKey:[`sessions-feed-facets`]}),n.invalidateQueries({queryKey:[`conversations`]})}}),_=(e,t)=>(0,z.jsxs)(`div`,{className:`flex gap-2 text-xs py-1 border-b border-border`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground w-28 shrink-0`,children:e}),(0,z.jsx)(`span`,{className:`text-foreground font-mono break-all`,children:t??`—`})]}),v=e=>{let t=a.trim();m.mutate({tier:e,...t?{model:t}:{}})};return(0,z.jsxs)(`div`,{className:`flex flex-col h-full border-l border-border bg-background`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[`Session #`,d.id]}),(0,z.jsx)(`span`,{className:d.overdeckManaged?`rounded border border-primary/32 bg-primary/8 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`:`rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,title:d.overdeckManaged?`Overdeck-managed session`:`Ad-hoc discovered session`,children:d.overdeckManaged?`Managed${d.panIssueId?` · ${d.panIssueId}`:``}`:`Ad-hoc`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f&&(0,z.jsx)(`button`,{onClick:()=>{f&&(window.history.pushState(null,``,qht(String(f))),window.dispatchEvent(new PopStateEvent(`popstate`)))},className:`rounded border border-border px-2 py-1 text-xs text-foreground transition-colors hover:border-border hover:bg-card`,children:`Open in Command Deck`}),(0,z.jsx)(`button`,{onClick:t,"aria-label":`Close session detail`,className:`text-muted-foreground/70 hover:text-foreground transition-colors`,children:(0,z.jsx)(Os,{className:`h-4 w-4`})})]})]}),(0,z.jsxs)(`details`,{open:!0,className:`shrink-0 border-b border-border`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground hover:text-foreground`,children:`Metadata and actions`}),(0,z.jsxs)(`div`,{className:`max-h-[38vh] overflow-auto px-3 py-2 space-y-4`,children:[d.summary&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Summary`}),(0,z.jsx)(`p`,{className:`text-xs text-foreground leading-relaxed`,children:d.summary})]}),d.summaryDetailed&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Detailed`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:d.summaryDetailed})]}),d.tags.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Tags`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.tags.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 bg-muted text-muted-foreground rounded text-[10px]`,children:e},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Metadata`}),_(`Workspace`,d.workspacePath),_(`Model`,d.primaryModel),_(`Messages`,d.messageCount),_(`Input tokens`,d.tokenInput.toLocaleString()),_(`Output tokens`,d.tokenOutput.toLocaleString()),_(`Est. cost`,d.estimatedCost>0?`$${d.estimatedCost.toFixed(6)}`:null),_(`First active`,d.firstTs?$8n(d.firstTs):null),_(`Last active`,d.lastTs?$8n(d.lastTs):null),s&&_(`Archived at`,d.archivedAt?$8n(d.archivedAt):null),d.panIssueId&&_(`Issue`,d.panIssueId),_(`Enrichment`,d.enrichmentLevel===0?`None`:`L${d.enrichmentLevel}`)]}),d.toolsUsed.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Tools Used`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.toolsUsed.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 bg-card text-muted-foreground rounded text-[10px] font-mono`,children:e},e))})]}),d.filesTouched.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`Files Touched`}),(0,z.jsx)(`div`,{className:`space-y-1 max-h-28 overflow-auto`,children:d.filesTouched.map(e=>(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-mono break-all`,children:e},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:`File`}),(0,z.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,z.jsx)(Mo,{className:`h-3 w-3 text-muted-foreground/70 mt-0.5 shrink-0`}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 font-mono break-all`,children:d.jsonlPath??`No JSONL path available`})]})]})]}),(0,z.jsx)(`div`,{className:`px-3 py-2 border-t border-border`,children:s?(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1.5`,children:`Archived conversation`}),(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70 mb-2`,children:`Restore this conversation to the active Command Deck list.`}),(0,z.jsx)(`button`,{onClick:()=>g.mutate(),disabled:g.isPending||g.isSuccess,className:`rounded bg-warning/12 px-2 py-1 text-xs text-warning-foreground transition-colors hover:bg-warning/16 disabled:opacity-50`,children:g.isPending?`Unarchiving…`:`Unarchive`}),g.isSuccess&&(0,z.jsx)(`div`,{className:`text-[10px] text-success mt-1`,children:`Conversation restored`}),g.isError&&(0,z.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:g.error instanceof Error?g.error.message:`Unarchive failed`})]}):(0,z.jsxs)(z.Fragment,{children:[d.enrichmentLevel<3&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1.5`,children:d.enrichmentFailed?`Enrichment failed — retry:`:`Enrich this session`}),(0,z.jsx)(`div`,{className:`text-[10px] text-warning-foreground/80 mb-1.5`,children:`Sends redacted conversation excerpts to the configured enrichment provider.`}),(0,z.jsxs)(`label`,{className:`mb-2 block text-[10px] text-muted-foreground`,children:[`Custom model`,(0,z.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`Use default provider model`,className:`mt-1 w-full rounded border border-border bg-card px-2 py-1 text-[10px] text-foreground placeholder:text-muted-foreground/70 focus:border-primary focus:outline-none`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d.enrichmentLevel<1&&(0,z.jsxs)(`button`,{onClick:()=>v(1),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(bs,{className:`h-3 w-3`}),`Quick (L1)`]}),d.enrichmentLevel<2&&(0,z.jsxs)(`button`,{onClick:()=>v(2),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(bs,{className:`h-3 w-3 text-muted-foreground`}),`Detailed (L2)`]}),(0,z.jsxs)(`button`,{onClick:()=>v(3),disabled:m.isPending,className:`flex items-center gap-1 px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(bs,{className:`h-3 w-3 text-muted-foreground`}),`Deep (L3)`]})]})]}),m.isPending&&(0,z.jsx)(`div`,{className:`text-[10px] text-primary mt-1`,children:`Enriching…`}),l&&(0,z.jsxs)(`div`,{className:l.success?`text-[10px] text-success mt-1`:`text-[10px] text-destructive mt-1`,children:[`L`,l.level,` `,l.success?`complete`:`failed: ${l.error??`unknown error`}`,` · `,l.model]}),r&&(0,z.jsxs)(`div`,{className:`mt-2 rounded border border-warning/32 bg-warning/8 p-2 text-[10px] text-warning-foreground`,children:[`Estimated cost $`,r.estimatedCost.toFixed(4),` exceeds threshold $`,r.threshold.toFixed(2),` for `,r.sessionCount,` session`,r.sessionCount===1?``:`s`,`.`,(0,z.jsx)(`button`,{onClick:()=>m.mutate({tier:r.tier,confirmed:!0,model:r.model}),disabled:m.isPending,className:`ml-2 rounded bg-warning/12 px-1.5 py-0.5 text-warning-foreground disabled:opacity-50`,children:`Confirm`})]}),m.isError&&!r&&(0,z.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:`Enrichment failed`}),(0,z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-border pt-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Semantic embedding`}),(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70`,children:`Generate or refresh this session's vector index.`})]}),(0,z.jsx)(`button`,{onClick:()=>h.mutate(),disabled:h.isPending,className:`px-2 py-1 bg-muted hover:bg-accent text-foreground rounded text-xs transition-colors disabled:opacity-50`,children:`Embed`})]}),h.isPending&&(0,z.jsx)(`div`,{className:`text-[10px] text-primary mt-1`,children:`Embedding…`}),h.isSuccess&&(0,z.jsx)(`div`,{className:`text-[10px] text-success mt-1`,children:`Embedding complete`}),h.isError&&(0,z.jsx)(`div`,{className:`text-[10px] text-destructive mt-1`,children:`Embedding failed`})]})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,z.jsx)(W8n,{session:d})})]})}function $8n(e){try{return new Date(e).toISOString().replace(`T`,` `).slice(0,16)}catch{return e}}function e5n({isScanning:e,onScan:t,lastResult:n,progress:r}){let i=e||r?.active===!0;return(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?.active?(0,z.jsxs)(`span`,{className:`text-[10px] text-primary font-mono`,children:[r.dirsProcessed,`/`,r.dirsTotal,` files · `,r.sessionsFound,` sessions · `,(r.elapsedMs/1e3).toFixed(1),`s`]}):n&&!i&&(0,z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,n.inserted,` ↑`,n.updated,` ·`,(n.durationMs/1e3).toFixed(1),`s`]}),(0,z.jsxs)(`button`,{onClick:t,disabled:i,className:`flex items-center gap-1.5 rounded px-3 py-1.5 bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 text-xs transition-colors`,children:[(0,z.jsx)(zt,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),i?`Scanning…`:`Scan`]})]})}var t5n=[{label:`All time`,value:``},{label:`Today`,value:`today`},{label:`Last 7 days`,value:`7d`},{label:`Last 30 days`,value:`30d`},{label:`Last 90 days`,value:`90d`}],n5n=[{label:`All`,value:`all`},{label:`Discovered`,value:`discovered`},{label:`Managed-archived`,value:`managed-archived`}];function r5n({filters:e,facets:t,onChange:n}){let r=t.harnesses.some(e=>e.value!==`claude-code`);return(0,z.jsxs)(`div`,{className:`w-48 shrink-0 border-r border-border bg-background p-3 overflow-auto`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:`Filters`}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Source`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n5n.map(t=>{let r=(e.source??`all`)===t.value;return(0,z.jsx)(`button`,{onClick:()=>n(`source`,t.value===`all`?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${r?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:t.label},t.value)})})]}),r&&(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Harness`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.harnesses.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`harness`,e.harness===t.value?void 0:t.value),className:`px-1.5 py-0.5 text-[10px] font-mono transition-colors ${e.harness===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Time range`}),(0,z.jsx)(`select`,{value:e.since??``,onChange:e=>n(`since`,e.target.value||void 0),className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,children:t5n.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:t.timeRanges.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`since`,e.since===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.since===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Workspace path`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-workspaces`,value:e.workspace??``,onChange:e=>n(`workspace`,e.target.value||void 0),placeholder:`e.g. /Projects/myapp`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,z.jsx)(`datalist`,{id:`conversation-workspaces`,children:t.workspaces.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Model`}),(0,z.jsxs)(`select`,{value:e.model??``,onChange:e=>n(`model`,e.target.value||void 0),className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,children:[(0,z.jsx)(`option`,{value:``,children:`All models`}),t.models.map(e=>(0,z.jsxs)(`option`,{value:e.value,children:[e.value,` (`,e.count,`)`]},e.value))]}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.models.slice(0,8).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`model`,e.model===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.model===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Tag`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-tags`,value:e.tag??``,onChange:e=>n(`tag`,e.target.value||void 0),placeholder:`e.g. bugfix`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,z.jsx)(`datalist`,{id:`conversation-tags`,children:t.tags.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tags.slice(0,12).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`tag`,e.tag===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tag===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`Tool`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-tools`,value:e.tool??``,onChange:e=>n(`tool`,e.target.value||void 0),placeholder:`e.g. Read`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,z.jsx)(`datalist`,{id:`conversation-tools`,children:t.tools.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tools.slice(0,12).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`tool`,e.tool===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tool===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`File touched`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-files`,value:e.file??``,onChange:e=>n(`file`,e.target.value||void 0),placeholder:`e.g. src/index.ts`,className:`w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`}),(0,z.jsx)(`datalist`,{id:`conversation-files`,children:t.files.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.files.slice(0,8).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`file`,e.file===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.file===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Workspace cost`}),(0,z.jsx)(`div`,{className:`space-y-1 max-h-24 overflow-auto`,children:t.workspaces.slice(0,8).map(e=>(0,z.jsxs)(`button`,{onClick:()=>n(`workspace`,e.value),className:`w-full text-left text-[10px] text-muted-foreground hover:text-foreground truncate`,title:e.value,children:[e.count,` · $`,(e.cost??0).toFixed(4),` · `,e.value]},e.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Cost ranges`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.costRanges.map(t=>(0,z.jsxs)(`button`,{onClick:()=>{let r=e.minCost===t.minCost&&e.maxCost===t.maxCost;n(`minCost`,r?void 0:t.minCost),n(`maxCost`,r?void 0:t.maxCost)},className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.minCost===t.minCost&&e.maxCost===t.maxCost?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,title:`Estimated total $${(t.cost??0).toFixed(4)}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground block mb-1`,children:`Enrichment levels`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.enrichmentLevels.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`enrichmentLevel`,e.enrichmentLevel===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.enrichmentLevel===t.value?`bg-primary text-primary-foreground`:`bg-card text-muted-foreground hover:text-foreground`}`,children:[`L`,t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,z.jsxs)(`label`,{className:`text-xs text-muted-foreground block`,children:[`Min cost`,(0,z.jsx)(`input`,{type:`number`,step:`0.001`,value:e.minCost??``,onChange:e=>n(`minCost`,e.target.value||void 0),className:`mt-1 w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`})]}),(0,z.jsxs)(`label`,{className:`text-xs text-muted-foreground block`,children:[`Max cost`,(0,z.jsx)(`input`,{type:`number`,step:`0.001`,value:e.maxCost??``,onChange:e=>n(`maxCost`,e.target.value||void 0),className:`mt-1 w-full bg-card border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:e.managed===!0,onChange:e=>n(`managed`,e.target.checked?!0:void 0),className:`rounded border-border bg-muted text-primary focus:ring-0`}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Overdeck-managed`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:e.enriched===!0,onChange:e=>n(`enriched`,e.target.checked?!0:void 0),className:`rounded border-border bg-muted text-primary focus:ring-0`}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Enriched only`})]})]}),Object.values(e).some(Boolean)&&(0,z.jsx)(`button`,{onClick:()=>{n(`since`,void 0),n(`harness`,void 0),n(`workspace`,void 0),n(`managed`,void 0),n(`enriched`,void 0),n(`model`,void 0),n(`tag`,void 0),n(`tool`,void 0),n(`file`,void 0),n(`minCost`,void 0),n(`maxCost`,void 0),n(`enrichmentLevel`,void 0)},className:`mt-4 text-[10px] text-muted-foreground/70 hover:text-muted-foreground transition-colors`,children:`Clear filters`})]})}function i5n(e){return`${e.source}:${e.id}`}function a5n(e){let t=new Set,n=[];for(let r of e??[])for(let e of r.rows){let r=i5n(e);t.has(r)||(t.add(r),n.push(e))}return n}function o5n(e){return`${e.source}:${e.id}`}function s5n(e){return{harnesses:[],models:e?.primaryModels.map(e=>({value:e.value,count:e.count}))??[],workspaces:[],tags:e?.tags.map(e=>({value:e.value,count:e.count}))??[],tools:e?.tools.map(e=>({value:e.value,count:e.count}))??[],files:e?.files.map(e=>({value:e.value,count:e.count}))??[],timeRanges:e?.timeBuckets.map(e=>({value:e.value===`24h`?`today`:e.value,label:e.value===`24h`?`Today`:e.value,count:e.count}))??[],costRanges:e?.costBuckets.map(e=>({value:e.value,label:e.value,count:e.count,minCost:e.value===`<$0.10`?void 0:e.value===`$0.10-1`?`0.10`:e.value===`$1-10`?`1`:`10`,maxCost:e.value===`<$0.10`?`0.10`:e.value===`$0.10-1`?`1`:e.value===`$1-10`?`10`:void 0}))??[],enrichmentLevels:e?.enrichmentLevels.map(e=>({value:String(e.value),count:e.count}))??[]}}function c5n(e){let t=new URLSearchParams;return e.harness&&t.set(`harness`,e.harness),e.workspace&&t.set(`workspacePath`,e.workspace),e.since&&t.set(`since`,e.since),e.managed&&t.set(`managed`,`true`),e.enriched&&t.set(`enriched`,`true`),e.model&&t.set(`primaryModel`,e.model),e.tag&&t.set(`tag`,e.tag),e.tool&&t.set(`tool`,e.tool),e.file&&t.set(`file`,e.file),e.minCost&&t.set(`minCost`,e.minCost),e.maxCost&&t.set(`maxCost`,e.maxCost),e.enrichmentLevel&&t.set(`enrichmentLevel`,e.enrichmentLevel),e.source&&e.source!==`all`&&t.set(`source`,e.source),t}function a7(e){let t={},n=e.get(`harness`),r=e.get(`workspacePath`),i=e.get(`primaryModel`),a=e.get(`since`),o=e.get(`managed`),s=e.get(`enriched`),c=e.get(`tag`),l=e.get(`tool`),u=e.get(`file`),d=e.get(`minCost`),f=e.get(`maxCost`),p=e.get(`enrichmentLevel`),m=e.get(`source`),h=e.get(`query`);return n&&(t.harness=n),r&&(t.workspacePath=r),i&&(t.primaryModel=i),a&&(t.since=a),o&&(t.managed=o===`true`),s&&(t.enriched=s===`true`),c&&(t.tags=[c]),l&&(t.tools=[l]),u&&(t.files=[u]),d&&Number.isFinite(Number(d))&&(t.minCost=Number(d)),f&&Number.isFinite(Number(f))&&(t.maxCost=Number(f)),p&&Number.isFinite(Number(p))&&(t.enrichmentLevel=Number(p)),(m===`discovered`||m===`managed-archived`)&&(t.source=m),h&&(t.query=h),t}function l5n(e){return{id:e.id,source:`discovered`,discoveredId:e.id,harness:e.harness??`claude-code`,conversationId:e.conversationId??null,conversationName:e.conversationName??null,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,conversationTitle:e.conversationTitle??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}function u5n(e){return{id:e.id,source:e.source,discoveredId:e.discoveredId??null,harness:e.harness??`claude-code`,conversationId:e.conversationId??null,conversationName:e.conversationName??null,conversationTitle:e.conversationTitle??null,archivedAt:e.archivedAt??null,jsonlPath:e.jsonlPath??null,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[],filesTouched:[],tags:[...e.tags],summary:e.summary??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function d5n(e,t){let n=await Mc().request(n=>n[Ft.listSessionsFeed]({...a7(e),limit:Number(e.get(`limit`)??50),...t?{cursor:t}:{}}));return{rows:n.rows.map(u5n),nextCursor:n.nextCursor??null}}async function f5n(e){return Mc().request(t=>t[Ft.getSessionsFeedFacets]({...a7(e),limit:Number(e.get(`limit`)??50)}))}async function p5n(e,t,n=50,r=0,i=!1){let a=await Mc().request(a=>a[Ft.searchConversations]({...a7(t),query:e,semantic:i,limit:n,offset:r}));return{...a,sessions:a.sessions.map(l5n)}}async function m5n(){let e=await Mc().request(e=>e[Ft.getConversationStats]({}));return{...e,embeddingModels:e.embeddingModels?.map(e=>({...e}))}}async function h5n(e){return Mc().request(t=>t[Ft.getConversationCost](a7(e)))}async function g5n(){return Mc().request(e=>e[Ft.scanConversations]({mode:`system`}))}function _5n({initialSessionKey:e=null}){let t=$t(),n=Wt(Ke),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(e),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(0),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)({}),h=p.source??`all`,g=r.trim(),[_,v]=(0,L.useState)(g),y=h!==`managed-archived`,b=d&&y,x=b?_:``,S=b?``:g,C=c5n(p);(0,L.useEffect)(()=>{if(!b){v(g);return}let e=window.setTimeout(()=>v(g),350);return()=>window.clearTimeout(e)},[b,g]),(0,L.useEffect)(()=>{!y&&d&&(f(!1),u(0))},[y,d]),(0,L.useEffect)(()=>{o(e)},[e]);let w=new URLSearchParams({limit:`100`});for(let[e,t]of C)w.set(e,t);S&&w.set(`query`,S);let T=ure({queryKey:[`sessions-feed`,w.toString()],queryFn:({pageParam:e})=>d5n(w,e),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor??void 0,enabled:!x}),{data:E}=F({queryKey:[`sessions-feed-facets`,w.toString()],queryFn:()=>f5n(w),enabled:!x,staleTime:3e4}),{data:D,isLoading:O}=F({queryKey:[`discovered-sessions-search`,x,C.toString(),l,b],queryFn:()=>p5n(x,C,50,l,b),enabled:!!x}),{data:k}=F({queryKey:[`discovered-sessions-stats`],queryFn:m5n,staleTime:3e4}),{data:A}=F({queryKey:[`discovered-sessions-cost`,C.toString()],queryFn:()=>h5n(C),staleTime:3e4}),j=Cn({mutationFn:g5n,onSuccess:()=>{t.invalidateQueries({queryKey:[`sessions-feed`]}),t.invalidateQueries({queryKey:[`sessions-feed-facets`]}),t.invalidateQueries({queryKey:[`discovered-sessions-stats`]})}}),ee=x?O:T.isLoading,M=a5n(T.data?.pages),N=x?D?.sessions??[]:M,P=a==null?null:N.find(e=>o5n(e)===a)??null,te=s5n(E),ne=[h===`all`?null:{key:`source`,label:`Source: ${h===`discovered`?`Discovered`:`Managed-archived`}`},p.harness?{key:`harness`,label:`Harness: ${p.harness}`}:null,p.workspace?{key:`workspace`,label:`Workspace: ${p.workspace}`}:null,p.model?{key:`model`,label:`Model: ${p.model}`}:null,p.tag?{key:`tag`,label:`Tag: ${p.tag}`}:null,p.tool?{key:`tool`,label:`Tool: ${p.tool}`}:null,p.file?{key:`file`,label:`File: ${p.file}`}:null,p.since?{key:`since`,label:`Since: ${p.since}`}:null,p.managed?{key:`managed`,label:`Managed`}:null,p.enriched?{key:`enriched`,label:`Enriched`}:null,p.minCost?{key:`minCost`,label:`Min cost: $${p.minCost}`}:null,p.maxCost?{key:`maxCost`,label:`Max cost: $${p.maxCost}`}:null,p.enrichmentLevel?{key:`enrichmentLevel`,label:`Enrichment: L${p.enrichmentLevel}`}:null].filter(e=>e!==null);(0,L.useEffect)(()=>{x||a==null||P!=null||!T.hasNextPage||T.isFetchingNextPage||T.fetchNextPage()},[x,T,P,a]);let re=(0,L.useCallback)(e=>{i(e),u(0)},[]),ie=(0,L.useCallback)((e,t)=>{m(n=>({...n,[e]:t})),u(0)},[]),ae=(0,L.useCallback)(e=>{o(e);let t=new URLSearchParams(window.location.search);e?t.set(`session`,e):t.delete(`session`);let n=t.toString();window.history.replaceState(null,``,`${window.location.pathname}${n?`?${n}`:``}`)},[]);return(0,z.jsxs)(`div`,{className:`flex flex-col h-full bg-background text-foreground`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border shrink-0`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-medium text-foreground`,children:`Session History`}),k&&(0,z.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground ml-2`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-foreground font-mono`,children:k.total}),` indexed`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-success font-mono`,children:k.enriched}),` enriched`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-primary font-mono`,children:k.managedCount}),` managed`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`span`,{className:`text-signal-cost-foreground font-mono`,children:[`$`,(A?.totalCost??0).toFixed(4)]}),` est. cost`]})]}),(0,z.jsx)(`div`,{className:`flex-1`}),(0,z.jsxs)(`div`,{className:`relative w-72`,children:[(0,z.jsx)(gs,{className:`absolute left-2.5 top-2 h-3.5 w-3.5 text-muted-foreground`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`Search sessions…`,value:r,onChange:e=>re(e.target.value),className:`w-full bg-card border border-border rounded pl-8 pr-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:border-primary`})]}),(0,z.jsx)(`button`,{onClick:()=>{y&&(f(e=>!e),u(0))},disabled:!y,className:`px-3 py-1.5 rounded text-xs border transition-colors ${y?b?`bg-signal-review/8 border-signal-review/32 text-signal-review-foreground`:`bg-card border-border text-muted-foreground hover:border-border`:`bg-muted border-border text-muted-foreground/60 cursor-not-allowed`}`,children:b?`Semantic`:`Keyword`}),(0,z.jsxs)(`button`,{onClick:()=>c(e=>!e),className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs border transition-colors ${s?`bg-primary border-primary text-primary-foreground`:`bg-card border-border text-muted-foreground hover:border-border`}`,children:[(0,z.jsx)(Io,{className:`h-3.5 w-3.5`}),`Filters`]}),(0,z.jsx)(e5n,{isScanning:j.isPending,onScan:()=>j.mutate(),lastResult:j.data,progress:n})]}),ne.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-b border-border bg-background shrink-0 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Active filters`}),ne.map(e=>(0,z.jsxs)(`button`,{onClick:()=>{ie(e.key,void 0),e.key===`minCost`&&ie(`maxCost`,void 0),e.key===`maxCost`&&ie(`minCost`,void 0)},className:`px-2 py-1 rounded-sm bg-primary/8 text-primary border border-primary/32 hover:bg-primary hover:text-primary-foreground transition-colors`,children:[e.label,` `,(0,z.jsx)(`span`,{className:`text-primary`,children:`×`})]},e.key)),(0,z.jsx)(`button`,{onClick:()=>m({}),className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Clear all`})]}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[s&&(0,z.jsx)(r5n,{filters:p,facets:te,onChange:ie}),(0,z.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 overflow-hidden ${P?`border-r border-border`:``}`,children:[x&&D?.error&&(0,z.jsxs)(`div`,{className:`px-4 py-2 border-b border-warning/32 bg-warning/8 text-warning-foreground text-xs`,children:[`Semantic search unavailable: `,D.error]}),ee?(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`Loading sessions…`}):N.length===0?(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-32 text-muted-foreground gap-2`,children:[(0,z.jsx)(`span`,{className:`text-sm`,children:`No sessions found`}),!k?.total&&(0,z.jsx)(`span`,{className:`text-xs`,children:`Run a scan to discover Claude Code sessions`})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(z8n,{sessions:N,selectedId:a,onSelect:ae,hasMore:!x&&T.hasNextPage,isLoadingMore:T.isFetchingNextPage,onLoadMore:()=>{T.fetchNextPage()}}),x&&D&&D.total>50&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-border shrink-0 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[l+1,`–`,l+N.length,` of `,D.total,` results`]}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`button`,{disabled:l===0,onClick:()=>u(e=>Math.max(0,e-50)),className:`px-2 py-1 rounded bg-muted hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Prev`}),(0,z.jsx)(`button`,{disabled:l+50>=D.total,onClick:()=>u(e=>e+50),className:`px-2 py-1 rounded bg-muted hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Next`})]})]})]})]}),P&&(0,z.jsx)(`div`,{className:`min-w-[28rem] flex-[1.15] overflow-hidden`,children:(0,z.jsx)(Q8n,{session:P,onClose:()=>ae(null)})})]})]})}function v5n(e){return e===`warming`?(0,z.jsx)(is,{className:`h-4 w-4 animate-spin text-primary`}):e===`ready`?(0,z.jsx)(vo,{className:`h-4 w-4 text-green-500`}):e===`failed`?(0,z.jsx)(go,{className:`h-4 w-4 text-destructive`}):(0,z.jsx)(So,{className:`h-4 w-4 text-muted-foreground`})}function y5n({mode:e,warmupStatus:t,isListening:n,onStart:r,onBackToStaging:i,onReset:a,onToggleMic:o,voiceError:s}){return(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`AutoPreso`}),(0,z.jsx)(`h2`,{className:`mt-1 text-lg font-semibold`,children:`Voice whiteboard`})]}),(0,z.jsx)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs font-medium capitalize text-muted-foreground`,children:e})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-lg px-3 py-2 text-sm font-semibold transition-colors ${n?`bg-destructive text-destructive-foreground`:`bg-primary text-primary-foreground`}`,children:n?`Stop mic`:`Start mic`}),(0,z.jsx)(`button`,{type:`button`,onClick:e===`staging`?r:i,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-foreground hover:bg-accent`,children:e===`staging`?`Go live`:`Back to staging`})]}),(0,z.jsxs)(`div`,{className:`mt-4 rounded-lg bg-muted/40 p-3 text-sm`,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-foreground`,children:[v5n(t),`Warmup: `,(0,z.jsx)(`span`,{className:`capitalize`,children:t})]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The whiteboard agent uses the staged canvas as context before live transcription starts.`})]}),s&&(0,z.jsx)(`div`,{className:`mt-4 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,children:s}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`mt-3 w-full rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Reset session`})]})}function b5n({partialText:e,turns:t}){let n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{n.current?.scrollIntoView({block:`end`})},[e,t]),(0,z.jsxs)(`section`,{className:`min-h-0 flex-1 rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Transcript`}),(0,z.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto pr-1 text-sm`,children:[t.length===0&&!e&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`Spoken turns will appear here while AutoPreso listens.`}),t.map((e,t)=>(0,z.jsxs)(`article`,{className:`rounded-lg bg-muted/40 p-2 text-foreground`,children:[(0,z.jsx)(`time`,{className:`mb-1 block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.timestamp.toLocaleTimeString()}),(0,z.jsx)(`p`,{children:e.text})]},`${e.timestamp.toISOString()}-${t}`)),e&&(0,z.jsx)(`p`,{className:`rounded-lg border border-dashed border-border p-2 italic text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{ref:n})]})]})}var x5n=25e4,S5n=6e3;function C5n(e){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}${e}`}function w5n(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(`staging`),[i,a]=(0,L.useState)(`idle`),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)([]),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(null),g=(0,L.useRef)(null),_=(0,L.useRef)(null),v=(0,L.useRef)(0),y=(0,L.useRef)(null),b=(0,L.useRef)(0),x=(0,L.useRef)(!0),S=(0,L.useRef)(null),C=(0,L.useRef)(null),w=(0,L.useRef)(null),T=(0,L.useRef)(null),E=(0,L.useRef)(null),D=(0,L.useRef)(null),O=(0,L.useCallback)(()=>{g.current?.close();let e=++v.current;(async()=>{try{await kc()}catch{return}if(!x.current||e!==v.current)return;let n=new WebSocket(C5n(`/ws/autopreso`));g.current=n,n.onopen=()=>{b.current=0},n.onmessage=e=>{let n=JSON.parse(String(e.data));(n.type===`whiteboard:snapshot`||n.type===`whiteboard:update`)&&(n.elements&&t(n.elements),n.mode&&r(n.mode),n.warmupStatus&&a(n.warmupStatus))},n.onclose=()=>{if(!x.current||g.current!==n)return;let e=Math.min(1e3*2**b.current,1e4);b.current+=1,y.current=window.setTimeout(O,e)}})()},[]),k=(0,L.useCallback)(e=>{d(!1),e&&_.current?.close(),e&&(_.current=null),w.current?.disconnect(),T.current?.disconnect(),E.current?.disconnect(),C.current?.close(),S.current?.getTracks().forEach(e=>e.stop()),w.current=null,T.current=null,E.current=null,C.current=null,S.current=null,h(null)},[]),A=(0,L.useCallback)(async(e=!0)=>{let t=_.current;k(!1),e&&t?.readyState===WebSocket.OPEN&&(t.send(JSON.stringify({type:`stop`})),await new Promise(e=>{let t=window.setTimeout(e,S5n);D.current=()=>{window.clearTimeout(t),e()}}),D.current=null),k(!0)},[k]);return(0,L.useEffect)(()=>(x.current=!0,O(),()=>{x.current=!1,y.current&&window.clearTimeout(y.current),y.current=null;let e=g.current;g.current=null,e?.close(),A(!1)}),[O,A]),{elements:e,mode:n,warmupStatus:i,partialText:o,committedTurns:c,isListening:u,voiceError:f,startListening:(0,L.useCallback)(async()=>{if(u)return;p(null);let e=null,t=null,n=null,r=null,i=null,a=null;try{await kc(),e=await navigator.mediaDevices.getUserMedia({audio:!0});let o=window.AudioContext;t=new o({sampleRate:24e3}),n=t.createMediaStreamSource(e),r=t.createAnalyser(),i=t.createScriptProcessor(4096,1,1),a=new WebSocket(C5n(`/ws/voice`)),a.binaryType=`arraybuffer`,a.onmessage=e=>{let t=JSON.parse(String(e.data));t.type===`transcript:partial`&&s(t.text),t.type===`transcript:committed`&&(s(``),l(e=>[...e,{text:t.text,timestamp:new Date}].slice(-200))),t.type===`transcript:finalized`&&D.current?.(),t.type===`error`&&p(t.error)},a.onclose=()=>{_.current===a&&A(!1)},i.onaudioprocess=e=>{if(a?.readyState!==WebSocket.OPEN||a.bufferedAmount>x5n)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e+=1){let r=Math.max(-1,Math.min(1,t[e]??0));n[e]=r<0?r*32768:r*32767}a.send(n.buffer)},n.connect(r),r.connect(i),i.connect(t.destination),S.current=e,C.current=t,T.current=n,E.current=r,w.current=i,_.current=a,h(r),d(!0)}catch(o){a?.close(),i?.disconnect(),n?.disconnect(),r?.disconnect(),t?.close(),e?.getTracks().forEach(e=>e.stop()),p(o instanceof Error?o.message:`Unable to start voice input`)}},[u,A]),stopListening:A,analyserNode:m}}var T5n=(0,L.lazy)(async()=>({default:(await I(()=>import(`./prod-DWloE-Tf.js`).then(e=>e.t),__vite__mapDeps([112,2,3,4,111,7,113]))).Excalidraw}));function E5n(){let{elements:e,mode:t,warmupStatus:n,partialText:r,committedTurns:i,isListening:a,voiceError:o,startListening:s,stopListening:c}=w5n(),[l,u]=(0,L.useState)([]),d=(0,L.useRef)(null),f=t===`live`?e:l,p=(0,L.useMemo)(()=>({elements:f}),[f]),m=(0,L.useCallback)(async()=>{await fetch(`/api/autopreso/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({elements:l,screenshotBase64:null})})},[l]),h=(0,L.useCallback)(async()=>{await fetch(`/api/autopreso/back-to-staging`,{method:`POST`})},[]),g=(0,L.useCallback)(async()=>{await fetch(`/api/autopreso/session/reset`,{method:`POST`}),u([]),d.current?.updateScene?.({elements:[]})},[]),_=(0,L.useCallback)(()=>{a?c():s()},[a,s,c]),v=(0,L.useCallback)(e=>{t===`staging`&&u(e)},[t]),y=(0,L.useCallback)(e=>{d.current=e},[]);return(0,L.useEffect)(()=>{t===`live`&&d.current?.updateScene?.({elements:e})},[t,e]),(0,z.jsxs)(`div`,{className:`flex h-full w-full gap-4 overflow-hidden bg-background p-4 text-foreground`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden rounded-xl border border-border bg-card shadow-sm`,children:(0,z.jsx)(L.Suspense,{fallback:(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading whiteboard…`}),children:(0,z.jsx)(T5n,{excalidrawAPI:y,initialData:p,onChange:v,viewModeEnabled:t===`live`},t)})}),(0,z.jsxs)(`aside`,{className:`flex w-96 shrink-0 flex-col gap-4 overflow-y-auto`,children:[(0,z.jsx)(y5n,{mode:t,warmupStatus:n,isListening:a,onStart:m,onBackToStaging:h,onReset:g,onToggleMic:_,voiceError:o}),(0,z.jsx)(b5n,{turns:i,partialText:r})]})]})}function o7({fallback:e,children:t}){return Wt(Vee)?(0,z.jsx)(z.Fragment,{children:t}):(0,z.jsx)(z.Fragment,{children:e})}var D5n=`overdeck:ui-mode`,O5n=`overdeck:last-tab`;function k5n(e=typeof window>`u`?void 0:window.localStorage){if(!e)return`simple`;try{let t=e.getItem(D5n);if(t===`simple`||t===`advanced`)return t;let n=e.getItem(O5n)?`advanced`:`simple`;return e.setItem(D5n,n),n}catch{return`simple`}}var s7=un(e=>({mode:k5n(),setMode:t=>{try{window.localStorage.setItem(D5n,t)}catch{}e({mode:t})},simpleIssueId:null,openSimpleIssue:t=>e({simpleIssueId:t}),closeSimpleIssue:()=>e({simpleIssueId:null})}));function A5n(e){if(typeof window>`u`)return;let t=e?`/issues/${encodeURIComponent(e)}`:`/`;window.location.pathname!==t&&window.history.pushState({},``,t)}var c7={home:{greetingFallback:`Hello.`,needsYouTitle:`Needs you`,needsYouSub:`Work pauses until you answer. Everything else keeps going.`,workingTitle:`Working now`,workingSub:`Nothing for you to do on these — you'll be told when they're ready.`,readyTitle:`Ready to merge`,doneTitle:`Finished`,composerPlaceholder:`Ask for anything, or describe what you want built, in plain words…`,chipIn:`In: `,chipNoProject:`Not in a project`,chipAddProject:`Add a project…`,nothingNeedsYou:`Nothing needs you right now. Nice.`,quietEmpty:`Nothing here yet.`},issue:{backToMyWork:`← My work`,composerPlaceholder:`Say something to the agent… (steer it, correct it, ask why)`,composerHint:`Talking to it never interrupts the work — it reads you between tasks.`,answerPlaceholder:`Type your answer…`,answerHint:`One sentence is enough. It continues immediately after you answer.`,whatHappened:`What happened`,advancedDisclosure:`Advanced — the machinery behind this task`,getHelp:`Get help`,steps:[`Started`,`Writing code`,`Checking`,`Ready`],feedTitle:`What it's doing`,waitingOnYou:`waiting on you`,taskStartedPrefix:`Task started · told to `,rawPromptDisclosure:`See the full instructions it was given`,readMore:`Read more`,showLess:`Show less`,pausedWaiting:`Paused — waiting for your answer`,pausedToStart:`Paused — waiting for you to start the work`,sentToAgent:`Sent to the agent`,questionTitle:`It has a question for you`,screenExcerptLabel:`Here's what it's showing on its screen:`,questionAskedPrefix:`Asked `,questionPauseSuffix:`work pauses until you answer — everything else keeps going`,questionAnswerPlaceholder:`Or type your own answer…`,answerSend:`Send answer`,questionOptionsHint:`Pick an option or write one sentence — it continues as soon as you answer.`,answerSentTitle:`Answer sent`,answerSentSub:`It's reading your answer and getting back to work.`,liveLabel:`live`,readyLiveRow:`All checks passed — ready when you are`},mode:{simple:`Simple`,advanced:`Advanced`},setup:{title:`Get set up`,subtitle:`A few things make Overdeck work best. Nothing here stops you from starting.`,hide:`Hide`,setUp:`Set up`,recheck:`Re-check`,claudeDone:`Claude is signed in`,claudeTodo:`Sign in to Claude`,githubDone:`GitHub is connected`,githubTodo:`Connect GitHub`,agentsDone:`Agents can start`,agentsTodo:`Finish setup so agents can start`,terminalsDone:`Plain terminals are ready`,terminalsTodo:`Install the terminal helper`,dockerDone:`Docker is running (optional)`,dockerTodo:`Docker (optional)`,memoryPrefix:`Free memory: `,memoryLow:`New agents may wait for memory to free up.`,runThis:`Run this in a terminal, then re-check:`}};function j5n(){let e=s7(e=>e.mode),t=s7(e=>e.setMode),n=[{id:`simple`,label:c7.mode.simple},{id:`advanced`,label:c7.mode.advanced}];return(0,z.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-lg border border-input`,children:n.map(n=>(0,z.jsx)(`button`,{onClick:()=>t(n.id),className:zc(`px-3 py-1.5 text-xs font-medium transition-colors`,e===n.id?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`),children:n.label},n.id))})}function M5n({state:e,pipelineState:t}){let n=c7.issue.steps,r=pft(t),i=e===`needs-you`;return(0,z.jsx)(`div`,{className:`mt-5 flex`,role:`list`,children:n.map((t,a)=>{let o=a<r||e===`done`,s=a===r&&e!==`done`&&e!==`ready`,c=a===n.length-1;return(0,z.jsxs)(`div`,{role:`listitem`,className:`relative flex-1 pt-3.5 text-center`,children:[(0,z.jsx)(`span`,{className:zc(`absolute left-0 right-0 top-[5px] h-0.5`,a===0&&`left-1/2`,c&&`right-1/2`,o||s?`bg-success`:`bg-muted`)}),(0,z.jsx)(`span`,{className:zc(`absolute left-1/2 top-0 h-3 w-3 -translate-x-1/2 rounded-full border-2`,o&&`border-transparent bg-success`,s&&!i&&`border-transparent bg-info shadow-[0_0_0_3px] shadow-info/25`,s&&i&&`border-transparent bg-warning shadow-[0_0_0_3px] shadow-warning/25`,!o&&!s&&`border-border bg-muted`)}),(0,z.jsx)(`span`,{className:zc(`text-[11.5px]`,o&&`text-success-foreground`,s&&`font-medium text-foreground`,!o&&!s&&`text-muted-foreground`),children:t}),s&&i&&(0,z.jsx)(`span`,{className:`mt-0.5 block text-[10.5px] text-warning-foreground`,children:c7.issue.waitingOnYou})]},t)})})}var N5n={"not-started":{accent:`border-transparent`,iconBg:`bg-muted text-muted-foreground`,icon:(0,z.jsx)(sfe,{size:15})},working:{accent:`border-info`,iconBg:`bg-info/10 text-info-foreground`,icon:(0,z.jsx)(is,{size:15})},"needs-you":{accent:`border-warning`,iconBg:`bg-warning/10 text-warning-foreground`,icon:(0,z.jsx)(yo,{size:15})},ready:{accent:`border-success`,iconBg:`bg-success/10 text-success-foreground`,icon:(0,z.jsx)(fo,{size:15})},done:{accent:`border-transparent`,iconBg:`bg-success/10 text-success-foreground`,icon:(0,z.jsx)(fo,{size:15})}};function P5n({display:e,children:t}){let n=N5n[e.state];return(0,z.jsxs)(`div`,{className:zc(`mt-4 rounded-2xl border-l-[3px] bg-card p-4`,`shadow-[0_1px_2px_rgb(0_0_0/0.05),0_4px_16px_rgb(0_0_0/0.05)] dark:border dark:border-border dark:shadow-none`,n.accent),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`span`,{className:zc(`flex h-8 w-8 flex-none items-center justify-center rounded-full`,n.iconBg),children:n.icon}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[15px] font-medium`,children:e.title}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.sentence})]})]}),t&&(0,z.jsx)(`div`,{className:`mt-3.5 flex flex-wrap items-center gap-2`,children:t})]})}function F5n({completed:e,total:t}){let n=t>0?Math.round(e/t*100):0;return(0,z.jsx)(`div`,{className:`mt-2.5 h-1 overflow-hidden rounded-full bg-accent`,"aria-label":`${e} of ${t}`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-info`,style:{width:`${n}%`}})})}function l7({children:e,onClick:t,disabled:n,tone:r=`primary`}){return(0,z.jsx)(`button`,{"data-slot":`primary-action`,onClick:t,disabled:n,className:zc(`inline-flex h-9 items-center rounded-lg px-4 text-[13.5px] font-medium text-white transition-opacity`,r===`success`?`bg-success text-[#04120c]`:`bg-primary text-primary-foreground`,n?`cursor-not-allowed opacity-50`:`hover:opacity-90`),children:e})}function u7({children:e,onClick:t,disabled:n}){return(0,z.jsx)(`button`,{onClick:t,disabled:n,className:zc(`inline-flex h-9 items-center rounded-lg border border-input px-4 text-[13.5px] font-medium text-muted-foreground transition-colors`,n?`cursor-not-allowed opacity-50`:`hover:bg-accent hover:text-foreground`),children:e})}var I5n={"claude-code":`Claude Code`,ohmypi:`oh-my-pi`,codex:`Codex`,acp:`ACP`,opencode:`OpenCode`,"kimi-code":`Kimi Code`,muse:`Muse Code`,"prime-agent":`Prime Agent`};function L5n(e){let{mode:t,harness:n,codexAvailable:r}=e,i=[n?{id:n,kind:`agent`,agentName:I5n[n],keys:`↵`}:{id:`agent`,kind:`agent`,keys:`↵`},{id:`terminal`,kind:`terminal`,keys:`⌃↵`}];return r&&n!==`codex`&&i.push({id:`codex`,kind:`agent`,agentName:`Codex`,keys:`⌘⇧↵`}),t===`simple`&&i.push({id:`talk`,kind:`talk`}),i}function R5n(e){return[`I want to discuss a possible task with you first — do not file anything yet.`,``,`The task idea, in my words:`,`"""`,e.trim(),`"""`,``,`Discuss it with me: ask what you need to know, point out what is underspecified or wrong, and help me sharpen it.`,`Only when I explicitly say it is ready (e.g. "file it"), file it as an issue in the tracker with a good title and body based on our discussion, and give me the issue link (e.g. PAN-1234).`].join(`
1484
1484
  `)}var z5n=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`).set;function B5n(e){(0,L.useEffect)(()=>{let t=t=>{if(t.key.length!==1||t.ctrlKey||t.metaKey||t.altKey)return;let n=document.activeElement;if(n!==document.body&&n!==null||document.querySelector(`[role="dialog"]`))return;let r=e.current;r&&(t.preventDefault(),t.stopPropagation(),r.focus(),z5n.call(r,r.value+t.key),r.dispatchEvent(new Event(`input`,{bubbles:!0})))};return document.addEventListener(`keydown`,t,{capture:!0}),()=>document.removeEventListener(`keydown`,t,{capture:!0})},[e])}function V5n({mode:e,projects:t,value:n,onChange:r,disabled:i}){let[a,o]=(0,L.useState)(!1),s=(0,L.useRef)(null),c=(0,L.useRef)(null),l=(0,L.useCallback)(()=>{o(!1),requestAnimationFrame(()=>c.current?.focus())},[]);(0,L.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&l()},t=e=>{e.key===`Escape`&&l()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[l,a]);let u=n?t.find(e=>e.key===n):void 0,d=e===`simple`?c7.home.chipNoProject:`No project (home folder)`,f=e===`simple`?c7.home.chipIn:`In: `,p=e===`simple`?c7.home.chipAddProject:`Add a project…`,m=u?`${f}${u.name??u.key}`:d,h=e=>{r(e),l()};return(0,z.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,z.jsx)(`button`,{ref:c,type:`button`,disabled:i,onClick:()=>o(e=>!e),className:`h-11 max-w-[180px] truncate rounded-xl border border-input bg-card px-3 text-xs text-muted-foreground outline-none hover:bg-accent focus:border-ring disabled:opacity-50`,"data-testid":`home-composer-project`,"aria-haspopup":`menu`,"aria-expanded":a,children:m}),a&&(0,z.jsxs)(`div`,{role:`menu`,"aria-label":`Choose a project`,className:`absolute bottom-full z-20 mb-1 max-h-64 min-w-[200px] overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-floating`,children:[t.map(e=>(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>h(e.key),className:`flex w-full cursor-pointer select-none items-center rounded px-3 py-1.5 text-left text-xs text-foreground outline-none hover:bg-accent`,children:e.name??e.key},e.key)),(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>h(void 0),className:`flex w-full cursor-pointer select-none items-center rounded px-3 py-1.5 text-left text-xs text-foreground outline-none hover:bg-accent`,children:d}),(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{l(),uS.getState().show()},className:`flex w-full cursor-pointer select-none items-center rounded px-3 py-1.5 text-left text-xs text-muted-foreground outline-none hover:bg-accent`,children:p})]})]})}var H5n=`overdeck:talk-project`,U5n=`Ask an agent, or run a command…`;function W5n(e){try{let t=localStorage.getItem(H5n);if(t&&e.some(e=>e.key===t))return t}catch{}return e[0]?.key}function G5n(){if(typeof document>`u`)return!1;let e=document.activeElement;return e?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.tagName===`SELECT`||e instanceof HTMLElement&&e.isContentEditable:!1}function K5n({mode:e}){let t=(0,L.useRef)(null),[n]=(0,L.useState)(()=>!G5n());B5n(t);let[r,i]=(0,L.useState)(Lf),[a,o]=(0,L.useState)(),[s,c]=(0,L.useState)(iS);(0,L.useEffect)(()=>{OPe().then(()=>{let e=Lf();e&&i(e)})},[]);let l=F({queryKey:[`registered-projects`],queryFn:ku,staleTime:6e4}).data??[],[u,d]=(0,L.useState)(void 0),f=u===void 0?W5n(l):u??void 0,p=F({queryKey:[`prerequisites`],queryFn:async()=>{let e=await fetch(`/api/prerequisites`);if(!e.ok)throw Error(`Failed to fetch prerequisites`);return e.json()},staleTime:3e5,retry:!1}).data?.checks?.find(e=>e.id===`codex`)?.found===!0,m=(0,L.useMemo)(()=>L5n({mode:e,harness:a,codexAvailable:p}),[e,a,p]),h=r?Qf(r)??Wx[r]:void 0,g=e=>{try{e?localStorage.setItem(H5n,e):localStorage.removeItem(H5n)}catch{}},_=Cn({mutationFn:async e=>{let t=await fetch(`/api/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:r,harness:e.codex?`codex`:a,message:e.message,...f?{projectKey:f}:{},...h?.length===0?{}:{effort:s}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to start the conversation (${t.status})`)}return t.json()},onSuccess:e=>{g(f),window.location.assign(`/conv/${encodeURIComponent(e.name)}`)}}),v=(e,t)=>{let n=t.trim();n&&r&&!_.isPending&&_.mutate({message:n,codex:e===`codex`})},y=e=>{let t=e.trim();t&&r&&!_.isPending&&_.mutate({message:R5n(t),codex:!1})},b=e=>{let t=f??`__no-project__`;Gzt({deckKey:t,command:e.trim()}),window.location.assign(`/command-deck/${encodeURIComponent(t)}`)},x=e===`simple`?c7.home.composerPlaceholder:U5n;return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(xVt,{intents:m,inputRef:t,autoFocus:n,inputTestId:`home-composer-input`,placeholder:x,busy:_.isPending,errorText:_.error?.message,onSelect:(e,t)=>LVt(e,t,{openAgent:(e,t)=>v(e.id,t),openTerminal:b,openWeb:()=>{},openTalk:y})})}),(0,z.jsx)(V5n,{mode:e,projects:l,value:f,onChange:e=>d(e??null),disabled:_.isPending}),(0,z.jsx)(`div`,{className:`min-w-0 max-w-full`,children:(0,z.jsx)(eS,{value:r,onChange:i,harness:a,onHarnessChange:o,followProviderDefault:!0,disabled:_.isPending})}),(0,z.jsx)(`div`,{className:`min-w-0 max-w-full`,children:(0,z.jsx)(aS,{value:s,onChange:c,availableLevels:h,disabled:_.isPending})}),!r&&(0,z.jsx)(`p`,{className:`w-full text-xs text-muted-foreground`,children:`Choose a model to start the conversation.`})]})}var q5n=`overdeck-setup-checklist-dismissed`;function d7(e,t){return t===`darwin`?e.install.mac:t===`win32`?e.install.win:e.install.linux}function J5n({command:e}){return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,z.jsx)(`code`,{className:`font-mono text-xs bg-card-2 border border-border rounded-sm px-1.5 py-0.5 truncate`,children:e}),(0,z.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(e).then(()=>B.success(`Copied`),()=>B.error(`Copy failed`))},className:`p-1 rounded-sm text-muted-foreground hover:text-foreground hover:bg-card-2 shrink-0`,"aria-label":`Copy install command for ${e}`,title:`Copy`,children:(0,z.jsx)(Oo,{className:`w-3.5 h-3.5`})})]})}function Y5n({check:e,platform:t}){return(0,z.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5 min-w-0`,children:[e.found?(0,z.jsx)(fo,{className:`w-4 h-4 text-muted-foreground shrink-0`,"aria-label":`installed`}):e.required?(0,z.jsx)(Ts,{className:`w-4 h-4 text-warning-foreground shrink-0`,"aria-label":`missing — required`}):(0,z.jsx)(`span`,{className:`w-4 h-4 text-muted-foreground text-center shrink-0`,"aria-label":`missing — optional`,children:`·`}),(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),!e.required&&(0,z.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:`optional`}),(0,z.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.purpose})]}),e.found?(0,z.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground truncate max-w-48`,children:e.version}):(0,z.jsx)(J5n,{command:d7(e,t)})]})}function X5n({activeTab:e}={}){let[t,n]=(0,L.useState)(!1),[r,i]=(0,L.useState)(()=>localStorage.getItem(q5n)??``),{data:a,refetch:o,isFetching:s}=F({queryKey:[`prerequisites`],queryFn:async()=>{let e=await fetch(`/api/prerequisites`);if(!e.ok)throw Error(`Failed to check prerequisites`);return e.json()},staleTime:3e5,retry:1}),c=(0,L.useMemo)(()=>(a?.checks??[]).filter(e=>e.required&&!e.found),[a]),l=c.map(e=>e.id).sort().join(`,`);if(!a||c.length===0||!t&&r===l||e===`home`)return null;let u=()=>{localStorage.setItem(q5n,l),i(l),n(!1)},d=async()=>{try{let e=await fetch(`/api/diagnostics/setup`);if(!e.ok)throw Error(`Diagnostics request failed`);let t=await e.json();if(!t.markdown)throw Error(`Diagnostics report was empty`);await navigator.clipboard.writeText(t.markdown),B.success(`Diagnostics copied`)}catch{B.error(`Could not copy diagnostics`)}};return(0,z.jsxs)(`div`,{className:`bg-warning/8 border-b border-warning/32 shrink-0`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-3 flex items-center gap-3`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-sm font-medium text-warning-foreground flex-1 min-w-0`,children:[`Finish setting up Overdeck — missing required `,c.length===1?`tool`:`tools`,`:`,` `,(0,z.jsx)(`span`,{className:`font-mono`,children:c.map(e=>e.id).join(`, `)}),`. Agents cannot start until `,c.length===1?`it is`:`they are`,` installed.`]}),(0,z.jsx)(`button`,{onClick:()=>n(e=>!e),className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-warning/8 border border-warning/32 text-warning-foreground hover:bg-warning/16 shrink-0`,children:t?`Hide checklist`:`Show checklist`}),(0,z.jsx)(`button`,{onClick:u,className:`p-1.5 rounded-sm text-muted-foreground hover:text-foreground hover:bg-card-2 shrink-0`,"aria-label":`Dismiss setup checklist`,title:`Dismiss (reappears if the missing set changes)`,children:(0,z.jsx)(Os,{className:`w-4 h-4`})})]}),t&&(0,z.jsxs)(`div`,{className:`px-4 pb-3`,children:[(0,z.jsx)(`div`,{className:`bg-card border border-border rounded-sm px-4 py-2 divide-y divide-border`,children:a.checks.map(e=>(0,z.jsx)(Y5n,{check:e,platform:a.platform},e.id))}),(0,z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,z.jsxs)(`button`,{onClick:()=>void o(),disabled:s,className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-card border border-border text-foreground hover:bg-card-2 disabled:opacity-50 inline-flex items-center gap-1.5`,children:[(0,z.jsx)(zt,{className:`w-3.5 h-3.5 ${s?`animate-spin`:``}`}),`Re-check`]}),(0,z.jsxs)(`button`,{onClick:()=>void d(),className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-card border border-border text-foreground hover:bg-card-2 inline-flex items-center gap-1.5`,children:[(0,z.jsx)(Oo,{className:`w-3.5 h-3.5`}),`Copy diagnostics`]}),(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Run the commands in a terminal, then re-check. Install commands are for this machine (`,a.platform===`darwin`?`macOS`:a.platform===`win32`?`Windows`:`Linux`,`).`]})]})]})]})}var Z5n=`overdeck:get-set-up-dismissed`,Q5n={...c7.setup,claudeTodo:`Log in to Claude Code`,githubTodo:`Log in to the GitHub CLI (gh)`,agentsDone:`Herdr is ready`,agentsTodo:`Herdr is not ready`,terminalsDone:`tmux is installed`,terminalsTodo:`Install tmux (plain terminals)`,dockerDone:`Docker is installed`,dockerTodo:`Docker (optional)`};function f7(e,t){return e.find(e=>e.id===t)}function $5n(e,t,n){let r=[];if(e.auth){let{claude:i,gh:a}=e.auth;r.push({id:`claude`,done:i.ok,label:i.ok?t.claudeDone:t.claudeTodo,commands:i.ok?[]:[`claude`,`/login`]});let o=f7(e.checks,`gh`);r.push({id:`github`,done:a.ok,label:a.ok?t.githubDone:t.githubTodo,commands:a.ok?[]:a.installed||!o?[`gh auth login`]:[d7(o,n)]})}if(e.backend&&e.backend.name!==`tmux`){let i=f7(e.checks,`herdr`),{available:a}=e.backend;r.push({id:`agents`,done:a,label:a?t.agentsDone:t.agentsTodo,commands:a||!i?[]:[d7(i,n)]})}let i=f7(e.checks,`tmux`);i&&r.push({id:`terminals`,done:i.found,label:i.found?t.terminalsDone:t.terminalsTodo,commands:i.found?[]:[d7(i,n)]});let a=f7(e.checks,`docker`);return a&&r.push({id:`docker`,done:a.found,label:a.found?t.dockerDone:t.dockerTodo,commands:a.found?[]:[d7(a,n)]}),r}function e7n(e){return!!(e.checks.some(e=>e.required&&!e.found)||e.backend&&!e.backend.available||e.auth&&!e.auth.claude.ok)}function t7n(){let e=s7(e=>e.mode)===`simple`?c7.setup:Q5n,t=$t(),[n,r]=(0,L.useState)(()=>{try{return localStorage.getItem(Z5n)===`1`}catch{return!1}}),[i,a]=(0,L.useState)(new Set),[o,s]=(0,L.useState)(!1),{data:c}=F({queryKey:[`prerequisites`],queryFn:async()=>{let e=await fetch(`/api/prerequisites`);if(!e.ok)throw Error(`Failed to check prerequisites`);return e.json()},staleTime:3e5,retry:1}),l=!!c&&Array.isArray(c.checks),u=(0,L.useMemo)(()=>l?$5n(c,e,c.platform):[],[l,c,e]),d=(0,L.useMemo)(()=>l?e7n(c):!1,[l,c]);if(!l||n&&!d)return null;let f=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},p=()=>{try{localStorage.setItem(Z5n,`1`)}catch{}r(!0)},m=async()=>{s(!0);try{let e=await fetch(`/api/prerequisites?refresh=1`);if(e.ok){let n=await e.json();t.setQueryData([`prerequisites`],n)}}finally{s(!1)}};return(0,z.jsxs)(`section`,{"data-component":`get-set-up-card`,"aria-labelledby":`get-set-up-title`,className:`rounded-xl border border-border bg-card p-5 shadow-sm`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`get-set-up-title`,className:`text-sm font-semibold text-foreground`,children:e.title}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.subtitle})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,z.jsxs)(`button`,{onClick:()=>void m(),disabled:o,className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-card border border-border text-foreground hover:bg-card-2 disabled:opacity-50 inline-flex items-center gap-1.5`,children:[(0,z.jsx)(zt,{className:`w-3.5 h-3.5 ${o?`animate-spin`:``}`}),e.recheck]}),(0,z.jsx)(`button`,{onClick:p,className:`p-1.5 rounded-sm text-muted-foreground hover:text-foreground hover:bg-card-2`,"aria-label":e.hide,title:e.hide,children:(0,z.jsx)(Os,{className:`w-4 h-4`})})]})]}),(0,z.jsxs)(`div`,{className:`mt-3 divide-y divide-border`,children:[u.map(t=>(0,z.jsxs)(`div`,{className:`py-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[t.done?(0,z.jsx)(fo,{className:`w-4 h-4 text-muted-foreground shrink-0`,"aria-label":`done`}):(0,z.jsx)(Ts,{className:`w-4 h-4 text-warning-foreground shrink-0`,"aria-label":`to do`}),(0,z.jsx)(`span`,{className:`flex-1 text-sm text-foreground min-w-0`,children:t.label}),!t.done&&t.commands.length>0&&(0,z.jsx)(`button`,{onClick:()=>f(t.id),className:`px-2.5 py-1 text-xs font-medium rounded-sm bg-card border border-border text-foreground hover:bg-card-2 shrink-0`,children:e.setUp})]}),!t.done&&t.commands.length>0&&i.has(t.id)&&(0,z.jsxs)(`div`,{className:`mt-2 ml-7 flex flex-col gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.runThis}),t.commands.map(e=>(0,z.jsx)(J5n,{command:e},e))]})]},t.id)),c.memory&&(0,z.jsxs)(`div`,{className:`py-2 flex items-center gap-3 min-w-0`,children:[(0,z.jsx)(`span`,{className:`w-4 h-4 shrink-0`}),(0,z.jsxs)(`span`,{className:`flex-1 text-sm text-foreground min-w-0`,children:[e.memoryPrefix,c.memory.availableGb,` GB`,c.memory.low&&(0,z.jsx)(`span`,{className:`block text-xs text-warning-foreground mt-0.5`,children:e.memoryLow})]})]})]})]})}var p7=c7.home;function m7(e,t){t(e.issue.identifier),A5n(e.issue.identifier)}var n7n=864e5;function r7n(e,t=Date.now()){return e.filter(e=>{if(e.display.state!==`not-started`)return!1;let n=Date.parse(e.issue.createdAt??``);return Number.isFinite(n)&&t-n<n7n}).sort((e,t)=>(t.issue.createdAt??``).localeCompare(e.issue.createdAt??``)).slice(0,5)}function i7n({item:e,onOpen:t}){let n=zD(),r=a7n(e.issue.createdAt);return(0,z.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 shadow-sm`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[10px]`,children:e.issue.identifier}),r&&(0,z.jsxs)(`span`,{children:[`filed `,r]})]}),(0,z.jsx)(`button`,{onClick:t,className:`mt-0.5 block w-full truncate text-left text-sm font-medium hover:underline`,children:e.issue.title})]}),(0,z.jsx)(u7,{onClick:t,children:`Open`}),(0,z.jsx)(l7,{disabled:n.startPlanning.isPending,onClick:()=>n.startPlanning.mutate({issueId:e.issue.identifier}),children:`Start planning`})]})}function a7n(e){let t=Date.parse(e??``);if(!Number.isFinite(t))return``;let n=Math.round((Date.now()-t)/6e4);return n<60?`${Math.max(n,1)}m ago`:`${Math.round(n/60)}h ago`}function o7n({item:e,subject:t,onOpen:n}){let r=zD(),i=Wt(e=>e.agentsById),[a,o]=(0,L.useState)(``),s=t?.agentId,c=!(!s||i?.[s]),l=s??e.pendingInputAgent?.id,u=t?.pendingAskUserQuestion?.questions?.[0]?.question??e.display.sentence,d=r.answer.isPending;return(0,z.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-warning/40 bg-card p-4 shadow-sm`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:(0,z.jsxs)(`span`,{children:[`Question · `,(e.issue.title,``),e.issue.identifier]})}),(0,z.jsx)(`button`,{onClick:n,className:`mt-1 text-left text-[15px] font-medium hover:underline`,children:e.issue.title}),(0,z.jsx)(`p`,{className:`mt-2 text-[13.5px] leading-relaxed`,children:u}),(0,z.jsxs)(`div`,{className:`mt-2.5 flex gap-2`,children:[(0,z.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a.trim()&&l&&r.answer.mutate({agentId:l,text:a.trim(),isConversation:c})},placeholder:c7.issue.answerPlaceholder,className:`h-9 flex-1 rounded-lg border border-input bg-muted px-3 text-[13px] text-foreground outline-none focus:border-ring`}),(0,z.jsx)(l7,{disabled:!a.trim()||!l||d,onClick:()=>l&&r.answer.mutate({agentId:l,text:a.trim(),isConversation:c}),children:e.display.primaryAction??`Answer`})]}),(0,z.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:c7.issue.answerHint})]})}function s7n({item:e,kind:t,onOpen:n}){let r=zD(),i=e.primaryAgent,a=r.tell.isPending||r.recover.isPending||r.startWork.isPending,o=t===`stuck`,s=t===`start-work`;return(0,z.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-warning/40 bg-card p-4 shadow-sm`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:(0,z.jsxs)(`span`,{children:[o?`Stuck`:s?e.display.title:`Problems found`,` · `,e.issue.identifier]})}),(0,z.jsx)(`button`,{onClick:n,className:`mt-1 text-left text-[15px] font-medium hover:underline`,children:e.issue.title}),(0,z.jsx)(`p`,{className:`mt-2 text-[13.5px] leading-relaxed`,children:e.display.sentence}),(0,z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[s?(0,z.jsx)(l7,{disabled:a,onClick:()=>r.startWork.mutate({issueId:e.issue.identifier}),children:e.display.primaryAction}):o?(0,z.jsx)(l7,{disabled:a||!i,onClick:()=>{i&&r.recover.mutate({agentId:i.id})},children:`Get it unstuck`}):(0,z.jsx)(l7,{disabled:!i||a,onClick:()=>i&&r.tell.mutate({agentId:i.id,message:`Please address the review findings and get this back to green.`}),children:`Tell the agent to fix them`}),(0,z.jsx)(u7,{onClick:n,children:`Open`})]})]})}function c7n({item:e,onOpen:t}){return(0,z.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-3.5 rounded-xl border border-border bg-card px-4 py-3.5 shadow-sm`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 flex-none animate-pulse rounded-full bg-info`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`button`,{onClick:t,className:`block w-full truncate text-left text-sm font-medium hover:underline`,children:e.issue.title}),(0,z.jsxs)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`text-info-foreground`,children:e.display.title}),e.taskProgress?` · task ${e.taskProgress.completed} of ${e.taskProgress.total}`:``,e.expectation?` · ${e.expectation}`:``]}),e.taskProgress&&(0,z.jsx)(F5n,{completed:e.taskProgress.completed,total:e.taskProgress.total})]}),(0,z.jsx)(u7,{onClick:t,children:`Watch`})]})}function l7n({item:e,onOpen:t}){let n=zD();return(0,z.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-success/40 bg-card p-4 shadow-sm`,children:[(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`All checks passed · `,e.issue.identifier]}),(0,z.jsx)(`button`,{onClick:t,className:`mt-1 text-left text-[15px] font-medium hover:underline`,children:e.issue.title}),(0,z.jsx)(`p`,{className:`mt-2 text-[13.5px] leading-relaxed`,children:e.display.sentence}),(0,z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,z.jsx)(l7,{tone:`success`,disabled:n.merge.isPending,onClick:()=>n.merge.mutate({issueId:e.issue.identifier}),children:`Merge to main`}),e.prUrl&&(0,z.jsx)(u7,{onClick:()=>window.open(e.prUrl,`_blank`,`noopener`),children:`See the changes`}),(0,z.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`Nothing merges by itself here`})]})]})}function u7n(){let e=Wt(e=>e.issuesRaw),t=Wt(e=>e.agentsById),n=Wt(e=>e.derivedIssueStateByIssueId),r=Wt(e=>e.backendPanesById),i=gS(),a=s7(e=>e.openSimpleIssue),{derivations:o,buckets:s,byIdentifier:c}=(0,L.useMemo)(()=>{let i=e??[],a=Object.values(t??{}),o=new Map;for(let e of a){let t=e.issueId?.toLowerCase();if(!t)continue;let n=o.get(t)??[];n.push(e),o.set(t,n)}let s=i.map(e=>LD(e,o.get(e.identifier.toLowerCase())??[],n?.[e.identifier],Object.values(r).filter(t=>t.issue?.toUpperCase()===e.identifier.toUpperCase())));return{derivations:s,buckets:nbt(s),byIdentifier:new Map(s.map(e=>[e.issue.identifier.toLowerCase(),e]))}},[e,t,n,r]),l=(0,L.useMemo)(()=>{let e=new Map;for(let t of i??[])t.issueId&&e.set(t.issueId.toLowerCase(),t);return e},[i]),u=(0,L.useMemo)(()=>{let e=new Set(s.needsYou.map(e=>e.derivation.issue.identifier.toLowerCase())),t=[];for(let[n,r]of l){if(e.has(n))continue;let i=c.get(n);i&&t.push({derivation:i,subject:r})}return t},[s.needsYou,l,c]),d=s.needsYou.length+u.length,f=(0,L.useMemo)(()=>r7n(o),[o]);return(0,z.jsx)(`div`,{"data-component":`simple-home-page`,className:`h-full w-full overflow-y-auto`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 pb-24 pt-7`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-2xl font-medium`,children:d>0?`${d} thing${d===1?``:`s`} need${d===1?`s`:``} you.`:p7.greetingFallback}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:d>0?`Everything else is moving on its own.`:p7.nothingNeedsYou}),(0,z.jsxs)(`div`,{className:`mt-3 flex gap-4 text-[13px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`b`,{className:`font-medium text-foreground`,children:s.working.length}),` being worked on`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`b`,{className:`font-medium text-foreground`,children:s.ready.length}),` ready to merge`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`b`,{className:`font-medium text-foreground`,children:s.finished.length}),` finished this week`]})]})]}),(0,z.jsx)(j5n,{})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:(0,z.jsx)(K5n,{mode:`simple`})}),(0,z.jsx)(`div`,{className:`mt-6`,children:(0,z.jsx)(t7n,{})}),(0,z.jsxs)(`section`,{className:`mt-8`,children:[(0,z.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[p7.needsYouTitle,` `,(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d})]}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:p7.needsYouSub}),d===0&&(0,z.jsx)(`div`,{className:`mt-3 rounded-xl border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:p7.nothingNeedsYou}),s.needsYou.map(({derivation:e,kind:t})=>t===`question`?(0,z.jsx)(o7n,{item:e,subject:l.get(e.issue.identifier.toLowerCase()),onOpen:()=>m7(e,a)},e.issue.identifier):(0,z.jsx)(s7n,{item:e,kind:t,onOpen:()=>m7(e,a)},e.issue.identifier)),u.map(({derivation:e,subject:t})=>(0,z.jsx)(o7n,{item:e,subject:t,onOpen:()=>m7(e,a)},`q-${e.issue.identifier}`))]}),f.length>0&&(0,z.jsxs)(`section`,{className:`mt-8`,children:[(0,z.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[`Just filed `,(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f.length})]}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Fresh from your conversations — start planning when you're ready.`}),f.map(e=>(0,z.jsx)(i7n,{item:e,onOpen:()=>m7(e,a)},e.issue.identifier))]}),(0,z.jsxs)(`section`,{className:`mt-8`,children:[(0,z.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[p7.workingTitle,` `,(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.working.length})]}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:p7.workingSub}),s.working.map(e=>(0,z.jsx)(c7n,{item:e,onOpen:()=>m7(e,a)},e.issue.identifier))]}),s.ready.length>0&&(0,z.jsxs)(`section`,{className:`mt-8`,children:[(0,z.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[p7.readyTitle,` `,(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.ready.length})]}),s.ready.map(e=>(0,z.jsx)(l7n,{item:e,onOpen:()=>m7(e,a)},e.issue.identifier))]}),s.finished.length>0&&(0,z.jsxs)(`section`,{className:`mt-8`,children:[(0,z.jsxs)(`h2`,{className:`text-[15px] font-medium`,children:[p7.doneTitle,` `,(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.finished.length})]}),(0,z.jsx)(`div`,{className:`mt-2`,children:s.finished.slice(0,8).map(e=>(0,z.jsxs)(`button`,{onClick:()=>m7(e,a),className:`flex w-full items-center gap-2.5 border-b border-border py-2.5 text-left text-[13px] last:border-none hover:bg-accent/40`,children:[(0,z.jsx)(`span`,{className:`flex h-4 w-4 flex-none items-center justify-center rounded-full bg-success/15 text-[10px] text-success-foreground`,children:`✓`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.issue.title}),(0,z.jsx)(`span`,{className:`ml-auto flex-none text-[11.5px] text-muted-foreground`,children:e.issue.identifier})]},e.issue.identifier))})]})]})})}function d7n(e){let t=e.url??``,n=/^https?:\/\/github\.com\/([^/]+\/[^/]+)\/issues\/\d+/.exec(t);if(n){let t=encodeURIComponent(`[HELP] ${e.identifier}: ${e.title}`.slice(0,200));return`https://github.com/${n[1]}/issues/new?title=${t}`}let r=/^https?:\/\/linear\.app\/([^/]+)\/issue\//.exec(t);return r?`https://linear.app/${r[1]}/new`:null}var f7n=280,p7n=80,m7n=2,h7n={Bash:`Ran`,Read:`Read`,Edit:`Edited`,MultiEdit:`Edited`,Write:`Wrote`,NotebookEdit:`Edited`,Glob:`Searched`,Grep:`Searched`,LS:`Listed files in`,WebFetch:`Fetched`,WebSearch:`Searched the web for`,TodoWrite:`Updated the task list`},g7n={Bash:`Ran a command`,Read:`Read a file`,Edit:`Edited a file`,MultiEdit:`Edited a file`,Write:`Wrote a file`,NotebookEdit:`Edited a file`,Glob:`Searched the code`,Grep:`Searched the code`,LS:`Listed files`,WebFetch:`Fetched a page`,WebSearch:`Searched the web`,TodoWrite:`Updated the task list`};function _7n(e){return e.replace(/```[\s\S]*?```/g,` … `).replace(/`([^`]*)`/g,`$1`).replace(/^\s{0,3}#{1,6}\s+/gm,``).replace(/\*\*([^*]+)\*\*/g,`$1`).replace(/__([^_]+)__/g,`$1`).replace(/(^|\s)\*([^*\n]+)\*(?=\s|$)/g,`$1$2`).replace(/^\s*[-*+]\s+/gm,``).replace(/\s+/g,` `).trim()}function v7n(e){return e.tone===`error`||/^error[:\s]/i.test(e.detail??``)}function y7n(e){let t=e.changedFiles??[];if(t.length>0)return`Edited ${t.slice(0,m7n).join(`, `)}${t.length>m7n?` (+${t.length-m7n} more)`:``}`;if(e.command)return`Ran ${e.command.length>p7n?`${e.command.slice(0,p7n)}…`:e.command}`;if(v7n(e)&&e.detail)return e.detail;let n=h7n[e.label];return n&&e.detail?`${n} ${e.detail}`:e.detail?e.detail:g7n[e.label]??e.label}function b7n(e){let t=[],n=!1;for(let r of e.messages){if(r.role===`user`&&!n){n=!0,t.push({kind:`system`,id:`sys-${r.id}`,createdAt:r.createdAt,text:c7.issue.taskStartedPrefix+e.issueTitle.toLowerCase(),raw:r.text});continue}if(r.role===`user`){t.push({kind:`reply`,id:`re-${r.id}`,createdAt:r.createdAt,text:r.text});continue}if(r.role===`assistant`){let e=_7n(r.text);t.push({kind:`say`,id:`say-${r.id}`,createdAt:r.createdAt,preview:e.length>f7n?`${e.slice(0,f7n)}…`:e,full:r.text,clamp:r.text.length>f7n})}}for(let n of e.workLog)n.tone!==`thinking`&&t.push({kind:`action`,id:`act-${n.id}`,createdAt:n.createdAt,text:y7n(n),files:n.changedFiles,failed:v7n(n)});return t.map((e,t)=>({entry:e,index:t})).sort((e,t)=>{let n=new Date(e.entry.createdAt).getTime(),r=new Date(t.entry.createdAt).getTime();return n===r?e.index-t.index:n-r}).map(({entry:e})=>e)}var h7=c7.issue;function x7n({issue:e,agents:t,agent:n,onSelectAgent:r,state:i,needsYouReason:a}){let o=(0,L.useMemo)(()=>rv(n),[n]),{enabled:s}=alt(o),c=$t(),l=(0,L.useMemo)(()=>iE(o.name),[o.name]),u=!nv(n),{data:d}=F({queryKey:l,queryFn:async({signal:e})=>{let t=await Dlt(o.name,e,n.id);if(s){let e=c.getQueryData(l);if(e&&e.messages.length>=t.messages.length)return e}return t},enabled:!s,refetchInterval:s?!1:u?2e3:!1}),f=(0,L.useMemo)(()=>d?.messages??[],[d]),p=(0,L.useMemo)(()=>d?.workLog??[],[d]),m=(0,L.useMemo)(()=>b7n({messages:f,workLog:p,issueTitle:e.title}),[f,p,e.title]),h=(0,L.useRef)(null),g=(0,L.useRef)(!0);(0,L.useEffect)(()=>{let e=h.current;e&&g.current&&(e.scrollTop=e.scrollHeight)},[m.length]);let _=u&&(n.status===`running`||n.status===`starting`),v=i===`needs-you`;return(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2.5`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium`,children:h7.feedTitle}),v?(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-warning-foreground`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`}),` `,h7.waitingOnYou]}):_?(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-info-foreground`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-info`}),` `,h7.liveLabel]}):null,(0,z.jsxs)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:[S7n(n.role),` agent · `,(0,z.jsx)(`span`,{className:`font-mono`,children:n.id.replace(/^agent-/,``)})]})]}),t.length>1&&(0,z.jsx)(`div`,{className:`mt-2 inline-flex overflow-hidden rounded-lg border border-input`,children:t.map(e=>(0,z.jsx)(`button`,{onClick:()=>r(e.id),className:zc(`px-3 py-1.5 text-xs font-medium transition-colors`,e.id===n.id?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`),children:S7n(e.role)},e.id))}),(0,z.jsxs)(`div`,{ref:h,onScroll:e=>{let t=e.currentTarget;g.current=t.scrollHeight-t.scrollTop-t.clientHeight<40},className:`mt-2.5 max-h-[470px] overflow-y-auto border-t border-border`,children:[m.map(e=>(0,z.jsx)(C7n,{entry:e},e.id)),(0,z.jsx)(w7n,{state:i,needsYouReason:a,running:_,messages:f,workLog:p})]})]})}function S7n(e){return e?`${e[0].toUpperCase()}${e.slice(1)}`:`Agent`}function C7n({entry:e}){let[t,n]=(0,L.useState)(!1),r=(0,z.jsx)(`span`,{className:`mt-0.5 flex-none text-[11px] text-muted-foreground`,children:np(e.createdAt,new Date)});return e.kind===`system`?(0,z.jsxs)(`div`,{className:`flex gap-2.5 border-b border-border px-0.5 py-2.5`,children:[(0,z.jsx)(`span`,{className:`mt-0.5 w-4 flex-none text-muted-foreground`,children:(0,z.jsx)(Lo,{size:13})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[e.text,(0,z.jsxs)(`details`,{className:`mt-1`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-[11.5px] underline underline-offset-2`,children:h7.rawPromptDisclosure}),(0,z.jsx)(`pre`,{className:`mt-2 max-h-[180px] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-accent p-2.5 font-mono text-[11.5px] leading-relaxed`,children:e.raw})]})]}),r]}):e.kind===`say`?(0,z.jsxs)(`div`,{className:`flex gap-2.5 border-b border-border px-0.5 py-2.5`,children:[(0,z.jsx)(`span`,{className:`mt-0.5 w-4 flex-none text-muted-foreground`,children:(0,z.jsx)(qfe,{size:13})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 text-[13.5px]`,children:[t?(0,z.jsx)(cu,{text:e.full}):e.preview,e.clamp&&(0,z.jsx)(`button`,{onClick:()=>n(e=>!e),className:`ml-1.5 text-[11.5px] text-info-foreground`,children:t?h7.showLess:h7.readMore})]}),r]}):e.kind===`action`?(0,z.jsxs)(`div`,{className:`flex gap-2.5 border-b border-border px-0.5 py-2.5`,children:[(0,z.jsx)(`span`,{className:`mt-0.5 w-4 flex-none text-muted-foreground`,children:(0,z.jsx)(Ds,{size:13})}),(0,z.jsx)(`div`,{className:zc(`min-w-0 flex-1 truncate text-[13px]`,e.failed?`text-destructive-foreground`:`text-muted-foreground`),children:e.text}),r]}):(0,z.jsxs)(`div`,{className:`flex gap-2.5 border-b border-border px-0.5 py-2.5`,children:[(0,z.jsx)(`span`,{className:`mt-0.5 w-4 flex-none text-muted-foreground`,children:(0,z.jsx)(_pe,{size:13})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 text-[13px]`,children:[(0,z.jsx)(`span`,{className:`mr-1.5 text-[11px] text-muted-foreground`,children:h7.sentToAgent}),(0,z.jsx)(`span`,{className:zc(!t&&`line-clamp-3`),children:e.text}),e.text.length>280&&(0,z.jsx)(`button`,{onClick:()=>n(e=>!e),className:`ml-1.5 text-[11.5px] text-info-foreground`,children:t?h7.showLess:h7.readMore})]}),r]})}function w7n({state:e,needsYouReason:t,running:n,messages:r,workLog:i}){if(e===`needs-you`)return(0,z.jsxs)(`div`,{className:`flex gap-2.5 px-0.5 py-2.5`,children:[(0,z.jsx)(`span`,{className:`mt-1.5 w-4 flex-none text-center text-[10px] text-warning`,children:`●`}),(0,z.jsx)(`div`,{className:`flex-1 text-[13px] text-warning-foreground`,children:t===`start-work`?h7.pausedToStart:h7.pausedWaiting}),(0,z.jsx)(`span`,{className:`mt-0.5 flex-none text-[11px] text-muted-foreground`,children:`now`})]});if(n){let e=_Fe(gFe(r,i),yFe(i));return(0,z.jsxs)(`div`,{className:`flex gap-2.5 px-0.5 py-2.5`,children:[(0,z.jsx)(`span`,{className:`mt-1.5 w-4 flex-none text-center text-[10px] text-info`,children:`●`}),(0,z.jsx)(`div`,{className:`flex-1 text-[13px] text-info-foreground`,children:e}),(0,z.jsx)(`span`,{className:`mt-0.5 flex-none text-[11px] text-muted-foreground`,children:`now`})]})}return e===`ready`?(0,z.jsxs)(`div`,{className:`flex gap-2.5 px-0.5 py-2.5`,children:[(0,z.jsx)(`span`,{className:`mt-1.5 w-4 flex-none text-center text-[10px] text-success`,children:`●`}),(0,z.jsx)(`div`,{className:`flex-1 text-[13px] text-success-foreground`,children:h7.readyLiveRow})]}):null}var g7=c7.issue;function T7n(e){let t=e.pendingAskUserQuestion?.questions;return Array.isArray(t)&&t.length===1&&t[0].multiSelect!==!0}function E7n({agent:e,onSend:t,sending:n}){let[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1);if(!T7n(e))return null;let l=e.pendingAskUserQuestion,u=l.questions[0];if(s)return(0,z.jsx)(`div`,{className:`mt-4 rounded-2xl border-l-[3px] border-info bg-card p-4 shadow-[0_1px_2px_rgb(0_0_0/0.05),0_4px_16px_rgb(0_0_0/0.05)] dark:border dark:border-border`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`flex h-8 w-8 flex-none items-center justify-center rounded-full bg-info/10 text-info-foreground`,children:(0,z.jsx)(is,{size:15})}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[15px] font-medium`,children:g7.answerSentTitle}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:g7.answerSentSub})]})]})});let d=()=>{let e=a.trim()||r;e&&!n&&t(e,()=>c(!0))};return(0,z.jsxs)(`div`,{className:`mt-4 rounded-2xl border-l-[3px] border-warning bg-card p-4 shadow-[0_1px_2px_rgb(0_0_0/0.05),0_4px_16px_rgb(0_0_0/0.05)] dark:border dark:border-border`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`flex h-8 w-8 flex-none items-center justify-center rounded-full bg-warning/10 text-warning-foreground`,children:(0,z.jsx)(yo,{size:15})}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[15px] font-medium`,children:g7.questionTitle}),(0,z.jsxs)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[g7.questionAskedPrefix,np(l.askedAt,new Date),` · `,g7.questionPauseSuffix]})]})]}),(0,z.jsx)(`div`,{className:`mt-3 rounded-[10px] bg-accent px-3.5 py-3 text-[14px] leading-relaxed`,children:u.question}),u.options.length>0&&(0,z.jsx)(`div`,{className:`mt-2.5 grid gap-2`,children:u.options.map(e=>(0,z.jsxs)(`button`,{onClick:()=>i(e.label),className:zc(`flex items-start gap-2.5 rounded-[10px] border border-input px-3 py-2.5 text-left text-[13.5px]`,r===e.label&&`border-ring shadow-[0_0_0_1px] shadow-ring`),children:[(0,z.jsx)(`span`,{className:zc(`mt-[3px] h-3.5 w-3.5 flex-none rounded-full border-2 border-muted-foreground`,r===e.label&&`border-primary bg-primary shadow-[inset_0_0_0_2.5px] shadow-card`)}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`block font-medium`,children:e.label}),e.description&&(0,z.jsx)(`span`,{className:`block text-[12.5px] text-muted-foreground`,children:e.description})]})]},e.label))}),(0,z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,z.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d()},placeholder:g7.questionAnswerPlaceholder,className:`h-[38px] flex-1 rounded-[10px] border border-input bg-transparent px-3 text-[13.5px] outline-none focus:border-ring`}),(0,z.jsx)(l7,{disabled:n||!a.trim()&&!r,onClick:d,children:g7.answerSend})]}),(0,z.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground`,children:g7.questionOptionsHint})]})}var D7n=c7.issue,O7n=40;function k7n({agentId:e}){let{data:t}=F({queryKey:[`simple-terminal-excerpt`,e],queryFn:async()=>{let t=await fetch(`/api/agents/${e}/output?lines=${O7n}`);return t.ok?((await t.json()).output??``).replace(/\s+$/,``):``},refetchInterval:15e3}),n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[t]),t?(0,z.jsxs)(`div`,{className:`w-full`,children:[(0,z.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:D7n.screenExcerptLabel}),(0,z.jsx)(`pre`,{ref:n,className:`mt-1.5 max-h-52 overflow-y-auto whitespace-pre-wrap break-words rounded-[10px] bg-accent px-3.5 py-3 font-mono text-[11.5px] leading-relaxed text-foreground`,children:t})]}):null}var _7=c7.issue;function A7n({issueId:e}){let t=Wt(e=>e.issuesRaw),n=Wt(e=>e.agentsById),r=Wt(e=>e.derivedIssueStateByIssueId),i=Wt(e=>e.backendPanesById),a=Wt(e=>e.openIssue),o=s7(e=>e.closeSimpleIssue),s=zD(),c=(0,L.useRef)(null),[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(null),p=(0,L.useMemo)(()=>{let a=t??[],o=a.find(t=>t.identifier===e)??a.find(t=>t.identifier.toLowerCase()===e.toLowerCase());return o?LD(o,Object.values(n??{}).filter(e=>e.issueId?.toLowerCase()===o.identifier.toLowerCase()),r?.[o.identifier],Object.values(i).filter(e=>e.issue?.toUpperCase()===o.identifier.toUpperCase())):null},[t,n,r,i,e]);if(!p)return(0,z.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 pt-7`,children:[(0,z.jsx)(S,{}),(0,z.jsx)(`p`,{className:`mt-8 text-sm text-muted-foreground`,children:`Can't find that task. It may have moved — head back and pick another.`})]})});let m=p,h=m.primaryAgent,g=m.display.needsYouReason===`question`?m.pendingInputAgent:void 0,_=m.agents.find(e=>e.id===d)??h,v=g!=null&&T7n(g),y=d7n(m.issue),b=s.tell.isPending||s.answer.isPending||s.recover.isPending||s.merge.isPending||s.startWork.isPending,x=()=>{let e=l.trim();e&&(g?s.answer.mutate({agentId:g.id,text:e}):_&&s.tell.mutate({agentId:_.id,message:e}),u(``))};return(0,z.jsx)(`div`,{"data-component":`simple-issue-page`,className:`h-full w-full overflow-y-auto`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 pb-24 pt-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(S,{}),(0,z.jsx)(j5n,{})]}),(0,z.jsxs)(`div`,{className:`mt-3.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:m.issue.identifier}),m.issue.project?.name&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{children:`·`}),(0,z.jsx)(`span`,{children:m.issue.project.name})]})]}),(0,z.jsx)(`h1`,{className:`mt-1 text-[21px] font-medium leading-snug`,children:m.issue.title})]}),(0,z.jsx)(M5n,{state:m.display.state,pipelineState:m.pipelineState}),v?(0,z.jsx)(E7n,{agent:g,sending:s.answer.isPending,onSend:(e,t)=>s.answer.mutate({agentId:g.id,text:e},{onSuccess:t})}):(0,z.jsxs)(P5n,{display:m.display,children:[g&&(0,z.jsx)(k7n,{agentId:g.id}),m.expectation&&(0,z.jsx)(`span`,{className:`w-full text-xs text-muted-foreground`,children:m.expectation}),(()=>{let e=m.display.primaryAction;if(!e)return null;switch(e){case`Merge to main`:return(0,z.jsx)(l7,{tone:`success`,disabled:b,onClick:()=>s.merge.mutate({issueId:m.issue.identifier}),children:e});case`Start work`:return(0,z.jsx)(l7,{disabled:b,onClick:()=>s.startWork.mutate({issueId:m.issue.identifier}),children:e});case`Get it unstuck`:return(0,z.jsx)(l7,{disabled:b||!h,onClick:()=>{h&&s.recover.mutate({agentId:h.id})},children:e});case`Tell the agent to fix them`:return(0,z.jsx)(l7,{disabled:!h||b,onClick:()=>h&&s.tell.mutate({agentId:h.id,message:`Please address the review findings and get this back to green.`}),children:e});case`See what changed`:return m.prUrl?(0,z.jsx)(l7,{onClick:()=>window.open(m.prUrl,`_blank`,`noopener`),children:e}):null;case`Answer`:return(0,z.jsx)(l7,{disabled:b,onClick:()=>c.current?.focus(),children:e});default:return null}})(),m.display.secondaryActions.map(e=>e===`See what changed`&&m.prUrl?(0,z.jsx)(u7,{onClick:()=>window.open(m.prUrl,`_blank`,`noopener`),children:e},e):e===`Tell the agent something`?(0,z.jsx)(u7,{onClick:()=>c.current?.focus(),children:e},e):null)]}),(0,z.jsxs)(`section`,{className:`mt-6`,children:[(0,z.jsx)(`div`,{className:`mt-2.5`,children:h?(0,z.jsx)(x7n,{issue:m.issue,agents:m.agents,agent:_,onSelectAgent:f,state:m.display.state,needsYouReason:m.display.needsYouReason}):(0,z.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:`Nothing to show yet — updates appear here as it works.`})}),!v&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 rounded-2xl border border-input bg-card py-2 pl-3.5 pr-2 focus-within:border-ring`,children:[(0,z.jsx)(`input`,{ref:c,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&x()},placeholder:g?_7.answerPlaceholder:_7.composerPlaceholder,className:`flex-1 bg-transparent text-[13.5px] text-foreground outline-none`}),(0,z.jsx)(`button`,{onClick:x,disabled:!l.trim()||!_&&!g||b,className:`flex h-8 w-8 items-center justify-center rounded-lg bg-primary text-primary-foreground transition-opacity disabled:opacity-40`,"aria-label":`Send`,children:`➤`})]}),(0,z.jsx)(`div`,{className:`mt-1.5 pl-1 text-[11px] text-muted-foreground`,children:g?_7.answerHint:_7.composerHint})]})]}),(0,z.jsx)(`div`,{className:`mt-8 rounded-xl border border-border bg-card`,children:(0,z.jsxs)(`button`,{onClick:()=>a(m.issue.identifier,`overview`),className:`flex w-full items-center gap-2 px-4 py-3 text-left text-[13px] text-muted-foreground hover:text-foreground`,children:[(0,z.jsx)(`span`,{children:`▸`}),` `,_7.advancedDisclosure]})}),(0,z.jsxs)(`div`,{className:`mt-6 text-center text-xs text-muted-foreground`,children:[`Something look wrong?`,` `,y?(0,z.jsx)(`a`,{href:y,target:`_blank`,rel:`noreferrer`,className:`text-info-foreground underline underline-offset-2`,children:_7.getHelp}):(0,z.jsx)(`span`,{className:`text-info-foreground`,children:_7.getHelp}),` `,`— a human sees these.`]})]})});function S(){return(0,z.jsxs)(`button`,{onClick:()=>{o(),A5n(null)},className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,z.jsx)(Gde,{size:13}),` `,c7.issue.backToMyWork.replace(`← `,``)]})}}function j7n({advanced:e}){let t=s7(e=>e.mode),n=s7(e=>e.simpleIssueId);return t===`simple`?n?(0,z.jsx)(A7n,{issueId:n}):(0,z.jsx)(u7n,{}):(0,z.jsx)(z.Fragment,{children:e})}function M7n(){return(0,z.jsx)(`div`,{className:`flex gap-4 overflow-x-auto pb-4`,children:[{title:`Todo`,color:`border-primary`},{title:`In Progress`,color:`border-yellow-500`},{title:`In Review`,color:`border-purple-500`},{title:`Done`,color:`border-success`}].map(e=>(0,z.jsxs)(`div`,{className:`border-t-4 ${e.color} bg-card rounded-lg min-w-[280px] flex-1`,children:[(0,z.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`div`,{className:`h-4 w-24 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-4 w-6 animate-pulse bg-muted rounded`})]})}),(0,z.jsx)(`div`,{className:`p-3 space-y-2`,children:Array.from({length:3}).map((e,t)=>(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-3 space-y-2`,children:[(0,z.jsx)(`div`,{className:`h-3 w-3/4 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-3 w-1/2 animate-pulse bg-muted rounded`}),(0,z.jsxs)(`div`,{className:`flex gap-2 mt-2`,children:[(0,z.jsx)(`div`,{className:`h-5 w-16 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-5 w-10 animate-pulse bg-muted rounded`})]})]},t))})]},e.title))})}function N7n(){return(0,z.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6 p-6 w-full`,children:[(0,z.jsxs)(`div`,{className:`bg-card rounded-lg`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[(0,z.jsx)(`div`,{className:`h-4 w-36 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-6 w-20 animate-pulse bg-muted rounded`})]}),(0,z.jsx)(`div`,{className:`divide-y divide-divider`,children:Array.from({length:4}).map((e,t)=>(0,z.jsxs)(`div`,{className:`p-4 flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`h-8 w-8 animate-pulse bg-muted rounded-full`}),(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,z.jsx)(`div`,{className:`h-3 w-32 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-3 w-20 animate-pulse bg-muted rounded`})]})]}),(0,z.jsx)(`div`,{className:`h-5 w-16 animate-pulse bg-muted rounded`})]},t))})]}),(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-4`,children:[(0,z.jsx)(`div`,{className:`h-4 w-28 animate-pulse bg-muted rounded mb-4`}),(0,z.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,z.jsx)(`div`,{className:`h-3 animate-pulse bg-muted rounded`,style:{width:`${60+t%3*15}%`}},t))})]})]})}function P7n(){return(0,z.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden bg-background`,children:[(0,z.jsxs)(`div`,{className:`flex h-[52px] shrink-0 items-center gap-[12px] border-b border-border bg-background px-[22px]`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 space-y-[4px]`,children:[(0,z.jsx)(`div`,{className:`h-[8px] w-[80px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[14px] w-[100px] animate-pulse rounded bg-muted`})]}),(0,z.jsx)(`div`,{className:`flex-1 h-[32px] min-w-[280px] animate-pulse rounded-[var(--radius-lg)] bg-muted`}),(0,z.jsx)(`div`,{className:`h-[32px] w-[120px] animate-pulse rounded-[var(--radius-lg)] bg-muted`}),(0,z.jsx)(`div`,{className:`ml-auto h-[32px] w-[110px] animate-pulse rounded-[var(--radius-lg)] bg-muted`})]}),(0,z.jsx)(`div`,{className:`flex shrink-0 border-b border-border bg-background`,children:Array.from({length:5}).map((e,t)=>(0,z.jsxs)(`div`,{className:`flex-1 border-r border-border last:border-r-0 px-[18px] py-[12px] space-y-[6px]`,children:[(0,z.jsx)(`div`,{className:`h-[10px] w-[70px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[20px] w-[40px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[9px] w-[55px] animate-pulse rounded bg-muted`})]},t))}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[8px] border-b border-border bg-background px-[22px] py-[10px]`,children:[Array.from({length:6}).map((e,t)=>(0,z.jsx)(`div`,{className:`h-[28px] animate-pulse rounded-[var(--radius-sm)] bg-muted ${t===0?`w-[40px]`:`w-[56px]`}`},t)),(0,z.jsxs)(`div`,{className:`ml-auto flex gap-[6px]`,children:[(0,z.jsx)(`div`,{className:`h-[28px] w-[70px] animate-pulse rounded-[var(--radius-sm)] bg-muted`}),(0,z.jsx)(`div`,{className:`h-[28px] w-[60px] animate-pulse rounded-[var(--radius-sm)] bg-muted`})]})]}),(0,z.jsx)(`div`,{className:`flex-1 overflow-auto`,children:[`Ship`,`Review`,`Work`,`Plan`].map(e=>(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-[10px] border-b border-border px-[22px] py-[12px]`,children:[(0,z.jsx)(`div`,{className:`h-[8px] w-[8px] animate-pulse rounded-full bg-muted`}),(0,z.jsx)(`div`,{className:`h-[14px] w-[60px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[16px] w-[24px] animate-pulse rounded-[var(--radius-sm)] bg-muted`})]}),Array.from({length:3}).map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-[10px] border-b border-border px-[22px] py-[12px]`,children:[(0,z.jsx)(`div`,{className:`h-[10px] w-[10px] animate-pulse rounded bg-muted shrink-0`}),(0,z.jsx)(`div`,{className:`h-[12px] flex-1 animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[18px] w-[90px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[10px] w-[55px] animate-pulse rounded bg-muted`})]},t))]},e))})]})}function F7n(){return(0,z.jsxs)(`div`,{className:`god-view flex flex-col flex-1 min-h-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border shrink-0`,children:[(0,z.jsx)(`div`,{className:`h-4 w-48 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-4 w-24 animate-pulse bg-muted rounded`})]}),(0,z.jsxs)(`div`,{className:`flex flex-1 gap-3 px-3 pb-3 pt-2 min-h-0 overflow-hidden`,children:[(0,z.jsx)(`div`,{className:`flex-1 grid grid-cols-3 gap-3 content-start overflow-auto`,children:Array.from({length:6}).map((e,t)=>(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-3 space-y-2 min-h-[120px]`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`h-6 w-6 animate-pulse bg-muted rounded-full`}),(0,z.jsx)(`div`,{className:`h-3 w-24 animate-pulse bg-muted rounded`})]}),(0,z.jsx)(`div`,{className:`h-3 w-3/4 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-3 w-1/2 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-16 animate-pulse bg-muted rounded mt-2`})]},t))}),(0,z.jsxs)(`div`,{className:`w-[220px] shrink-0 space-y-3`,children:[(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-3`,children:[(0,z.jsx)(`div`,{className:`h-3 w-20 animate-pulse bg-muted rounded mb-3`}),Array.from({length:4}).map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`h-2 w-2 animate-pulse bg-muted rounded-full`}),(0,z.jsx)(`div`,{className:`h-3 flex-1 animate-pulse bg-muted rounded`})]},t))]}),(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-3`,children:[(0,z.jsx)(`div`,{className:`h-3 w-24 animate-pulse bg-muted rounded mb-3`}),(0,z.jsx)(`div`,{className:`h-32 animate-pulse bg-muted rounded`})]})]})]})]})}function v7(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}project=${encodeURIComponent(t)}`:e}function I7n(e){let t=(e.state??e.status).toLowerCase();return e.stateType!==`completed`&&e.stateType!==`canceled`&&![`done`,`closed`,`completed`,`canceled`,`cancelled`].includes(t)}function L7n(e){let t=new Map;for(let n of e)if(n.status!==`complete`)for(let e of n.items)t.set(e.issue.toUpperCase(),n);return t}async function R7n(e,t,n,r){let i=await fetch(v7(`/api/orders/${encodeURIComponent(e)}/items`,r),{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({item:{issue:t,lane:n}})}),a=await i.json().catch(()=>null);if(!i.ok)throw Error(a?.error??`Could not add ${t} (${i.status})`);return a}function z7n({book:e,books:t,onBookChange:n,issues:r,project:i}){let a=Wt(Lt),o=r??a,[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(`A`),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),h=(0,L.useMemo)(()=>L7n(t),[t]),g=(0,L.useMemo)(()=>{let e=s.trim().toLowerCase();return e?o.filter(I7n).filter(t=>[t.identifier,t.title,...t.labels].some(t=>t.toLowerCase().includes(e))).slice(0,10):[]},[o,s]),_=async t=>{f(t),m(null);try{n(await R7n(e.id,t,l,i))}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(null)}};return(0,z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-3`,"aria-label":`Search and add issues`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Search open issues`}),(0,z.jsx)(`div`,{className:`ml-auto flex rounded-md border border-border p-0.5 text-[10px]`,children:[`A`,`B`].map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>u(e),"aria-pressed":l===e,className:`rounded-sm px-2 py-0.5 ${l===e?`bg-muted text-foreground`:`text-muted-foreground`}`,children:[`Lane `,e]},e))})]}),(0,z.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 rounded-md border border-input bg-background px-2 py-1.5`,children:[(0,z.jsx)(gs,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Search issues by id, title, or label`}),(0,z.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`ID, title, or label`,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none`})]}),(0,z.jsxs)(`div`,{className:`mt-2 grid gap-1`,children:[g.map(t=>{let n=h.get(t.identifier.toUpperCase()),r=n?n.id===e.id?`Already in this book`:`In ${n.name}`:null;return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5 first:border-t-0`,children:[(0,z.jsx)(`span`,{className:`w-20 shrink-0 font-mono text-[11px] text-foreground`,children:t.identifier}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:t.title}),(0,z.jsx)(`button`,{type:`button`,disabled:!!r||d===t.identifier,title:r??`Add to Lane ${l}`,onClick:()=>void _(t.identifier),className:`w-20 rounded-md border border-border px-2 py-1 text-[10px] text-muted-foreground hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:r??(d===t.identifier?`Adding…`:`+ Lane ${l}`)})]},t.id)}),s.trim()&&g.length===0&&(0,z.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No matching open issues.`})]}),(0,z.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:`Adding changes the plan only; dispatch begins when the book's run starts.`}),p&&(0,z.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,role:`alert`,children:p})]})}function B7n({book:e,onBookChange:t,project:n}){let[r,i]=(0,L.useState)([]),[a,o]=(0,L.useState)(`A`),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(null);(0,L.useEffect)(()=>{let t=!0;return fetch(v7(`/api/orders/backlog-candidates?limit=10`,n)).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error??`Could not load backlog candidates (${e.status})`);return t?.candidates??[]}).then(n=>{if(!t)return;let r=new Set(e.items.map(e=>e.issue.toUpperCase()));i(n.filter(e=>!r.has(e.issue.toUpperCase())).sort((e,t)=>e.rank-t.rank).slice(0,10))}).catch(e=>{t&&u(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e.id,e.items,n]);let d=async r=>{c(r),u(null);try{let o=await fetch(v7(`/api/orders/${encodeURIComponent(e.id)}/items`,n),{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({item:{issue:r,lane:a}})}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error??`Could not add ${r} (${o.status})`);t(s),i(e=>e.filter(e=>e.issue!==r))}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(null)}};return(0,z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-3`,"aria-label":`Backlog candidates`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Backlog top 10`}),(0,z.jsx)(`div`,{className:`ml-auto flex rounded-md border border-border p-0.5 text-[10px]`,children:[`A`,`B`].map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>o(e),"aria-pressed":a===e,className:`rounded-sm px-2 py-0.5 ${a===e?`bg-muted text-foreground`:`text-muted-foreground`}`,children:[`Lane `,e]},e))})]}),(0,z.jsxs)(`div`,{className:`mt-2 grid gap-1`,children:[r.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5 first:border-t-0`,children:[(0,z.jsxs)(`span`,{"data-testid":`sequence-rank`,className:`w-6 shrink-0 text-[10px] text-muted-foreground`,children:[`#`,e.rank]}),(0,z.jsx)(`span`,{className:`w-20 shrink-0 font-mono text-[11px] text-foreground`,children:e.issue}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:e.why}),(0,z.jsx)(`button`,{type:`button`,disabled:s===e.issue,onClick:()=>void d(e.issue),className:`w-16 rounded-md border border-border px-2 py-1 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,children:s===e.issue?`Adding…`:`+ ${a}`})]},e.issue)),r.length===0&&!l&&(0,z.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No unassigned backlog candidates.`})]}),(0,z.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:`Sequencer rank informs planning order; order-book lane position governs this run.`}),l&&(0,z.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,role:`alert`,children:l})]})}function V7n(e){if(e.status===`running`)return`Active · ${e.progress.landed}/${e.progress.total} landed`;if(e.status===`ready`)return`Queued · ${e.items.length} items`;if(e.status===`draft`)return`Draft · ${e.items.length} items`;let t=e.status===`complete`&&e.runId?` · retro ✓`:``;return`${e.status===`complete`?`Drained`:`Draining`} · ${e.progress.landed}/${e.progress.total} landed${t}`}function H7n({books:e,selectedId:t,onSelect:n,onCreate:r}){let[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(null),f=async()=>{let e=o.trim();if(e&&!c){l(!0),d(null);try{await r(e),s(``),a(!1)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}}};return(0,z.jsxs)(`section`,{className:`flex shrink-0 items-center gap-2 overflow-x-auto border-b border-border bg-muted/30 px-4 py-2`,"aria-label":`Order books`,children:[e.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-pressed":e.id===t,className:`min-w-44 rounded-lg border bg-card px-3 py-2 text-left transition-colors ${e.id===t?`border-primary/50`:`border-border hover:border-border/80`}`,children:[(0,z.jsx)(`span`,{className:`block truncate text-xs font-medium text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:`mt-0.5 block text-[10px] font-medium text-muted-foreground`,children:V7n(e)})]},e.id)),i?(0,z.jsxs)(`div`,{className:`flex min-w-64 items-center gap-2 rounded-lg border border-border bg-card p-2`,children:[(0,z.jsx)(`label`,{className:`sr-only`,htmlFor:`new-order-book-name`,children:`Book name`}),(0,z.jsx)(`input`,{id:`new-order-book-name`,autoFocus:!0,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f(),e.key===`Escape`&&a(!1)},placeholder:`Book name`,className:`min-w-0 flex-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs text-foreground outline-none focus:border-primary/50`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void f(),disabled:!o.trim()||c,className:`rounded-md border border-primary/40 px-2 py-1.5 text-xs text-foreground disabled:opacity-40`,children:c?`Creating…`:`Create`}),(0,z.jsx)(`button`,{type:`button`,"aria-label":`Cancel new book`,onClick:()=>a(!1),className:`text-muted-foreground hover:text-foreground`,children:(0,z.jsx)(Os,{className:`h-4 w-4`})}),u&&(0,z.jsx)(`span`,{role:`alert`,className:`text-xs text-destructive`,children:u})]}):(0,z.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex shrink-0 items-center rounded-md px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:`+ New book`})]})}function U7n(e){return e===`in-pipeline`?`border-l-2 border-l-info bg-info/[0.08]`:e===`landed`?`border-l-2 border-l-success bg-success/[0.08]`:`border-l-2 border-l-transparent`}function W7n({item:e,title:t,state:n,hasPrd:r,onDragStart:i,onDrop:a,onSwapLane:o,onRequirementsChange:s,onRemove:c}){let l=n===`in-pipeline`||n===`landed`,[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(e.prereqs.join(`, `)),[m,h]=(0,L.useState)(e.reVerify),[g,_]=(0,L.useState)(e.planAtPickup??!1),[v,y]=(0,L.useState)(!1);(0,L.useEffect)(()=>p(e.prereqs.join(`, `)),[e.prereqs]),(0,L.useEffect)(()=>h(e.reVerify),[e.reVerify]),(0,L.useEffect)(()=>_(e.planAtPickup??!1),[e.planAtPickup]);let b=async()=>{y(!0);try{await s(e.issue,{prereqs:[...new Set(f.split(/[\s,]+/).map(e=>e.trim().toUpperCase()).filter(Boolean))],reVerify:m,planAtPickup:g}),d(!1)}catch{}finally{y(!1)}};return(0,z.jsxs)(`div`,{draggable:!u,onDragStart:()=>i(e.issue),onDragOver:e=>e.preventDefault(),onDrop:t=>a(t,e.lane,e.order),"data-item-state":n,className:`border-t border-border first:border-t-0 ${U7n(n)}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs`,children:[(0,z.jsx)(jfe,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`,"aria-hidden":`true`}),(0,z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[e.lane,e.order,` · book`]}),(0,z.jsx)(`span`,{className:`w-20 shrink-0 font-mono text-[11px] text-foreground`,children:e.issue}),t?(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,title:t,children:t}):(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,"aria-hidden":`true`}),e.prereqs.length>0&&(0,z.jsxs)(`span`,{className:`rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:[`after `,e.prereqs.join(`, `)]}),e.reVerify&&(0,z.jsx)(`span`,{className:`rounded-sm border px-1.5 py-0.5 text-[10px] ${l?`border-border text-muted-foreground`:`border-warning/[0.32] bg-warning/[0.08] text-warning-foreground`}`,children:`re-verify`}),e.planAtPickup&&(0,z.jsx)(`span`,{className:`rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:`plan at pickup`}),(0,z.jsx)(`span`,{className:`rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:r?`PRD ✓`:`no PRD`}),(0,z.jsx)(`span`,{className:`w-16 shrink-0 text-right text-[10px] ${n===`in-pipeline`?`text-info`:n===`landed`?`text-success`:`text-muted-foreground`}`,children:n}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:`text-muted-foreground hover:text-foreground`,"aria-label":`Edit holds for ${e.issue}`,children:(0,z.jsx)(ype,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,"aria-label":`Move ${e.issue} to Lane ${e.lane===`A`?`B`:`A`}`,children:[`→ `,e.lane===`A`?`B`:`A`]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>c(e.issue),className:`text-muted-foreground hover:text-destructive`,"aria-label":`Remove ${e.issue} from book`,children:(0,z.jsx)(ws,{className:`h-3.5 w-3.5`})})]}),u&&(0,z.jsxs)(`div`,{className:`grid gap-2 border-t border-border bg-muted/20 px-3 py-3 text-[11px] md:grid-cols-[1fr_auto_auto_auto]`,"aria-label":`Holds for ${e.issue}`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 text-muted-foreground`,children:[`Prerequisites`,(0,z.jsx)(`input`,{"aria-label":`Prerequisites for ${e.issue}`,value:f,onChange:e=>p(e.target.value),placeholder:`PAN-100, PAN-101`,className:`rounded-md border border-input bg-background px-2 py-1.5 font-mono text-foreground`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1.5 self-end pb-1.5 text-muted-foreground`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked)}),`Re-verify PRD`]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1.5 self-end pb-1.5 text-muted-foreground`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked)}),`Plan at pickup`]}),(0,z.jsx)(`button`,{type:`button`,disabled:v,onClick:()=>void b(),className:`self-end rounded-md border border-primary/40 px-2.5 py-1.5 text-foreground disabled:opacity-40`,children:v?`Saving…`:`Save holds`})]})]})}async function G7n(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error??`Order book mutation failed (${e.status})`);return t}function K7n(e,t,n){return e.progress.items?.find(e=>e.issue===t)?.closed?`landed`:n.has(t.toUpperCase())?`in-pipeline`:e.settings.posture===`drain`?`held`:`released`}function q7n({book:e,inFlightIssues:t=new Set,issues:n,onBookChange:r,project:i}){let a=Wt(Lt),o=n??a,s=(0,L.useMemo)(()=>new Map(o.map(e=>[e.identifier.toUpperCase(),e.title])),[o]),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)(null),f=async(t,n)=>{d(null),r(await G7n(await fetch(v7(`/api/orders/${encodeURIComponent(e.id)}/items/${encodeURIComponent(t)}`,i),{method:`PATCH`,credentials:`include`,headers:await Ac(),body:JSON.stringify(n)})))},p=(e,t,n)=>{e.preventDefault(),e.stopPropagation(),c&&(f(c,{lane:t,order:n}).catch(e=>d(e instanceof Error?e.message:String(e))),l(null))},m=t=>{let n=t.lane===`A`?`B`:`A`,r=e.items.filter(e=>e.lane===n).length+1;f(t.issue,{lane:n,order:r}).catch(e=>d(e instanceof Error?e.message:String(e)))},h=async(e,t)=>{try{await f(e,t)}catch(e){throw d(e instanceof Error?e.message:String(e)),e}},g=async t=>{d(null);try{r(await G7n(await fetch(v7(`/api/orders/${encodeURIComponent(e.id)}/items/${encodeURIComponent(t)}`,i),{method:`DELETE`,credentials:`include`,headers:await Ac()})))}catch(e){d(e instanceof Error?e.message:String(e))}};return(0,z.jsxs)(`section`,{className:`grid gap-3 lg:grid-cols-2`,"aria-label":`Order book lane editor`,children:[[`A`,`B`].map(n=>{let r=e.items.filter(e=>e.lane===n).sort((e,t)=>e.order-t.order);return(0,z.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2 border-b border-border px-3 py-2`,children:[(0,z.jsxs)(`h2`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:[`Lane `,n]}),(0,z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n===`A`?`parallel · up to ${e.settings.laneAConcurrency}`:`strictly serial · one in flight`}),(0,z.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground`,children:[r.length,` items`]})]}),r.map(n=>(0,z.jsx)(W7n,{item:n,title:s.get(n.issue.toUpperCase()),state:K7n(e,n.issue,t),hasPrd:e.itemReadiness?.[n.issue]?.hasPrd??!0,onDragStart:l,onDrop:p,onSwapLane:m,onRequirementsChange:h,onRemove:e=>void g(e)},n.issue)),(0,z.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>p(e,n,r.length+1),className:`border-t border-dashed border-border px-3 py-2 text-center text-[11px] text-muted-foreground`,children:[`Drop issues here for Lane `,n]})]},n)}),u&&(0,z.jsx)(`p`,{className:`lg:col-span-2 text-xs text-destructive`,role:`alert`,children:u})]})}var J7n=[{status:`draft`,label:`Draft`},{status:`ready`,label:`Ready`},{status:`running`,label:`Running`},{status:`drained`,label:`Drained = run ends`},{status:`complete`,label:`Complete`}];function Y7n({status:e}){let t=J7n.findIndex(t=>t.status===e);return(0,z.jsx)(`nav`,{className:`flex flex-wrap items-center gap-1`,"aria-label":`Order book lifecycle`,children:J7n.map((e,n)=>{let r=n===t,i=n<t;return(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsxs)(`span`,{"aria-current":r?`step`:void 0,"data-state":r?`current`:i?`done`:`upcoming`,className:`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-[11px] font-medium ${r?`border-primary/50 bg-primary/10 text-foreground`:i?`border-success/30 bg-success/10 text-success`:`border-border bg-card text-muted-foreground`}`,children:[(0,z.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center rounded-full border border-current text-[9px]`,children:i?`✓`:n+1}),e.label]}),n<J7n.length-1&&(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`px-1 text-[10px] text-muted-foreground`,children:`→`})]},e.status)})})}function X7n(e){let t=e.issueId.toUpperCase(),n=e.book.items.find(e=>e.issue.toUpperCase()===t);if(!n){let n=e.offBook===!0;return{eligible:n,overrideUsed:n,...n?{}:{code:`off-book`,message:`Issue ${t} is not in active order book ${e.book.id}; work-agent dispatch is blocked. Retry with --off-book only for an intentional exception.`},conditions:[{key:`book-membership`,met:n,detail:n?`Issue ${t} is outside the book and the operator supplied --off-book.`:`Issue ${t} is not a member of ${e.book.id}.`}]}}let r=new Map(e.progress.items.map(e=>[e.issue.toUpperCase(),e.terminal]));for(let[t,n]of e.prerequisiteTerminal??[])r.has(t.toUpperCase())||r.set(t.toUpperCase(),n);let i=n.prereqs.find(e=>r.get(e.toUpperCase())!==!0),a=i===void 0,o=e.book.items.filter(n=>n.issue.toUpperCase()!==t&&e.inFlightIssues.has(n.issue.toUpperCase())),s=n.lane===`B`?o.find(e=>e.lane===`B`):void 0,c=o.filter(e=>e.lane===`A`).length,l=n.lane===`B`?s===void 0:c<e.book.settings.laneAConcurrency,u=e.book.settings.posture===`open`,d=!n.reVerify,f=[{key:`book-membership`,met:!0,detail:`${t} is a member of ${e.book.id}.`},{key:`pickup-posture`,met:u,detail:u?`Order-book pickup posture is OPEN.`:`Order-book pickup posture is DRAIN.`},{key:`lane-slot`,met:l,detail:n.lane===`B`?s?`Lane B is occupied by ${s.issue}.`:`Lane B has no issue in flight.`:`${c}/${e.book.settings.laneAConcurrency} Lane A slots are in flight.`},{key:`prerequisites`,met:a,detail:i?`Prerequisite ${i.toUpperCase()} is not terminal.`:`Every prerequisite is landed or parked.`},{key:`prd-reverified`,met:d,detail:d?`No PRD re-verification is pending.`:`${t} requires PRD re-verification before dispatch.`}];return u?i?{eligible:!1,overrideUsed:!1,code:`prerequisite-unmet`,message:`Issue ${t} cannot start because prerequisite ${i.toUpperCase()} has not landed or been parked.`,conditions:f}:d?s?{eligible:!1,overrideUsed:!1,code:`lane-b-busy`,message:`Issue ${t} cannot start in Lane B because ${s.issue} is still in flight; Lane B allows one active issue at a time.`,conditions:f}:n.lane===`A`&&!l?{eligible:!1,overrideUsed:!1,code:`lane-a-full`,message:`Issue ${t} cannot start in Lane A because ${c} issues are already in flight and laneAConcurrency is ${e.book.settings.laneAConcurrency}.`,conditions:f}:{eligible:!0,overrideUsed:!1,conditions:f}:{eligible:!1,overrideUsed:!1,code:`reverify-required`,message:`Issue ${t} cannot start until its PRD has been re-verified against current main.`,conditions:f}:{eligible:!1,overrideUsed:!1,code:`book-draining`,message:`Issue ${t} cannot start because order book ${e.book.id} is in DRAIN posture; no new book items may dispatch.`,conditions:f}}function Z7n(e,t){return t?`closed`:e?e.state===`merged`?`merged`:e.state===`closed`?`closed`:e.state===`planned`?`planning`:e.state===`in-review`||e.state===`changes-requested`||e.state===`ready`?`review`:e.state===`working`?`working`:`queued`:`queued`}function Q7n(e){return e===`planning`||e===`working`?`border-l-info bg-info/[0.08] text-info`:e===`review`?`border-l-warning bg-warning/[0.08] text-warning-foreground`:e===`merged`||e===`closed`?`border-l-success bg-success/[0.08] text-success`:`border-l-transparent text-muted-foreground`}var $7n={"pickup-posture":`Pickup posture`,"lane-slot":`Serial B-slot free`,prerequisites:`Prereqs landed`,"prd-reverified":`PRD re-verified`};function e9n({book:e}){let t=Wt(e=>e.derivedIssueStateByIssueId),n=(0,L.useMemo)(()=>new Map(Object.values(t).map(e=>[e.issueId.toUpperCase(),e])),[t]),r=(0,L.useMemo)(()=>new Set(e.items.map(e=>n.get(e.issue.toUpperCase())).filter(e=>!!e&&eEe.has(e.state)).map(e=>e.issueId.toUpperCase())),[e.items,n]),i=(0,L.useMemo)(()=>new Map(Object.entries(e.prerequisiteTerminal??{})),[e.prerequisiteTerminal]),a=e.items.map(t=>{let n=e.progress.items?.find(e=>e.issue.toUpperCase()===t.issue.toUpperCase());return{issue:t.issue,lane:t.lane,order:t.order,closed:n?.closed??!1,parked:n?.parked??!1,terminal:n?.terminal??!1}});return(0,z.jsxs)(`section`,{className:`grid gap-3`,"aria-label":`Order book progress`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,z.jsx)(`h2`,{className:`font-medium text-foreground`,children:`Live checklist`}),(0,z.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[e.progress.landed,`/`,e.progress.total,` landed`]})]}),(0,z.jsxs)(`div`,{className:`mt-3 overflow-hidden rounded-lg border border-border`,children:[e.items.map(t=>{let o=a.find(e=>e.issue===t.issue),s=Z7n(n.get(t.issue.toUpperCase()),o.terminal),c=X7n({book:e,progress:{bookId:e.id,total:e.progress.total,landed:e.progress.landed,drained:e.progress.drained,items:a},issueId:t.issue,inFlightIssues:r,prerequisiteTerminal:i}),l=s===`queued`;return(0,z.jsxs)(`div`,{"data-live-status":s,className:`border-l-2 border-t border-border px-3 py-2 first:border-t-0 ${Q7n(s)}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,z.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[t.lane,t.order,` · book`]}),(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:t.issue}),(0,z.jsx)(`span`,{className:`ml-auto text-[10px] uppercase tracking-wide`,children:s})]}),l&&(0,z.jsx)(`div`,{className:`mt-2 grid gap-1 sm:grid-cols-2`,"aria-label":`${t.issue} eligibility`,children:c.conditions.filter(e=>e.key!==`book-membership`).map(e=>(0,z.jsxs)(`span`,{title:e.detail,className:`text-[10px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:e.met?`text-success`:`text-destructive`,children:e.met?`✓`:`✕`}),` `,$7n[e.key]??e.key]},e.key))})]},t.issue)}),e.items.length===0&&(0,z.jsx)(`p`,{className:`p-4 text-xs text-muted-foreground`,children:`No items in this book.`})]})]}),e.progress.drained&&(0,z.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg border border-success/30 bg-success/[0.08] p-4 text-xs text-success`,role:`status`,children:(0,z.jsx)(`span`,{children:`✓ Order book drained — every item has landed.`})})]})}var y7={drain:`Operator paused new pickup.`,open:`Operator reopened pickup.`},t9n={drain:`In-flight items will finish. Nothing new dispatches from this book until it is reopened.`,open:`Eligible items will start dispatching again — Lane A up to its concurrency, Lane B one at a time in order.`},n9n={open:`Dispatch is live: eligible items start when a slot frees, Lane B strictly in order.`,drain:`Draining: in-flight items finish, nothing new starts until reopened.`},r9n={drain:`Switch to drain`,open:`Reopen pickup`},i9n={open:`border-info/[0.32] bg-info/[0.08] text-info-foreground`,drain:`border-warning/[0.32] bg-warning/[0.08] text-warning-foreground`},a9n=1600;function o9n(e){return`${String(e.getUTCHours()).padStart(2,`0`)}:${String(e.getUTCMinutes()).padStart(2,`0`)}:${String(e.getUTCSeconds()).padStart(2,`0`)}Z`}function s9n(e){let t=new Date(e);return`${t.toLocaleString(`en-US`,{month:`short`,day:`numeric`,timeZone:`UTC`})}, ${String(t.getUTCHours()).padStart(2,`0`)}:${String(t.getUTCMinutes()).padStart(2,`0`)}Z`}function c9n(e,t){return e===`open`&&t===y7.drain||e===`drain`&&t===y7.open}function l9n({save:e}){return e.state===`saving`?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground`,role:`status`,children:[(0,z.jsx)(is,{size:10,className:`animate-spin`}),`Saving…`]}):e.state===`saved`?(0,z.jsx)(`span`,{className:`text-[10px] text-success`,role:`status`,children:`Saved ✓`}):e.state===`error`?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-destructive`,role:`alert`,children:[`Couldn't save`,(0,z.jsx)(`button`,{type:`button`,onClick:e.retry,className:`underline`,children:`Retry`})]}):null}var u9n=1,d9n=8,f9n=500,p9n=550,m9n=/\.md$/i;function h9n({settings:e,onChange:t}){let[n,r]=(0,L.useState)(e.laneAConcurrency),[i,a]=(0,L.useState)(e.briefOverlay??``),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)({posture:{state:`idle`},lane:{state:`idle`},brief:{state:`idle`}}),[m,h]=(0,L.useState)(null),g=(0,L.useRef)({}),_=(0,L.useRef)(null),v=(0,L.useRef)(),y=(0,L.useRef)(),b=(0,L.useRef)(e.briefOverlay??``);(0,L.useEffect)(()=>r(e.laneAConcurrency),[e.laneAConcurrency]),(0,L.useEffect)(()=>a(e.briefOverlay??``),[e.briefOverlay]);let x=i.trim(),S=x===``?{text:`None — items run with their PRDs alone.`,tone:`muted`}:m9n.test(x)?{text:`Appended to every item's kickoff brief.`,tone:`success`}:{text:`Not a markdown file — expected a repo-relative .md path.`,tone:`error`};(0,L.useEffect)(()=>{o&&_.current?.select()},[o]);let C=(e,n)=>{clearTimeout(g.current[e]),p(t=>({...t,[e]:{state:`saving`}})),t(n).then(()=>{h(new Date),p(t=>({...t,[e]:{state:`saved`}})),g.current[e]=setTimeout(()=>p(t=>({...t,[e]:{state:`idle`}})),a9n)},()=>p(t=>({...t,[e]:{state:`error`,retry:()=>C(e,n)}})))},w=e=>{a(e),clearTimeout(y.current),y.current=setTimeout(()=>{let t=e.trim();if(t===``){b.current!==``&&(b.current=``,C(`brief`,{briefOverlay:``}));return}m9n.test(t)&&t!==b.current&&(b.current=t,C(`brief`,{briefOverlay:t}))},p9n)},T=e=>{r(t=>{let n=Math.min(d9n,Math.max(u9n,t+e));return clearTimeout(v.current),v.current=setTimeout(()=>C(`lane`,{laneAConcurrency:n}),f9n),n})};return(0,z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,"aria-label":`Run settings`,children:[(0,z.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Run settings`}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex-1`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Lane A concurrency`}),(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`How many parallel-safe Lane A items may run at once. Lane B ignores this — it is always one item at a time, in order.`})]}),(0,z.jsx)(l9n,{save:f.lane}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":`Decrease Lane A concurrency`,disabled:n<=u9n,onClick:()=>T(-1),className:`rounded-md border border-input px-2 py-1 text-foreground disabled:opacity-40`,children:`−`}),(0,z.jsx)(`span`,{className:`w-4 text-center font-mono tabular-nums text-foreground`,children:n}),(0,z.jsx)(`button`,{type:`button`,"aria-label":`Increase Lane A concurrency`,disabled:n>=d9n,onClick:()=>T(1),className:`rounded-md border border-input px-2 py-1 text-foreground disabled:opacity-40`,children:`+`})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:`Brief overlay`}),(0,z.jsx)(l9n,{save:f.brief}),(0,z.jsx)(`input`,{"aria-label":`Brief overlay`,value:i,onChange:e=>w(e.target.value),placeholder:`docs/briefs/refactor-p3.md`,className:`min-w-56 rounded-md border border-input bg-background px-2 py-1 font-mono text-[11px] text-foreground`})]}),(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Markdown appended to every item's kickoff brief for this run.`}),(0,z.jsx)(`p`,{className:`text-[11px] ${S.tone===`error`?`text-destructive`:S.tone===`success`?`text-success`:`text-muted-foreground`}`,children:S.text})]}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:`Pickup posture`}),(0,z.jsx)(l9n,{save:f.posture}),(0,z.jsx)(`div`,{className:`flex gap-1`,children:[`open`,`drain`].map(t=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":e.posture===t,onClick:()=>{t!==e.posture&&(s(t),d(y7[t]))},className:`rounded-md border px-2 py-1 text-[10px] uppercase tracking-wide ${e.posture===t?i9n[t]:`border-border text-muted-foreground`}`,children:t},t))})]}),(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:n9n[e.posture]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`capitalize text-foreground`,children:e.posture}),(0,z.jsx)(`span`,{children:`· set by`}),(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.postureSetBy??`operator`}),e.postureSetAt&&(0,z.jsxs)(`span`,{children:[`· `,s9n(e.postureSetAt)]}),(0,z.jsxs)(`span`,{children:[`— "`,e.postureReason??`No reason recorded.`,`"`]}),c9n(e.posture,e.postureReason)&&(0,z.jsx)(`span`,{className:`rounded-sm border border-warning/[0.32] bg-warning/[0.08] px-1 py-0.5 text-[10px] uppercase text-warning-foreground`,title:`This reason was recorded before the current posture was set — it describes a previous state.`,children:`stale reason`})]}),o&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-2 ${i9n[o]}`,children:[(0,z.jsx)(`p`,{className:`text-[11px]`,children:t9n[o]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Why? Recorded on the run and shown to anyone reading this book.`}),(0,z.jsx)(`input`,{ref:_,"aria-label":`Posture reason`,value:u,onChange:e=>d(e.target.value),className:`rounded-md border border-input bg-background px-2 py-1 text-[11px] text-foreground`})]}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>{C(`posture`,{posture:o,postureReason:u.trim()||y7[o]}),s(null)},className:`rounded-md border px-2 py-1 text-[10px] uppercase tracking-wide ${i9n[o]}`,children:r9n[o]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>s(null),className:`rounded-md border border-border px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Cancel`})]})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:`Off-book pickup`}),(0,z.jsx)(`button`,{type:`button`,"aria-expanded":c,onClick:()=>l(e=>!e),className:`text-[11px] text-muted-foreground underline`,children:`how the override works`})]}),(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`🔒 Blocked while this book runs — fixed policy, not a preference.`}),c&&(0,z.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`While a run is active the flywheel only starts issues that are in this book. Starting anything else requires`,` `,(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:`pan start <id> --off-book`}),`, which succeeds but is written to the run record with who ran it and when — an audited exception, not a setting.`]})]})]}),(0,z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-border pt-2 text-[10px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Changes save automatically`}),(0,z.jsx)(`span`,{className:`font-mono`,children:m?`last saved ${o9n(m)}`:`last saved —`})]})]})}function g9n({status:e,blocks:t,warns:n,starting:r=!1,onPreview:i,onQueue:a,onStart:o}){let s=t.length>0,c=e===`draft`,l=e===`ready`,u=r?c?`Queueing…`:`Starting…`:c?`Queue book`:l?`Start run`:e===`running`?`Run active`:`Book complete`;return(0,z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,"aria-label":`Start validation`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Start validation`}),(0,z.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:s?`${t.length} blocking`:`Ready to start`})]}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[t.map(e=>(0,z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 p-2 text-xs`,role:`alert`,children:[(0,z.jsx)(xo,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive`}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.issue}),` `,(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.message})]})]},`${e.code}-${e.issue}`)),n.map(e=>(0,z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/[0.32] bg-warning/[0.08] p-2 text-xs`,children:[(0,z.jsx)(Ts,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning-foreground`}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.issue}),` `,(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.message})]})]},`${e.code}-${e.issue}`)),!s&&n.length===0&&(0,z.jsx)(`p`,{className:`text-xs text-success`,children:`✓ No blocking findings.`})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:i,className:`flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,z.jsx)(No,{className:`h-3.5 w-3.5`}),` Preview brief`]}),(0,z.jsxs)(`button`,{type:`button`,disabled:s||r||!c&&!l,title:s?`Resolve every blocking finding before queueing or starting this book`:void 0,onClick:c?a:o,className:`flex items-center gap-1.5 rounded-md border border-primary/50 bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:[(0,z.jsx)(ds,{className:`h-3.5 w-3.5`}),` `,u]})]})]})}async function b7(e){let t=await e.json().catch(()=>null);return typeof t?.error==`string`?t.error:`Request failed (${e.status})`}function _9n(){return new URLSearchParams(window.location.search).get(`project`)}function v9n(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)(`setup`),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(_9n),[v,y]=(0,L.useState)(null),{data:b=[]}=F({queryKey:[`registered-projects`],queryFn:async()=>{let e=await fetch(`/api/registered-projects`);if(!e.ok)throw Error(`Failed to fetch registered projects`);return e.json()},staleTime:6e4}),x=(0,L.useRef)(0),S=(0,L.useCallback)(async()=>{let e=++x.current;a(!0),s(null);try{let n=await fetch(v7(`/api/orders`,g));if(!n.ok)throw Error(await b7(n));let i=await n.json();if(x.current!==e)return;t(i.books),i.project&&y(i.project),r(e=>e&&i.books.some(t=>t.id===e)?e:i.books.find(e=>e.status===`running`)?.id??i.books.find(e=>e.status===`ready`||e.status===`draft`)?.id??i.books[0]?.id??null)}catch(t){if(x.current!==e)return;s(t instanceof Error?t.message:String(t))}finally{x.current===e&&a(!1)}},[g]),C=(0,L.useCallback)(e=>{_(e),r(null),t([]),l(null),h(null);let n=new URLSearchParams(window.location.search);n.set(`project`,e),window.history.replaceState(null,``,`${window.location.pathname}?${n.toString()}`)},[]),w=g??v,T=(0,L.useMemo)(()=>{let e=b.map(e=>e.key);return w&&!e.includes(w)?[w,...e]:e},[b,w]);(0,L.useEffect)(()=>{S()},[S]);let E=(0,L.useMemo)(()=>e.find(e=>e.id===n)??null,[e,n]),D=(0,L.useCallback)(e=>{t(t=>t.map(t=>t.id===e.id?e:t))},[]);(0,L.useEffect)(()=>{if(!n)return;let e=!0;return fetch(v7(`/api/orders/${encodeURIComponent(n)}`,g)).then(async e=>{if(!e.ok)throw Error(await b7(e));return e.json()}).then(t=>{e&&D(t)}).catch(t=>{e&&h(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[n,D,g]);let O=async e=>{let n=await fetch(v7(`/api/orders`,g),{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({name:e})});if(!n.ok)throw Error(await b7(n));let i=await n.json();t(e=>[...e,i]),r(i.id)},k=async e=>{if(!E)return;let t=await fetch(v7(`/api/orders/${encodeURIComponent(E.id)}`,g),{method:`PATCH`,credentials:`include`,headers:await Ac(),body:JSON.stringify(e)});if(!t.ok)throw Error(await b7(t));D(await t.json())},A=async e=>{await k({settings:e})},j=async()=>{if(E){p(!0),h(null);try{await k({status:`ready`}),h(`${E.name} is queued and ready to start.`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},ee=async()=>{if(!E)return;h(null);let e=await fetch(v7(`/api/orders/${encodeURIComponent(E.id)}/preview-brief`,g));if(!e.ok){h(await b7(e));return}let t=await e.json();l(t.brief)},M=async()=>{if(E){p(!0),h(null);try{let e=await fetch(v7(`/api/orders/${encodeURIComponent(E.id)}/start`,g),{method:`POST`,credentials:`include`,headers:await Ac()});if(!e.ok)throw Error(await b7(e));let t=await e.json();h(`Started ${t.runId} from ${E.name}.`),await S()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,z.jsxs)(`main`,{className:`flex h-full w-full flex-col overflow-hidden bg-background font-medium`,"aria-label":`Order Book page`,children:[(0,z.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-border px-5 py-3`,children:[(0,z.jsx)(co,{className:`h-4 w-4 text-muted-foreground`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-sm font-medium text-foreground`,children:`Order Book`}),(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Operator special orders executed with lane semantics`})]}),(0,z.jsxs)(`label`,{className:`ml-2 flex items-center gap-1.5 border-l border-border pl-3 text-[11px] text-muted-foreground`,children:[`Project`,(0,z.jsxs)(`select`,{"aria-label":`Order book project`,value:w??``,onChange:e=>C(e.target.value),className:`rounded-sm border border-border bg-muted/40 px-1.5 py-0.5 font-mono text-[11px] text-foreground`,children:[!w&&(0,z.jsx)(`option`,{value:``,children:`Loading…`}),T.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]}),E&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`ml-2 border-l border-border pl-3 font-mono text-[11px] text-muted-foreground`,children:E.id}),(0,z.jsx)(`span`,{className:`rounded-sm border border-border bg-muted/40 px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:E.status}),(0,z.jsx)(`div`,{className:`ml-auto flex rounded-md border border-border p-0.5 text-[10px]`,"aria-label":`Order book view`,children:[`setup`,`progress`].map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded-sm px-2.5 py-1 capitalize ${u===e?`bg-muted text-foreground`:`text-muted-foreground`}`,children:e},e))}),(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[u===`setup`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:E.progress.landed}),`/`,(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:E.progress.total}),` landed`]}):`Live progress below`,E.runId&&(0,z.jsxs)(z.Fragment,{children:[` · run `,(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:E.runId})]})]})]})]}),(0,z.jsx)(H7n,{books:e,selectedId:n,onSelect:r,onCreate:O}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto p-5`,children:[i&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,children:[(0,z.jsx)(is,{className:`h-4 w-4 animate-spin`}),` Loading order books…`]}),o&&(0,z.jsxs)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,role:`alert`,children:[o,(0,z.jsx)(`button`,{type:`button`,onClick:()=>void S(),className:`ml-3 underline`,children:`Retry`})]}),!i&&!o&&!E&&(0,z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center text-sm text-muted-foreground`,children:`No order books yet. Create one to assemble a campaign.`}),!i&&E&&(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-6xl flex-col gap-4`,children:[(0,z.jsx)(Y7n,{status:E.status}),u===`setup`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`section`,{"data-testid":`order-book-posture`,"data-posture":E.settings.posture,className:`flex flex-wrap items-center gap-3 rounded-lg border px-4 py-3 ${E.settings.posture===`drain`?`border-warning/[0.32] bg-warning/[0.08]`:`border-border bg-card`}`,children:[(0,z.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:`Pickup posture`}),(0,z.jsx)(`span`,{className:`rounded-sm border px-2 py-1 text-[11px] font-medium ${E.settings.posture===`drain`?`border-warning/[0.32] bg-warning/[0.08] text-warning-foreground`:`border-border bg-muted/40 text-foreground`}`,children:E.settings.posture.toUpperCase()}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E.settings.posture===`drain`?`Drain set by ${E.settings.postureSetBy??`operator`}${E.settings.postureSetAt?` on ${E.settings.postureSetAt.slice(0,10)}`:``} — ${E.settings.postureReason??`No reason recorded.`}`:`Open posture permits eligible order-book items to dispatch; no operator hold is active.`})]}),(0,z.jsx)(q7n,{book:E,onBookChange:D,project:g}),(0,z.jsxs)(`section`,{className:`grid gap-3 lg:grid-cols-2`,"aria-label":`Add issues to order book`,children:[(0,z.jsx)(z7n,{book:E,books:e,onBookChange:D,project:g}),(0,z.jsx)(B7n,{book:E,onBookChange:D,project:g})]}),(0,z.jsxs)(`section`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,z.jsx)(h9n,{settings:E.settings,onChange:A},E.id),(0,z.jsx)(g9n,{status:E.status,blocks:E.validation?.blocks??[],warns:E.validation?.warns??[],starting:f,onPreview:()=>void ee(),onQueue:()=>void j(),onStart:()=>void M()})]}),m&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:m}),c&&(0,z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card p-4`,"aria-label":`Brief preview`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,z.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Brief preview`}),(0,z.jsx)(`button`,{type:`button`,className:`ml-auto text-xs text-muted-foreground hover:text-foreground`,onClick:()=>l(null),children:`Close`})]}),(0,z.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap font-mono text-[11px] text-muted-foreground`,children:c})]})]}):(0,z.jsx)(e9n,{book:E})]})]})]})}var y9n={info:`badge-bg-info badge-border-info text-info-foreground`,warning:`badge-bg-warning badge-border-warning text-warning-foreground`,destructive:`badge-bg-destructive badge-border-destructive text-destructive-foreground`,success:`badge-bg-success badge-border-success text-success`,neutral:`badge-bg-muted badge-border-muted text-muted-foreground`};function x7({tone:e,children:t,title:n,testId:r}){return(0,z.jsx)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap border px-2 py-0.5 text-[11px] font-medium ${y9n[e]}`,title:n,"data-testid":r,"data-tone":e,children:t})}function b9n({label:e,checked:t,disabled:n,title:r,onChange:i}){return(0,z.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":e,disabled:n,title:r,onClick:()=>i(!t),className:`flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground disabled:opacity-50`,children:[(0,z.jsx)(`span`,{className:`relative h-4 w-7 rounded-full border transition-colors ${t?`border-primary/60 bg-primary/25`:`border-border bg-muted`}`,children:(0,z.jsx)(`span`,{className:`absolute top-0.5 h-2.5 w-2.5 rounded-full transition-all ${t?`left-[14px] bg-primary`:`left-0.5 bg-muted-foreground`}`})}),e]})}function S7({label:e,ariaLabel:t,actions:n,children:r}){return(0,z.jsxs)(`section`,{className:`border-b border-border px-4 py-3`,"aria-label":t??e,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:e}),n]}),r]})}function C7({title:e,detail:t}){return(0,z.jsx)(`div`,{className:`flex min-h-[160px] items-center justify-center rounded-md border border-dashed border-border p-6 text-center`,children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e}),t&&(0,z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:t})]})})}var x9n=[7,30,90],S9n={green:`success`,yellow:`warning`,red:`destructive`,insufficient_data:`neutral`},C9n={green:`Green`,yellow:`Yellow`,red:`Red`,insufficient_data:`No data`},w9n={up:`↗ up`,down:`↘ down`,flat:`→ flat`};async function T9n(e){let t=await fetch(`/api/flywheel/stats?window=${e}`);if(!t.ok)throw Error(`GET /api/flywheel/stats → ${t.status}`);let n=await t.json();if(!n?.window?.since||!n.criteria?.c1_bugRate)throw Error(`GET /api/flywheel/stats returned a body without window/criteria`);return n}function E9n({label:e,value:t,status:n,trend:r,dataSufficient:i,since:a,detail:o,explanation:s}){return(0,z.jsxs)(`section`,{role:`region`,"aria-label":`${e} metric`,className:`rounded-md border border-border bg-card p-3`,title:s,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:e}),i?(0,z.jsx)(x7,{tone:S9n[n],children:C9n[n]}):(0,z.jsx)(x7,{tone:`neutral`,children:`Collecting`})]}),(0,z.jsx)(`div`,{className:`mt-2 text-lg font-medium text-foreground`,"data-testid":`flywheel-stat-${e}`,children:i?t:`collecting since ${a}`}),(0,z.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:o}),(0,z.jsx)(`span`,{"aria-label":`Trend: ${r}`,children:w9n[r]})]})]})}function D9n(){let[e,t]=(0,L.useState)(30),{data:n,error:r,isLoading:i}=F({queryKey:[`flywheel`,`stats`,e],queryFn:()=>T9n(e),refetchInterval:6e4});return(0,z.jsxs)(`div`,{className:`space-y-3`,"aria-label":`Flywheel stats`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`flex rounded-md border border-border p-0.5 text-[11px]`,role:`group`,"aria-label":`Stats window`,children:x9n.map(n=>(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":e===n,onClick:()=>t(n),className:`rounded-sm px-2.5 py-1 ${e===n?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[n,`d`]},n))}),n&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`since `,n.window.since.slice(0,10)]})]}),i&&!n?(0,z.jsx)(`div`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`Loading flywheel stats…`}):n?(0,z.jsxs)(z.Fragment,{children:[r&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,role:`status`,children:`Refresh failed — showing the last good data.`}),(0,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(E9n,{label:`Discovery rate`,value:n.criteria.c1_bugRate.value===null?`—`:n.criteria.c1_bugRate.value.toFixed(2),status:n.criteria.c1_bugRate.status,trend:n.criteria.c1_bugRate.trend,dataSufficient:n.criteria.c1_bugRate.dataSufficient,since:n.window.since.slice(0,10),detail:`${n.criteria.c1_bugRate.count} bugs / ${n.criteria.c1_bugRate.denominator} merged PRs`,explanation:`Substrate bugs filed in the window divided by PRs merged in the window. Green under 0.1, yellow under 0.3.`}),(0,z.jsx)(E9n,{label:`P0 bugs`,value:String(n.criteria.c2_p0Bugs.value),status:n.criteria.c2_p0Bugs.status,trend:n.criteria.c2_p0Bugs.trend,dataSufficient:n.criteria.c2_p0Bugs.dataSufficient,since:n.window.since.slice(0,10),detail:`labelled P0`,explanation:`P0 substrate bugs filed in the window. Green at 0, yellow at 1–2.`})]}),(0,z.jsxs)(`section`,{"aria-label":`Substrate bugs`,children:[(0,z.jsxs)(`h3`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:[`Substrate bugs · `,n.bugs.length]}),n.bugs.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`None filed in this window.`}):(0,z.jsx)(`ul`,{className:`space-y-1 text-xs`,children:n.bugs.map(e=>(0,z.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,z.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`#`,e.number]}),(0,z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.severity}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.closedAt?`closed`:`open`})]},e.number))})]})]}):(0,z.jsxs)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:[`Failed to load flywheel stats: `,r instanceof Error?r.message:`unknown error`]})]})}var w7=30;function O9n(e){return typeof e==`number`?String(e):`—`}function T7({label:e,value:t,testId:n,title:r}){return(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 border-l border-border pl-3 first:border-l-0 first:pl-0`,title:r,children:[(0,z.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:`truncate text-base font-medium text-foreground`,"data-testid":n,children:t})]})}function k9n({orderBook:e}){let t=F({queryKey:[`flywheel`,`stats`,w7],queryFn:()=>T9n(w7),refetchInterval:6e4}),{sections:n}=Wj(!0),r=t.data,i=O9n(r?.criteria?.c1_bugRate?.denominator),a=Array.isArray(r?.bugs)?String(r.bugs.filter(e=>e.closedAt).length):`—`;return(0,z.jsxs)(`section`,{"aria-label":`Flywheel headline`,className:`flex items-start gap-3 border-b border-border pb-3`,children:[(0,z.jsx)(T7,{label:`PRs merged · ${w7}d`,value:i,testId:`flywheel-headline-prs`,title:`Pull requests merged in the last ${w7} days — the denominator of the discovery rate.`}),(0,z.jsx)(T7,{label:`Bugs fixed`,value:a,testId:`flywheel-headline-fixed`,title:`Substrate bugs filed in the last ${w7} days that have since closed. A bug filed before the window is not counted here even if it closed inside it.`}),e&&(0,z.jsx)(T7,{label:`Order book`,value:`${e.landed}/${e.total}`,testId:`flywheel-headline-orderbook`,title:`${e.name} (${e.id}) — items landed of items ordered.`}),(0,z.jsx)(T7,{label:`Awaiting UAT`,value:String(yHt(n).features),testId:`flywheel-headline-uat`,title:`Features queued on the merge train, across every project it knows.`})]})}async function A9n(){let e=await fetch(`/api/orders`);if(!e.ok)throw Error(`GET /api/orders → ${e.status}`);return e.json()}function j9n({bookId:e}){let{data:t}=F({queryKey:[`flywheel`,`orders`],queryFn:A9n,refetchInterval:15e3}),n=t?.books??[],r=(e?n.find(t=>t.id===e):void 0)??n.find(e=>e.status===`running`);if(!r)return null;let i=t?.project?`/orders?project=${encodeURIComponent(t.project)}`:`/orders`;return(0,z.jsx)(S7,{label:`Order book · ${r.name}`,ariaLabel:`Running order book`,actions:(0,z.jsx)(`a`,{href:i,className:`text-[11px] text-primary hover:underline`,children:`Open in Order Book`}),children:(0,z.jsx)(e9n,{book:r})})}async function M9n(e){let t=await fetch(e);if(!t.ok)throw Error(`GET ${e} → ${t.status}`);return t.json()}function N9n(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString()} ${t.toLocaleTimeString()}`}function P9n({endpoint:e,queryKey:t,subject:n,emptyTitle:r,emptyDetail:i,markdownTestId:a}){let{data:o,error:s,isLoading:c}=F({queryKey:t,queryFn:()=>M9n(e),refetchInterval:1e4});if(c&&!o)return(0,z.jsxs)(`div`,{className:`py-6 text-center text-sm text-muted-foreground`,children:[`Loading `,n,`…`]});if(s&&!o)return(0,z.jsxs)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:[`Failed to load `,n,`: `,s instanceof Error?s.message:String(s)]});if(!o?.exists||!o.content)return(0,z.jsx)(C7,{title:r,detail:i});let l=N9n(o.lastModified);return(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-baseline justify-between gap-2 border-b border-border pb-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:o.path}),l&&(0,z.jsxs)(`span`,{children:[`Last modified `,l]})]}),(0,z.jsx)(`article`,{className:`prose prose-sm max-w-none dark:prose-invert`,"data-testid":a,children:(0,z.jsx)(Fc,{remarkPlugins:[fn],children:o.content})})]})}var F9n=({children:e})=>(0,z.jsx)(`code`,{className:`rounded-sm bg-muted px-1.5 py-0.5 font-mono text-xs`,children:e});function I9n(){return(0,z.jsx)(P9n,{endpoint:`/api/flywheel/state`,queryKey:[`flywheel`,`state`],subject:`flywheel state`,emptyTitle:`No flywheel state yet.`,emptyDetail:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(F9n,{children:`.pan/flywheel/state.md`}),` is written and committed by the loop the first time it records a substrate fix or a learning worth keeping across runs.`]}),markdownTestId:`flywheel-state-markdown`})}function L9n(){return(0,z.jsx)(P9n,{endpoint:`/api/flywheel/report`,queryKey:[`flywheel`,`report`],subject:`flywheel report`,emptyTitle:`No report yet`,emptyDetail:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(F9n,{children:`.pan/flywheel/report.md`}),` is written when the loop stops with a report, or when Report is pressed while it runs.`]}),markdownTestId:`flywheel-report-markdown`})}var R9n={live:`info`,breathing:`neutral`,stalled:`destructive`};function z9n(e,t,n){return e===`live`?`live`:e===`breathing`?`last tick ${Sp(t,n)}`:`stalled — last tick ${Sp(t,n)}`}function B9n({freshness:e,at:t,nowMs:n}){return(0,z.jsx)(x7,{tone:R9n[e],testId:`flywheel-freshness`,children:z9n(e,t,n)})}var V9n={"needs-you":`warning`,stuck:`destructive`,"api-error":`destructive`},H9n={working:`info`,blocked:`warning`};function U9n(e){return e.inFlightSource===`tick`?`${e.inFlight.filter(e=>e.inTick).length} in flight (loop)`:`${e.inFlight.length} feature workspaces`}function W9n({status:e,unreachable:t,nowMs:n,onNavigateIssue:r}){if(t&&!e)return(0,z.jsx)(C7,{title:`Can't reach the server — retrying`,detail:`The flywheel's state is unknown, not gone. This pane retries every few seconds.`});if(!e)return(0,z.jsx)(`div`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`Loading flywheel status…`});let i=e.conversation,a=e.lastTick;return(0,z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`flywheel-status-pane`,children:[t&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,role:`status`,children:`Can't reach the server — retrying. Showing the last status.`}),(0,z.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-xs`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Run`}),(0,z.jsx)(`dd`,{className:`text-foreground`,"data-testid":`flywheel-run-state`,children:e.run}),i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Conversation`}),(0,z.jsxs)(`dd`,{className:`font-mono text-foreground`,children:[i.name,` · `,i.harness??`—`,` · `,i.model??`—`]})]}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Project`}),(0,z.jsx)(`dd`,{className:`truncate font-mono text-foreground`,title:e.projectRoot,children:e.projectRoot}),e.orderBook&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Order book`}),(0,z.jsxs)(`dd`,{className:`text-foreground`,"data-testid":`flywheel-status-order-book`,children:[e.orderBook.name,` `,(0,z.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`(`,e.orderBook.id,`)`]}),` · `,e.orderBook.landed,`/`,e.orderBook.total,` landed`]})]})]}),e.run===`idle`?(0,z.jsx)(C7,{title:(0,z.jsxs)(z.Fragment,{children:[`No flywheel running — Start it from the conversation pane's toolbar, or run `,(0,z.jsx)(`code`,{className:`rounded-sm bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`pan flywheel start`})]}),detail:`Nothing is stored between runs: this pane fills in from the loop's tick markers once it starts.`}):e.run===`paused`?(0,z.jsx)(C7,{title:`Paused — Resume to continue`,detail:`The conversation and its transcript are kept. Resume respawns it and re-sends /pan-flywheel.`}):a?null:(0,z.jsx)(C7,{title:`Running — waiting for the first tick`,detail:`The loop prints a flywheel-tick line at the end of every tick.`}),a&&(0,z.jsxs)(`section`,{"aria-label":`Last tick`,className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,z.jsxs)(`span`,{className:`text-foreground`,"data-testid":`flywheel-last-tick`,children:[`tick `,a.tick,` · `,a.phase,` · `,a.pick?(0,z.jsx)(`span`,{className:`font-mono`,children:a.pick}):`no pick`]}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,title:a.at,children:Sp(a.at,n)}),e.freshness&&e.run===`running`&&(0,z.jsx)(B9n,{freshness:e.freshness,at:a.at,nowMs:n})]}),a.needsYou&&(0,z.jsxs)(`div`,{className:`border-l-2 border-warning bg-warning/[0.08] px-3 py-2 text-sm text-foreground`,role:`note`,"data-testid":`flywheel-needs-you`,children:[(0,z.jsx)(`span`,{className:`mr-2 text-[11px] font-medium uppercase tracking-wider text-warning-foreground`,children:`Needs you`}),a.needsYou]})]}),(0,z.jsxs)(`section`,{"aria-label":`In-flight issues`,children:[(0,z.jsx)(`h3`,{className:`mb-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:U9n(e)}),e.inFlight.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No feature workspaces in this project.`}):(0,z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,z.jsx)(`thead`,{className:`text-left text-muted-foreground`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Issue`}),(0,z.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`State`}),(0,z.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`PR`}),(0,z.jsx)(`th`,{className:`py-1 font-medium`,children:`Last journal`})]})}),(0,z.jsx)(`tbody`,{children:e.inFlight.map(e=>(0,z.jsxs)(`tr`,{className:`border-t border-border/60 align-top`,"data-testid":`flywheel-inflight-${e.issueId}`,"data-attention":e.attention,children:[(0,z.jsxs)(`td`,{className:`py-1.5 pr-2`,children:[(0,z.jsx)(`button`,{type:`button`,className:`whitespace-nowrap font-mono text-foreground hover:underline`,onClick:()=>r?.(e.issueId),children:e.issueId}),e.title&&(0,z.jsx)(`span`,{className:`block max-w-[18rem] truncate text-muted-foreground`,title:e.title,"data-testid":`flywheel-title-${e.issueId}`,children:e.title}),e.trackerUnknown&&(0,z.jsx)(`span`,{className:`mt-0.5 block`,children:(0,z.jsx)(x7,{tone:`neutral`,testId:`flywheel-tracker-unknown-${e.issueId}`,children:`tracker unknown`})})]}),(0,z.jsxs)(`td`,{className:`py-1.5 pr-2`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.state}),e.attention&&(0,z.jsx)(`span`,{className:`ml-1.5`,children:(0,z.jsx)(x7,{tone:V9n[e.attention]??`neutral`,children:e.attention})}),e.state===`working`&&e.liveAgents===0&&(0,z.jsx)(`span`,{className:`ml-1.5`,children:(0,z.jsx)(x7,{tone:`neutral`,testId:`flywheel-no-agent-${e.issueId}`,children:`no agent`})}),e.inTick&&(0,z.jsx)(`span`,{className:`ml-1.5`,children:(0,z.jsx)(x7,{tone:`info`,testId:`flywheel-in-tick-${e.issueId}`,children:`flywheel`})})]}),(0,z.jsx)(`td`,{className:`py-1.5 pr-2 text-muted-foreground`,children:e.pr?(0,z.jsxs)(`a`,{href:e.pr.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:[(0,z.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.pr.number]}),` · `,e.pr.reviewState,` · `,e.pr.checks]}):`—`}),(0,z.jsx)(`td`,{className:`py-1.5 text-muted-foreground`,children:e.lastJournal?(0,z.jsxs)(`span`,{title:e.lastJournal.at,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e.lastJournal.type}),` · `,Sp(e.lastJournal.at,n)]}):`—`})]},e.issueId))})]})]}),(0,z.jsxs)(`section`,{"aria-label":`Live agents`,children:[(0,z.jsxs)(`h3`,{className:`mb-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:[`Agents · `,e.agents.length]}),e.agents.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No agent panes are live for these issues.`}):(0,z.jsx)(`ul`,{className:`space-y-1 text-xs`,children:e.agents.map(e=>(0,z.jsxs)(`li`,{className:`flex items-baseline gap-2`,"data-testid":`flywheel-agent-${e.issueId}-${e.role}`,children:[(0,z.jsx)(`button`,{type:`button`,className:`whitespace-nowrap font-mono text-foreground hover:underline`,onClick:()=>r?.(e.issueId),children:e.issueId}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.role}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:e.model}),(0,z.jsx)(x7,{tone:H9n[e.state]??`neutral`,children:e.state})]},`${e.issueId}-${e.role}-${e.agentId??``}`))})]})]})}function G9n(e,t){return e===0&&t===0?null:`${e} feature${e===1?``:`s`} · ${((e,t)=>`${e} ${t}${e===1?``:`es`}`)(t,`batch`)}`}function K9n({onNavigateIssue:e}){let{sections:t}=Wj(!0),{features:n,batches:r}=yHt(t),i=G9n(n,r);return(0,z.jsx)(S7,{label:`UAT batches`,ariaLabel:`UAT batches`,actions:i&&(0,z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,"data-testid":`flywheel-uat-batches-count`,children:i}),children:(0,z.jsx)(xHt,{active:!0,showProjectFilter:!1,onNavigateIssue:e})})}var q9n=[`merge-train`,`auto-merge`,`pending`];async function J9n(){let e=await fetch(`/api/merge-train/auto-merge/pending`);if(!e.ok)throw Error(`GET /api/merge-train/auto-merge/pending → ${e.status}`);return e.json()}function Y9n(e,t){let n=Date.parse(e)-t;if(!Number.isFinite(n)||n<=0)return`merging…`;let r=Math.ceil(n/1e3);return`auto-merging in ${Math.floor(r/60)}:${String(r%60).padStart(2,`0`)}`}function X9n(e){if(e.prNumber)return`PR #${e.prNumber}`;let t=e.prUrl.match(/\/(?:pull|merge_requests)\/(\d+)(?:$|[/?#])/);return t?`PR #${t[1]}`:`PR`}function Z9n({onNavigateIssue:e}){let t=$t(),{data:n}=F({queryKey:q9n,queryFn:J9n,refetchInterval:5e3}),r=Cn({mutationFn:async e=>{let t=await fetch(`/api/merge-train/auto-merge/${encodeURIComponent(e)}`,{method:`DELETE`,headers:await Ac()});if(!t.ok)throw Error(await t.text().catch(()=>``)||`DELETE auto-merge ${e} → ${t.status}`)},onSettled:()=>t.invalidateQueries({queryKey:q9n})}),[i,a]=(0,L.useState)(()=>Date.now()),o=Array.isArray(n)?n.filter(e=>e.status===`pending`||e.status===`merging`):[];return(0,L.useEffect)(()=>{if(o.length===0)return;let e=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(e)},[o.length]),o.length===0?null:(0,z.jsxs)(S7,{label:`Pending auto-merges`,ariaLabel:`Pending auto-merges`,children:[(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:o.map(t=>{let n=t.status===`merging`||Date.parse(t.scheduledMergeAt)<=i;return(0,z.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`pending-auto-merge-${t.issueId}`,children:[(0,z.jsx)(`button`,{type:`button`,className:`font-mono text-foreground hover:underline`,onClick:()=>e?.(t.issueId),children:t.issueId}),(0,z.jsx)(`a`,{href:t.prUrl,target:`_blank`,rel:`noreferrer`,className:`font-mono text-muted-foreground hover:underline`,children:X9n(t)}),(0,z.jsx)(`span`,{className:`font-mono text-warning-foreground`,children:n?`merging…`:Y9n(t.scheduledMergeAt,i)}),(0,z.jsx)(`button`,{type:`button`,disabled:n||r.isPending,onClick:()=>r.mutate(t.issueId),className:`ml-auto rounded-sm border border-border px-2 py-0.5 text-[11px] text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,children:`Cancel`})]},t.id)})}),r.error&&(0,z.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,role:`alert`,children:r.error.message})]})}var Q9n=!1,$9n=new Set;function eer(){Q9n=!0,$9n.forEach(e=>e())}function ter(){let e=Q9n;return Q9n=!1,e}function ner(e){return $9n.add(e),()=>$9n.delete(e)}var rer=[`status`,`state`,`report`,`stats`],ier=`overdeck.ui.flywheelSplitWidth`,E7=360,aer=360,oer=560,ser=`Off: the loop picks up only backlog items the operator released. On: every ready, planned backlog item is pickable.`,cer=`On: a PR may not merge until UAT has passed. Off: eligible merges may be scheduled through the auto-merge cooldown.`;function ler(){try{let e=Number(window.localStorage.getItem(ier));return Number.isFinite(e)&&e>=E7?e:oer}catch{return oer}}function uer({onOpenSettings:e,onNavigateIssue:t}){let n=xp(),r=n.data,i=n.isError,a=cLe(),o=lLe(),s=a.data,[c,l]=(0,L.useState)(`status`),[u,d]=(0,L.useState)(ler),[f,p]=(0,L.useState)(()=>Date.now()),m=(0,L.useRef)(u),h=(0,L.useRef)(null);(0,L.useEffect)(()=>{let e=window.setInterval(()=>p(Date.now()),5e3);return()=>window.clearInterval(e)},[]),(0,L.useEffect)(()=>{let e=()=>{ter()&&(l(`status`),window.requestAnimationFrame(()=>{(document.querySelector(`[data-testid="flywheel-needs-you"]`)??document.querySelector(`[data-attention="needs-you"]`))?.scrollIntoView({block:`center`})}))};return e(),ner(e)},[]);let g=(0,L.useCallback)(e=>{let t=h.current?.getBoundingClientRect().width||window.innerWidth,n=Math.max(E7,t-aer),r=Math.round(Math.min(n,Math.max(E7,e)));m.current=r,d(r);try{window.localStorage.setItem(ier,String(r))}catch{}},[]),_=(0,L.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=m.current,r=e=>g(n+(e.clientX-t)),i=()=>{document.removeEventListener(`pointermove`,r),document.removeEventListener(`pointerup`,i),document.body.style.cursor=``,document.body.style.userSelect=``};document.addEventListener(`pointermove`,r),document.addEventListener(`pointerup`,i),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[g]),v=i&&!r?(0,z.jsx)(x7,{tone:`destructive`,testId:`flywheel-run-chip`,children:`unreachable`}):r?.run===`running`?(0,z.jsxs)(x7,{tone:`info`,testId:`flywheel-run-chip`,children:[`running`,r.lastTick?` · tick ${r.lastTick.tick}`:``]}):r?.run===`paused`?(0,z.jsx)(x7,{tone:`warning`,testId:`flywheel-run-chip`,children:`paused`}):r?(0,z.jsx)(x7,{tone:`neutral`,testId:`flywheel-run-chip`,children:`idle`}):null;return(0,z.jsxs)(`div`,{ref:h,"aria-label":`Flywheel page`,className:`flex h-full w-full flex-col overflow-hidden bg-background`,children:[(0,z.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-5 py-2.5`,children:[(0,z.jsx)(ao,{className:`h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-sm font-medium text-foreground`,children:`Flywheel`}),(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`The /pan-flywheel loop, derived live from its conversation`})]}),v,r?.run===`running`&&r.freshness&&r.lastTick&&(0,z.jsx)(B9n,{freshness:r.freshness,at:r.lastTick.at,nowMs:f}),r?.run===`running`&&r.conversation&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,"data-testid":`flywheel-elapsed`,title:r.conversation.createdAt,children:[`running `,_Le(f-Date.parse(r.conversation.createdAt))]}),r&&(0,z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,"data-testid":`flywheel-inflight-count`,children:U9n(r)}),(0,z.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-4`,children:[(0,z.jsx)(b9n,{label:`Auto-pickup`,checked:s?.auto_pickup_backlog??!1,disabled:!s||o.isPending,title:ser,onChange:e=>o.mutate({auto_pickup_backlog:e})}),(0,z.jsx)(b9n,{label:`Require UAT`,checked:s?.require_uat_before_merge??!0,disabled:!s||o.isPending,title:cer,onChange:e=>o.mutate({require_uat_before_merge:e})}),(0,z.jsxs)(`a`,{href:`/awaiting-merge`,className:`text-[11px] text-muted-foreground hover:text-foreground hover:underline`,title:`The merge train is configured on the Awaiting Merge page`,"data-testid":`flywheel-merge-train-chip`,children:[`Merge train: `,s?s.merge_train_enabled?`on`:`off`:`—`]})]})]}),o.error&&(0,z.jsx)(`div`,{className:`border-b border-border px-5 py-1.5 text-xs text-destructive`,role:`alert`,children:o.error.message}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,z.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-y-auto border-r border-border`,style:{width:`${u}px`,minWidth:`${E7}px`},"aria-label":`Flywheel control rail`,children:[(0,z.jsx)(Z9n,{onNavigateIssue:t}),(0,z.jsx)(K9n,{onNavigateIssue:t}),(0,z.jsx)(j9n,{bookId:r?.orderBook?.id??null}),(0,z.jsx)(S7,{label:`Flywheel`,ariaLabel:`Flywheel run status`,actions:(0,z.jsx)(`div`,{className:`flex rounded-md border border-border p-0.5 text-[11px]`,role:`tablist`,"aria-label":`Flywheel rail tabs`,children:rer.map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":c===e,onClick:()=>l(e),className:`rounded-sm px-2.5 py-1 capitalize ${c===e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e},e))}),children:(0,z.jsxs)(`div`,{role:`tabpanel`,"aria-label":`Flywheel ${c}`,children:[c===`status`&&(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(k9n,{orderBook:r?.orderBook??null}),(0,z.jsx)(W9n,{status:r,unreachable:i,nowMs:f,onNavigateIssue:t})]}),c===`state`&&(0,z.jsx)(I9n,{}),c===`report`&&(0,z.jsx)(L9n,{}),c===`stats`&&(0,z.jsx)(D9n,{})]})})]}),(0,z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize flywheel panes`,className:`w-1.5 shrink-0 cursor-col-resize bg-border/40 hover:bg-primary/40`,onPointerDown:_}),(0,z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,"aria-label":`Flywheel conversation column`,children:(0,z.jsx)(tgt,{onOpenSettings:e})})]})]})}function D7(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=D7(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var der=n(lne(),1),{useDebugValue:fer}=L.default,{useSyncExternalStoreWithSelector:per}=der.default,mer=e=>e;function her(e,t=mer,n){let r=per(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return fer(r),r}var ger=(e,t)=>{let n=une(e),r=(e,r=t)=>her(n,e,r);return Object.assign(r,n),r},_er=(e,t)=>e?ger(e,t):ger;function O7(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var k7=e=>()=>e;function ver(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}ver.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function yer(e){return!e.ctrlKey&&!e.button}function ber(){return this.parentNode}function xer(e,t){return t??{x:e.x,y:e.y}}function Ser(){return navigator.maxTouchPoints||`ontouchstart`in this}function Cer(){var e=yer,t=ber,n=xer,r=Ser,i={},a=Vne(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,Kne).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(bn(n.view).on(`mousemove.drag`,m,Jne).on(`mouseup.drag`,h,Jne),qne(n.view),_n(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(gn(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){bn(e.view).on(`mousemove.drag mouseup.drag`,null),Une(e.view,l),gn(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(_n(n),c(`start`,n,i[s]))}function _(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(gn(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(_n(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=Wne(l||r,t),p,m,h;if((h=n.call(e,new ver(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=Wne(l||a,t),_=o}u.call(r,e,new ver(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:k7(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:k7(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:k7(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:k7(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var A7=(0,L.createContext)(null),wer=A7.Provider,j7={error001:()=>`[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The React Flow parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?`target`:`source`} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},Ter=j7.error001();function M7(e,t){let n=(0,L.useContext)(A7);if(n===null)throw Error(Ter);return her(n,e,t)}var N7=()=>{let e=(0,L.useContext)(A7);if(e===null)throw Error(Ter);return(0,L.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},Eer=e=>e.userSelectionActive?`none`:`all`;function Der({position:e,children:t,className:n,style:r,...i}){let a=M7(Eer),o=`${e}`.split(`-`);return L.createElement(`div`,{className:D7([`react-flow__panel`,n,...o]),style:{...r,pointerEvents:a},...i},t)}function Oer({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:L.createElement(Der,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro`},L.createElement(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`},`React Flow`))}var ker=(0,L.memo)(({x:e,y:t,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:a={},labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u})=>{let d=(0,L.useRef)(null),[f,p]=(0,L.useState)({x:0,y:0,width:0,height:0}),m=D7([`react-flow__edge-textwrapper`,l]);return(0,L.useEffect)(()=>{if(d.current){let e=d.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n===void 0||!n?null:L.createElement(`g`,{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:m,visibility:f.width?`visible`:`hidden`,...u},i&&L.createElement(`rect`,{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),L.createElement(`text`,{className:`react-flow__edge-text`,y:f.height/2,dy:`0.3em`,ref:d,style:r},n),c)}),Aer=e=>({width:e.offsetWidth,height:e.offsetHeight}),P7=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),jer=(e={x:0,y:0},t)=>({x:P7(e.x,t[0][0],t[1][0]),y:P7(e.y,t[0][1],t[1][1])}),Mer=(e,t,n)=>e<t?P7(Math.abs(e-t),1,50)/50:e>n?-P7(Math.abs(e-n),1,50)/50:0,Ner=(e,t)=>[Mer(e.x,35,t.width-35)*20,Mer(e.y,35,t.height-35)*20],Per=e=>e.getRootNode?.()||window?.document,Fer=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Ier=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ler=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Rer=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),zer=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Ber=e=>F7(e.width)&&F7(e.height)&&F7(e.x)&&F7(e.y),F7=e=>!isNaN(e)&&isFinite(e),I7=Symbol.for(`internals`),Ver=[`Enter`,` `,`Escape`],Her=(e,t)=>{},Uer=e=>`nativeEvent`in e;function Wer(e){let t=(Uer(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return[`INPUT`,`SELECT`,`TEXTAREA`].includes(t?.nodeName)||t?.hasAttribute(`contenteditable`)||!!t?.closest(`.nokey`)}var Ger=e=>`clientX`in e,L7=(e,t)=>{let n=Ger(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},R7=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0,z7=({id:e,path:t,labelX:n,labelY:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:p=20})=>L.createElement(L.Fragment,null,L.createElement(`path`,{id:e,style:u,d:t,fill:`none`,className:`react-flow__edge-path`,markerEnd:d,markerStart:f}),p&&L.createElement(`path`,{d:t,fill:`none`,strokeOpacity:0,strokeWidth:p,className:`react-flow__edge-interaction`}),i&&F7(n)&&F7(r)?L.createElement(ker,{x:n,y:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l}):null);z7.displayName=`BaseEdge`;function B7(e,t,n){return n===void 0?n:r=>{let i=t().edges.find(t=>t.id===e);i&&n(r,{...i})}}function Ker({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function qer({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}var V7;(function(e){e.Strict=`strict`,e.Loose=`loose`})(V7||={});var H7;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(H7||={});var U7;(function(e){e.Partial=`partial`,e.Full=`full`})(U7||={});var W7;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(W7||={});var G7;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(G7||={});var K7;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(K7||={});function Jer({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===K7.Left||e===K7.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function Yer({sourceX:e,sourceY:t,sourcePosition:n=K7.Bottom,targetX:r,targetY:i,targetPosition:a=K7.Top}){let[o,s]=Jer({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=Jer({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=qer({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}var Xer=(0,L.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=K7.Bottom,targetPosition:a=K7.Top,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=Yer({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:a});return L.createElement(z7,{path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})});Xer.displayName=`SimpleBezierEdge`;var Zer={[K7.Left]:{x:-1,y:0},[K7.Right]:{x:1,y:0},[K7.Top]:{x:0,y:-1},[K7.Bottom]:{x:0,y:1}},Qer=({source:e,sourcePosition:t=K7.Bottom,target:n})=>t===K7.Left||t===K7.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},$er=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function etr({source:e,sourcePosition:t=K7.Bottom,target:n,targetPosition:r=K7.Top,center:i,offset:a}){let o=Zer[t],s=Zer[r],c={x:e.x+o.x*a,y:e.y+o.y*a},l={x:n.x+s.x*a,y:n.y+s.y*a},u=Qer({source:c,sourcePosition:t,target:l}),d=u.x===0?`y`:`x`,f=u[d],p=[],m,h,g={x:0,y:0},_={x:0,y:0},[v,y,b,x]=Ker({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[d]*s[d]===-1){m=i.x??v,h=i.y??y;let e=[{x:m,y:c.y},{x:m,y:l.y}],t=[{x:c.x,y:h},{x:l.x,y:h}];p=o[d]===f?d===`x`?e:t:d===`x`?t:e}else{let i=[{x:c.x,y:l.y}],u=[{x:l.x,y:c.y}];if(p=d===`x`?o.x===f?u:i:o.y===f?i:u,t===r){let t=Math.abs(e[d]-n[d]);if(t<=a){let r=Math.min(a-1,a-t);o[d]===f?g[d]=(c[d]>e[d]?-1:1)*r:_[d]=(l[d]>n[d]?-1:1)*r}}if(t!==r){let e=d===`x`?`y`:`x`,t=o[d]===s[e],n=c[e]>l[e],r=c[e]<l[e];(o[d]===1&&(!t&&n||t&&r)||o[d]!==1&&(!t&&r||t&&n))&&(p=d===`x`?i:u)}let v={x:c.x+g.x,y:c.y+g.y},y={x:l.x+_.x,y:l.y+_.y};Math.max(Math.abs(v.x-p[0].x),Math.abs(y.x-p[0].x))>=Math.max(Math.abs(v.y-p[0].y),Math.abs(y.y-p[0].y))?(m=(v.x+y.x)/2,h=p[0].y):(m=p[0].x,h=(v.y+y.y)/2)}return[[e,{x:c.x+g.x,y:c.y+g.y},...p,{x:l.x+_.x,y:l.y+_.y},n],m,h,b,x]}function ttr(e,t,n,r){let i=Math.min($er(e,t)/2,$er(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function ntr({sourceX:e,sourceY:t,sourcePosition:n=K7.Bottom,targetX:r,targetY:i,targetPosition:a=K7.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20}){let[u,d,f,p,m]=etr({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l});return[u.reduce((e,t,n)=>{let r=``;return r=n>0&&n<u.length-1?ttr(u[n-1],t,u[n+1],o):`${n===0?`M`:`L`}${t.x} ${t.y}`,e+=r,e},``),d,f,p,m]}var q7=(0,L.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,sourcePosition:d=K7.Bottom,targetPosition:f=K7.Top,markerEnd:p,markerStart:m,pathOptions:h,interactionWidth:g})=>{let[_,v,y]=ntr({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:f,borderRadius:h?.borderRadius,offset:h?.offset});return L.createElement(z7,{path:_,labelX:v,labelY:y,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:p,markerStart:m,interactionWidth:g})});q7.displayName=`SmoothStepEdge`;var rtr=(0,L.memo)(e=>L.createElement(q7,{...e,pathOptions:(0,L.useMemo)(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));rtr.displayName=`StepEdge`;function itr({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=Ker({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var atr=(0,L.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:p})=>{let[m,h,g]=itr({sourceX:e,sourceY:t,targetX:n,targetY:r});return L.createElement(z7,{path:m,labelX:h,labelY:g,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:p})});atr.displayName=`StraightEdge`;function J7(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function otr({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case K7.Left:return[t-J7(t-r,a),n];case K7.Right:return[t+J7(r-t,a),n];case K7.Top:return[t,n-J7(n-i,a)];case K7.Bottom:return[t,n+J7(i-n,a)]}}function str({sourceX:e,sourceY:t,sourcePosition:n=K7.Bottom,targetX:r,targetY:i,targetPosition:a=K7.Top,curvature:o=.25}){let[s,c]=otr({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=otr({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=qer({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}var Y7=(0,L.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=K7.Bottom,targetPosition:a=K7.Top,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,pathOptions:h,interactionWidth:g})=>{let[_,v,y]=str({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:a,curvature:h?.curvature});return L.createElement(z7,{path:_,labelX:v,labelY:y,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:g})});Y7.displayName=`BezierEdge`;var ctr=(0,L.createContext)(null),ltr=ctr.Provider;ctr.Consumer;var utr=()=>(0,L.useContext)(ctr),dtr=e=>`id`in e&&`source`in e&&`target`in e,ftr=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||``}-${n}${r||``}`,ptr=(e,t)=>e===void 0?``:typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`,mtr=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),htr=(e,t)=>{if(!e.source||!e.target)return j7.error006(),t;let n;return n=dtr(e)?{...e}:{...e,id:ftr(e)},mtr(n,t)?t:t.concat(n)},gtr=({x:e,y:t},[n,r,i],a,[o,s])=>{let c={x:(e-n)/i,y:(t-r)/i};return a?{x:o*Math.round(c.x/o),y:s*Math.round(c.y/s)}:c},_tr=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r}),X7=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};let n=(e.width??0)*t[0],r=(e.height??0)*t[1],i={x:e.position.x-n,y:e.position.y-r};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:i}},vtr=(e,t=[0,0])=>e.length===0?{x:0,y:0,width:0,height:0}:Ler(e.reduce((e,n)=>{let{x:r,y:i}=X7(n,t).positionAbsolute;return Fer(e,Ier({x:r,y:i,width:n.width||0,height:n.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),ytr=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1,s=[0,0])=>{let c={x:(t.x-n)/i,y:(t.y-r)/i,width:t.width/i,height:t.height/i},l=[];return e.forEach(e=>{let{width:t,height:n,selectable:r=!0,hidden:i=!1}=e;if(o&&!r||i)return!1;let{positionAbsolute:u}=X7(e,s),d={x:u.x,y:u.y,width:t||0,height:n||0},f=zer(c,d),p=t===void 0||n===void 0||t===null||n===null,m=a&&f>0,h=(t||0)*(n||0);(p||m||f>=h||e.dragging)&&l.push(e)}),l},btr=(e,t)=>{let n=e.map(e=>e.id);return t.filter(e=>n.includes(e.source)||n.includes(e.target))},xtr=(e,t,n,r,i,a=.1)=>{let o=t/(e.width*(1+a)),s=n/(e.height*(1+a)),c=P7(Math.min(o,s),r,i),l=e.x+e.width/2,u=e.y+e.height/2;return{x:t/2-l*c,y:n/2-u*c,zoom:c}},Z7=(e,t=0)=>e.transition().duration(t);function Str(e,t,n,r){return(t[n]||[]).reduce((t,i)=>(`${e.id}-${i.id}-${n}`!==r&&t.push({id:i.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+i.x+i.width/2,y:(e.positionAbsolute?.y??0)+i.y+i.height/2}),t),[])}function Ctr(e,t,n,r,i,a){let{x:o,y:s}=L7(e),c=t.elementsFromPoint(o,s).find(e=>e.classList.contains(`react-flow__handle`));if(c){let e=c.getAttribute(`data-nodeid`);if(e){let t=Otr(void 0,c),r=c.getAttribute(`data-handleid`),o=a({nodeId:e,id:r,type:t});if(o){let a=i.find(n=>n.nodeId===e&&n.type===t&&n.id===r);return{handle:{id:r,type:t,nodeId:e,x:a?.x||n.x,y:a?.y||n.y},validHandleResult:o}}}}let l=[],u=1/0;if(i.forEach(e=>{let t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=r){let n=a(e);t<=u&&(t<u?l=[{handle:e,validHandleResult:n}]:t===u&&l.push({handle:e,validHandleResult:n}),u=t)}}),!l.length)return{handle:null,validHandleResult:Ttr()};if(l.length===1)return l[0];let d=l.some(({validHandleResult:e})=>e.isValid),f=l.some(({handle:e})=>e.type===`target`);return l.find(({handle:e,validHandleResult:t})=>f?e.type===`target`:!d||t.isValid)||l[0]}var wtr={source:null,target:null,sourceHandle:null,targetHandle:null},Ttr=()=>({handleDomNode:null,isValid:!1,connection:wtr,endHandle:null});function Etr(e,t,n,r,i,a,o){let s=i===`target`,c=o.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),l={...Ttr(),handleDomNode:c};if(c){let e=Otr(void 0,c),i=c.getAttribute(`data-nodeid`),o=c.getAttribute(`data-handleid`),u=c.classList.contains(`connectable`),d=c.classList.contains(`connectableend`),f={source:s?i:n,sourceHandle:s?o:r,target:s?n:i,targetHandle:s?r:o};l.connection=f,u&&d&&(t===V7.Strict?s&&e===`source`||!s&&e===`target`:i!==n||o!==r)&&(l.endHandle={nodeId:i,handleId:o,type:e},l.isValid=a(f))}return l}function Dtr({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((e,i)=>{if(i[I7]){let{handleBounds:a}=i[I7],o=[],s=[];a&&(o=Str(i,a,`source`,`${t}-${n}-${r}`),s=Str(i,a,`target`,`${t}-${n}-${r}`)),e.push(...o,...s)}return e},[])}function Otr(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function ktr(e){e?.classList.remove(`valid`,`connecting`,`react-flow__handle-valid`,`react-flow__handle-connecting`)}function Atr(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function jtr({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:i,getState:a,setState:o,isValidConnection:s,edgeUpdaterType:c,onReconnectEnd:l}){let u=Per(e.target),{connectionMode:d,domNode:f,autoPanOnConnect:p,connectionRadius:m,onConnectStart:h,panBy:g,getNodes:_,cancelConnection:v}=a(),y=0,b,{x,y:S}=L7(e),C=u?.elementFromPoint(x,S),w=Otr(c,C),T=f?.getBoundingClientRect();if(!T||!w)return;let E,D=L7(e,T),O=!1,k=null,A=!1,j=null,ee=Dtr({nodes:_(),nodeId:n,handleId:t,handleType:w}),M=()=>{if(!p)return;let[e,t]=Ner(D,T);g({x:e,y:t}),y=requestAnimationFrame(M)};o({connectionPosition:D,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:w,connectionStartHandle:{nodeId:n,handleId:t,type:w},connectionEndHandle:null}),h?.(e,{nodeId:n,handleId:t,handleType:w});function N(e){let{transform:r}=a();D=L7(e,T);let{handle:c,validHandleResult:l}=Ctr(e,u,gtr(D,r,!1,[1,1]),m,ee,e=>Etr(e,d,n,t,i?`target`:`source`,s,u));if(b=c,O||=(M(),!0),j=l.handleDomNode,k=l.connection,A=l.isValid,o({connectionPosition:b&&A?_tr({x:b.x,y:b.y},r):D,connectionStatus:Atr(!!b,A),connectionEndHandle:l.endHandle}),!b&&!A&&!j)return ktr(E);k.source!==k.target&&j&&(ktr(E),E=j,j.classList.add(`connecting`,`react-flow__handle-connecting`),j.classList.toggle(`valid`,A),j.classList.toggle(`react-flow__handle-valid`,A))}function P(e){(b||j)&&k&&A&&r?.(k),a().onConnectEnd?.(e),c&&l?.(e),ktr(E),v(),cancelAnimationFrame(y),O=!1,A=!1,k=null,j=null,u.removeEventListener(`mousemove`,N),u.removeEventListener(`mouseup`,P),u.removeEventListener(`touchmove`,N),u.removeEventListener(`touchend`,P)}u.addEventListener(`mousemove`,N),u.addEventListener(`mouseup`,P),u.addEventListener(`touchmove`,N),u.addEventListener(`touchend`,P)}var Mtr=()=>!0,Ntr=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),Ptr=(e,t,n)=>r=>{let{connectionStartHandle:i,connectionEndHandle:a,connectionClickStartHandle:o}=r;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===n||a?.nodeId===e&&a?.handleId===t&&a?.type===n,clickConnecting:o?.nodeId===e&&o?.handleId===t&&o?.type===n}},Ftr=(0,L.forwardRef)(({type:e=`source`,position:t=K7.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p)=>{let m=o||null,h=e===`target`,g=N7(),_=utr(),{connectOnClick:v,noPanClassName:y}=M7(Ntr,O7),{connecting:b,clickConnecting:x}=M7(Ptr(_,m,e),O7);_||g.getState().onError?.(`010`,j7.error010());let S=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(htr(i,e))}n?.(i),s?.(i)},C=e=>{if(!_)return;let t=Ger(e);i&&(t&&e.button===0||!t)&&jtr({event:e,handleId:m,nodeId:_,onConnect:S,isTarget:h,getState:g.getState,setState:g.setState,isValidConnection:n||g.getState().isValidConnection||Mtr}),t?u?.(e):d?.(e)};return L.createElement(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${_}-${m}-${e}`,className:D7([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,connecting:x,connectionindicator:r&&(i&&!b||a&&b)}]),onMouseDown:C,onTouchStart:C,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,handleId:m}});return}let l=Per(t.target),u=n||c||Mtr,{connection:d,isValid:f}=Etr({nodeId:_,id:m,type:e},s,o.nodeId,o.handleId||null,o.type,u,l);f&&S(d),a?.(t),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f},c)});Ftr.displayName=`Handle`;var Q7=(0,L.memo)(Ftr),Itr=({data:e,isConnectable:t,targetPosition:n=K7.Top,sourcePosition:r=K7.Bottom})=>L.createElement(L.Fragment,null,L.createElement(Q7,{type:`target`,position:n,isConnectable:t}),e?.label,L.createElement(Q7,{type:`source`,position:r,isConnectable:t}));Itr.displayName=`DefaultNode`;var Ltr=(0,L.memo)(Itr),Rtr=({data:e,isConnectable:t,sourcePosition:n=K7.Bottom})=>L.createElement(L.Fragment,null,e?.label,L.createElement(Q7,{type:`source`,position:n,isConnectable:t}));Rtr.displayName=`InputNode`;var ztr=(0,L.memo)(Rtr),Btr=({data:e,isConnectable:t,targetPosition:n=K7.Top})=>L.createElement(L.Fragment,null,L.createElement(Q7,{type:`target`,position:n,isConnectable:t}),e?.label);Btr.displayName=`OutputNode`;var Vtr=(0,L.memo)(Btr),Htr=()=>null;Htr.displayName=`GroupNode`;var Utr=e=>({selectedNodes:e.getNodes().filter(e=>e.selected),selectedEdges:e.edges.filter(e=>e.selected).map(e=>({...e}))}),$7=e=>e.id;function Wtr(e,t){return O7(e.selectedNodes.map($7),t.selectedNodes.map($7))&&O7(e.selectedEdges.map($7),t.selectedEdges.map($7))}var Gtr=(0,L.memo)(({onSelectionChange:e})=>{let t=N7(),{selectedNodes:n,selectedEdges:r}=M7(Utr,Wtr);return(0,L.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChange.forEach(e=>e(i))},[n,r,e]),null});Gtr.displayName=`SelectionListener`;var Ktr=e=>!!e.onSelectionChange;function qtr({onSelectionChange:e}){let t=M7(Ktr);return e||t?L.createElement(Gtr,{onSelectionChange:e}):null}var Jtr=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function e9(e,t){(0,L.useEffect)(()=>{e!==void 0&&t(e)},[e])}function t9(e,t,n){(0,L.useEffect)(()=>{t!==void 0&&n({[e]:t})},[t])}var Ytr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:a,onConnectEnd:o,onClickConnectStart:s,onClickConnectEnd:c,nodesDraggable:l,nodesConnectable:u,nodesFocusable:d,edgesFocusable:f,edgesUpdatable:p,elevateNodesOnSelect:m,minZoom:h,maxZoom:g,nodeExtent:_,onNodesChange:v,onEdgesChange:y,elementsSelectable:b,connectionMode:x,snapGrid:S,snapToGrid:C,translateExtent:w,connectOnClick:T,defaultEdgeOptions:E,fitView:D,fitViewOptions:O,onNodesDelete:k,onEdgesDelete:A,onNodeDrag:j,onNodeDragStart:ee,onNodeDragStop:M,onSelectionDrag:N,onSelectionDragStart:P,onSelectionDragStop:te,noPanClassName:ne,nodeOrigin:re,rfId:ie,autoPanOnConnect:ae,autoPanOnNodeDrag:oe,onError:se,connectionRadius:ce,isValidConnection:le,nodeDragThreshold:ue})=>{let{setNodes:de,setEdges:fe,setDefaultNodesAndEdges:pe,setMinZoom:me,setMaxZoom:he,setTranslateExtent:ge,setNodeExtent:_e,reset:ve}=M7(Jtr,O7),ye=N7();return(0,L.useEffect)(()=>{let e=r?.map(e=>({...e,...E}));return pe(n,e),()=>{ve()}},[]),t9(`defaultEdgeOptions`,E,ye.setState),t9(`connectionMode`,x,ye.setState),t9(`onConnect`,i,ye.setState),t9(`onConnectStart`,a,ye.setState),t9(`onConnectEnd`,o,ye.setState),t9(`onClickConnectStart`,s,ye.setState),t9(`onClickConnectEnd`,c,ye.setState),t9(`nodesDraggable`,l,ye.setState),t9(`nodesConnectable`,u,ye.setState),t9(`nodesFocusable`,d,ye.setState),t9(`edgesFocusable`,f,ye.setState),t9(`edgesUpdatable`,p,ye.setState),t9(`elementsSelectable`,b,ye.setState),t9(`elevateNodesOnSelect`,m,ye.setState),t9(`snapToGrid`,C,ye.setState),t9(`snapGrid`,S,ye.setState),t9(`onNodesChange`,v,ye.setState),t9(`onEdgesChange`,y,ye.setState),t9(`connectOnClick`,T,ye.setState),t9(`fitViewOnInit`,D,ye.setState),t9(`fitViewOnInitOptions`,O,ye.setState),t9(`onNodesDelete`,k,ye.setState),t9(`onEdgesDelete`,A,ye.setState),t9(`onNodeDrag`,j,ye.setState),t9(`onNodeDragStart`,ee,ye.setState),t9(`onNodeDragStop`,M,ye.setState),t9(`onSelectionDrag`,N,ye.setState),t9(`onSelectionDragStart`,P,ye.setState),t9(`onSelectionDragStop`,te,ye.setState),t9(`noPanClassName`,ne,ye.setState),t9(`nodeOrigin`,re,ye.setState),t9(`rfId`,ie,ye.setState),t9(`autoPanOnConnect`,ae,ye.setState),t9(`autoPanOnNodeDrag`,oe,ye.setState),t9(`onError`,se,ye.setState),t9(`connectionRadius`,ce,ye.setState),t9(`isValidConnection`,le,ye.setState),t9(`nodeDragThreshold`,ue,ye.setState),e9(e,de),e9(t,fe),e9(h,me),e9(g,he),e9(w,ge),e9(_,_e),null},Xtr={display:`none`},Ztr={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},Qtr=`react-flow__node-desc`,$tr=`react-flow__edge-desc`,enr=`react-flow__aria-live`,tnr=e=>e.ariaLiveMessage;function nnr({rfId:e}){let t=M7(tnr);return L.createElement(`div`,{id:`${enr}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Ztr},t)}function rnr({rfId:e,disableKeyboardA11y:t}){return L.createElement(L.Fragment,null,L.createElement(`div`,{id:`${Qtr}-${e}`,style:Xtr},`Press enter or space to select a node.`,!t&&`You can then use the arrow keys to move the node around.`,` Press delete to remove it and escape to cancel.`,` `),L.createElement(`div`,{id:`${$tr}-${e}`,style:Xtr},`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`),!t&&L.createElement(nnr,{rfId:e}))}var n9=(e=null,t={actInsideInputWithModifier:!0})=>{let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(!1),a=(0,L.useRef)(new Set([])),[o,s]=(0,L.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.split(`+`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,L.useEffect)(()=>{let n=typeof document<`u`?document:null,c=t?.target||n;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey,(!i.current||i.current&&!t.actInsideInputWithModifier)&&Wer(e))return!1;let n=anr(e.code,s);a.current.add(e[n]),inr(o,a.current,!1)&&(e.preventDefault(),r(!0))},n=e=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Wer(e))return!1;let n=anr(e.code,s);inr(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[n]),e.key===`Meta`&&a.current.clear(),i.current=!1},l=()=>{a.current.clear(),r(!1)};return c?.addEventListener(`keydown`,e),c?.addEventListener(`keyup`,n),window.addEventListener(`blur`,l),()=>{c?.removeEventListener(`keydown`,e),c?.removeEventListener(`keyup`,n),window.removeEventListener(`blur`,l)}}},[e,r]),n};function inr(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function anr(e,t){return t.includes(e)?`code`:`key`}function onr(e,t,n,r){let i=e.parentNode||e.parentId;if(!i)return n;let a=t.get(i),o=X7(a,r);return onr(a,t,{x:(n.x??0)+o.x,y:(n.y??0)+o.y,z:(a[I7]?.z??0)>(n.z??0)?a[I7]?.z??0:n.z??0},r)}function snr(e,t,n){e.forEach(r=>{let i=r.parentNode||r.parentId;if(i&&!e.has(i))throw Error(`Parent node ${i} not found`);if(i||n?.[r.id]){let{x:i,y:a,z:o}=onr(r,e,{...r.position,z:r[I7]?.z??0},t);r.positionAbsolute={x:i,y:a},r[I7].z=o,n?.[r.id]&&(r[I7].isParent=!0)}})}function cnr(e,t,n,r){let i=new Map,a={},o=r?1e3:0;return e.forEach(e=>{let n=(F7(e.zIndex)?e.zIndex:0)+(e.selected?o:0),r=t.get(e.id),s={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},c=e.parentNode||e.parentId;c&&(a[c]=!0);let l=r?.type&&r?.type!==e.type;Object.defineProperty(s,I7,{enumerable:!1,value:{handleBounds:l?void 0:r?.[I7]?.handleBounds,z:n}}),i.set(e.id,s)}),snr(i,n,a),i}function lnr(e,t={}){let{getNodes:n,width:r,height:i,minZoom:a,maxZoom:o,d3Zoom:s,d3Selection:c,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:d}=e(),f=t.initial&&!l&&u;if(s&&c&&(f||!t.initial)){let e=n().filter(e=>{let n=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return t.nodes?.length?n&&t.nodes.some(t=>t.id===e.id):n}),l=e.every(e=>e.width&&e.height);if(e.length>0&&l){let{x:n,y:l,zoom:u}=xtr(vtr(e,d),r,i,t.minZoom??a,t.maxZoom??o,t.padding??.1),f=yn.translate(n,l).scale(u);return typeof t.duration==`number`&&t.duration>0?s.transform(Z7(c,t.duration),f):s.transform(c,f),!0}}return!1}function unr(e,t){return e.forEach(e=>{let n=t.get(e.id);n&&t.set(n.id,{...n,[I7]:n[I7],selected:e.selected})}),new Map(t)}function dnr(e,t){return t.map(t=>{let n=e.find(e=>e.id===t.id);return n&&(t.selected=n.selected),t})}function r9({changedNodes:e,changedEdges:t,get:n,set:r}){let{nodeInternals:i,edges:a,onNodesChange:o,onEdgesChange:s,hasDefaultNodes:c,hasDefaultEdges:l}=n();e?.length&&(c&&r({nodeInternals:unr(e,i)}),o?.(e)),t?.length&&(l&&r({edges:dnr(t,a)}),s?.(t))}var i9=()=>{},fnr={zoomIn:i9,zoomOut:i9,zoomTo:i9,getZoom:()=>1,setViewport:i9,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:i9,fitBounds:i9,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},pnr=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),mnr=()=>{let e=N7(),{d3Zoom:t,d3Selection:n}=M7(pnr,O7);return(0,L.useMemo)(()=>n&&t?{zoomIn:e=>t.scaleBy(Z7(n,e?.duration),1.2),zoomOut:e=>t.scaleBy(Z7(n,e?.duration),1/1.2),zoomTo:(e,r)=>t.scaleTo(Z7(n,r?.duration),e),getZoom:()=>e.getState().transform[2],setViewport:(r,i)=>{let[a,o,s]=e.getState().transform,c=yn.translate(r.x??a,r.y??o).scale(r.zoom??s);t.transform(Z7(n,i?.duration),c)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},fitView:t=>lnr(e.getState,t),setCenter:(r,i,a)=>{let{width:o,height:s,maxZoom:c}=e.getState(),l=a?.zoom===void 0?c:a.zoom,u=o/2-r*l,d=s/2-i*l,f=yn.translate(u,d).scale(l);t.transform(Z7(n,a?.duration),f)},fitBounds:(r,i)=>{let{width:a,height:o,minZoom:s,maxZoom:c}=e.getState(),{x:l,y:u,zoom:d}=xtr(r,a,o,s,c,i?.padding??.1),f=yn.translate(l,u).scale(d);t.transform(Z7(n,i?.duration),f)},project:t=>{let{transform:n,snapToGrid:r,snapGrid:i}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),gtr(t,n,r,i)},screenToFlowPosition:t=>{let{transform:n,snapToGrid:r,snapGrid:i,domNode:a}=e.getState();if(!a)return t;let{x:o,y:s}=a.getBoundingClientRect();return gtr({x:t.x-o,y:t.y-s},n,r,i)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=_tr(t,n);return{x:o.x+i,y:o.y+a}},viewportInitialized:!0}:fnr,[t,n])};function hnr(){let e=mnr(),t=N7(),n=(0,L.useCallback)(()=>t.getState().getNodes().map(e=>({...e})),[]),r=(0,L.useCallback)(e=>t.getState().nodeInternals.get(e),[]),i=(0,L.useCallback)(()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},[]),a=(0,L.useCallback)(e=>{let{edges:n=[]}=t.getState();return n.find(t=>t.id===e)},[]),o=(0,L.useCallback)(e=>{let{getNodes:n,setNodes:r,hasDefaultNodes:i,onNodesChange:a}=t.getState(),o=n(),s=typeof e==`function`?e(o):e;i?r(s):a&&a(s.length===0?o.map(e=>({type:`remove`,id:e.id})):s.map(e=>({item:e,type:`reset`})))},[]),s=(0,L.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a}=t.getState(),o=typeof e==`function`?e(n):e;i?r(o):a&&a(o.length===0?n.map(e=>({type:`remove`,id:e.id})):o.map(e=>({item:e,type:`reset`})))},[]),c=(0,L.useCallback)(e=>{let n=Array.isArray(e)?e:[e],{getNodes:r,setNodes:i,hasDefaultNodes:a,onNodesChange:o}=t.getState();a?i([...r(),...n]):o&&o(n.map(e=>({item:e,type:`add`})))},[]),l=(0,L.useCallback)(e=>{let n=Array.isArray(e)?e:[e],{edges:r=[],setEdges:i,hasDefaultEdges:a,onEdgesChange:o}=t.getState();a?i([...r,...n]):o&&o(n.map(e=>({item:e,type:`add`})))},[]),u=(0,L.useCallback)(()=>{let{getNodes:e,edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e().map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},[]),d=(0,L.useCallback)(({nodes:e,edges:n})=>{let{nodeInternals:r,getNodes:i,edges:a,hasDefaultNodes:o,hasDefaultEdges:s,onNodesDelete:c,onEdgesDelete:l,onNodesChange:u,onEdgesChange:d}=t.getState(),f=(e||[]).map(e=>e.id),p=(n||[]).map(e=>e.id),m=i().reduce((e,t)=>{let n=t.parentNode||t.parentId,r=!f.includes(t.id)&&n&&e.find(e=>e.id===n);return(typeof t.deletable!=`boolean`||t.deletable)&&(f.includes(t.id)||r)&&e.push(t),e},[]),h=a.filter(e=>typeof e.deletable!=`boolean`||e.deletable),g=h.filter(e=>p.includes(e.id));if(m||g){let e=btr(m,h),n=[...g,...e],i=n.reduce((e,t)=>(e.includes(t.id)||e.push(t.id),e),[]);(s||o)&&(s&&t.setState({edges:a.filter(e=>!i.includes(e.id))}),o&&(m.forEach(e=>{r.delete(e.id)}),t.setState({nodeInternals:new Map(r)}))),i.length>0&&(l?.(n),d&&d(i.map(e=>({id:e,type:`remove`})))),m.length>0&&(c?.(m),u&&u(m.map(e=>({id:e.id,type:`remove`}))))}},[]),f=(0,L.useCallback)(e=>{let n=Ber(e),r=n?null:t.getState().nodeInternals.get(e.id);return!n&&!r?[null,null,n]:[n?e:Rer(r),r,n]},[]),p=(0,L.useCallback)((e,n=!0,r)=>{let[i,a,o]=f(e);return i?(r||t.getState().getNodes()).filter(e=>{if(!o&&(e.id===a.id||!e.positionAbsolute))return!1;let t=zer(Rer(e),i);return n&&t>0||t>=i.width*i.height}):[]},[]),m=(0,L.useCallback)((e,t,n=!0)=>{let[r]=f(e);if(!r)return!1;let i=zer(r,t);return n&&i>0||i>=r.width*r.height},[]);return(0,L.useMemo)(()=>({...e,getNodes:n,getNode:r,getEdges:i,getEdge:a,setNodes:o,setEdges:s,addNodes:c,addEdges:l,toObject:u,deleteElements:d,getIntersectingNodes:p,isNodeIntersecting:m}),[e,n,r,i,a,o,s,c,l,u,d,p,m])}var gnr={actInsideInputWithModifier:!1},_nr=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{let n=N7(),{deleteElements:r}=hnr(),i=n9(e,gnr),a=n9(t);(0,L.useEffect)(()=>{if(i){let{edges:e,getNodes:t}=n.getState(),i=t().filter(e=>e.selected),a=e.filter(e=>e.selected);r({nodes:i,edges:a}),n.setState({nodesSelectionActive:!1})}},[i]),(0,L.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])};function vnr(e){let t=N7();(0,L.useEffect)(()=>{let n,r=()=>{if(!e.current)return;let n=Aer(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,j7.error004()),t.setState({width:n.width||500,height:n.height||500})};return r(),window.addEventListener(`resize`,r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener(`resize`,r),n&&e.current&&n.unobserve(e.current)}},[])}var ynr={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},bnr=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,a9=e=>({x:e.x,y:e.y,zoom:e.k}),o9=(e,t)=>e.target.closest(`.${t}`),xnr=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Snr=e=>{let t=e.ctrlKey&&R7()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},Cnr=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),wnr=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:a=!0,panOnScroll:o=!1,panOnScrollSpeed:s=.5,panOnScrollMode:c=H7.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:d=!0,defaultViewport:f,translateExtent:p,minZoom:m,maxZoom:h,zoomActivationKeyCode:g,preventScrolling:_=!0,children:v,noWheelClassName:y,noPanClassName:b})=>{let x=(0,L.useRef)(),S=N7(),C=(0,L.useRef)(!1),w=(0,L.useRef)(!1),T=(0,L.useRef)(null),E=(0,L.useRef)({x:0,y:0,zoom:0}),{d3Zoom:D,d3Selection:O,d3ZoomHandler:k,userSelectionActive:A}=M7(Cnr,O7),j=n9(g),ee=(0,L.useRef)(0),M=(0,L.useRef)(!1),N=(0,L.useRef)();return vnr(T),(0,L.useEffect)(()=>{if(T.current){let e=T.current.getBoundingClientRect(),t=Yne().scaleExtent([m,h]).translateExtent(p),n=bn(T.current).call(t),r=yn.translate(f.x,f.y).scale(P7(f.zoom,m,h)),i=[[0,0],[e.width,e.height]],a=t.constrain()(r,i,p);t.transform(n,a),t.wheelDelta(Snr),S.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on(`wheel.zoom`),transform:[a.x,a.y,a.k],domNode:T.current.closest(`.react-flow`)})}},[]),(0,L.useEffect)(()=>{O&&D&&(o&&!j&&!A?O.on(`wheel.zoom`,r=>{if(o9(r,y))return!1;r.preventDefault(),r.stopImmediatePropagation();let i=O.property(`__zoom`).k||1;if(r.ctrlKey&&a){let e=Wne(r),t=i*2**Snr(r);D.scaleTo(O,t,e,r);return}let o=r.deltaMode===1?20:1,l=c===H7.Vertical?0:r.deltaX*o,u=c===H7.Horizontal?0:r.deltaY*o;!R7()&&r.shiftKey&&c!==H7.Vertical&&(l=r.deltaY*o,u=0),D.translateBy(O,-(l/i)*s,-(u/i)*s,{internal:!0});let d=a9(O.property(`__zoom`)),{onViewportChangeStart:f,onViewportChange:p,onViewportChangeEnd:m}=S.getState();clearTimeout(N.current),M.current||(M.current=!0,t?.(r,d),f?.(d)),M.current&&(e?.(r,d),p?.(d),N.current=setTimeout(()=>{n?.(r,d),m?.(d),M.current=!1},150))},{passive:!1}):k!==void 0&&O.on(`wheel.zoom`,function(e,t){if(!_&&e.type===`wheel`&&!e.ctrlKey||o9(e,y))return null;e.preventDefault(),k.call(this,e,t)},{passive:!1}))},[A,o,c,O,D,k,j,a,_,y,t,e,n]),(0,L.useEffect)(()=>{D&&D.on(`start`,e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;ee.current=e.sourceEvent?.button;let{onViewportChangeStart:n}=S.getState(),r=a9(e.transform);C.current=!0,E.current=r,e.sourceEvent?.type===`mousedown`&&S.setState({paneDragging:!0}),n?.(r),t?.(e.sourceEvent,r)})},[D,t]),(0,L.useEffect)(()=>{D&&(A&&!C.current?D.on(`zoom`,null):A||D.on(`zoom`,t=>{let{onViewportChange:n}=S.getState();if(S.setState({transform:[t.transform.x,t.transform.y,t.transform.k]}),w.current=!!(r&&xnr(d,ee.current??0)),(e||n)&&!t.sourceEvent?.internal){let r=a9(t.transform);n?.(r),e?.(t.sourceEvent,r)}}))},[A,D,e,d,r]),(0,L.useEffect)(()=>{D&&D.on(`end`,e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;let{onViewportChangeEnd:t}=S.getState();if(C.current=!1,S.setState({paneDragging:!1}),r&&xnr(d,ee.current??0)&&!w.current&&r(e.sourceEvent),w.current=!1,(n||t)&&bnr(E.current,e.transform)){let r=a9(e.transform);E.current=r,clearTimeout(x.current),x.current=setTimeout(()=>{t?.(r),n?.(e.sourceEvent,r)},o?150:0)}})},[D,o,d,n,r]),(0,L.useEffect)(()=>{D&&D.filter(e=>{let t=j||i,n=a&&e.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&e.button===1&&e.type===`mousedown`&&(o9(e,`react-flow__node`)||o9(e,`react-flow__edge`)))return!0;if(!d&&!t&&!o&&!l&&!a||A||!l&&e.type===`dblclick`||o9(e,y)&&e.type===`wheel`||o9(e,b)&&(e.type!==`wheel`||o&&e.type===`wheel`&&!j)||!a&&e.ctrlKey&&e.type===`wheel`||!t&&!o&&!n&&e.type===`wheel`||!d&&(e.type===`mousedown`||e.type===`touchstart`)||Array.isArray(d)&&!d.includes(e.button)&&e.type===`mousedown`)return!1;let r=Array.isArray(d)&&d.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||e.type===`wheel`)&&r})},[A,D,i,a,o,l,d,u,j]),L.createElement(`div`,{className:`react-flow__renderer`,ref:T,style:ynr},v)},Tnr=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Enr(){let{userSelectionActive:e,userSelectionRect:t}=M7(Tnr,O7);return e&&t?L.createElement(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Dnr(e,t){let n=t.parentNode||t.parentId,r=e.find(e=>e.id===n);if(r){let e=t.position.x+t.width-r.width,n=t.position.y+t.height-r.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,e>0&&(r.style.width+=e),n>0&&(r.style.height+=n),t.position.x<0){let e=Math.abs(t.position.x);r.position.x=r.position.x-e,r.style.width+=e,t.position.x=0}if(t.position.y<0){let e=Math.abs(t.position.y);r.position.y=r.position.y-e,r.style.height+=e,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function Onr(e,t){if(e.some(e=>e.type===`reset`))return e.filter(e=>e.type===`reset`).map(e=>e.item);let n=e.filter(e=>e.type===`add`).map(e=>e.item);return t.reduce((t,n)=>{let r=e.filter(e=>e.id===n.id);if(r.length===0)return t.push(n),t;let i={...n};for(let e of r)if(e)switch(e.type){case`select`:i.selected=e.selected;break;case`position`:e.position!==void 0&&(i.position=e.position),e.positionAbsolute!==void 0&&(i.positionAbsolute=e.positionAbsolute),e.dragging!==void 0&&(i.dragging=e.dragging),i.expandParent&&Dnr(t,i);break;case`dimensions`:e.dimensions!==void 0&&(i.width=e.dimensions.width,i.height=e.dimensions.height),e.updateStyle!==void 0&&(i.style={...i.style||{},...e.dimensions}),typeof e.resizing==`boolean`&&(i.resizing=e.resizing),i.expandParent&&Dnr(t,i);break;case`remove`:return t}return t.push(i),t},n)}function knr(e,t){return Onr(e,t)}function Anr(e,t){return Onr(e,t)}var s9=(e,t)=>({id:e,type:`select`,selected:t});function c9(e,t){return e.reduce((e,n)=>{let r=t.includes(n.id);return!n.selected&&r?(n.selected=!0,e.push(s9(n.id,!0))):n.selected&&!r&&(n.selected=!1,e.push(s9(n.id,!1))),e},[])}var jnr=(e,t)=>n=>{n.target===t.current&&e?.(n)},Mnr=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),Nnr=(0,L.memo)(({isSelecting:e,selectionMode:t=U7.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:a,onPaneContextMenu:o,onPaneScroll:s,onPaneMouseEnter:c,onPaneMouseMove:l,onPaneMouseLeave:u,children:d})=>{let f=(0,L.useRef)(null),p=N7(),m=(0,L.useRef)(0),h=(0,L.useRef)(0),g=(0,L.useRef)(),{userSelectionActive:_,elementsSelectable:v,dragging:y}=M7(Mnr,O7),b=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),m.current=0,h.current=0},x=e=>{a?.(e),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},S=e=>{if(Array.isArray(n)&&n?.includes(2)){e.preventDefault();return}o?.(e)},C=s?e=>s(e):void 0,w=t=>{let{resetSelectedElements:n,domNode:i}=p.getState();if(g.current=i?.getBoundingClientRect(),!v||!e||t.button!==0||t.target!==f.current||!g.current)return;let{x:a,y:o}=L7(t,g.current);n(),p.setState({userSelectionRect:{width:0,height:0,startX:a,startY:o,x:a,y:o}}),r?.(t)},T=n=>{let{userSelectionRect:r,nodeInternals:i,edges:a,transform:o,onNodesChange:s,onEdgesChange:c,nodeOrigin:l,getNodes:u}=p.getState();if(!e||!g.current||!r)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});let d=L7(n,g.current),f=r.startX??0,_=r.startY??0,v={...r,x:d.x<f?d.x:f,y:d.y<_?d.y:_,width:Math.abs(d.x-f),height:Math.abs(d.y-_)},y=u(),b=ytr(i,v,o,t===U7.Partial,!0,l),x=btr(b,a).map(e=>e.id),S=b.map(e=>e.id);if(m.current!==S.length){m.current=S.length;let e=c9(y,S);e.length&&s?.(e)}if(h.current!==x.length){h.current=x.length;let e=c9(a,x);e.length&&c?.(e)}p.setState({userSelectionRect:v})},E=e=>{if(e.button!==0)return;let{userSelectionRect:t}=p.getState();!_&&t&&e.target===f.current&&x?.(e),p.setState({nodesSelectionActive:m.current>0}),b(),i?.(e)},D=e=>{_&&(p.setState({nodesSelectionActive:m.current>0}),i?.(e)),b()},O=v&&(e||_);return L.createElement(`div`,{className:D7([`react-flow__pane`,{dragging:y,selection:e}]),onClick:O?void 0:jnr(x,f),onContextMenu:jnr(S,f),onWheel:jnr(C,f),onMouseEnter:O?void 0:c,onMouseDown:O?w:void 0,onMouseMove:O?T:l,onMouseUp:O?E:void 0,onMouseLeave:O?D:u,ref:f,style:ynr},d,L.createElement(Enr,null))});Nnr.displayName=`Pane`;function Pnr(e,t){let n=e.parentNode||e.parentId;if(!n)return!1;let r=t.get(n);return r?r.selected?!0:Pnr(r,t):!1}function Fnr(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function Inr(e,t,n,r){return Array.from(e.values()).filter(n=>(n.selected||n.id===r)&&(!n.parentNode||n.parentId||!Pnr(n,e))&&(n.draggable||t&&n.draggable===void 0)).map(e=>({id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-(e.positionAbsolute?.x??0),y:n.y-(e.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode||e.parentId,parentId:e.parentNode||e.parentId,width:e.width,height:e.height,expandParent:e.expandParent}))}function Lnr(e,t){return!t||t===`parent`?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function Rnr(e,t,n,r,i=[0,0],a){let o=Lnr(e,e.extent||r),s=o,c=e.parentNode||e.parentId;if(e.extent===`parent`&&!e.expandParent){if(c&&e.width&&e.height){let t=n.get(c),{x:r,y:a}=X7(t,i).positionAbsolute;s=t&&F7(r)&&F7(a)&&F7(t.width)&&F7(t.height)?[[r+e.width*i[0],a+e.height*i[1]],[r+t.width-e.width+e.width*i[0],a+t.height-e.height+e.height*i[1]]]:s}else a?.(`005`,j7.error005()),s=o}else if(e.extent&&c&&e.extent!==`parent`){let{x:t,y:r}=X7(n.get(c),i).positionAbsolute;s=[[e.extent[0][0]+t,e.extent[0][1]+r],[e.extent[1][0]+t,e.extent[1][1]+r]]}let l={x:0,y:0};c&&(l=X7(n.get(c),i).positionAbsolute);let u=s&&s!==`parent`?jer(t,s):t;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function znr({nodeId:e,dragItems:t,nodeInternals:n}){let r=t.map(e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute}));return[e?r.find(t=>t.id===e):r[0],r]}var Bnr=(e,t,n,r)=>{let i=t.querySelectorAll(e);if(!i||!i.length)return null;let a=Array.from(i),o=t.getBoundingClientRect(),s={x:o.width*r[0],y:o.height*r[1]};return a.map(e=>{let t=e.getBoundingClientRect();return{id:e.getAttribute(`data-handleid`),position:e.getAttribute(`data-handlepos`),x:(t.left-o.left-s.x)/n,y:(t.top-o.top-s.y)/n,...Aer(e)}})};function l9(e,t,n){return n===void 0?n:r=>{let i=t().nodeInternals.get(e);i&&n(r,{...i})}}function Vnr({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeInternals:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,j7.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function Hnr(){let e=N7();return(0,L.useCallback)(({sourceEvent:t})=>{let{transform:n,snapGrid:r,snapToGrid:i}=e.getState(),a=t.touches?t.touches[0].clientX:t.clientX,o=t.touches?t.touches[0].clientY:t.clientY,s={x:(a-n[0])/n[2],y:(o-n[1])/n[2]};return{xSnapped:i?r[0]*Math.round(s.x/r[0]):s.x,ySnapped:i?r[1]*Math.round(s.y/r[1]):s.y,...s}},[])}function Unr(e){return(t,n,r)=>e?.(t,r)}function Wnr({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,selectNodesOnDrag:o}){let s=N7(),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)([]),d=(0,L.useRef)({x:null,y:null}),f=(0,L.useRef)(0),p=(0,L.useRef)(null),m=(0,L.useRef)({x:0,y:0}),h=(0,L.useRef)(null),g=(0,L.useRef)(!1),_=(0,L.useRef)(!1),v=(0,L.useRef)(!1),y=Hnr();return(0,L.useEffect)(()=>{if(e?.current){let c=bn(e.current),b=({x:e,y:t})=>{let{nodeInternals:n,onNodeDrag:r,onSelectionDrag:a,updateNodePositions:o,nodeExtent:c,snapGrid:f,snapToGrid:p,nodeOrigin:m,onError:g}=s.getState();d.current={x:e,y:t};let _=!1,v={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&c&&(v=Ier(vtr(u.current,m))),u.current=u.current.map(r=>{let i={x:e-r.distance.x,y:t-r.distance.y};p&&(i.x=f[0]*Math.round(i.x/f[0]),i.y=f[1]*Math.round(i.y/f[1]));let a=[[c[0][0],c[0][1]],[c[1][0],c[1][1]]];u.current.length>1&&c&&!r.extent&&(a[0][0]=r.positionAbsolute.x-v.x+c[0][0],a[1][0]=r.positionAbsolute.x+(r.width??0)-v.x2+c[1][0],a[0][1]=r.positionAbsolute.y-v.y+c[0][1],a[1][1]=r.positionAbsolute.y+(r.height??0)-v.y2+c[1][1]);let o=Rnr(r,i,n,a,m,g);return _=_||r.position.x!==o.position.x||r.position.y!==o.position.y,r.position=o.position,r.positionAbsolute=o.positionAbsolute,r}),!_)return;o(u.current,!0,!0),l(!0);let y=i?r:Unr(a);if(y&&h.current){let[e,t]=znr({nodeId:i,dragItems:u.current,nodeInternals:n});y(h.current,e,t)}},x=()=>{if(!p.current)return;let[e,t]=Ner(m.current,p.current);if(e!==0||t!==0){let{transform:n,panBy:r}=s.getState();d.current.x=(d.current.x??0)-e/n[2],d.current.y=(d.current.y??0)-t/n[2],r({x:e,y:t})&&b(d.current)}f.current=requestAnimationFrame(x)},S=t=>{let{nodeInternals:n,multiSelectionActive:r,nodesDraggable:c,unselectNodesAndEdges:l,onNodeDragStart:f,onSelectionDragStart:p}=s.getState();_.current=!0;let m=i?f:Unr(p);(!o||!a)&&!r&&i&&(n.get(i)?.selected||l()),i&&a&&o&&Vnr({id:i,store:s,nodeRef:e});let h=y(t);if(d.current=h,u.current=Inr(n,c,h,i),m&&u.current){let[e,r]=znr({nodeId:i,dragItems:u.current,nodeInternals:n});m(t.sourceEvent,e,r)}};if(t)c.on(`.drag`,null);else{let t=Cer().on(`start`,e=>{let{domNode:t,nodeDragThreshold:n}=s.getState();n===0&&S(e),v.current=!1;let r=y(e);d.current=r,p.current=t?.getBoundingClientRect()||null,m.current=L7(e.sourceEvent,p.current)}).on(`drag`,e=>{let t=y(e),{autoPanOnNodeDrag:n,nodeDragThreshold:r}=s.getState();if(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!g.current&&_.current&&n&&(g.current=!0,x()),!_.current){let n=t.xSnapped-(d?.current?.x??0),i=t.ySnapped-(d?.current?.y??0);Math.sqrt(n*n+i*i)>r&&S(e)}(d.current.x!==t.xSnapped||d.current.y!==t.ySnapped)&&u.current&&_.current&&(h.current=e.sourceEvent,m.current=L7(e.sourceEvent,p.current),b(t))}}).on(`end`,e=>{if(_.current&&!v.current&&(l(!1),g.current=!1,_.current=!1,cancelAnimationFrame(f.current),u.current)){let{updateNodePositions:t,nodeInternals:n,onNodeDragStop:r,onSelectionDragStop:a}=s.getState(),o=i?r:Unr(a);if(t(u.current,!1,!1),o){let[t,r]=znr({nodeId:i,dragItems:u.current,nodeInternals:n});o(e.sourceEvent,t,r)}}}).filter(t=>{let i=t.target;return!t.button&&(!n||!Fnr(i,`.${n}`,e))&&(!r||Fnr(i,r,e))});return c.call(t),()=>{c.on(`.drag`,null)}}}},[e,t,n,r,a,s,i,o,y]),c}function Gnr(){let e=N7();return(0,L.useCallback)(t=>{let{nodeInternals:n,nodeExtent:r,updateNodePositions:i,getNodes:a,snapToGrid:o,snapGrid:s,onError:c,nodesDraggable:l}=e.getState(),u=a().filter(e=>e.selected&&(e.draggable||l&&e.draggable===void 0)),d=o?s[0]:5,f=o?s[1]:5,p=t.isShiftPressed?4:1,m=t.x*d*p,h=t.y*f*p;i(u.map(e=>{if(e.positionAbsolute){let t={x:e.positionAbsolute.x+m,y:e.positionAbsolute.y+h};o&&(t.x=s[0]*Math.round(t.x/s[0]),t.y=s[1]*Math.round(t.y/s[1]));let{positionAbsolute:i,position:a}=Rnr(e,t,n,r,void 0,c);e.position=a,e.positionAbsolute=i}return e}),!0,!1)},[])}var u9={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},d9=e=>{let t=({id:t,type:n,data:r,xPos:i,yPos:a,xPosOrigin:o,yPosOrigin:s,selected:c,onClick:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:f,onContextMenu:p,onDoubleClick:m,style:h,className:g,isDraggable:_,isSelectable:v,isConnectable:y,isFocusable:b,selectNodesOnDrag:x,sourcePosition:S,targetPosition:C,hidden:w,resizeObserver:T,dragHandle:E,zIndex:D,isParent:O,noDragClassName:k,noPanClassName:A,initialized:j,disableKeyboardA11y:ee,ariaLabel:M,rfId:N,hasHandleBounds:P})=>{let te=N7(),ne=(0,L.useRef)(null),re=(0,L.useRef)(null),ie=(0,L.useRef)(S),ae=(0,L.useRef)(C),oe=(0,L.useRef)(n),se=v||_||l||u||d||f,ce=Gnr(),le=l9(t,te.getState,u),ue=l9(t,te.getState,d),de=l9(t,te.getState,f),fe=l9(t,te.getState,p),pe=l9(t,te.getState,m),me=e=>{let{nodeDragThreshold:n}=te.getState();if(v&&(!x||!_||n>0)&&Vnr({id:t,store:te,nodeRef:ne}),l){let n=te.getState().nodeInternals.get(t);n&&l(e,{...n})}},he=e=>{if(!Wer(e)&&!ee){if(Ver.includes(e.key)&&v){let n=e.key===`Escape`;Vnr({id:t,store:te,unselect:n,nodeRef:ne})}else _&&c&&Object.prototype.hasOwnProperty.call(u9,e.key)&&(te.setState({ariaLiveMessage:`Moved selected node ${e.key.replace(`Arrow`,``).toLowerCase()}. New position, x: ${~~i}, y: ${~~a}`}),ce({x:u9[e.key].x,y:u9[e.key].y,isShiftPressed:e.shiftKey}))}};(0,L.useEffect)(()=>()=>{re.current&&=(T?.unobserve(re.current),null)},[]),(0,L.useEffect)(()=>{if(ne.current&&!w){let e=ne.current;(!j||!P||re.current!==e)&&(re.current&&T?.unobserve(re.current),T?.observe(e),re.current=e)}},[w,j,P]),(0,L.useEffect)(()=>{let e=oe.current!==n,r=ie.current!==S,i=ae.current!==C;ne.current&&(e||r||i)&&(e&&(oe.current=n),r&&(ie.current=S),i&&(ae.current=C),te.getState().updateNodeDimensions([{id:t,nodeElement:ne.current,forceUpdate:!0}]))},[t,n,S,C]);let ge=Wnr({nodeRef:ne,disabled:w||!_,noDragClassName:k,handleSelector:E,nodeId:t,isSelectable:v,selectNodesOnDrag:x});return w?null:L.createElement(`div`,{className:D7([`react-flow__node`,`react-flow__node-${n}`,{[A]:_},g,{selected:c,selectable:v,parent:O,dragging:ge}]),ref:ne,style:{zIndex:D,transform:`translate(${o}px,${s}px)`,pointerEvents:se?`all`:`none`,visibility:j?`visible`:`hidden`,...h},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:le,onMouseMove:ue,onMouseLeave:de,onContextMenu:fe,onClick:me,onDoubleClick:pe,onKeyDown:b?he:void 0,tabIndex:b?0:void 0,role:b?`button`:void 0,"aria-describedby":ee?void 0:`${Qtr}-${N}`,"aria-label":M},L.createElement(ltr,{value:t},L.createElement(e,{id:t,data:r,type:n,xPos:i,yPos:a,selected:c,isConnectable:y,sourcePosition:S,targetPosition:C,dragging:ge,dragHandle:E,zIndex:D})))};return t.displayName=`NodeWrapper`,(0,L.memo)(t)},Knr=e=>({...vtr(e.getNodes().filter(e=>e.selected),e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive});function qnr({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=N7(),{width:i,height:a,x:o,y:s,transformString:c,userSelectionActive:l}=M7(Knr,O7),u=Gnr(),d=(0,L.useRef)(null);if((0,L.useEffect)(()=>{n||d.current?.focus({preventScroll:!0})},[n]),Wnr({nodeRef:d}),l||!i||!a)return null;let f=e?t=>{e(t,r.getState().getNodes().filter(e=>e.selected))}:void 0;return L.createElement(`div`,{className:D7([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:c}},L.createElement(`div`,{ref:d,className:`react-flow__nodesselection-rect`,onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(u9,e.key)&&u({x:u9[e.key].x,y:u9[e.key].y,isShiftPressed:e.shiftKey})},style:{width:i,height:a,top:s,left:o}}))}var Jnr=(0,L.memo)(qnr),Ynr=e=>e.nodesSelectionActive,Xnr=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,deleteKeyCode:s,onMove:c,onMoveStart:l,onMoveEnd:u,selectionKeyCode:d,selectionOnDrag:f,selectionMode:p,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:_,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:x,panOnScroll:S,panOnScrollSpeed:C,panOnScrollMode:w,zoomOnDoubleClick:T,panOnDrag:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,onSelectionContextMenu:ee,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P})=>{let te=M7(Ynr),ne=n9(d),re=n9(_),ie=re||E,ae=re||S,oe=ne||f&&ie!==!0;return _nr({deleteKeyCode:s,multiSelectionKeyCode:g}),L.createElement(wnr,{onMove:c,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:a,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:x,panOnScroll:ae,panOnScrollSpeed:C,panOnScrollMode:w,zoomOnDoubleClick:T,panOnDrag:!ne&&ie,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,zoomActivationKeyCode:v,preventScrolling:j,noWheelClassName:M,noPanClassName:N},L.createElement(Nnr,{onSelectionStart:m,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:ie,isSelecting:!!oe,selectionMode:p},e,te&&L.createElement(Jnr,{onSelectionContextMenu:ee,noPanClassName:N,disableKeyboardA11y:P})))};Xnr.displayName=`FlowRenderer`;var Znr=(0,L.memo)(Xnr);function Qnr(e){return M7((0,L.useCallback)(t=>e?ytr(t.nodeInternals,{x:0,y:0,width:t.width,height:t.height},t.transform,!0):t.getNodes(),[e]))}function $nr(e){let t={input:d9(e.input||ztr),default:d9(e.default||Ltr),output:d9(e.output||Vtr),group:d9(e.group||Htr)},n=Object.keys(e).filter(e=>![`input`,`default`,`output`,`group`].includes(e)).reduce((t,n)=>(t[n]=d9(e[n]||Ltr),t),{});return{...t,...n}}var err=({x:e,y:t,width:n,height:r,origin:i})=>!n||!r||i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-n*i[0],y:t-r*i[1]},trr=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),nrr=e=>{let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:a,onError:o}=M7(trr,O7),s=Qnr(e.onlyRenderVisibleElements),c=(0,L.useRef)(),l=(0,L.useMemo)(()=>{if(typeof ResizeObserver>`u`)return null;let e=new ResizeObserver(e=>{let t=e.map(e=>({id:e.target.getAttribute(`data-id`),nodeElement:e.target,forceUpdate:!0}));a(t)});return c.current=e,e},[]);return(0,L.useEffect)(()=>()=>{c?.current?.disconnect()},[]),L.createElement(`div`,{className:`react-flow__nodes`,style:ynr},s.map(a=>{let s=a.type||`default`;e.nodeTypes[s]||(o?.(`003`,j7.error003(s)),s=`default`);let c=e.nodeTypes[s]||e.nodeTypes.default,u=!!(a.draggable||t&&a.draggable===void 0),d=!!(a.selectable||i&&a.selectable===void 0),f=!!(a.connectable||n&&a.connectable===void 0),p=!!(a.focusable||r&&a.focusable===void 0),m=e.nodeExtent?jer(a.positionAbsolute,e.nodeExtent):a.positionAbsolute,h=m?.x??0,g=m?.y??0,_=err({x:h,y:g,width:a.width??0,height:a.height??0,origin:e.nodeOrigin});return L.createElement(c,{key:a.id,id:a.id,className:a.className,style:a.style,type:s,data:a.data,sourcePosition:a.sourcePosition||K7.Bottom,targetPosition:a.targetPosition||K7.Top,hidden:a.hidden,xPos:h,yPos:g,xPosOrigin:_.x,yPosOrigin:_.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!a.selected,isDraggable:u,isSelectable:d,isConnectable:f,isFocusable:p,resizeObserver:l,dragHandle:a.dragHandle,zIndex:a[I7]?.z??0,isParent:!!a[I7]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!a.width&&!!a.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:a.ariaLabel,hasHandleBounds:!!a[I7]?.handleBounds})}))};nrr.displayName=`NodeRenderer`;var rrr=(0,L.memo)(nrr),irr=(e,t,n)=>n===K7.Left?e-t:n===K7.Right?e+t:e,arr=(e,t,n)=>n===K7.Top?e-t:n===K7.Bottom?e+t:e,orr=`react-flow__edgeupdater`,srr=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s})=>L.createElement(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:D7([orr,`${orr}-${s}`]),cx:irr(t,r,e),cy:arr(n,r,e),r,stroke:`transparent`,fill:`transparent`}),crr=()=>!0,f9=e=>{let t=({id:t,className:n,type:r,data:i,onClick:a,onEdgeDoubleClick:o,selected:s,animated:c,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:h,source:g,target:_,sourceX:v,sourceY:y,targetX:b,targetY:x,sourcePosition:S,targetPosition:C,elementsSelectable:w,hidden:T,sourceHandleId:E,targetHandleId:D,onContextMenu:O,onMouseEnter:k,onMouseMove:A,onMouseLeave:j,reconnectRadius:ee,onReconnect:M,onReconnectStart:N,onReconnectEnd:P,markerEnd:te,markerStart:ne,rfId:re,ariaLabel:ie,isFocusable:ae,isReconnectable:oe,pathOptions:se,interactionWidth:ce,disableKeyboardA11y:le})=>{let ue=(0,L.useRef)(null),[de,fe]=(0,L.useState)(!1),[pe,me]=(0,L.useState)(!1),he=N7(),ge=(0,L.useMemo)(()=>`url('#${ptr(ne,re)}')`,[ne,re]),_e=(0,L.useMemo)(()=>`url('#${ptr(te,re)}')`,[te,re]);if(T)return null;let ve=e=>{let{edges:n,addSelectedEdges:r,unselectNodesAndEdges:i,multiSelectionActive:o}=he.getState(),s=n.find(e=>e.id===t);s&&(w&&(he.setState({nodesSelectionActive:!1}),s.selected&&o?(i({nodes:[],edges:[s]}),ue.current?.blur()):r([t])),a&&a(e,s))},ye=B7(t,he.getState,o),be=B7(t,he.getState,O),xe=B7(t,he.getState,k),Se=B7(t,he.getState,A),Ce=B7(t,he.getState,j),we=(e,n)=>{if(e.button!==0)return;let{edges:r,isValidConnection:i}=he.getState(),a=n?_:g,o=(n?D:E)||null,s=n?`target`:`source`,c=i||crr,l=n,u=r.find(e=>e.id===t);me(!0),N?.(e,u,s),jtr({event:e,handleId:o,nodeId:a,onConnect:e=>M?.(u,e),isTarget:l,getState:he.getState,setState:he.setState,isValidConnection:c,edgeUpdaterType:s,onReconnectEnd:e=>{me(!1),P?.(e,u,s)}})},Te=e=>we(e,!0),Ee=e=>we(e,!1),De=()=>fe(!0),Oe=()=>fe(!1),ke=!w&&!a;return L.createElement(`g`,{className:D7([`react-flow__edge`,`react-flow__edge-${r}`,n,{selected:s,animated:c,inactive:ke,updating:de}]),onClick:ve,onDoubleClick:ye,onContextMenu:be,onMouseEnter:xe,onMouseMove:Se,onMouseLeave:Ce,onKeyDown:ae?e=>{if(!le&&Ver.includes(e.key)&&w){let{unselectNodesAndEdges:n,addSelectedEdges:r,edges:i}=he.getState();e.key===`Escape`?(ue.current?.blur(),n({edges:[i.find(e=>e.id===t)]})):r([t])}}:void 0,tabIndex:ae?0:void 0,role:ae?`button`:`img`,"data-testid":`rf__edge-${t}`,"aria-label":ie===null?void 0:ie||`Edge from ${g} to ${_}`,"aria-describedby":ae?`${$tr}-${re}`:void 0,ref:ue},!pe&&L.createElement(e,{id:t,source:g,target:_,selected:s,animated:c,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,data:i,style:h,sourceX:v,sourceY:y,targetX:b,targetY:x,sourcePosition:S,targetPosition:C,sourceHandleId:E,targetHandleId:D,markerStart:ge,markerEnd:_e,pathOptions:se,interactionWidth:ce}),oe&&L.createElement(L.Fragment,null,(oe===`source`||oe===!0)&&L.createElement(srr,{position:S,centerX:v,centerY:y,radius:ee,onMouseDown:Te,onMouseEnter:De,onMouseOut:Oe,type:`source`}),(oe===`target`||oe===!0)&&L.createElement(srr,{position:C,centerX:b,centerY:x,radius:ee,onMouseDown:Ee,onMouseEnter:De,onMouseOut:Oe,type:`target`})))};return t.displayName=`EdgeWrapper`,(0,L.memo)(t)};function lrr(e){let t={default:f9(e.default||Y7),straight:f9(e.bezier||atr),step:f9(e.step||rtr),smoothstep:f9(e.step||q7),simplebezier:f9(e.simplebezier||Xer)},n=Object.keys(e).filter(e=>![`default`,`bezier`].includes(e)).reduce((t,n)=>(t[n]=f9(e[n]||Y7),t),{});return{...t,...n}}function urr(e,t,n=null){let r=(n?.x||0)+t.x,i=(n?.y||0)+t.y,a=n?.width||t.width,o=n?.height||t.height;switch(e){case K7.Top:return{x:r+a/2,y:i};case K7.Right:return{x:r+a,y:i+o/2};case K7.Bottom:return{x:r+a/2,y:i+o};case K7.Left:return{x:r,y:i+o/2}}}function drr(e,t){return e?e.length===1||!t?e[0]:t&&e.find(e=>e.id===t)||null:null}var frr=(e,t,n,r,i,a)=>{let o=urr(n,e,t),s=urr(a,r,i);return{sourceX:o.x,sourceY:o.y,targetX:s.x,targetY:s.y}};function prr({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:a,width:o,height:s,transform:c}){let l={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+i),y2:Math.max(e.y+r,t.y+a)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);let u=Ier({x:(0-c[0])/c[2],y:(0-c[1])/c[2],width:o/c[2],height:s/c[2]}),d=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),f=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(d*f)>0}function mrr(e){let t=e?.[I7]?.handleBounds||null,n=t&&e?.width&&e?.height&&e?.positionAbsolute?.x!==void 0&&e?.positionAbsolute?.y!==void 0;return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}var hrr=[{level:0,isMaxLevel:!0,edges:[]}];function grr(e,t,n=!1){let r=-1,i=e.reduce((e,i)=>{let a=F7(i.zIndex),o=a?i.zIndex:0;if(n){let e=t.get(i.target),n=t.get(i.source),r=i.selected||e?.selected||n?.selected,s=Math.max(n?.[I7]?.z||0,e?.[I7]?.z||0,1e3);o=(a?i.zIndex:0)+(r?s:0)}return e[o]?e[o].push(i):e[o]=[i],r=o>r?o:r,e},{}),a=Object.entries(i).map(([e,t])=>{let n=+e;return{edges:t,level:n,isMaxLevel:n===r}});return a.length===0?hrr:a}function _rr(e,t,n){return grr(M7((0,L.useCallback)(n=>e?n.edges.filter(e=>{let r=t.get(e.source),i=t.get(e.target);return r?.width&&r?.height&&i?.width&&i?.height&&prr({sourcePos:r.positionAbsolute||{x:0,y:0},targetPos:i.positionAbsolute||{x:0,y:0},sourceWidth:r.width,sourceHeight:r.height,targetWidth:i.width,targetHeight:i.height,width:n.width,height:n.height,transform:n.transform})}):n.edges,[e,t])),t,n)}var vrr=({color:e=`none`,strokeWidth:t=1})=>L.createElement(`polyline`,{style:{stroke:e,strokeWidth:t},strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,points:`-5,-4 0,0 -5,4`}),yrr=({color:e=`none`,strokeWidth:t=1})=>L.createElement(`polyline`,{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),brr={[G7.Arrow]:vrr,[G7.ArrowClosed]:yrr};function xrr(e){let t=N7();return(0,L.useMemo)(()=>Object.prototype.hasOwnProperty.call(brr,e)?brr[e]:(t.getState().onError?.(`009`,j7.error009(e)),null),[e])}var Srr=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=xrr(t);return c?L.createElement(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`},L.createElement(c,{color:n,strokeWidth:o})):null},Crr=({defaultColor:e,rfId:t})=>n=>{let r=[];return n.edges.reduce((n,i)=>([i.markerStart,i.markerEnd].forEach(i=>{if(i&&typeof i==`object`){let a=ptr(i,t);r.includes(a)||(n.push({id:a,color:i.color||e,...i}),r.push(a))}}),n),[]).sort((e,t)=>e.id.localeCompare(t.id))},wrr=({defaultColor:e,rfId:t})=>{let n=M7((0,L.useCallback)(Crr({defaultColor:e,rfId:t}),[e,t]),(e,t)=>!(e.length!==t.length||e.some((e,n)=>e.id!==t[n].id)));return L.createElement(`defs`,null,n.map(e=>L.createElement(Srr,{id:e.id,key:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient})))};wrr.displayName=`MarkerDefinitions`;var Trr=(0,L.memo)(wrr),Err=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Drr=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,reconnectRadius:h,children:g,disableKeyboardA11y:_})=>{let{edgesFocusable:v,edgesUpdatable:y,elementsSelectable:b,width:x,height:S,connectionMode:C,nodeInternals:w,onError:T}=M7(Err,O7),E=_rr(t,w,n);return x?L.createElement(L.Fragment,null,E.map(({level:t,edges:n,isMaxLevel:g})=>L.createElement(`svg`,{key:t,style:{zIndex:t},width:x,height:S,className:`react-flow__edges react-flow__container`},g&&L.createElement(Trr,{defaultColor:e,rfId:r}),L.createElement(`g`,null,n.map(e=>{let[t,n,g]=mrr(w.get(e.source)),[x,S,E]=mrr(w.get(e.target));if(!g||!E)return null;let D=e.type||`default`;i[D]||(T?.(`011`,j7.error011(D)),D=`default`);let O=i[D]||i.default,k=C===V7.Strict?S.target:(S.target??[]).concat(S.source??[]),A=drr(n.source,e.sourceHandle),j=drr(k,e.targetHandle),ee=A?.position||K7.Bottom,M=j?.position||K7.Top,N=!!(e.focusable||v&&e.focusable===void 0),P=e.reconnectable||e.updatable,te=f!==void 0&&(P||y&&P===void 0);if(!A||!j)return T?.(`008`,j7.error008(A,e)),null;let{sourceX:ne,sourceY:re,targetX:ie,targetY:ae}=frr(t,A,ee,x,j,M);return L.createElement(O,{key:e.id,id:e.id,className:D7([e.className,a]),type:D,data:e.data,selected:!!e.selected,animated:!!e.animated,hidden:!!e.hidden,label:e.label,labelStyle:e.labelStyle,labelShowBg:e.labelShowBg,labelBgStyle:e.labelBgStyle,labelBgPadding:e.labelBgPadding,labelBgBorderRadius:e.labelBgBorderRadius,style:e.style,source:e.source,target:e.target,sourceHandleId:e.sourceHandle,targetHandleId:e.targetHandle,markerEnd:e.markerEnd,markerStart:e.markerStart,sourceX:ne,sourceY:re,targetX:ie,targetY:ae,sourcePosition:ee,targetPosition:M,elementsSelectable:b,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,reconnectRadius:h,rfId:r,ariaLabel:e.ariaLabel,isFocusable:N,isReconnectable:te,pathOptions:`pathOptions`in e?e.pathOptions:void 0,interactionWidth:e.interactionWidth,disableKeyboardA11y:_})})))),g):null};Drr.displayName=`EdgeRenderer`;var Orr=(0,L.memo)(Drr),krr=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Arr({children:e}){let t=M7(krr);return L.createElement(`div`,{className:`react-flow__viewport react-flow__container`,style:{transform:t}},e)}function jrr(e){let t=hnr(),n=(0,L.useRef)(!1);(0,L.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Mrr={[K7.Left]:K7.Right,[K7.Right]:K7.Left,[K7.Top]:K7.Bottom,[K7.Bottom]:K7.Top},Nrr=({nodeId:e,handleType:t,style:n,type:r=W7.Bezier,CustomComponent:i,connectionStatus:a})=>{let{fromNode:o,handleId:s,toX:c,toY:l,connectionMode:u}=M7((0,L.useCallback)(t=>({fromNode:t.nodeInternals.get(e),handleId:t.connectionHandleId,toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2],connectionMode:t.connectionMode}),[e]),O7),d=o?.[I7]?.handleBounds,f=d?.[t];if(u===V7.Loose&&(f||=d?.[t===`source`?`target`:`source`]),!o||!f)return null;let p=s?f.find(e=>e.id===s):f[0],m=p?p.x+p.width/2:(o.width??0)/2,h=p?p.y+p.height/2:o.height??0,g=(o.positionAbsolute?.x??0)+m,_=(o.positionAbsolute?.y??0)+h,v=p?.position,y=v?Mrr[v]:null;if(!v||!y)return null;if(i)return L.createElement(i,{connectionLineType:r,connectionLineStyle:n,fromNode:o,fromHandle:p,fromX:g,fromY:_,toX:c,toY:l,fromPosition:v,toPosition:y,connectionStatus:a});let b=``,x={sourceX:g,sourceY:_,sourcePosition:v,targetX:c,targetY:l,targetPosition:y};return r===W7.Bezier?[b]=str(x):r===W7.Step?[b]=ntr({...x,borderRadius:0}):r===W7.SmoothStep?[b]=ntr(x):r===W7.SimpleBezier?[b]=Yer(x):b=`M${g},${_} ${c},${l}`,L.createElement(`path`,{d:b,fill:`none`,className:`react-flow__connection-path`,style:n})};Nrr.displayName=`ConnectionLine`;var Prr=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Frr({containerStyle:e,style:t,type:n,component:r}){let{nodeId:i,handleType:a,nodesConnectable:o,width:s,height:c,connectionStatus:l}=M7(Prr,O7);return i&&a&&s&&o?L.createElement(`svg`,{style:e,width:s,height:c,className:`react-flow__edges react-flow__connectionline react-flow__container`},L.createElement(`g`,{className:D7([`react-flow__connection`,l])},L.createElement(Nrr,{nodeId:i,handleType:a,style:t,type:n,CustomComponent:r,connectionStatus:l}))):null}function Irr(e,t){return(0,L.useRef)(null),N7(),(0,L.useMemo)(()=>t(e),[e])}var Lrr=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:a,onNodeClick:o,onEdgeClick:s,onNodeDoubleClick:c,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:p,onSelectionContextMenu:m,onSelectionStart:h,onSelectionEnd:g,connectionLineType:_,connectionLineStyle:v,connectionLineComponent:y,connectionLineContainerStyle:b,selectionKeyCode:x,selectionOnDrag:S,selectionMode:C,multiSelectionKeyCode:w,panActivationKeyCode:T,zoomActivationKeyCode:E,deleteKeyCode:D,onlyRenderVisibleElements:O,elementsSelectable:k,selectNodesOnDrag:A,defaultViewport:j,translateExtent:ee,minZoom:M,maxZoom:N,preventScrolling:P,defaultMarkerColor:te,zoomOnScroll:ne,zoomOnPinch:re,panOnScroll:ie,panOnScrollSpeed:ae,panOnScrollMode:oe,zoomOnDoubleClick:se,panOnDrag:ce,onPaneClick:le,onPaneMouseEnter:ue,onPaneMouseMove:de,onPaneMouseLeave:fe,onPaneScroll:pe,onPaneContextMenu:me,onEdgeContextMenu:he,onEdgeMouseEnter:ge,onEdgeMouseMove:_e,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:be,onReconnectEnd:xe,reconnectRadius:Se,noDragClassName:Ce,noWheelClassName:we,noPanClassName:Te,elevateEdgesOnSelect:Ee,disableKeyboardA11y:De,nodeOrigin:Oe,nodeExtent:ke,rfId:Ae})=>{let je=Irr(e,$nr),Me=Irr(t,lrr);return jrr(a),L.createElement(Znr,{onPaneClick:le,onPaneMouseEnter:ue,onPaneMouseMove:de,onPaneMouseLeave:fe,onPaneContextMenu:me,onPaneScroll:pe,deleteKeyCode:D,selectionKeyCode:x,selectionOnDrag:S,selectionMode:C,onSelectionStart:h,onSelectionEnd:g,multiSelectionKeyCode:w,panActivationKeyCode:T,zoomActivationKeyCode:E,elementsSelectable:k,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:ne,zoomOnPinch:re,zoomOnDoubleClick:se,panOnScroll:ie,panOnScrollSpeed:ae,panOnScrollMode:oe,panOnDrag:ce,defaultViewport:j,translateExtent:ee,minZoom:M,maxZoom:N,onSelectionContextMenu:m,preventScrolling:P,noDragClassName:Ce,noWheelClassName:we,noPanClassName:Te,disableKeyboardA11y:De},L.createElement(Arr,null,L.createElement(Orr,{edgeTypes:Me,onEdgeClick:s,onEdgeDoubleClick:l,onlyRenderVisibleElements:O,onEdgeContextMenu:he,onEdgeMouseEnter:ge,onEdgeMouseMove:_e,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:be,onReconnectEnd:xe,reconnectRadius:Se,defaultMarkerColor:te,noPanClassName:Te,elevateEdgesOnSelect:!!Ee,disableKeyboardA11y:De,rfId:Ae},L.createElement(Frr,{style:v,type:_,component:y,containerStyle:b})),L.createElement(`div`,{className:`react-flow__edgelabel-renderer`}),L.createElement(rrr,{nodeTypes:je,onNodeClick:o,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:p,selectNodesOnDrag:A,onlyRenderVisibleElements:O,noPanClassName:Te,noDragClassName:Ce,disableKeyboardA11y:De,nodeOrigin:Oe,nodeExtent:ke,rfId:Ae})))};Lrr.displayName=`GraphView`;var Rrr=(0,L.memo)(Lrr),zrr=[[-1/0,-1/0],[1/0,1/0]],p9={rfId:`1`,width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:zrr,nodeExtent:zrr,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:`source`,connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:V7.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:Her,isValidConnection:void 0},Brr=()=>_er((e,t)=>({...p9,setNodes:n=>{let{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:a}=t();e({nodeInternals:cnr(n,r,i,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{let{defaultEdgeOptions:r={}}=t();e({edges:n.map(e=>({...r,...e}))})},setDefaultNodesAndEdges:(n,r)=>{let i=n!==void 0,a=r!==void 0;e({nodeInternals:i?cnr(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map,edges:a?r:[],hasDefaultNodes:i,hasDefaultEdges:a})},updateNodeDimensions:n=>{let{onNodesChange:r,nodeInternals:i,fitViewOnInit:a,fitViewOnInitDone:o,fitViewOnInitOptions:s,domNode:c,nodeOrigin:l}=t(),u=c?.querySelector(`.react-flow__viewport`);if(!u)return;let d=window.getComputedStyle(u),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=n.reduce((e,t)=>{let n=i.get(t.id);if(n?.hidden)i.set(n.id,{...n,[I7]:{...n[I7],handleBounds:void 0}});else if(n){let r=Aer(t.nodeElement);r.width&&r.height&&(n.width!==r.width||n.height!==r.height||t.forceUpdate)&&(i.set(n.id,{...n,[I7]:{...n[I7],handleBounds:{source:Bnr(`.source`,t.nodeElement,f,l),target:Bnr(`.target`,t.nodeElement,f,l)}},...r}),e.push({id:n.id,type:`dimensions`,dimensions:r}))}return e},[]);snr(i,l);let m=o||a&&!o&&lnr(t,{initial:!0,...s});e({nodeInternals:new Map(i),fitViewOnInitDone:m}),p?.length>0&&r?.(p)},updateNodePositions:(e,n=!0,r=!1)=>{let{triggerNodeChanges:i}=t();i(e.map(e=>{let t={id:e.id,type:`position`,dragging:r};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t}))},triggerNodeChanges:n=>{let{onNodesChange:r,nodeInternals:i,hasDefaultNodes:a,nodeOrigin:o,getNodes:s,elevateNodesOnSelect:c}=t();n?.length&&(a&&e({nodeInternals:cnr(knr(n,s()),i,o,c)}),r?.(n))},addSelectedNodes:n=>{let{multiSelectionActive:r,edges:i,getNodes:a}=t(),o,s=null;r?o=n.map(e=>s9(e,!0)):(o=c9(a(),n),s=c9(i,[])),r9({changedNodes:o,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{let{multiSelectionActive:r,edges:i,getNodes:a}=t(),o,s=null;r?o=n.map(e=>s9(e,!0)):(o=c9(i,n),s=c9(a(),[])),r9({changedNodes:s,changedEdges:o,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{let{edges:i,getNodes:a}=t(),o=n||a(),s=r||i;r9({changedNodes:o.map(e=>(e.selected=!1,s9(e.id,!1))),changedEdges:s.map(e=>s9(e.id,!1)),get:t,set:e})},setMinZoom:n=>{let{d3Zoom:r,maxZoom:i}=t();r?.scaleExtent([n,i]),e({minZoom:n})},setMaxZoom:n=>{let{d3Zoom:r,minZoom:i}=t();r?.scaleExtent([i,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{let{edges:n,getNodes:r}=t();r9({changedNodes:r().filter(e=>e.selected).map(e=>s9(e.id,!1)),changedEdges:n.filter(e=>e.selected).map(e=>s9(e.id,!1)),get:t,set:e})},setNodeExtent:n=>{let{nodeInternals:r}=t();r.forEach(e=>{e.positionAbsolute=jer(e.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:e=>{let{transform:n,width:r,height:i,d3Zoom:a,d3Selection:o,translateExtent:s}=t();if(!a||!o||!e.x&&!e.y)return!1;let c=yn.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),l=[[0,0],[r,i]],u=a?.constrain()(c,l,s);return a.transform(o,u),n[0]!==u.x||n[1]!==u.y||n[2]!==u.k},cancelConnection:()=>e({connectionNodeId:p9.connectionNodeId,connectionHandleId:p9.connectionHandleId,connectionHandleType:p9.connectionHandleType,connectionStatus:p9.connectionStatus,connectionStartHandle:p9.connectionStartHandle,connectionEndHandle:p9.connectionEndHandle}),reset:()=>e({...p9})}),Object.is),Vrr=({children:e})=>{let t=(0,L.useRef)(null);return t.current||=Brr(),L.createElement(wer,{value:t.current},e)};Vrr.displayName=`ReactFlowProvider`;var Hrr=({children:e})=>(0,L.useContext)(A7)?L.createElement(L.Fragment,null,e):L.createElement(Vrr,null,e);Hrr.displayName=`ReactFlowWrapper`;var Urr={input:ztr,default:Ltr,output:Vtr,group:Htr},Wrr={default:Y7,straight:atr,step:rtr,smoothstep:q7,simplebezier:Xer},Grr=[0,0],Krr=[15,15],qrr={x:0,y:0,zoom:1},Jrr={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0},Yrr=(0,L.forwardRef)(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a=Urr,edgeTypes:o=Wrr,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onSelectionChange:O,onSelectionDragStart:k,onSelectionDrag:A,onSelectionDragStop:j,onSelectionContextMenu:ee,onSelectionStart:M,onSelectionEnd:N,connectionMode:P=V7.Strict,connectionLineType:te=W7.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ie,deleteKeyCode:ae=`Backspace`,selectionKeyCode:oe=`Shift`,selectionOnDrag:se=!1,selectionMode:ce=U7.Full,panActivationKeyCode:le=`Space`,multiSelectionKeyCode:ue=R7()?`Meta`:`Control`,zoomActivationKeyCode:de=R7()?`Meta`:`Control`,snapToGrid:fe=!1,snapGrid:pe=Krr,onlyRenderVisibleElements:me=!1,selectNodesOnDrag:he=!0,nodesDraggable:ge,nodesConnectable:_e,nodesFocusable:ve,nodeOrigin:ye=Grr,edgesFocusable:be,edgesUpdatable:xe,elementsSelectable:Se,defaultViewport:Ce=qrr,minZoom:we=.5,maxZoom:Te=2,translateExtent:Ee=zrr,preventScrolling:De=!0,nodeExtent:Oe,defaultMarkerColor:ke=`#b1b1b7`,zoomOnScroll:Ae=!0,zoomOnPinch:je=!0,panOnScroll:Me=!1,panOnScrollSpeed:Ne=.5,panOnScrollMode:Pe=H7.Free,zoomOnDoubleClick:Fe=!0,panOnDrag:Ie=!0,onPaneClick:Le,onPaneMouseEnter:Re,onPaneMouseMove:ze,onPaneMouseLeave:Be,onPaneScroll:Ve,onPaneContextMenu:He,children:Ue,onEdgeContextMenu:We,onEdgeDoubleClick:Ge,onEdgeMouseEnter:Ke,onEdgeMouseMove:qe,onEdgeMouseLeave:Je,onEdgeUpdate:Ye,onEdgeUpdateStart:Xe,onEdgeUpdateEnd:Ze,onReconnect:Qe,onReconnectStart:$e,onReconnectEnd:et,reconnectRadius:tt=10,edgeUpdaterRadius:nt=10,onNodesChange:rt,onEdgesChange:it,noDragClassName:at=`nodrag`,noWheelClassName:ot=`nowheel`,noPanClassName:st=`nopan`,fitView:ct=!1,fitViewOptions:lt,connectOnClick:ut=!0,attributionPosition:dt,proOptions:ft,defaultEdgeOptions:pt,elevateNodesOnSelect:mt=!0,elevateEdgesOnSelect:ht=!1,disableKeyboardA11y:gt=!1,autoPanOnConnect:_t=!0,autoPanOnNodeDrag:vt=!0,connectionRadius:yt=20,isValidConnection:bt,onError:xt,style:St,id:Ct,nodeDragThreshold:eee,...wt},Tt)=>{let Et=Ct||`1`;return L.createElement(`div`,{...wt,style:{...St,...Jrr},ref:Tt,className:D7([`react-flow`,i]),"data-testid":`rf__wrapper`,id:Ct},L.createElement(Hrr,null,L.createElement(Rrr,{onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:te,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ie,selectionKeyCode:oe,selectionOnDrag:se,selectionMode:ce,deleteKeyCode:ae,multiSelectionKeyCode:ue,panActivationKeyCode:le,zoomActivationKeyCode:de,onlyRenderVisibleElements:me,selectNodesOnDrag:he,defaultViewport:Ce,translateExtent:Ee,minZoom:we,maxZoom:Te,preventScrolling:De,zoomOnScroll:Ae,zoomOnPinch:je,zoomOnDoubleClick:Fe,panOnScroll:Me,panOnScrollSpeed:Ne,panOnScrollMode:Pe,panOnDrag:Ie,onPaneClick:Le,onPaneMouseEnter:Re,onPaneMouseMove:ze,onPaneMouseLeave:Be,onPaneScroll:Ve,onPaneContextMenu:He,onSelectionContextMenu:ee,onSelectionStart:M,onSelectionEnd:N,onEdgeContextMenu:We,onEdgeDoubleClick:Ge,onEdgeMouseEnter:Ke,onEdgeMouseMove:qe,onEdgeMouseLeave:Je,onReconnect:Qe??Ye,onReconnectStart:$e??Xe,onReconnectEnd:et??Ze,reconnectRadius:tt??nt,defaultMarkerColor:ke,noDragClassName:at,noWheelClassName:ot,noPanClassName:st,elevateEdgesOnSelect:ht,rfId:Et,disableKeyboardA11y:gt,nodeOrigin:ye,nodeExtent:Oe}),L.createElement(Ytr,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:ge,nodesConnectable:_e,nodesFocusable:ve,edgesFocusable:be,edgesUpdatable:xe,elementsSelectable:Se,elevateNodesOnSelect:mt,minZoom:we,maxZoom:Te,nodeExtent:Oe,onNodesChange:rt,onEdgesChange:it,snapToGrid:fe,snapGrid:pe,connectionMode:P,translateExtent:Ee,connectOnClick:ut,defaultEdgeOptions:pt,fitView:ct,fitViewOptions:lt,onNodesDelete:E,onEdgesDelete:D,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:A,onSelectionDragStart:k,onSelectionDragStop:j,noPanClassName:st,nodeOrigin:ye,rfId:Et,autoPanOnConnect:_t,autoPanOnNodeDrag:vt,onError:xt,connectionRadius:yt,isValidConnection:bt,nodeDragThreshold:eee}),L.createElement(qtr,{onSelectionChange:O}),Ue,L.createElement(Oer,{proOptions:ft,position:dt}),L.createElement(rnr,{rfId:Et,disableKeyboardA11y:gt})))});Yrr.displayName=`ReactFlow`;function Xrr(e){return t=>{let[n,r]=(0,L.useState)(t);return[n,r,(0,L.useCallback)(t=>r(n=>e(t,n)),[])]}}var Zrr=Xrr(knr),Qrr=Xrr(Anr);function $rr(){return L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`},L.createElement(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`}))}function eir(){return L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`},L.createElement(`path`,{d:`M0 0h32v4.2H0z`}))}function tir(){return L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`},L.createElement(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`}))}function nir(){return L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`},L.createElement(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`}))}function rir(){return L.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`},L.createElement(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`}))}var m9=({children:e,className:t,...n})=>L.createElement(`button`,{type:`button`,className:D7([`react-flow__controls-button`,t]),...n},e);m9.displayName=`ControlButton`;var iir=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),air=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`})=>{let f=N7(),[p,m]=(0,L.useState)(!1),{isInteractive:h,minZoomReached:g,maxZoomReached:_}=M7(iir,O7),{zoomIn:v,zoomOut:y,fitView:b}=hnr();return(0,L.useEffect)(()=>{m(!0)},[]),p?L.createElement(Der,{className:D7([`react-flow__controls`,l]),position:d,style:e,"data-testid":`rf__controls`},t&&L.createElement(L.Fragment,null,L.createElement(m9,{onClick:()=>{v(),a?.()},className:`react-flow__controls-zoomin`,title:`zoom in`,"aria-label":`zoom in`,disabled:_},L.createElement($rr,null)),L.createElement(m9,{onClick:()=>{y(),o?.()},className:`react-flow__controls-zoomout`,title:`zoom out`,"aria-label":`zoom out`,disabled:g},L.createElement(eir,null))),n&&L.createElement(m9,{className:`react-flow__controls-fitview`,onClick:()=>{b(i),s?.()},title:`fit view`,"aria-label":`fit view`},L.createElement(tir,null)),r&&L.createElement(m9,{className:`react-flow__controls-interactive`,onClick:()=>{f.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:`toggle interactivity`,"aria-label":`toggle interactivity`},h?L.createElement(rir,null):L.createElement(nir,null)),u):null};air.displayName=`Controls`;var oir=(0,L.memo)(air),h9;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(h9||={});function sir({color:e,dimensions:t,lineWidth:n}){return L.createElement(`path`,{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function cir({color:e,radius:t}){return L.createElement(`circle`,{cx:t,cy:t,r:t,fill:e})}var lir={[h9.Dots]:`#91919a`,[h9.Lines]:`#eee`,[h9.Cross]:`#e2e2e2`},uir={[h9.Dots]:1,[h9.Lines]:1,[h9.Cross]:6},dir=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function fir({id:e,variant:t=h9.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=2,color:o,style:s,className:c}){let l=(0,L.useRef)(null),{transform:u,patternId:d}=M7(dir,O7),f=o||lir[t],p=r||uir[t],m=t===h9.Dots,h=t===h9.Cross,g=Array.isArray(n)?n:[n,n],_=[g[0]*u[2]||1,g[1]*u[2]||1],v=p*u[2],y=h?[v,v]:_,b=m?[v/a,v/a]:[y[0]/a,y[1]/a];return L.createElement(`svg`,{className:D7([`react-flow__background`,c]),style:{...s,position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},ref:l,"data-testid":`rf__background`},L.createElement(`pattern`,{id:d+e,x:u[0]%_[0],y:u[1]%_[1],width:_[0],height:_[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${b[0]},-${b[1]})`},m?L.createElement(cir,{color:f,radius:v/a}):L.createElement(sir,{dimensions:y,color:f,lineWidth:i})),L.createElement(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${d+e})`}))}fir.displayName=`Background`;var pir=(0,L.memo)(fir),mir=Object.defineProperty,hir=(e,t,n)=>t in e?mir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gir=(e,t)=>{for(var n in t)mir(e,n,{get:t[n],enumerable:!0})},_ir=(e,t,n)=>hir(e,typeof t==`symbol`?t:t+``,n),vir={};gir(vir,{Graph:()=>y9,alg:()=>Air});var yir=Object.defineProperty,bir=(e,t)=>{for(var n in t)yir(e,n,{get:t[n],enumerable:!0})},xir=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=g9(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=wir(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Sir(this._preds[a],i),Sir(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Tir(this._isDirected,e):g9(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Tir(this._isDirected,e):g9(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Tir(this._isDirected,e):g9(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Cir(this._preds[t],e),Cir(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Sir(e,t){e[t]?e[t]++:e[t]=1}function Cir(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function g9(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function wir(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function Tir(e,t){return g9(e,t.v,t.w,t.name)}bir({},{read:()=>kir,write:()=>Eir});function Eir(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Dir(e),edges:Oir(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Dir(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function Oir(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function kir(e){let t=new xir(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var Air={};bir(Air,{CycleException:()=>v9,bellmanFord:()=>Mir,components:()=>Pir,dijkstra:()=>_9,dijkstraAll:()=>Rir,findCycles:()=>Bir,floydWarshall:()=>Hir,isAcyclic:()=>Gir,postorder:()=>Yir,preorder:()=>Xir,prim:()=>Zir,shortestPaths:()=>Qir,tarjan:()=>zir,topsort:()=>Wir});var jir=()=>1;function Mir(e,t,n,r){return Nir(e,String(t),n||jir,r||function(t){return e.outEdges(t)??[]})}function Nir(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function Pir(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var Fir=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},Iir=()=>1;function _9(e,t,n,r){return Lir(e,String(t),n||Iir,r||function(t){return e.outEdges(t)??[]})}function Lir(e,t,n,r){let i={},a=new Fir,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function Rir(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=_9(e,i,t,n),r},{})}function zir(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function Bir(e){return zir(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var Vir=()=>1;function Hir(e,t,n){return Uir(e,t||Vir,n||function(t){return e.outEdges(t)??[]})}function Uir(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var v9=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function Wir(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new v9;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new v9;return r}function Gir(e){try{Wir(e)}catch(e){if(e instanceof v9)return!1;throw e}return!0}function Kir(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=qir(e,t,n===`post`,o,a,r,i)}),i}function qir(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=qir(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function Jir(e,t,n){return Kir(e,t,n,function(e,t){return e.push(t),e},[])}function Yir(e,t){return Jir(e,t,`post`)}function Xir(e,t){return Jir(e,t,`pre`)}function Zir(e,t){var n;let r=new xir,i={},a=new Fir,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function Qir(e,t,n,r){return $ir(e,t,n,r??(t=>e.outEdges(t)??[]))}function $ir(e,t,n,r){if(n===void 0)return _9(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return Mir(e,t,n,r)}return _9(e,t,n,r)}var y9=xir;function b9(e,t,n,r){let i=r;for(;e.hasNode(i);)i=par(r);return n.dummy=t,e.setNode(i,n),i}function ear(e){let t=new y9().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function tar(e){let t=new y9({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function nar(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function x9(e){let t=C9(car(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function rar(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=S9(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function iar(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=S9(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function aar(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),b9(e,`border`,i,t)}function oar(e,t=sar){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var sar=65535;function S9(e,t){return t.length>sar?e(...oar(t).map(t=>e(...t))):e(...t)}function car(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return S9(Math.max,t)}function lar(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function uar(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function dar(e,t){return t()}var far=0;function par(e){return e+(``+ ++far)}function C9(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function w9(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function T9(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function mar(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var E9=`\0`;function har(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var gar=`3.1.1`,_ar=class{constructor(){_ir(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return yar(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&yar(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,bar)),n=n._prev;return`[`+e.join(`, `)+`]`}};function yar(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function bar(e,t){if(e!==`_next`&&e!==`_prev`)return t}var xar=_ar,Sar=()=>1;function Car(e,t){if(e.nodeCount()<=1)return[];let n=Ear(e,t||Sar);return war(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function war(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)Tar(e,t,n,o);for(;o=i.dequeue();)Tar(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(Tar(e,t,n,o,!0)||[]);break}}}return r}function Tar(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,Dar(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,Dar(t,n,o)}),e.removeNode(r.v),o}function Ear(e,t){let n=new y9,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=Oar(i+r+3).map(()=>new xar),o=r+1;return n.nodes().forEach(e=>{Dar(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function Dar(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function Oar(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function kar(e,t){(e.graph().acyclicer===`greedy`?Car(e,n(e)):Aar(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,par(`rev`))});function n(e){return t=>e.edge(t).weight}}function Aar(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&Mar(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function jar(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function Mar(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function Nar(e){e.graph().dummyChains=[],e.edges().forEach(t=>Par(e,t))}function Par(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=b9(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function Far(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Iar(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=S9(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function D9(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Lar=Rar;function Rar(e){let t=new y9({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;zar(t,e)<i&&(a=Bar(t,e),a);)o=t.hasNode(a.v)?D9(e,a):-D9(e,a),Var(t,e,o);return t}function zar(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!D9(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function Bar(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=D9(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function Var(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Har,postorder:Uar}=Air,War=O9;O9.initLowLimValues=Jar,O9.initCutValues=Gar,O9.calcCutValue=qar,O9.leaveEdge=Xar,O9.enterEdge=Zar,O9.exchangeEdges=Qar;function O9(e){e=ear(e),Iar(e);let t=Lar(e);Jar(t),Gar(t,e);let n,r;for(;n=Xar(t);)r=Zar(t,e,n),Qar(t,e,n,r)}function Gar(e,t){let n=Uar(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Kar(e,t,n))}function Kar(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=qar(e,t,n)}function qar(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,eor(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Jar(e,t){arguments.length<2&&(t=e.nodes()[0]),Yar(e,{},1,t)}function Yar(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=Yar(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function Xar(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Zar(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===tor(e,e.node(t.v),s)&&c!==tor(e,e.node(t.w),s)).reduce((e,n)=>D9(t,n)<D9(t,e)?n:e)}function Qar(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Jar(e),Gar(e,t),$ar(e,t)}function $ar(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Har(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function eor(e,t,n){return e.hasEdge(t,n)}function tor(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var nor=ror;function ror(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:oor(e);break;case`tight-tree`:aor(e);break;case`longest-path`:ior(e);break;case`none`:break;default:oor(e)}}var ior=Iar;function aor(e){Iar(e),Lar(e)}function oor(e){War(e)}var sor=cor;function cor(e){let t=uor(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=lor(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function lor(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function uor(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(E9).forEach(r),t}function dor(e){let t=b9(e,`root`,{},`_root`),n=mor(e),r=Object.values(n),i=S9(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=hor(e)+1;e.children(E9).forEach(r=>{por(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function por(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=aar(e,`_bt`),l=aar(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{por(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function mor(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(E9).forEach(e=>n(e,1)),t}function hor(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function gor(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var _or=vor;function vor(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)yor(e,`borderLeft`,`_bl`,n,i,t),yor(e,`borderRight`,`_br`,n,i,t)}}e.children(E9).forEach(t)}function yor(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=b9(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function bor(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&Sor(e)}function xor(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&wor(e),(t===`lr`||t===`rl`)&&(Eor(e),Sor(e))}function Sor(e){e.nodes().forEach(t=>Cor(e.node(t))),e.edges().forEach(t=>Cor(e.edge(t)))}function Cor(e){let t=e.width;e.width=e.height,e.height=t}function wor(e){e.nodes().forEach(t=>Tor(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Tor),Object.hasOwn(r,`y`)&&Tor(r)})}function Tor(e){e.y=-e.y}function Eor(e){e.nodes().forEach(t=>Dor(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Dor),Object.hasOwn(r,`x`)&&Dor(r)})}function Dor(e){let t=e.x;e.x=e.y,e.y=t}function Oor(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=C9(S9(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return har(t,e.node(n),e.node(r))}return a}function kor(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Aor(e,t[r-1],t[r]);return n}function Aor(e,t,n){let r=mar(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function jor(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function Mor(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),Nor(Object.values(n).filter(e=>!e.indegree))}function Nor(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&Por(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>w9(e,[`vs`,`i`,`barycenter`,`weight`]))}function Por(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function For(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=lar(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(Lor(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=Ior(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=Ior(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function Ior(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Lor(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=har(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function Ror(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=jor(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=Ror(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&Bor(t,r)}});let h=Mor(m,n);zor(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]=h[n],h.splice(n,1),n--}else _=!0}let v=For(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function zor(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function Bor(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function Vor(e,t,n,r){r||=e.nodes();let i=Hor(e),a=new y9({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function Hor(e){let t;for(;e.hasNode(t=par(`_root`)););return t}function Uor(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function Wor(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,Wor);return}let r=car(e),i=Gor(e,C9(1,r+1),`inEdges`),a=Gor(e,C9(r-1,-1,-1),`outEdges`),o=Oor(e,n);if(qor(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){Kor(t%2?i:a,t%4>=2,l,n),o=x9(e);let u=kor(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}qor(e,c)}function Gor(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return Vor(e,t,n,r.get(t)||[])})}function Kor(e,t,n,r){let i=!0,a=new y9;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=Ror(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),Uor(e,a,s.vs)})}function qor(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Jor(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=Xor(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&Zor(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function Yor(e,t){let n={};function r(t,r,i,a,o){C9(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&Zor(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function Xor(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function Zor(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Qor(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function $or(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||csr(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>csr(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!Qor(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function esr(e,t,n,r,i=!1){let a={},o=tsr(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function tsr(e,t,n,r){let i=new y9,a=e.graph(),o=osr(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function nsr(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=ssr(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function rsr(e,t){let n=Object.values(t),r=S9(Math.min,n),i=S9(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-S9(Math.min,c);a!==`l`&&(l=i-S9(Math.max,c)),l&&(e[o]=T9(s,e=>e+l))})})}function isr(e,t=void 0){let n=e.ul;return n?T9(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function asr(e,t){let n=x9(e),r=Object.assign(Jor(e,n),Yor(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=$or(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=esr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=T9(c,e=>-e)),i[o+n]=c})}),rsr(i,nsr(e,i)),isr(i,e.graph().align)}function osr(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function ssr(e,t){return e.node(t).width}function csr(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function lsr(e,t){e=tar(e),usr(e),Object.entries(asr(e,t)).forEach(([t,n])=>e.node(t).x=n)}function usr(e){let t=x9(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var dsr=new WeakMap;function fsr(e,t={}){return msr(e,dar,t),e}function psr(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function msr(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new y9({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=psr(e,t.v,r),i=psr(e,t.w,r);if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),msr(o,t,n);let l=Tsr(o);hsr(l,t,n,null),gsr(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),(!isFinite(u)||!isFinite(d)||!isFinite(f)||!isFinite(p))&&(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=Tsr(e),g=hsr(h,t,n,dsr.get(e)??null);dsr.set(e,g),gsr(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),delete n._dagreClusterSubgraph}})}function hsr(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>Esr(e)),t(` removeSelfEdges`,()=>Fsr(e)),t(` acyclic`,()=>kar(e,s)),t(` nestingGraph.run`,()=>dor(e)),t(` rank`,()=>nor(tar(e))),t(` injectEdgeLabelProxies`,()=>Dsr(e)),t(` removeEmptyRanks`,()=>iar(e)),t(` nestingGraph.cleanup`,()=>gor(e)),t(` normalizeRanks`,()=>rar(e)),t(` assignRankMinMax`,()=>Osr(e)),t(` removeEdgeLabelProxies`,()=>ksr(e)),t(` normalize.run`,()=>Nar(e)),t(` parentDummyChains`,()=>sor(e)),t(` addBorderSegments`,()=>_or(e)),t(` order`,()=>Wor(e,n,c)),t(` insertSelfEdges`,()=>Isr(e)),t(` adjustCoordinateSystem`,()=>bor(e)),t(` position`,()=>lsr(e,n.corePath)),t(` positionSelfEdges`,()=>Lsr(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>Psr(e)),t(` normalize.undo`,()=>Far(e)),t(` fixupEdgeLabelCoords`,()=>Msr(e)),t(` undoCoordinateSystem`,()=>xor(e)),t(` translateGraph`,()=>Asr(e)),t(` assignNodeIntersects`,()=>jsr(e)),t(` reversePoints`,()=>Nsr(e)),t(` acyclic.undo`,()=>jar(e)),{graph:e,rawNodes:l}}function gsr(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var _sr=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],vsr={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},ysr=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],bsr=[`width`,`height`,`rank`],xsr={width:0,height:0},Ssr=[`minlen`,`weight`,`width`,`height`,`labeloffset`],Csr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},wsr=[`labelpos`];function Tsr(e){let t=new y9({multigraph:!0,compound:!0}),n=zsr(e.graph());return t.setGraph(Object.assign({},vsr,Rsr(n,_sr),w9(n,ysr))),e.nodes().forEach(n=>{let r=Rsr(zsr(e.node(n)),bsr);Object.keys(xsr).forEach(e=>{r[e]===void 0&&(r[e]=xsr[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=zsr(e.edge(n));t.setEdge(n,Object.assign({},Csr,Rsr(r,Ssr),w9(r,wsr)))}),t}function Esr(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Dsr(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);b9(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function Osr(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function ksr(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Asr(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function jsr(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(nar(r,a)),n.points.push(nar(i,o))})}function Msr(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function Nsr(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Psr(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function Fsr(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Isr(e){x9(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{b9(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),(!Array.isArray(t.label.points)||t.label.points.length!==7)&&(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function Lsr(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function Rsr(e,t){return T9(w9(e,t),Number)}function zsr(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function Bsr(e){let t=x9(e),n=new y9({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var Vsr={graphlib:vir,version:gar,layout:fsr,debug:Bsr,util:{time:uar,notime:dar}},Hsr={XS:{w:150,h:90},S:{w:168,h:90},M:{w:196,h:94},L:{w:216,h:94},XL:{w:236,h:98}};function Usr(e){return Hsr[e]??Hsr.M}var Wsr={critical:`crit`,high:`high`,medium:`med`,low:`low`};function Gsr(e){return(e||`M`).toLowerCase()}function Ksr(e,t){if(e.length>1&&t.length<e.length*.75){let t=Math.min(5,Math.ceil(Math.sqrt(e.length*1.4)));return e.map((e,n)=>{let r=n%t,i=Math.floor(n/t);return{...e,position:{x:r*265,y:i*120}}})}let n=new Vsr.graphlib.Graph;n.setGraph({rankdir:`TB`,nodesep:50,ranksep:80}),n.setDefaultEdgeLabel(()=>({}));for(let t of e){let e=Usr(t.data.node.size);n.setNode(t.id,{width:e.w,height:e.h})}for(let e of t)n.setEdge(e.source,e.target);return Vsr.layout(n),e.map(e=>{let{x:t,y:r}=n.node(e.id),i=Usr(e.data.node.size);return{...e,position:{x:t-i.w/2,y:r-i.h/2}}})}function qsr({data:e}){let{node:t,onSelect:n}=e,r=[`node`,Gsr(t.size),Wsr[t.importance]??`med`];t.inPipeline&&r.push(`pipe`),t.condition===`needs-refinement`&&r.push(`cond-refine`),t.condition===`stale`&&r.push(`cond-stale`),t.gate===`blocked`&&r.push(`gate-blocked`),t.isEpic&&r.push(`epic`);let i=t.gate===`ready`&&!t.inPipeline;return i&&r.push(`gate-promoted`),(0,z.jsxs)(`div`,{className:r.join(` `),onClick:()=>n(t),children:[(0,z.jsx)(Q7,{type:`target`,position:K7.Top,className:`edge-handle`}),(0,z.jsxs)(`div`,{className:`row1`,children:[(0,z.jsxs)(`span`,{className:`rank`,children:[`#`,t.rank]}),(0,z.jsx)(`span`,{className:`iid`,children:t.issueId}),(0,z.jsx)(`span`,{className:`size-tag`,children:t.size})]}),(0,z.jsx)(`div`,{className:`title`,children:t.title||t.why}),(0,z.jsxs)(`div`,{className:`chips`,children:[i&&(0,z.jsx)(`span`,{className:`chip promoted`,children:`📌 PROMOTED`}),t.gate===`blocked`&&(0,z.jsx)(`span`,{className:`chip held`,children:`⛔ VETOED`}),t.inPipeline&&(0,z.jsxs)(`span`,{className:`chip verb work`,children:[(0,z.jsx)(`span`,{className:`pulsedot`}),`in pipeline`]}),t.condition===`needs-refinement`&&(0,z.jsx)(`span`,{className:`chip refine`,children:`⚠ REFINE`}),t.condition===`stale`&&(0,z.jsx)(`span`,{className:`chip stale`,children:`⊘ STALE`}),t.isEpic&&(0,z.jsx)(`span`,{className:`chip epic`,children:`EPIC`}),t.ready&&(0,z.jsx)(`span`,{className:`chip ready`,children:`✓ READY`}),t.hasPrd&&(0,z.jsx)(`span`,{className:`chip prd`,children:`PRD`}),(0,z.jsx)(`span`,{className:`score`,children:t.score})]}),(0,z.jsx)(Q7,{type:`source`,position:K7.Bottom,className:`edge-handle`})]})}var Jsr={issueNode:qsr};function Ysr(e,t,n){let r=e.map(e=>({id:e.issueId,type:`issueNode`,position:{x:0,y:0},data:{node:e,onSelect:n}})),i=t.map((e,t)=>{let n=e.type===`informs`,r=e.type===`contains`,i=r?`color-mix(in srgb, var(--primary) 58%, transparent)`:n?`color-mix(in srgb, var(--info) 60%, transparent)`:`color-mix(in srgb, var(--muted-foreground) 55%, transparent)`;return{id:`e-${t}-${e.from}-${e.to}`,source:e.from,target:e.to,type:`default`,markerEnd:{type:G7.ArrowClosed,width:14,height:14,color:i},style:{stroke:i,strokeWidth:r?1.2:1.5,strokeDasharray:n?`5 4`:r?`2 5`:void 0}}});return{nodes:Ksr(r,i),edges:i}}var Xsr={critical:`var(--destructive)`,high:`var(--warning)`,medium:`var(--color-neutral-400)`,low:`color-mix(in srgb, var(--muted-foreground) 55%, transparent)`};function Zsr(e){let t=[];return e.inPipeline&&t.push({label:`in pipeline`,kind:`pipeline`}),e.condition===`needs-refinement`&&t.push({label:`⚠ needs refinement`,kind:`refine`}),e.condition===`stale`&&t.push({label:`⊘ likely stale · candidate to close`,kind:`stale`}),e.ready&&t.push({label:`✓ READY`,kind:`ready`}),e.hasPrd&&t.push({label:`PRD`,kind:`prd`}),t.length===0&&t.push({label:`not yet planned`,kind:`none`}),t}function Qsr(e){let t={fontSize:10,fontWeight:500,letterSpacing:`0.04em`,padding:`1px 6px`,borderRadius:`var(--radius-sm, 4px)`,border:`1px solid`,lineHeight:`15px`,whiteSpace:`nowrap`};switch(e){case`ready`:return{...t,color:`var(--success-foreground)`,borderColor:`color-mix(in srgb, var(--success) 32%, transparent)`,background:`color-mix(in srgb, var(--success) 10%, transparent)`};case`refine`:return{...t,color:`var(--warning-foreground)`,borderColor:`color-mix(in srgb, var(--warning) 32%, transparent)`,background:`color-mix(in srgb, var(--warning) 10%, transparent)`};case`pipeline`:return{...t,color:`var(--info-foreground)`,borderColor:`color-mix(in srgb, var(--info) 32%, transparent)`,background:`color-mix(in srgb, var(--info) 10%, transparent)`};default:return{...t,color:`var(--muted-foreground)`,borderColor:`var(--border)`,background:`var(--accent)`}}}var $sr={display:`grid`,gridTemplateColumns:`auto 1fr`,gap:`7px 14px`,fontSize:12},k9={color:`var(--muted-foreground)`},A9={color:`var(--foreground)`,textAlign:`right`},ecr={flex:1,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:4,fontSize:10,textTransform:`uppercase`,letterSpacing:`0.06em`,fontWeight:500,padding:`5px 6px`,borderRadius:6,cursor:`pointer`,border:`1px solid var(--border)`,background:`var(--accent)`,color:`var(--foreground)`};function tcr({node:e,onClose:t,onIssueAction:n}){let r=Zsr(e),i=Math.max(0,Math.min(100,e.score));return(0,z.jsxs)(`div`,{style:{width:320,flexShrink:0,background:`var(--card)`,borderLeft:`1px solid var(--border)`,padding:`16px`,overflowY:`auto`,display:`flex`,flexDirection:`column`,color:`var(--foreground)`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,marginBottom:8},children:[(0,z.jsxs)(`span`,{style:{fontSize:10,textTransform:`uppercase`,letterSpacing:`0.12em`,color:`var(--muted-foreground)`},children:[`Why rank #`,e.rank]}),(0,z.jsx)(`button`,{onClick:t,style:{background:`none`,border:`none`,color:`var(--muted-foreground)`,cursor:`pointer`,fontSize:14,lineHeight:1,padding:`0 2px`},children:`×`})]}),(0,z.jsx)(`div`,{style:{fontFamily:`var(--font-mono)`,fontSize:12,color:`var(--muted-foreground)`},children:e.issueId}),e.title&&(0,z.jsx)(`div`,{style:{fontSize:14,fontWeight:500,lineHeight:1.35,margin:`2px 0 10px`},children:e.title}),n&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:6,margin:`${e.title?0:10}px 0 14px`},children:[(0,z.jsx)(`button`,{style:ecr,onClick:()=>n(e.issueId,`panel`),title:`Open the full issue cockpit (deep-linked tab)`,children:`⛶ Panel`}),(0,z.jsx)(`button`,{style:ecr,onClick:()=>n(e.issueId,`modal`),title:`Open the issue overlay (quick peek, stays on this page)`,children:`▢ Overlay`}),(0,z.jsx)(`button`,{style:ecr,onClick:()=>n(e.issueId,`browser`),title:`Open the issue on GitHub in a new tab`,children:`↗ GitHub`})]}),(0,z.jsxs)(`div`,{style:{...$sr,marginTop:e.title?0:12},children:[(0,z.jsx)(`span`,{style:k9,children:`Importance`}),(0,z.jsx)(`span`,{style:A9,children:(0,z.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,z.jsx)(`span`,{style:{width:10,height:10,borderRadius:3,background:Xsr[e.importance]??`var(--muted-foreground)`}}),e.importance]})}),(0,z.jsx)(`span`,{style:k9,children:`Impact score`}),(0,z.jsxs)(`span`,{style:{...A9,fontFamily:`var(--font-mono)`},children:[e.score,` / 100`]})]}),(0,z.jsx)(`div`,{style:{height:5,borderRadius:3,background:`var(--accent)`,overflow:`hidden`,marginTop:3,marginBottom:12},children:(0,z.jsx)(`div`,{style:{height:`100%`,width:`${i}%`,borderRadius:3,background:`linear-gradient(90deg, var(--warning), var(--destructive))`}})}),(0,z.jsxs)(`div`,{style:{...$sr,marginBottom:14},children:[(0,z.jsx)(`span`,{style:k9,children:`Est. size`}),(0,z.jsxs)(`span`,{style:A9,children:[e.size,` effort`]}),(0,z.jsx)(`span`,{style:k9,children:`Depends on`}),(0,z.jsx)(`span`,{style:{...A9,fontFamily:`var(--font-mono)`},children:e.dependsOn.length?e.dependsOn.join(`, `):`— none`})]}),r.length>0&&(0,z.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,marginBottom:14},children:r.map((e,t)=>(0,z.jsx)(`span`,{style:Qsr(e.kind),children:e.label},t))}),(0,z.jsx)(`div`,{style:{borderTop:`1px solid var(--border)`,paddingTop:13,marginBottom:13},children:(0,z.jsx)(Udt,{issueId:e.issueId,onOpenIssueBrowser:n?e=>n(e,`browser`):void 0})}),(0,z.jsxs)(`div`,{style:{fontSize:12,lineHeight:1.6,color:`color-mix(in srgb, var(--foreground) 88%, transparent)`,borderTop:`1px solid var(--border)`,paddingTop:13},children:[(0,z.jsx)(`div`,{style:{fontSize:10,textTransform:`uppercase`,letterSpacing:`0.1em`,color:`var(--muted-foreground)`,marginBottom:6},children:`AI rationale · from sequence.md`}),e.why,e.rationale&&(0,z.jsx)(`div`,{style:{marginTop:8},children:e.rationale})]})]})}function ncr({data:e,className:t,selectedNodeId:n,onSelectNode:r,onIssueAction:i}){let[a,o]=(0,L.useState)(null),s=r!==void 0,c=s?e.nodes.find(e=>e.issueId===n)??null:a,l=(0,L.useCallback)(e=>{s?r?.(n===e.issueId?null:e):o(t=>t?.issueId===e.issueId?null:e)},[s,r,n]),u=(0,L.useCallback)(()=>{s?r?.(null):o(null)},[s,r]),{nodes:d,edges:f}=(0,L.useMemo)(()=>Ysr(e.nodes,e.edges,l),[e.nodes,e.edges,l]),[p,m,h]=Zrr(d),[g,_,v]=Qrr(f);return(0,L.useEffect)(()=>{let{nodes:t,edges:n}=Ysr(e.nodes,e.edges,l);if(m(t),_(n),!s&&a){let t=e.nodes.find(e=>e.issueId===a.issueId);t&&o(t)}},[e.nodes,e.edges,l,m,_,a,s]),(0,z.jsxs)(`div`,{className:`bk-dag-root${t?` ${t}`:``}`,style:{width:`100%`,height:`100%`,display:`flex`,background:`var(--background)`},children:[(0,z.jsx)(`style`,{children:`
1485
1485
  /* ── Backlog DAG nodes — ported from docs/design/mockups/backlog-sequencer-scaled-opus.html, scoped to .bk-dag-root ── */
1486
1486
  .bk-dag-root .react-flow { background: transparent; }
@@ -1602,17 +1602,17 @@ It is recommended to remove them from the file. This can be configured via \`edi
1602
1602
  .bkf-bt { font-size:10px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
1603
1603
  .bkf-makespan { margin-top:10px; font-size:11px; color:var(--muted-foreground); }
1604
1604
  `,dcr={ok:`border border-success/32 bg-success/8 text-success-foreground`,"needs-refinement":`border border-warning/32 bg-warning/8 text-warning-foreground`,stale:`border border-border bg-[var(--accent)] text-[var(--muted-foreground)] line-through opacity-70`},fcr={ready:`border border-success/32 bg-success/8 text-success-foreground`,blocked:`border border-destructive/32 bg-destructive/8 text-destructive-foreground`,auto:`border border-border bg-[var(--accent)] text-[var(--muted-foreground)]`},pcr={critical:`bg-[var(--destructive)]`,high:`bg-[var(--warning)]`,medium:`bg-muted-foreground/80`,low:`bg-[var(--muted-foreground)] opacity-60`},M9=`inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs transition-colors`,N9=`border-border bg-card text-muted-foreground hover:border-foreground/25`,P9={info:`border-info/32 bg-info/8 text-info-foreground`,success:`border-success/32 bg-success/8 text-success-foreground`,warning:`border-warning/32 bg-warning/8 text-warning-foreground`,danger:`border-destructive/32 bg-destructive/8 text-destructive-foreground`,neutral:`border-foreground/25 bg-foreground/8 text-foreground`},F9={info:`bg-[var(--info-foreground)]`,success:`bg-[var(--success-foreground)]`,warning:`bg-[var(--warning-foreground)]`,danger:`bg-[var(--destructive-foreground)]`,neutral:`bg-muted-foreground`},mcr=150;function hcr({onIssueAction:e}={}){let t=$t(),[n,r]=(0,L.useState)(`list`),[i,a]=(0,L.useState)(`all`),[o,s]=(0,L.useState)(`all`),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(!0),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(!1),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),[w,T]=(0,L.useState)(``),[E,D]=(0,L.useState)(!1),[O,k]=(0,L.useState)(null),[A,j]=(0,L.useState)(null),[ee,M]=(0,L.useState)(null),[N,P]=(0,L.useState)(()=>new Set),[te,ne]=(0,L.useState)(null),{data:re,isLoading:ie,error:ae,refetch:oe}=F({queryKey:[`backlog-sequence`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequence`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:6e4}),{data:se=[]}=F({queryKey:[`order-books`],queryFn:async()=>{let e=await fetch(`/api/orders`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).books??[]},staleTime:15e3}),ce=(0,L.useMemo)(()=>se.filter(e=>e.status!==`complete`),[se]),le=(0,L.useMemo)(()=>ce.find(e=>e.status===`running`)??ce.find(e=>e.status===`ready`)??ce[0]??null,[ce]),ue=(0,L.useMemo)(()=>{let e=new Map;for(let t of ce)for(let n of t.items)e.set(n.issue.toUpperCase(),t);return e},[ce]),{data:de}=F({queryKey:[`sequencer-status`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequencer-status`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:3e3}),fe=de?.running??!1,pe=(0,L.useRef)(!1);(0,L.useEffect)(()=>{pe.current&&!fe&&oe(),pe.current=fe},[fe,oe]);let[me,he]=(0,L.useState)(()=>Date.now());(0,L.useEffect)(()=>{if(!fe)return;let e=setInterval(()=>he(Date.now()),1e3);return()=>clearInterval(e)},[fe]);let ge=de?.startedAt?Math.max(0,Math.floor((me-new Date(de.startedAt).getTime())/1e3)):0,_e=re?.nodes??[],ve=(0,L.useMemo)(()=>_e.filter(e=>e.condition===`stale`),[_e]),ye=(0,L.useMemo)(()=>_e.filter(e=>e.condition===`needs-refinement`),[_e]),be=(0,L.useMemo)(()=>_e.filter(e=>e.inPipeline).length,[_e]),xe=(0,L.useMemo)(()=>_e.filter(e=>e.state?.ready??!1).length,[_e]),Se=(0,L.useMemo)(()=>_e.filter(e=>e.hasPrd).length,[_e]),Ce=(0,L.useMemo)(()=>_e.filter(e=>{if(i!==`all`&&e.importance!==i||o!==`all`&&e.condition!==o||c&&!e.inPipeline||u&&!(e.state?.ready??!1)||E&&!e.hasPrd)return!1;if(w){let t=w.toLowerCase();if(!e.issueId.toLowerCase().includes(t)&&!e.why.toLowerCase().includes(t))return!1}return!0}),[_e,i,o,c,u,E,w]),we=(0,L.useMemo)(()=>{if(!re)return{nodes:[],edges:[]};let e=Ce.length;if(e<=mcr){let e=new Set(Ce.map(e=>e.issueId));return{nodes:Ce,edges:re.edges.filter(t=>e.has(t.from)&&e.has(t.to))}}let t=Math.max(Math.floor(e*.1),20),n=new Set(Ce.slice(0,t).map(e=>e.issueId));Ce.filter(e=>e.inPipeline).forEach(e=>n.add(e.issueId));let r=new Set(n);for(let e of re.edges)n.has(e.from)&&r.add(e.to),n.has(e.to)&&r.add(e.from);return{nodes:Ce.filter(e=>r.has(e.issueId)),edges:re.edges.filter(e=>r.has(e.from)&&r.has(e.to))}},[re,Ce]),Te=Ce.length-we.nodes.length;async function Ee(e){if(!g){_(!0),x(e),C(null);try{let t=await fetch(`/api/backlog/sequence/regenerate`,{method:`POST`,headers:await Ac(),body:JSON.stringify({pass:e})});if(!t.ok){let e=`Request failed (HTTP ${t.status})`;try{let n=await t.json();n?.error&&(e=String(n.error))}catch{let n=await t.text().catch(()=>``);n&&(e=n.slice(0,300))}throw Error(e)}setTimeout(()=>oe(),2e3)}catch(e){C(e instanceof Error?e.message:String(e))}finally{_(!1),x(null)}}}async function De(){if(!(v||g)&&window.confirm(`Delete the backlog sequencing? This removes the ranked sequence (sequence.md + cache) and any operator gate overrides. A re-sequence pass regenerates it.`)){y(!0),C(null);try{let e=await fetch(`/api/backlog/sequence/clear`,{method:`POST`,headers:await Ac()});if(!e.ok){let t=`Request failed (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=String(n.error))}catch{}throw Error(t)}setTimeout(()=>oe(),500)}catch(e){C(e instanceof Error?e.message:String(e))}finally{y(!1)}}}async function Oe(e){await fetch(`/api/issues/${e}/start-planning`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>{})}async function ke(e){(await fetch(`/api/issues/${e}/close`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>null))?.ok&&t.invalidateQueries({queryKey:[`backlog-sequence`]})}async function Ae(e,n){if(le&&!ee){M(e),ne(null);try{let r=await fetch(`/api/orders/${encodeURIComponent(le.id)}/items`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({item:{issue:e,lane:n}})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`Request failed (HTTP ${r.status})`)}P(t=>new Set(t).add(e.toUpperCase())),j(null),await t.invalidateQueries({queryKey:[`order-books`]})}catch(e){ne(e instanceof Error?e.message:String(e))}finally{M(null)}}}let je=e=>dcr[e]??`border border-border bg-[var(--accent)] text-[var(--muted-foreground)]`,Me=e=>fcr[e]??`border border-border bg-[var(--accent)] text-[var(--muted-foreground)]`;return(0,z.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background text-foreground`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-4 px-6 py-4 border-b border-border shrink-0 flex-wrap bg-background`,children:[(0,z.jsxs)(`div`,{className:`min-w-[280px] flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(ts,{className:`w-4 h-4 text-primary`}),(0,z.jsxs)(`h1`,{className:`font-display text-[22px] leading-tight font-medium tracking-normal text-foreground`,children:[`Backlog Sequencer`,_e.length>0&&(0,z.jsxs)(`span`,{className:`ml-2 font-mono text-sm font-normal text-muted-foreground`,children:[`· `,_e.length,` open`]})]})]}),(0,z.jsx)(`p`,{className:`mt-1 max-w-2xl text-[13px] leading-5 text-muted-foreground`,children:`Ordered backlog: the sequencer's pickup order with dependency context and operator gates for pickup and planning.`})]}),(0,z.jsxs)(`div`,{className:`flex rounded-md overflow-hidden border border-border bg-card`,children:[(0,z.jsxs)(`button`,{onClick:()=>r(`list`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`list`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-accent`}`,children:[(0,z.jsx)(ts,{className:`w-3 h-3`}),`List`]}),(0,z.jsxs)(`button`,{onClick:()=>r(`dag`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`dag`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-accent`}`,children:[(0,z.jsx)(Ko,{className:`w-3 h-3`}),`DAG`]}),(0,z.jsxs)(`button`,{onClick:()=>r(`forecast`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`forecast`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-accent`}`,children:[(0,z.jsx)(ds,{className:`w-3 h-3`}),`Forecast`]})]}),(0,z.jsxs)(`button`,{onClick:()=>h(e=>!e),className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border ${m?`border-primary/32 bg-primary/8 text-primary`:`border-border text-muted-foreground hover:bg-accent`}`,children:[(0,z.jsx)(Io,{className:`w-3 h-3`}),`Filters `,Ce.length!==_e.length&&`(${Ce.length})`]}),ve.length>0&&(0,z.jsxs)(`button`,{onClick:()=>p(e=>!e),className:`px-3 py-1.5 text-xs rounded-md border ${f?`border-warning/32 bg-warning/8 text-warning-foreground`:`border-border text-muted-foreground hover:bg-accent`}`,children:[`⊘ `,ve.length,` stale`]}),(0,z.jsxs)(`div`,{className:`relative ml-auto flex items-center gap-1`,children:[(0,z.jsxs)(`button`,{onClick:De,disabled:v||g||fe,className:`px-2.5 py-1.5 text-xs flex items-center gap-1 rounded-md border border-border text-muted-foreground hover:border-destructive/40 hover:text-destructive disabled:opacity-50`,title:`Delete the backlog sequencing (sequence.md + cache). A creation pass then rebuilds it from scratch.`,children:[(0,z.jsx)(ws,{className:`w-3 h-3`}),v?`Clearing…`:`Clear`]}),(0,z.jsxs)(`button`,{onClick:()=>Ee(`incremental`),disabled:g||fe,className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border border-primary text-primary hover:bg-primary/10 disabled:opacity-50`,title:`Incremental pass: re-reads only issues changed since the last pass and slots them in. Existing ranks are preserved.`,children:[(0,z.jsx)(ds,{className:`w-3 h-3`}),b===`incremental`?`Updating…`:fe?`Sequencing…`:`Update changed`]}),(0,z.jsxs)(`button`,{onClick:()=>Ee(`review`),disabled:g||fe,className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border border-border text-muted-foreground hover:bg-accent disabled:opacity-50`,title:`Review pass: re-ranks the whole open backlog. Slower and costlier; use when priorities have shifted, not just when issues changed.`,children:[(0,z.jsx)(zt,{className:`w-3 h-3`}),b===`review`?`Re-ranking…`:`Re-rank all`]})]}),(0,z.jsx)(`button`,{onClick:()=>oe(),className:`p-2 rounded-md hover:bg-accent text-muted-foreground hover:text-foreground`,title:`Refresh`,children:(0,z.jsx)(zt,{className:`w-3.5 h-3.5`})})]}),fe&&(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-2 bg-info/8 border-b border-info/32 text-xs`,children:[(0,z.jsx)(zt,{className:`w-3.5 h-3.5 animate-spin text-[var(--info-foreground)]`}),(0,z.jsx)(`span`,{className:`text-[var(--info-foreground)] font-medium`,children:`Sequencing pass running`}),(0,z.jsxs)(`span`,{className:`text-foreground`,children:[`ranked `,(0,z.jsx)(`b`,{className:`font-mono`,children:de?.processed??0}),` / `,(0,z.jsx)(`b`,{className:`font-mono`,children:de?.total??`…`}),` issues`]}),(0,z.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`· `,Math.floor(ge/60),`m `,String(ge%60).padStart(2,`0`),`s`]}),(0,z.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:`the new sequence appears automatically when it finishes`})]}),S&&(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-destructive/8 border-b border-destructive/32 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-[var(--destructive-foreground)] font-medium`,children:`Run pass failed`}),(0,z.jsx)(`span`,{className:`text-muted-foreground truncate flex-1`,children:S}),(0,z.jsx)(`button`,{onClick:()=>C(null),className:`px-2 py-0.5 rounded border border-destructive/32 bg-destructive/16 text-destructive-foreground hover:bg-destructive/24 shrink-0`,children:`Dismiss`})]}),m&&(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-3 px-6 py-3 bg-card border-b border-border text-xs shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Importance:`}),[`all`,`critical`,`high`,`medium`,`low`].map(e=>(0,z.jsx)(`button`,{onClick:()=>a(e),className:`px-2 py-0.5 rounded-md border ${i===e?`border-primary bg-primary text-primary-foreground`:`border-border bg-background text-muted-foreground hover:bg-accent`}`,children:e===`all`?`All`:e},e))]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Condition:`}),[`all`,`ok`,`needs-refinement`,`stale`].map(e=>(0,z.jsx)(`button`,{onClick:()=>s(e),className:`px-2 py-0.5 rounded-md border ${o===e?`border-primary bg-primary text-primary-foreground`:`border-border bg-background text-muted-foreground hover:bg-accent`}`,children:e===`all`?`All`:e},e))]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`accent-primary`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`In pipeline`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`accent-primary`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Ready only`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`accent-primary`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Has PRD`})]}),(0,z.jsx)(`div`,{className:`ml-auto`,children:(0,z.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:`filter by id / title…`,className:`h-6 px-2 rounded border border-border bg-background text-muted-foreground text-xs placeholder:text-muted-foreground/50 focus:outline-none focus:border-primary min-w-[180px]`})})]}),f&&ve.length>0&&(0,z.jsxs)(`div`,{className:`shrink-0 border-b border-border bg-card px-5 py-3`,children:[(0,z.jsxs)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:[`Candidates to close (`,ve.length,`)`]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-40 overflow-y-auto`,children:ve.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono text-primary w-24 shrink-0`,children:e.issueId}),(0,z.jsx)(`span`,{className:`text-muted-foreground truncate flex-1`,children:e.why}),(0,z.jsx)(`button`,{onClick:()=>ke(e.issueId),className:`shrink-0 rounded border border-destructive/32 bg-destructive/8 px-2 py-0.5 text-[10px] text-destructive-foreground hover:bg-destructive/16`,children:`Close`})]},e.issueId))})]}),ye.length>0&&(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-warning/8 border-b border-warning/32 text-xs`,children:[(0,z.jsxs)(`span`,{className:`text-warning-foreground font-medium`,children:[`⚠ `,ye.length,` need refinement`]}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[ye.slice(0,5).map(e=>e.issueId).join(`, `),ye.length>5?` +${ye.length-5}`:``]}),(0,z.jsx)(`button`,{onClick:()=>Oe(ye[0].issueId),className:`ml-auto shrink-0 rounded border border-warning/32 bg-warning/8 px-2 py-0.5 text-warning-foreground hover:bg-warning/16`,children:`Draft PRD →`})]}),_e.length>0&&(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-6 py-2.5 border-b border-border shrink-0`,children:[(0,z.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-border bg-card px-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`b`,{className:`text-foreground font-medium font-mono`,children:_e.length}),` open issues`]}),(0,z.jsxs)(`button`,{onClick:()=>l(e=>!e),className:`${M9} ${c?P9.info:N9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${F9.info}`}),`In pipeline `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-foreground`,children:be})]}),(0,z.jsxs)(`button`,{onClick:()=>d(e=>!e),className:`${M9} ${u?P9.success:N9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${F9.success}`}),`Ready `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-foreground`,children:xe})]}),(0,z.jsxs)(`button`,{onClick:()=>D(e=>!e),className:`${M9} ${E?P9.neutral:N9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${F9.neutral}`}),`Has PRD `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-foreground`,children:Se})]}),ye.length>0&&(0,z.jsxs)(`button`,{onClick:()=>s(e=>e===`needs-refinement`?`all`:`needs-refinement`),className:`${M9} ${o===`needs-refinement`?P9.warning:N9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${F9.warning}`}),`⚠ Needs refinement `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-foreground`,children:ye.length})]}),ve.length>0&&(0,z.jsxs)(`button`,{onClick:()=>s(e=>e===`stale`?`all`:`stale`),className:`${M9} ${o===`stale`?P9.neutral:N9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full opacity-60 shrink-0 ${F9.neutral}`}),`⊘ Stale candidates `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-foreground`,children:ve.length})]})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-hidden flex`,children:[(0,z.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-hidden flex flex-col`,children:[ie&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`Loading sequence…`}),ae&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-destructive-foreground text-sm`,children:String(ae)}),!ie&&!ae&&_e.length===0&&(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-3 text-muted-foreground`,children:[(0,z.jsx)(ts,{className:`w-8 h-8 opacity-40`}),(0,z.jsx)(`p`,{className:`text-sm`,children:`No backlog sequence yet.`}),(0,z.jsx)(`p`,{className:`text-xs`,children:`Run a creation pass to rank the open backlog.`}),(0,z.jsxs)(`button`,{onClick:()=>void Ee(`creation`),disabled:g,className:`px-3 py-1.5 text-xs rounded border border-primary text-primary hover:bg-primary/10 disabled:opacity-50 flex items-center gap-1`,children:[(0,z.jsx)(ds,{className:`w-3 h-3`}),g?`Spawning…`:`Run creation pass`]})]}),!ie&&!ae&&_e.length>0&&n===`list`&&(0,z.jsx)(`div`,{className:`overflow-y-auto flex-1`,children:(0,z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,z.jsx)(`thead`,{className:`sticky top-0 bg-card border-b border-border`,children:(0,z.jsxs)(`tr`,{className:`text-muted-foreground`,children:[(0,z.jsx)(`th`,{className:`text-right px-3 py-2 font-medium w-8 cursor-help`,title:`Pickup rank — lower means the Flywheel works it sooner`,children:`#`}),(0,z.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-6 cursor-help`,title:`Importance — red = critical, orange = high, gray = medium, dim = low`,children:`●`}),(0,z.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-28 cursor-help`,title:`Issue ID. Markers: ▶ in pipeline · ⚠ needs refinement · P has PRD · ✓ planned (spec + tasks)`,children:`Issue`}),(0,z.jsx)(`th`,{className:`text-left px-2 py-2 font-medium cursor-help`,title:`One-line rationale for this ranking (from the sequencer)`,children:`Why`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Estimated effort: XS / S / M / L / XL`,children:`Size`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-24 cursor-help`,title:`AI condition: ok · needs-refinement (vague spec) · stale (likely close)`,children:`Condition`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-20 cursor-help`,title:`Operator pickup gate: auto (normal) · promote (jump queue) · vetoed (never pick)`,children:`Gate`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Impact score (0–100) the sequencer assigned`,children:`Score`}),(0,z.jsx)(`th`,{className:`px-2 py-2 font-medium w-28`,children:(0,z.jsx)(`span`,{className:`sr-only`,children:`Order book`})})]})}),(0,z.jsx)(`tbody`,{children:Ce.map(e=>{let t=e.condition===`stale`,n=e.condition===`needs-refinement`,r=O?.issueId===e.issueId;return(0,z.jsxs)(`tr`,{onClick:()=>k(t=>t?.issueId===e.issueId?null:e),className:`group transition-colors cursor-pointer ${t?`opacity-50`:``} ${r?`bg-primary/15 ring-inset ring-1 ring-primary`:`even:bg-muted/20 hover:bg-accent/60`}`,children:[(0,z.jsx)(`td`,{className:`text-right px-3 py-2 text-muted-foreground tabular-nums border-l-2 ${e.inPipeline?`border-l-[var(--info)]`:`border-l-transparent`}`,children:e.rank}),(0,z.jsx)(`td`,{className:`px-2 py-2`,children:(0,z.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${pcr[e.importance]??`bg-muted-foreground`}`,title:`Importance: ${e.importance}`})}),(0,z.jsxs)(`td`,{className:`px-2 py-2 font-mono text-primary`,children:[e.issueId,e.inPipeline&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`In pipeline — active work / review / test`,children:`▶`}),n&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--warning-foreground)] align-top`,title:`Needs refinement — vague/underspecified`,children:`⚠`}),e.hasPrd&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`Has PRD`,children:`P`}),e.ready&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--success-foreground)] align-top`,title:`Has spec — ready for work`,children:`✓`})]}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-foreground max-w-xs truncate ${t?`line-through`:``}`,children:e.why}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center text-muted-foreground`,children:e.size}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${je(e.condition)}`,title:e.condition===`needs-refinement`?`Needs refinement — vague/underspecified`:e.condition===`stale`?`Stale — likely a candidate to close`:`OK — well-specified`,children:e.condition===`needs-refinement`?`⚠ refine`:e.condition===`stale`?`⊘ stale`:e.condition})}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Me(e.gate)}`,title:e.gate===`ready`?e.inPipeline?`Auto (in-pipeline pin)`:`Promoted — jumps the queue`:e.gate===`blocked`?`Vetoed — never auto-picked`:`Auto — normal eligibility`,children:e.gate===`ready`?e.inPipeline?`auto`:`📌`:e.gate===`blocked`?`⛔`:e.gate})}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center text-muted-foreground tabular-nums`,children:e.score}),(0,z.jsxs)(`td`,{className:`relative px-2 py-2 text-right`,onClick:e=>e.stopPropagation(),children:[ue.has(e.issueId.toUpperCase())||N.has(e.issueId.toUpperCase())?(0,z.jsx)(`a`,{href:`/orders`,className:`text-[10px] text-primary opacity-0 hover:underline group-hover:opacity-100 focus:opacity-100`,children:`Open order book`}):(0,z.jsx)(`button`,{type:`button`,disabled:!le,onClick:()=>{ne(null),j(t=>t===e.issueId?null:e.issueId)},className:`rounded border border-border px-2 py-1 text-[10px] text-muted-foreground opacity-0 transition-opacity hover:border-primary hover:text-primary focus:opacity-100 disabled:cursor-not-allowed disabled:opacity-30 group-hover:opacity-100`,title:le?`Add to ${le.name}`:`Create an order book first`,children:`+ Order book`}),A===e.issueId&&le&&(0,z.jsxs)(`div`,{className:`absolute right-2 top-full z-30 w-52 rounded-md border border-border bg-card p-2 text-left shadow-lg`,role:`dialog`,"aria-label":`Choose lane for ${e.issueId}`,children:[(0,z.jsxs)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:[`Add to `,le.name]}),(0,z.jsx)(`div`,{className:`mt-2 flex gap-2`,children:[`A`,`B`].map(t=>(0,z.jsxs)(`button`,{type:`button`,disabled:ee===e.issueId,onClick:()=>{Ae(e.issueId,t)},className:`flex-1 rounded border border-border px-2 py-1 text-[10px] text-foreground hover:border-primary disabled:opacity-50`,children:[`Lane `,t]},t))}),(0,z.jsx)(`a`,{href:`/orders`,className:`mt-2 block text-[10px] text-primary hover:underline`,children:`Open Order Book`}),te&&(0,z.jsx)(`p`,{className:`mt-2 text-[10px] text-[var(--destructive)]`,role:`alert`,children:te})]})]})]},e.issueId)})})]})}),!ie&&!ae&&_e.length>0&&n===`dag`&&re&&(0,z.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[Te>0&&(0,z.jsxs)(`div`,{className:`shrink-0 text-xs text-center py-1 bg-card border-b border-border text-muted-foreground`,children:[`Showing `,we.nodes.length,` of `,Ce.length,` issues (top 10% by rank + neighbors); `,Te,` collapsed`]}),(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(ncr,{data:we,className:`w-full h-full`,selectedNodeId:O?.issueId,onSelectNode:e=>k(e),onIssueAction:e})})]}),!ie&&!ae&&_e.length>0&&n===`forecast`&&(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(ccr,{className:`w-full h-full`,onSelectIssue:e=>k(_e.find(t=>t.issueId===e)??null)})})]}),O&&(0,z.jsx)(tcr,{node:O,onClose:()=>k(null),onIssueAction:e})]})]})}var gcr={exploring:{label:`Exploring`,color:`var(--primary)`,icon:gs},planning:{label:`Planning`,color:`var(--signal-review, var(--primary))`,icon:Co},building:{label:`Building`,color:`var(--success, #10b981)`,icon:tfe},verifying:{label:`Verifying`,color:`var(--warning, #f59e0b)`,icon:vo},cleaning:{label:`Cleaning`,color:`var(--muted-foreground)`,icon:Spe},shipping:{label:`Shipping`,color:`var(--primary)`,icon:upe}};function _cr(e){return e.filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp)).slice(0,3)}function vcr(e,t){if(!e)return!1;let n=Date.parse(e.timestamp);return!Number.isNaN(n)&&t.getTime()-n>36e5}function I9({label:e,value:t,tone:n}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,z.jsx)(`span`,{className:`text-xs font-semibold`,style:{color:n??`var(--foreground)`},children:t})]})}function ycr({issue:e,status:t,observations:n,stats:r,onOpenWorkspaceHome:i,now:a=new Date}){let o=t?.phase??`exploring`,s=gcr[o],c=s.icon,l=_cr(n),u=vcr(l[0],a),d=t?.headline||e.title,f=t?.summary||e.description||`No workspace status summary yet.`;return(0,z.jsxs)(`button`,{type:`button`,"data-testid":`workspace-status-card`,onClick:i,className:`w-full text-left bg-card border border-border rounded-lg p-3 hover:border-primary/50 hover:bg-popover transition-colors`,"aria-label":`Open ${e.identifier} workspace overview`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(`div`,{"data-testid":`workspace-status-phase-icon`,"data-phase":o,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border`,style:{color:s.color,borderColor:s.color,background:`color-mix(in srgb, currentColor 10%, transparent)`},children:(0,z.jsx)(c,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,title:d,children:d}),(0,z.jsx)(`span`,{"data-testid":`workspace-status-phase-label`,className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,style:{color:s.color,borderColor:s.color},children:s.label}),u&&(0,z.jsxs)(`span`,{"data-testid":`workspace-status-stale`,className:`ml-auto flex shrink-0 items-center gap-1 text-[10px] font-semibold text-warning`,children:[(0,z.jsx)(Ts,{className:`h-3 w-3`}),`Stale`]})]}),(0,z.jsx)(`p`,{"data-testid":`workspace-status-summary`,className:`mt-1 text-xs text-muted-foreground`,style:{display:`-webkit-box`,WebkitLineClamp:3,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:f})]})]}),(0,z.jsx)(`ul`,{"data-testid":`workspace-status-observations`,className:`mt-3 space-y-1 text-xs text-muted-foreground`,children:l.length===0?(0,z.jsx)(`li`,{className:`text-muted-foreground/70`,children:`No recent action status.`}):l.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`}),e.actionStatus?(0,z.jsx)(WE,{status:e.actionStatus}):null,(0,z.jsx)(`span`,{className:`min-w-0 truncate`,title:e.summary,children:e.summary})]},e.id))}),(0,z.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-3 border-t border-border pt-3`,children:[(0,z.jsx)(I9,{label:`Additions`,value:`+${r.additions}`,tone:`var(--success, #10b981)`}),(0,z.jsx)(I9,{label:`Deletions`,value:`-${r.deletions}`,tone:`var(--destructive)`}),(0,z.jsx)(I9,{label:`Commits`,value:r.commits}),(0,z.jsx)(I9,{label:`PRs`,value:r.prs})]})]})}var bcr={justNow:`Just Now`,earlierToday:`Earlier Today`,yesterday:`Yesterday`,thisWeek:`This Week`,thisMonth:`This Month`,older:`Older`},xcr=[`justNow`,`earlierToday`,`yesterday`,`thisWeek`,`thisMonth`,`older`];async function Scr(){let e=await fetch(`/api/registry/features`);if(!e.ok)throw Error(`Registry request failed (${e.status})`);let t=await e.json();return Array.isArray(t.entries)?t.entries:[]}async function Ccr(){let e=await fetch(`/api/metrics/summary`);if(!e.ok)throw Error(`Metrics summary request failed (${e.status})`);return e.json()}function wcr({onOpenWorkspaceHome:e,onNewProject:t,onSelectProject:n,onOpenSettings:r,now:i}={}){let a=F({queryKey:[`feature-registry`],queryFn:Scr,staleTime:3e4,retry:!1}),o=F({queryKey:[`metrics-summary`],queryFn:Ccr,staleTime:3e4,retry:!1}),s=F({queryKey:[`command-deck-projects`],queryFn:Ou,staleTime:3e4,retry:!1}),c=s.data??[],l=vp(e=>e.showPlannedBacklog),u=Wt(e=>e.issuesRaw),d=Wt(e=>e.statusByIssueId),f=Wt(e=>e.observationsByIssueId),p=Wt(e=>e.agentsById),m=Wt(e=>e.derivedIssueStateByIssueId),h=Wt(ene),g=i??new Date,_=(0,L.useMemo)(()=>Ncr({issuesRaw:u,statusByIssueId:d,observationsByIssueId:f,agentsById:p,derivedIssueStateByIssueId:m}),[p,u,f,m,d]),v=(0,L.useMemo)(()=>Mcr(f),[f]),y=(0,L.useMemo)(()=>Acr(kcr({agentsById:p,derivedIssueStateByIssueId:m,dailyCost:o.data?.today?.totalCost})),[p,o.data?.today?.totalCost,m]);return(0,z.jsx)(`div`,{className:`h-full w-full overflow-y-auto bg-background`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6 p-6`,children:[(0,z.jsx)(`header`,{className:`rounded-xl border border-border bg-card p-6 shadow-sm`,children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:`Overdeck Home`}),(0,z.jsx)(`h1`,{className:`mt-2 text-3xl font-semibold text-foreground`,children:`System briefing`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm text-muted-foreground`,children:`A live landing page for current workspace context, cross-workspace ownership, and memory-first guidance.`}),(0,z.jsx)(`div`,{className:`mt-4`,children:(0,z.jsx)(K5n,{mode:`advanced`})})]}),(0,z.jsx)(j5n,{})]})}),(0,z.jsx)(t7n,{}),(0,z.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-5`,"aria-label":`Home summary`,children:y.map(e=>(0,z.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,z.jsx)(`p`,{className:`mt-2 text-2xl font-semibold tabular-nums ${e.tone??`text-foreground`}`,children:e.value}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.detail})]},e.label))}),(0,z.jsx)(Tcr,{observations:v,failure:h,onOpenSettings:r,now:g}),(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`workspace-status-title`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`workspace-status-title`,className:`text-lg font-semibold text-foreground`,children:`Workspaces`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Live workspace status rollups from memory observations.`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:_.length>0?(0,z.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:_.map(t=>(0,z.jsx)(ycr,{issue:t.issue,status:t.status,observations:t.observations,stats:t.stats,onOpenWorkspaceHome:()=>e?.(t.issue.identifier),now:i},t.issue.identifier))}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No workspace status is available yet.`}),(0,z.jsx)(`p`,{className:`mt-1`,children:`Workspace cards will appear after memory status or observations are recorded for an issue.`})]})})]}),(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`knowledge-registry-title`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`knowledge-registry-title`,className:`text-lg font-semibold text-foreground`,children:`Knowledge Registry`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Feature ownership across issues, workspaces, and agents.`})]}),a.isFetching&&(0,z.jsx)(`span`,{className:`mt-2 rounded-full border border-border px-2 py-1 text-xs text-muted-foreground sm:mt-0`,children:`Refreshing`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:a.isError?(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Knowledge Registry could not be loaded. The rest of Home is still available.`}):a.isLoading?(0,z.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading registry entries…`}):a.data&&a.data.length>0?(0,z.jsx)(zcr,{entries:a.data}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No features are registered yet.`}),(0,z.jsxs)(`p`,{className:`mt-1`,children:[`Add one with `,(0,z.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`pan registry tag <issueId> <feature>`}),`. Automatic classification will populate future entries as issue and workspace lifecycle wiring lands.`]})]})})]}),(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-projects-title`,"data-testid":`home-projects`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`home-projects-title`,className:`text-lg font-semibold text-foreground`,children:`Projects`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your registered projects — click one to open its deck.`})]}),t&&(0,z.jsx)(`button`,{"data-testid":`home-new-project`,onClick:t,className:`rounded-lg border border-border bg-muted/20 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:s.isLoading?(0,z.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading projects…`}):s.isError?(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Projects could not be loaded. The rest of Home is still available.`}):c.length>0?(0,z.jsx)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:c.map(e=>{let t=uEe(e.features,l),r=t.length>0;return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{"data-testid":`home-project-${e.name}`,onClick:()=>n?.(e.name),title:e.path,className:`flex w-full items-center gap-3 px-4 py-3 text-left text-sm font-medium text-foreground transition-colors hover:bg-accent`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${r?`bg-primary`:`bg-muted-foreground/30`}`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),r&&(0,z.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:t.length})]})},e.path)})}):(0,z.jsxs)(`div`,{"data-testid":`home-projects-empty`,className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No projects yet.`}),(0,z.jsx)(`p`,{className:`mt-1`,children:`Create your first project to get started.`}),t&&(0,z.jsx)(`button`,{"data-testid":`home-new-project-empty`,onClick:t,className:`mt-3 rounded-lg border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]})})]})]})})}function Tcr({observations:e,failure:t,onOpenSettings:n,now:r}){let i=(0,L.useMemo)(()=>XHt(e,e=>e.timestamp,r),[e,r]);return(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-activity-title`,"data-testid":`home-activity-feed`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`home-activity-title`,className:`text-lg font-semibold text-foreground`,children:`Activity Feed`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Recent actionable memory observations across workspaces.`})]}),t&&(0,z.jsx)(Ecr,{failure:t,onOpenSettings:n}),e.length===0?(0,z.jsxs)(`div`,{"data-testid":`home-activity-empty`,className:`mt-4 rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No actionable observations yet.`}),(0,z.jsx)(`p`,{className:`mt-1`,children:`Observations are extracted from running work agents — they appear here once an agent makes a change worth recording.`})]}):(0,z.jsx)(`div`,{className:`mt-4 space-y-5`,children:xcr.map(e=>{let t=i[e];return t.length===0?null:(0,z.jsxs)(`section`,{"data-testid":`home-activity-bucket-${e}`,children:[(0,z.jsx)(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:bcr[e]}),(0,z.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,z.jsx)(Ocr,{observation:e,now:r},e.id))})]},e)})})]})}function Ecr({failure:e,onOpenSettings:t}){let n=Dcr(e);return(0,z.jsx)(`div`,{"data-testid":`home-memory-failure`,className:`mt-4 rounded-lg border border-destructive/32 bg-destructive/8 p-4 text-sm text-foreground`,role:`alert`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(Ts,{className:`mt-0.5 h-4 w-4 shrink-0 text-destructive`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`font-medium text-destructive`,children:`Memory extraction is failing`}),(0,z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),e.detail?(0,z.jsx)(`p`,{className:`mt-2 break-words font-mono text-[11px] text-muted-foreground`,children:e.detail}):null,(0,z.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:`Memory observations and agent memory injection are disabled until this is fixed.`}),t?(0,z.jsx)(`button`,{onClick:t,className:`mt-3 rounded-sm border border-border bg-background px-2.5 py-1 text-xs font-medium text-foreground hover:bg-accent transition-colors`,children:`Open Settings › Memory`}):null]})]})})}function Dcr(e){let t=(e.detail??``).toLowerCase();return t.includes(`could not resolve authentication`)||t.includes(`anthropic_api_key`)||t.includes(`x-api-key`)?`The Anthropic API provider has no API key. Switch the extraction provider to cliproxy (your ChatGPT subscription) in Settings › Memory.`:t.includes(`unknown provider for model`)||t.includes(`does not exist`)||t.includes(`unknown model`)?`The configured extraction model is not available on cliproxy. Pick a served model (e.g. gpt-5.4-mini) in Settings › Memory.`:t.includes(`401`)||t.includes(`unauthorized`)||t.includes(`expired`)?`The extraction provider rejected the credentials — the codex/ChatGPT subscription token used by cliproxy may have expired. Re-authenticate, then it will recover automatically.`:`Background memory-extraction calls are failing. Check the extraction provider and model in Settings › Memory.`}function Ocr({observation:e,now:t}){return(0,z.jsxs)(`li`,{className:`rounded-lg border border-border bg-background p-3 text-xs`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(WE,{status:e.actionStatus}),(0,z.jsx)(`p`,{className:`font-semibold text-foreground`,children:e.summary})]}),(0,z.jsxs)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[e.workspaceId,` · `,e.issueId,` · `,(0,z.jsx)(`time`,{dateTime:e.timestamp,children:np(e.timestamp,t)})]}),e.narrative?(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:e.narrative}):null,e.files.length>0?(0,z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,"aria-label":`Files`,children:e.files.map(e=>(0,z.jsx)(`code`,{className:`rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,e.tags.length>0?(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,"aria-label":`Tags`,children:e.tags.map(e=>(0,z.jsx)(`span`,{className:`rounded-full border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,(0,z.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,z.jsx)(UE,{kind:`memory`})})]})}function kcr({agentsById:e={},derivedIssueStateByIssueId:t={},dailyCost:n}){let r=Object.values(e),i=Object.values(t);return{runningAgents:r.filter(jcr).length,pausedAgents:r.filter(e=>e.paused===!0).length,readyToMerge:i.filter(e=>e.state===`ready`).length,needsYou:i.filter(e=>e.attention===`needs-you`).length,dailyCost:typeof n==`number`&&Number.isFinite(n)?n:null}}function Acr(e){return[{label:`Running agents`,value:String(e.runningAgents),detail:`Live or starting sessions`,tone:e.runningAgents>0?`text-primary`:void 0},{label:`Paused`,value:String(e.pausedAgents),detail:`Agents an operator parked`,tone:e.pausedAgents>0?`text-warning`:void 0},{label:`Ready to merge`,value:String(e.readyToMerge),detail:`Approved, green, mergeable`,tone:e.readyToMerge>0?`text-success`:void 0},{label:`Needs you`,value:String(e.needsYou),detail:`Waiting on an operator answer`,tone:e.needsYou>0?`text-warning`:void 0},{label:`Cost today`,value:e.dailyCost===null?`Unavailable`:`$${e.dailyCost.toFixed(2)}`,detail:`UTC daily cost summary`,tone:e.dailyCost===null?`text-muted-foreground`:`text-success`}]}function jcr(e){return e.hasLivePane===!0||e.status===`running`||e.status===`starting`}function Mcr(e){return Object.values(e).flatMap(e=>e).filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp))}function Ncr({issuesRaw:e,statusByIssueId:t={},observationsByIssueId:n={},agentsById:r={},derivedIssueStateByIssueId:i={}}){let a=new Map;for(let t of e){let e=Lcr(t);e&&a.set(e.identifier,e)}let o=new Set;for(let e of Object.keys(t))o.add(e);for(let[e,t]of Object.entries(n))t.length>0&&o.add(e);for(let e of Object.values(r))e.issueId&&Pcr(e)&&o.add(e.issueId);return[...o].sort(nt).map(e=>{let r=t[e],o=n[e]??[];return{issue:a.get(e)??{identifier:e,title:r?.headline||e,description:r?.summary},status:r,observations:o,stats:Fcr(o,i[e])}})}function Pcr(e){return e.hasLivePane===!0||[`healthy`,`running`,`starting`,`stuck`,`warning`].includes(e.status)}function Fcr(e,t){return{additions:0,deletions:0,commits:e.filter(Icr).length,prs:+!!t?.pr}}function Icr(e){return e.tags.some(e=>[`commit`,`commits`,`git.commit`].includes(e.toLowerCase()))}function Lcr(e){return!Rcr(e)||typeof e.identifier!=`string`||typeof e.title!=`string`?null:{identifier:e.identifier,title:e.title,description:typeof e.description==`string`?e.description:void 0}}function Rcr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zcr({entries:e}){return(0,z.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`min-w-full divide-y divide-border text-sm`,children:[(0,z.jsx)(`thead`,{className:`bg-muted/40 text-left text-xs uppercase tracking-wide text-muted-foreground`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Feature`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Issue`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Workspace`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Agent`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Status`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Updated`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Tags`})]})}),(0,z.jsx)(`tbody`,{className:`divide-y divide-border bg-card`,children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`px-4 py-3 font-medium text-foreground`,children:e.featureName}),(0,z.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningIssueId??`—`}),(0,z.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningWorkspaceId??`—`}),(0,z.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningAgentId??`—`}),(0,z.jsx)(`td`,{className:`px-4 py-3`,children:(0,z.jsx)(`span`,{className:`rounded-full border border-border bg-muted/30 px-2 py-1 text-xs font-medium text-foreground`,children:e.status})}),(0,z.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:Bcr(e.updatedAt)}),(0,z.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:e.tags.length>0?e.tags.join(`, `):`—`})]},e.featureId))})]})})})}function Bcr(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}async function Vcr(e){let t=await Is(e?`/api/fs/list-dirs?path=${encodeURIComponent(e)}`:`/api/fs/list-dirs`,{credentials:`include`});if(!t.ok)throw Error(`list-dirs failed: ${t.status}`);return t.json()}function L9({onSelect:e,initialPath:t}){let[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(null),c=(0,L.useCallback)(e=>{a(!0),s(null),Vcr(e).then(e=>{r(e),a(!1)}).catch(e=>{s(e instanceof Error?e.message:String(e)),a(!1)})},[]);return(0,L.useEffect)(()=>{c(t)},[c,t]),(0,z.jsxs)(`div`,{"data-testid":`folder-picker`,style:{display:`flex`,flexDirection:`column`,gap:4,fontSize:13,color:`var(--foreground)`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,minHeight:24},children:[n?.parent!=null&&(0,z.jsx)(`button`,{type:`button`,"data-testid":`folder-picker-up`,onClick:()=>c(n.parent??void 0),style:{background:`none`,border:`none`,cursor:`pointer`,padding:`2px 6px`,borderRadius:4,color:`var(--muted-foreground)`,fontSize:13},children:`↑`}),(0,z.jsx)(`span`,{"data-testid":`folder-picker-path`,style:{color:`var(--muted-foreground)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:n?.path??``}),(0,z.jsx)(`button`,{type:`button`,"data-testid":`folder-picker-select`,disabled:!n||i,onClick:()=>{n&&e(n.path)},style:{padding:`2px 10px`,borderRadius:4,border:`1px solid var(--border)`,background:`var(--card)`,cursor:n?`pointer`:`default`,color:`var(--foreground)`,fontSize:12},children:`Select`})]}),i&&(0,z.jsx)(`span`,{"data-testid":`folder-picker-loading`,style:{color:`var(--muted-foreground)`,fontSize:12},children:`Loading…`}),o&&(0,z.jsx)(`span`,{"data-testid":`folder-picker-error`,style:{color:`var(--destructive)`,fontSize:12},children:o}),!i&&!o&&n&&(0,z.jsxs)(`div`,{"data-testid":`folder-picker-entries`,style:{display:`flex`,flexDirection:`column`,gap:1,maxHeight:240,overflowY:`auto`},children:[n.entries.length===0&&(0,z.jsx)(`span`,{style:{color:`var(--muted-foreground)`,fontSize:12,padding:`4px 0`},children:`No subdirectories`}),n.entries.map(e=>(0,z.jsxs)(`button`,{type:`button`,"data-testid":`folder-picker-entry`,"data-path":e.path,onClick:()=>c(e.path),style:{background:`none`,border:`none`,cursor:`pointer`,textAlign:`left`,padding:`3px 6px`,borderRadius:4,color:`var(--foreground)`,fontSize:13},children:[e.name,`/`]},e.path))]})]})}function Hcr({initialProjectKey:e=``,onCreated:t}={}){let[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(e),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(`shared`),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(!0),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(null),b=(0,L.useRef)(0),x=(0,L.useRef)(0);(0,L.useEffect)(()=>()=>{x.current+=1},[]);let S=c===`isolated`?``:o,C=(0,L.useMemo)(()=>({project:i,name:n,isolated:c===`isolated`,...S?{targetPath:S}:{},...u?{parentBranch:u}:{}}),[S,c,n,u,i]),w=(0,L.useMemo)(()=>n.trim().length>=2?{...C,branchQuery:n.trim()}:C,[n,C]);(0,L.useEffect)(()=>{p(null),h(!0),y(null);let e=++b.current,t=setTimeout(()=>{(async()=>{try{let t=await Is(`/api/workspace-registry/resolve`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify(w)});if(!t.ok){e===b.current&&y(`Could not resolve the workspace intent (HTTP ${t.status}).`);return}let n=await t.json();if(e!==b.current)return;p(n),h(!1)}catch{e===b.current&&y(`Could not reach the server to resolve the workspace intent.`)}})()},300);return()=>clearTimeout(t)},[w]);let T=(0,L.useCallback)(e=>(f?.findings??[]).filter(t=>t.field===e),[f]),E=(f?.findings.length??0)>0;return{name:n,setName:r,projectKey:i,setProjectKey:a,targetPath:o,setTargetPath:s,mode:c,setMode:l,parentBranch:u,setParentBranch:d,effectiveTargetPath:S,intent:f,stale:m,creating:g,error:v,findingsFor:T,hasFindings:E,canCreate:!g&&!m&&!!f&&!E,submitIntent:(0,L.useCallback)(async(e=C)=>{y(null),_(!0);let n=++x.current;try{let r=await Is(`/api/workspace-registry`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify(e)});if(n!==x.current)return null;if(!r.ok){let e=await r.json().catch(()=>({}));return n===x.current&&(e.findings?.length?(p(t=>t&&{...t,findings:e.findings??[]}),y(e.findings[0]?.message??`The workspace intent was rejected.`)):y(e.error??`HTTP ${r.status}`)),null}let i=await r.json();return n===x.current?(t?.(i.id),i.id):null}catch(e){return n===x.current&&y(e instanceof Error?e.message:String(e)),null}finally{n===x.current&&_(!1)}},[t,C])}}var Ucr=/^https?:\/\/github\.com\/[^/]+\/[^/]+\/(issues|pull)\/(\d+)/;function Wcr(e,t){let n=e.trim(),r=/^#(\d+)$/.exec(n);if(r)return{kind:`issue`,id:`#${r[1]}`};let i=/^([A-Za-z][A-Za-z0-9]*)-(\d+)$/.exec(n);if(i){let e=i[1].toUpperCase();if(t.some(t=>t.toUpperCase()===e))return{kind:`issue`,id:`${e}-${i[2]}`}}let a=Ucr.exec(n);return a?{kind:`url`,id:`#${a[2]}`,url:n}:/^https?:\/\//.test(n)?{kind:`url`,url:n}:{kind:`text`}}function Gcr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)}var Kcr=/^[a-zA-Z0-9-]+$/;function qcr(e){return e.kind===`issue`?`Open ${e.id} and start work`:e.kind===`branch`?`Start from branch ${e.branch}`:`Use "${e.slug}" as the name`}function Jcr({value:e,onChange:t,inputRef:n,prefixes:r,projectPrefix:i,branchCandidates:a,onOpenIssue:o,onPickBranch:s,onUseName:c}){let l=(0,L.useId)(),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(-1),m=(0,L.useMemo)(()=>Wcr(e,r),[e,r]),h=(0,L.useMemo)(()=>{let t=[],n=m.kind===`issue`||m.kind===`url`?m.id:void 0,r=n?.startsWith(`#`)?i?`${i}-${n.slice(1)}`:void 0:n;r&&t.push({kind:`issue`,id:r});for(let e of a)t.push({kind:`branch`,branch:e});let o=Gcr(e);return m.kind===`text`&&o&&o!==e.trim()&&t.push({kind:`name`,slug:o}),t},[a,m,i,e]),g=u&&e.trim().length>0&&h.length>0,_=h[0]?.kind===`issue`||!Kcr.test(e.trim())?0:-1,v=f>=0?f:_,y=e=>{d(!1),p(-1),e.kind===`issue`?o(e.id):e.kind===`branch`?s(e.branch):c(e.slug)};return(0,z.jsxs)(`div`,{className:`relative mb-7`,children:[(0,z.jsx)(`input`,{ref:n,"data-testid":`new-workspace-hero-title`,"data-region":`hero-title`,"aria-label":`Workspace name`,"aria-autocomplete":`list`,"aria-controls":g?l:void 0,"aria-expanded":g,className:`display-xl w-full border-0 bg-transparent p-0 text-foreground caret-primary outline-none placeholder:text-muted-foreground/40`,value:e,onChange:e=>{t(e.target.value),d(!0),p(-1)},onBlur:()=>d(!1),onKeyDown:e=>{g&&!e.nativeEvent.isComposing&&(e.key===`ArrowDown`?(e.preventDefault(),p(Math.min(v+1,h.length-1))):e.key===`ArrowUp`?(e.preventDefault(),p(Math.max(v-1,0))):e.key===`Escape`?(e.preventDefault(),d(!1)):e.key===`Enter`&&v>=0&&h[v]&&(e.preventDefault(),y(h[v])))},placeholder:`Untitled workspace`,autoComplete:`off`,spellCheck:!1,autoFocus:!0}),g&&(0,z.jsx)(`div`,{id:l,role:`listbox`,"aria-label":`Suggestions`,className:`absolute left-0 top-full z-20 mt-1 min-w-80 rounded-lg border border-border bg-popover p-1 shadow-lg`,children:h.map((e,t)=>(0,z.jsx)(`div`,{role:`option`,"aria-selected":t===v,onMouseEnter:()=>p(t),onMouseDown:t=>{t.preventDefault(),y(e)},className:`cursor-pointer rounded-md px-3 py-2 text-sm text-popover-foreground ${t===v?`bg-accent`:``}`,children:e.kind===`branch`?(0,z.jsxs)(z.Fragment,{children:[`Start from branch `,(0,z.jsx)(`span`,{className:`font-mono`,children:e.branch})]}):qcr(e)},`${e.kind}-${e.kind===`issue`?e.id:e.kind===`branch`?e.branch:e.slug}`))})]})}var Ycr=[],Xcr=[],Zcr=[[`AUTOMATE`,`Nightly dependency-audit sweep across all registered projects`],[`DELEGATE`,`Triage the untriaged backlog and draft a priority proposal`],[`EXPLORE`,`Map how the merge train decides dispatch order`],[`BUILD`,`Prototype kanban swimlanes grouped by project`],[`PLAN`,`Plan the Q3 cost-governor roadmap from open issues`],[`DESIGN`,`Redesign the agent card footer around the new style guide`]];function Qcr({onCancel:e,onCreated:t}){let n=(0,L.useRef)(null),r=(0,L.useRef)(!1),[i]=(0,L.useState)(()=>Lht()??``),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(!1),_=Hcr({initialProjectKey:i,onCreated:t}),v=F({queryKey:[`registered-projects`],queryFn:async()=>{let e=await Is(`/api/registered-projects`,{credentials:`include`});if(!e.ok)return[];let t=await e.json();return Array.isArray(t)?t:[]},staleTime:6e4}),y=F({queryKey:[`workspace-registry`],queryFn:async()=>{let e=await Is(`/api/workspace-registry`,{credentials:`include`});if(!e.ok)return[];let t=await e.json();return Array.isArray(t.workspaces)?t.workspaces:[]},staleTime:1e4,refetchInterval:1e4}),b=v.data??Ycr,x=y.data??Xcr,S=(0,L.useMemo)(()=>{let e=new Map;for(let t of x)e.set(t.projectId,Math.max(e.get(t.projectId)??0,t.lastAccessedAt));return[...b].sort((t,n)=>(e.get(n.key)??0)-(e.get(t.key)??0))},[b,x]);(0,L.useEffect)(()=>{if(!v.isSuccess||r.current)return;r.current=!0;let e=i?S.find(e=>e.key===i||e.name===i)?.key:void 0;e&&_.projectKey!==e?_.setProjectKey(e):!_.projectKey&&S.length===1&&_.setProjectKey(S[0]?.key??``)},[_.projectKey,_.setProjectKey,i,S,v.isSuccess]),(0,L.useEffect)(()=>{if(_.setTargetPath(``),m(null),c(!1),u(!1),!_.projectKey)return;let e=!1;return(async()=>{try{let t=await Is(`/api/workspace-registry/project-targets?project=${encodeURIComponent(_.projectKey)}`,{credentials:`include`});if(e||!t.ok)return;let n=await t.json();if(e)return;m(n),_.setTargetPath(n.primaryPath)}catch{}})(),()=>{e=!0}},[_.projectKey,_.setTargetPath]),(0,L.useEffect)(()=>{if(g(!1),!_.projectKey)return;let e=!1;return(async()=>{try{let t=await Is(`/api/workspace-registry?project=${encodeURIComponent(_.projectKey)}&kind=main&includeArchived=true`,{credentials:`include`});if(e||!t.ok)return;let n=await t.json();e||g((n.workspaces??[]).length===0)}catch{}})(),()=>{e=!0}},[_.projectKey]);let C=(0,L.useMemo)(()=>{if(!p)return[];let e=new Set;return[p.primaryPath,...p.targets.map(e=>e.path)].filter(t=>!t||e.has(t)?!1:(e.add(t),!0))},[p]),w=_.mode===`isolated`?_.intent?.path??`Resolved isolated path`:_.targetPath||_.intent?.path||`Choose target directory`,T=[`name`,`project`,`targetPath`,`parentBranch`].flatMap(e=>_.findingsFor(e)),E=(0,L.useMemo)(()=>b.flatMap(e=>e.linearTeam?[e.linearTeam]:[]),[b]),D=b.find(e=>e.key===_.projectKey)?.linearTeam??null,O=_.parentBranch||_.intent?.parentBranch,k=!_.parentBranch&&_.intent?.parentBranchGuessed;return(0,z.jsx)(`div`,{"data-testid":`new-workspace-page`,className:`h-full w-full overflow-y-auto bg-background`,children:(0,z.jsxs)(`form`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col px-8 py-12 lg:px-12 lg:py-16`,onSubmit:e=>{e.preventDefault(),_.canCreate&&_.submitIntent()},children:[(0,z.jsxs)(`div`,{"data-testid":`new-workspace-project-chip-row`,"data-region":`project-chip-row`,"data-selected-project":_.projectKey,className:`relative mb-8 flex min-h-9 flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>uS.getState().show(`clone`,`/workspaces/new`),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-dashed border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,z.jsx)(fs,{className:`h-4 w-4`}),`clone repo`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>uS.getState().show(`existing`,`/workspaces/new`),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-dashed border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,z.jsx)(fs,{className:`h-4 w-4`}),`add existing`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>uS.getState().show(`new`,`/workspaces/new`),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-dashed border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,z.jsx)(Efe,{className:`h-4 w-4`}),`new project`]}),S.slice(0,5).map(e=>(0,z.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-project-chip`,"data-project-key":e.key,"aria-pressed":_.projectKey===e.key,onClick:()=>_.setProjectKey(e.key),className:`inline-flex h-9 items-center rounded-lg border px-3 text-sm transition-colors ${_.projectKey===e.key?`border-foreground/40 bg-accent text-foreground`:`border-input text-foreground hover:bg-accent`}`,children:e.name},e.key)),S.length>5&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(e=>!e),className:`inline-flex h-9 items-center gap-2 rounded-lg border border-input px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground`,children:[`more projects`,(0,z.jsx)(po,{className:`h-3.5 w-3.5`})]}),a&&(0,z.jsx)(`div`,{"data-testid":`new-workspace-project-overflow`,className:`absolute left-0 top-11 z-30 min-w-64 rounded-lg border border-border bg-popover p-1 shadow-lg`,children:S.slice(5).map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>{_.setProjectKey(e.key),o(!1)},className:`block w-full rounded-md px-3 py-2 text-left text-sm text-popover-foreground hover:bg-accent`,children:e.name},e.key))})]})]}),(0,z.jsx)(Jcr,{inputRef:n,value:_.name,onChange:_.setName,prefixes:E,projectPrefix:D,branchCandidates:_.intent?.branchCandidates??[],onOpenIssue:e=>{window.history.pushState({},``,`/issues/${encodeURIComponent(e)}`),window.dispatchEvent(new PopStateEvent(`popstate`))},onPickBranch:e=>{_.setParentBranch(e),f(!0)},onUseName:_.setName}),_.mode===`isolated`&&_.intent?.branchName&&(0,z.jsxs)(`p`,{"data-testid":`new-workspace-branch-preview`,className:`-mt-5 mb-7 font-mono text-xs text-muted-foreground`,children:[`Branch: `,_.intent.branchName]}),(0,z.jsxs)(`div`,{"data-testid":`new-workspace-target-row`,"data-region":`target-row`,className:`relative mb-10 flex min-h-9 flex-wrap items-center gap-2.5`,children:[(0,z.jsxs)(`button`,{type:`button`,"data-testid":`new-workspace-target-chip`,disabled:_.mode===`isolated`,"aria-expanded":s,onClick:()=>c(e=>!e),className:`inline-flex h-9 max-w-full items-center gap-2 rounded-lg border border-input bg-transparent px-3 font-mono text-xs text-foreground transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,z.jsx)(Bo,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate`,children:w}),(0,z.jsx)(po,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,z.jsx)(`div`,{className:`inline-flex h-9 overflow-hidden rounded-lg border border-input`,"aria-label":`Workspace mode`,children:[`shared`,`isolated`].map(e=>(0,z.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-mode-${e}`,"aria-pressed":_.mode===e,onClick:()=>_.setMode(e),className:`px-3 text-sm transition-colors ${_.mode===e?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e===`shared`?`Shared directory`:`Isolated worktree`},e))}),(0,z.jsxs)(`button`,{type:`button`,"data-testid":`new-workspace-advanced-toggle`,"aria-expanded":d,onClick:()=>f(e=>!e),className:`eyebrow inline-flex items-center gap-1 bg-transparent px-1 py-2 text-muted-foreground hover:text-foreground`,children:[(0,z.jsx)(ho,{className:`h-3 w-3 transition-transform ${d?`rotate-90`:``}`}),`Advanced`]}),s&&_.mode===`shared`&&(0,z.jsxs)(`div`,{"data-testid":`new-workspace-target-menu`,className:`absolute left-0 top-11 z-20 min-w-72 rounded-lg border border-border bg-popover p-1 shadow-lg`,children:[C.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>{_.setTargetPath(e),c(!1),u(!1)},className:`block w-full rounded-md px-3 py-2 text-left font-mono text-xs text-popover-foreground hover:bg-accent`,children:e},e)),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{u(!0),c(!1)},className:`block w-full rounded-md px-3 py-2 text-left font-mono text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Browse…`})]}),d&&(0,z.jsx)(`input`,{"data-testid":`new-workspace-parent-branch-input`,"aria-label":`Parent branch`,value:_.parentBranch,onChange:e=>_.setParentBranch(e.target.value),placeholder:_.intent?.parentBranch??`parent branch`,className:`h-9 min-w-56 rounded-lg border border-input bg-transparent px-3 font-mono text-xs text-foreground outline-none placeholder:text-muted-foreground focus:border-ring`}),l&&_.mode===`shared`&&(0,z.jsx)(`div`,{className:`w-full rounded-lg border border-border bg-card p-3`,children:(0,z.jsx)(L9,{initialPath:_.targetPath||void 0,onSelect:e=>{_.setTargetPath(e),u(!1)}})})]}),h&&_.projectKey&&(0,z.jsxs)(`div`,{"data-testid":`new-workspace-bootstrap-main`,className:`mb-5 flex items-center justify-between gap-4 rounded-lg border border-border px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`This project has no main workspace registered yet.`}),(0,z.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-bootstrap-main-button`,disabled:_.creating,onClick:()=>{_.submitIntent({project:_.projectKey,bootstrapMain:!0}).then(e=>{e&&g(!1)})},className:`shrink-0 rounded-lg border border-input bg-transparent px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:`Register main workspace`})]}),(0,z.jsx)(`div`,{"data-testid":`new-workspace-hairline-top`,"data-region":`hairline-top`,className:`mb-5 border-t border-border`}),(0,z.jsxs)(`div`,{"data-testid":`new-workspace-status-strip`,"data-region":`status-strip`,className:`mb-5 flex min-h-12 flex-wrap items-center justify-between gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center font-mono text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`mr-2 h-1.5 w-1.5 shrink-0 rounded-full bg-success`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:`Memory enabled`}),T.length>0||_.error?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,z.jsx)(`span`,{"data-testid":`new-workspace-status-finding`,className:`text-destructive-foreground`,children:T.map(e=>e.message).join(` · `)||_.error})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,z.jsx)(`span`,{children:_.mode===`isolated`?`Isolated worktree`:`Files shared`}),(0,z.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,z.jsx)(`span`,{children:_.intent?.isGitRepository?`git repository`:`no git detected`}),_.intent?.path&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,z.jsx)(`span`,{children:_.intent.path})]}),_.intent?.branchName&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,z.jsxs)(`span`,{children:[`creates `,_.intent.branchName]})]}),_.intent?.wouldCreateWorktree&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,z.jsx)(`span`,{children:`worktree`})]}),_.intent?.unregisteredTargetPath&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,z.jsx)(`span`,{className:`text-destructive-foreground`,children:`unregistered target`})]}),O&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`mx-2 opacity-50`,children:`·`}),(0,z.jsxs)(`span`,{"data-testid":`new-workspace-status-parent`,children:[`parent `,O,k?` (inferred)`:``]})]})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,"data-testid":`new-workspace-cancel`,onClick:()=>{window.history.state?.tab===`workspace-new`&&window.history.length>1?window.history.back():e?e():(window.history.replaceState({tab:`home`},``,`/`),window.dispatchEvent(new PopStateEvent(`popstate`)))},className:`eyebrow bg-transparent px-2 py-2 text-muted-foreground hover:text-foreground`,children:`Cancel`}),(0,z.jsxs)(`button`,{type:`submit`,"data-testid":`new-workspace-submit`,disabled:!_.canCreate,className:`inline-flex h-12 items-center gap-3 rounded-xl bg-primary/15 px-5 text-sm font-semibold text-primary transition-colors hover:bg-primary/25 disabled:cursor-not-allowed disabled:opacity-40`,children:[`Start workspace`,(0,z.jsx)(`span`,{className:`inline-grid h-6 min-w-6 place-items-center rounded-md bg-foreground/10 px-1.5 font-mono text-xs`,children:`↵`})]})]})]}),(0,z.jsx)(`div`,{"data-testid":`new-workspace-hairline-bottom`,"data-region":`hairline-bottom`,className:`mb-8 border-t border-border`}),(0,z.jsxs)(`div`,{"data-testid":`new-workspace-idea-grid`,"data-region":`idea-grid`,className:`min-h-48 flex-1`,children:[(0,z.jsx)(`h2`,{className:`eyebrow mb-4 font-mono`,children:`Ideas for your next workspace`}),(0,z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3`,children:Zcr.map(([e,t])=>(0,z.jsxs)(`button`,{type:`button`,"data-testid":`new-workspace-idea-card`,onClick:()=>{_.setName(t),n.current?.focus()},className:`flex min-h-28 flex-col gap-2 rounded-xl border border-transparent bg-foreground/[0.03] p-4 text-left transition-colors hover:bg-foreground/[0.055] active:scale-[0.985]`,children:[(0,z.jsx)(`span`,{className:`eyebrow font-mono`,children:e}),(0,z.jsx)(`span`,{className:`text-sm leading-relaxed text-foreground`,children:t})]},e))})]})]})})}function $cr(){return(0,z.jsxs)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:[`A project is a repository or folder. To make another checkout of a project you already use,`,` `,(0,z.jsx)(`a`,{className:`underline`,href:`/workspaces/new`,children:`create a workspace`}),`.`]})}var elr={clone:`Clone repository`,existing:`Add project`,new:`Create project`},tlr=[`name`,`issuePrefix`,`parentDir`],nlr=`w-full rounded border border-border bg-surface px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-accent`,rlr=`mb-1 block text-sm font-medium text-foreground`,R9=`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`;function z9({findings:e,id:t}){return e.length===0?null:(0,z.jsx)(`div`,{id:t,role:`alert`,className:`mt-1 space-y-1`,children:e.map(e=>(0,z.jsxs)(`p`,{className:`text-sm text-danger`,children:[e.message,e.detail?(0,z.jsx)(`span`,{className:`ml-1 font-mono text-xs opacity-80`,children:e.detail}):null]},e.code))})}function ilr({create:e,titleId:t,banner:n,onChange:r,onCancel:i}){let a=(0,L.useId)(),o=`${a}-url`,s=`${a}-path`,c=`${a}-parent`,l=`${a}-name`,u=`${a}-prefix`,d=`${a}-options`,f=`${a}-status`,{mode:p,setMode:m,url:h,setUrl:g,path:_,setPath:v,parentDir:y,setParentDir:b,name:x,setName:S,issuePrefix:C,setIssuePrefix:w,hasOverrides:T,resetOverrides:E,intent:D,checking:O,resolveError:k,submission:A,frozen:j,canCreate:ee,findingsFor:M,submit:N,cancel:P,checkAgain:te,finishSetup:ne,dismissFailure:re}=e,[ie,ae]=(0,L.useState)(!1),[oe,se]=(0,L.useState)(null),ce=(0,L.useRef)(null),le=(0,L.useRef)(null),ue=(0,L.useRef)(null),de=(0,L.useMemo)(()=>tlr.flatMap(e=>M(e)),[M]);(0,L.useEffect)(()=>{de.length>0&&ae(!0)},[de.length]),(0,L.useEffect)(()=>{ce.current?.focus()},[p]),(0,L.useEffect)(()=>{(A.kind===`failed`||A.kind===`needs-setup`)&&le.current?.focus()},[A.kind]);let fe=(0,L.useCallback)(()=>{ee&&N()},[ee,N]),pe=(0,L.useCallback)(e=>{e.nativeEvent.isComposing||(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),fe())},[fe]),me=(0,L.useCallback)(e=>{e.key!==`Enter`||e.nativeEvent.isComposing||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),fe())},[fe]),he=(0,L.useCallback)((e,t)=>{ue.current=t,se(e)},[]),ge=(0,L.useCallback)(()=>{se(null),ue.current?.focus()},[]),_e=D?.path??null,ve=p===`existing`?_e&&`Will add ${_e}`:_e&&`Will ${p===`clone`?`clone`:`create`} to ${_e}`;return(0,z.jsxs)(`form`,{className:`mx-auto w-full max-w-[42rem] px-6 py-12`,onSubmit:e=>{e.preventDefault(),fe()},onKeyDown:pe,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,z.jsx)(`h1`,{id:t,className:`text-xl font-semibold text-foreground`,children:`Add a project`}),(0,z.jsx)(`button`,{type:`button`,disabled:j,onClick:r,className:`text-sm text-muted-foreground underline disabled:opacity-50`,children:`Change`})]}),(0,z.jsx)($cr,{}),n,(0,z.jsxs)(`fieldset`,{disabled:j,className:`mt-8 space-y-5 border-0 p-0`,children:[p===`clone`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-foreground`,htmlFor:o,children:`Repository URL`}),(0,z.jsx)(`input`,{id:o,ref:ce,className:`w-full rounded border border-border bg-surface px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-accent`,value:h,placeholder:`https://github.com/owner/repo or owner/repo`,"aria-invalid":M(`url`).length>0,"aria-describedby":M(`url`).length?`${o}-error`:void 0,onChange:e=>g(e.target.value),onKeyDown:me}),(0,z.jsx)(z9,{findings:M(`url`),id:`${o}-error`})]}),p===`existing`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-foreground`,htmlFor:s,children:`Folder`}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{id:s,ref:ce,className:`w-full rounded border border-border bg-surface px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-accent font-mono`,value:_,placeholder:`/home/you/Projects/my-repo`,"aria-invalid":M(`path`).length>0,"aria-describedby":M(`path`).length?`${s}-error`:void 0,onChange:e=>v(e.target.value)}),(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:e=>he(`path`,e.currentTarget),children:`Browse server folders`})]}),(0,z.jsx)(z9,{findings:M(`path`),id:`${s}-error`}),D&&!M(`path`).length&&(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:D.isGitRepository?`This folder is a Git repository.`:`This folder is not a Git repository. It can still be a project.`})]}),p===`new`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-foreground`,htmlFor:l,children:`Project name`}),(0,z.jsx)(`input`,{id:l,ref:ce,"data-testid":`new-project-name-input`,className:`w-full rounded border border-border bg-surface px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-accent`,value:x,placeholder:`my-project`,"aria-invalid":M(`name`).length>0,"aria-describedby":M(`name`).length?`${l}-error`:void 0,onChange:e=>S(e.target.value),onKeyDown:me}),(0,z.jsx)(z9,{findings:M(`name`),id:`${l}-error`}),D&&(0,z.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Git repository in `,(0,z.jsx)(`span`,{className:`font-mono`,children:D.parentDir})]})]}),p===`clone`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-foreground`,htmlFor:c,children:`Parent folder`}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{id:c,className:`w-full rounded border border-border bg-surface px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-accent font-mono`,value:y,"aria-invalid":M(`parentDir`).length>0,onChange:e=>b(e.target.value)}),(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:e=>he(`parentDir`,e.currentTarget),children:`Browse`})]}),(0,z.jsx)(z9,{findings:M(`parentDir`),id:`${c}-error`})]}),ve&&(0,z.jsxs)(`p`,{className:`text-sm text-foreground`,children:[ve.split(/(\/.*)/)[0],(0,z.jsx)(`span`,{className:`font-mono`,children:_e})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`button`,{type:`button`,"aria-expanded":ie,"aria-controls":d,onClick:()=>ae(e=>!e),className:`text-sm text-muted-foreground underline`,children:`Options`}),(0,z.jsxs)(`div`,{id:d,hidden:!ie,className:`mt-3 space-y-4`,children:[p!==`new`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-foreground`,htmlFor:l,children:`Project name`}),(0,z.jsx)(`input`,{id:l,"data-testid":`new-project-name-input`,className:`w-full rounded border border-border bg-surface px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-accent`,value:x,"aria-invalid":M(`name`).length>0,onChange:e=>S(e.target.value)}),(0,z.jsx)(z9,{findings:M(`name`),id:`${l}-error`})]}),p===`new`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-foreground`,htmlFor:c,children:`Parent folder`}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{id:c,className:`w-full rounded border border-border bg-surface px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-accent font-mono`,value:y,onChange:e=>b(e.target.value)}),(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:e=>he(`parentDir`,e.currentTarget),children:`Browse`})]}),(0,z.jsx)(z9,{findings:M(`parentDir`),id:`${c}-error`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:rlr,htmlFor:u,children:`Issue prefix`}),(0,z.jsx)(`input`,{id:u,className:nlr,value:C,"aria-invalid":M(`issuePrefix`).length>0,onChange:e=>w(e.target.value)}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Used in issue IDs, for example APP-123.`}),(0,z.jsx)(z9,{findings:M(`issuePrefix`),id:`${u}-error`})]}),T&&(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:E,children:`Reset to detected values`})]})]})]}),oe&&(0,z.jsxs)(`div`,{className:`mt-4 rounded border border-border p-3`,children:[(0,z.jsx)(L9,{initialPath:oe===`path`?_||void 0:y||void 0,onSelect:e=>{oe===`path`?v(e):b(e),ge()}}),(0,z.jsx)(`button`,{type:`button`,className:`mt-2 rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:ge,children:`Close`})]}),(0,z.jsxs)(`div`,{className:`mt-8 flex items-center gap-3`,children:[(0,z.jsx)(`button`,{type:`submit`,disabled:!ee,className:R9,children:elr[p]}),A.kind===`running`&&(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void P(),children:`Cancel clone`}),A.kind===`connection-lost`&&A.exhausted&&(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:te,children:`Check again`}),A.kind===`needs-setup`&&(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void ne(),children:`Finish setup`}),(A.kind===`failed`||A.kind===`cancelled`)&&(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:re,children:`Back to the form`}),A.kind===`editing`&&(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:i,children:`Cancel`})]}),(0,z.jsxs)(`div`,{id:f,"aria-live":`polite`,className:`mt-4 min-h-[1.5rem] text-sm`,children:[O&&A.kind===`editing`&&(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Checking…`}),k&&(0,z.jsx)(`span`,{className:`text-danger`,children:k}),A.kind===`submitting`&&(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Preparing clone…`}),A.kind===`running`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`text-foreground`,children:A.progress.phase===`registering`?`Finishing project setup…`:`${A.progress.phase}…`}),A.progress.percent===null?(0,z.jsx)(`progress`,{className:`ml-2 align-middle`,"aria-label":`Clone progress`}):(0,z.jsx)(`progress`,{className:`ml-2 align-middle`,"aria-label":`Clone progress`,value:A.progress.percent,max:100})]}),A.kind===`cancelling`&&(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Cancelling clone…`}),A.kind===`connection-lost`&&(0,z.jsxs)(`div`,{className:`text-foreground`,children:[(0,z.jsx)(`p`,{children:`Connection interrupted. The clone may still be running.`}),!A.exhausted&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`Checking status…`}),A.lastProgress&&(0,z.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Last update: `,A.lastProgress.phase,A.lastProgress.percent===null?``:` ${A.lastProgress.percent}%`]})]}),A.kind===`cancelled`&&(0,z.jsx)(`span`,{className:`text-foreground`,children:`The clone was cancelled.`})]}),(A.kind===`failed`||A.kind===`needs-setup`)&&(0,z.jsxs)(`div`,{ref:le,tabIndex:-1,role:`alert`,className:`mt-4 rounded border border-danger p-3`,children:[(0,z.jsx)(`p`,{className:`text-sm text-danger`,children:A.failure.message}),A.failure.recovery?.action===`use-existing`&&(0,z.jsx)(`div`,{className:`mt-2 flex gap-2`,children:(0,z.jsx)(`button`,{type:`button`,className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>{let e=A.failure.recovery?.action===`use-existing`?A.failure.recovery.path:``;re(),m(`existing`),v(e)},children:`Use existing folder`})}),A.failure.detail&&(0,z.jsxs)(`details`,{className:`mt-2`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-sm text-muted-foreground`,children:`Details`}),(0,z.jsx)(`pre`,{className:`mt-1 overflow-x-auto whitespace-pre-wrap font-mono text-xs text-muted-foreground`,children:A.failure.detail})]})]})]})}async function alr(e){try{let t=await Is(`/api/projects/resolve`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify(e)});if(!t.ok)return{ok:!1,message:`HTTP ${t.status}`};let n=(await t.json()).findings?.[0];if(n)return{ok:!1,message:n.message};let r=await Is(`/api/projects`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({...e,operationId:crypto.randomUUID()})}),i=await r.json().catch(()=>({}));return!r.ok||!i.key?{ok:!1,message:i.error??i.findings?.[0]?.message??`HTTP ${r.status}`}:(ro(`project_created`,{mode:`existing`}),{ok:!0,project:{key:i.key,name:i.name??i.key,path:i.path??e.path}})}catch{return{ok:!1,message:`Could not reach the server. Try again.`}}}var B9=[`project-suggestions`];function olr(){return F({queryKey:B9,staleTime:3e4,queryFn:async()=>{let e=await Is(`/api/projects/suggestions`,{credentials:`include`});if(!e.ok)return{root:void 0,homeDir:void 0,repositories:[]};let t=await e.json();return{root:typeof t.root==`string`?t.root:void 0,homeDir:typeof t.homeDir==`string`?t.homeDir:void 0,repositories:Array.isArray(t.repositories)?t.repositories:[]}}}).data??{root:void 0,homeDir:void 0,repositories:[]}}function V9(e,t){return t?e===t?`~`:e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e:e}var slr={mode:`existing`,label:`Open a folder`,description:`A project folder, a Git repository, or a folder with many repositories`},clr=[{mode:`clone`,label:`Clone from URL`,description:`Download a Git repository`},{mode:`new`,label:`Create new project`,description:`Start an empty Git repository`}],llr=`block w-full rounded border border-border px-4 py-3 text-left hover:bg-surface-hover focus:outline-none focus:ring-2 focus:ring-accent`;function ulr({titleId:e,showGuide:t,onChoose:n,onCreated:r,onCancel:i}){let a=(0,L.useRef)(null),o=(0,L.useRef)(null),s=$t(),c=olr(),[l,u]=(0,L.useState)({}),d=async e=>{u(t=>({...t,[e]:{kind:`adding`}}));let t=await alr({mode:`existing`,path:e});t.ok?(s.invalidateQueries({queryKey:B9}),r(t.project)):u(n=>({...n,[e]:{kind:`failed`,message:t.message}}))},f=F({queryKey:[`registered-projects`],queryFn:async()=>{let e=await Is(`/api/registered-projects`,{credentials:`include`});if(!e.ok)return[];let t=await e.json();return Array.isArray(t)?t:[]}}),p=f.isSuccess&&f.data.length===0;return(0,L.useEffect)(()=>{o.current?.focus()},[]),(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-[42rem] px-6 py-12`,children:[(0,z.jsx)(`h1`,{id:e,className:`text-xl font-semibold text-foreground`,children:`Add a project`}),p&&(0,z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Add a project to start working in it. You can also skip this and just type on Home.`}),t&&(0,z.jsx)($cr,{}),(0,z.jsxs)(`div`,{ref:a,className:`mt-8`,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(a.current?.querySelectorAll(`[data-add-project-row]`)??[]),n=t.indexOf(document.activeElement);n!==-1&&(e.preventDefault(),t[e.key===`ArrowDown`?Math.min(n+1,t.length-1):Math.max(n-1,0)]?.focus())},children:[(0,z.jsxs)(`button`,{ref:o,type:`button`,"data-add-project-row":!0,onClick:()=>n(slr.mode),className:llr,children:[(0,z.jsxs)(`span`,{className:`flex items-baseline justify-between gap-4`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:slr.label}),(0,z.jsx)(`kbd`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`⏎`})]}),(0,z.jsx)(`span`,{className:`block text-sm text-muted-foreground`,children:slr.description})]}),(0,z.jsx)(`h2`,{className:`mt-6 mb-2 text-sm font-medium text-muted-foreground`,children:`Other ways to add`}),(0,z.jsx)(`div`,{className:`space-y-3`,children:clr.map(e=>(0,z.jsxs)(`button`,{type:`button`,"data-add-project-row":!0,onClick:()=>n(e.mode),className:llr,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.label}),(0,z.jsx)(`span`,{className:`block text-sm text-muted-foreground`,children:e.description})]},e.mode))}),c.repositories.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`h2`,{className:`mt-6 mb-2 text-sm font-medium text-muted-foreground`,children:[`Repositories in `,V9(c.root??``,c.homeDir)]}),(0,z.jsx)(`ul`,{className:`divide-y divide-border rounded border border-border`,children:c.repositories.map(e=>{let t=l[e.path];return(0,z.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-xs text-muted-foreground`,children:V9(e.path,c.homeDir)}),t?.kind===`failed`&&(0,z.jsx)(`span`,{role:`alert`,className:`block text-sm text-danger`,children:t.message})]}),(0,z.jsx)(`button`,{type:`button`,"data-add-project-row":!0,"aria-label":`Add ${e.name}`,disabled:t?.kind===`adding`,onClick:()=>void d(e.path),className:`rounded border border-border px-3 py-2 text-sm text-foreground hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,children:t?.kind===`adding`?`Adding…`:`Add`})]},e.path)})})]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:i,className:`mt-8 ${R9}`,children:`Cancel`})]})}var dlr=`overdeck:project-create:v1`,flr=[1e3,2e3,4e3,8e3,8e3];function plr(){return globalThis.crypto?.randomUUID?.()??`op-${Date.now()}-${Math.random().toString(36).slice(2)}`}function mlr(){try{let e=sessionStorage.getItem(dlr);if(!e)return null;let t=JSON.parse(e);return t.version===1?t:null}catch{return null}}function H9(e){try{e?sessionStorage.setItem(dlr,JSON.stringify(e)):sessionStorage.removeItem(dlr)}catch{}}function hlr(e,t){let n=e;return n?.failure?.code?n.failure:{code:`internal-error`,message:n?.error??t,retrySafe:!0}}function glr({onCreated:e,initialMode:t=`clone`,initialUrl:n}={}){let[r,i]=(0,L.useState)(t),[a,o]=(0,L.useState)(n??``),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(void 0),[d,f]=(0,L.useState)(void 0),[p,m]=(0,L.useState)(void 0),[h,g]=(0,L.useState)(null),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(null),[x,S]=(0,L.useState)({kind:`editing`}),C=(0,L.useRef)(0),w=(0,L.useRef)(0),T=(0,L.useRef)(!1),E=(0,L.useRef)(null),D=(0,L.useRef)(null),O=(0,L.useRef)(0),k=(0,L.useRef)(null),A=(0,L.useRef)(null),j=x.kind===`submitting`||x.kind===`running`||x.kind===`cancelling`||x.kind===`connection-lost`,ee=(0,L.useCallback)(()=>{D.current!==null&&(clearTimeout(D.current),D.current=null)},[]);(0,L.useEffect)(()=>()=>{w.current+=1,ee(),A.current?.abort()},[ee]);let M=l??h?.parentDir??``,N=d??h?.name??``,P=p??h?.proposedIssuePrefix??``,te=(0,L.useMemo)(()=>({mode:r,...r===`clone`&&a?{url:a}:{},...r===`existing`&&s?{path:s}:{},...l?{parentDir:l}:{},...d?{name:d}:{},...p?{issuePrefix:p}:{}}),[r,a,s,l,d,p]);(0,L.useEffect)(()=>{if(j)return;let e=++C.current;v(!0),b(null);let t=setTimeout(()=>{(async()=>{try{let t=await Is(`/api/projects/resolve`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify(te)});if(e!==C.current)return;if(!t.ok){v(!1),b(`Could not check this with the server. Try again.`);return}let n=await t.json();if(e!==C.current)return;g(n),v(!1)}catch{if(e!==C.current)return;v(!1),b(`Could not reach the server. Check your connection, then try again.`)}})()},300);return()=>clearTimeout(t)},[te,j]);let ne=(0,L.useCallback)(e=>(h?.findings??[]).filter(t=>t.field===e),[h]),re=(0,L.useCallback)(e=>{j||(i(e),o(``),c(``),g(null))},[j]),ie=(0,L.useCallback)(()=>{f(void 0),m(void 0),u(void 0)},[]),ae=(0,L.useCallback)((t,n)=>{H9(null),S({kind:`done`,result:n}),k.current!==t&&(k.current=t,ro(`project_created`,{mode:r}),e?.(n))},[r,e]),oe=(0,L.useCallback)((e,t)=>{ee(),D.current=window.setTimeout(e,t)},[ee]),se=(0,L.useRef)(null),ce=(0,L.useCallback)(async(e,t)=>{try{let n=await Is(`/api/projects/create-jobs/reconcile`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({operationId:e.operationId,jobId:e.jobId,key:e.expectedKey,expectedPath:e.expectedPath,mode:e.mode,expectedRepoSlug:e.expectedRepoSlug??null})});if(t!==w.current)return;if(!n.ok){S({kind:`connection-lost`,operationId:e.operationId,jobId:e.jobId,exhausted:!0});return}let r=await n.json();if(t!==w.current)return;if(r.status===`completed`){ae(e.operationId,{key:r.key,name:r.name??r.key,path:r.path,mainWorkspaceId:r.mainWorkspaceId});return}if(r.status===`needs-setup`){S({kind:`needs-setup`,operationId:e.operationId,key:r.key,path:r.path,failure:{code:`setup-incomplete`,message:`The repository is available at ${r.path}, but project setup did not finish.`,retrySafe:!1,recovery:{action:`finish-setup`,key:r.key,path:r.path}}});return}if(r.status===`job`){let n={...e,jobId:r.job.id};H9(n),S({kind:`running`,operationId:e.operationId,jobId:r.job.id,progress:{phase:r.job.phase,percent:r.job.percent}}),O.current=0,se.current?.(n,t);return}S({kind:`connection-lost`,operationId:e.operationId,jobId:e.jobId,exhausted:!0})}catch{if(t!==w.current)return;S({kind:`connection-lost`,operationId:e.operationId,jobId:e.jobId,exhausted:!0})}},[ae]),le=(0,L.useCallback)(async(e,t)=>{let n=e.jobId;if(n)try{let r=await Is(`/api/projects/create-jobs/${n}`,{credentials:`include`});if(t!==w.current)return;if(r.status===404){await ce(e,t);return}if(r.status===401||r.status===403){S({kind:`connection-lost`,operationId:e.operationId,jobId:n,exhausted:!0});return}if(!r.ok)throw Error(`HTTP ${r.status}`);O.current=0;let i=await r.json();if(t!==w.current)return;if(i.status===`done`&&i.result){ae(e.operationId,i.result);return}if(i.status===`cancelled`){H9(null),S({kind:`cancelled`});return}if(i.status===`failed`){let t=hlr(i,`Project setup failed on the server.`);H9(null),S(t.code===`setup-incomplete`&&t.recovery?.action===`finish-setup`?{kind:`needs-setup`,operationId:e.operationId,key:t.recovery.key,path:t.recovery.path,failure:t}:{kind:`failed`,failure:t,retrySafe:t.retrySafe});return}let a={phase:i.phase,percent:i.percent};S(t=>t.kind===`cancelling`?t:{kind:`running`,operationId:e.operationId,jobId:n,progress:a}),oe(()=>void le(e,t),750)}catch{if(t!==w.current)return;let r=O.current;if(r>=flr.length){S(t=>({kind:`connection-lost`,operationId:e.operationId,jobId:n,lastProgress:t.kind===`running`?t.progress:void 0,exhausted:!0}));return}O.current=r+1,S(t=>({kind:`connection-lost`,operationId:e.operationId,jobId:n,lastProgress:t.kind===`running`?t.progress:t.kind===`connection-lost`?t.lastProgress:void 0,exhausted:!1})),oe(()=>void le(e,t),flr[r])}},[ae,ce,oe]);se.current=(e,t)=>void le(e,t),(0,L.useEffect)(()=>{let e=mlr();e&&(E.current=e.operationId,T.current=!0,S({kind:`connection-lost`,operationId:e.operationId,jobId:e.jobId,exhausted:!1}),e.jobId?le(e,w.current):ce(e,w.current))},[]);let ue=(h?.findings.length??0)>0,de=x.kind===`editing`&&!_&&!!h&&!ue&&!y,fe=(0,L.useCallback)(async()=>{if(T.current||!de||!h)return;T.current=!0;let e=E.current??plr();E.current=e;let t=w.current;S({kind:`submitting`,operationId:e});let n={version:1,operationId:e,mode:r,expectedKey:h.key??``,expectedPath:h.path??``,expectedRepoSlug:h.repoSlug};try{let r=await Is(`/api/projects`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({...te,operationId:e})});if(t!==w.current)return;if(r.status===202){let{jobId:i}=await r.json();if(!i){H9(n),S({kind:`connection-lost`,operationId:e,exhausted:!0});return}let a={...n,jobId:i};H9(a),S({kind:`running`,operationId:e,jobId:i,progress:{phase:`preparing`,percent:null}}),O.current=0,le(a,t);return}if(r.ok){ae(e,await r.json());return}if(r.status===422){let{findings:e}=await r.json();g(t=>t&&{...t,findings:e??[]}),T.current=!1,E.current=null,S({kind:`editing`});return}let i=hlr(await r.json().catch(()=>null),`Project setup failed.`);S(i.recovery?.action===`finish-setup`?{kind:`needs-setup`,operationId:e,key:i.recovery.key,path:i.recovery.path,failure:i}:{kind:`failed`,failure:i,retrySafe:i.retrySafe}),i.retrySafe&&(T.current=!1,E.current=null)}catch{if(t!==w.current)return;H9(n),S({kind:`connection-lost`,operationId:e,exhausted:!1}),ce(n,t)}},[de,h,r,te,ae,le,ce]),pe=(0,L.useCallback)(async()=>{if(x.kind!==`running`)return;let{operationId:e,jobId:t}=x;S({kind:`cancelling`,operationId:e,jobId:t});try{(await Is(`/api/projects/create-jobs/${t}/cancel`,{method:`POST`,credentials:`include`,headers:await Ac(),body:`{}`})).status===409&&S({kind:`running`,operationId:e,jobId:t,progress:{phase:`registering`,percent:null}})}catch{S({kind:`connection-lost`,operationId:e,jobId:t,exhausted:!0})}},[x]),me=(0,L.useCallback)(()=>{if(x.kind!==`connection-lost`)return;let e=mlr();e&&(O.current=0,S({...x,exhausted:!1}),e.jobId?le(e,w.current):ce(e,w.current))},[x,le,ce]),he=(0,L.useCallback)(async()=>{if(x.kind!==`needs-setup`)return;let{key:e,path:t,operationId:n}=x;try{let r=await Is(`/api/projects/${encodeURIComponent(e)}/finish-setup`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify({expectedPath:t,operationId:n})});if(r.ok){ae(n,await r.json());return}S({...x,failure:hlr(await r.json().catch(()=>null),`Setup could not be finished.`)})}catch{S({kind:`connection-lost`,operationId:n,exhausted:!0})}},[x,ae]),ge=(0,L.useCallback)(()=>{T.current=!1,E.current=null,H9(null),S({kind:`editing`})},[]);return{mode:r,setMode:re,url:a,setUrl:o,path:s,setPath:c,parentDir:M,setParentDir:u,name:N,setName:f,issuePrefix:P,setIssuePrefix:m,hasOverrides:d!==void 0||p!==void 0||l!==void 0,resetOverrides:ie,intent:h,checking:_,resolveError:y,submission:x,frozen:j,canCreate:de,findingsFor:ne,submit:fe,cancel:pe,checkAgain:me,finishSetup:he,dismissFailure:ge}}function _lr({mode:e,initialUrl:t,titleId:n,onCreated:r,onChange:i,onCancel:a,onBusyChange:o}){let s=glr({initialMode:e,onCreated:r,initialUrl:t});return(0,L.useEffect)(()=>(o?.(s.frozen),()=>o?.(!1)),[s.frozen,o]),(0,z.jsx)(ilr,{create:s,titleId:n,onChange:i,onCancel:a})}function vlr({titleId:e,folder:t,homeDir:n,repositories:r,onCreated:i,onBack:a,onCancel:o,onRunningChange:s}){let c=$t(),[l,u]=(0,L.useState)(()=>new Set(r.map(e=>e.path))),[d,f]=(0,L.useState)({}),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(null),[_,v]=(0,L.useState)(null);(0,L.useEffect)(()=>(s?.(p),()=>s?.(!1)),[p,s]);let y=r.filter(e=>l.has(e.path)),b=y.length,x=b===0||p||h!==null,S=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),C=async()=>{m(!0);let e=null,t=!1;for(let n of y){f(e=>({...e,[n.path]:{kind:`adding`}}));let r=await alr({mode:`existing`,path:n.path});r.ok?(e=r.project,f(e=>({...e,[n.path]:{kind:`added`}}))):(t=!0,f(e=>({...e,[n.path]:{kind:`failed`,message:r.message}})))}m(!1),c.invalidateQueries({queryKey:B9}),!t&&e?i(e):g({lastAdded:e})},w=async()=>{m(!0),v(null);let e=await alr({mode:`existing`,path:t,repos:y.map(e=>e.name)});m(!1),e.ok?(c.invalidateQueries({queryKey:B9}),i(e.project)):v(e.message)};return(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-[42rem] px-6 py-12`,children:[(0,z.jsx)(`h1`,{id:e,className:`text-xl font-semibold text-foreground`,children:`Add a project`}),(0,z.jsxs)(`p`,{className:`mt-2 text-sm text-foreground`,children:[`Found `,r.length,` `,r.length===1?`repository`:`repositories`,` in`,` `,(0,z.jsx)(`span`,{className:`font-mono`,children:V9(t,n)})]}),(0,z.jsx)(`ul`,{className:`mt-6 divide-y divide-border rounded border border-border`,children:r.map(e=>{let t=d[e.path];return(0,z.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,id:`nested-${e.path}`,checked:l.has(e.path),disabled:p||h!==null,onChange:()=>S(e.path)}),(0,z.jsxs)(`label`,{htmlFor:`nested-${e.path}`,className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-xs text-muted-foreground`,children:V9(e.path,n)})]}),t&&(0,z.jsx)(`span`,{"data-testid":`nested-row-status`,className:`text-sm ${t.kind===`failed`?`text-danger`:`text-muted-foreground`}`,children:t.kind===`adding`?`Adding…`:t.kind===`added`?`Added`:t.message})]},e.path)})}),(0,z.jsxs)(`div`,{className:`mt-8 flex flex-wrap items-start gap-3`,children:[(0,z.jsxs)(`button`,{type:`button`,disabled:x,onClick:()=>void C(),className:R9,children:[`Add `,b,` `,b===1?`project`:`projects`]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`button`,{type:`button`,disabled:x,onClick:()=>void w(),className:R9,children:`Add this folder as one project`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`One multi-repo project spanning the checked repositories.`})]})]}),_&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:_}),(0,z.jsx)(`div`,{className:`mt-8 flex gap-3`,children:h?(0,z.jsx)(`button`,{type:`button`,className:R9,onClick:()=>h.lastAdded?i(h.lastAdded):o(),children:`Done`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,disabled:p,onClick:a,className:R9,children:`Back`}),(0,z.jsx)(`button`,{type:`button`,disabled:p,onClick:o,className:R9,children:`Cancel`})]})})]})}function ylr({titleId:e,showGuide:t,onCreated:n,onChange:r,onCancel:i,onBusyChange:a}){let o=glr({initialMode:`existing`,onCreated:n}),{path:s,setPath:c,intent:l,checking:u,resolveError:d,canCreate:f,submit:p,submission:m,frozen:h}=o,[g,_]=(0,L.useState)(!1);(0,L.useEffect)(()=>(a?.(h||g),()=>a?.(!1)),[h,g,a]);let v=olr(),y=(0,L.useId)(),[b,x]=(0,L.useState)(`pick`),[S,C]=(0,L.useState)(``),[w,T]=(0,L.useState)(void 0),E=(0,L.useRef)(null),D=(0,L.useRef)(!1);(0,L.useEffect)(()=>{b===`pick`&&E.current?.focus()},[b]),(0,L.useEffect)(()=>{b===`waiting`&&(u?D.current=!0:D.current&&x(`review`))},[b,u]);let O=e=>{let t=e.trim();if(t){if(C(t),t===s&&l&&!u){x(`review`);return}D.current=!1,c(t),x(`waiting`)}},k=()=>{T(l?.path??(s||void 0)),x(`pick`)},A=n=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,z.jsx)(`h1`,{id:e,className:`text-xl font-semibold text-foreground`,children:`Add a project`}),n&&(0,z.jsx)(`button`,{type:`button`,onClick:r,className:`text-sm text-muted-foreground underline`,children:`Change`})]}),t&&(0,z.jsx)($cr,{})]});if(b===`review`&&l&&!d){let t=(l.notices??[]).find(e=>e.code===`using-repository-root`),a=t?(0,z.jsxs)(`p`,{role:`status`,className:`mt-2 text-sm text-foreground`,children:[`Using the repository root`,` `,(0,z.jsx)(`span`,{className:`font-mono`,children:V9(t.detail??l.path??``,l.homeDir)}),`.`]}):null,c=l.nestedRepositories??[];return!l.isGitRepository&&c.length>0&&l.path?(0,z.jsx)(vlr,{titleId:e,folder:l.path,homeDir:l.homeDir,repositories:c,onCreated:n,onBack:k,onCancel:i,onRunningChange:_}):!l.isGitRepository&&(m.kind===`editing`||m.kind===`submitting`)?(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-[42rem] px-6 py-12`,children:[A(!0),(0,z.jsx)(`p`,{className:`mt-8 font-mono text-sm text-foreground`,children:V9(l.path??s,l.homeDir)}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-foreground`,children:`This folder isn't a Git repository. Agents and terminals work here; branches, isolated copies and pull requests won't.`}),l.findings.length>0&&(0,z.jsx)(`div`,{role:`alert`,className:`mt-2 space-y-1`,children:l.findings.map(e=>(0,z.jsx)(`p`,{className:`text-sm text-danger`,children:e.message},e.code))}),(0,z.jsxs)(`div`,{className:`mt-8 flex items-center gap-3`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:!f,onClick:()=>void p(),className:R9,children:m.kind===`submitting`?`Adding…`:`Add as folder`}),(0,z.jsx)(`button`,{type:`button`,disabled:m.kind===`submitting`,onClick:k,className:R9,children:`Back`})]})]}):(0,z.jsx)(ilr,{create:o,titleId:e,banner:a,onChange:r,onCancel:i})}return(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-[42rem] px-6 py-12`,children:[A(!0),(0,z.jsxs)(`form`,{className:`mt-8`,onSubmit:e=>{e.preventDefault(),O(S)},children:[(0,z.jsx)(`label`,{className:rlr,htmlFor:y,children:`Folder`}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{id:y,ref:E,className:`${nlr} font-mono`,value:S,placeholder:`/home/you/Projects/my-repo`,onChange:e=>C(e.target.value)}),(0,z.jsx)(`button`,{type:`submit`,disabled:!S.trim()||b===`waiting`,className:R9,children:`Continue`})]})]}),(0,z.jsx)(`div`,{className:`mt-4 rounded border border-border p-3`,children:(0,z.jsx)(L9,{initialPath:w??v.root,onSelect:O})}),(0,z.jsxs)(`div`,{"aria-live":`polite`,className:`mt-4 min-h-[1.5rem] text-sm`,children:[b===`waiting`&&(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Checking…`}),b===`review`&&d&&(0,z.jsx)(`span`,{className:`text-danger`,children:d})]}),(0,z.jsx)(`button`,{type:`button`,onClick:i,className:`mt-4 ${R9}`,children:`Cancel`})]})}var blr={clone:`clone`,new:`create`,existing:`folder`},xlr={clone:`clone`,create:`new`};function Slr({variant:e,initialMode:t,initialUrl:n,onCreated:r,onCancel:i}){let[a,o]=(0,L.useState)(t?blr[t]:`start`),[s,c]=(0,L.useState)(!1),l=(0,L.useId)(),u=(0,L.useCallback)(()=>o(`start`),[]),d=a===`start`?(0,z.jsx)(ulr,{titleId:l,showGuide:e===`page`,onChoose:e=>o(blr[e]),onCreated:r,onCancel:i}):a===`folder`?(0,z.jsx)(ylr,{titleId:l,showGuide:e===`page`,onCreated:r,onChange:u,onCancel:i,onBusyChange:c}):(0,z.jsx)(_lr,{mode:xlr[a],initialUrl:a===`clone`?n:void 0,titleId:l,onCreated:r,onChange:u,onCancel:i,onBusyChange:c},a);return e===`page`?(0,z.jsx)(`div`,{className:`h-full w-full overflow-y-auto bg-background`,children:d}):(0,z.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-start justify-center overflow-y-auto pt-[8vh]`,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-black/70`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":l,onKeyDown:e=>{e.key===`Escape`&&!s&&(e.preventDefault(),i())},className:`relative mx-4 mb-8 w-full max-w-[42rem] rounded border border-border bg-background shadow-2xl`,children:d})]})}function Clr({onCreated:e}){let t=uS(e=>e.open),n=uS(e=>e.mode),r=uS(e=>e.initialUrl),i=uS(e=>e.onCreatedExtra),a=uS(e=>e.hide);return t?(0,z.jsx)(Slr,{variant:`modal`,initialMode:n,initialUrl:r,onCancel:a,onCreated:t=>{e(t),i?.(t),a()}}):null}function wlr({onCancel:e,onCreated:t}){return(0,z.jsx)(Slr,{variant:`page`,initialMode:Rht()??void 0,onCreated:t,onCancel:e})}function Tlr(e,t){return e===t||e.startsWith(t.endsWith(`/`)?t:`${t}/`)}function Elr({workspaceId:e,onBack:t}){let{data:n}=F({queryKey:[`workspace-registry`,e],queryFn:async()=>{let t=await fetch(`/api/workspace-registry/${e}`);return t.ok?t.json():null}}),{data:r}=F({queryKey:[`workspace-registry`,e,`memory`],queryFn:async()=>{let t=await fetch(`/api/workspace-registry/${e}/memory`);return t.ok?t.json():null},refetchInterval:15e3,enabled:!!n}),{data:i}=F({queryKey:[`workspace-plan`,n?.issueId],queryFn:async()=>{if(!n?.issueId)return null;let e=await fetch(`/api/workspaces/${n.issueId}/plan`);return e.ok?e.json():null},enabled:!!n?.issueId}),{data:a}=F({queryKey:[`conversations`],queryFn:gIe,refetchInterval:1e4}),o=Array.isArray(a)?a:[],[s,c]=(0,L.useState)(!1),l=(0,L.useMemo)(()=>{if(s||!n)return;let t=new Set;for(let r of o)(r.workspaceId==null?Tlr(r.cwd,n.path):r.workspaceId===e)&&t.add(r.id);return t},[s,n,e,o]),u=JTe(e),d=(0,L.useCallback)(t=>{GTe(e,t)},[e]),[f,p]=(0,L.useState)(null),m=o.find(e=>e.name===f)??null,h=Wt(Jt),g=(0,L.useMemo)(()=>{if(!n?.issueId)return null;let e=n.issueId.toLowerCase();return h.find(t=>t.issueId?.toLowerCase()===e)??null},[h,n]),_=(0,L.useMemo)(()=>{let t=n?.layoutConfig??null;return{getItem:()=>t,setItem:(n,r)=>{t=r;let i;try{i=JSON.parse(r)}catch{return}fetch(`/api/workspace-registry/${e}/layout`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({layout:i})})}}},[e,n!==void 0]),{defaultLayout:v,onLayoutChanged:y}=Jxt({id:`workspace-${e}`,storage:_}),b=$t(),x=As(),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(null),E=(0,L.useCallback)(()=>{b.invalidateQueries({queryKey:[`workspace-registry`]}),b.invalidateQueries({queryKey:[`workspace-registry`,e]})},[b,e]),D=(0,L.useCallback)(async(t,n)=>{T(null);try{let r=await Is(`/api/workspace-registry/${e}${t}`,{method:`POST`,credentials:`include`,headers:await Ac(),body:JSON.stringify(n)});if(!r.ok){let e=await r.json().catch(()=>({}));return T(e.error??`HTTP ${r.status}`),!1}return E(),!0}catch(e){return T(e instanceof Error?e.message:String(e)),!1}},[e,E]),O=(0,L.useCallback)(()=>{D(`/favorite`,{favorite:!n?.isFavorite})},[D,n?.isFavorite]),k=(0,L.useCallback)(async()=>{await x({title:`Archive workspace`,message:`Archive '${n?.name}'? It disappears from the rail but its files, branch and memory are left untouched.`,confirmLabel:`Archive`,variant:`destructive`})&&D(`/archive`,{archived:!0})},[x,D,n?.name]),A=(0,L.useCallback)(async e=>{C(!1);let t=n?.kind===`main`;await x({title:`Relocate workspace`,message:t?`Point the main workspace at ${e}? Its path will diverge from projects.yaml's primary path.`:`Point '${n?.name}' at ${e}?`,confirmLabel:`Relocate`,...t?{variant:`destructive`,requiredText:n?.name??`main`}:{}})&&D(`/relocate`,t?{path:e,force:!0}:{path:e})},[x,D,n?.kind,n?.name]);return n?(0,z.jsxs)(`div`,{className:`flex flex-col w-full h-full overflow-hidden`,"data-testid":`workspace-view`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b border-border shrink-0`,children:[t&&(0,z.jsx)(`button`,{type:`button`,onClick:t,"data-testid":`workspace-view-back`,className:`text-muted-foreground hover:text-foreground text-sm`,children:`← Back`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:n.title??n.name}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:n.kind}),n.kind!==`issue`&&(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,"data-testid":`workspace-view-actions`,children:[(0,z.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-favorite`,onClick:O,"aria-pressed":n.isFavorite,className:`text-xs text-muted-foreground hover:text-foreground`,children:n.isFavorite?`Unfavorite`:`Favorite`}),(0,z.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-relocate`,onClick:()=>C(e=>!e),className:`text-xs text-muted-foreground hover:text-foreground`,children:`Relocate`}),(0,z.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-archive`,onClick:()=>void k(),className:`text-xs text-destructive hover:brightness-110`,children:`Archive`})]})]}),S&&n.kind!==`issue`&&(0,z.jsx)(`div`,{className:`border-b border-border px-4 py-2 shrink-0`,"data-testid":`workspace-view-relocate-picker`,children:(0,z.jsx)(L9,{onSelect:e=>void A(e),initialPath:n.path})}),w&&(0,z.jsx)(`div`,{className:`border-b border-border px-4 py-2 text-xs text-destructive shrink-0`,"data-testid":`workspace-view-action-error`,children:w}),(0,z.jsx)(QTe,{workspaceId:e,kind:n.kind,issueId:n.issueId,isGitRepository:n.isGitRepository!==!1,runCommand:n.runCommand??null,runCommandDefault:n.runCommandDefault??null,runCommandOptions:n.runCommandOptions??[],openInEditorConfigured:n.openInEditorConfigured===!0,runSessionName:u,onRunSessionChange:d},e),n.kind===`issue`&&n.issueId&&(0,z.jsxs)(`div`,{className:`border-b border-border p-3 space-y-3 shrink-0 max-h-64 overflow-y-auto`,"data-testid":`workspace-view-issue-panels`,children:[(0,z.jsx)(kdt,{issueId:n.issueId}),(0,z.jsx)(uE,{doc:i??null,showTabBar:!1})]}),(0,z.jsxs)(dO,{orientation:`horizontal`,defaultLayout:v,onLayoutChanged:y,className:`flex-1 min-h-0`,id:`workspace-${e}`,children:[(0,z.jsxs)(pO,{id:`terminal`,defaultSize:34,minSize:15,className:`min-w-0 h-full overflow-hidden flex flex-col`,children:[g?(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(C_,{sessionName:g.id,embedded:!0})}):u?null:(0,z.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,"data-testid":`workspace-view-no-terminal`,children:`No active agent terminal for this workspace.`}),u&&(0,z.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col border-t border-border first:border-t-0`,"data-testid":`workspace-view-run-terminal`,children:[(0,z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground px-3 py-1 shrink-0`,children:`Run`}),(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(C_,{sessionName:u,embedded:!0})})]})]}),(0,z.jsx)(mO,{className:`w-px bg-border`}),(0,z.jsxs)(pO,{id:`conversations`,defaultSize:33,minSize:15,className:`min-w-0 h-full overflow-hidden flex flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[(0,z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground`,children:`Conversations`}),(0,z.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-all-conversations-toggle`,onClick:()=>c(e=>!e),className:`text-[10px] text-muted-foreground hover:text-foreground`,children:s?`This workspace`:`All conversations`})]}),(0,z.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:m?(0,z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,z.jsx)(`button`,{type:`button`,"data-testid":`workspace-view-conversation-back`,onClick:()=>p(null),className:`text-left px-3 py-1.5 text-[11px] text-muted-foreground hover:text-foreground border-b border-border shrink-0`,children:`← All conversations`}),(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(oE,{conversation:m,embedded:!0})})]}):(0,z.jsx)(wIe,{selectedConversation:f,onSelectConversation:p,includeIds:l})})]}),(0,z.jsx)(mO,{className:`w-px bg-border`}),(0,z.jsxs)(pO,{id:`memory`,defaultSize:33,minSize:15,className:`min-w-0 h-full overflow-y-auto p-3`,children:[(0,z.jsxs)(`p`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground mb-2`,children:[`Memory`,r?.status&&(0,z.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-muted-foreground/70`,"data-testid":`workspace-view-memory-phase`,children:[r.status.phase,typeof r.status.confidence==`number`&&` · confidence ${r.status.confidence}`]})]}),r?.status?(0,z.jsxs)(`div`,{className:`space-y-2`,"data-testid":`workspace-view-memory-status`,children:[(0,z.jsx)(`p`,{className:`text-sm text-foreground`,children:r.status.headline}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.status.summary}),r.status.nextSteps.length>0&&(0,z.jsx)(`ul`,{className:`text-xs text-muted-foreground list-disc pl-4`,children:r.status.nextSteps.map(e=>(0,z.jsx)(`li`,{children:e},e))})]}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`No memory status yet.`}),(0,z.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-widest text-muted-foreground mt-4 mb-2`,children:`Observations`}),(0,z.jsx)(`ul`,{className:`space-y-2`,"data-testid":`workspace-view-observation-timeline`,children:(r?.observations??[]).map(e=>(0,z.jsxs)(`li`,{className:`text-xs text-muted-foreground border-l-2 border-border pl-2`,children:[(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:e.timestamp}),(0,z.jsx)(`p`,{className:`text-foreground`,children:e.actionStatus??e.summary})]},e.id))})]})]})]}):(0,z.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,"data-testid":`workspace-view-loading`,children:`Loading workspace…`})}function Dlr(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var{useRef:Olr}=L.default;function klr(e){let t=Olr();return n=>{let r=e(n);return Dlr(t.current,r)?t.current:t.current=r}}function Alr({children:e}){let t=Tc(klr(e=>({serverReachable:e.serverReachable,streamLive:e.streamLive,restarting:e.restarting,sessionAuthFailed:e.sessionAuthFailed,hasSnapshot:e.hasSnapshot,lastLiveAt:e.lastLiveAt}))),n=Ec(t),r=Oc(n),i=$t(),a=(0,L.useRef)(r);return(0,L.useEffect)(()=>{a.current&&!r&&i.invalidateQueries(),a.current=r},[r,i]),Qge(t)?(0,z.jsx)(jlr,{phase:n}):(0,z.jsx)(z.Fragment,{children:e})}function jlr({phase:e}){return(0,z.jsx)(`div`,{role:`status`,"data-component":`first-load-screen`,className:`flex h-full w-full items-center justify-center bg-background p-8`,children:(0,z.jsxs)(`div`,{className:`flex max-w-md items-start gap-3 text-left`,children:[(0,z.jsx)(zt,{className:`mt-0.5 h-5 w-5 shrink-0 animate-spin text-primary`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e===`restarting`?`Overdeck server is restarting`:e===`unauthorized`?`Dashboard session could not be established`:`Can't reach the Overdeck server`}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e===`unauthorized`?`The server refused this browser's session. See docs/DASHBOARD-AUTH.md.`:`The dashboard will load as soon as the server answers.`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>Tc.getState().requestReconnect(),className:`mt-3 rounded-md border border-border px-3 py-1 text-sm text-foreground transition-colors hover:bg-muted`,children:`Retry`})]})]})})}function Mlr({activeTab:e,issues:t,selectedConvId:n,conversationViewMode:r,selectedProjectKey:i,pendingConversationTarget:a,cockpitRoute:o,workspaceRouteId:s,onWorkspaceViewBack:c,onWorkspaceCreated:l,onProjectCreated:u,initialSessionKey:d,onOpenWorkspaceHome:f,onNewProject:p,onSelectProject:m,onOpenSettings:h,onConvIdChange:g,onConversationViewModeChange:_,onPendingConversationTargetConsumed:v,onProjectPrefixChange:y,onCockpitChange:b,onSearchOpen:x,onTabChange:S,onOpenIssue:C,onPlanDialogChange:w,onSelectAgent:T,onBacklogIssueAction:E,keyboardShortcutsDisabled:D=!1}){return(0,z.jsxs)(Alr,{children:[e===`home`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(j7n,{advanced:(0,z.jsx)(wcr,{onOpenWorkspaceHome:f,onNewProject:p,onSelectProject:m,onOpenSettings:h})})}),e===`command-deck`&&(0,z.jsx)(`div`,{className:`w-full h-full`,children:(0,z.jsx)(hGt,{issues:t,convId:n,conversationViewMode:r,onConvIdChange:g,onConversationViewModeChange:_,pendingConversationTarget:a,onPendingConversationTargetConsumed:v,selectedProject:i,onSelectProject:m,onProjectPrefixChange:y,cockpitIssue:o,onCockpitChange:b})}),e===`workspace-new`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(Qcr,{onCancel:()=>S(`home`),onCreated:l},Lht()??``)}),e===`project-new`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(wlr,{onCancel:()=>S(`home`),onCreated:u})}),e===`workspace`&&s&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(Elr,{workspaceId:s,onBack:c})}),e===`pipeline`&&(0,z.jsx)(o7,{fallback:(0,z.jsx)(P7n,{}),children:(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(fKt,{onSearchOpen:x,onTabChange:e=>S(e),keyboardShortcutsDisabled:D})})}),e===`awaiting-merge`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-auto`,children:(0,z.jsx)(CKt,{})}),e===`kanban`&&(0,z.jsx)(o7,{fallback:(0,z.jsx)(`div`,{className:`flex-1 overflow-auto p-6 w-full`,children:(0,z.jsx)(M7n,{})}),children:(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto p-6 w-full`,children:[(0,z.jsx)(Zwt,{}),(0,z.jsx)(lbt,{selectedIssue:null,onSelectIssue:e=>{e&&C(e)},onPlanDialogChange:w,keyboardShortcutsDisabled:D})]})})}),e===`agents`&&(0,z.jsx)(o7,{fallback:(0,z.jsx)(N7n,{}),children:(0,z.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,z.jsx)(YCt,{onNavigateToIssues:()=>S(`kanban`)})})}),e===`resources`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(Oqt,{onNavigateToAgents:e=>{T(e),S(`agents`)}})}),e===`knowledge`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(I8n,{projectKey:i})}),e===`skills`&&(0,z.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,z.jsx)(Mwt,{})}),e===`context`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(A8n,{})}),e===`health`&&(0,z.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,z.jsx)(jwt,{onOpenSettings:h})}),e===`activity`&&(0,z.jsx)(`div`,{className:`w-full h-full`,children:(0,z.jsx)(Jwt,{onClose:()=>S(`kanban`)})}),e===`metrics`&&(0,z.jsx)(`div`,{className:`w-full overflow-auto`,children:(0,z.jsx)(eTt,{})}),e===`costs`&&(0,z.jsx)(`div`,{className:`w-full overflow-auto`,children:(0,z.jsx)(bMt,{})}),e===`autopreso`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(E5n,{})}),e===`flywheel`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(uer,{onOpenSettings:h,onNavigateIssue:C})}),e===`orders`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(v9n,{})}),e===`backlog`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(hcr,{onIssueAction:E})}),e===`settings`&&(0,z.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,z.jsx)(iLt,{})}),e===`sessions`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(_5n,{initialSessionKey:d})}),e===`god-view`&&(0,z.jsx)(o7,{fallback:(0,z.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:(0,z.jsx)(F7n,{})}),children:(0,z.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:(0,z.jsx)(CQt,{})})}),e===`deacon`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(PQt,{})})]})}var Nlr=2500,Plr=3e3;function Flr(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Ilr({lifecycle:e,onRestartBackend:t,isRestartBackendPending:n}){let r=Dc(),i=Tc(e=>e.lastLiveAt),a=$t(),[o,s]=(0,L.useState)(null),c=(0,L.useRef)(!1);if((0,L.useEffect)(()=>{if(r===`live`){c.current=!0,s(e=>e===null?null:`reconnected`);return}if(r===`delayed`&&!c.current){s(e=>e===null?null:`delayed`);let e=setTimeout(()=>s(`delayed`),Plr);return()=>clearTimeout(e)}s(r)},[r]),(0,L.useEffect)(()=>{if(o!==`reconnected`)return;let e=setTimeout(()=>s(null),Nlr);return()=>clearTimeout(e)},[o]),o===null)return null;let l=()=>{Tc.getState().requestReconnect(),a.refetchQueries({queryKey:[`backend-health`]})},u=i===null?``:Flr(i),d=`shrink-0 rounded-md border px-2.5 py-0.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${o===`unreachable`||o===`unauthorized`?`border-destructive/40 hover:bg-destructive/15`:`border-warning/40 hover:bg-warning/20`}`,f=(0,z.jsx)(`button`,{type:`button`,onClick:l,className:d,children:`Retry`}),p=`bg-warning/10 text-warning-foreground`,m=(0,z.jsx)(zt,{className:`h-3.5 w-3.5 shrink-0 animate-spin`}),h,g=null;switch(o){case`unreachable`:p=`bg-destructive/10 text-destructive`,m=(0,z.jsx)(Ts,{className:`h-3.5 w-3.5 shrink-0`}),h=(0,z.jsxs)(z.Fragment,{children:[`Can't reach the Overdeck server`,u&&` — showing data from ${u}`]}),g=(0,z.jsxs)(z.Fragment,{children:[f,(0,z.jsx)(`button`,{type:`button`,onClick:t,disabled:n,className:d,children:n?`Restarting…`:`Force Restart`})]});break;case`restarting`:h=(0,z.jsxs)(z.Fragment,{children:[`Overdeck server is restarting`,u&&` — showing data from ${u}`,e.issueId&&(0,z.jsxs)(z.Fragment,{children:[` — `,(0,z.jsx)(`span`,{className:`font-mono`,children:e.issueId})]}),e.reason&&(0,z.jsxs)(`span`,{className:`ml-1 opacity-70`,children:[`(`,e.reason,`)`]})]});break;case`delayed`:h=(0,z.jsxs)(z.Fragment,{children:[`Live updates are delayed — reconnecting`,u&&` · showing data from ${u}`]}),g=f;break;case`unauthorized`:p=`bg-destructive/10 text-destructive`,m=(0,z.jsx)(Ts,{className:`h-3.5 w-3.5 shrink-0`}),h=`Dashboard session could not be established (HTTP 401) — see docs/DASHBOARD-AUTH.md`,g=f;break;case`reconnected`:p=`bg-muted/40 text-muted-foreground`,m=(0,z.jsx)(vo,{className:`h-3.5 w-3.5 shrink-0`}),h=`Reconnected`}return(0,z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-component":`degraded-mode-banner`,"data-phase":o===`reconnected`?`live`:o,className:`flex shrink-0 items-center gap-2 border-b border-border px-4 py-1.5 text-xs ${p}`,children:[m,(0,z.jsx)(`p`,{className:`flex-1 truncate`,children:h}),g]})}async function Llr(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`settings fetch failed`);return e.json()}function Rlr({onOpenSettings:e}){let{data:t}=F({queryKey:[`settings`],queryFn:Llr,retry:!1});return t?.background_ai?.cheap_mode===!0?(0,z.jsxs)(`button`,{type:`button`,"data-testid":`low-cost-mode-pill`,onClick:()=>{tp(`background-ai`),e?.()},title:`Background AI (titles, memory, enrichment, narration) is off to save cost. Memory in particular is one of Overdeck's most valuable features — click to choose what runs.`,className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,z.jsx)(Vo,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Low-cost mode`,(0,z.jsx)(go,{className:`h-3.5 w-3.5 text-muted-foreground/70`,"aria-hidden":`true`})]}):null}function zlr(e){GE(e)}function Blr(){let e=Z5e(),[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(null);if((0,L.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),e.length===0)return null;let i=`${e.length} decision${e.length===1?``:`s`} waiting on you — click to view`;return(0,z.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),title:i,"aria-label":i,"aria-expanded":t,"data-testid":`decisions-indicator`,className:`inline-flex h-5 items-center gap-1.5 rounded-sm border px-1.5 text-[10px] font-medium badge-bg-warning badge-border-warning text-warning-foreground tabular-nums`,children:[(0,z.jsx)(cfe,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),e.length]}),t&&(0,z.jsx)(`div`,{className:`absolute top-full right-0 z-[200] mt-2 w-[26rem] max-h-[70vh] overflow-y-auto rounded-xl border border-border bg-popover p-2 text-sm shadow-lg`,children:(0,z.jsx)(Pmt,{onOpenSubject:e=>{zlr(e),n(!1)}})})]})}function Vlr({onActivate:e}){let{data:t}=xp({refetchInterval:3e4}),n=Array.isArray(t?.inFlight)?t.inFlight:[],r=+!!t?.lastTick?.needsYou+n.filter(e=>e.attention===`needs-you`).length;return r===0?null:(0,z.jsx)(`button`,{type:`button`,"aria-label":`${r} thing${r===1?``:`s`} need you`,title:`Show what the flywheel is waiting on you for`,onClick:()=>{eer(),e?.()},children:(0,z.jsxs)(x7,{tone:`warning`,testId:`flywheel-needs-you-indicator`,children:[`Needs you · `,r]})})}async function Hlr(){let e=await fetch(`/api/cloister/status`);if(!e.ok)throw Error(`Failed to fetch Cloister status`);return e.json()}async function Ulr(){if(!(await fetch(`/api/cloister/start`,{method:`POST`})).ok)throw Error(`Failed to start Cloister`)}async function Wlr(){if(!(await fetch(`/api/cloister/stop`,{method:`POST`})).ok)throw Error(`Failed to stop Cloister`)}async function Glr(){let e=await Is(`/api/conversations`);return e.ok?e.json():[]}async function Klr(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`Failed to fetch settings`);return e.json()}async function qlr(){let e=await fetch(`/api/tts/health`);if(!e.ok)throw Error(`Failed to fetch TTS health`);return e.json()}async function Jlr(){let e=await fetch(`/api/agents/restart-with-current-config`);if(!e.ok)throw Error(`Failed to fetch restart config list`);let t=await e.json();return{items:t.items||[],changedAgents:t.changedAgents||0}}function Ylr(e,t){if(t)return`TTS: Health check failed`;if(!e)return`TTS: Checking daemon`;if(!e.ok)return e.error?`TTS: ${e.error}`:`TTS: Daemon offline`;let n=[e.model===void 0?void 0:`model: ${String(e.model)}`,e.queueDepth===void 0?e.queue===void 0?void 0:`queue: ${String(e.queue)}`:`queue: ${String(e.queueDepth)}`,typeof e.pid==`number`?`pid: ${e.pid}`:void 0,e.gpuMemoryUsedMb===void 0?void 0:`VRAM: ${e.gpuMemoryUsedMb}MB`].filter(Boolean);return n.length>0?`TTS: Running (${n.join(`, `)})`:`TTS: Running`}function Xlr({onOpenSettings:e}){let[t,n]=(0,L.useState)(!1),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(!0),[s,c]=(0,L.useState)(!0),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(new Set),h=(0,L.useRef)(null),g=(0,L.useRef)(null),[_,v]=(0,L.useState)(null),y=$t(),{data:b,refetch:x}=F({queryKey:[`cloister-status`],queryFn:Hlr,refetchInterval:1e4}),{data:S}=F({queryKey:[`specialists-raw`],queryFn:async()=>{let e=await fetch(`/api/specialists`);return e.ok?e.json():null},refetchInterval:3e4}),{data:C=[]}=F({queryKey:[`conversations`],queryFn:Glr,refetchInterval:1e4}),{data:w}=F({queryKey:[`settings`],queryFn:Klr,retry:!1}),T=w?.tts?.enabled===!0,{data:E,isError:D}=F({queryKey:[`tts-health`],queryFn:qlr,enabled:T,refetchInterval:1e4,retry:!1}),{data:O}=F({queryKey:[`restart-config-list`],queryFn:Jlr,enabled:d,refetchInterval:5e3}),k=Wt(Jt).filter(e=>e.status===`running`).length,A=C.filter(e=>e.sessionAlive).length,j=(S?.projects??[]).filter(e=>e.isRunning),ee=(0,L.useCallback)(()=>{if(g.current){let e=g.current.getBoundingClientRect();v({left:Math.max(8,Math.min(e.right-256,window.innerWidth-256-8)),top:Math.max(8,Math.min(e.bottom+8,window.innerHeight-8))})}i(!0)},[]);(0,L.useEffect)(()=>{if(!r)return;let e=e=>{h.current&&!h.current.contains(e.target)&&g.current&&!g.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let M=Cn({mutationFn:async({convs:e,doAgents:t})=>{let n=[];e&&n.push(fetch(`/api/conversations/restart-all`,{method:`POST`})),t&&n.push(fetch(`/api/agents/restart-all`,{method:`POST`}));let r=await Promise.all(n);for(let e of r)if(!e.ok)throw Error(`Restart failed: ${e.statusText}`)},onSuccess:()=>{y.invalidateQueries({queryKey:[`conversations`]}),x(),i(!1)}}),N=Cn({mutationFn:async e=>{let t=await fetch(`/api/agents/restart-with-current-config`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentIds:e})});if(!t.ok)throw Error(`Restart failed: ${t.statusText}`);return t.json()},onSuccess:()=>{y.invalidateQueries({queryKey:[`agents`]}),x(),f(!1),m(new Set)}}),P=async()=>{u(!0);try{b?.running?await Wlr():await Ulr(),await x()}finally{u(!1)}},te=async()=>{await D_e()&&n(!1),x()},ne=()=>{(a||s)&&M.mutate({convs:a,doAgents:s})};if(!b)return(0,z.jsx)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:(0,z.jsx)(`button`,{onClick:e,className:`p-1 rounded text-xs bg-popover text-foreground hover:bg-card transition-colors`,title:`Open Settings`,children:(0,z.jsx)(_s,{className:`w-3.5 h-3.5`})})});let re=b.summary.warning>0||b.summary.stuck>0,ie=b.agentsNeedingAttention.length,ae=D?`bg-destructive`:E?.ok?`bg-success`:`bg-muted-foreground`;return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-1`,title:b.running?`Cloister: Running`:`Cloister: Stopped`,children:b.running?(0,z.jsx)(Zde,{className:`w-3.5 h-3.5 text-success`}):(0,z.jsx)(Xde,{className:`w-3.5 h-3.5 text-muted-foreground`})}),b.running&&b.summary.total>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[b.summary.active>0&&(0,z.jsx)(`span`,{className:`text-success`,children:b.summary.active}),b.summary.warning>0&&(0,z.jsx)(`span`,{className:`text-warning`,children:b.summary.warning}),b.summary.stuck>0&&(0,z.jsx)(`span`,{className:`text-destructive`,children:b.summary.stuck})]}),j.length>0&&(0,z.jsxs)(`span`,{className:`flex items-center gap-0.5 text-xs text-success`,title:`Ephemeral: ${j.map(e=>`${e.projectKey.toUpperCase()} ${e.specialistType}`).join(`, `)}`,children:[(0,z.jsx)(ks,{className:`w-3 h-3`}),j.length]}),re&&(0,z.jsx)(`span`,{title:`${ie} agent${ie===1?``:`s`} need attention`,children:(0,z.jsx)(Ts,{className:`w-3.5 h-3.5 text-warning`})}),T&&(0,z.jsxs)(`span`,{"data-testid":`tts-health-badge`,className:`flex items-center gap-1 rounded bg-popover px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,title:Ylr(E,D),children:[(0,z.jsx)(`span`,{"data-testid":`tts-health-dot`,className:`h-1.5 w-1.5 rounded-full ${ae}`}),`TTS`]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{onClick:P,disabled:l,className:`px-2 py-0.5 rounded text-xs transition-colors ${l?`bg-card text-muted-foreground cursor-wait`:b.running?`bg-popover text-foreground hover:bg-card`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:l?`…`:b.running?`Stop Cloister`:`Start Cloister`}),(0,z.jsx)(`button`,{onClick:()=>f(!0),className:`p-1 rounded text-xs bg-popover text-foreground border border-border hover:bg-card transition-colors`,title:`Restart agents with current config`,children:(0,z.jsx)(ks,{className:`w-3.5 h-3.5 ${N.isPending?`animate-spin`:``}`})}),(0,z.jsx)(`button`,{ref:g,onClick:()=>r?i(!1):ee(),"aria-haspopup":`dialog`,"aria-expanded":r,className:`p-1 rounded text-xs bg-popover text-foreground border border-border hover:bg-card transition-colors`,title:`Restart sessions`,children:(0,z.jsx)(zt,{className:`w-3.5 h-3.5 ${M.isPending?`animate-spin`:``}`})}),r&&_&&(0,Ms.createPortal)((0,z.jsxs)(ACe,{ref:h,"aria-label":`Restart sessions`,onClose:()=>i(!1),returnFocusRef:g,className:`fixed z-[1000] w-64 p-0`,style:{left:_.left,top:_.top},children:[(0,z.jsx)(`div`,{className:`border-b border-border px-3 py-2 text-xs font-medium text-foreground`,children:`Restart Sessions`}),(0,z.jsxs)(`div`,{className:`p-2 space-y-1`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`accent-primary`}),(0,z.jsx)(`span`,{children:`Conversations`}),(0,z.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[`(`,A,` active)`]})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),className:`accent-primary`}),(0,z.jsx)(`span`,{children:`Workspace Agents`}),(0,z.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[`(`,k,` active)`]})]})]}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-1.5 px-3 py-2 border-t border-border`,children:[(0,z.jsx)(`button`,{onClick:()=>i(!1),className:`px-2 py-1 rounded text-xs text-foreground bg-muted hover:bg-accent`,children:`Cancel`}),(0,z.jsx)(`button`,{onClick:ne,disabled:M.isPending||!a&&!s,className:`px-2 py-1 rounded text-xs text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:M.isPending?`Restarting...`:`Restart`})]}),M.isError&&(0,z.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive border-t border-border`,children:M.error.message})]}),document.body),d&&(0,Ms.createPortal)((0,z.jsx)(`div`,{className:`fixed inset-0 bg-black/50 z-50 flex items-center justify-center`,children:(0,z.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-lg max-w-2xl max-h-96 overflow-auto w-96`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-3 border-b border-border flex justify-between items-center`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Restart Agents with Current Config`}),(0,z.jsx)(`button`,{onClick:()=>f(!1),className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]}),(0,z.jsx)(`div`,{className:`p-4 space-y-3 max-h-64 overflow-y-auto`,children:O?.items.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No eligible agents to restart.`}):O?.items.map(e=>(0,z.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p.has(e.agentId),onChange:t=>{let n=new Set(p);t.target.checked?n.add(e.agentId):n.delete(e.agentId),m(n)},disabled:e.paused,className:`accent-primary mt-0.5`}),(0,z.jsxs)(`div`,{className:`flex-1`,children:[(0,z.jsx)(`div`,{className:`font-medium text-foreground`,children:e.issueId}),(0,z.jsxs)(`div`,{className:`text-[10px] text-muted-foreground space-y-0.5`,children:[(0,z.jsxs)(`div`,{children:[`Current: `,e.currentModel,` / `,e.currentHarness]}),e.changed&&(0,z.jsxs)(`div`,{className:`text-warning`,children:[`→ New: `,e.newModel,` / `,e.newHarness]}),!e.changed&&(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`No change needed`}),e.paused&&(0,z.jsx)(`div`,{className:`text-destructive`,children:`Paused — cannot restart`})]})]})]},e.agentId))}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-1.5 px-4 py-3 border-t border-border`,children:[(0,z.jsx)(`button`,{onClick:()=>f(!1),className:`px-2 py-1 rounded text-xs text-foreground bg-muted hover:bg-accent`,children:`Cancel`}),(0,z.jsx)(`button`,{onClick:()=>N.mutate(Array.from(p)),disabled:N.isPending||p.size===0,className:`px-2 py-1 rounded text-xs text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:N.isPending?`Restarting...`:`Restart (${p.size})`})]}),N.isError&&(0,z.jsx)(`div`,{className:`px-4 py-2 text-xs text-destructive border-t border-border`,children:N.error.message})]})}),document.body),t?(0,z.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-0.5 badge-bg-destructive rounded border badge-border-destructive`,children:[(0,z.jsx)(`span`,{className:`text-xs text-destructive`,children:`Kill all?`}),(0,z.jsx)(`button`,{onClick:te,className:`px-1.5 py-0.5 rounded text-xs bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Yes`}),(0,z.jsx)(`button`,{onClick:()=>n(!1),className:`px-1.5 py-0.5 rounded text-xs bg-popover text-foreground hover:bg-card`,children:`No`})]}):(0,z.jsx)(`button`,{onClick:()=>n(!0),className:`p-1 rounded text-xs badge-bg-destructive text-destructive border badge-border-destructive hover:bg-destructive/20 transition-colors`,title:`Emergency stop — kill all agents (hotkey: ${C_e})`,children:(0,z.jsx)(bo,{className:`w-3.5 h-3.5`})}),(0,z.jsx)(`button`,{onClick:e,className:`p-1 rounded text-xs bg-popover text-foreground hover:bg-card transition-colors`,title:`Open Settings`,children:(0,z.jsx)(_s,{className:`w-3.5 h-3.5`})})]})]})}function Zlr({onOpenSettings:e}){let[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`button`,{ref:r,type:`button`,"aria-label":`System controls`,"aria-haspopup":`dialog`,"aria-expanded":t,title:`System controls — Cloister, restart, emergency stop, settings`,onClick:()=>n(e=>!e),className:`rounded-md p-1.5 transition-colors focus:outline-none focus:ring-2 focus:ring-ring ${t?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:(0,z.jsx)(Tpe,{className:`h-4 w-4`,"aria-hidden":`true`})}),t&&(0,z.jsx)(ACe,{"aria-label":`System controls`,onClose:()=>n(!1),returnFocusRef:r,className:`absolute right-0 top-full z-[1000] mt-1 p-2`,children:(0,z.jsx)(Xlr,{onOpenSettings:e})})]})}var Qlr=new Set([`running`,`active`,`starting`,`thinking`,`working`]),$lr=new Set([`flywheel`,`sequencer`,`knowledge`]);function eur(e){return Qlr.has(e)}function tur(e){return e.pausedReason?`paused: ${e.pausedReason}`:e.paused?`paused`:e.stoppedByUser?`stopped by operator`:`stopped cleanly`}function nur(e){window.location.pathname!==e&&window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function rur(e){nur(`/issues/${encodeURIComponent(e)}`)}function iur(e,t){let n=Date.parse(e);if(!Number.isFinite(n))return`—`;let r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function aur({agent:e,title:t,contextLine:n,onNavigate:r}){let i=e.issueId??e.id;return(0,z.jsxs)(`button`,{type:`button`,className:`block w-full rounded-lg px-2 py-1.5 text-left transition-colors hover:bg-accent`,onClick:()=>{e.issueId&&!$lr.has(e.role??``)?rur(e.issueId):nur(`/agents`),r?.()},children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-foreground`,children:i}),t&&(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,title:t,children:t}),e.role&&(0,z.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-foreground`,children:e.role})]}),(0,z.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-muted-foreground`,children:n})]})}var our=new Set([`plan`,`review`,`test`,`uat`]),sur=new Set([`merged`,`closed`]);function cur({variant:e=`banner`}={}){let t=Wt(Jt),n=Wt(Lt),r=Wt(e=>e.backendPanesById),i=Wt(e=>e.derivedIssueStateByIssueId),a=new Map;for(let e of n){let t=typeof e.identifier==`string`?e.identifier.toUpperCase():null,n=typeof e.title==`string`?e.title:null;t&&n&&a.set(t,n)}let o=(0,L.useRef)(new Set);(0,L.useEffect)(()=>{let e=new Set(t.filter(e=>e.resolution===`api_error`).map(e=>e.id));for(let n of e)if(!o.current.has(n)){let e=t.find(e=>e.id===n)?.issueId||n;B.warning(`${e}: API error — auto-retry nudge sent`,{duration:8e3})}o.current=e},[t]);let s=(0,L.useMemo)(()=>{let e=e=>t.find(t=>t.id===e.id||t.id===e.terminalId)??t.find(t=>t.issueId?.toUpperCase()===e.issue?.toUpperCase()&&t.role===e.role),n=new Map;for(let t of Object.values(r)){if(t.state!==`exited`||!t.issue)continue;let r=i[t.issue]?.state;if(our.has(t.role)&&r&&sur.has(r))continue;let a=e(t);a&&(n.has(t.issue)||n.set(t.issue,a))}return Array.from(n.values())},[t,r,i]),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(!1),g=(0,L.useRef)(null);(0,L.useEffect)(()=>{if(!m)return;let e=e=>{g.current?.contains(e.target)||h(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[m]);let _=(0,L.useCallback)(async()=>{if(u)return;d(!0),p(null);let e=[],t=!1;for(let n of s)if(n.issueId)try{let r={issueId:n.issueId},i=r,a=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),o=await a.json().catch(()=>({}));if(a.status===409&&o.requiresAcknowledgement){if(!window.confirm((o.guardrails?.warnings??[]).map(e=>`• ${e.message}`).join(`
1605
- `))){e.push({issueId:n.issueId,success:!1,error:`Agent start canceled`});continue}i={...r,guardrailAcknowledged:!0},a=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),o=await a.json().catch(()=>({}))}if(a.ok)o.guardrails?.warnings?.length&&B.success(`${n.issueId}: started after acknowledging system health warnings`,{duration:8e3}),e.push({issueId:n.issueId,success:!0});else{if(mht(a,o)){lht(i),e.push({issueId:n.issueId,success:!1,error:o.hint||o.error||`Codex authentication expired — re-authenticate to continue`});continue}let r=a.status===409?X_(o):null;if(r){t||=(J_.getState().openRecovery({...r,issueId:n.issueId}),!0),e.push({issueId:n.issueId,success:!1,error:`Needs your choice — Resume or Start fresh`});continue}e.push({issueId:n.issueId,success:!1,error:o.error||o.hint||a.statusText})}}catch(t){e.push({issueId:n.issueId,success:!1,error:t instanceof Error?t.message:String(t)})}p(e),d(!1)},[u,s]),v=(0,L.useCallback)(()=>{l(!0)},[]),y=(0,L.useCallback)(()=>{p(null),l(!1)},[]),b=f?.filter(e=>e.success).length??0,x=f?.filter(e=>!e.success).length??0;if(e===`pill`)return s.length===0?null:(0,z.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-expanded":m,className:`inline-flex items-center gap-1.5 rounded-full border border-warning/40 bg-warning/10 px-2.5 py-1 text-xs font-medium text-warning-foreground transition-colors hover:bg-warning/20`,"data-testid":`stopped-agents-pill`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`}),s.length,` stopped`]}),m&&(0,z.jsxs)(`div`,{"data-testid":`stopped-agents-popover`,className:`absolute right-0 top-full z-50 mt-1.5 w-80 rounded-lg border border-border bg-card p-3 shadow-xl`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs font-semibold text-warning-foreground`,children:[(0,z.jsx)(Ts,{className:`h-3.5 w-3.5`}),s.length,` stopped · panes the backend reports exited`]}),(0,z.jsx)(`div`,{className:`mb-3 max-h-64 overflow-y-auto`,children:s.map(e=>{let t=e.lastActivity?Date.parse(e.lastActivity):0,n=e.startedAt?Date.parse(e.startedAt):0,r=new Date(Math.max(t,n)).toISOString();return(0,z.jsx)(aur,{agent:e,title:e.issueId?a.get(e.issueId.toUpperCase()):void 0,contextLine:`${tur(e)} · ${iur(r,Date.now())}`,onNavigate:()=>h(!1)},e.id)})}),f&&(0,z.jsxs)(`div`,{className:`mb-2 text-xs`,children:[b>0&&(0,z.jsxs)(`span`,{className:`text-success`,children:[`✓ `,b,` restarted`]}),x>0&&(0,z.jsxs)(`span`,{className:`ml-2 text-destructive`,children:[`✕ `,x,` failed`]})]}),(0,z.jsxs)(`button`,{onClick:_,disabled:u,className:`flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-2 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,"data-testid":`pill-restart-all`,children:[u?(0,z.jsx)(is,{className:`h-3 w-3 animate-spin`}):(0,z.jsx)(ds,{className:`h-3 w-3`}),u?`Restarting…`:`Restart all`]})]})]});if(c||s.length===0)return c&&s.length>0?(0,z.jsxs)(`div`,{className:`bg-card/40 border-b border-border px-4 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s.length,` agent`,s.length>1?`s`:``,` stopped`]}),(0,z.jsx)(`button`,{onClick:y,className:`text-xs text-primary hover:text-primary/80 underline`,children:`Show`})]}):null;let S=f?.filter(e=>e.success).length??0,C=f?.filter(e=>!e.success).length??0;return(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b border-warning/30 px-3 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,z.jsx)(Ts,{className:`w-3.5 h-3.5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`span`,{className:`text-warning-foreground text-xs font-semibold`,children:[s.length,` stopped`]}),(0,z.jsxs)(`span`,{className:`text-warning-foreground/70 text-xs truncate`,children:[s.map(e=>e.issueId||e.id).join(`, `),s.some(e=>e.lastActivity)&&(0,z.jsxs)(`span`,{className:`ml-1`,children:[`(`,Math.max(...s.map(e=>e.lastActivity?Date.now()-new Date(e.lastActivity).getTime():0))/6e4|0,`m ago)`]})]}),f&&(0,z.jsxs)(`span`,{className:`text-xs ml-1`,children:[S>0&&(0,z.jsxs)(`span`,{className:`text-success inline-flex items-center gap-0.5`,children:[(0,z.jsx)(_o,{className:`w-3 h-3`}),` `,S]}),C>0&&(0,z.jsxs)(`span`,{className:`text-destructive inline-flex items-center gap-0.5 ml-1`,children:[(0,z.jsx)(Os,{className:`w-3 h-3`}),` `,C]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 ml-auto`,children:[(0,z.jsxs)(`button`,{onClick:_,disabled:u,className:`flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,"data-testid":`banner-restart-all`,children:[u?(0,z.jsx)(is,{className:`w-3 h-3 animate-spin`}):(0,z.jsx)(ds,{className:`w-3 h-3`}),u?`Restarting...`:`Restart All`]}),(0,z.jsx)(`button`,{onClick:v,disabled:u,className:`text-warning-foreground/60 hover:text-warning-foreground shrink-0 disabled:opacity-50`,title:`Dismiss`,"data-testid":`banner-dismiss`,children:(0,z.jsx)(Os,{className:`w-3.5 h-3.5`})})]})]})}function lur(){let e=Wt(Jt),t=Wt(Lt),[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(null),a=(0,L.useMemo)(()=>e.filter(e=>eur(e.status)).sort((e,t)=>{let n=Date.parse(e.lastActivity??e.startedAt);return Date.parse(t.lastActivity??t.startedAt)-n}),[e]),o=(0,L.useMemo)(()=>new Map(t.map(e=>[e.identifier.toUpperCase(),e.title])),[t]);return(0,L.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),a.length===0?null:(0,z.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-label":`${a.length} running agent${a.length===1?``:`s`} — click to view`,"data-testid":`running-agents-pill`,className:`inline-flex items-center gap-1.5 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2.5 py-1 text-xs text-emerald-600 transition-colors hover:bg-emerald-500/20 dark:text-emerald-400`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`}),a.length,` agent`,a.length===1?``:`s`]}),n&&(0,z.jsxs)(`div`,{"data-testid":`running-agents-popover`,className:`absolute right-0 top-full z-50 mt-1.5 w-80 rounded-lg border border-border bg-card p-3 shadow-xl`,children:[(0,z.jsxs)(`div`,{className:`mb-2 text-xs font-semibold text-foreground`,children:[a.length,` running now`]}),(0,z.jsx)(`div`,{className:`max-h-64 overflow-y-auto`,children:a.map(e=>{let t=e.lastActivity??e.startedAt;return(0,z.jsx)(aur,{agent:e,title:e.issueId?o.get(e.issueId.toUpperCase()):void 0,contextLine:`${e.model} · ${iur(t,Date.now())}`,onNavigate:()=>r(!1)},e.id)})})]})]})}function uur(){let{data:e}=iht(),[t,n]=(0,L.useState)(!1);return!e||e.status!==`expired`&&e.status!==`burned`?null:(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:[`Codex authentication `,e.status,` — Codex-routed agents (gpt-5.x, o3, o4-mini) will fail.`,e.email&&(0,z.jsxs)(`span`,{className:`font-normal ml-1 opacity-80`,children:[`(`,(0,z.jsx)(bNt,{value:e.email,className:`text-sm`}),`)`]}),e.affectedAgents&&e.affectedAgents.length>0&&(0,z.jsxs)(`span`,{className:`font-normal ml-1 opacity-80`,children:[`— `,e.affectedAgents.length,` agent`,e.affectedAgents.length===1?``:`s`,` wedged on a revoked token`]})]}),(0,z.jsx)(`button`,{onClick:async()=>{n(!0);try{let e=await fetch(`/api/settings/codex-reauth`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to spawn re-auth session (${e.status})`)}let{sessionName:t,statusToken:n}=await e.json();uht(t,n),B.success(`Re-authentication session started — opening terminal…`),yNt(t,`Codex re-authentication`)}catch(e){B.error(e instanceof Error?e.message:`Failed to start re-authentication`)}finally{n(!1)}},disabled:t,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0 flex items-center gap-1.5`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(is,{className:`w-3.5 h-3.5 animate-spin`}),`Starting…`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Mo,{className:`w-3.5 h-3.5`}),`Re-authenticate`]})})]})}async function dur(){let e=await fetch(`/api/settings/conversation-search/status`);if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`Failed to fetch conversation search status (${e.status}): ${t}`)}return e.json()}function fur(){return F({queryKey:[`conversation-search-status`],queryFn:dur,refetchInterval:6e4,staleTime:3e4})}function pur(){let{data:e}=fur();if(!e?.enabled)return null;let t=e.health,n=t?.lastErrorAt!=null&&(t.lastSuccessAt==null||t.lastErrorAt>t.lastSuccessAt),r=t?.watcher?.state,i=r===`restarting`||r===`failed`;if(e.available&&!n&&!i)return null;let a=e.available&&!n,o=a&&r===`failed`,s=t?.watcher?.lastErrorReason??`unknown error`,c=e.available?o?`transcript watcher stopped after repeated failures (${s})`:a?`transcript watcher failed (${s}), restarting`:t?.lastErrorReason??`recent embedding failures`:e.unavailableReason??`embedding provider unavailable`,l=/credit|billing|quota|insufficient/i.test(c);return(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1 min-w-0 [&_span]:break-words`,children:[`Conversation search is not working: `,(0,z.jsx)(`span`,{className:`font-normal`,children:c}),(0,z.jsx)(`span`,{className:`font-normal ml-1 opacity-80`,children:o?`— new transcripts are not indexed. Restart the dashboard or save the conversation-search settings to retry.`:a?`— new transcripts are not indexed until the watcher is back.`:`— Ctrl+K conversation hits and transcript indexing are unavailable until this is fixed.`})]}),l&&(0,z.jsxs)(`a`,{href:`https://platform.openai.com/settings/organization/billing/`,target:`_blank`,rel:`noreferrer`,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors shrink-0 flex items-center gap-1.5`,children:[(0,z.jsx)(Mo,{className:`w-3.5 h-3.5`}),`OpenAI billing`]})]})}var mur=`echo 'fs.inotify.max_user_watches = 2097152' | sudo tee /etc/sysctl.d/99-inotify.conf && sudo sysctl --system`;function hur(){let{data:e}=twt(),t=e?.host.reasons.find(e=>e.code.startsWith(`host.linux.inotify_watches.`));if(!e||!t)return null;let n=t.code===`host.linux.inotify_watches.critical`,r=e.host.metrics.inotifyWatchesUsed,i=e.host.metrics.inotifyWatchesMax,a=r!=null&&i!=null?`${r.toLocaleString()} of ${i.toLocaleString()} file watchers in use`:`file-watcher usage is near the limit`,o=t.observed==null?``:` (${Math.round(t.observed)}%)`;return(0,z.jsxs)(`div`,{className:`${n?`bg-destructive/10`:`bg-warning/10`} flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`inotify-pressure-banner`,children:[(0,z.jsx)(Ts,{className:`w-3.5 h-3.5 shrink-0 ${n?`text-destructive`:`text-warning-foreground`}`}),(0,z.jsxs)(`p`,{className:`flex-1 truncate text-xs ${n?`text-destructive`:`text-warning-foreground`}`,title:`inotify watches are a per-user kernel budget shared by every process and container on this host. When it is exhausted, new file-watching dev servers fail to start with ENOSPC. ${a}${o}. Raise and persist the limit with: ${mur}`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:n?`File watchers exhausted`:`File watchers running low`}),` — `,a,o,`; new dev servers `,n?`will`:`may`,` fail with ENOSPC`]}),(0,z.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(mur),B.success(`Fix command copied — run it in a terminal to raise and persist the limit`)}catch{B.error(`Copy failed — run: ${mur}`)}},className:`h-[26px] shrink-0 rounded-sm px-[10px] text-[11px] font-medium ${n?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-warning/20 text-warning-foreground hover:bg-warning/30`}`,children:`Copy fix`})]})}async function gur(){let e=await fetch(`/api/linear-mcp-auth`);if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`Failed to fetch Linear MCP auth status (${e.status}): ${t}`)}return e.json()}function _ur(e={}){return F({queryKey:[`linear-mcp-auth`],queryFn:gur,refetchInterval:t=>e.fast?1e3:t.state.data?.status===`none`?3e4:5e3})}function vur(e){let t=e.toLowerCase();return t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||t===`[::1]`||/^127(\.\d{1,3}){3}$/.test(t)}var yur=9e4,bur=6e4,xur=`No fresh Linear link yet — open a blocked conversation to check on it.`,Sur=`Linear still isn't connected. Finish approving in the Linear tab, then click Check now.`;async function Cur(e){let t=await fetch(e,{method:`POST`}),n=await t.json().catch(()=>({}));return{ok:t.ok,status:t.status,body:n}}function wur(e,t){return typeof e.error==`string`&&e.error!==``?e.error:t}function Tur(){let[e,t]=(0,L.useState)(`idle`),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(null),{data:o}=_ur({fast:e!==`idle`}),s=(0,L.useRef)(null),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(!1),d=(0,L.useRef)(0),f=(0,L.useCallback)(e=>{let n=s.current;n?(n.opener=null,n.location.href=e):r(e),l.current=Date.now(),u.current=!1,t(`awaiting-approval`)},[]),p=(0,L.useCallback)(e=>{s.current?.close(),s.current=null,B.error(e),t(`idle`)},[]),m=(0,L.useCallback)(()=>{e===`idle`&&(s.current=window.open(`about:blank`,`_blank`),r(null),a(null),t(`opening`),(async()=>{try{let{ok:e,status:n,body:r}=await Cur(`/api/linear-mcp-auth/connect`);e&&n===200&&r.action===`open`&&typeof r.authUrl==`string`?f(r.authUrl):e&&r.action===`refreshing`?(c.current=typeof r.previousAuthUrl==`string`?r.previousAuthUrl:null,t(`refreshing`)):p(wur(r,`Failed to connect Linear (${n})`))}catch(e){p(e instanceof Error?e.message:`Failed to connect Linear`)}})())},[e,f,p]),h=(0,L.useCallback)(()=>{a(null),t(`checking`),(async()=>{try{let{ok:e,status:n,body:r}=await Cur(`/api/linear-mcp-auth/verify`);e||(B.error(wur(r,`Failed to check Linear access (${n})`)),t(`awaiting-approval`))}catch(e){B.error(e instanceof Error?e.message:`Failed to check Linear access`),t(`awaiting-approval`)}})()},[]);return(0,L.useEffect)(()=>{if(!o)return;if(o.status!==`none`){d.current=o.blockedAgents?.length??0;return}if(e===`idle`)return;let n=d.current;B.success(`Linear connected — ${n} agent${n===1?``:`s`} resumed`),s.current=null,r(null),a(null),t(`idle`)},[o,e]),(0,L.useEffect)(()=>{e===`refreshing`&&o&&o.status===`active`&&o.authUrl!==null&&o.authUrl!==c.current&&f(o.authUrl)},[e,o,f]),(0,L.useEffect)(()=>{if(e!==`refreshing`)return;let t=setTimeout(()=>p(xur),yur);return()=>clearTimeout(t)},[e,p]),(0,L.useEffect)(()=>{if(e!==`checking`)return;let n=setTimeout(()=>{a(Sur),t(`awaiting-approval`)},bur);return()=>clearTimeout(n)},[e]),(0,L.useEffect)(()=>{if(e!==`awaiting-approval`||!vur(window.location.hostname))return;let t=()=>{if(u.current||document.visibilityState!==`visible`)return;let e=l.current;e===null||Date.now()-e<2e3||(u.current=!0,h())};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,t)}},[e,h]),{intervention:o,phase:e,fallbackUrl:n,notice:i,connect:m,checkNow:h}}function Eur(e){return{label:e.conversationTitle??e.issueId??e.agentId,href:e.conversationUrl??(e.issueId?`/issues/${e.issueId}`:null)}}function Dur(){let e=Tur(),t=e.intervention,[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1);if(!t||t.status===`none`)return null;let c=t.blockedAgents??[],l=async()=>{a(!0);try{let e=await fetch(`/api/linear-mcp-auth/callback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({callbackUrl:n})}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Failed to relay callback URL (${e.status})`);B.success(`Callback URL relayed to ${t.relayedTo??`the blocked agent`} — it will finish the OAuth flow.`),r(``)}catch(e){B.error(e instanceof Error?e.message:`Failed to relay callback URL`)}finally{a(!1)}},u=async()=>{s(!0);try{let e=await fetch(`/api/linear-mcp-auth/complete`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to mark Linear auth completed (${e.status})`)}B.success(`Marked Linear authentication healthy — blocked agents are being woken to re-check.`)}catch(e){B.error(e instanceof Error?e.message:`Failed to mark Linear auth completed`)}finally{s(!1)}},d=`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0 flex items-center gap-1.5`;return(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex flex-col gap-2 shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:[`Linear authentication required — `,c.length,` agent`,c.length===1?``:`s`,` blocked on Linear MCP OAuth.`]}),e.fallbackUrl?(0,z.jsxs)(`a`,{href:e.fallbackUrl,target:`_blank`,rel:`noreferrer`,className:d,children:[(0,z.jsx)(Mo,{className:`w-3.5 h-3.5`}),`Open Linear authorization`]}):(0,z.jsxs)(`button`,{onClick:e.connect,disabled:e.phase!==`idle`,className:d,children:[(0,z.jsx)(Rfe,{className:`w-3.5 h-3.5`}),`Connect Linear`]})]}),(0,z.jsx)(Our,{phase:e.phase,expired:t.status===`expired`,notice:e.notice,onCheckNow:e.checkNow}),c.length>0&&(0,z.jsx)(`ul`,{className:`text-warning-foreground text-sm pl-8 flex flex-col gap-0.5`,children:c.map(e=>{let{label:t,href:n}=Eur(e),r=e.issueUrl??(e.issueId?kp(e.issueId):null);return(0,z.jsxs)(`li`,{children:[n?(0,z.jsx)(`a`,{href:n,title:e.agentId,className:`font-semibold underline hover:opacity-80`,children:t}):(0,z.jsx)(`span`,{className:`font-semibold`,title:e.agentId,children:t}),e.issueId&&r&&(0,z.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,"aria-label":`Open ${e.issueId} in tracker`,className:`inline-flex align-middle ml-1 hover:opacity-80`,children:(0,z.jsx)(Mo,{className:`w-3.5 h-3.5`})}),e.notifiedAt&&(0,z.jsx)(`span`,{className:`opacity-80`,children:` (woken, re-checking)`})]},e.agentId)})}),(0,z.jsxs)(`details`,{open:!vur(window.location.hostname),className:`pl-8 text-warning-foreground text-sm`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer opacity-80 hover:opacity-100`,children:`Signed in from a different device? Paste the callback URL`}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Paste the localhost callback URL here`,className:`flex-1 max-w-xl px-2 py-1.5 text-sm rounded-md bg-background border border-warning/40 text-foreground placeholder:text-muted-foreground`}),(0,z.jsx)(`button`,{onClick:l,disabled:i||n.trim()===``,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0`,children:i?`Relaying…`:`Submit callback URL`})]}),(0,z.jsxs)(`p`,{className:`text-xs opacity-80`,children:[`After authorizing in your browser, Linear redirects to a localhost URL. On a remote session the callback page fails to load — copy the URL from the address bar and paste it above; it is relayed to the blocked agent to finish the flow. If you authorized another way (e.g. `,(0,z.jsx)(`code`,{children:`claude mcp login linear`}),`), use Mark completed: blocked agents will be woken to re-check Linear access, and this banner returns if authentication is still broken.`]}),(0,z.jsx)(`div`,{children:(0,z.jsx)(`button`,{onClick:u,disabled:o,className:d,children:o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(is,{className:`w-3.5 h-3.5 animate-spin`}),`Marking…`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(vo,{className:`w-3.5 h-3.5`}),`Already authorized another way? Mark completed`]})})})]})]})]})}function Our({phase:e,expired:t,notice:n,onCheckNow:r}){let i=null;return e===`opening`?i=`Opening Linear…`:e===`refreshing`?i=`Getting a fresh link…`:e===`awaiting-approval`?i=`Approve access in the Linear tab, then come back here.`:e===`checking`?i=`Checking Linear access…`:t&&(i=`The last authorization link expired — Connect Linear gets a fresh one.`),i===null&&n===null?null:(0,z.jsxs)(`div`,{className:`text-warning-foreground text-sm pl-8 flex flex-col gap-1`,children:[i!==null&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(e===`opening`||e===`refreshing`||e===`checking`)&&(0,z.jsx)(is,{className:`w-3.5 h-3.5 animate-spin`}),(0,z.jsx)(`span`,{className:`opacity-80`,children:i}),e===`awaiting-approval`&&(0,z.jsx)(`button`,{onClick:r,className:`underline font-semibold hover:opacity-80`,children:`Check now`})]}),n!==null&&(0,z.jsx)(`p`,{className:`opacity-80`,children:n})]})}var kur=8e3,Aur={waiting:{strip:`bg-warning/10`,text:`text-warning-foreground`},working:{strip:`bg-info/10`,text:`text-info-foreground`},settled:{strip:`bg-muted/40`,text:`text-muted-foreground`}};function U9({tone:e,icon:t,title:n,children:r,action:i}){let a=Aur[e];return(0,z.jsxs)(`div`,{className:`${a.strip} flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`restart-approval-banner`,children:[(0,z.jsx)(t,{className:`w-3.5 h-3.5 ${a.text} shrink-0`}),(0,z.jsx)(`p`,{className:`flex-1 truncate text-xs ${a.text}`,title:n,children:r}),i]})}function jur(){let e=Wt(D),t=e?.lastOutcome?.type===`pruned-unclaimed`?e.lastOutcome.at:null,[n,r]=(0,L.useState)(!1);(0,L.useEffect)(()=>{if(!t)return;let e=kur-(Date.now()-Date.parse(t));if(e<=0){r(!0);return}r(!1);let n=setTimeout(()=>r(!0),e);return()=>clearTimeout(n)},[t]);let i=Cn({mutationFn:async()=>{let e=await fetch(`/api/restart-gate/approve`,{method:`POST`,headers:await Ac()}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Failed to approve the restart`);return t},onSuccess:e=>{let t=e.pendingCount??0;B.success(t>0?`Restart approved — ${t} waiting request${t===1?``:`s`} will be satisfied by one restart`:`Nothing left to restart for — every waiting request had already given up`)},onError:e=>B.error(e instanceof Error?e.message:`Failed to approve the restart`)});if(!e)return null;let a=e.pending.length,o=e.pending.map(e=>e.reason||e.kind).join(`; `);if(e.status===`pending`&&a>0){let e=`${a} process${a===1?``:`es`} asked to restart the dashboard and ${a===1?`is`:`are`} waiting for you. Nothing restarts until you approve, and one approval covers every request listed here — they are satisfied by a single restart. Approve here, or run \`pan restart approve\` in a terminal. Waiting: ${o}`;return(0,z.jsxs)(U9,{tone:`waiting`,icon:sfe,title:e,action:(0,z.jsx)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:i.isPending,className:`h-[26px] shrink-0 rounded-sm bg-warning/20 px-[10px] text-[11px] font-medium text-warning-foreground hover:bg-warning/30 disabled:opacity-50`,children:i.isPending?`Approving…`:`Restart now`}),children:[(0,z.jsx)(`span`,{className:`font-medium`,children:a===1?`A dashboard restart is waiting for your approval`:`${a} dashboard restarts are waiting for your approval`}),` — `,o]})}if(e.status===`approved`){let t=e.pending.map(e=>e.requesterId).join(`, `)||`the requester`;return(0,z.jsxs)(U9,{tone:`working`,icon:dpe,title:`The restart is approved. ${t} performs it on the next poll — nothing else is waiting on you.`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Approved`}),` — waiting for `,t,` to restart…`]})}return e.status===`claimed`?(0,z.jsxs)(U9,{tone:`working`,icon:dpe,title:`A requester is restarting the dashboard now. This page loses its connection for a moment and reconnects on its own.`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Restarting…`}),` — the dashboard reconnects on its own in a moment`]}):t&&!n?(0,z.jsx)(U9,{tone:`settled`,icon:Qo,title:`Every process waiting on that approval had already exited, so the approval had nothing left to restart. Restart again from a terminal if you still want one.`,children:`The requester(s) went away without restarting — nothing was restarted.`}):null}function Mur(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Nur(e){let t=null;for(let n of e)(!t||Date.parse(n.until)>Date.parse(t.until))&&(t=n);return t}function Pur(e,t){let n=t.pool===`pat`?`the GITHUB_TOKEN personal access token`:t.pool===`app`?`the GitHub App`:e.login??`your account`,r=Mur(t.until);if(t.kind===`secondary`)return`GitHub secondary rate limit for ${n}: calls paused until ${r}. Overdeck sent requests too fast; pollers resume automatically.`;let i=e.samples.find(e=>e.pool===t.pool&&e.bucket===t.bucket),a=i?` GitHub reports ${i.limit-i.remaining} of ${i.limit} points used this hour.`:``,o=e=>e[t.bucket].points,s=e.callers.reduce((e,t)=>e+o(t),0);if(e.ownUsageLow&&t.pool===`user`)return`GitHub rate limit for ${n}: ${i?`calls paused until ${r}.${a} Not caused by this machine`:`calls paused until ${r}; not caused by this machine`} (this machine used ${s} points in the last hour). Another tool or Overdeck install using this account is spending the shared limit.`;let c=[...e.callers].sort((e,t)=>o(t)-o(e))[0];return c&&o(c)>0?`GitHub rate limit for ${n}: calls paused until ${r}.${a} This machine used ${s} points in the last hour; top caller: ${c.caller} (${o(c)} points).`:`GitHub rate limit for ${n}: calls paused until ${r}.`}function Fur(){let e=Wt(Gee),t=e?Nur(e.pauses):null;if(!e||!t)return null;let n=Pur(e,t);return(0,z.jsxs)(`div`,{className:`bg-warning/10 flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`github-rate-limit-banner`,children:[(0,z.jsx)(sfe,{className:`w-3.5 h-3.5 text-warning-foreground shrink-0`}),(0,z.jsx)(`p`,{className:`flex-1 truncate text-xs text-warning-foreground`,title:n,children:n})]})}var Iur=`github-quota-popover`,Lur=`github-quota-popover-title`,Rur=5;function W9(e){return e.graphql.points+e.rest.points}function zur(e){return[...e.callers].filter(e=>W9(e)>0).sort((e,t)=>W9(t)-W9(e)).slice(0,Rur)}function Bur(){let e=Wt(Gee),[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(null),i=(0,L.useRef)(null),a=(0,L.useCallback)(()=>{n(!1),requestAnimationFrame(()=>i.current?.focus())},[]);if((0,L.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&a()},n=e=>{e.key===`Escape`&&a()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,n)}},[a,t]),!e)return null;let o=e.samples.find(e=>e.pool===`user`&&e.bucket===`graphql`),s=o?`GH ${o.remaining}/${o.limit}`:`GH —`,c=e.pauses.length>0?`border-warning/40 bg-warning/10 text-warning-foreground`:`border-border text-muted-foreground`,l=zur(e),u=o?`GitHub GraphQL quota${e.login?` for ${e.login}`:``}: ${o.remaining} of ${o.limit} points left this hour`:`GitHub GraphQL quota: no sample yet`;return(0,z.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,z.jsx)(`button`,{ref:i,type:`button`,onClick:()=>n(e=>!e),className:`flex items-center rounded-md border px-2 py-1.5 font-mono text-xs tabular-nums transition-colors hover:bg-accent ${c}`,"data-testid":`github-quota-pill`,title:u,"aria-label":u,"aria-expanded":t,"aria-controls":Iur,"aria-haspopup":`dialog`,children:s}),t&&(0,z.jsxs)(`div`,{id:Iur,role:`dialog`,"aria-labelledby":Lur,className:`absolute right-0 top-full z-[200] mt-2 w-[min(20rem,calc(100vw-1rem))] rounded-xl border border-border bg-popover p-3 text-sm shadow-lg`,children:[(0,z.jsx)(`p`,{id:Lur,className:`mb-2 font-medium text-foreground`,children:`GitHub calls, last hour`}),l.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No metered GitHub calls this hour.`}):(0,z.jsx)(`ul`,{className:`space-y-1`,"data-testid":`github-quota-callers`,children:l.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.caller}),(0,z.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[W9(e),` pts`,e.estimated?` (est.)`:``]})]},e.caller))}),(0,z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3 border-t border-border pt-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Unattributed (other tools and installs)`}),(0,z.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[e.unattributed,` pts`]})]})]})]})}var Vur=5e3,Hur=6e5,Uur=6e5;function Wur(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}function Gur(e){if(!e.found||!e.outdated)return null;let t=e.requirements.filter(e=>e.satisfied===!1);if(t.length===0)return null;let n=t.reduce((e,t)=>Wur(t.minVersion,e.minVersion)>0?t:e),r=`Claude Code ${e.version} is older than ${n.displayName} needs (${n.minVersion}).`,i=t.length-1;return i>0?`${r} and ${i} more model(s)`:r}function Kur(){let[e,t]=(0,L.useState)(!1),n=(0,L.useRef)(!1),r=(0,L.useRef)(null);(0,L.useEffect)(()=>{n.current=e},[e]);let{data:i,refetch:a}=F({queryKey:[`claude-code-status`],queryFn:async()=>{let e=n.current?`/api/claude-code/status?refresh=1`:`/api/claude-code/status`,t=await fetch(e);if(!t.ok)throw Error(`Failed to check Claude Code status`);return t.json()},staleTime:3e5,refetchInterval:e?Vur:Hur});if((0,L.useEffect)(()=>{if(e){if(i&&!i.outdated){t(!1),r.current=null;return}r.current!==null&&Date.now()-r.current>Uur&&(t(!1),r.current=null)}},[e,i]),!i)return null;let o=Gur(i);if(!o)return null;let s=i.upgrade,c=async()=>{await a()},l=async()=>{try{let e=await fetch(`/api/claude-code/upgrade`,{method:`POST`});if(e.status===200||e.status===409){yNt((await e.json()).sessionName,`Upgrade Claude Code`),r.current=Date.now(),t(!0);return}let n=await e.json().catch(()=>({}));B.error(n.error??`Could not start the Claude Code upgrade`)}catch{B.error(`Could not start the Claude Code upgrade`)}};return(0,z.jsx)(`div`,{className:`bg-warning/8 border-b border-warning/32 shrink-0`,"data-component":`claude-code-upgrade-banner`,children:(0,z.jsxs)(`div`,{className:`px-4 py-3 flex items-center gap-3 flex-wrap`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-sm font-medium text-warning-foreground flex-1 min-w-0`,children:[o,` Running agents and conversations keep their current Claude Code; new launches use the upgraded one.`]}),s?.runnable?(0,z.jsx)(`button`,{onClick:()=>void l(),disabled:e,className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-warning/8 border border-warning/32 text-warning-foreground hover:bg-warning/16 shrink-0 disabled:opacity-50`,children:e?`Upgrading…`:`Upgrade Claude Code`}):s?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(J5n,{command:s.display}),(0,z.jsx)(`button`,{onClick:()=>void c(),className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-card border border-border text-foreground hover:bg-card-2 shrink-0`,children:`Re-check`})]}):null]})})}var qur=`Sync the latest context rules, lifecycle hooks, and skills before starting new agents.`;function Jur(){let e=F({queryKey:[`sync-status`],queryFn:async()=>{let e=await fetch(`/api/sync-status`);if(!e.ok)throw Error(`Failed to check Overdeck sync status`);return e.json()},refetchInterval:6e4}),t=Cn({mutationFn:async()=>{let e=await fetch(`/api/system/sync`,{method:`POST`,headers:await Ac()}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`pan sync failed`)},onSuccess:async()=>{B.success(`Overdeck context, hooks, and skills are up to date`),await e.refetch()},onError:e=>B.error(e instanceof Error?e.message:`pan sync failed`)}),n=e.data;if(!n?.banner)return null;let r=n.autoSync?.state,i=n.summary||`sync context, hooks, and skills`,a=n.autoSync?.lastError??null,o=n.details??[],s=`${o.length>0?o.join(`
1606
- `):qur}${a?`\n\n${a}`:``}`;return(0,z.jsxs)(`div`,{className:`bg-primary/10 flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`sync-required-banner`,children:[(0,z.jsx)(zt,{className:`w-3.5 h-3.5 text-primary shrink-0 ${t.isPending?`animate-spin`:``}`}),(0,z.jsx)(`p`,{className:`flex-1 truncate text-xs text-primary`,title:s,children:r===`failed`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Auto-sync failed`}),` — `,i,`.`,a?` ${a.split(`
1607
- `)[0]}`:``]}):r===`unresolved`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Setup changed`}),` — `,i,`; auto-sync ran but could not apply it`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Setup changed`}),` — `,i]})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>t.mutate(),disabled:t.isPending,className:`h-[26px] shrink-0 rounded-sm bg-primary px-[10px] text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:t.isPending?`Syncing…`:r===`failed`?`Retry sync`:`Sync now`})]})}function Yur(e,t){let n=As(),r=$t(),i=Cn({mutationFn:async()=>{if(!e)throw Error(`No agent to kill`);let t=await fetch(`/api/agents/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`Failed to kill agent`);return t.json()},onSuccess:async()=>{await q_(r),t?.onSuccess?.()}});return{killMutation:i,confirmAndKill:async()=>{if(!e)return!1;let t=await n({title:`Kill Agent`,message:`Kill agent ${e}?`,variant:`destructive`,confirmLabel:`Kill`});return t&&i.mutate(),t},isPending:i.isPending}}function Xur(e){return[...e.host.reasons.filter(e=>e.severity===`info`),...e.admission.reasons.filter(e=>e.severity===`info`),...e.agents.flatMap(e=>e.reasons).filter(e=>e.severity===`info`),...e.services.flatMap(e=>e.reasons).filter(e=>e.severity===`info`)]}function Zur(e,t){switch(t.code){case`admission.memory_available.soft`:return`spawn headroom tight`;case`admission.memory_available.blocked`:return e.admission.availableMemoryBytes==null?`spawn admission blocked`:`${Qur(e.admission.availableMemoryBytes)} available`;case`host.linux.psi_some.warning`:case`host.linux.psi_full.critical`:case`host.darwin.memory_pressure.warning`:case`host.darwin.memory_pressure.critical`:return`memory pressure detected`;case`host.linux.swap_activity.warning`:case`host.linux.swap_activity.critical`:return t.observed==null?`swap activity detected`:`${Qur(t.observed)} swap activity/min`;case`host.linux.inotify_watches.warning`:return`file-watcher budget low`;case`host.linux.inotify_watches.critical`:return`file-watcher budget exhausted`;case`agent.context.saturated`:return`agent context exhausted`;case`agent.tmux.missing`:return`agent session missing`;case`agent.kickoff.not_delivered`:return`agent kickoff stalled`;case`agent.runtime.inactive.warning`:case`agent.runtime.inactive.stalled`:return`agent activity stalled`;case`service.smee_relay.stopped`:return`webhook relay stopped`;case`service.smee_relay.unavailable`:return`webhook relay unavailable`;case`system.health_snapshot.unavailable`:case`host.current_pressure.unavailable`:case`host.sampler.collection_failed`:case`agent.persisted_state.unavailable`:return`Retry`;default:return null}}function Qur(e){let t=e/1024**3;return t>=1?`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function $ur(e){let t=new Map;for(let n of e.topConsumers){if(n.type===`container`)continue;let e=n.killTarget?.kind===`agent`?n.killTarget.agentId??n.id:n.id;t.has(e)||t.set(e,n)}let n=[];e.host.reasons.filter(e=>e.severity!==`info`).forEach(e=>{n.push({reason:e})}),e.admission.reasons.filter(e=>e.severity!==`info`).forEach(e=>{n.push({reason:e})}),e.services.flatMap(e=>e.reasons.filter(e=>e.severity!==`info`).map(e=>({reason:e}))).forEach(e=>{n.push(e)}),e.agents.forEach(e=>{e.reasons.filter(e=>e.severity!==`info`).forEach(r=>{n.push({reason:r,target:{agentId:e.id,issueId:e.issueId,killConsumer:t.get(e.id)}})})});let r=new Map;for(let e of n){let t=e.reason.code;r.has(t)||r.set(t,[]),r.get(t).push(e)}let i=[];for(let[t,n]of r){let r=n[0],a=r.reason;if(t.startsWith(`agent.`)&&n.length>1){let r=n.map(e=>e.target).filter(e=>e!==void 0),o=r.map(e=>e.agentId),s=o.slice(0,2).join(`, `)+(o.length>2?` +${o.length-2} more`:``);i.push({severity:edr(a.code,a.severity),code:t,title:Zur(e,a)??t,sub:`${o.length}× agents: ${s}`,agents:o,targets:r})}else{let n=r.target,o=n?.agentId,s=n?.issueId,c=o?s?`${o} · ${s}`:o:Zur(e,a)??t,l=o?`${o} has produced `:void 0,u=l&&a.message.startsWith(l)?a.message.slice(l.length):a.message;i.push({severity:edr(a.code,a.severity),code:t,title:c,sub:u,agents:o?[o]:[],targets:n?[n]:[],agentId:o,issueId:s,killConsumer:n?.killConsumer})}}return i.sort((e,t)=>{if(e.severity!==t.severity)return e.severity===`critical`?-1:1;let n=e.code===`agent.runtime.inactive.stalled`;return n===(t.code===`agent.runtime.inactive.stalled`)?0:n?-1:1}),i}function edr(e,t){return e===`agent.runtime.inactive.stalled`||t===`critical`?`critical`:`warning`}function tdr(e,t){let n=t.filter(e=>e.code===`agent.runtime.inactive.stalled`).reduce((e,t)=>e+t.agents.length,0),r=t.filter(e=>e.code===`agent.runtime.inactive.warning`).reduce((e,t)=>e+t.agents.length,0),i=t.filter(e=>e.severity===`warning`).length,a=t.filter(e=>e.severity===`critical`).length,o=Xur(e).length,s=e.host.metrics.memoryUsedPercent==null?`memory unavailable`:`memory at ${e.host.metrics.memoryUsedPercent.toFixed(1)}%`,c=e.admission.availableMemoryBytes==null?`spawn headroom unavailable`:`${Qur(e.admission.availableMemoryBytes)} spawn headroom`,l=e.summary.smeeRelay.configured?e.summary.smeeRelay.running?`relay running`:`relay stopped`:`relay not configured`,u=[`${n} stalled agent${n===1?``:`s`}`,`${r} idle agent${r===1?``:`s`}`,s,c,`${o} context note${o===1?``:`s`}`].join(` · `);return t.length===0?`All clear · ${s} · ${c} · ${l} · ${n} stalled agents · ${r} idle agents · ${o} context note${o===1?``:`s`}`:a>0?`Action required: ${a} critical issue${a===1?``:`s`} · ${u}`:`Attention needed: ${i} warning${i===1?``:`s`} · ${u}`}var ndr=`system-health-popover`,rdr=`system-health-popover-title`;function G9(e){let t=e/1024**3;return t>=1?`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function idr(e){switch(e){case`critical`:return`border-destructive/50 bg-destructive/10 text-destructive motion-safe:animate-pulse`;case`warning`:return`border-warning/40 bg-warning/10 text-warning-foreground`;case`unavailable`:return`border-border bg-muted text-muted-foreground`;case`measuring`:return`border-info/40 bg-info/10 text-info`;case`healthy`:return`border-success/40 bg-success/10 text-success`}}function adr(e){switch(e){case`critical`:return`bg-destructive`;case`warning`:return`bg-warning`;case`unavailable`:return`bg-muted-foreground`;case`measuring`:return`bg-info`;case`healthy`:return`bg-success`}}function odr(e){return e.issueId?`${e.label} · ${e.issueId}`:e.currentIssue?`${e.label} · ${e.currentIssue}`:e.label}function sdr(e){switch(e.type){case`agent`:return`Agent`;case`specialist`:return`Specialist`;case`container`:return`Container`}}function cdr(e){return[...e.host.reasons,...e.admission.reasons,...e.agents.flatMap(e=>e.reasons),...e.services.flatMap(e=>e.reasons)]}function ldr(e,t){for(let n of t){let t=Zur(e,n);if(t)return t}return null}function udr(e,t){switch(e.state){case`measuring`:return`Measuring system health…`;case`healthy`:return e.admission.availableMemoryBytes==null?`Healthy`:`Healthy · ${G9(e.admission.availableMemoryBytes)} available`;case`warning`:return`Warning · ${ldr(e,t)??`attention required`}`;case`critical`:return`Critical · ${ldr(e,t)??`action required`}`;case`unavailable`:return`Health unavailable · Retry`}}function ddr({state:e}){switch(e){case`measuring`:return(0,z.jsx)(is,{"data-health-icon":`measuring`,"aria-hidden":`true`,className:`h-3.5 w-3.5 animate-spin motion-reduce:animate-none`});case`healthy`:return(0,z.jsx)(vo,{"data-health-icon":`healthy`,"aria-hidden":`true`,className:`h-3.5 w-3.5`});case`warning`:return(0,z.jsx)(Ts,{"data-health-icon":`warning`,"aria-hidden":`true`,className:`h-3.5 w-3.5`});case`critical`:return(0,z.jsx)(wpe,{"data-health-icon":`critical`,"aria-hidden":`true`,className:`h-3.5 w-3.5`});case`unavailable`:return(0,z.jsx)(yo,{"data-health-icon":`unavailable`,"aria-hidden":`true`,className:`h-3.5 w-3.5`})}}function fdr({consumer:e,onSelectLeaked:t}){let n=As(),r=$t(),{confirmAndKill:i,isPending:a}=Yur(e.killTarget?.kind===`agent`?e.killTarget.agentId:void 0,{onSuccess:()=>{e.leaked&&t()}}),o=Cn({mutationFn:async()=>{let t=e.killTarget;if(!t)throw Error(`No kill target available`);if(t.kind===`container`){if(!t.containerId)throw Error(`Missing container id`);let e=await fetch(`/api/resources/docker/container/${t.containerId}`,{method:`DELETE`});if(!e.ok)throw Error(`Failed to remove container`);return e.json()}if(t.kind===`specialist`){if(!t.projectKey||!t.issueId||!t.specialistType)throw Error(`Missing specialist target`);let e=await fetch(`/api/specialists/${t.projectKey}/${t.issueId}/${t.specialistType}/kill`,{method:`POST`});if(!e.ok)throw Error(`Failed to kill specialist`);return e.json()}throw Error(`Unsupported kill target`)},onSuccess:async()=>{await q_(r),await r.invalidateQueries({queryKey:[`system-health`]}),e.leaked&&t()}}),s=a||o.isPending,c=e.killTarget;if(!c)return null;let l=c.kind===`container`?`Remove container ${e.label}`:c.kind===`specialist`?`Kill specialist ${e.label}`:`Kill ${e.label}`,u=async()=>{if(c.kind===`agent`){await i();return}await n({title:c.kind===`container`?`Remove Container`:`Kill Specialist`,message:c.kind===`container`?`Remove Docker container ${e.label}?`:`Kill specialist ${e.label}?`,variant:`destructive`,confirmLabel:c.kind===`container`?`Remove`:`Kill`})&&o.mutate()};return(0,z.jsx)(`button`,{onClick:()=>void u(),disabled:s,className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50`,title:l,children:s?`Killing…`:c.kind===`container`?`Remove`:`Kill`})}function pdr({target:e,onOpen:t,onSelectLeaked:n}){return!e.issueId&&!e.killConsumer?null:(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[e.issueId&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>t(e.issueId),className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Open ${e.issueId}`,children:`Open`}),e.killConsumer&&(0,z.jsx)(fdr,{consumer:e.killConsumer,onSelectLeaked:n})]})}function mdr({compact:e=!1}){let{data:t,isLoading:n,error:r}=twt(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(null),d=(0,L.useCallback)((e=!0)=>{s(!1),a(!1),e&&requestAnimationFrame(()=>u.current?.focus())},[]),f=(0,L.useCallback)(e=>{Wt.getState().openIssue(e),d()},[d]);(0,L.useEffect)(()=>{if(!i)return;let e=e=>{document.querySelector(`[role="alertdialog"]`)||l.current&&!l.current.contains(e.target)&&d()},t=e=>{e.key===`Escape`&&d()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[d,i]);let p=(0,L.useMemo)(()=>t?cdr(t):[],[t]),m=t?udr(t,p):`Health unavailable · Retry`,h=(0,L.useMemo)(()=>t?$ur(t):[],[t]),g=(0,L.useMemo)(()=>t?tdr(t,h):``,[t,h]),_=(0,L.useMemo)(()=>t?Xur(t):[],[t]);(0,L.useEffect)(()=>{if(!t)return;let n=c.current;c.current=t.state,!(e||n==null||n===t.state||t.state!==`critical`)&&B.error(`System health is critical`,{description:p[0]?.message??`Open the health panel to inspect top consumers and agent health.`,duration:1e4,action:{label:`Open`,onClick:()=>{s(t.topConsumers.some(e=>e.leaked)),a(!0)}}})},[e,t,p]);let v=(0,L.useMemo)(()=>{let e=[...t?.topConsumers??[]].sort((e,t)=>Number(t.leaked??!1)-Number(e.leaked??!1));if(!o)return e;let n=e.filter(e=>e.leaked);return n.length>0?n:e},[t?.topConsumers,o]),y=(0,L.useMemo)(()=>v.reduce((e,t)=>Math.max(e,t.memoryGb),1),[v]);if(n)return(0,z.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5 text-xs text-muted-foreground ${e?`justify-center px-1.5`:``}`,"aria-label":`Loading system health`,children:[(0,z.jsx)(is,{"aria-hidden":`true`,className:`h-3.5 w-3.5 animate-spin motion-reduce:animate-none`}),!e&&(0,z.jsx)(`span`,{children:`Health`})]});if(r||!t)return(0,z.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1.5 text-xs text-muted-foreground ${e?`justify-center px-1.5`:``}`,title:r?.message??`Failed to load system health`,"aria-label":`Health unavailable`,children:[(0,z.jsx)(yo,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),!e&&(0,z.jsx)(`span`,{children:`Health unavailable · Retry`})]});let b=t.services.find(e=>e.id===`smee-relay`||e.id===`webhook-relay`),x=b?.status??t.summary.smeeRelay.status,S=x===`not_configured`||!t.summary.smeeRelay.configured&&b===void 0?{label:`Not configured`,classes:`border-border bg-muted/40`,dotClass:`bg-muted-foreground`}:x===`running`?{label:`Running`,classes:`border-success/40 bg-success/10`,dotClass:`bg-success`}:{label:x===`unavailable`?`Unavailable`:`Stopped`,classes:`border-destructive/50 bg-destructive/10`,dotClass:`bg-destructive`};return(0,z.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,z.jsxs)(`button`,{ref:u,type:`button`,onClick:()=>{s(!1),a(e=>!e)},className:`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-xs transition-colors hover:bg-accent ${idr(t.state)} ${e?`justify-center px-1.5`:`justify-between`}`,"data-testid":`system-health-pill`,"aria-label":m,"aria-expanded":i,"aria-controls":ndr,"aria-haspopup":`dialog`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(ddr,{state:t.state}),!e&&(0,z.jsx)(`span`,{children:m})]}),!e&&(0,z.jsx)(po,{"aria-hidden":`true`,className:`h-3.5 w-3.5 transition-transform ${i?`rotate-180`:``}`})]}),i&&!e&&(0,z.jsxs)(`div`,{id:ndr,role:`dialog`,"aria-labelledby":rdr,className:`absolute right-0 top-full z-[200] mt-2 w-[min(22rem,calc(100vw-1rem))] max-h-[calc(100vh-1rem)] overflow-auto rounded-xl border border-border bg-popover p-3 text-sm shadow-lg`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,z.jsx)(`span`,{id:rdr,className:`font-semibold text-foreground`,children:`System health`}),(0,z.jsxs)(`span`,{role:`status`,"aria-label":`${t.state} system health`,className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize ${idr(t.state)}`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex h-2 w-2 rounded-full ${adr(t.state)}`}),t.state]})]}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Updated `,Math.round((Date.now()-Date.parse(t.updatedAt))/1e3),`s ago`]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>d(),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Close system health`,children:(0,z.jsx)(Os,{"aria-hidden":`true`,className:`h-4 w-4`})})]}),(0,z.jsx)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/30 p-2 text-sm`,children:(0,z.jsx)(`div`,{className:`text-foreground`,children:g})}),(0,z.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`CPU`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.host.metrics.cpuPercent==null?`Unavailable`:`${t.host.metrics.cpuPercent.toFixed(1)}%`}),(0,z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Load/core `,t.host.metrics.loadPerCore1m==null?`Unavailable`:t.host.metrics.loadPerCore1m.toFixed(2)]}),t.host.metrics.cpuPercent!=null&&(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`CPU usage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.host.metrics.cpuPercent,className:`h-full ${t.host.metrics.cpuPercent<60?`bg-success`:t.host.metrics.cpuPercent<=85?`bg-warning`:`bg-destructive`}`,style:{width:`${Math.min(100,t.host.metrics.cpuPercent)}%`}})})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Memory`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.host.metrics.usedMemoryBytes==null||t.host.metrics.totalMemoryBytes==null?`Unavailable`:`${G9(t.host.metrics.usedMemoryBytes)} / ${G9(t.host.metrics.totalMemoryBytes)}`}),(0,z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Avail `,t.host.metrics.availableMemoryBytes==null?`Unavailable`:G9(t.host.metrics.availableMemoryBytes)]}),t.host.metrics.memoryUsedPercent!=null&&(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`Memory usage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.host.metrics.memoryUsedPercent,className:`h-full ${t.host.metrics.memoryUsedPercent<60?`bg-success`:t.host.metrics.memoryUsedPercent<=85?`bg-warning`:`bg-destructive`}`,style:{width:`${Math.min(100,t.host.metrics.memoryUsedPercent)}%`}})})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Overdeck`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:G9(t.summary.overdeckMemoryBytes)}),(0,z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[t.summary.overdeckMemoryPercent.toFixed(1),`% of host RAM`]}),(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`Overdeck memory share`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.summary.overdeckMemoryPercent,className:`h-full bg-info`,style:{width:`${Math.min(100,t.summary.overdeckMemoryPercent)}%`}})})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Swap `,(0,z.jsx)(`span`,{className:`text-[11px]`,children:`historical · not live pressure`})]}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.host.metrics.swapUsedPercent==null?`Unavailable`:`${t.host.metrics.swapUsedPercent.toFixed(1)}%`}),t.host.metrics.swapUsedPercent!=null&&(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`Swap usage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.host.metrics.swapUsedPercent,className:`h-full ${t.host.metrics.swapUsedPercent<60?`bg-success`:t.host.metrics.swapUsedPercent<=85?`bg-warning`:`bg-destructive`}`,style:{width:`${Math.min(100,t.host.metrics.swapUsedPercent)}%`}})}),(0,z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Overcommit `,t.host.metrics.virtualCommitmentPercent==null?`Unavailable`:`${t.host.metrics.virtualCommitmentPercent.toFixed(1)}%`]})]})]}),(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[(0,z.jsxs)(`div`,{role:`group`,className:`flex items-center gap-1 rounded-full border border-border bg-muted/40 px-2 py-1 text-xs text-foreground`,"aria-label":`Admitted work agents: ${t.admission.admittedWorkAgentCount}`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Admitted work agents`}),(0,z.jsx)(`span`,{children:t.admission.admittedWorkAgentCount})]}),(0,z.jsxs)(`div`,{role:`group`,className:`flex items-center gap-1 rounded-full border border-border bg-muted/40 px-2 py-1 text-xs text-foreground`,"aria-label":`Containers: ${t.summary.containerCount}`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Containers`}),(0,z.jsx)(`span`,{children:t.summary.containerCount})]}),(0,z.jsxs)(`div`,{role:`group`,className:`flex items-center gap-1 rounded-full border px-2 py-1 text-xs text-foreground ${S.classes}`,"aria-label":`Webhook relay: ${S.label}`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 rounded-full ${S.dotClass}`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Webhook relay`}),(0,z.jsx)(`span`,{children:S.label})]})]}),(0,z.jsxs)(`div`,{className:`mb-3`,children:[h.length>0?(0,z.jsx)(`div`,{className:`space-y-1 rounded-lg border border-border p-2`,children:h.map(e=>{let t=e.targets.length===1?e.targets[0]:void 0;return(0,z.jsx)(`div`,{className:`text-xs`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`span`,{role:`img`,className:`inline-block h-2 w-2 rounded-full ${e.severity===`critical`?`bg-destructive`:`bg-warning`}`,"aria-label":`${e.severity} attention`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`text-foreground`,children:[e.title,e.agents.length>1&&(0,z.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.agents.length]})]}),(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:e.sub})]})]}),t&&(0,z.jsx)(pdr,{target:t,onOpen:f,onSelectLeaked:()=>s(!0)})]})},`${e.code}-${e.agents.join(`,`)}`)})}):(0,z.jsx)(`div`,{className:`rounded-lg border border-border p-2 text-xs text-foreground`,children:`No active pressure signals.`}),_.length>0&&(0,z.jsxs)(`details`,{className:`mt-2 cursor-pointer text-xs`,children:[(0,z.jsxs)(`summary`,{className:`text-muted-foreground hover:text-foreground`,children:[_.length,` context note`,_.length===1?``:`s`,` — background, not pressure signals`]}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg border border-border p-2`,children:_.map((e,t)=>(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`• `,e.message]},`${e.code}-${t}`))})]})]}),(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Top consumers`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o&&t.summary.leakedSpecialistCount>0&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Show all`}),(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.summary.leakedSpecialistCount>0?`⚠ ${t.summary.leakedSpecialistCount} leaked specialist${t.summary.leakedSpecialistCount===1?``:`s`}`:`No leaks`})]})]}),(0,z.jsx)(`div`,{className:`max-h-72 space-y-2 overflow-auto pr-1`,children:v.map(e=>{let t=e.memoryGb/y*100;return(0,z.jsx)(`div`,{className:`rounded-lg border p-2 ${e.leaked?`border-warning/40 bg-warning/10`:`border-border`}`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:odr(e)}),(0,z.jsx)(`span`,{role:`note`,className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,"aria-label":`Consumer kind: ${sdr(e)}`,children:sdr(e)}),e.leaked&&(0,z.jsx)(`span`,{className:`rounded bg-warning/20 px-1.5 py-0.5 text-[10px] font-medium text-warning`,children:`LEAKED`})]}),(0,z.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.memoryGb.toFixed(2),` GB`,e.cpuPercent==null?``:` · ${e.cpuPercent.toFixed(1)}% CPU`]}),t>0&&(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`${e.label} memory share: ${t.toFixed(1)}%`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Number(t.toFixed(1)),className:`h-full bg-info`,style:{width:`${t}%`}})})]}),(0,z.jsx)(fdr,{consumer:e,onSelectLeaked:()=>s(!0)})]})},e.id)})})]})]})}async function hdr(){let e=await fetch(`/api/deploy/staleness`);if(!e.ok)throw Error(`Failed to fetch deploy staleness`);let t=await e.json();return w(bt(ine(ane))(t))}function gdr(){return F({queryKey:[`deploy-staleness`],queryFn:hdr,refetchInterval:6e4})}function _dr(e){return e?.slice(0,8)||`unknown`}function vdr(){let{data:e}=gdr();if(e?.status!==`stale`||(e.behindBuildInputs??0)<1)return null;let t=[`Running build ${_dr(e.buildCommit)}`,`origin/main ${_dr(e.originMainSha)}`,`${e.behindTotal??`unknown`} total commit(s) behind`].join(` · `);return(0,z.jsxs)(`span`,{className:`text-[11px] font-medium text-warning-foreground`,title:t,children:[`build stale ×`,e.behindBuildInputs]})}function ydr({activeTab:e,selectedProjectKey:t,runningAgentCount:n,dashboardLifecycle:r,missingKeyTrackers:i,trackerBannerDismissed:a,showCliproxyBanner:o,isRestartBackendPending:s,isRestartCliproxyPending:c,isSessionFeedSidebarOpen:l,onSearchOpen:u,onOpenSettings:d,onDismissTrackerBanner:f,onRestartBackend:p,onRestartCliproxy:m,onToggleSessionFeedSidebar:h,onNavigateNeedsYou:g,onProjectCreated:_}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Clr,{onCreated:_}),(0,z.jsxs)(`div`,{"data-component":`system-notices-row`,className:`flex flex-wrap items-stretch border-b border-border`,children:[(0,z.jsx)(jur,{}),(0,z.jsx)(Fur,{}),(0,z.jsx)(X5n,{activeTab:e}),(0,z.jsx)(Kur,{}),(0,z.jsx)(Jur,{}),(0,z.jsx)(uur,{}),(0,z.jsx)(pur,{}),(0,z.jsx)(hur,{}),(0,z.jsx)(Dur,{})]}),(0,z.jsx)(Ilr,{lifecycle:r,onRestartBackend:p,isRestartBackendPending:s}),i.length>0&&!a&&(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b border-warning/30 px-4 py-2 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ts,{className:`w-4 h-4 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm flex-1`,children:[(0,z.jsxs)(`span`,{className:`font-semibold`,children:[`Missing API key`,i.length>1?`s`:``,`:`]}),` `,i.map(e=>(0,z.jsxs)(`span`,{children:[e.name,` (`,(0,z.jsx)(`code`,{className:`font-mono text-xs bg-warning/20 px-1 rounded`,children:e.envVar}),`)`]},e.type)).reduce((e,t,n)=>n===0?[t]:[...e,`, `,t],[]),`.`,` `,(0,z.jsx)(`button`,{onClick:d,className:`underline hover:opacity-80 font-semibold`,children:`Configure in Settings`})]}),(0,z.jsx)(`button`,{onClick:f,className:`text-warning-foreground/60 hover:text-warning-foreground shrink-0`,title:`Dismiss`,children:`✕`})]}),o&&(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsx)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:`CLIProxy is down — GPT subscription agents will fail.`}),(0,z.jsx)(`button`,{onClick:m,disabled:c,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0`,children:c?`Restarting…`:`Restart CLIProxy`})]}),(0,z.jsxs)(`div`,{className:`relative flex h-12 shrink-0 items-center gap-3 border-b border-border bg-background px-3`,children:[(0,z.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 text-sm font-semibold text-foreground`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`h-3.5 w-3.5 rounded-[4px] bg-primary/40`,"aria-hidden":`true`}),t]}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`All projects`})}),(0,z.jsxs)(`button`,{type:`button`,onClick:u,className:`mx-auto flex w-full min-w-0 max-w-md items-center gap-2 rounded-lg border border-border px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent`,title:`Search`,children:[(0,z.jsx)(gs,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,children:t?`Search ${t}…`:`Search issues, conversations, commands…`}),(0,z.jsx)(`kbd`,{className:`ml-auto rounded border border-border px-1.5 text-[11px]`,children:`/`})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,z.jsx)(DQt,{compact:!0}),(0,z.jsx)(lur,{}),n>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:T_e,title:`Emergency stop — kill all agents and freeze auto-resume (${C_e})`,"aria-label":`Emergency stop all agents`,className:`inline-flex items-center gap-1.5 rounded-full border border-destructive/40 bg-destructive/10 px-2.5 py-1 text-xs font-medium text-destructive hover:bg-destructive/20 transition-colors`,children:[(0,z.jsx)(bo,{className:`h-3.5 w-3.5`}),` Stop all`]}),(0,z.jsx)(cur,{variant:`pill`}),(0,z.jsx)(Rlr,{onOpenSettings:d}),(0,z.jsx)(vdr,{}),(0,z.jsx)(Bur,{}),(0,z.jsx)(mdr,{}),(0,z.jsx)(Blr,{}),(0,z.jsx)(Vlr,{onActivate:g}),(0,z.jsx)(Zlr,{onOpenSettings:d}),e!==`command-deck`&&(0,z.jsx)(`button`,{type:`button`,"aria-label":`Toggle activity feed`,"aria-pressed":l,title:`Activity Feed`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,onClick:h,children:(0,z.jsx)(Xo,{className:`h-4 w-4`,"aria-hidden":`true`})})]})]})]})}function K9(e,t){return`${e}::${t.signature??`unanswerable:${t.agentKey??`unknown`}`}`}function bdr(e,t){let n=$t(),[r,i]=(0,L.useState)(()=>new Set),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(null),d=e.filter(e=>e.pendingPermission!=null).map(e=>({conversationName:e.name,title:e.title??null,pendingPermission:e.pendingPermission})).filter(e=>!r.has(K9(e.conversationName,e.pendingPermission))).sort((e,t)=>e.pendingPermission.since.localeCompare(t.pendingPermission.since)),f=d.find(e=>K9(e.conversationName,e.pendingPermission)===a)??d.find(e=>e.conversationName===l)??d[0]??null,p=d.map(e=>K9(e.conversationName,e.pendingPermission)).join(`
1605
+ `))){e.push({issueId:n.issueId,success:!1,error:`Agent start canceled`});continue}i={...r,guardrailAcknowledged:!0},a=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),o=await a.json().catch(()=>({}))}if(a.ok)o.guardrails?.warnings?.length&&B.success(`${n.issueId}: started after acknowledging system health warnings`,{duration:8e3}),e.push({issueId:n.issueId,success:!0});else{if(mht(a,o)){lht(i),e.push({issueId:n.issueId,success:!1,error:o.hint||o.error||`Codex authentication expired — re-authenticate to continue`});continue}let r=a.status===409?X_(o):null;if(r){t||=(J_.getState().openRecovery({...r,issueId:n.issueId}),!0),e.push({issueId:n.issueId,success:!1,error:`Needs your choice — Resume or Start fresh`});continue}e.push({issueId:n.issueId,success:!1,error:o.error||o.hint||a.statusText})}}catch(t){e.push({issueId:n.issueId,success:!1,error:t instanceof Error?t.message:String(t)})}p(e),d(!1)},[u,s]),v=(0,L.useCallback)(()=>{l(!0)},[]),y=(0,L.useCallback)(()=>{p(null),l(!1)},[]),b=f?.filter(e=>e.success).length??0,x=f?.filter(e=>!e.success).length??0;if(e===`pill`)return s.length===0?null:(0,z.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-expanded":m,className:`inline-flex items-center gap-1.5 rounded-full border border-warning/40 bg-warning/10 px-2.5 py-1 text-xs font-medium text-warning-foreground transition-colors hover:bg-warning/20`,"data-testid":`stopped-agents-pill`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`}),s.length,` stopped`]}),m&&(0,z.jsxs)(`div`,{"data-testid":`stopped-agents-popover`,className:`absolute right-0 top-full z-50 mt-1.5 w-80 rounded-lg border border-border bg-card p-3 shadow-xl`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs font-semibold text-warning-foreground`,children:[(0,z.jsx)(Ts,{className:`h-3.5 w-3.5`}),s.length,` stopped · panes the backend reports exited`]}),(0,z.jsx)(`div`,{className:`mb-3 max-h-64 overflow-y-auto`,children:s.map(e=>{let t=e.lastActivity?Date.parse(e.lastActivity):0,n=e.startedAt?Date.parse(e.startedAt):0,r=new Date(Math.max(t,n)).toISOString();return(0,z.jsx)(aur,{agent:e,title:e.issueId?a.get(e.issueId.toUpperCase()):void 0,contextLine:`${tur(e)} · ${iur(r,Date.now())}`,onNavigate:()=>h(!1)},e.id)})}),f&&(0,z.jsxs)(`div`,{className:`mb-2 text-xs`,children:[b>0&&(0,z.jsxs)(`span`,{className:`text-success`,children:[`✓ `,b,` restarted`]}),x>0&&(0,z.jsxs)(`span`,{className:`ml-2 text-destructive`,children:[`✕ `,x,` failed`]})]}),(0,z.jsxs)(`button`,{onClick:_,disabled:u,className:`flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-2 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,"data-testid":`pill-restart-all`,children:[u?(0,z.jsx)(is,{className:`h-3 w-3 animate-spin`}):(0,z.jsx)(ds,{className:`h-3 w-3`}),u?`Restarting…`:`Restart all`]})]})]});if(c||s.length===0)return c&&s.length>0?(0,z.jsxs)(`div`,{className:`bg-card/40 border-b border-border px-4 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s.length,` agent`,s.length>1?`s`:``,` stopped`]}),(0,z.jsx)(`button`,{onClick:y,className:`text-xs text-primary hover:text-primary/80 underline`,children:`Show`})]}):null;let S=f?.filter(e=>e.success).length??0,C=f?.filter(e=>!e.success).length??0;return(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b border-warning/30 px-3 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,z.jsx)(Ts,{className:`w-3.5 h-3.5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`span`,{className:`text-warning-foreground text-xs font-semibold`,children:[s.length,` stopped`]}),(0,z.jsxs)(`span`,{className:`text-warning-foreground/70 text-xs truncate`,children:[s.map(e=>e.issueId||e.id).join(`, `),s.some(e=>e.lastActivity)&&(0,z.jsxs)(`span`,{className:`ml-1`,children:[`(`,Math.max(...s.map(e=>e.lastActivity?Date.now()-new Date(e.lastActivity).getTime():0))/6e4|0,`m ago)`]})]}),f&&(0,z.jsxs)(`span`,{className:`text-xs ml-1`,children:[S>0&&(0,z.jsxs)(`span`,{className:`text-success inline-flex items-center gap-0.5`,children:[(0,z.jsx)(_o,{className:`w-3 h-3`}),` `,S]}),C>0&&(0,z.jsxs)(`span`,{className:`text-destructive inline-flex items-center gap-0.5 ml-1`,children:[(0,z.jsx)(Os,{className:`w-3 h-3`}),` `,C]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 ml-auto`,children:[(0,z.jsxs)(`button`,{onClick:_,disabled:u,className:`flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,"data-testid":`banner-restart-all`,children:[u?(0,z.jsx)(is,{className:`w-3 h-3 animate-spin`}):(0,z.jsx)(ds,{className:`w-3 h-3`}),u?`Restarting...`:`Restart All`]}),(0,z.jsx)(`button`,{onClick:v,disabled:u,className:`text-warning-foreground/60 hover:text-warning-foreground shrink-0 disabled:opacity-50`,title:`Dismiss`,"data-testid":`banner-dismiss`,children:(0,z.jsx)(Os,{className:`w-3.5 h-3.5`})})]})]})}function lur(){let e=Wt(Jt),t=Wt(Lt),[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(null),a=(0,L.useMemo)(()=>e.filter(e=>eur(e.status)).sort((e,t)=>{let n=Date.parse(e.lastActivity??e.startedAt);return Date.parse(t.lastActivity??t.startedAt)-n}),[e]),o=(0,L.useMemo)(()=>new Map(t.map(e=>[e.identifier.toUpperCase(),e.title])),[t]);return(0,L.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),a.length===0?null:(0,z.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-label":`${a.length} running agent${a.length===1?``:`s`} — click to view`,"data-testid":`running-agents-pill`,className:`inline-flex items-center gap-1.5 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2.5 py-1 text-xs text-emerald-600 transition-colors hover:bg-emerald-500/20 dark:text-emerald-400`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`}),a.length,` agent`,a.length===1?``:`s`]}),n&&(0,z.jsxs)(`div`,{"data-testid":`running-agents-popover`,className:`absolute right-0 top-full z-50 mt-1.5 w-80 rounded-lg border border-border bg-card p-3 shadow-xl`,children:[(0,z.jsxs)(`div`,{className:`mb-2 text-xs font-semibold text-foreground`,children:[a.length,` running now`]}),(0,z.jsx)(`div`,{className:`max-h-64 overflow-y-auto`,children:a.map(e=>{let t=e.lastActivity??e.startedAt;return(0,z.jsx)(aur,{agent:e,title:e.issueId?o.get(e.issueId.toUpperCase()):void 0,contextLine:`${e.model} · ${iur(t,Date.now())}`,onNavigate:()=>r(!1)},e.id)})})]})]})}var uur={native:`~/.codex`,cliproxy:`CLIProxy copy`};function dur(){let{data:e}=iht(),[t,n]=(0,L.useState)(!1);return!e||e.status!==`expired`&&e.status!==`burned`?null:(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:[`Codex authentication `,e.status,e.source&&(0,z.jsxs)(`span`,{className:`font-normal ml-1 opacity-80`,children:[`(`,uur[e.source],`)`]}),` `,`— Codex-routed agents (gpt-5.x, o3, o4-mini) will fail.`,e.email&&(0,z.jsxs)(`span`,{className:`font-normal ml-1 opacity-80`,children:[`(`,(0,z.jsx)(bNt,{value:e.email,className:`text-sm`}),`)`]}),e.affectedAgents&&e.affectedAgents.length>0&&(0,z.jsxs)(`span`,{className:`font-normal ml-1 opacity-80`,children:[`— `,e.affectedAgents.length,` agent`,e.affectedAgents.length===1?``:`s`,` wedged on a revoked token`]})]}),(0,z.jsx)(`button`,{onClick:async()=>{n(!0);try{let e=await fetch(`/api/settings/codex-reauth`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to spawn re-auth session (${e.status})`)}let{sessionName:t,statusToken:n}=await e.json();uht(t,n),B.success(`Re-authentication session started — opening terminal…`),yNt(t,`Codex re-authentication`)}catch(e){B.error(e instanceof Error?e.message:`Failed to start re-authentication`)}finally{n(!1)}},disabled:t,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0 flex items-center gap-1.5`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(is,{className:`w-3.5 h-3.5 animate-spin`}),`Starting…`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Mo,{className:`w-3.5 h-3.5`}),`Re-authenticate`]})})]})}async function fur(){let e=await fetch(`/api/settings/conversation-search/status`);if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`Failed to fetch conversation search status (${e.status}): ${t}`)}return e.json()}function pur(){return F({queryKey:[`conversation-search-status`],queryFn:fur,refetchInterval:6e4,staleTime:3e4})}function mur(){let{data:e}=pur();if(!e?.enabled)return null;let t=e.health,n=t?.lastErrorAt!=null&&(t.lastSuccessAt==null||t.lastErrorAt>t.lastSuccessAt),r=t?.watcher?.state,i=r===`restarting`||r===`failed`;if(e.available&&!n&&!i)return null;let a=e.available&&!n,o=a&&r===`failed`,s=t?.watcher?.lastErrorReason??`unknown error`,c=e.available?o?`transcript watcher stopped after repeated failures (${s})`:a?`transcript watcher failed (${s}), restarting`:t?.lastErrorReason??`recent embedding failures`:e.unavailableReason??`embedding provider unavailable`,l=/credit|billing|quota|insufficient/i.test(c);return(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1 min-w-0 [&_span]:break-words`,children:[`Conversation search is not working: `,(0,z.jsx)(`span`,{className:`font-normal`,children:c}),(0,z.jsx)(`span`,{className:`font-normal ml-1 opacity-80`,children:o?`— new transcripts are not indexed. Restart the dashboard or save the conversation-search settings to retry.`:a?`— new transcripts are not indexed until the watcher is back.`:`— Ctrl+K conversation hits and transcript indexing are unavailable until this is fixed.`})]}),l&&(0,z.jsxs)(`a`,{href:`https://platform.openai.com/settings/organization/billing/`,target:`_blank`,rel:`noreferrer`,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors shrink-0 flex items-center gap-1.5`,children:[(0,z.jsx)(Mo,{className:`w-3.5 h-3.5`}),`OpenAI billing`]})]})}var hur=`echo 'fs.inotify.max_user_watches = 2097152' | sudo tee /etc/sysctl.d/99-inotify.conf && sudo sysctl --system`;function gur(){let{data:e}=twt(),t=e?.host.reasons.find(e=>e.code.startsWith(`host.linux.inotify_watches.`));if(!e||!t)return null;let n=t.code===`host.linux.inotify_watches.critical`,r=e.host.metrics.inotifyWatchesUsed,i=e.host.metrics.inotifyWatchesMax,a=r!=null&&i!=null?`${r.toLocaleString()} of ${i.toLocaleString()} file watchers in use`:`file-watcher usage is near the limit`,o=t.observed==null?``:` (${Math.round(t.observed)}%)`;return(0,z.jsxs)(`div`,{className:`${n?`bg-destructive/10`:`bg-warning/10`} flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`inotify-pressure-banner`,children:[(0,z.jsx)(Ts,{className:`w-3.5 h-3.5 shrink-0 ${n?`text-destructive`:`text-warning-foreground`}`}),(0,z.jsxs)(`p`,{className:`flex-1 truncate text-xs ${n?`text-destructive`:`text-warning-foreground`}`,title:`inotify watches are a per-user kernel budget shared by every process and container on this host. When it is exhausted, new file-watching dev servers fail to start with ENOSPC. ${a}${o}. Raise and persist the limit with: ${hur}`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:n?`File watchers exhausted`:`File watchers running low`}),` — `,a,o,`; new dev servers `,n?`will`:`may`,` fail with ENOSPC`]}),(0,z.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(hur),B.success(`Fix command copied — run it in a terminal to raise and persist the limit`)}catch{B.error(`Copy failed — run: ${hur}`)}},className:`h-[26px] shrink-0 rounded-sm px-[10px] text-[11px] font-medium ${n?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-warning/20 text-warning-foreground hover:bg-warning/30`}`,children:`Copy fix`})]})}async function _ur(){let e=await fetch(`/api/linear-mcp-auth`);if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`Failed to fetch Linear MCP auth status (${e.status}): ${t}`)}return e.json()}function vur(e={}){return F({queryKey:[`linear-mcp-auth`],queryFn:_ur,refetchInterval:t=>e.fast?1e3:t.state.data?.status===`none`?3e4:5e3})}function yur(e){let t=e.toLowerCase();return t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||t===`[::1]`||/^127(\.\d{1,3}){3}$/.test(t)}var bur=9e4,xur=6e4,Sur=`No fresh Linear link yet — open a blocked conversation to check on it.`,Cur=`Linear still isn't connected. Finish approving in the Linear tab, then click Check now.`;async function wur(e){let t=await fetch(e,{method:`POST`}),n=await t.json().catch(()=>({}));return{ok:t.ok,status:t.status,body:n}}function Tur(e,t){return typeof e.error==`string`&&e.error!==``?e.error:t}function Eur(){let[e,t]=(0,L.useState)(`idle`),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(null),{data:o}=vur({fast:e!==`idle`}),s=(0,L.useRef)(null),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(!1),d=(0,L.useRef)(0),f=(0,L.useCallback)(e=>{let n=s.current;n?(n.opener=null,n.location.href=e):r(e),l.current=Date.now(),u.current=!1,t(`awaiting-approval`)},[]),p=(0,L.useCallback)(e=>{s.current?.close(),s.current=null,B.error(e),t(`idle`)},[]),m=(0,L.useCallback)(()=>{e===`idle`&&(s.current=window.open(`about:blank`,`_blank`),r(null),a(null),t(`opening`),(async()=>{try{let{ok:e,status:n,body:r}=await wur(`/api/linear-mcp-auth/connect`);e&&n===200&&r.action===`open`&&typeof r.authUrl==`string`?f(r.authUrl):e&&r.action===`refreshing`?(c.current=typeof r.previousAuthUrl==`string`?r.previousAuthUrl:null,t(`refreshing`)):p(Tur(r,`Failed to connect Linear (${n})`))}catch(e){p(e instanceof Error?e.message:`Failed to connect Linear`)}})())},[e,f,p]),h=(0,L.useCallback)(()=>{a(null),t(`checking`),(async()=>{try{let{ok:e,status:n,body:r}=await wur(`/api/linear-mcp-auth/verify`);e||(B.error(Tur(r,`Failed to check Linear access (${n})`)),t(`awaiting-approval`))}catch(e){B.error(e instanceof Error?e.message:`Failed to check Linear access`),t(`awaiting-approval`)}})()},[]);return(0,L.useEffect)(()=>{if(!o)return;if(o.status!==`none`){d.current=o.blockedAgents?.length??0;return}if(e===`idle`)return;let n=d.current;B.success(`Linear connected — ${n} agent${n===1?``:`s`} resumed`),s.current=null,r(null),a(null),t(`idle`)},[o,e]),(0,L.useEffect)(()=>{e===`refreshing`&&o&&o.status===`active`&&o.authUrl!==null&&o.authUrl!==c.current&&f(o.authUrl)},[e,o,f]),(0,L.useEffect)(()=>{if(e!==`refreshing`)return;let t=setTimeout(()=>p(Sur),bur);return()=>clearTimeout(t)},[e,p]),(0,L.useEffect)(()=>{if(e!==`checking`)return;let n=setTimeout(()=>{a(Cur),t(`awaiting-approval`)},xur);return()=>clearTimeout(n)},[e]),(0,L.useEffect)(()=>{if(e!==`awaiting-approval`||!yur(window.location.hostname))return;let t=()=>{if(u.current||document.visibilityState!==`visible`)return;let e=l.current;e===null||Date.now()-e<2e3||(u.current=!0,h())};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,t)}},[e,h]),{intervention:o,phase:e,fallbackUrl:n,notice:i,connect:m,checkNow:h}}function Dur(e){return{label:e.conversationTitle??e.issueId??e.agentId,href:e.conversationUrl??(e.issueId?`/issues/${e.issueId}`:null)}}function Our(){let e=Eur(),t=e.intervention,[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1);if(!t||t.status===`none`)return null;let c=t.blockedAgents??[],l=async()=>{a(!0);try{let e=await fetch(`/api/linear-mcp-auth/callback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({callbackUrl:n})}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Failed to relay callback URL (${e.status})`);B.success(`Callback URL relayed to ${t.relayedTo??`the blocked agent`} — it will finish the OAuth flow.`),r(``)}catch(e){B.error(e instanceof Error?e.message:`Failed to relay callback URL`)}finally{a(!1)}},u=async()=>{s(!0);try{let e=await fetch(`/api/linear-mcp-auth/complete`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to mark Linear auth completed (${e.status})`)}B.success(`Marked Linear authentication healthy — blocked agents are being woken to re-check.`)}catch(e){B.error(e instanceof Error?e.message:`Failed to mark Linear auth completed`)}finally{s(!1)}},d=`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0 flex items-center gap-1.5`;return(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex flex-col gap-2 shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:[`Linear authentication required — `,c.length,` agent`,c.length===1?``:`s`,` blocked on Linear MCP OAuth.`]}),e.fallbackUrl?(0,z.jsxs)(`a`,{href:e.fallbackUrl,target:`_blank`,rel:`noreferrer`,className:d,children:[(0,z.jsx)(Mo,{className:`w-3.5 h-3.5`}),`Open Linear authorization`]}):(0,z.jsxs)(`button`,{onClick:e.connect,disabled:e.phase!==`idle`,className:d,children:[(0,z.jsx)(Rfe,{className:`w-3.5 h-3.5`}),`Connect Linear`]})]}),(0,z.jsx)(kur,{phase:e.phase,expired:t.status===`expired`,notice:e.notice,onCheckNow:e.checkNow}),c.length>0&&(0,z.jsx)(`ul`,{className:`text-warning-foreground text-sm pl-8 flex flex-col gap-0.5`,children:c.map(e=>{let{label:t,href:n}=Dur(e),r=e.issueUrl??(e.issueId?kp(e.issueId):null);return(0,z.jsxs)(`li`,{children:[n?(0,z.jsx)(`a`,{href:n,title:e.agentId,className:`font-semibold underline hover:opacity-80`,children:t}):(0,z.jsx)(`span`,{className:`font-semibold`,title:e.agentId,children:t}),e.issueId&&r&&(0,z.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,"aria-label":`Open ${e.issueId} in tracker`,className:`inline-flex align-middle ml-1 hover:opacity-80`,children:(0,z.jsx)(Mo,{className:`w-3.5 h-3.5`})}),e.notifiedAt&&(0,z.jsx)(`span`,{className:`opacity-80`,children:` (woken, re-checking)`})]},e.agentId)})}),(0,z.jsxs)(`details`,{open:!yur(window.location.hostname),className:`pl-8 text-warning-foreground text-sm`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer opacity-80 hover:opacity-100`,children:`Signed in from a different device? Paste the callback URL`}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Paste the localhost callback URL here`,className:`flex-1 max-w-xl px-2 py-1.5 text-sm rounded-md bg-background border border-warning/40 text-foreground placeholder:text-muted-foreground`}),(0,z.jsx)(`button`,{onClick:l,disabled:i||n.trim()===``,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0`,children:i?`Relaying…`:`Submit callback URL`})]}),(0,z.jsxs)(`p`,{className:`text-xs opacity-80`,children:[`After authorizing in your browser, Linear redirects to a localhost URL. On a remote session the callback page fails to load — copy the URL from the address bar and paste it above; it is relayed to the blocked agent to finish the flow. If you authorized another way (e.g. `,(0,z.jsx)(`code`,{children:`claude mcp login linear`}),`), use Mark completed: blocked agents will be woken to re-check Linear access, and this banner returns if authentication is still broken.`]}),(0,z.jsx)(`div`,{children:(0,z.jsx)(`button`,{onClick:u,disabled:o,className:d,children:o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(is,{className:`w-3.5 h-3.5 animate-spin`}),`Marking…`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(vo,{className:`w-3.5 h-3.5`}),`Already authorized another way? Mark completed`]})})})]})]})]})}function kur({phase:e,expired:t,notice:n,onCheckNow:r}){let i=null;return e===`opening`?i=`Opening Linear…`:e===`refreshing`?i=`Getting a fresh link…`:e===`awaiting-approval`?i=`Approve access in the Linear tab, then come back here.`:e===`checking`?i=`Checking Linear access…`:t&&(i=`The last authorization link expired — Connect Linear gets a fresh one.`),i===null&&n===null?null:(0,z.jsxs)(`div`,{className:`text-warning-foreground text-sm pl-8 flex flex-col gap-1`,children:[i!==null&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(e===`opening`||e===`refreshing`||e===`checking`)&&(0,z.jsx)(is,{className:`w-3.5 h-3.5 animate-spin`}),(0,z.jsx)(`span`,{className:`opacity-80`,children:i}),e===`awaiting-approval`&&(0,z.jsx)(`button`,{onClick:r,className:`underline font-semibold hover:opacity-80`,children:`Check now`})]}),n!==null&&(0,z.jsx)(`p`,{className:`opacity-80`,children:n})]})}var Aur=8e3,jur={waiting:{strip:`bg-warning/10`,text:`text-warning-foreground`},working:{strip:`bg-info/10`,text:`text-info-foreground`},settled:{strip:`bg-muted/40`,text:`text-muted-foreground`}};function U9({tone:e,icon:t,title:n,children:r,action:i}){let a=jur[e];return(0,z.jsxs)(`div`,{className:`${a.strip} flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`restart-approval-banner`,children:[(0,z.jsx)(t,{className:`w-3.5 h-3.5 ${a.text} shrink-0`}),(0,z.jsx)(`p`,{className:`flex-1 truncate text-xs ${a.text}`,title:n,children:r}),i]})}function Mur(){let e=Wt(D),t=e?.lastOutcome?.type===`pruned-unclaimed`?e.lastOutcome.at:null,[n,r]=(0,L.useState)(!1);(0,L.useEffect)(()=>{if(!t)return;let e=Aur-(Date.now()-Date.parse(t));if(e<=0){r(!0);return}r(!1);let n=setTimeout(()=>r(!0),e);return()=>clearTimeout(n)},[t]);let i=Cn({mutationFn:async()=>{let e=await fetch(`/api/restart-gate/approve`,{method:`POST`,headers:await Ac()}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Failed to approve the restart`);return t},onSuccess:e=>{let t=e.pendingCount??0;B.success(t>0?`Restart approved — ${t} waiting request${t===1?``:`s`} will be satisfied by one restart`:`Nothing left to restart for — every waiting request had already given up`)},onError:e=>B.error(e instanceof Error?e.message:`Failed to approve the restart`)});if(!e)return null;let a=e.pending.length,o=e.pending.map(e=>e.reason||e.kind).join(`; `);if(e.status===`pending`&&a>0){let e=`${a} process${a===1?``:`es`} asked to restart the dashboard and ${a===1?`is`:`are`} waiting for you. Nothing restarts until you approve, and one approval covers every request listed here — they are satisfied by a single restart. Approve here, or run \`pan restart approve\` in a terminal. Waiting: ${o}`;return(0,z.jsxs)(U9,{tone:`waiting`,icon:sfe,title:e,action:(0,z.jsx)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:i.isPending,className:`h-[26px] shrink-0 rounded-sm bg-warning/20 px-[10px] text-[11px] font-medium text-warning-foreground hover:bg-warning/30 disabled:opacity-50`,children:i.isPending?`Approving…`:`Restart now`}),children:[(0,z.jsx)(`span`,{className:`font-medium`,children:a===1?`A dashboard restart is waiting for your approval`:`${a} dashboard restarts are waiting for your approval`}),` — `,o]})}if(e.status===`approved`){let t=e.pending.map(e=>e.requesterId).join(`, `)||`the requester`;return(0,z.jsxs)(U9,{tone:`working`,icon:dpe,title:`The restart is approved. ${t} performs it on the next poll — nothing else is waiting on you.`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Approved`}),` — waiting for `,t,` to restart…`]})}return e.status===`claimed`?(0,z.jsxs)(U9,{tone:`working`,icon:dpe,title:`A requester is restarting the dashboard now. This page loses its connection for a moment and reconnects on its own.`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Restarting…`}),` — the dashboard reconnects on its own in a moment`]}):t&&!n?(0,z.jsx)(U9,{tone:`settled`,icon:Qo,title:`Every process waiting on that approval had already exited, so the approval had nothing left to restart. Restart again from a terminal if you still want one.`,children:`The requester(s) went away without restarting — nothing was restarted.`}):null}function Nur(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Pur(e){let t=null;for(let n of e)(!t||Date.parse(n.until)>Date.parse(t.until))&&(t=n);return t}function Fur(e,t){let n=t.pool===`pat`?`the GITHUB_TOKEN personal access token`:t.pool===`app`?`the GitHub App`:e.login??`your account`,r=Nur(t.until);if(t.kind===`secondary`)return`GitHub secondary rate limit for ${n}: calls paused until ${r}. Overdeck sent requests too fast; pollers resume automatically.`;let i=e.samples.find(e=>e.pool===t.pool&&e.bucket===t.bucket),a=i?` GitHub reports ${i.limit-i.remaining} of ${i.limit} points used this hour.`:``,o=e=>e[t.bucket].points,s=e.callers.reduce((e,t)=>e+o(t),0);if(e.ownUsageLow&&t.pool===`user`)return`GitHub rate limit for ${n}: ${i?`calls paused until ${r}.${a} Not caused by this machine`:`calls paused until ${r}; not caused by this machine`} (this machine used ${s} points in the last hour). Another tool or Overdeck install using this account is spending the shared limit.`;let c=[...e.callers].sort((e,t)=>o(t)-o(e))[0];return c&&o(c)>0?`GitHub rate limit for ${n}: calls paused until ${r}.${a} This machine used ${s} points in the last hour; top caller: ${c.caller} (${o(c)} points).`:`GitHub rate limit for ${n}: calls paused until ${r}.`}function Iur(){let e=Wt(Gee),t=e?Pur(e.pauses):null;if(!e||!t)return null;let n=Fur(e,t);return(0,z.jsxs)(`div`,{className:`bg-warning/10 flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`github-rate-limit-banner`,children:[(0,z.jsx)(sfe,{className:`w-3.5 h-3.5 text-warning-foreground shrink-0`}),(0,z.jsx)(`p`,{className:`flex-1 truncate text-xs text-warning-foreground`,title:n,children:n})]})}var Lur=`github-quota-popover`,Rur=`github-quota-popover-title`,zur=5;function W9(e){return e.graphql.points+e.rest.points}function Bur(e){return[...e.callers].filter(e=>W9(e)>0).sort((e,t)=>W9(t)-W9(e)).slice(0,zur)}function Vur(){let e=Wt(Gee),[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(null),i=(0,L.useRef)(null),a=(0,L.useCallback)(()=>{n(!1),requestAnimationFrame(()=>i.current?.focus())},[]);if((0,L.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&a()},n=e=>{e.key===`Escape`&&a()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,n)}},[a,t]),!e)return null;let o=e.samples.find(e=>e.pool===`user`&&e.bucket===`graphql`),s=o?`GH ${o.remaining}/${o.limit}`:`GH —`,c=e.pauses.length>0?`border-warning/40 bg-warning/10 text-warning-foreground`:`border-border text-muted-foreground`,l=Bur(e),u=o?`GitHub GraphQL quota${e.login?` for ${e.login}`:``}: ${o.remaining} of ${o.limit} points left this hour`:`GitHub GraphQL quota: no sample yet`;return(0,z.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,z.jsx)(`button`,{ref:i,type:`button`,onClick:()=>n(e=>!e),className:`flex items-center rounded-md border px-2 py-1.5 font-mono text-xs tabular-nums transition-colors hover:bg-accent ${c}`,"data-testid":`github-quota-pill`,title:u,"aria-label":u,"aria-expanded":t,"aria-controls":Lur,"aria-haspopup":`dialog`,children:s}),t&&(0,z.jsxs)(`div`,{id:Lur,role:`dialog`,"aria-labelledby":Rur,className:`absolute right-0 top-full z-[200] mt-2 w-[min(20rem,calc(100vw-1rem))] rounded-xl border border-border bg-popover p-3 text-sm shadow-lg`,children:[(0,z.jsx)(`p`,{id:Rur,className:`mb-2 font-medium text-foreground`,children:`GitHub calls, last hour`}),l.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No metered GitHub calls this hour.`}):(0,z.jsx)(`ul`,{className:`space-y-1`,"data-testid":`github-quota-callers`,children:l.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.caller}),(0,z.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[W9(e),` pts`,e.estimated?` (est.)`:``]})]},e.caller))}),(0,z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3 border-t border-border pt-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Unattributed (other tools and installs)`}),(0,z.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[e.unattributed,` pts`]})]})]})]})}var Hur=5e3,Uur=6e5,Wur=6e5;function Gur(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}function Kur(e){if(!e.found||!e.outdated)return null;let t=e.requirements.filter(e=>e.satisfied===!1);if(t.length===0)return null;let n=t.reduce((e,t)=>Gur(t.minVersion,e.minVersion)>0?t:e),r=`Claude Code ${e.version} is older than ${n.displayName} needs (${n.minVersion}).`,i=t.length-1;return i>0?`${r} and ${i} more model(s)`:r}function qur(){let[e,t]=(0,L.useState)(!1),n=(0,L.useRef)(!1),r=(0,L.useRef)(null);(0,L.useEffect)(()=>{n.current=e},[e]);let{data:i,refetch:a}=F({queryKey:[`claude-code-status`],queryFn:async()=>{let e=n.current?`/api/claude-code/status?refresh=1`:`/api/claude-code/status`,t=await fetch(e);if(!t.ok)throw Error(`Failed to check Claude Code status`);return t.json()},staleTime:3e5,refetchInterval:e?Hur:Uur});if((0,L.useEffect)(()=>{if(e){if(i&&!i.outdated){t(!1),r.current=null;return}r.current!==null&&Date.now()-r.current>Wur&&(t(!1),r.current=null)}},[e,i]),!i)return null;let o=Kur(i);if(!o)return null;let s=i.upgrade,c=async()=>{await a()},l=async()=>{try{let e=await fetch(`/api/claude-code/upgrade`,{method:`POST`});if(e.status===200||e.status===409){yNt((await e.json()).sessionName,`Upgrade Claude Code`),r.current=Date.now(),t(!0);return}let n=await e.json().catch(()=>({}));B.error(n.error??`Could not start the Claude Code upgrade`)}catch{B.error(`Could not start the Claude Code upgrade`)}};return(0,z.jsx)(`div`,{className:`bg-warning/8 border-b border-warning/32 shrink-0`,"data-component":`claude-code-upgrade-banner`,children:(0,z.jsxs)(`div`,{className:`px-4 py-3 flex items-center gap-3 flex-wrap`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-sm font-medium text-warning-foreground flex-1 min-w-0`,children:[o,` Running agents and conversations keep their current Claude Code; new launches use the upgraded one.`]}),s?.runnable?(0,z.jsx)(`button`,{onClick:()=>void l(),disabled:e,className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-warning/8 border border-warning/32 text-warning-foreground hover:bg-warning/16 shrink-0 disabled:opacity-50`,children:e?`Upgrading…`:`Upgrade Claude Code`}):s?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(J5n,{command:s.display}),(0,z.jsx)(`button`,{onClick:()=>void c(),className:`px-3 py-1.5 text-sm font-medium rounded-sm bg-card border border-border text-foreground hover:bg-card-2 shrink-0`,children:`Re-check`})]}):null]})})}var Jur=`Sync the latest context rules, lifecycle hooks, and skills before starting new agents.`;function Yur(){let e=F({queryKey:[`sync-status`],queryFn:async()=>{let e=await fetch(`/api/sync-status`);if(!e.ok)throw Error(`Failed to check Overdeck sync status`);return e.json()},refetchInterval:6e4}),t=Cn({mutationFn:async()=>{let e=await fetch(`/api/system/sync`,{method:`POST`,headers:await Ac()}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`pan sync failed`)},onSuccess:async()=>{B.success(`Overdeck context, hooks, and skills are up to date`),await e.refetch()},onError:e=>B.error(e instanceof Error?e.message:`pan sync failed`)}),n=e.data;if(!n?.banner)return null;let r=n.autoSync?.state,i=n.summary||`sync context, hooks, and skills`,a=n.autoSync?.lastError??null,o=n.details??[],s=`${o.length>0?o.join(`
1606
+ `):Jur}${a?`\n\n${a}`:``}`;return(0,z.jsxs)(`div`,{className:`bg-primary/10 flex flex-1 items-center gap-2 px-4 py-1.5`,"data-testid":`sync-required-banner`,children:[(0,z.jsx)(zt,{className:`w-3.5 h-3.5 text-primary shrink-0 ${t.isPending?`animate-spin`:``}`}),(0,z.jsx)(`p`,{className:`flex-1 truncate text-xs text-primary`,title:s,children:r===`failed`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Auto-sync failed`}),` — `,i,`.`,a?` ${a.split(`
1607
+ `)[0]}`:``]}):r===`unresolved`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Setup changed`}),` — `,i,`; auto-sync ran but could not apply it`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-medium`,children:`Setup changed`}),` — `,i]})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>t.mutate(),disabled:t.isPending,className:`h-[26px] shrink-0 rounded-sm bg-primary px-[10px] text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:t.isPending?`Syncing…`:r===`failed`?`Retry sync`:`Sync now`})]})}function Xur(e,t){let n=As(),r=$t(),i=Cn({mutationFn:async()=>{if(!e)throw Error(`No agent to kill`);let t=await fetch(`/api/agents/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`Failed to kill agent`);return t.json()},onSuccess:async()=>{await q_(r),t?.onSuccess?.()}});return{killMutation:i,confirmAndKill:async()=>{if(!e)return!1;let t=await n({title:`Kill Agent`,message:`Kill agent ${e}?`,variant:`destructive`,confirmLabel:`Kill`});return t&&i.mutate(),t},isPending:i.isPending}}function Zur(e){return[...e.host.reasons.filter(e=>e.severity===`info`),...e.admission.reasons.filter(e=>e.severity===`info`),...e.agents.flatMap(e=>e.reasons).filter(e=>e.severity===`info`),...e.services.flatMap(e=>e.reasons).filter(e=>e.severity===`info`)]}function Qur(e,t){switch(t.code){case`admission.memory_available.soft`:return`spawn headroom tight`;case`admission.memory_available.blocked`:return e.admission.availableMemoryBytes==null?`spawn admission blocked`:`${$ur(e.admission.availableMemoryBytes)} available`;case`host.linux.psi_some.warning`:case`host.linux.psi_full.critical`:case`host.darwin.memory_pressure.warning`:case`host.darwin.memory_pressure.critical`:return`memory pressure detected`;case`host.linux.swap_activity.warning`:case`host.linux.swap_activity.critical`:return t.observed==null?`swap activity detected`:`${$ur(t.observed)} swap activity/min`;case`host.linux.inotify_watches.warning`:return`file-watcher budget low`;case`host.linux.inotify_watches.critical`:return`file-watcher budget exhausted`;case`agent.context.saturated`:return`agent context exhausted`;case`agent.tmux.missing`:return`agent session missing`;case`agent.kickoff.not_delivered`:return`agent kickoff stalled`;case`agent.runtime.inactive.warning`:case`agent.runtime.inactive.stalled`:return`agent activity stalled`;case`service.smee_relay.stopped`:return`webhook relay stopped`;case`service.smee_relay.unavailable`:return`webhook relay unavailable`;case`system.health_snapshot.unavailable`:case`host.current_pressure.unavailable`:case`host.sampler.collection_failed`:case`agent.persisted_state.unavailable`:return`Retry`;default:return null}}function $ur(e){let t=e/1024**3;return t>=1?`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function edr(e){let t=new Map;for(let n of e.topConsumers){if(n.type===`container`)continue;let e=n.killTarget?.kind===`agent`?n.killTarget.agentId??n.id:n.id;t.has(e)||t.set(e,n)}let n=[];e.host.reasons.filter(e=>e.severity!==`info`).forEach(e=>{n.push({reason:e})}),e.admission.reasons.filter(e=>e.severity!==`info`).forEach(e=>{n.push({reason:e})}),e.services.flatMap(e=>e.reasons.filter(e=>e.severity!==`info`).map(e=>({reason:e}))).forEach(e=>{n.push(e)}),e.agents.forEach(e=>{e.reasons.filter(e=>e.severity!==`info`).forEach(r=>{n.push({reason:r,target:{agentId:e.id,issueId:e.issueId,killConsumer:t.get(e.id)}})})});let r=new Map;for(let e of n){let t=e.reason.code;r.has(t)||r.set(t,[]),r.get(t).push(e)}let i=[];for(let[t,n]of r){let r=n[0],a=r.reason;if(t.startsWith(`agent.`)&&n.length>1){let r=n.map(e=>e.target).filter(e=>e!==void 0),o=r.map(e=>e.agentId),s=o.slice(0,2).join(`, `)+(o.length>2?` +${o.length-2} more`:``);i.push({severity:tdr(a.code,a.severity),code:t,title:Qur(e,a)??t,sub:`${o.length}× agents: ${s}`,agents:o,targets:r})}else{let n=r.target,o=n?.agentId,s=n?.issueId,c=o?s?`${o} · ${s}`:o:Qur(e,a)??t,l=o?`${o} has produced `:void 0,u=l&&a.message.startsWith(l)?a.message.slice(l.length):a.message;i.push({severity:tdr(a.code,a.severity),code:t,title:c,sub:u,agents:o?[o]:[],targets:n?[n]:[],agentId:o,issueId:s,killConsumer:n?.killConsumer})}}return i.sort((e,t)=>{if(e.severity!==t.severity)return e.severity===`critical`?-1:1;let n=e.code===`agent.runtime.inactive.stalled`;return n===(t.code===`agent.runtime.inactive.stalled`)?0:n?-1:1}),i}function tdr(e,t){return e===`agent.runtime.inactive.stalled`||t===`critical`?`critical`:`warning`}function ndr(e,t){let n=t.filter(e=>e.code===`agent.runtime.inactive.stalled`).reduce((e,t)=>e+t.agents.length,0),r=t.filter(e=>e.code===`agent.runtime.inactive.warning`).reduce((e,t)=>e+t.agents.length,0),i=t.filter(e=>e.severity===`warning`).length,a=t.filter(e=>e.severity===`critical`).length,o=Zur(e).length,s=e.host.metrics.memoryUsedPercent==null?`memory unavailable`:`memory at ${e.host.metrics.memoryUsedPercent.toFixed(1)}%`,c=e.admission.availableMemoryBytes==null?`spawn headroom unavailable`:`${$ur(e.admission.availableMemoryBytes)} spawn headroom`,l=e.summary.smeeRelay.configured?e.summary.smeeRelay.running?`relay running`:`relay stopped`:`relay not configured`,u=[`${n} stalled agent${n===1?``:`s`}`,`${r} idle agent${r===1?``:`s`}`,s,c,`${o} context note${o===1?``:`s`}`].join(` · `);return t.length===0?`All clear · ${s} · ${c} · ${l} · ${n} stalled agents · ${r} idle agents · ${o} context note${o===1?``:`s`}`:a>0?`Action required: ${a} critical issue${a===1?``:`s`} · ${u}`:`Attention needed: ${i} warning${i===1?``:`s`} · ${u}`}var rdr=`system-health-popover`,idr=`system-health-popover-title`;function G9(e){let t=e/1024**3;return t>=1?`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function adr(e){switch(e){case`critical`:return`border-destructive/50 bg-destructive/10 text-destructive motion-safe:animate-pulse`;case`warning`:return`border-warning/40 bg-warning/10 text-warning-foreground`;case`unavailable`:return`border-border bg-muted text-muted-foreground`;case`measuring`:return`border-info/40 bg-info/10 text-info`;case`healthy`:return`border-success/40 bg-success/10 text-success`}}function odr(e){switch(e){case`critical`:return`bg-destructive`;case`warning`:return`bg-warning`;case`unavailable`:return`bg-muted-foreground`;case`measuring`:return`bg-info`;case`healthy`:return`bg-success`}}function sdr(e){return e.issueId?`${e.label} · ${e.issueId}`:e.currentIssue?`${e.label} · ${e.currentIssue}`:e.label}function cdr(e){switch(e.type){case`agent`:return`Agent`;case`specialist`:return`Specialist`;case`container`:return`Container`}}function ldr(e){return[...e.host.reasons,...e.admission.reasons,...e.agents.flatMap(e=>e.reasons),...e.services.flatMap(e=>e.reasons)]}function udr(e,t){for(let n of t){let t=Qur(e,n);if(t)return t}return null}function ddr(e,t){switch(e.state){case`measuring`:return`Measuring system health…`;case`healthy`:return e.admission.availableMemoryBytes==null?`Healthy`:`Healthy · ${G9(e.admission.availableMemoryBytes)} available`;case`warning`:return`Warning · ${udr(e,t)??`attention required`}`;case`critical`:return`Critical · ${udr(e,t)??`action required`}`;case`unavailable`:return`Health unavailable · Retry`}}function fdr({state:e}){switch(e){case`measuring`:return(0,z.jsx)(is,{"data-health-icon":`measuring`,"aria-hidden":`true`,className:`h-3.5 w-3.5 animate-spin motion-reduce:animate-none`});case`healthy`:return(0,z.jsx)(vo,{"data-health-icon":`healthy`,"aria-hidden":`true`,className:`h-3.5 w-3.5`});case`warning`:return(0,z.jsx)(Ts,{"data-health-icon":`warning`,"aria-hidden":`true`,className:`h-3.5 w-3.5`});case`critical`:return(0,z.jsx)(wpe,{"data-health-icon":`critical`,"aria-hidden":`true`,className:`h-3.5 w-3.5`});case`unavailable`:return(0,z.jsx)(yo,{"data-health-icon":`unavailable`,"aria-hidden":`true`,className:`h-3.5 w-3.5`})}}function pdr({consumer:e,onSelectLeaked:t}){let n=As(),r=$t(),{confirmAndKill:i,isPending:a}=Xur(e.killTarget?.kind===`agent`?e.killTarget.agentId:void 0,{onSuccess:()=>{e.leaked&&t()}}),o=Cn({mutationFn:async()=>{let t=e.killTarget;if(!t)throw Error(`No kill target available`);if(t.kind===`container`){if(!t.containerId)throw Error(`Missing container id`);let e=await fetch(`/api/resources/docker/container/${t.containerId}`,{method:`DELETE`});if(!e.ok)throw Error(`Failed to remove container`);return e.json()}if(t.kind===`specialist`){if(!t.projectKey||!t.issueId||!t.specialistType)throw Error(`Missing specialist target`);let e=await fetch(`/api/specialists/${t.projectKey}/${t.issueId}/${t.specialistType}/kill`,{method:`POST`});if(!e.ok)throw Error(`Failed to kill specialist`);return e.json()}throw Error(`Unsupported kill target`)},onSuccess:async()=>{await q_(r),await r.invalidateQueries({queryKey:[`system-health`]}),e.leaked&&t()}}),s=a||o.isPending,c=e.killTarget;if(!c)return null;let l=c.kind===`container`?`Remove container ${e.label}`:c.kind===`specialist`?`Kill specialist ${e.label}`:`Kill ${e.label}`,u=async()=>{if(c.kind===`agent`){await i();return}await n({title:c.kind===`container`?`Remove Container`:`Kill Specialist`,message:c.kind===`container`?`Remove Docker container ${e.label}?`:`Kill specialist ${e.label}?`,variant:`destructive`,confirmLabel:c.kind===`container`?`Remove`:`Kill`})&&o.mutate()};return(0,z.jsx)(`button`,{onClick:()=>void u(),disabled:s,className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50`,title:l,children:s?`Killing…`:c.kind===`container`?`Remove`:`Kill`})}function mdr({target:e,onOpen:t,onSelectLeaked:n}){return!e.issueId&&!e.killConsumer?null:(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[e.issueId&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>t(e.issueId),className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Open ${e.issueId}`,children:`Open`}),e.killConsumer&&(0,z.jsx)(pdr,{consumer:e.killConsumer,onSelectLeaked:n})]})}function hdr({compact:e=!1}){let{data:t,isLoading:n,error:r}=twt(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(null),d=(0,L.useCallback)((e=!0)=>{s(!1),a(!1),e&&requestAnimationFrame(()=>u.current?.focus())},[]),f=(0,L.useCallback)(e=>{Wt.getState().openIssue(e),d()},[d]);(0,L.useEffect)(()=>{if(!i)return;let e=e=>{document.querySelector(`[role="alertdialog"]`)||l.current&&!l.current.contains(e.target)&&d()},t=e=>{e.key===`Escape`&&d()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[d,i]);let p=(0,L.useMemo)(()=>t?ldr(t):[],[t]),m=t?ddr(t,p):`Health unavailable · Retry`,h=(0,L.useMemo)(()=>t?edr(t):[],[t]),g=(0,L.useMemo)(()=>t?ndr(t,h):``,[t,h]),_=(0,L.useMemo)(()=>t?Zur(t):[],[t]);(0,L.useEffect)(()=>{if(!t)return;let n=c.current;c.current=t.state,!(e||n==null||n===t.state||t.state!==`critical`)&&B.error(`System health is critical`,{description:p[0]?.message??`Open the health panel to inspect top consumers and agent health.`,duration:1e4,action:{label:`Open`,onClick:()=>{s(t.topConsumers.some(e=>e.leaked)),a(!0)}}})},[e,t,p]);let v=(0,L.useMemo)(()=>{let e=[...t?.topConsumers??[]].sort((e,t)=>Number(t.leaked??!1)-Number(e.leaked??!1));if(!o)return e;let n=e.filter(e=>e.leaked);return n.length>0?n:e},[t?.topConsumers,o]),y=(0,L.useMemo)(()=>v.reduce((e,t)=>Math.max(e,t.memoryGb),1),[v]);if(n)return(0,z.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5 text-xs text-muted-foreground ${e?`justify-center px-1.5`:``}`,"aria-label":`Loading system health`,children:[(0,z.jsx)(is,{"aria-hidden":`true`,className:`h-3.5 w-3.5 animate-spin motion-reduce:animate-none`}),!e&&(0,z.jsx)(`span`,{children:`Health`})]});if(r||!t)return(0,z.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1.5 text-xs text-muted-foreground ${e?`justify-center px-1.5`:``}`,title:r?.message??`Failed to load system health`,"aria-label":`Health unavailable`,children:[(0,z.jsx)(yo,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),!e&&(0,z.jsx)(`span`,{children:`Health unavailable · Retry`})]});let b=t.services.find(e=>e.id===`smee-relay`||e.id===`webhook-relay`),x=b?.status??t.summary.smeeRelay.status,S=x===`not_configured`||!t.summary.smeeRelay.configured&&b===void 0?{label:`Not configured`,classes:`border-border bg-muted/40`,dotClass:`bg-muted-foreground`}:x===`running`?{label:`Running`,classes:`border-success/40 bg-success/10`,dotClass:`bg-success`}:{label:x===`unavailable`?`Unavailable`:`Stopped`,classes:`border-destructive/50 bg-destructive/10`,dotClass:`bg-destructive`};return(0,z.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,z.jsxs)(`button`,{ref:u,type:`button`,onClick:()=>{s(!1),a(e=>!e)},className:`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-xs transition-colors hover:bg-accent ${adr(t.state)} ${e?`justify-center px-1.5`:`justify-between`}`,"data-testid":`system-health-pill`,"aria-label":m,"aria-expanded":i,"aria-controls":rdr,"aria-haspopup":`dialog`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(fdr,{state:t.state}),!e&&(0,z.jsx)(`span`,{children:m})]}),!e&&(0,z.jsx)(po,{"aria-hidden":`true`,className:`h-3.5 w-3.5 transition-transform ${i?`rotate-180`:``}`})]}),i&&!e&&(0,z.jsxs)(`div`,{id:rdr,role:`dialog`,"aria-labelledby":idr,className:`absolute right-0 top-full z-[200] mt-2 w-[min(22rem,calc(100vw-1rem))] max-h-[calc(100vh-1rem)] overflow-auto rounded-xl border border-border bg-popover p-3 text-sm shadow-lg`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,z.jsx)(`span`,{id:idr,className:`font-semibold text-foreground`,children:`System health`}),(0,z.jsxs)(`span`,{role:`status`,"aria-label":`${t.state} system health`,className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize ${adr(t.state)}`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex h-2 w-2 rounded-full ${odr(t.state)}`}),t.state]})]}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Updated `,Math.round((Date.now()-Date.parse(t.updatedAt))/1e3),`s ago`]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>d(),className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Close system health`,children:(0,z.jsx)(Os,{"aria-hidden":`true`,className:`h-4 w-4`})})]}),(0,z.jsx)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/30 p-2 text-sm`,children:(0,z.jsx)(`div`,{className:`text-foreground`,children:g})}),(0,z.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`CPU`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.host.metrics.cpuPercent==null?`Unavailable`:`${t.host.metrics.cpuPercent.toFixed(1)}%`}),(0,z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Load/core `,t.host.metrics.loadPerCore1m==null?`Unavailable`:t.host.metrics.loadPerCore1m.toFixed(2)]}),t.host.metrics.cpuPercent!=null&&(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`CPU usage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.host.metrics.cpuPercent,className:`h-full ${t.host.metrics.cpuPercent<60?`bg-success`:t.host.metrics.cpuPercent<=85?`bg-warning`:`bg-destructive`}`,style:{width:`${Math.min(100,t.host.metrics.cpuPercent)}%`}})})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Memory`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.host.metrics.usedMemoryBytes==null||t.host.metrics.totalMemoryBytes==null?`Unavailable`:`${G9(t.host.metrics.usedMemoryBytes)} / ${G9(t.host.metrics.totalMemoryBytes)}`}),(0,z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Avail `,t.host.metrics.availableMemoryBytes==null?`Unavailable`:G9(t.host.metrics.availableMemoryBytes)]}),t.host.metrics.memoryUsedPercent!=null&&(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`Memory usage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.host.metrics.memoryUsedPercent,className:`h-full ${t.host.metrics.memoryUsedPercent<60?`bg-success`:t.host.metrics.memoryUsedPercent<=85?`bg-warning`:`bg-destructive`}`,style:{width:`${Math.min(100,t.host.metrics.memoryUsedPercent)}%`}})})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Overdeck`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:G9(t.summary.overdeckMemoryBytes)}),(0,z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[t.summary.overdeckMemoryPercent.toFixed(1),`% of host RAM`]}),(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`Overdeck memory share`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.summary.overdeckMemoryPercent,className:`h-full bg-info`,style:{width:`${Math.min(100,t.summary.overdeckMemoryPercent)}%`}})})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Swap `,(0,z.jsx)(`span`,{className:`text-[11px]`,children:`historical · not live pressure`})]}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.host.metrics.swapUsedPercent==null?`Unavailable`:`${t.host.metrics.swapUsedPercent.toFixed(1)}%`}),t.host.metrics.swapUsedPercent!=null&&(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`Swap usage`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.host.metrics.swapUsedPercent,className:`h-full ${t.host.metrics.swapUsedPercent<60?`bg-success`:t.host.metrics.swapUsedPercent<=85?`bg-warning`:`bg-destructive`}`,style:{width:`${Math.min(100,t.host.metrics.swapUsedPercent)}%`}})}),(0,z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`Overcommit `,t.host.metrics.virtualCommitmentPercent==null?`Unavailable`:`${t.host.metrics.virtualCommitmentPercent.toFixed(1)}%`]})]})]}),(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[(0,z.jsxs)(`div`,{role:`group`,className:`flex items-center gap-1 rounded-full border border-border bg-muted/40 px-2 py-1 text-xs text-foreground`,"aria-label":`Admitted work agents: ${t.admission.admittedWorkAgentCount}`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Admitted work agents`}),(0,z.jsx)(`span`,{children:t.admission.admittedWorkAgentCount})]}),(0,z.jsxs)(`div`,{role:`group`,className:`flex items-center gap-1 rounded-full border border-border bg-muted/40 px-2 py-1 text-xs text-foreground`,"aria-label":`Containers: ${t.summary.containerCount}`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Containers`}),(0,z.jsx)(`span`,{children:t.summary.containerCount})]}),(0,z.jsxs)(`div`,{role:`group`,className:`flex items-center gap-1 rounded-full border px-2 py-1 text-xs text-foreground ${S.classes}`,"aria-label":`Webhook relay: ${S.label}`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 rounded-full ${S.dotClass}`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Webhook relay`}),(0,z.jsx)(`span`,{children:S.label})]})]}),(0,z.jsxs)(`div`,{className:`mb-3`,children:[h.length>0?(0,z.jsx)(`div`,{className:`space-y-1 rounded-lg border border-border p-2`,children:h.map(e=>{let t=e.targets.length===1?e.targets[0]:void 0;return(0,z.jsx)(`div`,{className:`text-xs`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`span`,{role:`img`,className:`inline-block h-2 w-2 rounded-full ${e.severity===`critical`?`bg-destructive`:`bg-warning`}`,"aria-label":`${e.severity} attention`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`text-foreground`,children:[e.title,e.agents.length>1&&(0,z.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.agents.length]})]}),(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:e.sub})]})]}),t&&(0,z.jsx)(mdr,{target:t,onOpen:f,onSelectLeaked:()=>s(!0)})]})},`${e.code}-${e.agents.join(`,`)}`)})}):(0,z.jsx)(`div`,{className:`rounded-lg border border-border p-2 text-xs text-foreground`,children:`No active pressure signals.`}),_.length>0&&(0,z.jsxs)(`details`,{className:`mt-2 cursor-pointer text-xs`,children:[(0,z.jsxs)(`summary`,{className:`text-muted-foreground hover:text-foreground`,children:[_.length,` context note`,_.length===1?``:`s`,` — background, not pressure signals`]}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg border border-border p-2`,children:_.map((e,t)=>(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`• `,e.message]},`${e.code}-${t}`))})]})]}),(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Top consumers`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o&&t.summary.leakedSpecialistCount>0&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Show all`}),(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.summary.leakedSpecialistCount>0?`⚠ ${t.summary.leakedSpecialistCount} leaked specialist${t.summary.leakedSpecialistCount===1?``:`s`}`:`No leaks`})]})]}),(0,z.jsx)(`div`,{className:`max-h-72 space-y-2 overflow-auto pr-1`,children:v.map(e=>{let t=e.memoryGb/y*100;return(0,z.jsx)(`div`,{className:`rounded-lg border p-2 ${e.leaked?`border-warning/40 bg-warning/10`:`border-border`}`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:sdr(e)}),(0,z.jsx)(`span`,{role:`note`,className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,"aria-label":`Consumer kind: ${cdr(e)}`,children:cdr(e)}),e.leaked&&(0,z.jsx)(`span`,{className:`rounded bg-warning/20 px-1.5 py-0.5 text-[10px] font-medium text-warning`,children:`LEAKED`})]}),(0,z.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.memoryGb.toFixed(2),` GB`,e.cpuPercent==null?``:` · ${e.cpuPercent.toFixed(1)}% CPU`]}),t>0&&(0,z.jsx)(`div`,{className:`mt-1 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{role:`meter`,"aria-label":`${e.label} memory share: ${t.toFixed(1)}%`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Number(t.toFixed(1)),className:`h-full bg-info`,style:{width:`${t}%`}})})]}),(0,z.jsx)(pdr,{consumer:e,onSelectLeaked:()=>s(!0)})]})},e.id)})})]})]})}async function gdr(){let e=await fetch(`/api/deploy/staleness`);if(!e.ok)throw Error(`Failed to fetch deploy staleness`);let t=await e.json();return w(bt(ine(ane))(t))}function _dr(){return F({queryKey:[`deploy-staleness`],queryFn:gdr,refetchInterval:6e4})}function vdr(e){return e?.slice(0,8)||`unknown`}function ydr(){let{data:e}=_dr();if(e?.status!==`stale`||(e.behindBuildInputs??0)<1)return null;let t=[`Running build ${vdr(e.buildCommit)}`,`origin/main ${vdr(e.originMainSha)}`,`${e.behindTotal??`unknown`} total commit(s) behind`].join(` · `);return(0,z.jsxs)(`span`,{className:`text-[11px] font-medium text-warning-foreground`,title:t,children:[`build stale ×`,e.behindBuildInputs]})}function bdr({activeTab:e,selectedProjectKey:t,runningAgentCount:n,dashboardLifecycle:r,missingKeyTrackers:i,trackerBannerDismissed:a,showCliproxyBanner:o,isRestartBackendPending:s,isRestartCliproxyPending:c,isSessionFeedSidebarOpen:l,onSearchOpen:u,onOpenSettings:d,onDismissTrackerBanner:f,onRestartBackend:p,onRestartCliproxy:m,onToggleSessionFeedSidebar:h,onNavigateNeedsYou:g,onProjectCreated:_}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Clr,{onCreated:_}),(0,z.jsxs)(`div`,{"data-component":`system-notices-row`,className:`flex flex-wrap items-stretch border-b border-border`,children:[(0,z.jsx)(Mur,{}),(0,z.jsx)(Iur,{}),(0,z.jsx)(X5n,{activeTab:e}),(0,z.jsx)(qur,{}),(0,z.jsx)(Yur,{}),(0,z.jsx)(dur,{}),(0,z.jsx)(mur,{}),(0,z.jsx)(gur,{}),(0,z.jsx)(Our,{})]}),(0,z.jsx)(Ilr,{lifecycle:r,onRestartBackend:p,isRestartBackendPending:s}),i.length>0&&!a&&(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b border-warning/30 px-4 py-2 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ts,{className:`w-4 h-4 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm flex-1`,children:[(0,z.jsxs)(`span`,{className:`font-semibold`,children:[`Missing API key`,i.length>1?`s`:``,`:`]}),` `,i.map(e=>(0,z.jsxs)(`span`,{children:[e.name,` (`,(0,z.jsx)(`code`,{className:`font-mono text-xs bg-warning/20 px-1 rounded`,children:e.envVar}),`)`]},e.type)).reduce((e,t,n)=>n===0?[t]:[...e,`, `,t],[]),`.`,` `,(0,z.jsx)(`button`,{onClick:d,className:`underline hover:opacity-80 font-semibold`,children:`Configure in Settings`})]}),(0,z.jsx)(`button`,{onClick:f,className:`text-warning-foreground/60 hover:text-warning-foreground shrink-0`,title:`Dismiss`,children:`✕`})]}),o&&(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ts,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsx)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:`CLIProxy is down — GPT subscription agents will fail.`}),(0,z.jsx)(`button`,{onClick:m,disabled:c,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0`,children:c?`Restarting…`:`Restart CLIProxy`})]}),(0,z.jsxs)(`div`,{className:`relative flex h-12 shrink-0 items-center gap-3 border-b border-border bg-background px-3`,children:[(0,z.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 text-sm font-semibold text-foreground`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`h-3.5 w-3.5 rounded-[4px] bg-primary/40`,"aria-hidden":`true`}),t]}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`All projects`})}),(0,z.jsxs)(`button`,{type:`button`,onClick:u,className:`mx-auto flex w-full min-w-0 max-w-md items-center gap-2 rounded-lg border border-border px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent`,title:`Search`,children:[(0,z.jsx)(gs,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,children:t?`Search ${t}…`:`Search issues, conversations, commands…`}),(0,z.jsx)(`kbd`,{className:`ml-auto rounded border border-border px-1.5 text-[11px]`,children:`/`})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,z.jsx)(DQt,{compact:!0}),(0,z.jsx)(lur,{}),n>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:T_e,title:`Emergency stop — kill all agents and freeze auto-resume (${C_e})`,"aria-label":`Emergency stop all agents`,className:`inline-flex items-center gap-1.5 rounded-full border border-destructive/40 bg-destructive/10 px-2.5 py-1 text-xs font-medium text-destructive hover:bg-destructive/20 transition-colors`,children:[(0,z.jsx)(bo,{className:`h-3.5 w-3.5`}),` Stop all`]}),(0,z.jsx)(cur,{variant:`pill`}),(0,z.jsx)(Rlr,{onOpenSettings:d}),(0,z.jsx)(ydr,{}),(0,z.jsx)(Vur,{}),(0,z.jsx)(hdr,{}),(0,z.jsx)(Blr,{}),(0,z.jsx)(Vlr,{onActivate:g}),(0,z.jsx)(Zlr,{onOpenSettings:d}),e!==`command-deck`&&(0,z.jsx)(`button`,{type:`button`,"aria-label":`Toggle activity feed`,"aria-pressed":l,title:`Activity Feed`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,onClick:h,children:(0,z.jsx)(Xo,{className:`h-4 w-4`,"aria-hidden":`true`})})]})]})]})}function K9(e,t){return`${e}::${t.signature??`unanswerable:${t.agentKey??`unknown`}`}`}function xdr(e,t){let n=$t(),[r,i]=(0,L.useState)(()=>new Set),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(null),d=e.filter(e=>e.pendingPermission!=null).map(e=>({conversationName:e.name,title:e.title??null,pendingPermission:e.pendingPermission})).filter(e=>!r.has(K9(e.conversationName,e.pendingPermission))).sort((e,t)=>e.pendingPermission.since.localeCompare(t.pendingPermission.since)),f=d.find(e=>K9(e.conversationName,e.pendingPermission)===a)??d.find(e=>e.conversationName===l)??d[0]??null,p=d.map(e=>K9(e.conversationName,e.pendingPermission)).join(`
1608
1608
  `);(0,L.useEffect)(()=>{a&&!p.split(`
1609
- `).includes(a)&&o(null)},[a,p]);let m=(0,L.useCallback)(()=>n.invalidateQueries({queryKey:[`conv-ask-user-question`]}),[n]),h=(0,L.useCallback)(async e=>{let t=f?.pendingPermission.signature;if(f&&t){c(!0);try{let n=await Eht(f.conversationName,t,e);n.ok?o(K9(f.conversationName,f.pendingPermission)):n.code===`delivery-unconfirmed`?B.warning(`The keys were sent but the prompt is still up — answer it in the terminal`):n.code===`prompt-changed`||n.code===`prompt-gone`?B.info(`The permission prompt changed — review it again`):B.error(n.error??`Failed to answer the permission prompt (${n.status})`)}catch(e){B.error(e instanceof Error?e.message:`Failed to answer the permission prompt`)}finally{c(!1),m()}}},[m,f]),g=(0,L.useCallback)(()=>{if(!f)return;let e=K9(f.conversationName,f.pendingPermission);i(t=>new Set(t).add(e))},[f]),_=(0,L.useCallback)(()=>{f&&(g(),GE({id:f.conversationName,source:`conversation`,view:`terminal`}))},[g,f]);return{focus:(0,L.useCallback)(e=>{u(e),i(t=>new Set([...t].filter(t=>!t.startsWith(`${e}::`))))},[]),subject:f,isOpen:f!==null&&!t,isSubmitting:s,confirming:f!==null&&a===K9(f.conversationName,f.pendingPermission),onAnswer:e=>{h(e)},onOpenTerminal:_,onDismiss:g}}function xdr(e,t,n,r){if(B.info(t,{description:n,duration:12e3,action:{label:`Answer`,onClick:r}}),typeof window<`u`&&`Notification`in window&&Notification.permission===`granted`)try{let i=new Notification(t,{body:n,tag:e});i.onclick=()=>{window.focus(),r(),i.close()}}catch{}}var Sdr=[3e5,18e5];function Cdr(e,t){let n=(0,L.useRef)(new Map),r=(0,L.useRef)(t);r.current=t,(0,L.useEffect)(()=>{let t=new Set;for(let i of e){let e=i.pendingPermission;if(!e)continue;let a=`conv-perm::${i.name}::${e.signature??`unanswerable`}`;if(t.add(a),n.current.has(a))continue;let o=`Permission needed`,s=[i.title??i.name,e.agentLabel,e.toolName].filter(Boolean).join(` · `),c=()=>r.current(i.name);xdr(a,o,s,c);let l=Date.parse(e.since),u=[];for(let e of Sdr){let t=(Number.isNaN(l)?Date.now():l)+e-Date.now();t<=0||u.push(setTimeout(()=>{xdr(`${a}::${e}`,o,`Still waiting · ${s}`,c)},t))}n.current.set(a,u)}for(let[e,r]of n.current)t.has(e)||(r.forEach(clearTimeout),n.current.delete(e))},[e]),(0,L.useEffect)(()=>{let e=n.current;return()=>{for(let t of e.values())t.forEach(clearTimeout);e.clear()}},[])}function wdr(){let{data:e=[],dataUpdatedAt:t}=F({queryKey:[`conv-ask-user-question`],queryFn:({signal:e})=>hS(e),refetchInterval:4e3}),n=xv(e=>e.byConversation),r=xv(e=>e.releaseHeld);(0,L.useEffect)(()=>{let i=new Set((Array.isArray(e)?e:[]).filter(e=>e.pendingPermission?.answerable).map(e=>e.name));for(let[e,a]of Object.entries(n)){let n=a.optimistic.filter(e=>e.deliveryState===`held`);if(n.length===0||i.has(e))continue;let o=Math.max(...n.map(e=>e.heldAt??0));t<=o||r(e)}},[n,t,r,e])}function Tdr({agents:e,issues:t}){let n=$t(),r=Wt(Ree),i=Wt(Ote),a=Wt(Tee),o=sp(e=>e.resolvedPlanToolUseIds),s=sp(e=>e.dismissedPlanSubjectIds),c=sp(e=>e.markPlanResolved),l=sp(e=>e.unmarkPlanResolved),u=sp(e=>e.markPlanDismissed),d=sp(e=>e.undismissPlan),f=sp(e=>e.reconcilePlanResolved),p=sp(e=>e.reconcilePlanDismissed),[m,h]=(0,L.useState)(null),g=sp(e=>e.answeredToolUseIds),_=sp(e=>e.dismissedSubjectIds),v=sp(e=>e.markAnswered),y=sp(e=>e.unmarkAnswered),b=sp(e=>e.markDismissed),x=sp(e=>e.undismiss),S=sp(e=>e.reconcileAnswered),C=sp(e=>e.reconcileDismissed),w=sp(e=>e.reopenId),T=sp(e=>e.reopenNonce),E=sp(e=>e.requestReopen),[D,O]=(0,L.useState)(new Set),[k,A]=(0,L.useState)(null),[j,ee]=(0,L.useState)(null),M=(0,L.useRef)([]),N=(0,L.useRef)(()=>{});(0,L.useEffect)(()=>{if(!w)return;let e=Wt.getState().agentsById[w],t=e!=null,n=M.current.find(e=>e.name===w);if(n?.pendingPermission){N.current(w);return}let r=e?.pendingAskUserQuestion!=null||n?.pendingAskUserQuestion!=null,i=e?.pendingProposedPlan!=null||n?.pendingProposedPlan!=null;if(!r&&i){d(w),h(w);return}let a=(e?.pendingInputKinds?.length??0)>0||Jee(e),o=e?.pendingAskUserQuestion!=null||a;x(w),A(w),t&&!o?B.info(`That question is no longer waiting`,{description:`The agent stopped or already received an answer.`}):t&&e?.pendingAskUserQuestion==null&&a&&B.info(`This agent is blocked on a terminal dialog`,{description:`Open its terminal to answer (e.g. a tool-permission, rate-limit, or session-resume prompt) — it cannot be answered from here yet.`})},[T]);let P=r.filter(e=>!D.has(e.requestId))[0]??null,te=P?.issueId??e.find(e=>e.id===P?.agentId)?.issueId,{data:ne=[]}=F({queryKey:[`conv-ask-user-question`],queryFn:async({signal:e})=>{let t=await Is(`/api/conversations/pending-input`,{signal:e});return t.ok?t.json():[]},refetchInterval:4e3,refetchIntervalInBackground:!0});M.current=ne;let{focus:re,...ie}=bdr(ne,P!==null);N.current=re,Cdr(ne,E),wdr();let ae=[...a.map(e=>({kind:`agent`,id:e.id,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Agent`,title:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,pendingProposedPlan:e.pendingProposedPlan,askedAt:e.pendingProposedPlan?.askedAt??``})),...ne.filter(e=>e.pendingProposedPlan).map(e=>({kind:`conv`,id:e.name,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Conversation`,title:e.title??null,pendingProposedPlan:e.pendingProposedPlan,askedAt:e.pendingProposedPlan?.askedAt??``}))];ae.sort((e,t)=>e.askedAt===t.askedAt?e.id.localeCompare(t.id):e.askedAt.localeCompare(t.askedAt));let oe=ae.filter(e=>{let t=e.pendingProposedPlan?.toolUseId;return!(!t||o.has(t)||s.has(e.id))}),se=(m?oe.find(e=>e.id===m):void 0)??oe[0]??null,ce=[...i.map(e=>({kind:`agent`,id:e.id,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Agent`,title:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``})),...ne.map(e=>({kind:`conv`,id:e.name,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Conversation`,title:e.title??null,harness:e.harness??null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``}))];ce.sort((e,t)=>e.askedAt===t.askedAt?e.id.localeCompare(t.id):e.askedAt.localeCompare(t.askedAt));let le=ce.filter(e=>{let t=e.pendingAskUserQuestion?.toolUseId;return!(!t||g.has(t)||_.has(e.id))}),ue=(k?le.find(e=>e.id===k):void 0)??le[0]??null;(0,L.useEffect)(()=>{O(e=>{let t=new Set,n=new Set(r.map(e=>e.requestId));for(let r of e)n.has(r)&&t.add(r);return t.size===e.size&&Array.from(t).every(t=>e.has(t))?e:t})},[r]);let{data:de=[]}=F({queryKey:[`confirmations`],queryFn:Cht,refetchInterval:1e4});(0,L.useEffect)(()=>{de.length>0&&!j&&ee(de[0])},[de,j]),(0,L.useEffect)(()=>{if(typeof window<`u`&&`Notification`in window&&Notification.permission==="default"){let e=()=>{Notification.requestPermission().catch(()=>{}),window.removeEventListener(`pointerdown`,e)};return window.addEventListener(`pointerdown`,e,{once:!0}),()=>{window.removeEventListener(`pointerdown`,e)}}},[]);let fe=(0,L.useRef)(new Set);(0,L.useEffect)(()=>{let e=(e,t,n,r)=>{let i=e;fe.current.has(i)||(fe.current.add(i),xdr(i,n,r,()=>E(t)))};for(let n of i){let r=n.pendingAskUserQuestion?.toolUseId;if(!r)continue;let i=n.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,a=(n.issueId?t.find(e=>e.id===n.issueId)?.title:void 0)??n.issueId??n.id;e(`agent::${n.id}::${r}`,n.id,`${a} is waiting on you`,i)}for(let t of ne){let n=t.pendingAskUserQuestion?.toolUseId;if(!n)continue;let r=t.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,i=t.title??t.name;e(`conv::${t.name}::${n}`,t.name,`"${i}" is waiting on you`,r)}for(let n of a){let r=n.pendingProposedPlan?.toolUseId;if(!r)continue;let i=(n.issueId?t.find(e=>e.id===n.issueId)?.title:void 0)??n.issueId??n.id;e(`agent-plan::${n.id}::${r}`,n.id,`${i} has a plan awaiting approval`,`Review and approve the plan to start implementation.`)}for(let t of ne){let n=t.pendingProposedPlan?.toolUseId;if(!n)continue;let r=t.title??t.name;e(`conv-plan::${t.name}::${n}`,t.name,`"${r}" has a plan awaiting approval`,`Review and approve the plan to start implementation.`)}let n=new Set;for(let e of i){let t=e.pendingAskUserQuestion?.toolUseId;t&&n.add(`agent::${e.id}::${t}`)}for(let e of ne){let t=e.pendingAskUserQuestion?.toolUseId;t&&n.add(`conv::${e.name}::${t}`);let r=e.pendingProposedPlan?.toolUseId;r&&n.add(`conv-plan::${e.name}::${r}`)}for(let e of a){let t=e.pendingProposedPlan?.toolUseId;t&&n.add(`agent-plan::${e.id}::${t}`)}for(let e of fe.current)n.has(e)||fe.current.delete(e)},[i,a,ne,t]);let pe=Cn({mutationFn:async({kind:e,id:t,answers:n,questions:r,harness:i,toolUseId:a})=>{if(e===`agent`){let e=await Is(`/api/agents/${encodeURIComponent(t)}/answer-question`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answers:n,toolUseId:a})});if(!e.ok){let t=`Failed to deliver answer (${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}throw Error(t)}return e.json()}if(i===`ohmypi`||i===`pi`){let e=await Is(`/api/conversations/${encodeURIComponent(t)}/pi-ask-answer`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({toolUseId:a,answers:n})});if(!e.ok){let t=`Failed to deliver answer (${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}throw Error(t)}return e.json()}let o=[],s=r??[];for(let e=0;e<n.length&&e<s.length;e++){let t=s[e]?.question??`Question ${e+1}`;o.push(`Q: ${t}\nA: ${n[e]}`)}let c=`Operator answered the pending question${n.length>1?`s`:``}:\n\n${o.join(`
1609
+ `).includes(a)&&o(null)},[a,p]);let m=(0,L.useCallback)(()=>n.invalidateQueries({queryKey:[`conv-ask-user-question`]}),[n]),h=(0,L.useCallback)(async e=>{let t=f?.pendingPermission.signature;if(f&&t){c(!0);try{let n=await Eht(f.conversationName,t,e);n.ok?o(K9(f.conversationName,f.pendingPermission)):n.code===`delivery-unconfirmed`?B.warning(`The keys were sent but the prompt is still up — answer it in the terminal`):n.code===`prompt-changed`||n.code===`prompt-gone`?B.info(`The permission prompt changed — review it again`):B.error(n.error??`Failed to answer the permission prompt (${n.status})`)}catch(e){B.error(e instanceof Error?e.message:`Failed to answer the permission prompt`)}finally{c(!1),m()}}},[m,f]),g=(0,L.useCallback)(()=>{if(!f)return;let e=K9(f.conversationName,f.pendingPermission);i(t=>new Set(t).add(e))},[f]),_=(0,L.useCallback)(()=>{f&&(g(),GE({id:f.conversationName,source:`conversation`,view:`terminal`}))},[g,f]);return{focus:(0,L.useCallback)(e=>{u(e),i(t=>new Set([...t].filter(t=>!t.startsWith(`${e}::`))))},[]),subject:f,isOpen:f!==null&&!t,isSubmitting:s,confirming:f!==null&&a===K9(f.conversationName,f.pendingPermission),onAnswer:e=>{h(e)},onOpenTerminal:_,onDismiss:g}}function Sdr(e,t,n,r){if(B.info(t,{description:n,duration:12e3,action:{label:`Answer`,onClick:r}}),typeof window<`u`&&`Notification`in window&&Notification.permission===`granted`)try{let i=new Notification(t,{body:n,tag:e});i.onclick=()=>{window.focus(),r(),i.close()}}catch{}}var Cdr=[3e5,18e5];function wdr(e,t){let n=(0,L.useRef)(new Map),r=(0,L.useRef)(t);r.current=t,(0,L.useEffect)(()=>{let t=new Set;for(let i of e){let e=i.pendingPermission;if(!e)continue;let a=`conv-perm::${i.name}::${e.signature??`unanswerable`}`;if(t.add(a),n.current.has(a))continue;let o=`Permission needed`,s=[i.title??i.name,e.agentLabel,e.toolName].filter(Boolean).join(` · `),c=()=>r.current(i.name);Sdr(a,o,s,c);let l=Date.parse(e.since),u=[];for(let e of Cdr){let t=(Number.isNaN(l)?Date.now():l)+e-Date.now();t<=0||u.push(setTimeout(()=>{Sdr(`${a}::${e}`,o,`Still waiting · ${s}`,c)},t))}n.current.set(a,u)}for(let[e,r]of n.current)t.has(e)||(r.forEach(clearTimeout),n.current.delete(e))},[e]),(0,L.useEffect)(()=>{let e=n.current;return()=>{for(let t of e.values())t.forEach(clearTimeout);e.clear()}},[])}function Tdr(){let{data:e=[],dataUpdatedAt:t}=F({queryKey:[`conv-ask-user-question`],queryFn:({signal:e})=>hS(e),refetchInterval:4e3}),n=xv(e=>e.byConversation),r=xv(e=>e.releaseHeld);(0,L.useEffect)(()=>{let i=new Set((Array.isArray(e)?e:[]).filter(e=>e.pendingPermission?.answerable).map(e=>e.name));for(let[e,a]of Object.entries(n)){let n=a.optimistic.filter(e=>e.deliveryState===`held`);if(n.length===0||i.has(e))continue;let o=Math.max(...n.map(e=>e.heldAt??0));t<=o||r(e)}},[n,t,r,e])}function Edr({agents:e,issues:t}){let n=$t(),r=Wt(Ree),i=Wt(Ote),a=Wt(Tee),o=sp(e=>e.resolvedPlanToolUseIds),s=sp(e=>e.dismissedPlanSubjectIds),c=sp(e=>e.markPlanResolved),l=sp(e=>e.unmarkPlanResolved),u=sp(e=>e.markPlanDismissed),d=sp(e=>e.undismissPlan),f=sp(e=>e.reconcilePlanResolved),p=sp(e=>e.reconcilePlanDismissed),[m,h]=(0,L.useState)(null),g=sp(e=>e.answeredToolUseIds),_=sp(e=>e.dismissedSubjectIds),v=sp(e=>e.markAnswered),y=sp(e=>e.unmarkAnswered),b=sp(e=>e.markDismissed),x=sp(e=>e.undismiss),S=sp(e=>e.reconcileAnswered),C=sp(e=>e.reconcileDismissed),w=sp(e=>e.reopenId),T=sp(e=>e.reopenNonce),E=sp(e=>e.requestReopen),[D,O]=(0,L.useState)(new Set),[k,A]=(0,L.useState)(null),[j,ee]=(0,L.useState)(null),M=(0,L.useRef)([]),N=(0,L.useRef)(()=>{});(0,L.useEffect)(()=>{if(!w)return;let e=Wt.getState().agentsById[w],t=e!=null,n=M.current.find(e=>e.name===w);if(n?.pendingPermission){N.current(w);return}let r=e?.pendingAskUserQuestion!=null||n?.pendingAskUserQuestion!=null,i=e?.pendingProposedPlan!=null||n?.pendingProposedPlan!=null;if(!r&&i){d(w),h(w);return}let a=(e?.pendingInputKinds?.length??0)>0||Jee(e),o=e?.pendingAskUserQuestion!=null||a;x(w),A(w),t&&!o?B.info(`That question is no longer waiting`,{description:`The agent stopped or already received an answer.`}):t&&e?.pendingAskUserQuestion==null&&a&&B.info(`This agent is blocked on a terminal dialog`,{description:`Open its terminal to answer (e.g. a tool-permission, rate-limit, or session-resume prompt) — it cannot be answered from here yet.`})},[T]);let P=r.filter(e=>!D.has(e.requestId))[0]??null,te=P?.issueId??e.find(e=>e.id===P?.agentId)?.issueId,{data:ne=[]}=F({queryKey:[`conv-ask-user-question`],queryFn:async({signal:e})=>{let t=await Is(`/api/conversations/pending-input`,{signal:e});return t.ok?t.json():[]},refetchInterval:4e3,refetchIntervalInBackground:!0});M.current=ne;let{focus:re,...ie}=xdr(ne,P!==null);N.current=re,wdr(ne,E),Tdr();let ae=[...a.map(e=>({kind:`agent`,id:e.id,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Agent`,title:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,pendingProposedPlan:e.pendingProposedPlan,askedAt:e.pendingProposedPlan?.askedAt??``})),...ne.filter(e=>e.pendingProposedPlan).map(e=>({kind:`conv`,id:e.name,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Conversation`,title:e.title??null,pendingProposedPlan:e.pendingProposedPlan,askedAt:e.pendingProposedPlan?.askedAt??``}))];ae.sort((e,t)=>e.askedAt===t.askedAt?e.id.localeCompare(t.id):e.askedAt.localeCompare(t.askedAt));let oe=ae.filter(e=>{let t=e.pendingProposedPlan?.toolUseId;return!(!t||o.has(t)||s.has(e.id))}),se=(m?oe.find(e=>e.id===m):void 0)??oe[0]??null,ce=[...i.map(e=>({kind:`agent`,id:e.id,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Agent`,title:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``})),...ne.map(e=>({kind:`conv`,id:e.name,issueId:e.issueId??null,issueTitle:e.issueId?t.find(t=>t.id===e.issueId)?.title??null:null,kindLabel:`Conversation`,title:e.title??null,harness:e.harness??null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``}))];ce.sort((e,t)=>e.askedAt===t.askedAt?e.id.localeCompare(t.id):e.askedAt.localeCompare(t.askedAt));let le=ce.filter(e=>{let t=e.pendingAskUserQuestion?.toolUseId;return!(!t||g.has(t)||_.has(e.id))}),ue=(k?le.find(e=>e.id===k):void 0)??le[0]??null;(0,L.useEffect)(()=>{O(e=>{let t=new Set,n=new Set(r.map(e=>e.requestId));for(let r of e)n.has(r)&&t.add(r);return t.size===e.size&&Array.from(t).every(t=>e.has(t))?e:t})},[r]);let{data:de=[]}=F({queryKey:[`confirmations`],queryFn:Cht,refetchInterval:1e4});(0,L.useEffect)(()=>{de.length>0&&!j&&ee(de[0])},[de,j]),(0,L.useEffect)(()=>{if(typeof window<`u`&&`Notification`in window&&Notification.permission==="default"){let e=()=>{Notification.requestPermission().catch(()=>{}),window.removeEventListener(`pointerdown`,e)};return window.addEventListener(`pointerdown`,e,{once:!0}),()=>{window.removeEventListener(`pointerdown`,e)}}},[]);let fe=(0,L.useRef)(new Set);(0,L.useEffect)(()=>{let e=(e,t,n,r)=>{let i=e;fe.current.has(i)||(fe.current.add(i),Sdr(i,n,r,()=>E(t)))};for(let n of i){let r=n.pendingAskUserQuestion?.toolUseId;if(!r)continue;let i=n.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,a=(n.issueId?t.find(e=>e.id===n.issueId)?.title:void 0)??n.issueId??n.id;e(`agent::${n.id}::${r}`,n.id,`${a} is waiting on you`,i)}for(let t of ne){let n=t.pendingAskUserQuestion?.toolUseId;if(!n)continue;let r=t.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,i=t.title??t.name;e(`conv::${t.name}::${n}`,t.name,`"${i}" is waiting on you`,r)}for(let n of a){let r=n.pendingProposedPlan?.toolUseId;if(!r)continue;let i=(n.issueId?t.find(e=>e.id===n.issueId)?.title:void 0)??n.issueId??n.id;e(`agent-plan::${n.id}::${r}`,n.id,`${i} has a plan awaiting approval`,`Review and approve the plan to start implementation.`)}for(let t of ne){let n=t.pendingProposedPlan?.toolUseId;if(!n)continue;let r=t.title??t.name;e(`conv-plan::${t.name}::${n}`,t.name,`"${r}" has a plan awaiting approval`,`Review and approve the plan to start implementation.`)}let n=new Set;for(let e of i){let t=e.pendingAskUserQuestion?.toolUseId;t&&n.add(`agent::${e.id}::${t}`)}for(let e of ne){let t=e.pendingAskUserQuestion?.toolUseId;t&&n.add(`conv::${e.name}::${t}`);let r=e.pendingProposedPlan?.toolUseId;r&&n.add(`conv-plan::${e.name}::${r}`)}for(let e of a){let t=e.pendingProposedPlan?.toolUseId;t&&n.add(`agent-plan::${e.id}::${t}`)}for(let e of fe.current)n.has(e)||fe.current.delete(e)},[i,a,ne,t]);let pe=Cn({mutationFn:async({kind:e,id:t,answers:n,questions:r,harness:i,toolUseId:a})=>{if(e===`agent`){let e=await Is(`/api/agents/${encodeURIComponent(t)}/answer-question`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answers:n,toolUseId:a})});if(!e.ok){let t=`Failed to deliver answer (${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}throw Error(t)}return e.json()}if(i===`ohmypi`||i===`pi`){let e=await Is(`/api/conversations/${encodeURIComponent(t)}/pi-ask-answer`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({toolUseId:a,answers:n})});if(!e.ok){let t=`Failed to deliver answer (${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}throw Error(t)}return e.json()}let o=[],s=r??[];for(let e=0;e<n.length&&e<s.length;e++){let t=s[e]?.question??`Question ${e+1}`;o.push(`Q: ${t}\nA: ${n[e]}`)}let c=`Operator answered the pending question${n.length>1?`s`:``}:\n\n${o.join(`
1610
1610
 
1611
- `)}`,l=await Is(`/api/conversations/${encodeURIComponent(t)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:c})});if(!l.ok){let e=`Failed to deliver answer (${l.status})`;try{let t=await l.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return l.json()},onMutate:e=>{let t=ue?.pendingAskUserQuestion?.toolUseId;return t&&v(t),{subjectId:e.id,toolUseId:t}},onSuccess:(e,t)=>{B.success(`Answer delivered to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&y(n.toolUseId),B.error(`Failed to deliver answer: ${e.message}`)}}),me=Cn({mutationFn:async({id:e,optionNumber:t,toolUseId:n})=>{let r=await Is(`/api/conversations/${encodeURIComponent(e)}/codex-approval`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({optionNumber:t,toolUseId:n})});if(!r.ok){let e=`Failed to send approval (${r.status})`;try{let t=await r.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return r.json()},onMutate:({toolUseId:e})=>(e&&v(e),{toolUseId:e}),onSuccess:(e,t)=>{B.success(`Approval sent to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&y(n.toolUseId),B.error(`Failed to send approval: ${e.message}`)}}),he=(0,L.useCallback)(e=>{if(!ue)return;let t=ue,n=t.pendingAskUserQuestion?.toolUseId;if(n?.startsWith(`codex-approval:`)){let r=/^\s*(\d+)/.exec(e[0]??``),i=r?Number(r[1]):NaN;if(!Number.isInteger(i)){B.error(`Could not determine which option was selected`);return}me.mutate({id:t.id,optionNumber:i,label:t.title?.trim()||t.id,toolUseId:n});return}pe.mutate({kind:t.kind??`agent`,id:t.id,label:t.title?.trim()||t.id,answers:e,questions:t.pendingAskUserQuestion?.questions,harness:t.harness??null,toolUseId:t.pendingAskUserQuestion?.toolUseId})},[pe,me,ue]),ge=(0,L.useCallback)(()=>{ue&&b(ue.id)},[ue,b]),_e=Cn({mutationFn:async({kind:e,id:t,action:n,feedback:r})=>{let i=await Is(e===`agent`?`/api/agents/${encodeURIComponent(t)}/plan-action`:`/api/conversations/${encodeURIComponent(t)}/plan-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:n,feedback:r})});if(!i.ok){let e=`Failed to deliver plan action (${i.status})`;try{let t=await i.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return i.json()},onMutate:({toolUseId:e})=>(e&&c(e),{toolUseId:e}),onSuccess:(e,t)=>{B.success(t.action===`approve-manual`?`Plan approved for ${t.label?.trim()||t.id}`:`Plan feedback sent to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&l(n.toolUseId),B.error(`Plan action failed: ${e.message}`)}}),ve=(0,L.useCallback)(()=>{if(!se)return;let e=se;_e.mutate({kind:e.kind,id:e.id,label:e.title?.trim()||e.issueId||e.id,action:`approve-manual`,toolUseId:e.pendingProposedPlan?.toolUseId})},[se,_e]),ye=(0,L.useCallback)(e=>{if(!se)return;let t=se;_e.mutate({kind:t.kind,id:t.id,label:t.title?.trim()||t.issueId||t.id,action:`reject-feedback`,feedback:e,toolUseId:t.pendingProposedPlan?.toolUseId})},[se,_e]),be=(0,L.useCallback)(()=>{se&&(u(se.id),h(e=>e===se.id?null:e))},[se,u]);(0,L.useEffect)(()=>{let e=i.map(e=>e.pendingAskUserQuestion?.toolUseId).filter(e=>typeof e==`string`),t=ne.map(e=>e.pendingAskUserQuestion?.toolUseId).filter(e=>typeof e==`string`),n=new Set([...e,...t]);S(n);let r=new Set([...i.map(e=>e.id),...ne.map(e=>e.name)]);C(r),A(e=>e&&r.has(e)?e:null);let o=new Set([...a.map(e=>e.pendingProposedPlan?.toolUseId).filter(e=>typeof e==`string`),...ne.map(e=>e.pendingProposedPlan?.toolUseId).filter(e=>typeof e==`string`)]);f(o);let s=new Set([...a.map(e=>e.id),...ne.filter(e=>e.pendingProposedPlan).map(e=>e.name)]);p(s),h(e=>e&&s.has(e)?e:null)},[i,a,ne,S,C,f,p]);let xe=Cn({mutationFn:({agentId:e,requestId:t,behavior:n})=>Tht(e,t,n),onMutate:async e=>{O(t=>{let n=new Set(t);return n.add(e.requestId),n})},onSuccess:async(e,t)=>{await q_(n),B.success(t.behavior===`allow`?`Allowed ${t.agentId} to continue`:`Denied permission request for ${t.agentId}`)},onError:(e,t)=>{O(e=>{if(!e.has(t.requestId))return e;let n=new Set(e);return n.delete(t.requestId),n}),B.error(`Permission response failed: ${e.message}`)}}),Se=(0,L.useCallback)(async()=>{if(j)try{await wht(j.id,!0),ee(null)}catch(e){console.error(`Failed to confirm:`,e)}},[j]),Ce=(0,L.useCallback)(async()=>{if(j)try{await wht(j.id,!1),ee(null)}catch(e){console.error(`Failed to deny:`,e)}},[j]),we=(0,L.useCallback)(()=>{P&&xe.mutate({agentId:P.agentId,requestId:P.requestId,behavior:`allow`})},[xe,P]),Te=(0,L.useCallback)(()=>{P&&xe.mutate({agentId:P.agentId,requestId:P.requestId,behavior:`deny`})},[xe,P]),Ee=(0,L.useCallback)(()=>{ee(null)},[]);return{currentChannelPermissionRequest:P,currentChannelPermissionIssueId:te,isChannelPermissionSubmitting:xe.isPending,handleAllowChannelPermission:we,handleDenyChannelPermission:Te,terminalPermissionDialog:ie,currentAskUserQuestionSubject:ie.isOpen?null:ue,isAskUserQuestionSubmitting:pe.isPending||me.isPending,handleSubmitAskUserQuestion:he,handleDismissAskUserQuestion:ge,currentPlanApprovalSubject:ie.isOpen?null:se,isPlanActionSubmitting:_e.isPending,handleApprovePlan:ve,handleRequestPlanChanges:ye,handleDismissPlanApproval:be,currentConfirmation:j,handleConfirm:Se,handleDeny:Ce,handleCloseConfirmation:Ee}}function Edr(){let e=Wt(e=>e.recentActivity),t=(0,L.useRef)(new Set),n=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(Array.isArray(e)){if(!n.current){for(let n of e)n?.id&&t.current.add(n.id);n.current=!0;return}for(let n of e)if(n?.desktop&&n.id&&!t.current.has(n.id)&&(t.current.add(n.id),typeof window<`u`&&`Notification`in window&&Notification.permission===`granted`))try{let e=new Notification(`Overdeck`,{body:n.message??`Overdeck notification`,tag:n.id});e.onclick=()=>{window.focus(),e.close()}}catch{}}},[e])}var Ddr=`overdeck.ui.sessionFeedSidebarOpen`;function Odr(){if(typeof window>`u`)return!0;let e=window.localStorage.getItem(Ddr);return e===null||e===`true`}function kdr(){let e=Wt(e=>e.tasksViewerIssueId),t=Wt(e=>e.closeTasksViewer);return e?(0,z.jsx)(Xmt,{issueId:e,isOpen:!0,onClose:t}):null}function Adr(){let e=Wt(e=>e.prdViewerIssueId),t=Wt(e=>e.closePrdViewer);return e?(0,z.jsx)(Zmt,{issueId:e,onClose:t}):null}function jdr(){(0,L.useEffect)(()=>{},[]);let e=window.location.pathname,t=new URLSearchParams(window.location.search).get(`terminal`);if(e.startsWith(`/terminal/`)||t){let n=e.startsWith(`/terminal/`)?e.replace(`/terminal/`,``):t,r=new URLSearchParams(window.location.search).get(`token`)??void 0;return(0,z.jsx)(ngt,{sessionName:n,token:r})}let n=e.match(/^\/popout\/conversation\/([^/]+)$/);if(n)return(0,z.jsx)(rgt,{conversationId:n[1]});if(e===`/popout/flywheel-conversation`)return(0,z.jsx)(agt,{});if(e===`/popout/diff`)return(0,z.jsx)(igt,{});let[r,i]=(0,L.useState)(()=>Kht().tab),[,a]=(0,L.useState)(()=>{let e=window.location.hash;return e.startsWith(`#agent=`)?decodeURIComponent(e.slice(7)):null}),o=(0,L.useCallback)(e=>{a(e),e?window.history.replaceState(null,``,`${window.location.pathname}#agent=${encodeURIComponent(e)}`):window.history.replaceState(null,``,window.location.pathname)},[]);ZE(),(0,L.useEffect)(()=>{let e=()=>{let e=window.location.hash;e.startsWith(`#agent=`)&&a(decodeURIComponent(e.slice(7)))};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let s=Kht(),c=Pht(),l=Fht(),u=Hht(),[d,f]=(0,L.useState)(()=>s.convId),[p,m]=(0,L.useState)(()=>c?.project??l),[h,g]=(0,L.useState)(()=>s.viewMode),[_,v]=(0,L.useState)(()=>s.viewModes),[y,b]=(0,L.useState)(()=>c),[x,S]=(0,L.useState)(()=>Iht()),C=(0,L.useRef)(c?`/command-deck/${encodeURIComponent(c.project)}/${encodeURIComponent(c.issue)}`:l?`/command-deck/${encodeURIComponent(l)}`:`/command-deck`),w=(0,L.useCallback)((e,t=`conversation`,n=!0)=>{f(e),g(e?t:`conversation`),v(r=>{let i={...r};return e&&t===`terminal`?i[e]=`terminal`:e&&delete i[e],n&&window.history.replaceState(null,``,e?qht(e,t,r):C.current),i})},[]),T=(0,L.useCallback)(e=>{let t=e?_[e]??`conversation`:`conversation`;w(e,t)},[_,w]),E=(0,L.useCallback)(e=>{w(d,e)},[d,w]),D=$t(),O=Wt(e=>e.recentActivity??[]),k=(0,L.useCallback)(()=>uS.getState().show(),[]),A=(0,L.useCallback)(e=>{D.invalidateQueries({queryKey:[`command-deck-projects`]}),D.invalidateQueries({queryKey:[`registered-projects`]}),m(e.key);let t=Bht(e.key,g5e());i(t.tab),t.tab===`command-deck`&&(C.current=t.path),window.location.pathname!==t.path&&window.history.pushState(t.state,``,t.path),w(null,`conversation`,t.tab===`command-deck`),mp.getState().ensureHome(e.key),Jmt(t.tab,e.key)},[D,w]),j=(0,L.useRef)(new Set);(0,L.useEffect)(()=>{for(let e of O.slice(0,10)){let t=typeof e.id==`string`?e.id:null,n=typeof e.issueId==`string`?e.issueId:null,r=typeof e.message==`string`?e.message:``;t&&n&&!j.current.has(t)&&/^Rebuild stack for\b/.test(r)&&(j.current.add(t),D.invalidateQueries({queryKey:[`workspace`,n]}))}},[D,O]);let[ee,M]=(0,L.useState)(null),[N,P]=(0,L.useState)(!1),[te,ne]=(0,L.useState)(!1),[re,ie]=(0,L.useState)(null),[ae,oe]=(0,L.useState)(!1),[se,ce]=(0,L.useState)(`all`),[le,ue]=(0,L.useState)(null),[de,fe]=(0,L.useState)(Odr),[pe,me]=(0,L.useState)(!1),he=Wt(e=>e.drawer.issueId)!==null,ge=Wt(e=>e.openIssue),_e=Wt(e=>e.openIssueFromRoute),ve=Wt(e=>e.syncDrawerFromUrl),ye=Wt(xte),{isError:be,failureCount:xe,dataUpdatedAt:Se,errorUpdatedAt:Ce}=F({queryKey:[`backend-health`],queryFn:vht,refetchInterval:5e3,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),we=be&&xe>=2;(0,L.useEffect)(()=>{Tc.getState().setServerReachable(!we)},[we,Se,Ce]),(0,L.useEffect)(()=>{Tc.getState().setRestarting(ye.active)},[ye.active]);let{data:Te}=F({queryKey:[`tracker-status`],queryFn:Sht,refetchInterval:6e4,retry:!1}),Ee=Te?.configured.filter(e=>!e.hasKey)||[],{data:De}=F({queryKey:[`cliproxy-status`],queryFn:Dht,refetchInterval:1e4,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),Oe=De&&!De.running,{data:ke}=F({queryKey:[`settings`,`experimental-features`],queryFn:oLe,staleTime:3e4}),Ae=ke===!0||ke===!1,je=Cn({mutationFn:Oht,onSuccess:()=>{D.invalidateQueries({queryKey:[`cliproxy-status`]}),B.success(`CLIProxy restarted successfully`)},onError:e=>{B.error(`Failed to restart CLIProxy: `+e.message)}}),Me=Cn({mutationFn:async()=>{let e=window.overdeckBridge;if(e?.restartDashboard){await e.restartDashboard();return}try{if((await fetch(`/api/system/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(3e3)})).ok)return}catch{}let t=_ht();if(!t)throw Error(`Dashboard is unreachable and supervisor URL is unknown — try restarting from the CLI.`);let n=await fetch(`${t}/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(5e3)});if(!n.ok)throw Error(`Supervisor returned ${n.status}`)},onSuccess:()=>{B.success(`Restart requested — reconnecting…`)},onError:e=>{B.error(`Restart failed: `+e.message)}}),Ne=(0,L.useCallback)(e=>{let t=Ae&&!ke&&sLe(e)?`home`:e;i(t),ro(`dashboard_tab_viewed`,{tab:t});let n=QE[t];window.location.pathname!==n&&window.history.pushState({tab:t},``,n)},[ke,Ae]);(0,L.useEffect)(()=>{Ae&&!ke&&sLe(r)&&Ne(`home`)},[r,ke,Ae,Ne]),(0,L.useEffect)(()=>{if(typeof window<`u`)try{window.localStorage.setItem(kht,r)}catch{}},[r]);let Pe=(0,L.useCallback)(()=>{let e=Nht();if(!e)return;if(s7.getState().mode===`simple`){r!==`home`&&i(`home`),s7.getState().openSimpleIssue(e);return}let t=jht()??`pipeline`;r!==t&&i(t),_e(e,QE[t],window.location.pathname)},[r,_e]);(0,L.useEffect)(()=>{Pe()},[Pe]);let Fe=(0,L.useCallback)((e,t)=>{if(e&&t){let n=`/command-deck/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;C.current=n,window.location.pathname!==n&&window.history.replaceState({tab:`command-deck`},``,n)}else if(e){let t=`/command-deck/${encodeURIComponent(e)}`;C.current=t,window.location.pathname!==t&&window.history.replaceState({tab:`command-deck`,project:e},``,t)}else C.current=`/command-deck`,window.location.pathname.startsWith(`/command-deck/`)&&window.history.replaceState({tab:`command-deck`},``,`/command-deck`)},[]),Ie=(0,L.useCallback)(e=>{i(`workspace`),S(e);let t=`/workspace/${encodeURIComponent(e)}`;window.location.pathname!==t&&window.history.pushState({tab:`workspace`},``,t)},[]),Le=(0,L.useCallback)(e=>{let t=e?`/workspaces/new?project=${encodeURIComponent(e)}`:`/workspaces/new`;i(`workspace-new`),window.history.pushState({tab:`workspace-new`},``,t)},[]),Re=(0,L.useCallback)(()=>{S(null),Ne(`home`)},[Ne]),ze=(0,L.useCallback)(e=>{D.invalidateQueries({queryKey:[`workspace-registry`]}),(async()=>{try{await Is(`/api/workspace-registry/${encodeURIComponent(e)}/activate`,{method:`POST`,credentials:`include`,headers:await Ac()})}catch{}})(),Ie(e)},[Ie,D]),Be=(0,L.useCallback)(async e=>{let t=e.conversationId||e.sessionId,n=e.projectKey||`__no-project__`;try{let r=e.subagentId??void 0,i=bht(e)?await yht(t,e.byteOffset,r):null,a=Date.now();i&&ue({conversationName:t,messageId:i.messageId,messageIndex:i.messageIndex,nonce:a,label:e.label||`Agent`,subagentId:r}),Ne(`command-deck`),m(n),w(t,`conversation`);let o=mp.getState();o.ensureHome(n);let s=o.addPane(n,{paneType:`agent`,label:e.label||`Agent`,conversationId:t,viewMode:`conversation`});mp.getState().updatePane(n,s,i?{viewMode:`conversation`,targetMessageId:i.messageId,targetMessageIndex:i.messageIndex,targetMessageNonce:a,targetSubagentId:r}:{viewMode:`conversation`,targetMessageId:void 0,targetMessageIndex:void 0,targetMessageNonce:void 0,targetSubagentId:void 0})}catch(t){B.error(xht(e,t))}},[Ne,w]),Ve=(0,L.useCallback)(e=>{fe(e),window.localStorage.setItem(Ddr,String(e))},[]),He=(0,L.useCallback)((e,t)=>{if(m(e),i(`command-deck`),t?.updateUrl!==!1){let t=e?`/command-deck/${encodeURIComponent(e)}`:`/command-deck`;C.current=t,window.location.pathname!==t&&window.history.pushState({tab:`command-deck`,project:e},``,t),w(null)}if(e){mp.getState().ensureHome(e);let t=mp.getState(),n=(t.panesByWorkspace[e]??[]).find(e=>e.paneType===`home`);n&&t.setActivePane(e,n.paneId)}},[w]);(0,L.useEffect)(()=>{let e=()=>{let e=Kht();i(e.tab),f(e.convId),g(e.viewMode),v(e.viewModes);let t=Pht();b(t),S(Iht());let n=t?.project??Fht();C.current=t?`/command-deck/${encodeURIComponent(t.project)}/${encodeURIComponent(t.issue)}`:n?`/command-deck/${encodeURIComponent(n)}`:`/command-deck`,n?m(n):window.location.pathname===`/command-deck`&&m(null),ve(),Pe()};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ve,Pe]);let Ue=Wt(Jt),We=(0,L.useMemo)(()=>Ue.filter(e=>eur(e.status)).length,[Ue]),Ge=Wt(Lt),{currentChannelPermissionRequest:Ke,currentChannelPermissionIssueId:qe,isChannelPermissionSubmitting:Je,handleAllowChannelPermission:Ye,handleDenyChannelPermission:Xe,terminalPermissionDialog:Ze,currentAskUserQuestionSubject:Qe,isAskUserQuestionSubmitting:$e,handleSubmitAskUserQuestion:et,handleDismissAskUserQuestion:tt,currentPlanApprovalSubject:nt,isPlanActionSubmitting:rt,handleApprovePlan:it,handleRequestPlanChanges:at,handleDismissPlanApproval:ot,currentConfirmation:st,handleConfirm:ct,handleDeny:lt,handleCloseConfirmation:ut}=Tdr({agents:Ue,issues:Ge});Edr();let dt=(0,L.useRef)({prefix:null,timer:null});(0,L.useEffect)(()=>{let e=e=>{let t=navigator.platform.includes(`Mac`)?e.metaKey:e.ctrlKey,n=e.target,r=n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable;if(!r&&!ae){if(e.key===`g`){e.preventDefault(),dt.current.prefix=`g`,dt.current.timer&&clearTimeout(dt.current.timer),dt.current.timer=setTimeout(()=>{dt.current.prefix=null,dt.current.timer=null},1500);return}if(dt.current.prefix===`g`){dt.current.timer&&clearTimeout(dt.current.timer),dt.current.timer=null,dt.current.prefix=null;let t=e.key===`p`?`pipeline`:e.key===`b`?`kanban`:e.key===`a`?`agents`:e.key===`c`?`command-deck`:null;t&&(e.preventDefault(),Ne(t));return}}e.key===`/`&&!r?(e.preventDefault(),P(!0)):e.key===`k`&&t&&!e.shiftKey?(e.preventDefault(),ce(`all`),oe(e=>!e)):e.key===`j`&&t&&!e.shiftKey&&(e.preventDefault(),ce(`conversations`),oe(!0))};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),dt.current.timer&&clearTimeout(dt.current.timer)}},[ae,Ne,P,oe]),(0,L.useEffect)(()=>{let e=window.overdeckBridge;if(e)return e.onMenuAction(e=>{if(e===`open-settings`)Ne(`settings`);else if(e.startsWith(`open-workspace:`)){let t=e.slice(15);Ne(`kanban`),t&&ge(t)}else if(e.startsWith(`auto-start-nag:`)){oe(!1);let t=e.split(`:`);ft(parseInt(t[1]??`0`,10),parseInt(t[2]??`5`,10))}else e===`open-updater`&&ne(!0)})},[ge,Ne]);function ft(e,t){let n=[`Auto-start means never missing an agent asking for help.`,`Your agents could be waiting for you right now.`,`Overdeck works best when it's always watching.`,`One click enables auto-start. You can disable it anytime.`];B(`Reminder ${e} of ${t} — ${n[(e-2)%n.length]??n[0]}`,{duration:8e3,action:{label:`Enable`,onClick:()=>{window.overdeckBridge?.updateDesktopSetting(`autoStart.enabled`,!0)}}})}let pt=(0,L.useCallback)(e=>{Ne(`kanban`),ge(e)},[ge,Ne]),{data:mt=[]}=F({queryKey:[`registered-projects`],queryFn:async()=>{let e=await fetch(`/api/registered-projects`);if(!e.ok)throw Error(`Failed to fetch registered projects`);return e.json()},staleTime:6e4}),ht=(0,L.useCallback)(e=>{let t=Ge.find(t=>t.identifier===e),n=t?.sourceRepo||t?.project?.name||``,r=n.includes(`/`)?n.split(`/`).pop():n,i=mt.find(e=>e.key===r||e.name===r||e.key===n||e.name===n);return i?i.name??i.key:p??null},[Ge,mt,p]),gt=(0,L.useCallback)((e,t)=>{let n=Ge.find(t=>t.identifier===e);if(t===`browser`){let t=e.replace(/^[A-Za-z]+-/,``),r=n?.project?.name,i=n?.url||(r&&r.includes(`/`)?`https://github.com/${r}/issues/${t}`:null);if(!i){ge(e);return}window.open(i,`_blank`,`noopener,noreferrer`);return}if(t===`modal`){ge(e);return}let r=ht(e);if(!r){ge(e);return}Ne(`command-deck`),b({project:r,issue:e}),Fe(r,e)},[Ge,ge,ht,Ne,Fe]),_t=(0,L.useCallback)(e=>{Ne(`kanban`),ge(e)},[ge,Ne]);return(0,z.jsxs)(`div`,{className:`h-screen flex flex-row overflow-hidden bg-background`,children:[(0,z.jsx)(lu,{}),(0,z.jsx)(APe,{}),(0,z.jsx)(kLe,{activeTab:r,onTabChange:Ne,onSearchOpen:()=>P(!0),selectedProject:p,onSelectProject:He,onNewProject:k,onNewWorkspace:()=>Le(p??void 0),onOpenUpdater:()=>ne(!0),onSelectWorkspace:Ie}),(0,z.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden min-w-0`,children:[(0,z.jsx)(ydr,{activeTab:r,selectedProjectKey:p,runningAgentCount:We,dashboardLifecycle:ye,missingKeyTrackers:Ee,trackerBannerDismissed:pe,showCliproxyBanner:Oe,isRestartBackendPending:Me.isPending,isRestartCliproxyPending:je.isPending,isSessionFeedSidebarOpen:de,onSearchOpen:()=>P(!0),onOpenSettings:()=>Ne(`settings`),onDismissTrackerBanner:()=>me(!0),onRestartBackend:()=>Me.mutate(),onRestartCliproxy:()=>je.mutate(),onToggleSessionFeedSidebar:()=>Ve(!de),onNavigateNeedsYou:()=>Ne(`flywheel`),onProjectCreated:A}),(0,z.jsxs)(`div`,{className:`min-h-0 flex flex-1 overflow-hidden`,children:[(0,z.jsx)(`main`,{"data-drawer-open":he?`true`:void 0,className:`relative flex-1 flex overflow-hidden data-[drawer-open=true]:before:pointer-events-none data-[drawer-open=true]:before:absolute data-[drawer-open=true]:before:inset-0 data-[drawer-open=true]:before:z-[80] data-[drawer-open=true]:before:bg-primary/[0.04] data-[drawer-open=true]:before:backdrop-blur-[2px]`,children:(0,z.jsx)(Mlr,{activeTab:r,issues:Ge,selectedConvId:d,conversationViewMode:h,selectedProjectKey:p,pendingConversationTarget:le,cockpitRoute:y,workspaceRouteId:x,onWorkspaceViewBack:Re,onWorkspaceCreated:ze,onProjectCreated:A,initialSessionKey:u,onOpenWorkspaceHome:_t,onNewProject:k,onSelectProject:He,onOpenSettings:()=>Ne(`settings`),onConvIdChange:T,onConversationViewModeChange:E,onPendingConversationTargetConsumed:()=>ue(null),onProjectPrefixChange:ie,onCockpitChange:Fe,onSearchOpen:()=>P(!0),onTabChange:Ne,onOpenIssue:ge,onPlanDialogChange:M,onSelectAgent:o,onBacklogIssueAction:gt,keyboardShortcutsDisabled:N||ae})}),de&&![`command-deck`,`backlog`,`god-view`].includes(r)&&(0,z.jsx)(Bmt,{onClose:()=>Ve(!1)})]})]}),(0,z.jsx)(Tpt,{}),(0,z.jsx)(nht,{}),(0,z.jsx)(kdr,{}),(0,z.jsx)(Adr,{}),(0,z.jsx)(Apt,{}),(0,z.jsx)(Mpt,{}),(0,z.jsx)(Ymt,{isOpen:te,runningAgentCount:We,onClose:()=>ne(!1)}),(0,z.jsx)(k_e,{request:Ke,issueId:qe,isOpen:!!Ke,isSubmitting:Je,onAllow:Ye,onDeny:Xe}),(0,z.jsx)(N_e,{...Ze}),(0,z.jsx)(P_e,{subject:Qe,isOpen:!!Qe&&!Ke,isSubmitting:$e,onSubmit:et,onDismiss:tt}),(0,z.jsx)(mwe,{subject:nt,isOpen:!!nt&&!Ke&&!Qe,isSubmitting:rt,onApprove:it,onRequestChanges:at,onDismiss:ot}),(0,z.jsx)(x_e,{request:st,isOpen:!!st,onConfirm:ct,onDeny:lt,onClose:ut}),(0,z.jsx)(VTe,{isOpen:N,onClose:()=>P(!1),onSelectIssue:pt,cycleFilter:`current`,includeCompletedFilter:!1,projectPrefix:r===`command-deck`?re:null}),(0,z.jsx)($Le,{isOpen:ae,initialScope:se,onClose:()=>oe(!1),onNavigate:(e,t)=>{Ne(e),t&&ge(t)},onOpenConversationHit:Be,onSelectWorkspace:Ie,onNewWorkspace:()=>Le()}),(0,z.jsx)(O_e,{}),(0,z.jsx)(wme,{})]})}var Mdr=`pan-recovery-overlay`,Ndr=`pan.recovery.lastReload`,Pdr=`pan.recovery.reloadCount`,Fdr=15e3,Idr=3,Ldr=!1;function q9(e){return typeof e==`string`?e:e&&typeof e==`object`&&`message`in e?String(e.message??``):``}function J9(e){if(!e||typeof e!=`object`||!(`stack`in e))return;let t=String(e.stack??``);return t?t.split(`
1611
+ `)}`,l=await Is(`/api/conversations/${encodeURIComponent(t)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:c})});if(!l.ok){let e=`Failed to deliver answer (${l.status})`;try{let t=await l.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return l.json()},onMutate:e=>{let t=ue?.pendingAskUserQuestion?.toolUseId;return t&&v(t),{subjectId:e.id,toolUseId:t}},onSuccess:(e,t)=>{B.success(`Answer delivered to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&y(n.toolUseId),B.error(`Failed to deliver answer: ${e.message}`)}}),me=Cn({mutationFn:async({id:e,optionNumber:t,toolUseId:n})=>{let r=await Is(`/api/conversations/${encodeURIComponent(e)}/codex-approval`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({optionNumber:t,toolUseId:n})});if(!r.ok){let e=`Failed to send approval (${r.status})`;try{let t=await r.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return r.json()},onMutate:({toolUseId:e})=>(e&&v(e),{toolUseId:e}),onSuccess:(e,t)=>{B.success(`Approval sent to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&y(n.toolUseId),B.error(`Failed to send approval: ${e.message}`)}}),he=(0,L.useCallback)(e=>{if(!ue)return;let t=ue,n=t.pendingAskUserQuestion?.toolUseId;if(n?.startsWith(`codex-approval:`)){let r=/^\s*(\d+)/.exec(e[0]??``),i=r?Number(r[1]):NaN;if(!Number.isInteger(i)){B.error(`Could not determine which option was selected`);return}me.mutate({id:t.id,optionNumber:i,label:t.title?.trim()||t.id,toolUseId:n});return}pe.mutate({kind:t.kind??`agent`,id:t.id,label:t.title?.trim()||t.id,answers:e,questions:t.pendingAskUserQuestion?.questions,harness:t.harness??null,toolUseId:t.pendingAskUserQuestion?.toolUseId})},[pe,me,ue]),ge=(0,L.useCallback)(()=>{ue&&b(ue.id)},[ue,b]),_e=Cn({mutationFn:async({kind:e,id:t,action:n,feedback:r})=>{let i=await Is(e===`agent`?`/api/agents/${encodeURIComponent(t)}/plan-action`:`/api/conversations/${encodeURIComponent(t)}/plan-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:n,feedback:r})});if(!i.ok){let e=`Failed to deliver plan action (${i.status})`;try{let t=await i.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return i.json()},onMutate:({toolUseId:e})=>(e&&c(e),{toolUseId:e}),onSuccess:(e,t)=>{B.success(t.action===`approve-manual`?`Plan approved for ${t.label?.trim()||t.id}`:`Plan feedback sent to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&l(n.toolUseId),B.error(`Plan action failed: ${e.message}`)}}),ve=(0,L.useCallback)(()=>{if(!se)return;let e=se;_e.mutate({kind:e.kind,id:e.id,label:e.title?.trim()||e.issueId||e.id,action:`approve-manual`,toolUseId:e.pendingProposedPlan?.toolUseId})},[se,_e]),ye=(0,L.useCallback)(e=>{if(!se)return;let t=se;_e.mutate({kind:t.kind,id:t.id,label:t.title?.trim()||t.issueId||t.id,action:`reject-feedback`,feedback:e,toolUseId:t.pendingProposedPlan?.toolUseId})},[se,_e]),be=(0,L.useCallback)(()=>{se&&(u(se.id),h(e=>e===se.id?null:e))},[se,u]);(0,L.useEffect)(()=>{let e=i.map(e=>e.pendingAskUserQuestion?.toolUseId).filter(e=>typeof e==`string`),t=ne.map(e=>e.pendingAskUserQuestion?.toolUseId).filter(e=>typeof e==`string`),n=new Set([...e,...t]);S(n);let r=new Set([...i.map(e=>e.id),...ne.map(e=>e.name)]);C(r),A(e=>e&&r.has(e)?e:null);let o=new Set([...a.map(e=>e.pendingProposedPlan?.toolUseId).filter(e=>typeof e==`string`),...ne.map(e=>e.pendingProposedPlan?.toolUseId).filter(e=>typeof e==`string`)]);f(o);let s=new Set([...a.map(e=>e.id),...ne.filter(e=>e.pendingProposedPlan).map(e=>e.name)]);p(s),h(e=>e&&s.has(e)?e:null)},[i,a,ne,S,C,f,p]);let xe=Cn({mutationFn:({agentId:e,requestId:t,behavior:n})=>Tht(e,t,n),onMutate:async e=>{O(t=>{let n=new Set(t);return n.add(e.requestId),n})},onSuccess:async(e,t)=>{await q_(n),B.success(t.behavior===`allow`?`Allowed ${t.agentId} to continue`:`Denied permission request for ${t.agentId}`)},onError:(e,t)=>{O(e=>{if(!e.has(t.requestId))return e;let n=new Set(e);return n.delete(t.requestId),n}),B.error(`Permission response failed: ${e.message}`)}}),Se=(0,L.useCallback)(async()=>{if(j)try{await wht(j.id,!0),ee(null)}catch(e){console.error(`Failed to confirm:`,e)}},[j]),Ce=(0,L.useCallback)(async()=>{if(j)try{await wht(j.id,!1),ee(null)}catch(e){console.error(`Failed to deny:`,e)}},[j]),we=(0,L.useCallback)(()=>{P&&xe.mutate({agentId:P.agentId,requestId:P.requestId,behavior:`allow`})},[xe,P]),Te=(0,L.useCallback)(()=>{P&&xe.mutate({agentId:P.agentId,requestId:P.requestId,behavior:`deny`})},[xe,P]),Ee=(0,L.useCallback)(()=>{ee(null)},[]);return{currentChannelPermissionRequest:P,currentChannelPermissionIssueId:te,isChannelPermissionSubmitting:xe.isPending,handleAllowChannelPermission:we,handleDenyChannelPermission:Te,terminalPermissionDialog:ie,currentAskUserQuestionSubject:ie.isOpen?null:ue,isAskUserQuestionSubmitting:pe.isPending||me.isPending,handleSubmitAskUserQuestion:he,handleDismissAskUserQuestion:ge,currentPlanApprovalSubject:ie.isOpen?null:se,isPlanActionSubmitting:_e.isPending,handleApprovePlan:ve,handleRequestPlanChanges:ye,handleDismissPlanApproval:be,currentConfirmation:j,handleConfirm:Se,handleDeny:Ce,handleCloseConfirmation:Ee}}function Ddr(){let e=Wt(e=>e.recentActivity),t=(0,L.useRef)(new Set),n=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(Array.isArray(e)){if(!n.current){for(let n of e)n?.id&&t.current.add(n.id);n.current=!0;return}for(let n of e)if(n?.desktop&&n.id&&!t.current.has(n.id)&&(t.current.add(n.id),typeof window<`u`&&`Notification`in window&&Notification.permission===`granted`))try{let e=new Notification(`Overdeck`,{body:n.message??`Overdeck notification`,tag:n.id});e.onclick=()=>{window.focus(),e.close()}}catch{}}},[e])}var Odr=`overdeck.ui.sessionFeedSidebarOpen`;function kdr(){if(typeof window>`u`)return!0;let e=window.localStorage.getItem(Odr);return e===null||e===`true`}function Adr(){let e=Wt(e=>e.tasksViewerIssueId),t=Wt(e=>e.closeTasksViewer);return e?(0,z.jsx)(Xmt,{issueId:e,isOpen:!0,onClose:t}):null}function jdr(){let e=Wt(e=>e.prdViewerIssueId),t=Wt(e=>e.closePrdViewer);return e?(0,z.jsx)(Zmt,{issueId:e,onClose:t}):null}function Mdr(){(0,L.useEffect)(()=>{},[]);let e=window.location.pathname,t=new URLSearchParams(window.location.search).get(`terminal`);if(e.startsWith(`/terminal/`)||t){let n=e.startsWith(`/terminal/`)?e.replace(`/terminal/`,``):t,r=new URLSearchParams(window.location.search).get(`token`)??void 0;return(0,z.jsx)(ngt,{sessionName:n,token:r})}let n=e.match(/^\/popout\/conversation\/([^/]+)$/);if(n)return(0,z.jsx)(rgt,{conversationId:n[1]});if(e===`/popout/flywheel-conversation`)return(0,z.jsx)(agt,{});if(e===`/popout/diff`)return(0,z.jsx)(igt,{});let[r,i]=(0,L.useState)(()=>Kht().tab),[,a]=(0,L.useState)(()=>{let e=window.location.hash;return e.startsWith(`#agent=`)?decodeURIComponent(e.slice(7)):null}),o=(0,L.useCallback)(e=>{a(e),e?window.history.replaceState(null,``,`${window.location.pathname}#agent=${encodeURIComponent(e)}`):window.history.replaceState(null,``,window.location.pathname)},[]);ZE(),(0,L.useEffect)(()=>{let e=()=>{let e=window.location.hash;e.startsWith(`#agent=`)&&a(decodeURIComponent(e.slice(7)))};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let s=Kht(),c=Pht(),l=Fht(),u=Hht(),[d,f]=(0,L.useState)(()=>s.convId),[p,m]=(0,L.useState)(()=>c?.project??l),[h,g]=(0,L.useState)(()=>s.viewMode),[_,v]=(0,L.useState)(()=>s.viewModes),[y,b]=(0,L.useState)(()=>c),[x,S]=(0,L.useState)(()=>Iht()),C=(0,L.useRef)(c?`/command-deck/${encodeURIComponent(c.project)}/${encodeURIComponent(c.issue)}`:l?`/command-deck/${encodeURIComponent(l)}`:`/command-deck`),w=(0,L.useCallback)((e,t=`conversation`,n=!0)=>{f(e),g(e?t:`conversation`),v(r=>{let i={...r};return e&&t===`terminal`?i[e]=`terminal`:e&&delete i[e],n&&window.history.replaceState(null,``,e?qht(e,t,r):C.current),i})},[]),T=(0,L.useCallback)(e=>{let t=e?_[e]??`conversation`:`conversation`;w(e,t)},[_,w]),E=(0,L.useCallback)(e=>{w(d,e)},[d,w]),D=$t(),O=Wt(e=>e.recentActivity??[]),k=(0,L.useCallback)(()=>uS.getState().show(),[]),A=(0,L.useCallback)(e=>{D.invalidateQueries({queryKey:[`command-deck-projects`]}),D.invalidateQueries({queryKey:[`registered-projects`]}),m(e.key);let t=Bht(e.key,g5e());i(t.tab),t.tab===`command-deck`&&(C.current=t.path),window.location.pathname!==t.path&&window.history.pushState(t.state,``,t.path),w(null,`conversation`,t.tab===`command-deck`),mp.getState().ensureHome(e.key),Jmt(t.tab,e.key)},[D,w]),j=(0,L.useRef)(new Set);(0,L.useEffect)(()=>{for(let e of O.slice(0,10)){let t=typeof e.id==`string`?e.id:null,n=typeof e.issueId==`string`?e.issueId:null,r=typeof e.message==`string`?e.message:``;t&&n&&!j.current.has(t)&&/^Rebuild stack for\b/.test(r)&&(j.current.add(t),D.invalidateQueries({queryKey:[`workspace`,n]}))}},[D,O]);let[ee,M]=(0,L.useState)(null),[N,P]=(0,L.useState)(!1),[te,ne]=(0,L.useState)(!1),[re,ie]=(0,L.useState)(null),[ae,oe]=(0,L.useState)(!1),[se,ce]=(0,L.useState)(`all`),[le,ue]=(0,L.useState)(null),[de,fe]=(0,L.useState)(kdr),[pe,me]=(0,L.useState)(!1),he=Wt(e=>e.drawer.issueId)!==null,ge=Wt(e=>e.openIssue),_e=Wt(e=>e.openIssueFromRoute),ve=Wt(e=>e.syncDrawerFromUrl),ye=Wt(xte),{isError:be,failureCount:xe,dataUpdatedAt:Se,errorUpdatedAt:Ce}=F({queryKey:[`backend-health`],queryFn:vht,refetchInterval:5e3,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),we=be&&xe>=2;(0,L.useEffect)(()=>{Tc.getState().setServerReachable(!we)},[we,Se,Ce]),(0,L.useEffect)(()=>{Tc.getState().setRestarting(ye.active)},[ye.active]);let{data:Te}=F({queryKey:[`tracker-status`],queryFn:Sht,refetchInterval:6e4,retry:!1}),Ee=Te?.configured.filter(e=>!e.hasKey)||[],{data:De}=F({queryKey:[`cliproxy-status`],queryFn:Dht,refetchInterval:1e4,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),Oe=De&&!De.running,{data:ke}=F({queryKey:[`settings`,`experimental-features`],queryFn:oLe,staleTime:3e4}),Ae=ke===!0||ke===!1,je=Cn({mutationFn:Oht,onSuccess:()=>{D.invalidateQueries({queryKey:[`cliproxy-status`]}),B.success(`CLIProxy restarted successfully`)},onError:e=>{B.error(`Failed to restart CLIProxy: `+e.message)}}),Me=Cn({mutationFn:async()=>{let e=window.overdeckBridge;if(e?.restartDashboard){await e.restartDashboard();return}try{if((await fetch(`/api/system/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(3e3)})).ok)return}catch{}let t=_ht();if(!t)throw Error(`Dashboard is unreachable and supervisor URL is unknown — try restarting from the CLI.`);let n=await fetch(`${t}/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(5e3)});if(!n.ok)throw Error(`Supervisor returned ${n.status}`)},onSuccess:()=>{B.success(`Restart requested — reconnecting…`)},onError:e=>{B.error(`Restart failed: `+e.message)}}),Ne=(0,L.useCallback)(e=>{let t=Ae&&!ke&&sLe(e)?`home`:e;i(t),ro(`dashboard_tab_viewed`,{tab:t});let n=QE[t];window.location.pathname!==n&&window.history.pushState({tab:t},``,n)},[ke,Ae]);(0,L.useEffect)(()=>{Ae&&!ke&&sLe(r)&&Ne(`home`)},[r,ke,Ae,Ne]),(0,L.useEffect)(()=>{if(typeof window<`u`)try{window.localStorage.setItem(kht,r)}catch{}},[r]);let Pe=(0,L.useCallback)(()=>{let e=Nht();if(!e)return;if(s7.getState().mode===`simple`){r!==`home`&&i(`home`),s7.getState().openSimpleIssue(e);return}let t=jht()??`pipeline`;r!==t&&i(t),_e(e,QE[t],window.location.pathname)},[r,_e]);(0,L.useEffect)(()=>{Pe()},[Pe]);let Fe=(0,L.useCallback)((e,t)=>{if(e&&t){let n=`/command-deck/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;C.current=n,window.location.pathname!==n&&window.history.replaceState({tab:`command-deck`},``,n)}else if(e){let t=`/command-deck/${encodeURIComponent(e)}`;C.current=t,window.location.pathname!==t&&window.history.replaceState({tab:`command-deck`,project:e},``,t)}else C.current=`/command-deck`,window.location.pathname.startsWith(`/command-deck/`)&&window.history.replaceState({tab:`command-deck`},``,`/command-deck`)},[]),Ie=(0,L.useCallback)(e=>{i(`workspace`),S(e);let t=`/workspace/${encodeURIComponent(e)}`;window.location.pathname!==t&&window.history.pushState({tab:`workspace`},``,t)},[]),Le=(0,L.useCallback)(e=>{let t=e?`/workspaces/new?project=${encodeURIComponent(e)}`:`/workspaces/new`;i(`workspace-new`),window.history.pushState({tab:`workspace-new`},``,t)},[]),Re=(0,L.useCallback)(()=>{S(null),Ne(`home`)},[Ne]),ze=(0,L.useCallback)(e=>{D.invalidateQueries({queryKey:[`workspace-registry`]}),(async()=>{try{await Is(`/api/workspace-registry/${encodeURIComponent(e)}/activate`,{method:`POST`,credentials:`include`,headers:await Ac()})}catch{}})(),Ie(e)},[Ie,D]),Be=(0,L.useCallback)(async e=>{let t=e.conversationId||e.sessionId,n=e.projectKey||`__no-project__`;try{let r=e.subagentId??void 0,i=bht(e)?await yht(t,e.byteOffset,r):null,a=Date.now();i&&ue({conversationName:t,messageId:i.messageId,messageIndex:i.messageIndex,nonce:a,label:e.label||`Agent`,subagentId:r}),Ne(`command-deck`),m(n),w(t,`conversation`);let o=mp.getState();o.ensureHome(n);let s=o.addPane(n,{paneType:`agent`,label:e.label||`Agent`,conversationId:t,viewMode:`conversation`});mp.getState().updatePane(n,s,i?{viewMode:`conversation`,targetMessageId:i.messageId,targetMessageIndex:i.messageIndex,targetMessageNonce:a,targetSubagentId:r}:{viewMode:`conversation`,targetMessageId:void 0,targetMessageIndex:void 0,targetMessageNonce:void 0,targetSubagentId:void 0})}catch(t){B.error(xht(e,t))}},[Ne,w]),Ve=(0,L.useCallback)(e=>{fe(e),window.localStorage.setItem(Odr,String(e))},[]),He=(0,L.useCallback)((e,t)=>{if(m(e),i(`command-deck`),t?.updateUrl!==!1){let t=e?`/command-deck/${encodeURIComponent(e)}`:`/command-deck`;C.current=t,window.location.pathname!==t&&window.history.pushState({tab:`command-deck`,project:e},``,t),w(null)}if(e){mp.getState().ensureHome(e);let t=mp.getState(),n=(t.panesByWorkspace[e]??[]).find(e=>e.paneType===`home`);n&&t.setActivePane(e,n.paneId)}},[w]);(0,L.useEffect)(()=>{let e=()=>{let e=Kht();i(e.tab),f(e.convId),g(e.viewMode),v(e.viewModes);let t=Pht();b(t),S(Iht());let n=t?.project??Fht();C.current=t?`/command-deck/${encodeURIComponent(t.project)}/${encodeURIComponent(t.issue)}`:n?`/command-deck/${encodeURIComponent(n)}`:`/command-deck`,n?m(n):window.location.pathname===`/command-deck`&&m(null),ve(),Pe()};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ve,Pe]);let Ue=Wt(Jt),We=(0,L.useMemo)(()=>Ue.filter(e=>eur(e.status)).length,[Ue]),Ge=Wt(Lt),{currentChannelPermissionRequest:Ke,currentChannelPermissionIssueId:qe,isChannelPermissionSubmitting:Je,handleAllowChannelPermission:Ye,handleDenyChannelPermission:Xe,terminalPermissionDialog:Ze,currentAskUserQuestionSubject:Qe,isAskUserQuestionSubmitting:$e,handleSubmitAskUserQuestion:et,handleDismissAskUserQuestion:tt,currentPlanApprovalSubject:nt,isPlanActionSubmitting:rt,handleApprovePlan:it,handleRequestPlanChanges:at,handleDismissPlanApproval:ot,currentConfirmation:st,handleConfirm:ct,handleDeny:lt,handleCloseConfirmation:ut}=Edr({agents:Ue,issues:Ge});Ddr();let dt=(0,L.useRef)({prefix:null,timer:null});(0,L.useEffect)(()=>{let e=e=>{let t=navigator.platform.includes(`Mac`)?e.metaKey:e.ctrlKey,n=e.target,r=n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable;if(!r&&!ae){if(e.key===`g`){e.preventDefault(),dt.current.prefix=`g`,dt.current.timer&&clearTimeout(dt.current.timer),dt.current.timer=setTimeout(()=>{dt.current.prefix=null,dt.current.timer=null},1500);return}if(dt.current.prefix===`g`){dt.current.timer&&clearTimeout(dt.current.timer),dt.current.timer=null,dt.current.prefix=null;let t=e.key===`p`?`pipeline`:e.key===`b`?`kanban`:e.key===`a`?`agents`:e.key===`c`?`command-deck`:null;t&&(e.preventDefault(),Ne(t));return}}e.key===`/`&&!r?(e.preventDefault(),P(!0)):e.key===`k`&&t&&!e.shiftKey?(e.preventDefault(),ce(`all`),oe(e=>!e)):e.key===`j`&&t&&!e.shiftKey&&(e.preventDefault(),ce(`conversations`),oe(!0))};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),dt.current.timer&&clearTimeout(dt.current.timer)}},[ae,Ne,P,oe]),(0,L.useEffect)(()=>{let e=window.overdeckBridge;if(e)return e.onMenuAction(e=>{if(e===`open-settings`)Ne(`settings`);else if(e.startsWith(`open-workspace:`)){let t=e.slice(15);Ne(`kanban`),t&&ge(t)}else if(e.startsWith(`auto-start-nag:`)){oe(!1);let t=e.split(`:`);ft(parseInt(t[1]??`0`,10),parseInt(t[2]??`5`,10))}else e===`open-updater`&&ne(!0)})},[ge,Ne]);function ft(e,t){let n=[`Auto-start means never missing an agent asking for help.`,`Your agents could be waiting for you right now.`,`Overdeck works best when it's always watching.`,`One click enables auto-start. You can disable it anytime.`];B(`Reminder ${e} of ${t} — ${n[(e-2)%n.length]??n[0]}`,{duration:8e3,action:{label:`Enable`,onClick:()=>{window.overdeckBridge?.updateDesktopSetting(`autoStart.enabled`,!0)}}})}let pt=(0,L.useCallback)(e=>{Ne(`kanban`),ge(e)},[ge,Ne]),{data:mt=[]}=F({queryKey:[`registered-projects`],queryFn:async()=>{let e=await fetch(`/api/registered-projects`);if(!e.ok)throw Error(`Failed to fetch registered projects`);return e.json()},staleTime:6e4}),ht=(0,L.useCallback)(e=>{let t=Ge.find(t=>t.identifier===e),n=t?.sourceRepo||t?.project?.name||``,r=n.includes(`/`)?n.split(`/`).pop():n,i=mt.find(e=>e.key===r||e.name===r||e.key===n||e.name===n);return i?i.name??i.key:p??null},[Ge,mt,p]),gt=(0,L.useCallback)((e,t)=>{let n=Ge.find(t=>t.identifier===e);if(t===`browser`){let t=e.replace(/^[A-Za-z]+-/,``),r=n?.project?.name,i=n?.url||(r&&r.includes(`/`)?`https://github.com/${r}/issues/${t}`:null);if(!i){ge(e);return}window.open(i,`_blank`,`noopener,noreferrer`);return}if(t===`modal`){ge(e);return}let r=ht(e);if(!r){ge(e);return}Ne(`command-deck`),b({project:r,issue:e}),Fe(r,e)},[Ge,ge,ht,Ne,Fe]),_t=(0,L.useCallback)(e=>{Ne(`kanban`),ge(e)},[ge,Ne]);return(0,z.jsxs)(`div`,{className:`h-screen flex flex-row overflow-hidden bg-background`,children:[(0,z.jsx)(lu,{}),(0,z.jsx)(APe,{}),(0,z.jsx)(kLe,{activeTab:r,onTabChange:Ne,onSearchOpen:()=>P(!0),selectedProject:p,onSelectProject:He,onNewProject:k,onNewWorkspace:()=>Le(p??void 0),onOpenUpdater:()=>ne(!0),onSelectWorkspace:Ie}),(0,z.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden min-w-0`,children:[(0,z.jsx)(bdr,{activeTab:r,selectedProjectKey:p,runningAgentCount:We,dashboardLifecycle:ye,missingKeyTrackers:Ee,trackerBannerDismissed:pe,showCliproxyBanner:Oe,isRestartBackendPending:Me.isPending,isRestartCliproxyPending:je.isPending,isSessionFeedSidebarOpen:de,onSearchOpen:()=>P(!0),onOpenSettings:()=>Ne(`settings`),onDismissTrackerBanner:()=>me(!0),onRestartBackend:()=>Me.mutate(),onRestartCliproxy:()=>je.mutate(),onToggleSessionFeedSidebar:()=>Ve(!de),onNavigateNeedsYou:()=>Ne(`flywheel`),onProjectCreated:A}),(0,z.jsxs)(`div`,{className:`min-h-0 flex flex-1 overflow-hidden`,children:[(0,z.jsx)(`main`,{"data-drawer-open":he?`true`:void 0,className:`relative flex-1 flex overflow-hidden data-[drawer-open=true]:before:pointer-events-none data-[drawer-open=true]:before:absolute data-[drawer-open=true]:before:inset-0 data-[drawer-open=true]:before:z-[80] data-[drawer-open=true]:before:bg-primary/[0.04] data-[drawer-open=true]:before:backdrop-blur-[2px]`,children:(0,z.jsx)(Mlr,{activeTab:r,issues:Ge,selectedConvId:d,conversationViewMode:h,selectedProjectKey:p,pendingConversationTarget:le,cockpitRoute:y,workspaceRouteId:x,onWorkspaceViewBack:Re,onWorkspaceCreated:ze,onProjectCreated:A,initialSessionKey:u,onOpenWorkspaceHome:_t,onNewProject:k,onSelectProject:He,onOpenSettings:()=>Ne(`settings`),onConvIdChange:T,onConversationViewModeChange:E,onPendingConversationTargetConsumed:()=>ue(null),onProjectPrefixChange:ie,onCockpitChange:Fe,onSearchOpen:()=>P(!0),onTabChange:Ne,onOpenIssue:ge,onPlanDialogChange:M,onSelectAgent:o,onBacklogIssueAction:gt,keyboardShortcutsDisabled:N||ae})}),de&&![`command-deck`,`backlog`,`god-view`].includes(r)&&(0,z.jsx)(Bmt,{onClose:()=>Ve(!1)})]})]}),(0,z.jsx)(Tpt,{}),(0,z.jsx)(nht,{}),(0,z.jsx)(Adr,{}),(0,z.jsx)(jdr,{}),(0,z.jsx)(Apt,{}),(0,z.jsx)(Mpt,{}),(0,z.jsx)(Ymt,{isOpen:te,runningAgentCount:We,onClose:()=>ne(!1)}),(0,z.jsx)(k_e,{request:Ke,issueId:qe,isOpen:!!Ke,isSubmitting:Je,onAllow:Ye,onDeny:Xe}),(0,z.jsx)(N_e,{...Ze}),(0,z.jsx)(P_e,{subject:Qe,isOpen:!!Qe&&!Ke,isSubmitting:$e,onSubmit:et,onDismiss:tt}),(0,z.jsx)(mwe,{subject:nt,isOpen:!!nt&&!Ke&&!Qe,isSubmitting:rt,onApprove:it,onRequestChanges:at,onDismiss:ot}),(0,z.jsx)(x_e,{request:st,isOpen:!!st,onConfirm:ct,onDeny:lt,onClose:ut}),(0,z.jsx)(VTe,{isOpen:N,onClose:()=>P(!1),onSelectIssue:pt,cycleFilter:`current`,includeCompletedFilter:!1,projectPrefix:r===`command-deck`?re:null}),(0,z.jsx)($Le,{isOpen:ae,initialScope:se,onClose:()=>oe(!1),onNavigate:(e,t)=>{Ne(e),t&&ge(t)},onOpenConversationHit:Be,onSelectWorkspace:Ie,onNewWorkspace:()=>Le()}),(0,z.jsx)(O_e,{}),(0,z.jsx)(wme,{})]})}var Ndr=`pan-recovery-overlay`,Pdr=`pan.recovery.lastReload`,Fdr=`pan.recovery.reloadCount`,Idr=15e3,Ldr=3,Rdr=!1;function q9(e){return typeof e==`string`?e:e&&typeof e==`object`&&`message`in e?String(e.message??``):``}function J9(e){if(!e||typeof e!=`object`||!(`stack`in e))return;let t=String(e.stack??``);return t?t.split(`
1612
1612
  `).slice(0,5).join(`
1613
- `):void 0}function Rdr(e){let t=q9(e).toLowerCase();return t.includes(`failed to fetch dynamically imported module`)||t.includes(`error loading dynamically imported module`)||t.includes(`importing a module script failed`)||t.includes(`module script failed`)||t.includes(`dynamically imported module`)}function zdr(e){let t;if(typeof e==`string`)t=e;else{if(!(e instanceof HTMLElement)||e.tagName!==`SCRIPT`&&e.tagName!==`LINK`)return null;t=e.tagName===`SCRIPT`?e.src:e.href}if(!t)return null;try{let e=new URL(t,window.location.href);return e.origin===window.location.origin?e.href:null}catch{return null}}function Y9(e){let t=e.match(/(?:https?:\/\/|\/)[^\s'"<>]+/)?.[0].replace(/[),.;]+$/,``);return t?zdr(t)??void 0:void 0}function Bdr(e=Date.now()){let t=Number(sessionStorage.getItem(Ndr)||`0`),n=Number(sessionStorage.getItem(Pdr)||`0`),r=e-t<Fdr?n+1:1;return sessionStorage.setItem(Ndr,String(e)),sessionStorage.setItem(Pdr,String(r)),{count:r,shouldReload:r<=Idr}}function Vdr(e,t){let n=Error(e.message??`Frontend recovery reload`);e.stackHead&&(n.stack=e.stackHead);let r={action:`frontend_recovery_reload`,trigger:e.trigger,reload_count:Hde(t.count),should_reload:t.shouldReload};io(n,r),t.shouldReload||io(n,{...r,action:`frontend_recovery_reload_loop`})}function Hdr(e,t){document.getElementById(Mdr)?.remove();let n=document.createElement(`div`);n.id=Mdr,n.style.cssText=[`position:fixed`,`inset:0`,`z-index:2147483647`,`display:flex`,`flex-direction:column`,`align-items:center`,`justify-content:center`,`gap:16px`,`background:rgba(10,12,16,0.92)`,`color:#e6e6e6`,`font-family:var(--font-sans),system-ui,sans-serif`,`font-size:15px`].join(`;`),n.innerHTML=`
1613
+ `):void 0}function zdr(e){let t=q9(e).toLowerCase();return t.includes(`failed to fetch dynamically imported module`)||t.includes(`error loading dynamically imported module`)||t.includes(`importing a module script failed`)||t.includes(`module script failed`)||t.includes(`dynamically imported module`)}function Bdr(e){let t;if(typeof e==`string`)t=e;else{if(!(e instanceof HTMLElement)||e.tagName!==`SCRIPT`&&e.tagName!==`LINK`)return null;t=e.tagName===`SCRIPT`?e.src:e.href}if(!t)return null;try{let e=new URL(t,window.location.href);return e.origin===window.location.origin?e.href:null}catch{return null}}function Y9(e){let t=e.match(/(?:https?:\/\/|\/)[^\s'"<>]+/)?.[0].replace(/[),.;]+$/,``);return t?Bdr(t)??void 0:void 0}function Vdr(e=Date.now()){let t=Number(sessionStorage.getItem(Pdr)||`0`),n=Number(sessionStorage.getItem(Fdr)||`0`),r=e-t<Idr?n+1:1;return sessionStorage.setItem(Pdr,String(e)),sessionStorage.setItem(Fdr,String(r)),{count:r,shouldReload:r<=Ldr}}function Hdr(e,t){let n=Error(e.message??`Frontend recovery reload`);e.stackHead&&(n.stack=e.stackHead);let r={action:`frontend_recovery_reload`,trigger:e.trigger,reload_count:Hde(t.count),should_reload:t.shouldReload};io(n,r),t.shouldReload||io(n,{...r,action:`frontend_recovery_reload_loop`})}function Udr(e,t){document.getElementById(Ndr)?.remove();let n=document.createElement(`div`);n.id=Ndr,n.style.cssText=[`position:fixed`,`inset:0`,`z-index:2147483647`,`display:flex`,`flex-direction:column`,`align-items:center`,`justify-content:center`,`gap:16px`,`background:rgba(10,12,16,0.92)`,`color:#e6e6e6`,`font-family:var(--font-sans),system-ui,sans-serif`,`font-size:15px`].join(`;`),n.innerHTML=`
1614
1614
  <div style="width:34px;height:34px;border:3px solid rgba(255,255,255,0.18);border-top-color:#6aa0ff;border-radius:50%;animation:pan-recovery-spin 0.8s linear infinite"></div>
1615
1615
  <div data-pan-recovery-message="true"></div>
1616
1616
  ${t?`<button type="button" data-pan-recovery-action="true" style="padding:8px 18px;border-radius:8px;border:1px solid rgba(255,255,255,0.2);background:#1b2533;color:#e6e6e6;cursor:pointer;font-size:14px"></button>`:``}
1617
1617
  <style>@keyframes pan-recovery-spin{to{transform:rotate(360deg)}}</style>
1618
- `;let r=n.querySelector(`[data-pan-recovery-message="true"]`);if(r&&(r.textContent=e),t){let e=n.querySelector(`[data-pan-recovery-action="true"]`);e&&(e.textContent=t.label,e.addEventListener(`click`,t.onClick))}document.body.appendChild(n)}async function X9(e){if(Ldr)return;Ldr=!0,e.trigger===`root_error_boundary`&&Hdr(`Reconnecting to the dashboard…`);let t=Number(sessionStorage.getItem(Ndr)||`0`);for(let e=0;;e++){try{if((await fetch(`/`,{cache:`no-store`})).ok)break}catch{}await Udr(Math.min(500+e*250,3e3))}Date.now()-t<4e3&&await Udr(2e3);let n=Bdr();if(Vdr(e,n),!n.shouldReload){Hdr(`The dashboard stopped automatic recovery after repeated load failures.${e.resource?` Failing resource: ${e.resource}`:``}`,{label:`Reload dashboard`,onClick:()=>window.location.reload()});return}window.location.reload()}function Udr(e){return new Promise(t=>setTimeout(t,e))}function Wdr(){window.addEventListener(`vite:preloadError`,e=>{e.preventDefault();let t=e.payload,n=q9(t);X9({trigger:`vite_preload_error`,resource:Y9(n),message:n||void 0,stackHead:J9(t)})}),window.addEventListener(`error`,e=>{let t=zdr(e.target);if(t){X9({trigger:`asset_load_error`,resource:t,message:e.message||`Module asset failed to load`});return}let n=e.error??e.message;if(Rdr(n)){let e=q9(n);X9({trigger:`window_module_error`,resource:Y9(e),message:e||void 0,stackHead:J9(n)})}},!0),window.addEventListener(`unhandledrejection`,e=>{if(Rdr(e.reason)){let t=q9(e.reason);X9({trigger:`unhandled_rejection`,resource:Y9(t),message:t||void 0,stackHead:J9(e.reason)})}})}var Gdr=class extends L.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){if(io(e,{action:`frontend_unhandled_error`,trigger:`root_error_boundary`}),Rdr(e)){let t=q9(e);X9({trigger:`root_error_boundary`,resource:Y9(t),message:t||void 0,stackHead:J9(e)})}}render(){return this.state.hasError?(0,z.jsxs)(`div`,{style:{position:`fixed`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:16,background:`rgba(10,12,16,0.92)`,color:`#e6e6e6`,fontFamily:`var(--font-sans),system-ui,sans-serif`,fontSize:15},children:[(0,z.jsx)(`div`,{children:`The dashboard hit an error.`}),(0,z.jsx)(`button`,{onClick:()=>window.location.reload(),style:{padding:`8px 18px`,borderRadius:8,border:`1px solid rgba(255,255,255,0.2)`,background:`#1b2533`,color:`#e6e6e6`,cursor:`pointer`,fontSize:14},children:`Reload dashboard`})]}):this.props.children}},Kdr=`https://overdeck.ai/configuration/session-vault`,qdr=`rounded-md border border-border px-2.5 py-1 text-xs text-foreground hover:bg-muted/50 transition-colors disabled:opacity-50`,Jdr=`block rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground break-all`;function Ydr(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Xdr(e){return e!==null&&typeof e.result==`string`}function Zdr(){NFe(),ep.getState().close()}function Qdr({target:e,status:t}){if(!wFe.has(e.harness))return(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Hand-off works for Claude Code and Codex conversations. This conversation runs on `,e.harness,`.`]});switch(t.vault.state){case`off`:return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Hand-off needs the Session Vault, which is off on this machine.`}),(0,z.jsx)(`button`,{type:`button`,onClick:Zdr,className:qdr,children:`Set up`})]});case`locked`:return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This machine cannot open the Session Vault until it is unlocked.`}),(0,z.jsx)(`button`,{type:`button`,onClick:Zdr,className:qdr,children:`Open Session Vault`})]});case`rotation-pending`:return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A vault key rotation started on this machine has not finished.`}),(0,z.jsx)(`a`,{href:Kdr,target:`_blank`,rel:`noreferrer`,className:`text-xs text-primary hover:underline`,children:`How to finish it`})]});case`ready`:return null}}function $dr({outcome:e}){let{status:t,body:n}=e;if(!Xdr(n))return(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:n?.error??`Hand-off failed (${t}).`});switch(n.result){case`saved`:{let e=Ydr(n.savedAt),t=`On your other machine, open "${n.title}" from ${n.machineLabel} and click Continue here.`;return n.wipProblem?(0,z.jsxs)(`div`,{className:`space-y-2`,"data-testid":`handoff-result`,children:[(0,z.jsxs)(`p`,{className:`text-xs text-foreground`,children:[`The conversation was saved (version `,n.version,`), but its code snapshot was not.`]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.wipProblem.message}),n.wipProblem.fix&&(0,z.jsx)(`code`,{className:Jdr,children:n.wipProblem.fix})]}):(0,z.jsx)(`p`,{className:`text-xs text-foreground`,"data-testid":`handoff-result`,children:n.forkedFrom?`Saved as version ${n.version} at ${e} as a separate copy, because another machine already continued this conversation. ${t}`:`Saved as version ${n.version} at ${e}. ${t}`})}case`blocked`:return(0,z.jsxs)(`div`,{className:`space-y-2`,"data-testid":`handoff-result`,children:[(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:`Not saved. The secret scan blocked:`}),(0,z.jsx)(`ul`,{className:`text-xs text-foreground`,children:n.hits.map(e=>(0,z.jsxs)(`li`,{children:[`line `,e.line,`: `,e.pattern]},`${e.line}-${e.pattern}`))}),n.fixes.map(e=>(0,z.jsx)(`code`,{className:Jdr,children:e},e)),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`After allowing a line, click Hand off now again.`})]});case`offline`:return(0,z.jsxs)(`div`,{className:`space-y-2`,"data-testid":`handoff-result`,children:[(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),(0,z.jsx)(`code`,{className:Jdr,children:n.fix})]});default:return(0,z.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`handoff-result`,children:n.error})}}function efr({target:e,status:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(null);if(!wFe.has(e.harness)||t.vault.state!==`ready`)return(0,z.jsx)(`div`,{className:`text-sm`,children:(0,z.jsx)(Qdr,{target:e,status:t})});let o=async()=>{r(!0);try{let t=await AFe(e.name);a(t);let n=t.body;t.status===200&&Xdr(n)&&n.result===`saved`&&n.wipProblem===null&&e.sessionAlive&&mS.getState().record(e.name,n.savedAt)}catch(e){a({status:0,body:{error:e.message}})}finally{r(!1)}};return(0,z.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saves this conversation to the Session Vault now, so your other machine can continue it.`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void o(),disabled:n,className:`rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:n?`Handing off…`:`Hand off now`}),i&&(0,z.jsx)($dr,{outcome:i})]})}function tfr(e){try{let t=new URL(e.trim());return t.protocol===`http:`||t.protocol===`https:`?t.origin:null}catch{return null}}function nfr(e){let t=Math.max(1,Math.round((e-Date.now())/6e4));return`Expires in ${t} minute${t===1?``:`s`} · works once`}function rfr({link:e}){let t=(0,L.useMemo)(()=>{let t=WA(0,`M`);return t.addData(e),t.make(),t.createDataURL(6,8)},[e]);return(0,z.jsx)(`img`,{alt:`Conversation QR code`,src:t,className:`rounded-md bg-white p-1 w-48 h-48`})}var ifr=`rounded-md border border-border px-2.5 py-1 text-xs text-foreground hover:bg-muted/50 transition-colors disabled:opacity-50`;function afr({target:e,status:t}){let n=$t(),r=(0,L.useMemo)(()=>t.addresses.filter(e=>!e.loopback),[t]),i=t.viewer.kind===`root-session`,[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(!0),[h,g]=(0,L.useState)(null),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(!1),[x,S]=(0,L.useState)(null),C=a??r[0]?.origin??null,w=[...r.map(e=>e.origin),...a&&!r.some(e=>e.origin===a)?[a]:[]];(0,L.useEffect)(()=>{if(!h)return;v(!1);let e=setTimeout(()=>v(!0),Math.max(0,h.expiresAt-Date.now()));return()=>clearTimeout(e)},[h]);let T=C?`${C.replace(/\/+$/,``)}/conv/${e.id}${e.viewMode===`terminal`?`?view=terminal`:``}`:null,E=h&&!_?h.link:T,D=async()=>{let e=tfr(s);if(!e){f(`Enter an http:// or https:// address.`);return}u(!0),f(null);try{let t=await mwt(e);if(!AO(t)){f(kO(t));return}await n.invalidateQueries({queryKey:DO}),o(t.body.origin),c(``)}catch(e){f(e.message)}finally{u(!1)}},O=async()=>{if(T){b(!0),S(null);try{let e=await pwt();if(e.status===403){S(`Pairing links can be created only from a browser on this machine. Open the dashboard on the machine itself.`);return}if(!AO(e)){S(kO(e));return}g({link:`${T}#pair=${e.body.credential}`,expiresAt:new Date(e.body.expiresAt).getTime()})}catch(e){S(e.message)}finally{b(!1)}}},k=async()=>{if(E)try{await navigator.clipboard.writeText(E),B.success(`Copied`)}catch(e){B.error(`Could not copy: ${e.message}`)}};return C?(0,z.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`label`,{htmlFor:`continue-address`,className:`text-xs text-muted-foreground`,children:`Address the other device opens`}),(0,z.jsx)(`select`,{id:`continue-address`,"aria-label":`Address the other device opens`,value:C,onChange:e=>{o(e.target.value),g(null),S(null)},className:`w-full bg-background border border-border rounded-md px-2 py-1.5 text-xs text-foreground focus:ring-1 focus:ring-primary`,children:w.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),i&&(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>{m(e.target.checked),g(null),S(null)}}),`Also pair the device`]}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{readOnly:!0,"aria-label":`Conversation link`,"data-testid":`continue-link`,value:E??``,onFocus:e=>e.target.select(),className:`flex-1 min-w-0 bg-background border border-border rounded-md px-2 py-1.5 text-xs text-foreground font-mono`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void k(),className:`shrink-0 ${ifr}`,children:`Copy`})]}),E&&(0,z.jsx)(rfr,{link:E}),i&&p&&(h?_?(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`This link expired`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void O(),disabled:y,className:ifr,children:`New link`})]}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:nfr(h.expiresAt)}):(0,z.jsx)(`button`,{type:`button`,onClick:()=>void O(),disabled:y,className:`rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:`Create pairing link`})),x&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:x})]}):(0,z.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No address another device can reach is trusted yet.`}),i?(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`input`,{type:`url`,"aria-label":`Address`,placeholder:`https://desk.tailnet.ts.net`,value:s,onChange:e=>{c(e.target.value),f(null)},className:`w-full bg-background border border-border rounded-md px-2 py-1.5 text-xs text-foreground font-mono focus:ring-1 focus:ring-primary`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void D(),disabled:l||s.trim()===``,className:ifr,children:`Add an address`}),d&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:d})]}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add an address from a browser on this machine (Settings → Anywhere).`})]})}function ofr(e,t){return!e.addresses.some(e=>!e.loopback)&&e.vault.state===`ready`&&wFe.has(t.harness)?`handoff`:`screen`}function sfr(){let e=ep(e=>e.target),t=ep(e=>e.close);return e?(0,z.jsx)(lfr,{target:e,onClose:t}):null}var cfr={screen:`Open on another screen`,handoff:`Hand off to another machine`};function lfr({target:e,onClose:t}){let{data:n,error:r,isLoading:i}=F({queryKey:DO,queryFn:gwt}),[a,o]=(0,L.useState)(null);(0,L.useEffect)(()=>{n&&a===null&&o(ofr(n,e))},[n,a,e]),(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let s=a??(n?ofr(n,e):`screen`);return(0,z.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:t,children:(0,z.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-2xl w-full max-w-md mx-4`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`continue-on-device-title`,"data-component":`continue-on-device-dialog`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 py-3 border-b border-border`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h3`,{id:`continue-on-device-title`,className:`text-base font-medium text-foreground`,children:`Continue on another device`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:e.title})]}),(0,z.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close`,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,z.jsx)(Os,{className:`w-5 h-5`})})]}),(0,z.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,z.jsx)(`div`,{role:`tablist`,className:`flex gap-1 border-b border-border`,children:[`screen`,`handoff`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":s===e,onClick:()=>o(e),className:`px-2.5 py-1.5 text-xs transition-colors -mb-px border-b-2 ${s===e?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:cfr[e]},e))}),i?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading…`}):r?(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:r.message}):n?s===`screen`?(0,z.jsx)(afr,{target:e,status:n}):(0,z.jsx)(efr,{target:e,status:n}):null]})]})})}var Z9={field:`_field_1an8l_1`,filter:`_filter_1an8l_7`,list:`_list_1an8l_22`,group:`_group_1an8l_29`,groupHeader:`_groupHeader_1an8l_37`,chevron:`_chevron_1an8l_60`,chevronOpen:`_chevronOpen_1an8l_68`,groupLabel:`_groupLabel_1an8l_72`,groupCount:`_groupCount_1an8l_80`,row:`_row_1an8l_86`,nameCell:`_nameCell_1an8l_99`,name:`_name_1an8l_99`,description:`_description_1an8l_114`,inherited:`_inherited_1an8l_122`,choices:`_choices_1an8l_128`,choice:`_choice_1an8l_128`,choiceSelected:`_choiceSelected_1an8l_149`,note:`_note_1an8l_154`},ufr=[[`project`,`Project skills`],[`overdeck`,`Overdeck`],[`personal`,`Personal`]],dfr=`/api/skills/overrides`;async function ffr(e,t){let n=new URLSearchParams;e&&n.set(`project`,e),t&&n.set(`issue`,t);let r=n.toString();return fetch(r?`${dfr}?${r}`:dfr)}function pfr(e){return{id:e.id,enabled:e.enabled,source:e.source,description:e.description??``}}async function mfr(e,t){let n=await ffr(e,t);if(!n.ok&&t&&(n=await ffr(e)),!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=new Map;for(let e of r.skills??[]){if(e.core)continue;let t=e.origin??`personal`,n=i.get(t)??[];n.push(pfr({id:e.name,enabled:e.enabled,source:e.source,description:e.description})),i.set(t,n)}let a=[];for(let[e,t]of ufr){let n=i.get(e);n?.length&&a.push({key:e,label:t,rows:[...n].sort((e,t)=>e.id.localeCompare(t.id))})}for(let e of r.packs??[]){let t=(e.skills??[]).map(pfr);t.length&&a.push({key:`pack:${e.id}`,label:e.id,rows:t.sort((e,t)=>e.id.localeCompare(t.id))})}return a}var hfr=[[null,`Inherit`],[!0,`On`],[!1,`Off`]];function gfr({projectKey:e,issueId:t,value:n,onChange:r}){let[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)({}),c=F({queryKey:[`new-conversation-skills`,e??``,t??``],queryFn:()=>mfr(e,t)}),l=c.data,u=(0,L.useMemo)(()=>(l??[]).flatMap(e=>e.rows),[l]);(0,L.useEffect)(()=>{if(!l)return;let e=new Set(u.map(e=>e.id)),t=Object.entries(n).filter(([t])=>e.has(t));t.length!==Object.keys(n).length&&r(Object.fromEntries(t))},[l,u,n,r]);let d=i.trim().toLowerCase(),f=d.length>0,p=(0,L.useMemo)(()=>(l??[]).map(e=>({group:e,rows:f?e.rows.filter(e=>e.id.toLowerCase().includes(d)||e.description.toLowerCase().includes(d)):e.rows})).filter(e=>e.rows.length>0),[l,f,d]),m=e=>f||(o[e.key]??e.rows.some(e=>Object.prototype.hasOwnProperty.call(n,e.id))),h=e=>s(t=>({...t,[e.key]:!m(e)})),g=(e,t,i)=>{let a={...n};i===null?delete a[t]:a[t]=i,r(a),s(t=>({...t,[e.key]:!0}))};return c.isLoading?(0,z.jsx)(`p`,{className:Z9.note,children:`Loading skills…`}):c.isError||!l?(0,z.jsx)(`p`,{className:Z9.note,children:`Skills unavailable`}):(0,z.jsxs)(`div`,{className:Z9.field,children:[(0,z.jsx)(`input`,{type:`text`,className:Z9.filter,"aria-label":`Filter skills`,placeholder:`Filter skills by name or description`,value:i,onChange:e=>a(e.target.value)}),(0,z.jsxs)(`div`,{className:Z9.list,children:[p.length===0&&(0,z.jsx)(`p`,{className:Z9.note,children:`No skills match.`}),p.map(({group:e,rows:t})=>{let r=m(e),i=e.rows.filter(e=>Object.prototype.hasOwnProperty.call(n,e.id)?n[e.id]:e.enabled).length;return(0,z.jsxs)(`div`,{className:Z9.group,children:[(0,z.jsxs)(`button`,{type:`button`,className:Z9.groupHeader,"aria-expanded":r,disabled:f,onClick:()=>h(e),children:[(0,z.jsx)(ho,{className:zc(Z9.chevron,r&&Z9.chevronOpen)}),(0,z.jsx)(`span`,{className:Z9.groupLabel,children:e.label}),` `,(0,z.jsxs)(`span`,{className:Z9.groupCount,children:[i,` on · `,e.rows.length]})]}),r&&t.map(t=>{let r=Object.prototype.hasOwnProperty.call(n,t.id)?n[t.id]:null;return(0,z.jsxs)(`div`,{className:Z9.row,"data-skill":t.id,children:[(0,z.jsxs)(`div`,{className:Z9.nameCell,children:[(0,z.jsx)(`span`,{className:Z9.name,children:t.id}),t.description&&(0,z.jsx)(`span`,{className:Z9.description,title:t.description,children:t.description})]}),(0,z.jsxs)(`span`,{className:Z9.inherited,children:[t.enabled?`On`:`Off`,` · `,t.source.replace(`-`,` `)]}),(0,z.jsx)(`div`,{role:`radiogroup`,"aria-label":t.id,className:Z9.choices,children:hfr.map(([n,i])=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r===n,className:zc(Z9.choice,r===n&&Z9.choiceSelected),onClick:()=>g(e,t.id,n),children:i},i))})]},t.id)})]},e.key)})]})]})}var Q9={picker:`_picker_13kbi_1`,input:`_input_13kbi_5`,list:`_list_13kbi_20`,option:`_option_13kbi_36`,optionActive:`_optionActive_13kbi_44`,identifier:`_identifier_13kbi_48`,title:`_title_13kbi_54`,selected:`_selected_13kbi_61`,selectedText:`_selectedText_13kbi_72`,clear:`_clear_13kbi_80`},_fr=20;function vfr({value:e,onChange:t}){let n=Wt(Lt),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(0),l=(0,L.useMemo)(()=>{let e=r.trim().toLowerCase();return n.filter(t=>!e||t.identifier.toLowerCase().includes(e)||(t.title??``).toLowerCase().includes(e)).slice(0,_fr)},[n,r]);if(e){let r=n.find(t=>t.identifier===e);return(0,z.jsxs)(`div`,{className:Q9.selected,children:[(0,z.jsx)(`span`,{className:Q9.selectedText,children:r?`${e} — ${r.title}`:e}),(0,z.jsx)(`button`,{type:`button`,className:Q9.clear,"aria-label":`Clear linked issue`,onClick:()=>t(null),children:(0,z.jsx)(Os,{size:12})})]})}let u=e=>{e&&(t(e.identifier),i(``),o(!1))},d=e=>{e.key===`Escape`?(a&&e.stopPropagation(),o(!1)):e.key===`ArrowDown`?(e.preventDefault(),o(!0),c(e=>Math.min(e+1,l.length-1))):e.key===`ArrowUp`?(e.preventDefault(),c(e=>Math.max(e-1,0))):e.key===`Enter`&&a&&(e.preventDefault(),u(l[s]))},f=`issue-picker-listbox`;return(0,z.jsxs)(`div`,{className:Q9.picker,children:[(0,z.jsx)(`input`,{type:`text`,role:`combobox`,"aria-label":`Link to an issue`,"aria-expanded":a,"aria-controls":f,"aria-autocomplete":`list`,className:Q9.input,placeholder:`Search issues`,value:r,onChange:e=>{i(e.target.value),c(0),o(!0)},onFocus:()=>o(!0),onBlur:()=>o(!1),onKeyDown:d}),a&&l.length>0&&(0,z.jsx)(`ul`,{id:f,role:`listbox`,className:Q9.list,children:l.map((e,t)=>(0,z.jsxs)(`li`,{role:`option`,"aria-selected":t===s,className:zc(Q9.option,t===s&&Q9.optionActive),onMouseDown:t=>{t.preventDefault(),u(e)},children:[(0,z.jsx)(`span`,{className:Q9.identifier,children:e.identifier}),(0,z.jsx)(`span`,{className:Q9.title,children:e.title})]},e.identifier))})]})}var $9={backdrop:`_backdrop_fq0lh_1`,dialog:`_dialog_fq0lh_12`,header:`_header_fq0lh_24`,title:`_title_fq0lh_32`,iconButton:`_iconButton_fq0lh_39`,body:`_body_fq0lh_53`,row:`_row_fq0lh_61`,group:`_group_fq0lh_68`,label:`_label_fq0lh_77`,control:`_control_fq0lh_86`,effort:`_effort_fq0lh_102`,hint:`_hint_fq0lh_110`,check:`_check_fq0lh_117`,textarea:`_textarea_fq0lh_125`,error:`_error_fq0lh_137`,footer:`_footer_fq0lh_143`,button:`_button_fq0lh_151`,primaryButton:`_primaryButton_fq0lh_152`};function yfr(e,t){if(t)return e.find(e=>e.key===t)??e.find(e=>e.name===t)}function bfr(e){return Qf(e)??Wx[e]??Tt}function xfr(){let e=Su(e=>e.open),t=Su(e=>e.projectKey),n=Su(e=>e.close);return e?(0,z.jsx)(Sfr,{presetProject:t,onClose:n}):null}function Sfr({presetProject:e,onClose:t}){let n=$t(),r=(0,L.useId)(),{groups:i,harnessPolicy:a}=Xf(),{data:o,isFetched:s}=F({queryKey:[`registered-projects`],queryFn:ku,staleTime:6e4}),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)(()=>Yx()),[g,_]=(0,L.useState)(()=>K8e()),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(!1),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(!1),[E,D]=(0,L.useState)({}),[O,k]=(0,L.useState)(null),[A,j]=(0,L.useState)(``),[ee,M]=(0,L.useState)(!1),[N,P]=(0,L.useState)(null),te=(0,L.useMemo)(()=>o?.find(e=>e.key===c),[o,c]);(0,L.useEffect)(()=>{if(u||!s)return;let t=yfr(o??[],e);t&&(l(t.key),p(t.path)),d(!0)},[u,s,o,e]);let ne=bfr(m),re=ne.length>0,{data:ie}=F({queryKey:[`new-conversation-effort-default`,m,g,O??``],queryFn:()=>r5e({model:m,harness:g,issueId:O}),enabled:re});(0,L.useEffect)(()=>{!b&&ie&&y(ie.effort)},[b,ie]),(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!ee&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,ee]);let ae=e=>{h(e),v&&!bfr(e).includes(v)&&(x(!1),y(null))},oe=e=>{let t=o?.find(t=>t.key===e);l(t?t.key:null),p(t?.path??``)};return(0,z.jsx)(`div`,{className:$9.backdrop,onClick:()=>{ee||t()},children:(0,z.jsxs)(`form`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":r,className:$9.dialog,onClick:e=>e.stopPropagation(),onSubmit:async e=>{e.preventDefault(),M(!0),P(null);try{let e=await a5e(i5e({projectKey:c,projectPath:te?.path??null,cwd:f,model:m,harness:g,effort:re?v??ie?.effort??null:null,bareContext:S,skipClaudeMd:w,skillOverrides:E,issueId:O,message:A}));t(),n.invalidateQueries({queryKey:[`conversations`]}),window.history.pushState({},``,`/conv/${e.id}`),window.dispatchEvent(new PopStateEvent(`popstate`))}catch(e){P(e instanceof Error?e.message:String(e)),M(!1)}},children:[(0,z.jsxs)(`div`,{className:$9.header,children:[(0,z.jsx)(`h2`,{id:r,className:$9.title,children:`New conversation with options`}),(0,z.jsx)(`button`,{type:`button`,className:$9.iconButton,"aria-label":`Close`,onClick:t,disabled:ee,children:(0,z.jsx)(Os,{size:14})})]}),(0,z.jsxs)(`div`,{className:$9.body,children:[(0,z.jsxs)(`label`,{className:$9.row,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Project`}),(0,z.jsxs)(`select`,{"aria-label":`Project`,className:$9.control,value:c??``,onChange:e=>oe(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`No project`}),(o??[]).map(e=>(0,z.jsx)(`option`,{value:e.key,children:e.name??e.key},e.key))]})]}),(0,z.jsxs)(`label`,{className:$9.row,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Working directory`}),(0,z.jsx)(`input`,{"aria-label":`Working directory`,className:$9.control,value:f,disabled:!c,placeholder:c?``:`Default working directory`,onChange:e=>p(e.target.value)})]}),(0,z.jsx)($Pe,{label:`Model`,value:m,onChange:ae,groups:i}),(0,z.jsx)(eFe,{value:g,onChange:_,modelId:m,harnessPolicy:a}),(0,z.jsxs)(`div`,{className:$9.row,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Effort`}),re?(0,z.jsxs)(`div`,{className:$9.effort,children:[(0,z.jsxs)(`select`,{"aria-label":`Effort`,className:$9.control,value:v??``,onChange:e=>{y(e.target.value),x(!0)},children:[v===null&&(0,z.jsx)(`option`,{value:``,children:`…`}),ne.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),ie&&(0,z.jsxs)(`span`,{className:$9.hint,children:[`Default: `,ie.effort,` (`,ie.source,`)`,ie.clamped?` · clamped from ${ie.requested}`:``]})]}):(0,z.jsx)(`span`,{className:$9.hint,children:`Not supported by this model`})]}),(0,z.jsxs)(`fieldset`,{className:$9.group,children:[(0,z.jsx)(`legend`,{className:$9.label,children:`Context`}),(0,z.jsxs)(`label`,{className:$9.check,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),`No context`]}),(0,z.jsx)(`p`,{className:$9.hint,children:`New conversations start without Overdeck context: no bundled rules, session briefing, memory injection or resume message. Faster to spawn.`}),g===`claude-code`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:$9.check,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked)}),`Skip CLAUDE.md`]}),(0,z.jsx)(`p`,{className:$9.hint,children:`Claude Code skips ~/.claude/CLAUDE.md, project CLAUDE.md files and auto memory (CLAUDE_CODE_DISABLE_CLAUDE_MDS).`})]})]}),(0,z.jsxs)(`div`,{className:$9.group,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Skills`}),(0,z.jsx)(gfr,{projectKey:c??void 0,issueId:O??void 0,value:E,onChange:D})]}),(0,z.jsxs)(`div`,{className:$9.group,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Linked issue`}),(0,z.jsx)(vfr,{value:O,onChange:k})]}),(0,z.jsxs)(`label`,{className:$9.group,children:[(0,z.jsx)(`span`,{className:$9.label,children:`First message`}),(0,z.jsx)(`textarea`,{"aria-label":`First message`,className:$9.textarea,rows:3,placeholder:`Optional`,value:A,onChange:e=>j(e.target.value)})]}),N&&(0,z.jsx)(`p`,{role:`alert`,className:$9.error,children:N})]}),(0,z.jsxs)(`div`,{className:$9.footer,children:[(0,z.jsx)(`button`,{type:`button`,className:$9.button,onClick:t,disabled:ee,children:`Cancel`}),(0,z.jsx)(`button`,{type:`submit`,className:$9.primaryButton,"aria-label":`Create conversation`,disabled:ee,children:ee?`Creating…`:`Create`})]})]})})}Bde(),y_.getState().reconcileFromServer(),Wdr();function Cfr(e){if(e instanceof TypeError){let t=e.message.toLowerCase();return t.includes(`failed to fetch`)||t.includes(`networkerror`)||t.includes(`network request failed`)}return!1}var wfr=new sre({defaultOptions:{queries:{refetchInterval:6e4,staleTime:3e4,refetchIntervalInBackground:!1,retry:(e,t)=>Cfr(t)&&e<3},mutations:{retry:(e,t)=>Cfr(t)&&e<3,retryDelay:e=>Math.min(1e3*2**e,8e3)}}});zWt(wfr),dre.createRoot(document.getElementById(`root`)).render((0,z.jsx)(L.StrictMode,{children:(0,z.jsx)(Gdr,{children:(0,z.jsx)(De,{client:wfr,children:(0,z.jsxs)(Qpe,{children:[(0,z.jsx)(jdr,{}),(0,z.jsx)(GFe,{}),(0,z.jsx)(sfr,{}),(0,z.jsx)(xfr,{}),(0,z.jsx)(LQe,{})]})})})})),window.__panMounted=!0;export{KM as A,XM as C,qM as D,FYt as E,gM as F,RJt as I,wYt as M,DM as N,ZM as O,oYt as P,QM as S,JM as T,iN as _,HYt as a,$M as b,oN as c,BYt as d,WYt as f,LYt as g,rN as h,uN as i,AYt as j,IYt as k,VYt as l,qYt as m,fN as n,RYt as o,cN as p,lN as r,UYt as s,dN as t,zYt as u,tN as v,YM as w,eN as x,nN as y};
1618
+ `;let r=n.querySelector(`[data-pan-recovery-message="true"]`);if(r&&(r.textContent=e),t){let e=n.querySelector(`[data-pan-recovery-action="true"]`);e&&(e.textContent=t.label,e.addEventListener(`click`,t.onClick))}document.body.appendChild(n)}async function X9(e){if(Rdr)return;Rdr=!0,e.trigger===`root_error_boundary`&&Udr(`Reconnecting to the dashboard…`);let t=Number(sessionStorage.getItem(Pdr)||`0`);for(let e=0;;e++){try{if((await fetch(`/`,{cache:`no-store`})).ok)break}catch{}await Wdr(Math.min(500+e*250,3e3))}Date.now()-t<4e3&&await Wdr(2e3);let n=Vdr();if(Hdr(e,n),!n.shouldReload){Udr(`The dashboard stopped automatic recovery after repeated load failures.${e.resource?` Failing resource: ${e.resource}`:``}`,{label:`Reload dashboard`,onClick:()=>window.location.reload()});return}window.location.reload()}function Wdr(e){return new Promise(t=>setTimeout(t,e))}function Gdr(){window.addEventListener(`vite:preloadError`,e=>{e.preventDefault();let t=e.payload,n=q9(t);X9({trigger:`vite_preload_error`,resource:Y9(n),message:n||void 0,stackHead:J9(t)})}),window.addEventListener(`error`,e=>{let t=Bdr(e.target);if(t){X9({trigger:`asset_load_error`,resource:t,message:e.message||`Module asset failed to load`});return}let n=e.error??e.message;if(zdr(n)){let e=q9(n);X9({trigger:`window_module_error`,resource:Y9(e),message:e||void 0,stackHead:J9(n)})}},!0),window.addEventListener(`unhandledrejection`,e=>{if(zdr(e.reason)){let t=q9(e.reason);X9({trigger:`unhandled_rejection`,resource:Y9(t),message:t||void 0,stackHead:J9(e.reason)})}})}var Kdr=class extends L.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){if(io(e,{action:`frontend_unhandled_error`,trigger:`root_error_boundary`}),zdr(e)){let t=q9(e);X9({trigger:`root_error_boundary`,resource:Y9(t),message:t||void 0,stackHead:J9(e)})}}render(){return this.state.hasError?(0,z.jsxs)(`div`,{style:{position:`fixed`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:16,background:`rgba(10,12,16,0.92)`,color:`#e6e6e6`,fontFamily:`var(--font-sans),system-ui,sans-serif`,fontSize:15},children:[(0,z.jsx)(`div`,{children:`The dashboard hit an error.`}),(0,z.jsx)(`button`,{onClick:()=>window.location.reload(),style:{padding:`8px 18px`,borderRadius:8,border:`1px solid rgba(255,255,255,0.2)`,background:`#1b2533`,color:`#e6e6e6`,cursor:`pointer`,fontSize:14},children:`Reload dashboard`})]}):this.props.children}},qdr=`https://overdeck.ai/configuration/session-vault`,Jdr=`rounded-md border border-border px-2.5 py-1 text-xs text-foreground hover:bg-muted/50 transition-colors disabled:opacity-50`,Ydr=`block rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground break-all`;function Xdr(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Zdr(e){return e!==null&&typeof e.result==`string`}function Qdr(){NFe(),ep.getState().close()}function $dr({target:e,status:t}){if(!wFe.has(e.harness))return(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Hand-off works for Claude Code and Codex conversations. This conversation runs on `,e.harness,`.`]});switch(t.vault.state){case`off`:return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Hand-off needs the Session Vault, which is off on this machine.`}),(0,z.jsx)(`button`,{type:`button`,onClick:Qdr,className:Jdr,children:`Set up`})]});case`locked`:return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This machine cannot open the Session Vault until it is unlocked.`}),(0,z.jsx)(`button`,{type:`button`,onClick:Qdr,className:Jdr,children:`Open Session Vault`})]});case`rotation-pending`:return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A vault key rotation started on this machine has not finished.`}),(0,z.jsx)(`a`,{href:qdr,target:`_blank`,rel:`noreferrer`,className:`text-xs text-primary hover:underline`,children:`How to finish it`})]});case`ready`:return null}}function efr({outcome:e}){let{status:t,body:n}=e;if(!Zdr(n))return(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:n?.error??`Hand-off failed (${t}).`});switch(n.result){case`saved`:{let e=Xdr(n.savedAt),t=`On your other machine, open "${n.title}" from ${n.machineLabel} and click Continue here.`;return n.wipProblem?(0,z.jsxs)(`div`,{className:`space-y-2`,"data-testid":`handoff-result`,children:[(0,z.jsxs)(`p`,{className:`text-xs text-foreground`,children:[`The conversation was saved (version `,n.version,`), but its code snapshot was not.`]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.wipProblem.message}),n.wipProblem.fix&&(0,z.jsx)(`code`,{className:Ydr,children:n.wipProblem.fix})]}):(0,z.jsx)(`p`,{className:`text-xs text-foreground`,"data-testid":`handoff-result`,children:n.forkedFrom?`Saved as version ${n.version} at ${e} as a separate copy, because another machine already continued this conversation. ${t}`:`Saved as version ${n.version} at ${e}. ${t}`})}case`blocked`:return(0,z.jsxs)(`div`,{className:`space-y-2`,"data-testid":`handoff-result`,children:[(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:`Not saved. The secret scan blocked:`}),(0,z.jsx)(`ul`,{className:`text-xs text-foreground`,children:n.hits.map(e=>(0,z.jsxs)(`li`,{children:[`line `,e.line,`: `,e.pattern]},`${e.line}-${e.pattern}`))}),n.fixes.map(e=>(0,z.jsx)(`code`,{className:Ydr,children:e},e)),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`After allowing a line, click Hand off now again.`})]});case`offline`:return(0,z.jsxs)(`div`,{className:`space-y-2`,"data-testid":`handoff-result`,children:[(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),(0,z.jsx)(`code`,{className:Ydr,children:n.fix})]});default:return(0,z.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`handoff-result`,children:n.error})}}function tfr({target:e,status:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(null);if(!wFe.has(e.harness)||t.vault.state!==`ready`)return(0,z.jsx)(`div`,{className:`text-sm`,children:(0,z.jsx)($dr,{target:e,status:t})});let o=async()=>{r(!0);try{let t=await AFe(e.name);a(t);let n=t.body;t.status===200&&Zdr(n)&&n.result===`saved`&&n.wipProblem===null&&e.sessionAlive&&mS.getState().record(e.name,n.savedAt)}catch(e){a({status:0,body:{error:e.message}})}finally{r(!1)}};return(0,z.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saves this conversation to the Session Vault now, so your other machine can continue it.`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void o(),disabled:n,className:`rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:n?`Handing off…`:`Hand off now`}),i&&(0,z.jsx)(efr,{outcome:i})]})}function nfr(e){try{let t=new URL(e.trim());return t.protocol===`http:`||t.protocol===`https:`?t.origin:null}catch{return null}}function rfr(e){let t=Math.max(1,Math.round((e-Date.now())/6e4));return`Expires in ${t} minute${t===1?``:`s`} · works once`}function ifr({link:e}){let t=(0,L.useMemo)(()=>{let t=WA(0,`M`);return t.addData(e),t.make(),t.createDataURL(6,8)},[e]);return(0,z.jsx)(`img`,{alt:`Conversation QR code`,src:t,className:`rounded-md bg-white p-1 w-48 h-48`})}var afr=`rounded-md border border-border px-2.5 py-1 text-xs text-foreground hover:bg-muted/50 transition-colors disabled:opacity-50`;function ofr({target:e,status:t}){let n=$t(),r=(0,L.useMemo)(()=>t.addresses.filter(e=>!e.loopback),[t]),i=t.viewer.kind===`root-session`,[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(!0),[h,g]=(0,L.useState)(null),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(!1),[x,S]=(0,L.useState)(null),C=a??r[0]?.origin??null,w=[...r.map(e=>e.origin),...a&&!r.some(e=>e.origin===a)?[a]:[]];(0,L.useEffect)(()=>{if(!h)return;v(!1);let e=setTimeout(()=>v(!0),Math.max(0,h.expiresAt-Date.now()));return()=>clearTimeout(e)},[h]);let T=C?`${C.replace(/\/+$/,``)}/conv/${e.id}${e.viewMode===`terminal`?`?view=terminal`:``}`:null,E=h&&!_?h.link:T,D=async()=>{let e=nfr(s);if(!e){f(`Enter an http:// or https:// address.`);return}u(!0),f(null);try{let t=await mwt(e);if(!AO(t)){f(kO(t));return}await n.invalidateQueries({queryKey:DO}),o(t.body.origin),c(``)}catch(e){f(e.message)}finally{u(!1)}},O=async()=>{if(T){b(!0),S(null);try{let e=await pwt();if(e.status===403){S(`Pairing links can be created only from a browser on this machine. Open the dashboard on the machine itself.`);return}if(!AO(e)){S(kO(e));return}g({link:`${T}#pair=${e.body.credential}`,expiresAt:new Date(e.body.expiresAt).getTime()})}catch(e){S(e.message)}finally{b(!1)}}},k=async()=>{if(E)try{await navigator.clipboard.writeText(E),B.success(`Copied`)}catch(e){B.error(`Could not copy: ${e.message}`)}};return C?(0,z.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`label`,{htmlFor:`continue-address`,className:`text-xs text-muted-foreground`,children:`Address the other device opens`}),(0,z.jsx)(`select`,{id:`continue-address`,"aria-label":`Address the other device opens`,value:C,onChange:e=>{o(e.target.value),g(null),S(null)},className:`w-full bg-background border border-border rounded-md px-2 py-1.5 text-xs text-foreground focus:ring-1 focus:ring-primary`,children:w.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),i&&(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>{m(e.target.checked),g(null),S(null)}}),`Also pair the device`]}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{readOnly:!0,"aria-label":`Conversation link`,"data-testid":`continue-link`,value:E??``,onFocus:e=>e.target.select(),className:`flex-1 min-w-0 bg-background border border-border rounded-md px-2 py-1.5 text-xs text-foreground font-mono`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void k(),className:`shrink-0 ${afr}`,children:`Copy`})]}),E&&(0,z.jsx)(ifr,{link:E}),i&&p&&(h?_?(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`This link expired`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void O(),disabled:y,className:afr,children:`New link`})]}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:rfr(h.expiresAt)}):(0,z.jsx)(`button`,{type:`button`,onClick:()=>void O(),disabled:y,className:`rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:`Create pairing link`})),x&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:x})]}):(0,z.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No address another device can reach is trusted yet.`}),i?(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`input`,{type:`url`,"aria-label":`Address`,placeholder:`https://desk.tailnet.ts.net`,value:s,onChange:e=>{c(e.target.value),f(null)},className:`w-full bg-background border border-border rounded-md px-2 py-1.5 text-xs text-foreground font-mono focus:ring-1 focus:ring-primary`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void D(),disabled:l||s.trim()===``,className:afr,children:`Add an address`}),d&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:d})]}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add an address from a browser on this machine (Settings → Anywhere).`})]})}function sfr(e,t){return!e.addresses.some(e=>!e.loopback)&&e.vault.state===`ready`&&wFe.has(t.harness)?`handoff`:`screen`}function cfr(){let e=ep(e=>e.target),t=ep(e=>e.close);return e?(0,z.jsx)(ufr,{target:e,onClose:t}):null}var lfr={screen:`Open on another screen`,handoff:`Hand off to another machine`};function ufr({target:e,onClose:t}){let{data:n,error:r,isLoading:i}=F({queryKey:DO,queryFn:gwt}),[a,o]=(0,L.useState)(null);(0,L.useEffect)(()=>{n&&a===null&&o(sfr(n,e))},[n,a,e]),(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let s=a??(n?sfr(n,e):`screen`);return(0,z.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:t,children:(0,z.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-2xl w-full max-w-md mx-4`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`continue-on-device-title`,"data-component":`continue-on-device-dialog`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 py-3 border-b border-border`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h3`,{id:`continue-on-device-title`,className:`text-base font-medium text-foreground`,children:`Continue on another device`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:e.title})]}),(0,z.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close`,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,z.jsx)(Os,{className:`w-5 h-5`})})]}),(0,z.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,z.jsx)(`div`,{role:`tablist`,className:`flex gap-1 border-b border-border`,children:[`screen`,`handoff`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":s===e,onClick:()=>o(e),className:`px-2.5 py-1.5 text-xs transition-colors -mb-px border-b-2 ${s===e?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:lfr[e]},e))}),i?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading…`}):r?(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:r.message}):n?s===`screen`?(0,z.jsx)(ofr,{target:e,status:n}):(0,z.jsx)(tfr,{target:e,status:n}):null]})]})})}var Z9={field:`_field_1an8l_1`,filter:`_filter_1an8l_7`,list:`_list_1an8l_22`,group:`_group_1an8l_29`,groupHeader:`_groupHeader_1an8l_37`,chevron:`_chevron_1an8l_60`,chevronOpen:`_chevronOpen_1an8l_68`,groupLabel:`_groupLabel_1an8l_72`,groupCount:`_groupCount_1an8l_80`,row:`_row_1an8l_86`,nameCell:`_nameCell_1an8l_99`,name:`_name_1an8l_99`,description:`_description_1an8l_114`,inherited:`_inherited_1an8l_122`,choices:`_choices_1an8l_128`,choice:`_choice_1an8l_128`,choiceSelected:`_choiceSelected_1an8l_149`,note:`_note_1an8l_154`},dfr=[[`project`,`Project skills`],[`overdeck`,`Overdeck`],[`personal`,`Personal`]],ffr=`/api/skills/overrides`;async function pfr(e,t){let n=new URLSearchParams;e&&n.set(`project`,e),t&&n.set(`issue`,t);let r=n.toString();return fetch(r?`${ffr}?${r}`:ffr)}function mfr(e){return{id:e.id,enabled:e.enabled,source:e.source,description:e.description??``}}async function hfr(e,t){let n=await pfr(e,t);if(!n.ok&&t&&(n=await pfr(e)),!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json(),i=new Map;for(let e of r.skills??[]){if(e.core)continue;let t=e.origin??`personal`,n=i.get(t)??[];n.push(mfr({id:e.name,enabled:e.enabled,source:e.source,description:e.description})),i.set(t,n)}let a=[];for(let[e,t]of dfr){let n=i.get(e);n?.length&&a.push({key:e,label:t,rows:[...n].sort((e,t)=>e.id.localeCompare(t.id))})}for(let e of r.packs??[]){let t=(e.skills??[]).map(mfr);t.length&&a.push({key:`pack:${e.id}`,label:e.id,rows:t.sort((e,t)=>e.id.localeCompare(t.id))})}return a}var gfr=[[null,`Inherit`],[!0,`On`],[!1,`Off`]];function _fr({projectKey:e,issueId:t,value:n,onChange:r}){let[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)({}),c=F({queryKey:[`new-conversation-skills`,e??``,t??``],queryFn:()=>hfr(e,t)}),l=c.data,u=(0,L.useMemo)(()=>(l??[]).flatMap(e=>e.rows),[l]);(0,L.useEffect)(()=>{if(!l)return;let e=new Set(u.map(e=>e.id)),t=Object.entries(n).filter(([t])=>e.has(t));t.length!==Object.keys(n).length&&r(Object.fromEntries(t))},[l,u,n,r]);let d=i.trim().toLowerCase(),f=d.length>0,p=(0,L.useMemo)(()=>(l??[]).map(e=>({group:e,rows:f?e.rows.filter(e=>e.id.toLowerCase().includes(d)||e.description.toLowerCase().includes(d)):e.rows})).filter(e=>e.rows.length>0),[l,f,d]),m=e=>f||(o[e.key]??e.rows.some(e=>Object.prototype.hasOwnProperty.call(n,e.id))),h=e=>s(t=>({...t,[e.key]:!m(e)})),g=(e,t,i)=>{let a={...n};i===null?delete a[t]:a[t]=i,r(a),s(t=>({...t,[e.key]:!0}))};return c.isLoading?(0,z.jsx)(`p`,{className:Z9.note,children:`Loading skills…`}):c.isError||!l?(0,z.jsx)(`p`,{className:Z9.note,children:`Skills unavailable`}):(0,z.jsxs)(`div`,{className:Z9.field,children:[(0,z.jsx)(`input`,{type:`text`,className:Z9.filter,"aria-label":`Filter skills`,placeholder:`Filter skills by name or description`,value:i,onChange:e=>a(e.target.value)}),(0,z.jsxs)(`div`,{className:Z9.list,children:[p.length===0&&(0,z.jsx)(`p`,{className:Z9.note,children:`No skills match.`}),p.map(({group:e,rows:t})=>{let r=m(e),i=e.rows.filter(e=>Object.prototype.hasOwnProperty.call(n,e.id)?n[e.id]:e.enabled).length;return(0,z.jsxs)(`div`,{className:Z9.group,children:[(0,z.jsxs)(`button`,{type:`button`,className:Z9.groupHeader,"aria-expanded":r,disabled:f,onClick:()=>h(e),children:[(0,z.jsx)(ho,{className:zc(Z9.chevron,r&&Z9.chevronOpen)}),(0,z.jsx)(`span`,{className:Z9.groupLabel,children:e.label}),` `,(0,z.jsxs)(`span`,{className:Z9.groupCount,children:[i,` on · `,e.rows.length]})]}),r&&t.map(t=>{let r=Object.prototype.hasOwnProperty.call(n,t.id)?n[t.id]:null;return(0,z.jsxs)(`div`,{className:Z9.row,"data-skill":t.id,children:[(0,z.jsxs)(`div`,{className:Z9.nameCell,children:[(0,z.jsx)(`span`,{className:Z9.name,children:t.id}),t.description&&(0,z.jsx)(`span`,{className:Z9.description,title:t.description,children:t.description})]}),(0,z.jsxs)(`span`,{className:Z9.inherited,children:[t.enabled?`On`:`Off`,` · `,t.source.replace(`-`,` `)]}),(0,z.jsx)(`div`,{role:`radiogroup`,"aria-label":t.id,className:Z9.choices,children:gfr.map(([n,i])=>(0,z.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r===n,className:zc(Z9.choice,r===n&&Z9.choiceSelected),onClick:()=>g(e,t.id,n),children:i},i))})]},t.id)})]},e.key)})]})]})}var Q9={picker:`_picker_13kbi_1`,input:`_input_13kbi_5`,list:`_list_13kbi_20`,option:`_option_13kbi_36`,optionActive:`_optionActive_13kbi_44`,identifier:`_identifier_13kbi_48`,title:`_title_13kbi_54`,selected:`_selected_13kbi_61`,selectedText:`_selectedText_13kbi_72`,clear:`_clear_13kbi_80`},vfr=20;function yfr({value:e,onChange:t}){let n=Wt(Lt),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(0),l=(0,L.useMemo)(()=>{let e=r.trim().toLowerCase();return n.filter(t=>!e||t.identifier.toLowerCase().includes(e)||(t.title??``).toLowerCase().includes(e)).slice(0,vfr)},[n,r]);if(e){let r=n.find(t=>t.identifier===e);return(0,z.jsxs)(`div`,{className:Q9.selected,children:[(0,z.jsx)(`span`,{className:Q9.selectedText,children:r?`${e} — ${r.title}`:e}),(0,z.jsx)(`button`,{type:`button`,className:Q9.clear,"aria-label":`Clear linked issue`,onClick:()=>t(null),children:(0,z.jsx)(Os,{size:12})})]})}let u=e=>{e&&(t(e.identifier),i(``),o(!1))},d=e=>{e.key===`Escape`?(a&&e.stopPropagation(),o(!1)):e.key===`ArrowDown`?(e.preventDefault(),o(!0),c(e=>Math.min(e+1,l.length-1))):e.key===`ArrowUp`?(e.preventDefault(),c(e=>Math.max(e-1,0))):e.key===`Enter`&&a&&(e.preventDefault(),u(l[s]))},f=`issue-picker-listbox`;return(0,z.jsxs)(`div`,{className:Q9.picker,children:[(0,z.jsx)(`input`,{type:`text`,role:`combobox`,"aria-label":`Link to an issue`,"aria-expanded":a,"aria-controls":f,"aria-autocomplete":`list`,className:Q9.input,placeholder:`Search issues`,value:r,onChange:e=>{i(e.target.value),c(0),o(!0)},onFocus:()=>o(!0),onBlur:()=>o(!1),onKeyDown:d}),a&&l.length>0&&(0,z.jsx)(`ul`,{id:f,role:`listbox`,className:Q9.list,children:l.map((e,t)=>(0,z.jsxs)(`li`,{role:`option`,"aria-selected":t===s,className:zc(Q9.option,t===s&&Q9.optionActive),onMouseDown:t=>{t.preventDefault(),u(e)},children:[(0,z.jsx)(`span`,{className:Q9.identifier,children:e.identifier}),(0,z.jsx)(`span`,{className:Q9.title,children:e.title})]},e.identifier))})]})}var $9={backdrop:`_backdrop_fq0lh_1`,dialog:`_dialog_fq0lh_12`,header:`_header_fq0lh_24`,title:`_title_fq0lh_32`,iconButton:`_iconButton_fq0lh_39`,body:`_body_fq0lh_53`,row:`_row_fq0lh_61`,group:`_group_fq0lh_68`,label:`_label_fq0lh_77`,control:`_control_fq0lh_86`,effort:`_effort_fq0lh_102`,hint:`_hint_fq0lh_110`,check:`_check_fq0lh_117`,textarea:`_textarea_fq0lh_125`,error:`_error_fq0lh_137`,footer:`_footer_fq0lh_143`,button:`_button_fq0lh_151`,primaryButton:`_primaryButton_fq0lh_152`};function bfr(e,t){if(t)return e.find(e=>e.key===t)??e.find(e=>e.name===t)}function xfr(e){return Qf(e)??Wx[e]??Tt}function Sfr(){let e=Su(e=>e.open),t=Su(e=>e.projectKey),n=Su(e=>e.close);return e?(0,z.jsx)(Cfr,{presetProject:t,onClose:n}):null}function Cfr({presetProject:e,onClose:t}){let n=$t(),r=(0,L.useId)(),{groups:i,harnessPolicy:a}=Xf(),{data:o,isFetched:s}=F({queryKey:[`registered-projects`],queryFn:ku,staleTime:6e4}),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)(()=>Yx()),[g,_]=(0,L.useState)(()=>K8e()),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(!1),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(!1),[E,D]=(0,L.useState)({}),[O,k]=(0,L.useState)(null),[A,j]=(0,L.useState)(``),[ee,M]=(0,L.useState)(!1),[N,P]=(0,L.useState)(null),te=(0,L.useMemo)(()=>o?.find(e=>e.key===c),[o,c]);(0,L.useEffect)(()=>{if(u||!s)return;let t=bfr(o??[],e);t&&(l(t.key),p(t.path)),d(!0)},[u,s,o,e]);let ne=xfr(m),re=ne.length>0,{data:ie}=F({queryKey:[`new-conversation-effort-default`,m,g,O??``],queryFn:()=>r5e({model:m,harness:g,issueId:O}),enabled:re});(0,L.useEffect)(()=>{!b&&ie&&y(ie.effort)},[b,ie]),(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!ee&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,ee]);let ae=e=>{h(e),v&&!xfr(e).includes(v)&&(x(!1),y(null))},oe=e=>{let t=o?.find(t=>t.key===e);l(t?t.key:null),p(t?.path??``)};return(0,z.jsx)(`div`,{className:$9.backdrop,onClick:()=>{ee||t()},children:(0,z.jsxs)(`form`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":r,className:$9.dialog,onClick:e=>e.stopPropagation(),onSubmit:async e=>{e.preventDefault(),M(!0),P(null);try{let e=await a5e(i5e({projectKey:c,projectPath:te?.path??null,cwd:f,model:m,harness:g,effort:re?v??ie?.effort??null:null,bareContext:S,skipClaudeMd:w,skillOverrides:E,issueId:O,message:A}));t(),n.invalidateQueries({queryKey:[`conversations`]}),window.history.pushState({},``,`/conv/${e.id}`),window.dispatchEvent(new PopStateEvent(`popstate`))}catch(e){P(e instanceof Error?e.message:String(e)),M(!1)}},children:[(0,z.jsxs)(`div`,{className:$9.header,children:[(0,z.jsx)(`h2`,{id:r,className:$9.title,children:`New conversation with options`}),(0,z.jsx)(`button`,{type:`button`,className:$9.iconButton,"aria-label":`Close`,onClick:t,disabled:ee,children:(0,z.jsx)(Os,{size:14})})]}),(0,z.jsxs)(`div`,{className:$9.body,children:[(0,z.jsxs)(`label`,{className:$9.row,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Project`}),(0,z.jsxs)(`select`,{"aria-label":`Project`,className:$9.control,value:c??``,onChange:e=>oe(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`No project`}),(o??[]).map(e=>(0,z.jsx)(`option`,{value:e.key,children:e.name??e.key},e.key))]})]}),(0,z.jsxs)(`label`,{className:$9.row,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Working directory`}),(0,z.jsx)(`input`,{"aria-label":`Working directory`,className:$9.control,value:f,disabled:!c,placeholder:c?``:`Default working directory`,onChange:e=>p(e.target.value)})]}),(0,z.jsx)($Pe,{label:`Model`,value:m,onChange:ae,groups:i}),(0,z.jsx)(eFe,{value:g,onChange:_,modelId:m,harnessPolicy:a}),(0,z.jsxs)(`div`,{className:$9.row,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Effort`}),re?(0,z.jsxs)(`div`,{className:$9.effort,children:[(0,z.jsxs)(`select`,{"aria-label":`Effort`,className:$9.control,value:v??``,onChange:e=>{y(e.target.value),x(!0)},children:[v===null&&(0,z.jsx)(`option`,{value:``,children:`…`}),ne.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),ie&&(0,z.jsxs)(`span`,{className:$9.hint,children:[`Default: `,ie.effort,` (`,ie.source,`)`,ie.clamped?` · clamped from ${ie.requested}`:``]})]}):(0,z.jsx)(`span`,{className:$9.hint,children:`Not supported by this model`})]}),(0,z.jsxs)(`fieldset`,{className:$9.group,children:[(0,z.jsx)(`legend`,{className:$9.label,children:`Context`}),(0,z.jsxs)(`label`,{className:$9.check,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),`No context`]}),(0,z.jsx)(`p`,{className:$9.hint,children:`New conversations start without Overdeck context: no bundled rules, session briefing, memory injection or resume message. Faster to spawn.`}),g===`claude-code`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:$9.check,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked)}),`Skip CLAUDE.md`]}),(0,z.jsx)(`p`,{className:$9.hint,children:`Claude Code skips ~/.claude/CLAUDE.md, project CLAUDE.md files and auto memory (CLAUDE_CODE_DISABLE_CLAUDE_MDS).`})]})]}),(0,z.jsxs)(`div`,{className:$9.group,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Skills`}),(0,z.jsx)(_fr,{projectKey:c??void 0,issueId:O??void 0,value:E,onChange:D})]}),(0,z.jsxs)(`div`,{className:$9.group,children:[(0,z.jsx)(`span`,{className:$9.label,children:`Linked issue`}),(0,z.jsx)(yfr,{value:O,onChange:k})]}),(0,z.jsxs)(`label`,{className:$9.group,children:[(0,z.jsx)(`span`,{className:$9.label,children:`First message`}),(0,z.jsx)(`textarea`,{"aria-label":`First message`,className:$9.textarea,rows:3,placeholder:`Optional`,value:A,onChange:e=>j(e.target.value)})]}),N&&(0,z.jsx)(`p`,{role:`alert`,className:$9.error,children:N})]}),(0,z.jsxs)(`div`,{className:$9.footer,children:[(0,z.jsx)(`button`,{type:`button`,className:$9.button,onClick:t,disabled:ee,children:`Cancel`}),(0,z.jsx)(`button`,{type:`submit`,className:$9.primaryButton,"aria-label":`Create conversation`,disabled:ee,children:ee?`Creating…`:`Create`})]})]})})}Bde(),y_.getState().reconcileFromServer(),Gdr();function wfr(e){if(e instanceof TypeError){let t=e.message.toLowerCase();return t.includes(`failed to fetch`)||t.includes(`networkerror`)||t.includes(`network request failed`)}return!1}var Tfr=new sre({defaultOptions:{queries:{refetchInterval:6e4,staleTime:3e4,refetchIntervalInBackground:!1,retry:(e,t)=>wfr(t)&&e<3},mutations:{retry:(e,t)=>wfr(t)&&e<3,retryDelay:e=>Math.min(1e3*2**e,8e3)}}});zWt(Tfr),dre.createRoot(document.getElementById(`root`)).render((0,z.jsx)(L.StrictMode,{children:(0,z.jsx)(Kdr,{children:(0,z.jsx)(De,{client:Tfr,children:(0,z.jsxs)(Qpe,{children:[(0,z.jsx)(Mdr,{}),(0,z.jsx)(GFe,{}),(0,z.jsx)(cfr,{}),(0,z.jsx)(Sfr,{}),(0,z.jsx)(LQe,{})]})})})})),window.__panMounted=!0;export{KM as A,XM as C,qM as D,FYt as E,gM as F,RJt as I,wYt as M,DM as N,ZM as O,oYt as P,QM as S,JM as T,iN as _,HYt as a,$M as b,oN as c,BYt as d,WYt as f,LYt as g,rN as h,uN as i,AYt as j,IYt as k,VYt as l,qYt as m,fN as n,RYt as o,cN as p,lN as r,UYt as s,dN as t,zYt as u,tN as v,YM as w,eN as x,nN as y};