epiq 1.9.0 → 1.10.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 (799) hide show
  1. package/dist/gui/abap-2J4LSWVV.js +1 -0
  2. package/dist/gui/actionscript-3-QBCO7GBI.js +1 -0
  3. package/dist/gui/ada-D5ESCCWX.js +1 -0
  4. package/dist/gui/ahk-7PFXBG6H.js +1 -0
  5. package/dist/gui/ahk2-K5PQCZEP.js +1 -0
  6. package/dist/gui/andromeeda-RHRS4Q5O.js +1 -0
  7. package/dist/gui/angular-html-YBC4GTV4.js +1 -0
  8. package/dist/gui/angular-ts-ZIU7OVGE.js +1 -0
  9. package/dist/gui/apache-U32KA2FB.js +1 -0
  10. package/dist/gui/apex-VTA27EIA.js +1 -0
  11. package/dist/gui/apl-3N2QYEVK.js +1 -0
  12. package/dist/gui/applescript-WKBNOJN3.js +1 -0
  13. package/dist/gui/ara-LOYFRK44.js +1 -0
  14. package/dist/gui/asciidoc-BIAX4CUU.js +1 -0
  15. package/dist/gui/asm-5NJNIH7L.js +1 -0
  16. package/dist/gui/astro-RDSHXCML.js +1 -0
  17. package/dist/gui/aurora-x-FAPHH5YB.js +1 -0
  18. package/dist/gui/awk-ESSJ54IN.js +1 -0
  19. package/dist/gui/ayu-dark-GAZUJSFG.js +1 -0
  20. package/dist/gui/ayu-light-S3HDK3P6.js +1 -0
  21. package/dist/gui/ayu-mirage-FRLUTQCD.js +1 -0
  22. package/dist/gui/ballerina-I5G6WI4V.js +1 -0
  23. package/dist/gui/bat-XQTE6ROZ.js +1 -0
  24. package/dist/gui/beancount-LP7NWB5A.js +1 -0
  25. package/dist/gui/berry-KUSHPXSF.js +1 -0
  26. package/dist/gui/bibtex-5Q4QFORS.js +1 -0
  27. package/dist/gui/bicep-RLEFUJBB.js +1 -0
  28. package/dist/gui/bird2-H2ROQN7N.js +1 -0
  29. package/dist/gui/blade-62REZWJW.js +1 -0
  30. package/dist/gui/bsl-3ICADNA4.js +1 -0
  31. package/dist/gui/c-Q4CAL6EN.js +1 -0
  32. package/dist/gui/c3-CHQTUKMB.js +1 -0
  33. package/dist/gui/cadence-GMQVA7GB.js +1 -0
  34. package/dist/gui/cairo-ZPLUE773.js +1 -0
  35. package/dist/gui/catppuccin-frappe-WTOO7TQU.js +1 -0
  36. package/dist/gui/catppuccin-latte-A2LSA3LJ.js +1 -0
  37. package/dist/gui/catppuccin-macchiato-RCIP7S3P.js +1 -0
  38. package/dist/gui/catppuccin-mocha-OS7AM3GC.js +1 -0
  39. package/dist/gui/chapel-3Z633JGJ.js +1 -0
  40. package/dist/gui/chunk-26MLVG6L.js +1 -0
  41. package/dist/gui/chunk-2SOBHFBG.js +1 -0
  42. package/dist/gui/chunk-2YYHCOMV.js +1 -0
  43. package/dist/gui/chunk-37IWMLTX.js +1 -0
  44. package/dist/gui/chunk-3FGBQ6A6.js +1 -0
  45. package/dist/gui/chunk-3ZKK7SIN.js +1 -0
  46. package/dist/gui/chunk-3ZQCKWX3.js +1 -0
  47. package/dist/gui/chunk-46DHNZDP.js +1 -0
  48. package/dist/gui/chunk-4L4526WS.js +1 -0
  49. package/dist/gui/chunk-55JTXQF7.js +164 -0
  50. package/dist/gui/chunk-5BZ5GSXY.js +1 -0
  51. package/dist/gui/chunk-5LBKFR6X.js +1 -0
  52. package/dist/gui/chunk-5UNDITZ6.js +1 -0
  53. package/dist/gui/chunk-5YAVAROY.js +1 -0
  54. package/dist/gui/chunk-63FIM4UN.js +1 -0
  55. package/dist/gui/chunk-6ASVBJNB.js +1 -0
  56. package/dist/gui/chunk-6R3KEE7K.js +1 -0
  57. package/dist/gui/chunk-6RHIU6UJ.js +1 -0
  58. package/dist/gui/chunk-6WZKLANJ.js +1 -0
  59. package/dist/gui/chunk-6YUFSVTA.js +1 -0
  60. package/dist/gui/chunk-74DAPDUZ.js +1 -0
  61. package/dist/gui/chunk-7DL6FRG7.js +1 -0
  62. package/dist/gui/chunk-AJYDCVPS.js +1 -0
  63. package/dist/gui/chunk-ALTLFZIS.js +1 -0
  64. package/dist/gui/chunk-BQQOMDF3.js +1 -0
  65. package/dist/gui/chunk-CJN6NEEF.js +1 -0
  66. package/dist/gui/chunk-DCJRCM7E.js +1 -0
  67. package/dist/gui/chunk-DD73BSYL.js +1 -0
  68. package/dist/gui/chunk-DHEVTTF6.js +1 -0
  69. package/dist/gui/chunk-DXKN75GC.js +1 -0
  70. package/dist/gui/chunk-E3W66Q2M.js +1 -0
  71. package/dist/gui/chunk-E56XDXUN.js +1 -0
  72. package/dist/gui/chunk-ESXHTAGG.js +1 -0
  73. package/dist/gui/chunk-FNPLEVVQ.js +1 -0
  74. package/dist/gui/chunk-FROJTAOT.js +1 -0
  75. package/dist/gui/chunk-FYI27QRJ.js +1 -0
  76. package/dist/gui/chunk-G7PZUARL.js +1 -0
  77. package/dist/gui/chunk-HHEBGI74.js +1 -0
  78. package/dist/gui/chunk-IGL365IS.js +1 -0
  79. package/dist/gui/chunk-IHPQHJTE.js +1 -0
  80. package/dist/gui/chunk-JFHYNQRZ.js +1 -0
  81. package/dist/gui/chunk-JXMQU3VM.js +1 -0
  82. package/dist/gui/chunk-KWIOD2XB.js +1 -0
  83. package/dist/gui/chunk-M3W3D44W.js +1 -0
  84. package/dist/gui/chunk-MAHOIE36.js +1 -0
  85. package/dist/gui/chunk-MLTQE63C.js +1 -0
  86. package/dist/gui/chunk-MSGQCPM6.js +1 -0
  87. package/dist/gui/chunk-NA4VE6LQ.js +1 -0
  88. package/dist/gui/chunk-O36SAGVH.js +1 -0
  89. package/dist/gui/chunk-OOY6SNOQ.js +1 -0
  90. package/dist/gui/chunk-OR5FHECQ.js +1 -0
  91. package/dist/gui/chunk-P7GHE3RQ.js +1 -0
  92. package/dist/gui/chunk-PHEOHAKT.js +1 -0
  93. package/dist/gui/chunk-PRHZBKTR.js +1 -0
  94. package/dist/gui/chunk-PYRZ523Z.js +1 -0
  95. package/dist/gui/chunk-PZEZXK43.js +1 -0
  96. package/dist/gui/chunk-QIL2Z2PV.js +1 -0
  97. package/dist/gui/chunk-QOHIV2P6.js +1 -0
  98. package/dist/gui/chunk-QP5MZ6PD.js +1 -0
  99. package/dist/gui/chunk-QZTMXTQ5.js +1 -0
  100. package/dist/gui/chunk-RVQECLU5.js +1 -0
  101. package/dist/gui/chunk-SILA42W7.js +1 -0
  102. package/dist/gui/chunk-T3N6MPDP.js +1 -0
  103. package/dist/gui/chunk-TGZ7ELPN.js +1 -0
  104. package/dist/gui/chunk-TK4ZAFYM.js +1 -0
  105. package/dist/gui/chunk-TV7I3SW3.js +1 -0
  106. package/dist/gui/chunk-UVQC6P2E.js +1 -0
  107. package/dist/gui/chunk-V6RWMCFC.js +1 -0
  108. package/dist/gui/chunk-W2DTVSTF.js +1 -0
  109. package/dist/gui/chunk-WKNCCTIH.js +1 -0
  110. package/dist/gui/chunk-WS3EQ3SY.js +1 -0
  111. package/dist/gui/chunk-WTRKJZEH.js +1 -0
  112. package/dist/gui/chunk-WY4VX6QJ.js +1 -0
  113. package/dist/gui/chunk-XIVHKWKD.js +1 -0
  114. package/dist/gui/chunk-XZQZMXAN.js +1 -0
  115. package/dist/gui/chunk-Y2SOJ45P.js +1 -0
  116. package/dist/gui/chunk-YBPUFKZG.js +1 -0
  117. package/dist/gui/chunk-YC22HROH.js +1 -0
  118. package/dist/gui/chunk-Z6EXOQLM.js +1 -0
  119. package/dist/gui/chunk-ZD72CDNJ.js +1 -0
  120. package/dist/gui/chunk-ZYM5HG5R.js +1 -0
  121. package/dist/gui/clarity-DYA2JUGZ.js +1 -0
  122. package/dist/gui/clojure-G7IURXNK.js +1 -0
  123. package/dist/gui/cmake-4DZSTAWG.js +1 -0
  124. package/dist/gui/cobol-DUCWHDIZ.js +1 -0
  125. package/dist/gui/codeowners-IKIECA5K.js +1 -0
  126. package/dist/gui/codeql-EK6NFINM.js +1 -0
  127. package/dist/gui/coffee-HZ62PXBN.js +1 -0
  128. package/dist/gui/common-lisp-C5JFPP2W.js +1 -0
  129. package/dist/gui/coq-QNZJXEO2.js +1 -0
  130. package/dist/gui/cpp-LVH4DUEH.js +1 -0
  131. package/dist/gui/crystal-OEOE5VN5.js +1 -0
  132. package/dist/gui/csharp-Y6M5EGHH.js +1 -0
  133. package/dist/gui/css-MYBAEYPV.js +1 -0
  134. package/dist/gui/csv-W2N6UZ5O.js +1 -0
  135. package/dist/gui/cue-XLSH6VNO.js +1 -0
  136. package/dist/gui/cypher-LIAJ2AQF.js +1 -0
  137. package/dist/gui/d-KOZ5GW3B.js +1 -0
  138. package/dist/gui/dark-plus-HCLPH6DY.js +1 -0
  139. package/dist/gui/dart-HSXEG6I6.js +1 -0
  140. package/dist/gui/dax-XUGRY6W7.js +1 -0
  141. package/dist/gui/desktop-NXYZUBRS.js +1 -0
  142. package/dist/gui/diff-62RZJUWL.js +1 -0
  143. package/dist/gui/diffs-worker.js +5 -0
  144. package/dist/gui/docker-5PAL7A2H.js +1 -0
  145. package/dist/gui/dotenv-QNGBJ7H6.js +1 -0
  146. package/dist/gui/dracula-JHW4RJTX.js +1 -0
  147. package/dist/gui/dracula-soft-5EFEA2BQ.js +1 -0
  148. package/dist/gui/dream-maker-EHSANE6P.js +1 -0
  149. package/dist/gui/edge-GY7QH5MJ.js +1 -0
  150. package/dist/gui/elixir-TXRUL5QI.js +1 -0
  151. package/dist/gui/elm-O2IRWDLI.js +1 -0
  152. package/dist/gui/emacs-lisp-YSAYXSLO.js +1 -0
  153. package/dist/gui/erb-LOH7WKGU.js +1 -0
  154. package/dist/gui/erlang-J6XNI2HL.js +1 -0
  155. package/dist/gui/everforest-dark-YYJDFM4G.js +1 -0
  156. package/dist/gui/everforest-light-6VKVRX63.js +1 -0
  157. package/dist/gui/fennel-UIF7WTON.js +1 -0
  158. package/dist/gui/fish-XNUBLCAF.js +1 -0
  159. package/dist/gui/fluent-UFZK23ZF.js +1 -0
  160. package/dist/gui/fortran-fixed-form-GF4EQUFG.js +1 -0
  161. package/dist/gui/fortran-free-form-PXTWSUJU.js +1 -0
  162. package/dist/gui/fsharp-NXUAWXAF.js +1 -0
  163. package/dist/gui/gdresource-3Z6GJTMS.js +1 -0
  164. package/dist/gui/gdscript-NR3VITKY.js +1 -0
  165. package/dist/gui/gdshader-M5YZ63Y2.js +1 -0
  166. package/dist/gui/genie-BO3CX2XQ.js +1 -0
  167. package/dist/gui/gherkin-LWGWZ3RS.js +1 -0
  168. package/dist/gui/git-commit-RPQOTEF3.js +1 -0
  169. package/dist/gui/git-rebase-TF2QJEAL.js +1 -0
  170. package/dist/gui/github-dark-REFHQ7KZ.js +1 -0
  171. package/dist/gui/{github-dark-default-VHJFG2UV.js → github-dark-default-HNVWMHF4.js} +1 -7
  172. package/dist/gui/github-dark-dimmed-JJPACVZZ.js +1 -0
  173. package/dist/gui/github-dark-high-contrast-MKQ5JYLO.js +1 -0
  174. package/dist/gui/github-light-IM7NG6OB.js +1 -0
  175. package/dist/gui/github-light-default-QU2YVTXI.js +1 -0
  176. package/dist/gui/github-light-high-contrast-OUURX2TU.js +1 -0
  177. package/dist/gui/gleam-5HTZJ72P.js +1 -0
  178. package/dist/gui/glimmer-js-PFOARH3K.js +1 -0
  179. package/dist/gui/glimmer-ts-LZJTTHVF.js +1 -0
  180. package/dist/gui/glsl-2WUTP43R.js +1 -0
  181. package/dist/gui/gn-FLOS4RZF.js +1 -0
  182. package/dist/gui/gnuplot-AA3IX5VA.js +1 -0
  183. package/dist/gui/go-D4ZGPS2Z.js +1 -0
  184. package/dist/gui/graphql-XZVYVEOX.js +1 -0
  185. package/dist/gui/groovy-E5CINRXU.js +1 -0
  186. package/dist/gui/gruvbox-dark-hard-UFIAEKPP.js +1 -0
  187. package/dist/gui/{gruvbox-dark-medium-BELAJCDV.js → gruvbox-dark-medium-XK6AECTF.js} +1 -7
  188. package/dist/gui/gruvbox-dark-soft-WNTU4C4A.js +1 -0
  189. package/dist/gui/gruvbox-light-hard-VLLYGWMV.js +1 -0
  190. package/dist/gui/gruvbox-light-medium-MOKQOXML.js +1 -0
  191. package/dist/gui/gruvbox-light-soft-OVPAH42P.js +1 -0
  192. package/dist/gui/hack-R5BPE4XT.js +1 -0
  193. package/dist/gui/haml-F7BK2NAC.js +1 -0
  194. package/dist/gui/handlebars-TDZDKBFN.js +1 -0
  195. package/dist/gui/haskell-OMKSKXE4.js +1 -0
  196. package/dist/gui/haxe-DA2WYZGW.js +1 -0
  197. package/dist/gui/hcl-CRLVRE3Z.js +1 -0
  198. package/dist/gui/hjson-UIMUDXPE.js +1 -0
  199. package/dist/gui/hlsl-I7ZGIUMO.js +1 -0
  200. package/dist/gui/horizon-NQLSMOTK.js +1 -0
  201. package/dist/gui/horizon-bright-RLXCKKC2.js +1 -0
  202. package/dist/gui/houston-LOYTQEEC.js +1 -0
  203. package/dist/gui/html-7XII5ONP.js +1 -0
  204. package/dist/gui/html-derivative-JQOMEZ36.js +1 -0
  205. package/dist/gui/http-EJHR5COJ.js +1 -0
  206. package/dist/gui/hurl-AFBMX2SV.js +1 -0
  207. package/dist/gui/hxml-SPWPZW4Z.js +1 -0
  208. package/dist/gui/hy-GTUAPP6L.js +1 -0
  209. package/dist/gui/imba-PR2LWKPL.js +1 -0
  210. package/dist/gui/ini-KJTRFM25.js +1 -0
  211. package/dist/gui/java-DSZN5VJV.js +1 -0
  212. package/dist/gui/javascript-XR4WJT5N.js +1 -0
  213. package/dist/gui/jinja-ANXS2HAO.js +1 -0
  214. package/dist/gui/jison-QLTVNL3C.js +1 -0
  215. package/dist/gui/json-3EUJJ54W.js +1 -0
  216. package/dist/gui/json5-IDTK7YOE.js +1 -0
  217. package/dist/gui/jsonc-6ZTWASVR.js +1 -0
  218. package/dist/gui/jsonl-MLAJJYGB.js +1 -0
  219. package/dist/gui/jsonnet-R4IMWKFV.js +1 -0
  220. package/dist/gui/jssm-BZWTK76Y.js +1 -0
  221. package/dist/gui/jsx-TXRT3F4T.js +1 -0
  222. package/dist/gui/julia-BBWH3F3Q.js +1 -0
  223. package/dist/gui/just-NTMFF2RX.js +1 -0
  224. package/dist/gui/kanagawa-dragon-HEOKFLSM.js +1 -0
  225. package/dist/gui/kanagawa-lotus-FLUYKNAJ.js +1 -0
  226. package/dist/gui/kanagawa-wave-W5JS3SJB.js +1 -0
  227. package/dist/gui/kdl-JLCHZWOT.js +1 -0
  228. package/dist/gui/kotlin-3JSE5GFW.js +1 -0
  229. package/dist/gui/kusto-6X3HWIDS.js +1 -0
  230. package/dist/gui/laserwave-RYH62ULF.js +1 -0
  231. package/dist/gui/latex-DAN4LSSN.js +1 -0
  232. package/dist/gui/lean-WK3JB7KT.js +1 -0
  233. package/dist/gui/less-EARLTJNN.js +1 -0
  234. package/dist/gui/light-plus-5B5GHCAO.js +1 -0
  235. package/dist/gui/liquid-NGA53ZPS.js +1 -0
  236. package/dist/gui/llvm-J5EFVCQS.js +1 -0
  237. package/dist/gui/log-2G4LLVHC.js +1 -0
  238. package/dist/gui/logo-TCNRKRD5.js +1 -0
  239. package/dist/gui/lua-JIKWKGJV.js +1 -0
  240. package/dist/gui/luau-SFLPX4FF.js +1 -0
  241. package/dist/gui/main.js +1642 -80087
  242. package/dist/gui/make-NJO3L26C.js +1 -0
  243. package/dist/gui/markdown-33JM3RBU.js +1 -0
  244. package/dist/gui/marko-5E7LEGXI.js +1 -0
  245. package/dist/gui/material-theme-BENJVRUI.js +1 -0
  246. package/dist/gui/material-theme-darker-7UJLVDMH.js +1 -0
  247. package/dist/gui/material-theme-lighter-PPK5M2KX.js +1 -0
  248. package/dist/gui/material-theme-ocean-GSEYSNHR.js +1 -0
  249. package/dist/gui/material-theme-palenight-BT7M3Z7N.js +1 -0
  250. package/dist/gui/matlab-XHMB4W76.js +1 -0
  251. package/dist/gui/mdc-NGUCNP3J.js +1 -0
  252. package/dist/gui/mdx-XWES6DQN.js +1 -0
  253. package/dist/gui/mermaid-FU5XZ4UI.js +1 -0
  254. package/dist/gui/min-dark-M65IJXSI.js +1 -0
  255. package/dist/gui/min-light-6C5NEZVA.js +1 -0
  256. package/dist/gui/mipsasm-PZKYVJ7H.js +1 -0
  257. package/dist/gui/mojo-IHPQ75I5.js +1 -0
  258. package/dist/gui/monokai-JG2G5WZJ.js +1 -0
  259. package/dist/gui/moonbit-RKDBWPCI.js +1 -0
  260. package/dist/gui/move-7QARO2MW.js +1 -0
  261. package/dist/gui/narrat-ACZ2QBHY.js +1 -0
  262. package/dist/gui/nextflow-SE5ZBILO.js +1 -0
  263. package/dist/gui/nextflow-groovy-OUI4UFJZ.js +1 -0
  264. package/dist/gui/nginx-X4AEE2Y3.js +1 -0
  265. package/dist/gui/night-owl-O35XCMH2.js +1 -0
  266. package/dist/gui/night-owl-light-V2Y4RCYQ.js +1 -0
  267. package/dist/gui/nim-5SOHKETF.js +1 -0
  268. package/dist/gui/nix-X5MVXECB.js +1 -0
  269. package/dist/gui/nord-LP5RXKO4.js +1 -0
  270. package/dist/gui/nsis-4ITGWURL.js +1 -0
  271. package/dist/gui/nushell-ZFA4HPZK.js +1 -0
  272. package/dist/gui/objective-c-LNJ26AQV.js +1 -0
  273. package/dist/gui/objective-cpp-6MQLZISN.js +1 -0
  274. package/dist/gui/ocaml-T4K5GHXS.js +1 -0
  275. package/dist/gui/odin-6FP5C6CH.js +1 -0
  276. package/dist/gui/one-dark-pro-D45YYOSC.js +1 -0
  277. package/dist/gui/one-light-7SELK2HX.js +1 -0
  278. package/dist/gui/openscad-EW4KI2UZ.js +1 -0
  279. package/dist/gui/org-L7PJD5VW.js +1 -0
  280. package/dist/gui/pascal-RC4O2NCX.js +1 -0
  281. package/dist/gui/perl-7QWV5WJH.js +1 -0
  282. package/dist/gui/php-3P3VLQXF.js +1 -0
  283. package/dist/gui/pierre-dark-UUALILXQ.js +1 -0
  284. package/dist/gui/pierre-dark-protanopia-deuteranopia-GNBYHTF4.js +1 -0
  285. package/dist/gui/pierre-dark-soft-J5EIFRXM.js +1 -0
  286. package/dist/gui/pierre-dark-tritanopia-6YRJO27P.js +1 -0
  287. package/dist/gui/{pierre-dark-vibrant-74HELCEP.js → pierre-dark-vibrant-NJEA5K4W.js} +1 -7
  288. package/dist/gui/pierre-light-ZQTWM32A.js +1 -0
  289. package/dist/gui/pierre-light-protanopia-deuteranopia-FUEM3DXT.js +1 -0
  290. package/dist/gui/pierre-light-soft-TCQDDSNP.js +1 -0
  291. package/dist/gui/pierre-light-tritanopia-OV2PHN3L.js +1 -0
  292. package/dist/gui/pierre-light-vibrant-AZKXRX64.js +1 -0
  293. package/dist/gui/pkl-RPQFMJHD.js +1 -0
  294. package/dist/gui/plastic-PAFZF6UX.js +1 -0
  295. package/dist/gui/plsql-W3DB43CI.js +1 -0
  296. package/dist/gui/po-5BV5ST4S.js +1 -0
  297. package/dist/gui/poimandres-4AUR6LMN.js +1 -0
  298. package/dist/gui/polar-2A4DMGDX.js +1 -0
  299. package/dist/gui/postcss-TNHQ4NSC.js +1 -0
  300. package/dist/gui/powerquery-VUKZRFZR.js +1 -0
  301. package/dist/gui/powershell-TK6ME3LY.js +1 -0
  302. package/dist/gui/prisma-EI7DDMP7.js +1 -0
  303. package/dist/gui/prolog-AVYZOBBB.js +1 -0
  304. package/dist/gui/proto-24ZKYESH.js +1 -0
  305. package/dist/gui/pug-BBOBRMAQ.js +1 -0
  306. package/dist/gui/puppet-K3V25A6J.js +1 -0
  307. package/dist/gui/purescript-FOAG6MUG.js +1 -0
  308. package/dist/gui/python-RGDF5IZE.js +1 -0
  309. package/dist/gui/qml-XFYRCCU2.js +1 -0
  310. package/dist/gui/qmldir-25IWZ43Y.js +1 -0
  311. package/dist/gui/qss-3QVASW5Z.js +1 -0
  312. package/dist/gui/r-4SYQX3YB.js +1 -0
  313. package/dist/gui/racket-ZXK4SKKC.js +1 -0
  314. package/dist/gui/raku-QA35WOMY.js +1 -0
  315. package/dist/gui/razor-4TWVQHTU.js +1 -0
  316. package/dist/gui/rbs-3NEBMVOA.js +1 -0
  317. package/dist/gui/red-FHDCYAGC.js +1 -0
  318. package/dist/gui/reg-DDDCCL2S.js +1 -0
  319. package/dist/gui/regexp-WCMKSTB5.js +1 -0
  320. package/dist/gui/rel-UZZH4IDH.js +1 -0
  321. package/dist/gui/riscv-ZLG5M6ET.js +1 -0
  322. package/dist/gui/ron-CJ5PF6JZ.js +1 -0
  323. package/dist/gui/rose-pine-7HOL5AMQ.js +1 -0
  324. package/dist/gui/rose-pine-dawn-ILHX5FOL.js +1 -0
  325. package/dist/gui/rose-pine-moon-KLXMC5MV.js +1 -0
  326. package/dist/gui/rosmsg-G5A6MUGH.js +1 -0
  327. package/dist/gui/rst-BOZJLDXS.js +1 -0
  328. package/dist/gui/ruby-ERSYBX2A.js +1 -0
  329. package/dist/gui/rust-D6W4ZLZ4.js +1 -0
  330. package/dist/gui/sas-MEFFXSOG.js +1 -0
  331. package/dist/gui/sass-WKJBO4S6.js +1 -0
  332. package/dist/gui/scala-URQSYH5Q.js +1 -0
  333. package/dist/gui/scheme-X3MMQWU4.js +1 -0
  334. package/dist/gui/scss-WPGS5D6U.js +1 -0
  335. package/dist/gui/sdbl-II465DZK.js +1 -0
  336. package/dist/gui/shaderlab-UOD53IUD.js +1 -0
  337. package/dist/gui/shellscript-K2EAVF55.js +1 -0
  338. package/dist/gui/shellsession-4BNORSYP.js +1 -0
  339. package/dist/gui/slack-dark-PKA4XJM5.js +1 -0
  340. package/dist/gui/slack-ochin-M6NLSFYN.js +1 -0
  341. package/dist/gui/smalltalk-6HWUSNWG.js +1 -0
  342. package/dist/gui/smithy-3NE7ZMNJ.js +1 -0
  343. package/dist/gui/snazzy-light-XP7LR76H.js +1 -0
  344. package/dist/gui/solarized-dark-OZQGSSTI.js +1 -0
  345. package/dist/gui/solarized-light-FIEQXCCQ.js +1 -0
  346. package/dist/gui/solidity-EJNFJ37K.js +1 -0
  347. package/dist/gui/soy-MZEYLXUU.js +1 -0
  348. package/dist/gui/sparql-ILD7IWLS.js +1 -0
  349. package/dist/gui/splunk-FMTEVKBA.js +1 -0
  350. package/dist/gui/sql-2KVUOGK2.js +1 -0
  351. package/dist/gui/ssh-config-44SOGF2N.js +1 -0
  352. package/dist/gui/stata-YMFQSMUD.js +1 -0
  353. package/dist/gui/stylus-A5FIEREC.js +1 -0
  354. package/dist/gui/surrealql-VKFTSBUL.js +1 -0
  355. package/dist/gui/svelte-H4D3PMRS.js +1 -0
  356. package/dist/gui/swift-N6UUV4WM.js +1 -0
  357. package/dist/gui/synthwave-84-PD5BOFK2.js +1 -0
  358. package/dist/gui/system-verilog-NNY6GQOQ.js +1 -0
  359. package/dist/gui/systemd-RVODVMDH.js +1 -0
  360. package/dist/gui/talonscript-ENLOEX56.js +1 -0
  361. package/dist/gui/tasl-GC4YOF35.js +1 -0
  362. package/dist/gui/tcl-UAQKRIMQ.js +1 -0
  363. package/dist/gui/templ-3SR7WDHA.js +1 -0
  364. package/dist/gui/terraform-WWPSCXCZ.js +1 -0
  365. package/dist/gui/tex-7CMEVGPS.js +1 -0
  366. package/dist/gui/tokyo-night-K7YYNJI2.js +1 -0
  367. package/dist/gui/toml-EV2WQVY5.js +1 -0
  368. package/dist/gui/ts-tags-UEGU4VKD.js +1 -0
  369. package/dist/gui/tsv-NTCI55EL.js +1 -0
  370. package/dist/gui/tsx-CW7A3IBI.js +1 -0
  371. package/dist/gui/turtle-LR4PTJRE.js +1 -0
  372. package/dist/gui/twig-VLD6HZP7.js +1 -0
  373. package/dist/gui/typescript-BXBSQ4TF.js +1 -0
  374. package/dist/gui/typespec-SPATFDEV.js +1 -0
  375. package/dist/gui/typst-IBXX7HGO.js +1 -0
  376. package/dist/gui/v-CNCWXBH3.js +1 -0
  377. package/dist/gui/vala-COQFDBCD.js +1 -0
  378. package/dist/gui/vb-ZKUVQ2IB.js +1 -0
  379. package/dist/gui/verilog-AE42CTAL.js +1 -0
  380. package/dist/gui/vesper-G6AAATZ5.js +1 -0
  381. package/dist/gui/vhdl-TUUYGSZC.js +1 -0
  382. package/dist/gui/viml-NJSEO5HU.js +1 -0
  383. package/dist/gui/vitesse-black-2JMSBH2Y.js +1 -0
  384. package/dist/gui/vitesse-dark-MZIINQYJ.js +1 -0
  385. package/dist/gui/vitesse-light-PUU6ALJN.js +1 -0
  386. package/dist/gui/vue-G3BU3ZXC.js +1 -0
  387. package/dist/gui/vue-html-JVIPDA3J.js +1 -0
  388. package/dist/gui/vue-vine-2J4EFZYJ.js +1 -0
  389. package/dist/gui/vyper-X5IIQBLQ.js +1 -0
  390. package/dist/gui/wasm-PBY6OWX6.js +1 -0
  391. package/dist/gui/wasm-RWK3SGH4.js +1 -0
  392. package/dist/gui/wenyan-SVN34UX2.js +1 -0
  393. package/dist/gui/wgsl-JT3SSBOT.js +1 -0
  394. package/dist/gui/wikitext-ZINAKQJN.js +1 -0
  395. package/dist/gui/wit-IPHVVCU7.js +1 -0
  396. package/dist/gui/wolfram-BM2HK6J7.js +1 -0
  397. package/dist/gui/xml-OPIMP5GR.js +1 -0
  398. package/dist/gui/xsl-IQGV6DOU.js +1 -0
  399. package/dist/gui/yaml-P37LLXQD.js +1 -0
  400. package/dist/gui/zenscript-3FWIWZXX.js +1 -0
  401. package/dist/gui/zig-3HPW2CFC.js +1 -0
  402. package/dist/index.js +96 -96
  403. package/dist/mcp.js +89 -89
  404. package/package.json +5 -2
  405. package/dist/gui/abap-QUGURUBX.js +0 -10
  406. package/dist/gui/actionscript-3-3B35LJ6O.js +0 -10
  407. package/dist/gui/ada-UZZSP2VN.js +0 -10
  408. package/dist/gui/ahk-AV2XNNVZ.js +0 -10
  409. package/dist/gui/ahk2-KEAF4H55.js +0 -10
  410. package/dist/gui/andromeeda-2GR76PYB.js +0 -7
  411. package/dist/gui/angular-html-TCKFTSN3.js +0 -10
  412. package/dist/gui/angular-ts-OWXT6U2F.js +0 -44
  413. package/dist/gui/apache-K3WQQUQC.js +0 -10
  414. package/dist/gui/apex-76A7OZCW.js +0 -10
  415. package/dist/gui/apl-QUJH6REI.js +0 -31
  416. package/dist/gui/applescript-DYSSLNAH.js +0 -10
  417. package/dist/gui/ara-JBUHYAMO.js +0 -10
  418. package/dist/gui/asciidoc-GVSAY7ID.js +0 -10
  419. package/dist/gui/asm-7T5K47RE.js +0 -10
  420. package/dist/gui/astro-ROBUIKHM.js +0 -34
  421. package/dist/gui/aurora-x-CCBQ7SH7.js +0 -7
  422. package/dist/gui/awk-X3RXUDTD.js +0 -10
  423. package/dist/gui/ayu-dark-PIU367MT.js +0 -7
  424. package/dist/gui/ayu-light-Y4QUM4BU.js +0 -7
  425. package/dist/gui/ayu-mirage-LSLYYZ6M.js +0 -7
  426. package/dist/gui/ballerina-X5OCGDT7.js +0 -10
  427. package/dist/gui/bat-6N655JFC.js +0 -7
  428. package/dist/gui/beancount-737SRZDB.js +0 -10
  429. package/dist/gui/berry-27ZIFCK5.js +0 -10
  430. package/dist/gui/bibtex-PCJ2P64N.js +0 -7
  431. package/dist/gui/bicep-KZTPGRFB.js +0 -10
  432. package/dist/gui/bird2-4JCG5OZF.js +0 -10
  433. package/dist/gui/blade-TDVDX7TO.js +0 -39
  434. package/dist/gui/bsl-35Z2FTGV.js +0 -14
  435. package/dist/gui/c-7CKX2DSI.js +0 -7
  436. package/dist/gui/c3-DR3DV77K.js +0 -10
  437. package/dist/gui/cadence-OYNPDM3M.js +0 -10
  438. package/dist/gui/cairo-COXU6RBH.js +0 -14
  439. package/dist/gui/catppuccin-frappe-P2B2FXCB.js +0 -7
  440. package/dist/gui/catppuccin-latte-AIEPHNSB.js +0 -7
  441. package/dist/gui/catppuccin-macchiato-CLAJLZV7.js +0 -7
  442. package/dist/gui/catppuccin-mocha-DJZW5ULN.js +0 -7
  443. package/dist/gui/chapel-5CK5YMSY.js +0 -14
  444. package/dist/gui/chunk-2IVRELJI.js +0 -9
  445. package/dist/gui/chunk-2JKKPALB.js +0 -9
  446. package/dist/gui/chunk-2PUAXP2T.js +0 -38
  447. package/dist/gui/chunk-2QHMH6QB.js +0 -9
  448. package/dist/gui/chunk-2XE676KO.js +0 -9
  449. package/dist/gui/chunk-2YCLQAMI.js +0 -9
  450. package/dist/gui/chunk-3567J5D4.js +0 -14
  451. package/dist/gui/chunk-3BGADQKG.js +0 -9
  452. package/dist/gui/chunk-45O7TJOW.js +0 -9
  453. package/dist/gui/chunk-4DOSCG4B.js +0 -26
  454. package/dist/gui/chunk-4IZ5IRSO.js +0 -9
  455. package/dist/gui/chunk-5TDK5Y5S.js +0 -9
  456. package/dist/gui/chunk-67HINKFV.js +0 -9
  457. package/dist/gui/chunk-6TG6XZZD.js +0 -14
  458. package/dist/gui/chunk-76C5RMV7.js +0 -9
  459. package/dist/gui/chunk-7CB7TITS.js +0 -9
  460. package/dist/gui/chunk-7YLAFQQ7.js +0 -27
  461. package/dist/gui/chunk-AZIN3OHL.js +0 -14
  462. package/dist/gui/chunk-BW7B23CF.js +0 -9
  463. package/dist/gui/chunk-C774R7J7.js +0 -26
  464. package/dist/gui/chunk-CB7BCEL4.js +0 -9
  465. package/dist/gui/chunk-CYKSS2Y7.js +0 -9
  466. package/dist/gui/chunk-DCJCRTKO.js +0 -14
  467. package/dist/gui/chunk-DKOWBU7G.js +0 -9
  468. package/dist/gui/chunk-DWAALHPK.js +0 -9
  469. package/dist/gui/chunk-EZITVRXA.js +0 -9
  470. package/dist/gui/chunk-FAHLSHNR.js +0 -9
  471. package/dist/gui/chunk-FALFVRCV.js +0 -14
  472. package/dist/gui/chunk-GL2Q3EDW.js +0 -9
  473. package/dist/gui/chunk-H66FQEKW.js +0 -9
  474. package/dist/gui/chunk-HGZA2JNF.js +0 -9
  475. package/dist/gui/chunk-HQG63PQL.js +0 -9
  476. package/dist/gui/chunk-HSNCWORT.js +0 -9
  477. package/dist/gui/chunk-IJCSV645.js +0 -14
  478. package/dist/gui/chunk-ILHZPDJC.js +0 -9
  479. package/dist/gui/chunk-IYFWWBRC.js +0 -34
  480. package/dist/gui/chunk-J6IKJJ34.js +0 -34
  481. package/dist/gui/chunk-JBVY6KB5.js +0 -9
  482. package/dist/gui/chunk-JJHUDSW7.js +0 -9
  483. package/dist/gui/chunk-JLIS73DH.js +0 -14
  484. package/dist/gui/chunk-JO5JNDTX.js +0 -9
  485. package/dist/gui/chunk-JV223PVL.js +0 -14
  486. package/dist/gui/chunk-JVCCJA2A.js +0 -30
  487. package/dist/gui/chunk-KGH6JTBL.js +0 -9
  488. package/dist/gui/chunk-KM2QKTEE.js +0 -50
  489. package/dist/gui/chunk-KSXADT4K.js +0 -9
  490. package/dist/gui/chunk-MT4FGOLU.js +0 -9
  491. package/dist/gui/chunk-NAD33WBI.js +0 -14
  492. package/dist/gui/chunk-NE25QJUZ.js +0 -9
  493. package/dist/gui/chunk-OII47WE4.js +0 -14
  494. package/dist/gui/chunk-OWEPHUF3.js +0 -14
  495. package/dist/gui/chunk-Q2AHPUVI.js +0 -9
  496. package/dist/gui/chunk-Q567VMM5.js +0 -9
  497. package/dist/gui/chunk-QFOAKHDY.js +0 -9
  498. package/dist/gui/chunk-QH2T6GYZ.js +0 -9
  499. package/dist/gui/chunk-QU263C3I.js +0 -9
  500. package/dist/gui/chunk-QYOJGBVM.js +0 -14
  501. package/dist/gui/chunk-R27EWKMH.js +0 -58
  502. package/dist/gui/chunk-RW4VQAW5.js +0 -18
  503. package/dist/gui/chunk-S7GWCO5B.js +0 -9
  504. package/dist/gui/chunk-SBETFYFF.js +0 -30
  505. package/dist/gui/chunk-SF5VS2XA.js +0 -9
  506. package/dist/gui/chunk-SZ2AIRR5.js +0 -9
  507. package/dist/gui/chunk-TKLN6WSC.js +0 -9
  508. package/dist/gui/chunk-TS3VPCJT.js +0 -9
  509. package/dist/gui/chunk-UUL2FFKC.js +0 -53
  510. package/dist/gui/chunk-VB3O6QM4.js +0 -9
  511. package/dist/gui/chunk-VEW77XHD.js +0 -9
  512. package/dist/gui/chunk-VVHT2QDI.js +0 -14
  513. package/dist/gui/chunk-WAWKOXXW.js +0 -18
  514. package/dist/gui/chunk-WBGGZ2J4.js +0 -9
  515. package/dist/gui/chunk-WC4BNZJP.js +0 -9
  516. package/dist/gui/chunk-XOMTOLBK.js +0 -9
  517. package/dist/gui/chunk-YBPIMBI6.js +0 -9
  518. package/dist/gui/chunk-YCL6DOP5.js +0 -9
  519. package/dist/gui/chunk-YJV35WLF.js +0 -14
  520. package/dist/gui/chunk-YOOITCA2.js +0 -22
  521. package/dist/gui/chunk-YWGUZU7U.js +0 -9
  522. package/dist/gui/chunk-YXIK6PVL.js +0 -9
  523. package/dist/gui/chunk-ZMZROCQO.js +0 -9
  524. package/dist/gui/clarity-X6Y4EF32.js +0 -10
  525. package/dist/gui/clojure-HWHJFZBF.js +0 -7
  526. package/dist/gui/cmake-4WVDKLXE.js +0 -7
  527. package/dist/gui/cobol-BK36TVIL.js +0 -20
  528. package/dist/gui/codeowners-PKXUEH4G.js +0 -10
  529. package/dist/gui/codeql-GSSNZAAP.js +0 -10
  530. package/dist/gui/coffee-CGHHEFIM.js +0 -8
  531. package/dist/gui/common-lisp-V4DD5MQE.js +0 -10
  532. package/dist/gui/coq-QVWLCVBB.js +0 -10
  533. package/dist/gui/cpp-KAUF3RSB.js +0 -10
  534. package/dist/gui/crystal-7TGOAT76.js +0 -34
  535. package/dist/gui/csharp-RRPDDXD7.js +0 -7
  536. package/dist/gui/css-S4XR6RYL.js +0 -7
  537. package/dist/gui/csv-ZNGJRB22.js +0 -7
  538. package/dist/gui/cue-7HOXZRS4.js +0 -10
  539. package/dist/gui/cypher-EAUAMJM6.js +0 -10
  540. package/dist/gui/d-CBA7NL6B.js +0 -10
  541. package/dist/gui/dark-plus-BOB45KCW.js +0 -7
  542. package/dist/gui/dart-MZSRF3IM.js +0 -7
  543. package/dist/gui/dax-Q4BTRBTA.js +0 -10
  544. package/dist/gui/desktop-NKAUWTGR.js +0 -10
  545. package/dist/gui/diff-RVUP6GV7.js +0 -7
  546. package/dist/gui/docker-KGDTLYEN.js +0 -7
  547. package/dist/gui/dotenv-5YOSIPZS.js +0 -10
  548. package/dist/gui/dracula-F56RSW6N.js +0 -7
  549. package/dist/gui/dracula-soft-CV5NUT6A.js +0 -7
  550. package/dist/gui/dream-maker-RGHMRX3B.js +0 -10
  551. package/dist/gui/edge-R66O24VV.js +0 -24
  552. package/dist/gui/elixir-5LJ2OUDN.js +0 -10
  553. package/dist/gui/elm-UWVV5ID7.js +0 -15
  554. package/dist/gui/emacs-lisp-TAO5U74P.js +0 -10
  555. package/dist/gui/erb-VBZVG65V.js +0 -35
  556. package/dist/gui/erlang-NLTHURFZ.js +0 -8
  557. package/dist/gui/everforest-dark-JBR4GKJA.js +0 -7
  558. package/dist/gui/everforest-light-AIUWRSLR.js +0 -7
  559. package/dist/gui/fennel-U2PEW23D.js +0 -10
  560. package/dist/gui/fish-KA4MOTTR.js +0 -10
  561. package/dist/gui/fluent-TC32ABGF.js +0 -10
  562. package/dist/gui/fortran-fixed-form-HMHOKX2P.js +0 -14
  563. package/dist/gui/fortran-free-form-T5IDESEJ.js +0 -7
  564. package/dist/gui/fsharp-QTHVHR6A.js +0 -8
  565. package/dist/gui/gdresource-ANDGJRDE.js +0 -18
  566. package/dist/gui/gdscript-2MXOLWT4.js +0 -7
  567. package/dist/gui/gdshader-RPDJURLG.js +0 -7
  568. package/dist/gui/genie-KQGSIM6L.js +0 -10
  569. package/dist/gui/gherkin-UU7PIT6E.js +0 -10
  570. package/dist/gui/git-commit-2OSO66MB.js +0 -8
  571. package/dist/gui/git-rebase-QIB3QI3O.js +0 -8
  572. package/dist/gui/github-dark-H5MJU2XK.js +0 -7
  573. package/dist/gui/github-dark-dimmed-UMS2CKX4.js +0 -7
  574. package/dist/gui/github-dark-high-contrast-N7ADHDRY.js +0 -7
  575. package/dist/gui/github-light-L3SBY5N4.js +0 -7
  576. package/dist/gui/github-light-default-N7QH7CFJ.js +0 -7
  577. package/dist/gui/github-light-high-contrast-2RMTNJOX.js +0 -7
  578. package/dist/gui/gleam-MB2OP4K4.js +0 -10
  579. package/dist/gui/glimmer-js-YJIW2B6M.js +0 -26
  580. package/dist/gui/glimmer-ts-RBWTLTMH.js +0 -26
  581. package/dist/gui/glsl-F7QZR37K.js +0 -8
  582. package/dist/gui/gn-F5BIWANZ.js +0 -10
  583. package/dist/gui/gnuplot-5K7Z5OR2.js +0 -10
  584. package/dist/gui/go-C26CLWJG.js +0 -7
  585. package/dist/gui/graphql-LOUCQJXE.js +0 -11
  586. package/dist/gui/groovy-DVSWXLFJ.js +0 -7
  587. package/dist/gui/gruvbox-dark-hard-WCNUL35F.js +0 -7
  588. package/dist/gui/gruvbox-dark-soft-DA4S6ZCG.js +0 -7
  589. package/dist/gui/gruvbox-light-hard-G3DA2CVN.js +0 -7
  590. package/dist/gui/gruvbox-light-medium-XC4P77WY.js +0 -7
  591. package/dist/gui/gruvbox-light-soft-AXFRXVRJ.js +0 -7
  592. package/dist/gui/hack-7E22AMLX.js +0 -20
  593. package/dist/gui/haml-DLYDG7TX.js +0 -9
  594. package/dist/gui/handlebars-EXMYBU7Q.js +0 -11
  595. package/dist/gui/haskell-PZFDAWUI.js +0 -10
  596. package/dist/gui/haxe-VZSRFGDC.js +0 -7
  597. package/dist/gui/hcl-NAPQ56UJ.js +0 -10
  598. package/dist/gui/hjson-7YO44GAE.js +0 -10
  599. package/dist/gui/hlsl-P6H2KE4L.js +0 -7
  600. package/dist/gui/horizon-ABEUFKCJ.js +0 -7
  601. package/dist/gui/horizon-bright-4IF4JCRZ.js +0 -7
  602. package/dist/gui/houston-ACBQLVIG.js +0 -7
  603. package/dist/gui/html-37GWH2QE.js +0 -9
  604. package/dist/gui/html-derivative-TSWK6LSQ.js +0 -10
  605. package/dist/gui/http-MBDMTHEC.js +0 -31
  606. package/dist/gui/hurl-WAATKOCB.js +0 -27
  607. package/dist/gui/hxml-LG2R5CDK.js +0 -14
  608. package/dist/gui/hy-4MDQ72ZR.js +0 -10
  609. package/dist/gui/imba-AMDQ2OVM.js +0 -10
  610. package/dist/gui/ini-BSRRTTCB.js +0 -7
  611. package/dist/gui/java-VPDWWQCN.js +0 -7
  612. package/dist/gui/javascript-YSK6TDHD.js +0 -7
  613. package/dist/gui/jinja-PJIERUUD.js +0 -23
  614. package/dist/gui/jison-6R6YZ4D3.js +0 -14
  615. package/dist/gui/json-CDBUD4K4.js +0 -7
  616. package/dist/gui/json5-GQ5EPJPN.js +0 -10
  617. package/dist/gui/jsonc-EUK6K7BC.js +0 -7
  618. package/dist/gui/jsonl-AZZ6LVAP.js +0 -10
  619. package/dist/gui/jsonnet-TG4672OU.js +0 -10
  620. package/dist/gui/jssm-POLM2BGU.js +0 -10
  621. package/dist/gui/jsx-HNQJHG7G.js +0 -7
  622. package/dist/gui/julia-EQ4JLFSR.js +0 -15
  623. package/dist/gui/just-3SVPXB4P.js +0 -49
  624. package/dist/gui/kanagawa-dragon-4QPQEBJF.js +0 -7
  625. package/dist/gui/kanagawa-lotus-E2SVDYBP.js +0 -7
  626. package/dist/gui/kanagawa-wave-ZAYNGKIP.js +0 -7
  627. package/dist/gui/kdl-GX2QLRI3.js +0 -10
  628. package/dist/gui/kotlin-GKENNT4G.js +0 -10
  629. package/dist/gui/kusto-YE5J7WH7.js +0 -10
  630. package/dist/gui/laserwave-FEC67QFP.js +0 -7
  631. package/dist/gui/latex-AULDPOF3.js +0 -9
  632. package/dist/gui/lean-WU3KGKFX.js +0 -10
  633. package/dist/gui/less-G3PHK6XJ.js +0 -7
  634. package/dist/gui/light-plus-IWZ7H7K5.js +0 -7
  635. package/dist/gui/liquid-GRGQYWEM.js +0 -26
  636. package/dist/gui/llvm-GZMF4RGX.js +0 -10
  637. package/dist/gui/log-IVFPTJO5.js +0 -7
  638. package/dist/gui/logo-QKNO4KB4.js +0 -10
  639. package/dist/gui/lua-2SFYRRVQ.js +0 -8
  640. package/dist/gui/luau-7LGUQMID.js +0 -10
  641. package/dist/gui/make-6IBN4RHX.js +0 -7
  642. package/dist/gui/markdown-RGBXB5KM.js +0 -7
  643. package/dist/gui/marko-6ENW4ITK.js +0 -26
  644. package/dist/gui/material-theme-JOKMNPZD.js +0 -7
  645. package/dist/gui/material-theme-darker-7MTKLCCM.js +0 -7
  646. package/dist/gui/material-theme-lighter-VOBCBDGF.js +0 -7
  647. package/dist/gui/material-theme-ocean-HIZIQ6ZI.js +0 -7
  648. package/dist/gui/material-theme-palenight-MDKGMWOS.js +0 -7
  649. package/dist/gui/matlab-NVRQWPT4.js +0 -10
  650. package/dist/gui/mdc-3KJ5Z26I.js +0 -25
  651. package/dist/gui/mdx-TUFOPE2U.js +0 -10
  652. package/dist/gui/mermaid-2ELHPTEI.js +0 -10
  653. package/dist/gui/min-dark-H6FRUPEW.js +0 -7
  654. package/dist/gui/min-light-AAKNJKN7.js +0 -7
  655. package/dist/gui/mipsasm-CMTR7652.js +0 -10
  656. package/dist/gui/mojo-QON2ZHI5.js +0 -10
  657. package/dist/gui/monokai-4IQYQQA3.js +0 -7
  658. package/dist/gui/moonbit-YXIFXWNL.js +0 -10
  659. package/dist/gui/move-5AVESP7D.js +0 -10
  660. package/dist/gui/narrat-P67ZRVLF.js +0 -10
  661. package/dist/gui/nextflow-IA3AKAOV.js +0 -14
  662. package/dist/gui/nextflow-groovy-3TZGSHZN.js +0 -7
  663. package/dist/gui/nginx-A674IMF2.js +0 -15
  664. package/dist/gui/night-owl-YKMG5AEG.js +0 -7
  665. package/dist/gui/night-owl-light-FK52JHEJ.js +0 -7
  666. package/dist/gui/nim-TNAHEHQE.js +0 -15
  667. package/dist/gui/nix-PKII6ZAX.js +0 -17
  668. package/dist/gui/nord-UMPZ4MDR.js +0 -7
  669. package/dist/gui/nsis-RLNIMWJ4.js +0 -10
  670. package/dist/gui/nushell-XCKRAB5V.js +0 -10
  671. package/dist/gui/objective-c-VW6IYVZR.js +0 -7
  672. package/dist/gui/objective-cpp-A6HOVYIZ.js +0 -10
  673. package/dist/gui/ocaml-LEW2N47R.js +0 -7
  674. package/dist/gui/odin-ZYNZP2Z7.js +0 -10
  675. package/dist/gui/one-dark-pro-7ZD2R4C3.js +0 -7
  676. package/dist/gui/one-light-S6GW5JPC.js +0 -7
  677. package/dist/gui/openscad-S55J35RH.js +0 -10
  678. package/dist/gui/org-HWNUVJ3K.js +0 -203
  679. package/dist/gui/pascal-PQJYR7AK.js +0 -10
  680. package/dist/gui/perl-NRCSCL2T.js +0 -13
  681. package/dist/gui/php-7FKD7NQ6.js +0 -14
  682. package/dist/gui/pierre-dark-2VX7FTVH.js +0 -7
  683. package/dist/gui/pierre-dark-protanopia-deuteranopia-IWPDHMFY.js +0 -7
  684. package/dist/gui/pierre-dark-soft-PBZEND7C.js +0 -7
  685. package/dist/gui/pierre-dark-tritanopia-H4RGFNEU.js +0 -7
  686. package/dist/gui/pierre-light-2CTJ4CSM.js +0 -7
  687. package/dist/gui/pierre-light-protanopia-deuteranopia-SGQCEX2P.js +0 -7
  688. package/dist/gui/pierre-light-soft-FSLVXWQU.js +0 -7
  689. package/dist/gui/pierre-light-tritanopia-YDWTX7OC.js +0 -7
  690. package/dist/gui/pierre-light-vibrant-CBHQI6SK.js +0 -7
  691. package/dist/gui/pkl-BBS5JDCX.js +0 -10
  692. package/dist/gui/plastic-24BUHBC6.js +0 -7
  693. package/dist/gui/plsql-WTYXI2RI.js +0 -10
  694. package/dist/gui/po-GLVRZSLC.js +0 -10
  695. package/dist/gui/poimandres-6BCLQCCV.js +0 -7
  696. package/dist/gui/polar-HQ7LUSDG.js +0 -10
  697. package/dist/gui/postcss-5ILUXDAM.js +0 -7
  698. package/dist/gui/powerquery-T2DA4K5Q.js +0 -10
  699. package/dist/gui/powershell-YAEHZVQU.js +0 -7
  700. package/dist/gui/prisma-UYCP5C7X.js +0 -10
  701. package/dist/gui/prolog-JLW5JO7Q.js +0 -10
  702. package/dist/gui/proto-XPAGGVMR.js +0 -10
  703. package/dist/gui/pug-4D7KLPNZ.js +0 -10
  704. package/dist/gui/puppet-CAH3DWTQ.js +0 -10
  705. package/dist/gui/purescript-TY5CZSBG.js +0 -10
  706. package/dist/gui/python-AJWUUEXZ.js +0 -7
  707. package/dist/gui/qml-3P7XGIWB.js +0 -14
  708. package/dist/gui/qmldir-MU3RYVKI.js +0 -10
  709. package/dist/gui/qss-GQ3SQE63.js +0 -10
  710. package/dist/gui/r-MZS2GKC3.js +0 -7
  711. package/dist/gui/racket-EJOVFY7Q.js +0 -10
  712. package/dist/gui/raku-N7M6AP4Z.js +0 -7
  713. package/dist/gui/razor-XMDVCJ7X.js +0 -20
  714. package/dist/gui/rbs-3XJPBJS3.js +0 -10
  715. package/dist/gui/red-DQ454N4M.js +0 -7
  716. package/dist/gui/reg-FCSLOXMU.js +0 -10
  717. package/dist/gui/regexp-OU4NYHVA.js +0 -7
  718. package/dist/gui/rel-GPRT753E.js +0 -10
  719. package/dist/gui/riscv-IO6X3OUS.js +0 -10
  720. package/dist/gui/ron-LAUU7JCT.js +0 -10
  721. package/dist/gui/rose-pine-FGMQPAXN.js +0 -7
  722. package/dist/gui/rose-pine-dawn-XZHKMJMS.js +0 -7
  723. package/dist/gui/rose-pine-moon-44RDFYAS.js +0 -7
  724. package/dist/gui/rosmsg-HKG52NBT.js +0 -10
  725. package/dist/gui/rst-PIASADIQ.js +0 -56
  726. package/dist/gui/ruby-Z6MF5JYI.js +0 -25
  727. package/dist/gui/rust-C45CB5ZB.js +0 -7
  728. package/dist/gui/sas-EOAR3TJ3.js +0 -14
  729. package/dist/gui/sass-KEOLMOQJ.js +0 -10
  730. package/dist/gui/scala-O3LM5FKD.js +0 -7
  731. package/dist/gui/scheme-NGQ2H462.js +0 -10
  732. package/dist/gui/scss-WAYO2YAL.js +0 -8
  733. package/dist/gui/sdbl-G5J5BQHJ.js +0 -7
  734. package/dist/gui/shaderlab-XU7645J6.js +0 -14
  735. package/dist/gui/shellscript-QPJOW65X.js +0 -7
  736. package/dist/gui/shellsession-LCJMCYFU.js +0 -14
  737. package/dist/gui/slack-dark-VD234CKF.js +0 -7
  738. package/dist/gui/slack-ochin-QY7RWW52.js +0 -7
  739. package/dist/gui/smalltalk-LMQWJTYB.js +0 -10
  740. package/dist/gui/smithy-XKBQ5TXG.js +0 -10
  741. package/dist/gui/snazzy-light-7DJMADZF.js +0 -7
  742. package/dist/gui/solarized-dark-PXF6MHWO.js +0 -7
  743. package/dist/gui/solarized-light-XQPVPM7L.js +0 -7
  744. package/dist/gui/solidity-67AFBEYM.js +0 -10
  745. package/dist/gui/soy-C25UWDWI.js +0 -16
  746. package/dist/gui/sparql-GG32TI6Q.js +0 -14
  747. package/dist/gui/splunk-Q7OG3S6M.js +0 -10
  748. package/dist/gui/sql-6F3HA23R.js +0 -7
  749. package/dist/gui/ssh-config-EK5IZW3T.js +0 -10
  750. package/dist/gui/stata-54FRWEK5.js +0 -14
  751. package/dist/gui/stylus-TKKFQVIW.js +0 -7
  752. package/dist/gui/surrealql-2O6L6FVR.js +0 -14
  753. package/dist/gui/svelte-RQW3BSQN.js +0 -26
  754. package/dist/gui/swift-XM6BATYX.js +0 -7
  755. package/dist/gui/synthwave-84-T7XO3VP6.js +0 -7
  756. package/dist/gui/system-verilog-5A7OWIS7.js +0 -7
  757. package/dist/gui/systemd-YG2GIELU.js +0 -10
  758. package/dist/gui/talonscript-PIYOSW4G.js +0 -10
  759. package/dist/gui/tasl-LSN6MJU3.js +0 -10
  760. package/dist/gui/tcl-QL7GI7GB.js +0 -10
  761. package/dist/gui/templ-LLH4QDAT.js +0 -22
  762. package/dist/gui/terraform-7ESBXUP7.js +0 -10
  763. package/dist/gui/tex-X4LXVCV7.js +0 -8
  764. package/dist/gui/tokyo-night-FBILIEZB.js +0 -7
  765. package/dist/gui/toml-ZPLDESJA.js +0 -10
  766. package/dist/gui/ts-tags-HZGRWBOR.js +0 -81
  767. package/dist/gui/tsv-DFQOAT3Y.js +0 -10
  768. package/dist/gui/tsx-HKUFCS2K.js +0 -7
  769. package/dist/gui/turtle-JNLUZA5M.js +0 -7
  770. package/dist/gui/twig-OEKA6N6I.js +0 -30
  771. package/dist/gui/typescript-TJKT3IXK.js +0 -7
  772. package/dist/gui/typespec-LYVFB2R5.js +0 -10
  773. package/dist/gui/typst-NRT4OQOK.js +0 -243
  774. package/dist/gui/v-Y4OWOLQI.js +0 -10
  775. package/dist/gui/vala-MD66CNI7.js +0 -10
  776. package/dist/gui/vb-CPQUJ3PO.js +0 -7
  777. package/dist/gui/verilog-ECIZCOEU.js +0 -7
  778. package/dist/gui/vesper-JUVJQUCS.js +0 -7
  779. package/dist/gui/vhdl-QJIATVDS.js +0 -10
  780. package/dist/gui/viml-SAWLYNSC.js +0 -10
  781. package/dist/gui/vitesse-black-44DSWBPL.js +0 -7
  782. package/dist/gui/vitesse-dark-ZB4X3SXC.js +0 -7
  783. package/dist/gui/vitesse-light-T4PKXN2B.js +0 -7
  784. package/dist/gui/vue-YZTXYZUC.js +0 -63
  785. package/dist/gui/vue-html-3OB5SOZU.js +0 -14
  786. package/dist/gui/vue-vine-ZQNB45F6.js +0 -34
  787. package/dist/gui/vyper-545OELAD.js +0 -10
  788. package/dist/gui/wasm-6SXLSWDK.js +0 -13
  789. package/dist/gui/wasm-UNG3ITYZ.js +0 -10
  790. package/dist/gui/wenyan-6MAMINLZ.js +0 -10
  791. package/dist/gui/wgsl-GTGWOC2E.js +0 -10
  792. package/dist/gui/wikitext-X3KHSBD4.js +0 -10
  793. package/dist/gui/wit-RN2FK5B5.js +0 -10
  794. package/dist/gui/wolfram-X3KENW2V.js +0 -10
  795. package/dist/gui/xml-Y333D7KT.js +0 -8
  796. package/dist/gui/xsl-ZBX7NBWE.js +0 -9
  797. package/dist/gui/yaml-HXOTARZF.js +0 -7
  798. package/dist/gui/zenscript-UJ7J7IFX.js +0 -10
  799. package/dist/gui/zig-6J4JS6G3.js +0 -7
package/dist/mcp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var Ux=Object.defineProperty;var g=(e,t)=>()=>(e&&(t=e(e=0)),t);var Zr=(e,t)=>{for(var n in t)Ux(e,n,{get:t[n],enumerable:!0})};var nm={};Zr(nm,{failed:()=>l,isFail:()=>a,isSuccess:()=>Dt,resultStatuses:()=>Sn,succeeded:()=>d});var Sn,l,d,a,Dt,w=g(()=>{"use strict";Sn={Success:"success",Fail:"fail"},l=e=>({status:Sn.Fail,message:e,value:null}),d=(e,t)=>({status:Sn.Success,message:e,value:t}),a=e=>e.status==="fail",Dt=e=>e.status==="success"});var sm={};Zr(sm,{ACTOR_ID_ENV:()=>es,ACTOR_NAME_ENV:()=>Ot,applyActorNameArgument:()=>vl,deriveActorId:()=>rm,isValidUserId:()=>gi,isValidUserName:()=>ts,resolveEnvActor:()=>hl});import Hx from"node:crypto";var Ot,es,om,Wx,gl,gi,ts,Qo,rm,hl,vl,vo=g(()=>{"use strict";w();Ot="EPIQ_USER_NAME",es="EPIQ_USER_ID",om="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Wx=26,gl=80,gi=e=>/^[0-9A-HJKMNP-TV-Z]{26}$/.test(e),ts=e=>e.trim().length>0&&e.length<=gl,Qo=e=>e.trim().toLowerCase(),rm=e=>{let t=Hx.createHash("sha256").update(`epiq:actor:${Qo(e)}`).digest(),n="";for(let o=0;o<Wx;o++)n+=om[(t[o]??0)%om.length];return n},hl=(e,t=process.env)=>{let n=(t[Ot]??"").trim(),o=(t[es]??"").trim();return n?ts(n)?!o&&e.userId&&e.userName&&Qo(e.userName)===Qo(n)?d("Actor override names the configured user",{userId:e.userId,userName:e.userName}):o&&!gi(o)?l(`${es} must be 26 characters of Crockford base32`):o&&e.userId&&o===e.userId?l(`${es} is the configured user's own id; using it under a different name would rename them on the board`):d("Resolved actor from environment",{userId:o||rm(n),userName:o?n:Qo(n)}):l(`${Ot} must be 1-${gl} characters of text`):o?l(`${es} is set without ${Ot}`):d("No actor override",null)},vl=(e,t,n=process.env)=>{let o=e.trim();if(!ts(o))return l(`${t} must be 1-${gl} characters of text`);let r=(n[Ot]??"").trim();return r&&Qo(r)!==Qo(o)?l(`${t} names ${o}, but ${Ot} names ${r}`):(r||(n[Ot]=o),d("Applied actor name argument",r||o))}});var yl,im=g(()=>{"use strict";yl="1.9.0"});var am={};Zr(am,{parseMcpArgs:()=>Gx});var qx,Gx,lm=g(()=>{"use strict";im();qx=`epiq-mcp ${yl}
2
+ var uI=Object.defineProperty;var g=(e,t)=>()=>(e&&(t=e(e=0)),t);var rs=(e,t)=>{for(var n in t)uI(e,n,{get:t[n],enumerable:!0})};var hm={};rs(hm,{failed:()=>l,isFail:()=>a,isSuccess:()=>Dt,resultStatuses:()=>An,succeeded:()=>d});var An,l,d,a,Dt,N=g(()=>{"use strict";An={Success:"success",Fail:"fail"},l=e=>({status:An.Fail,message:e,value:null}),d=(e,t)=>({status:An.Success,message:e,value:t}),a=e=>e.status==="fail",Dt=e=>e.status==="success"});var bm={};rs(bm,{ACTOR_ID_ENV:()=>os,ACTOR_NAME_ENV:()=>Ot,applyActorNameArgument:()=>wl,deriveActorId:()=>ym,isValidUserId:()=>Ni,isValidUserName:()=>ss,resolveEnvActor:()=>Cl});import mI from"node:crypto";var Ot,os,vm,pI,Nl,Ni,ss,no,ym,Cl,wl,yr=g(()=>{"use strict";N();Ot="EPIQ_USER_NAME",os="EPIQ_USER_ID",vm="0123456789ABCDEFGHJKMNPQRSTVWXYZ",pI=26,Nl=80,Ni=e=>/^[0-9A-HJKMNP-TV-Z]{26}$/.test(e),ss=e=>e.trim().length>0&&e.length<=Nl,no=e=>e.trim().toLowerCase(),ym=e=>{let t=mI.createHash("sha256").update(`epiq:actor:${no(e)}`).digest(),n="";for(let r=0;r<pI;r++)n+=vm[(t[r]??0)%vm.length];return n},Cl=(e,t=process.env)=>{let n=(t[Ot]??"").trim(),r=(t[os]??"").trim();return n?ss(n)?!r&&e.userId&&e.userName&&no(e.userName)===no(n)?d("Actor override names the configured user",{userId:e.userId,userName:e.userName}):r&&!Ni(r)?l(`${os} must be 26 characters of Crockford base32`):r&&e.userId&&r===e.userId?l(`${os} is the configured user's own id; using it under a different name would rename them on the board`):d("Resolved actor from environment",{userId:r||ym(n),userName:r?n:no(n)}):l(`${Ot} must be 1-${Nl} characters of text`):r?l(`${os} is set without ${Ot}`):d("No actor override",null)},wl=(e,t,n=process.env)=>{let r=e.trim();if(!ss(r))return l(`${t} must be 1-${Nl} characters of text`);let o=(n[Ot]??"").trim();return o&&no(o)!==no(r)?l(`${t} names ${r}, but ${Ot} names ${o}`):(o||(n[Ot]=r),d("Applied actor name argument",o||r))}});var Al,xm=g(()=>{"use strict";Al="1.10.0"});var Im={};rs(Im,{parseMcpArgs:()=>gI});var fI,gI,Em=g(()=>{"use strict";xm();fI=`epiq-mcp ${Al}
3
3
 
4
4
  Usage: epiq-mcp [name]
5
5
 
@@ -9,104 +9,104 @@ Usage: epiq-mcp [name]
9
9
  Options:
10
10
  -v, --version print the version
11
11
  -h, --help print this help
12
- `,Gx=e=>{if(e.length>1)return{kind:"error",message:`Expected at most one name argument, got ${e.length}`};let t=e[0];return t===void 0?{kind:"none"}:t==="--version"||t==="-v"?{kind:"print",text:`${yl}
13
- `}:t==="--help"||t==="-h"?{kind:"print",text:qx}:t.startsWith("-")?{kind:"error",message:`Unknown option ${t}; expected a name, e.g. epiq-mcp claude/peter`}:{kind:"name",name:t}}});import{decodeTime as cm}from"ulid";var hi,ns,ct,os,dm,yo,ft=g(()=>{"use strict";w();hi=1440*60*1e3,ns=(e,t=Date.now())=>e>t+hi?t:e,ct=e=>ns(cm(e)),os=e=>{let t=Date.now()+hi,n=e.find(r=>r!==null&&r<=t)??null;if(n===null)return[...e];let o=null;return e.map(r=>{if(r===null)return null;let s=r<=t?r:o??n;return o=s,s})},dm=e=>{try{return d("Decoded date",new Date(ct(e)))}catch(t){return l("Decoding failed + "+t.message)}},yo=e=>{if(!e?.id)return null;try{return cm(e.id)}catch{return null}}});var tt,k,Je=g(()=>{"use strict";tt={bg:"#1a1b26",fg:"#c8d3ff",grayDark:"#3a3e54",gray:"#46507a",grayLight:"#969bb5",cyan:"#88d5ee",cyanSoft:"#8fe6fb",blue:"#5b8cff",magenta:"#a78bfa",magentaSoft:"#c4b5fd",green:"#8fdc8c",yellow:"#f1c27d",red:"#ff7a90",white:"#ffffff"},k={accent:tt.cyan,accent2:tt.magenta,primary:tt.white,secondary:tt.grayDark,secondary2:tt.grayLight,gray:tt.gray,green:tt.green,yellow:tt.yellow,red:tt.red}});var M,vi,bl=g(()=>{"use strict";Je();M={red:tt.red,yellow:tt.yellow,green:tt.green,blue:tt.blue,magenta:tt.magenta,cyan:tt.cyan},vi={urgent:M.red,critical:M.red,important:M.red,blocker:M.red,asap:M.red,immediate:M.red,fail:M.red,failure:M.red,broken:M.red,bug:M.red,error:M.red,incident:M.red,outage:M.red,production:M.red,crash:M.red,security:M.red,warning:M.yellow,warn:M.yellow,risky:M.yellow,risk:M.yellow,attention:M.yellow,pending:M.yellow,review:M.yellow,"needs-review":M.yellow,qa:M.yellow,testing:M.yellow,test:M.yellow,validate:M.yellow,verification:M.yellow,staging:M.yellow,check:M.yellow,"follow-up":M.yellow,followup:M.yellow,waiting:M.yellow,blocked:M.yellow,hold:M.yellow,done:M.green,complete:M.green,completed:M.green,success:M.green,ok:M.green,stable:M.green,resolved:M.green,fixed:M.green,closed:M.green,merged:M.green,released:M.green,deployed:M.green,approved:M.green,verified:M.green,working:M.green,healthy:M.green,pass:M.green,passing:M.green,info:M.blue,information:M.blue,note:M.blue,docs:M.blue,documentation:M.blue,doc:M.blue,guide:M.blue,help:M.blue,explanation:M.blue,detail:M.blue,details:M.blue,context:M.blue,design:M.blue,discussion:M.blue,proposal:M.blue,idea:M.blue,feature:M.magenta,enhancement:M.magenta,improvement:M.magenta,refactor:M.magenta,refactoring:M.magenta,cleanup:M.magenta,optimize:M.magenta,optimization:M.magenta,perf:M.magenta,performance:M.magenta,upgrade:M.magenta,migration:M.magenta,modernize:M.magenta,debt:M.magenta,todo:M.cyan,next:M.cyan,planned:M.cyan,plan:M.cyan,future:M.cyan,backlog:M.cyan,investigate:M.cyan,explore:M.cyan,prototype:M.cyan}});import um from"chalk";var Il,mm,xl,pm,zx,Vx,fm,Kx,Yx,El,nt,gm,hm,yi,Xx,Jx,bi,dn=g(()=>{"use strict";bl();Il={stringColor:{saturation:50,lightness:60},gradient:{stops:[[174,150,240],[92,138,232],[102,204,226]]}},mm=(e,t,n)=>Math.max(t,Math.min(n,e)),xl=(e,t,n)=>e+(t-e)*n,pm=e=>{let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return t},zx=e=>e.toLowerCase().trim(),Vx=(e,t,n)=>{let o=t/100,r=n/100,s=(1-Math.abs(2*r-1))*o,i=e/60,c=s*(1-Math.abs(i%2-1)),u=0,p=0,m=0;i>=0&&i<1?(u=s,p=c):i>=1&&i<2?(u=c,p=s):i>=2&&i<3?(p=s,m=c):i>=3&&i<4?(p=c,m=s):i>=4&&i<5?(u=c,m=s):(u=s,m=c);let f=r-s/2;return[Math.round((u+f)*255),Math.round((p+f)*255),Math.round((m+f)*255)]},fm=([e,t,n])=>`#${e.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`,Kx=(e,t,n)=>{let o=mm(n,0,1);return[Math.round(xl(e[0],t[0],o)),Math.round(xl(e[1],t[1],o)),Math.round(xl(e[2],t[2],o))]},Yx=(e,t,n)=>Kx(e,t,n),El=e=>{let t=pm(e)%360,n=Vx(t,Il.stringColor.saturation,Il.stringColor.lightness);return fm(n)},nt=(e,t=vi)=>{let n=zx(e??"");return n&&t[n]?t[n]:El(n)},gm=e=>{let t=Il.gradient.stops,n=mm(e,0,1);if(t.length===0)return[0,0,0];if(t.length===1)return t[0];let o=t.length-1,r=n*o,s=Math.min(Math.floor(r),o-1),i=r-s;return Yx(t[s],t[s+1],i)},hm=e=>fm(gm(e)),yi=e=>pm(e.toLowerCase().trim())/4294967295,Xx=e=>{let t=yi(e);return gm(t)},Jx=e=>{let[t,n,o]=Xx(e);return{normal:r=>um.bgRgb(t,n,o).black(r),cursor:r=>um.bgRgb(t,n,o).white.bold(r)}},bi=e=>Jx(e).normal(` ${e} `)});var Qx,rs,gt,Nn=g(()=>{"use strict";dn();Qx="Unknown",rs=(e,t)=>t?.length?t:e?.length?e:Qx,gt=(e,t)=>{let n=rs(e,t);return{id:e?.length?e:n,name:n,color:nt(n)}}});var ss,Nt,vm,Yt=g(()=>{"use strict";w();ss="removed",Nt=(e,t)=>{let n=e.find(o=>o.context===t);return n!==void 0?d("Found node",n):l("Unable to find node in breadcrumb")},vm=["png","jpg","gif","webp"]});var Ve,Gn,is,Rl,Sl,zn,ym,xi,wt=g(()=>{"use strict";Ve=e=>e.trim().toLowerCase(),Gn=e=>{let t=Ve(e);return t.length>0&&t.length<=254&&/^[^\s@]+@[^\s@]+$/.test(t)},is=(e,t)=>`${Ve(e)} ${t}`,Rl=e=>!e.tombstoned,Sl=(e,t)=>{let n=Ve(t),o=new Set;for(let r of Object.values(e))Rl(r)&&r.email===n&&o.add(r.contributor);return[...o]},zn=(e,t)=>{let n=new Set;for(let o of Object.values(e))Rl(o)&&o.contributor===t&&n.add(o.email);return[...n]},ym=e=>{let t=new Map;for(let o of Object.values(e)){if(!Rl(o))continue;let r=t.get(o.email)??new Set;r.add(o.contributor),t.set(o.email,r)}let n=new Map;for(let[o,r]of t){let[s]=[...r];r.size===1&&s&&n.set(o,s)}return n},xi=(e,t)=>e===t.authorId||e===t.contributor});function Nl(e){return e.context===se.WORKSPACE}function U(e){return e.context===se.TICKET}function bm(e){return e.context===se.TEXT}function ot(e){return e.context===se.FIELD}function as(e){return e.context===se.FIELD_LIST}var se,bo,xo,ls,me=g(()=>{"use strict";se={WORKSPACE:"WORKSPACE",BOARD:"BOARD",SWIMLANE:"SWIMLANE",TICKET:"TICKET",FIELD:"FIELD",FIELD_LIST:"FIELD_LIST",TEXT:"TEXT",COMMENT:"COMMENT"};bo=e=>e.context===se.SWIMLANE,xo=e=>e.context===se.BOARD,ls=e=>e.context===se.COMMENT});var b,Oe=g(()=>{"use strict";b={DEFAULT:"default",MOVE:"move",HELP:"help",COMMAND_LINE:"cmd-line",PALETTE:"palette",IDENTITY:"identity"}});var xm=g(()=>{"use strict";Vn()});import Im from"string-width";function Ii(e,t){let n=Math.min(e.length,t.length),o=0;for(;o<n&&e[o]===t[o];)o++;return o}var Io,Zx,wl,eI,Eo,Se,ht=g(()=>{"use strict";Io=(e,t)=>t<=0?"":e.length<=t?e:t<=3?"...".slice(0,t):e.slice(0,t-3)+"...",Zx=/\u001B\[[0-9;]*m/,wl="\x1B[0m",eI=e=>[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(e)].map(({segment:t})=>t),Eo=(e,t)=>{if(t<=0)return"";if(Im(e)<=t)return e;if(t<=3)return"...".slice(0,t);let o=t-3,r="",s=0,i=!1;for(let c of e.split(/(\u001B\[[0-9;]*m)/))if(c!==""){if(Zx.test(c)){r+=c,i=c!==wl&&c!=="\x1B[m";continue}for(let u of eI(c)){let p=Im(u);if(s+p>o)return`${r}...${i?wl:""}`;r+=u,s+=p}}return`${r}...${i?wl:""}`},Se=e=>typeof e!="string"?"":e.replace(/[\x00-\x08\x0B-\x1F\x7F]/g,"").replace(/[\r\n\t]/g," ").replace(/\s+/g," ").trim()});var Em,Rm,Sm=g(()=>{"use strict";Em=e=>{let t=new Map;for(let n of e){let o=n.toLowerCase();for(let r=1;r<=n.length;r++){let s=o.slice(0,r),i=t.get(s);i?i.push(n):t.set(s,[n])}}return t},Rm=(e,t)=>t?e.get(t)??[]:[]});var Nm,tI,wm,Cm=g(()=>{"use strict";ht();Sm();Nm=new WeakMap,tI=e=>{let t=Nm.get(e);return t||(t=Em(e),Nm.set(e,t)),t},wm=({wordList:e,inputToMatch:t,overlapThreshold:n=1})=>{let o=t.toLowerCase();return Rm(tI(e),o).filter(s=>Ii(o,s.toLowerCase())>=n)}});var nI,Tm,Am,km=g(()=>{"use strict";ht();Cm();nI={hint:"",hints:[],overlap:0,remainder:""},Tm=({inputToMatch:e,lastWord:t,isLastWordCompleted:n,inputString:o},r,s=[])=>{if(n||e===""){let[c]=s;return s.length===1&&c&&!o.trim()?Am("",[c]):nI}let i=wm({wordList:r,inputToMatch:e,overlapThreshold:1});return Am(t,i)},Am=(e,t)=>{let n=t[0]??"",o=Ii(e.toLowerCase(),n.toLowerCase()),[r,s]=n.split(":"),i=o<(r??"").length,c=!!s,m=(c&&i?r:n)+(c&&i?":":" "),f=m.slice(o);return{hint:m,hints:t,overlap:o,remainder:f}}});import{useSyncExternalStore as QA}from"react";var Ei,oI,rI,le,Qe,Fe=g(()=>{"use strict";Ei={logLevel:"info",autoSyncIntervalMs:null,attachmentMaxKb:null,autoSync:null,preferredEditor:null,userName:null,userId:null,gitEmail:null,gitName:null,declinedEmailBoards:[],viewMode:null},oI=new Set,rI=()=>{for(let e of oI)e()},le=()=>Ei,Qe=e=>(Ei={...Ei,...e},rI(),Ei)});function Mm(e){return!e||!iI.test(e)?l(`Invalid hex rank: ${e}`):d("Converted rank to bigint",BigInt("0x"+e))}function Ct(e,t=cs){if(e<0n)return l("Negative rank not allowed");let n=e.toString(16);return d("Converted bigint to hex rank",n.padStart(Number(t),"0"))}function dt(e,t){if(!e&&!t)return Ct(Xt/2n,cs);let n=e?Mm(e):d("Resolved lower bound",0n);if(a(n))return n;let o=t?Mm(t):d("Resolved upper bound",Xt);if(a(o))return o;let r=n.value,s=o.value;if(s<=r)return l("Neighbouring ranks leave no space between them");let i=(r+s)/2n;return i===r||i===s?l("No rank space available between neighbors"):Ct(i,cs)}function Lm(e){if(e<=0)return d("Resolved empty rank list",[]);let t=BigInt(e),n=[];for(let o=0;o<e;o++){let r=Xt*BigInt(o+1)/(t+1n),s=Ct(r,cs);if(a(s))return s;n.push(s.value)}return d("Resolved evenly spaced ranks",n)}var cs,sI,Xt,iI,Zo=g(()=>{"use strict";w();cs=24n,sI=cs*4n,Xt=(1n<<sI)-1n,iI=/^[0-9a-f]+$/});var D,Pm,Ft=g(()=>{"use strict";D=({userId:e})=>({userId:e}),Pm=e=>({action:e.action,payload:e.payload})});var Cl,cT,_t=g(()=>{"use strict";Ft();Cl=["init.workspace","add.workspace","add.board","add.swimlane","add.issue","add.field","edit.title","delete.node","create.tag","tombstone.tag","restore.tag","create.contributor","rename.contributor","tombstone.contributor","restore.contributor","add.issue.assignee","remove.issue.assignee","add.issue.tag","remove.issue.tag","move.node","edit.description","add.issue.comment","edit.issue.comment","delete.issue.comment","add.issue.attachment","delete.issue.attachment","close.issue","reopen.issue","lock.node","rebalance.children","link.contributor.user","link.contributor.email","unlink.contributor.email"],cT=new Set(Cl)});import{ulid as aI}from"ulid";var Al,Dm=g(()=>{"use strict";w();Bt();Zo();_t();Al=(e,t)=>{let n=ke(e),o=Lm(n.length);if(a(o))return o;let r={};for(let s=0;s<n.length;s++){let i=n[s],c=o.value[s];if(!i||!c)return l("Unable to assign rebalance rank");r[i.id]=c}return d("Created rebalance event",{id:aI(),action:"rebalance.children",payload:{parent:e,ranks:r},...D(t)})}});import{z as Ro}from"zod";var Om,Fm,lI,cI,_m,dI,uI,Tl,Bm,kl,ds=g(()=>{"use strict";w();Om=1,Fm=Ro.tuple([Ro.string().min(1),Ro.string().min(1).nullable()]),lI=Ro.looseObject({v:Ro.literal(Om),id:Fm}),cI=Ro.looseObject({v:Ro.number().int().positive(),id:Fm}),_m=e=>{let t=cI.safeParse(e);return t.success?d("Parsed persisted event envelope",t.data):l(`Invalid persisted event envelope: ${t.error.issues.map(n=>n.path.join(".")||n.message).join(", ")}`)},dI=[1],uI=new Set(dI),Tl=e=>uI.has(e),Bm=e=>{let t=lI.safeParse(e);return t.success?d("Parsed persisted event",t.data):l(`Invalid persisted event: ${t.error.issues.map(n=>n.path.join(".")||n.message).join(", ")}`)},kl=(e,t)=>{let n={[e.action]:e.payload,v:Om,id:t};return Bm(n)}});import us from"node:fs";import{ulid as mI}from"ulid";import{z as Ri}from"zod";var pI,fI,Si,At,un,Ml,Jt=g(()=>{"use strict";w();ee();pI="__epiq_state__",fI=Ri.object({projectId:Ri.string().min(1),stateBranch:Ri.string().min(1),createdAt:Ri.iso.datetime()}),Si=()=>({projectId:mI(),stateBranch:pI,createdAt:new Date().toISOString()}),At=e=>{let t=er(e);if(!us.existsSync(t))return l("Missing .epiq/project.json");try{let n=us.readFileSync(t,"utf8"),o=JSON.parse(n),r=fI.safeParse(o);return r.success?d("Read project.json",r.data):l(`Invalid .epiq/project.json: ${r.error.issues.map(s=>`${s.path.join(".")}: ${s.message}`).join(", ")}`)}catch(n){return l(n instanceof Error?`Failed to read .epiq/project.json: ${n.message}`:"Failed to read .epiq/project.json")}},un=e=>{let t=At(e);return a(t)?l(t.message):d("Read projectId",t.value.projectId)},Ml=({repoRoot:e,fileContents:t})=>{let n=So(e),o=er(e);try{if(us.mkdirSync(n,{recursive:!0}),us.existsSync(o)){let r=At(e);return a(r)?l(r.message):d("Project already initialized",null)}return us.writeFileSync(o,JSON.stringify(t,null,2)+`
14
- `,"utf8"),d("Created project.json",null)}catch(r){return l(r instanceof Error?`Failed to initialize project: ${r.message}`:"Failed to initialize project")}}});import gI from"node:os";import hI from"node:path";var Qt,wn,Ni=g(()=>{"use strict";Qt=".epiq-global",wn=()=>process.env.EPIQ_GLOBAL_DIR??hI.join(gI.homedir(),Qt)});var Ll,$m=g(()=>{"use strict";w();Ll=(e,t)=>{let n=new Map,o=t??((...s)=>JSON.stringify(s)),r=((...s)=>{let i=o(...s);if(!n.has(i)){let c=e(...s).then(u=>(a(u)&&n.delete(i),u));n.set(i,c)}return n.get(i)});return r.clear=()=>n.clear(),r}});var Ne,wi=g(()=>{"use strict";Ke();Ne={stage:({cwd:e,pathspec:t,ignoreRemoval:n=!1})=>W({args:["add",...n?["--ignore-removal"]:[],...t],cwd:e}),commit:({cwd:e,message:t,allowEmpty:n=!1,pathspec:o})=>W({args:["commit","--no-verify",...n?["--allow-empty"]:[],"-m",t,...o?.length?["--",...o]:[]],cwd:e}),fetch:({cwd:e,remote:t,branch:n})=>W({args:["fetch",t,`+refs/heads/${n}:refs/remotes/${t}/${n}`],cwd:e}),rebaseOnto:({cwd:e,ref:t})=>W({args:["-c","rebase.autoStash=true","rebase",t],cwd:e}),checkout:({cwd:e,branch:t})=>W({args:["checkout",t],cwd:e}),push:({cwd:e,remote:t,branch:n,setUpstream:o=!1})=>{let r=t&&n?["push","--no-verify",...o?["-u"]:[],t,n]:["push","--no-verify"];return W({args:r,cwd:e})},setUpstream:({cwd:e,branch:t,upstream:n})=>W({args:["branch","--set-upstream-to",n,t],cwd:e}),worktreeAdd:({cwd:e,worktreeRoot:t,branch:n})=>W({args:["worktree","add",t,n],cwd:e}),worktreeRemove:({cwd:e,worktreeRoot:t})=>W({args:["worktree","remove","--force",t],cwd:e}),worktreePrune:({cwd:e})=>W({args:["worktree","prune"],cwd:e})}});var vt,Tt,Cn=g(()=>{"use strict";Jt();w();ee();vt=e=>{let t=we(e);if(a(t))return l("Unable to resolve epiq project root");let n=At(t.value);return a(n)?l("Unable to read project.json"):d("Resolved state branch",n.value.stateBranch)},Tt="origin"});import{spawn as Um}from"node:child_process";import An from"node:fs";import Tn from"node:path";var Pl,vI,yI,bI,xI,Hm,Wm,qm,W,Le,Dl,nr,Ol,II,Ci,kn,ms,Ai,tr,Gm,Fl,Ti,zm,Vm,Km,EI,RI,SI,NI,wI,jm,ps,CI,fs,Ym,Xm,Jm,Qm,Ke=g(()=>{"use strict";w();wi();Cn();Pl=1e4,vI=12e4,yI=new Set(["fetch","push","pull","clone","ls-remote","rebase","checkout","worktree"]),bI=e=>{let t=e.find((n,o)=>!n.startsWith("-")&&e[o-1]!=="-c");return t&&yI.has(t)?vI:Pl},xI=()=>{let e=process.platform==="win32"?["git.exe","git"]:["git"];for(let t of(process.env.PATH??"").split(Tn.delimiter))if(t)for(let n of e){let o=Tn.join(t,n);try{if(!An.statSync(o).isFile())continue;return An.accessSync(o,An.constants.X_OK),o}catch{continue}}return"git"},Hm=xI(),Wm={...process.env,GIT_TERMINAL_PROMPT:"0",GIT_ASKPASS:"echo",GIT_SSH_COMMAND:process.env.GIT_SSH_COMMAND??"ssh -o BatchMode=yes -o ConnectTimeout=10"},qm=({args:e,cwd:t,allowFail:n})=>new Promise(o=>{if(!An.existsSync(t)){let f=`Git cwd does not exist: ${t}`;if(n){o({stdout:"",stderr:f,exitCode:1});return}o(l(f));return}let r=Um(Hm,e,{cwd:t,stdio:["ignore","pipe","pipe"],env:Wm}),s=!1,i="",c="",u=f=>{s||(s=!0,clearTimeout(m),o(f))},p=bI(e),m=setTimeout(()=>{r.kill("SIGTERM");let f=[`git ${e.join(" ")}`,`cwd=${t}`,`Git command timed out after ${p}ms`].join(`
15
- `);u(n?{stdout:i,stderr:f,exitCode:124}:l(f))},p);r.stdout.setEncoding("utf8"),r.stderr.setEncoding("utf8"),r.stdout.on("data",f=>{i+=f}),r.stderr.on("data",f=>{c+=f}),r.on("error",f=>{if(n){u({stdout:i,stderr:f.message,exitCode:1});return}u(l([`git ${e.join(" ")}`,`cwd=${t}`,f.message].join(`
16
- `)))}),r.on("close",f=>{let h=f??1;if(n){u({stdout:i,stderr:c,exitCode:h});return}if(h!==0){u(l([`git ${e.join(" ")}`,c.trim()||i.trim()||"Git command failed"].filter(Boolean).join(`
17
- `)));return}u(d("Git command succeeded",{stdout:i,stderr:c,exitCode:h}))})}),W=({args:e,cwd:t})=>qm({args:e,cwd:t,allowFail:!1}),Le=({args:e,cwd:t})=>qm({args:e,cwd:t,allowFail:!0}),Dl=(e,t)=>new Promise(n=>{if(e.length===0){n(d("No blobs to read",new Map));return}let o=Um(Hm,["cat-file","--batch"],{cwd:t,stdio:["pipe","pipe","pipe"],env:Wm}),r=[],s="",i=!1,c=p=>{i||(i=!0,clearTimeout(u),n(p))},u=setTimeout(()=>{o.kill("SIGTERM"),c(l(`git cat-file --batch timed out after ${Pl}ms`))},Pl);o.stdout.on("data",p=>r.push(p)),o.stderr.setEncoding("utf8"),o.stderr.on("data",p=>{s+=p}),o.on("error",p=>c(l(p.message))),o.on("close",p=>{if(p!==0){c(l(`git cat-file --batch exited ${p}${s?`
18
- ${s}`:""}`));return}let m=Buffer.concat(r),f=new Map,h=0;for(let x of e){let E=m.indexOf(10,h);if(E===-1){c(l(`git cat-file --batch output ended before a header for ${x}`));return}let S=m.toString("utf8",h,E);h=E+1;let C=/^[0-9a-f]{4,64} \S+ (\d+)$/.exec(S);if(!C||!C[1]){c(l(`Unexpected git cat-file --batch header: "${S}"`));return}let R=Number(C[1]);f.set(x,m.toString("utf8",h,h+R)),h+=R+1}c(d("Read blobs",f))}),o.stdin.write(e.join(`
12
+ `,gI=e=>{if(e.length>1)return{kind:"error",message:`Expected at most one name argument, got ${e.length}`};let t=e[0];return t===void 0?{kind:"none"}:t==="--version"||t==="-v"?{kind:"print",text:`${Al}
13
+ `}:t==="--help"||t==="-h"?{kind:"print",text:fI}:t.startsWith("-")?{kind:"error",message:`Unknown option ${t}; expected a name, e.g. epiq-mcp claude/peter`}:{kind:"name",name:t}}});import{decodeTime as Rm}from"ulid";var Ci,is,at,as,Tl,br,lt=g(()=>{"use strict";N();Ci=1440*60*1e3,is=(e,t=Date.now())=>e>t+Ci?t:e,at=e=>is(Rm(e)),as=e=>{let t=Date.now()+Ci,n=e.find(o=>o!==null&&o<=t)??null;if(n===null)return[...e];let r=null;return e.map(o=>{if(o===null)return null;let s=o<=t?o:r??n;return r=s,s})},Tl=e=>{try{return d("Decoded date",new Date(at(e)))}catch(t){return l("Decoding failed + "+t.message)}},br=e=>{if(!e?.id)return null;try{return Rm(e.id)}catch{return null}}});var et,T,Je=g(()=>{"use strict";et={bg:"#1a1b26",fg:"#c8d3ff",grayDark:"#3a3e54",gray:"#46507a",grayLight:"#969bb5",cyan:"#88d5ee",cyanSoft:"#8fe6fb",blue:"#5b8cff",magenta:"#a78bfa",magentaSoft:"#c4b5fd",green:"#8fdc8c",yellow:"#f1c27d",red:"#ff7a90",white:"#ffffff"},T={accent:et.cyan,accent2:et.magenta,primary:et.white,secondary:et.grayDark,secondary2:et.grayLight,gray:et.gray,green:et.green,yellow:et.yellow,red:et.red}});var L,wi,kl=g(()=>{"use strict";Je();L={red:et.red,yellow:et.yellow,green:et.green,blue:et.blue,magenta:et.magenta,cyan:et.cyan},wi={urgent:L.red,critical:L.red,important:L.red,blocker:L.red,asap:L.red,immediate:L.red,fail:L.red,failure:L.red,broken:L.red,bug:L.red,error:L.red,incident:L.red,outage:L.red,production:L.red,crash:L.red,security:L.red,warning:L.yellow,warn:L.yellow,risky:L.yellow,risk:L.yellow,attention:L.yellow,pending:L.yellow,review:L.yellow,"needs-review":L.yellow,qa:L.yellow,testing:L.yellow,test:L.yellow,validate:L.yellow,verification:L.yellow,staging:L.yellow,check:L.yellow,"follow-up":L.yellow,followup:L.yellow,waiting:L.yellow,blocked:L.yellow,hold:L.yellow,done:L.green,complete:L.green,completed:L.green,success:L.green,ok:L.green,stable:L.green,resolved:L.green,fixed:L.green,closed:L.green,merged:L.green,released:L.green,deployed:L.green,approved:L.green,verified:L.green,working:L.green,healthy:L.green,pass:L.green,passing:L.green,info:L.blue,information:L.blue,note:L.blue,docs:L.blue,documentation:L.blue,doc:L.blue,guide:L.blue,help:L.blue,explanation:L.blue,detail:L.blue,details:L.blue,context:L.blue,design:L.blue,discussion:L.blue,proposal:L.blue,idea:L.blue,feature:L.magenta,enhancement:L.magenta,improvement:L.magenta,refactor:L.magenta,refactoring:L.magenta,cleanup:L.magenta,optimize:L.magenta,optimization:L.magenta,perf:L.magenta,performance:L.magenta,upgrade:L.magenta,migration:L.magenta,modernize:L.magenta,debt:L.magenta,todo:L.cyan,next:L.cyan,planned:L.cyan,plan:L.cyan,future:L.cyan,backlog:L.cyan,investigate:L.cyan,explore:L.cyan,prototype:L.cyan}});import Sm from"chalk";var Ll,Nm,Ml,Cm,hI,vI,wm,yI,bI,Pl,tt,Am,Tm,Ai,xI,II,Ti,un=g(()=>{"use strict";kl();Ll={stringColor:{saturation:50,lightness:60},gradient:{stops:[[174,150,240],[92,138,232],[102,204,226]]}},Nm=(e,t,n)=>Math.max(t,Math.min(n,e)),Ml=(e,t,n)=>e+(t-e)*n,Cm=e=>{let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return t},hI=e=>e.toLowerCase().trim(),vI=(e,t,n)=>{let r=t/100,o=n/100,s=(1-Math.abs(2*o-1))*r,i=e/60,c=s*(1-Math.abs(i%2-1)),u=0,p=0,m=0;i>=0&&i<1?(u=s,p=c):i>=1&&i<2?(u=c,p=s):i>=2&&i<3?(p=s,m=c):i>=3&&i<4?(p=c,m=s):i>=4&&i<5?(u=c,m=s):(u=s,m=c);let f=o-s/2;return[Math.round((u+f)*255),Math.round((p+f)*255),Math.round((m+f)*255)]},wm=([e,t,n])=>`#${e.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`,yI=(e,t,n)=>{let r=Nm(n,0,1);return[Math.round(Ml(e[0],t[0],r)),Math.round(Ml(e[1],t[1],r)),Math.round(Ml(e[2],t[2],r))]},bI=(e,t,n)=>yI(e,t,n),Pl=e=>{let t=Cm(e)%360,n=vI(t,Ll.stringColor.saturation,Ll.stringColor.lightness);return wm(n)},tt=(e,t=wi)=>{let n=hI(e??"");return n&&t[n]?t[n]:Pl(n)},Am=e=>{let t=Ll.gradient.stops,n=Nm(e,0,1);if(t.length===0)return[0,0,0];if(t.length===1)return t[0];let r=t.length-1,o=n*r,s=Math.min(Math.floor(o),r-1),i=o-s;return bI(t[s],t[s+1],i)},Tm=e=>wm(Am(e)),Ai=e=>Cm(e.toLowerCase().trim())/4294967295,xI=e=>{let t=Ai(e);return Am(t)},II=e=>{let[t,n,r]=xI(e);return{normal:o=>Sm.bgRgb(t,n,r).black(o),cursor:o=>Sm.bgRgb(t,n,r).white.bold(o)}},Ti=e=>II(e).normal(` ${e} `)});var EI,ls,ht,Tn=g(()=>{"use strict";un();EI="Unknown",ls=(e,t)=>t?.length?t:e?.length?e:EI,ht=(e,t)=>{let n=ls(e,t);return{id:e?.length?e:n,name:n,color:tt(n)}}});var cs,Ct,km,Xt=g(()=>{"use strict";N();cs="removed",Ct=(e,t)=>{let n=e.find(r=>r.context===t);return n!==void 0?d("Found node",n):l("Unable to find node in breadcrumb")},km=["png","jpg","gif","webp"]});var Ve,zn,ds,Dl,Ol,Vn,Mm,ki,wt=g(()=>{"use strict";Ve=e=>e.trim().toLowerCase(),zn=e=>{let t=Ve(e);return t.length>0&&t.length<=254&&/^[^\s@]+@[^\s@]+$/.test(t)},ds=(e,t)=>`${Ve(e)} ${t}`,Dl=e=>!e.tombstoned,Ol=(e,t)=>{let n=Ve(t),r=new Set;for(let o of Object.values(e))Dl(o)&&o.email===n&&r.add(o.contributor);return[...r]},Vn=(e,t)=>{let n=new Set;for(let r of Object.values(e))Dl(r)&&r.contributor===t&&n.add(r.email);return[...n]},Mm=e=>{let t=new Map;for(let r of Object.values(e)){if(!Dl(r))continue;let o=t.get(r.email)??new Set;o.add(r.contributor),t.set(r.email,o)}let n=new Map;for(let[r,o]of t){let[s]=[...o];o.size===1&&s&&n.set(r,s)}return n},ki=(e,t)=>e===t.authorId||e===t.contributor});function _l(e){return e.context===ie.WORKSPACE}function U(e){return e.context===ie.TICKET}function Lm(e){return e.context===ie.TEXT}function nt(e){return e.context===ie.FIELD}function us(e){return e.context===ie.FIELD_LIST}var ie,xr,Ir,ms,me=g(()=>{"use strict";ie={WORKSPACE:"WORKSPACE",BOARD:"BOARD",SWIMLANE:"SWIMLANE",TICKET:"TICKET",FIELD:"FIELD",FIELD_LIST:"FIELD_LIST",TEXT:"TEXT",COMMENT:"COMMENT"};xr=e=>e.context===ie.SWIMLANE,Ir=e=>e.context===ie.BOARD,ms=e=>e.context===ie.COMMENT});var x,Oe=g(()=>{"use strict";x={DEFAULT:"default",MOVE:"move",HELP:"help",COMMAND_LINE:"cmd-line",PALETTE:"palette",IDENTITY:"identity"}});var Pm=g(()=>{"use strict";Kn()});import Dm from"string-width";function Mi(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return r}var Er,RI,Fl,SI,Rr,Se,vt=g(()=>{"use strict";Er=(e,t)=>t<=0?"":e.length<=t?e:t<=3?"...".slice(0,t):e.slice(0,t-3)+"...",RI=/\u001B\[[0-9;]*m/,Fl="\x1B[0m",SI=e=>[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(e)].map(({segment:t})=>t),Rr=(e,t)=>{if(t<=0)return"";if(Dm(e)<=t)return e;if(t<=3)return"...".slice(0,t);let r=t-3,o="",s=0,i=!1;for(let c of e.split(/(\u001B\[[0-9;]*m)/))if(c!==""){if(RI.test(c)){o+=c,i=c!==Fl&&c!=="\x1B[m";continue}for(let u of SI(c)){let p=Dm(u);if(s+p>r)return`${o}...${i?Fl:""}`;o+=u,s+=p}}return`${o}...${i?Fl:""}`},Se=e=>typeof e!="string"?"":e.replace(/[\x00-\x08\x0B-\x1F\x7F]/g,"").replace(/[\r\n\t]/g," ").replace(/\s+/g," ").trim()});var Om,_m,Fm=g(()=>{"use strict";Om=e=>{let t=new Map;for(let n of e){let r=n.toLowerCase();for(let o=1;o<=n.length;o++){let s=r.slice(0,o),i=t.get(s);i?i.push(n):t.set(s,[n])}}return t},_m=(e,t)=>t?e.get(t)??[]:[]});var Bm,NI,$m,jm=g(()=>{"use strict";vt();Fm();Bm=new WeakMap,NI=e=>{let t=Bm.get(e);return t||(t=Om(e),Bm.set(e,t)),t},$m=({wordList:e,inputToMatch:t,overlapThreshold:n=1})=>{let r=t.toLowerCase();return _m(NI(e),r).filter(s=>Mi(r,s.toLowerCase())>=n)}});var CI,Hm,Um,Wm=g(()=>{"use strict";vt();jm();CI={hint:"",hints:[],overlap:0,remainder:""},Hm=({inputToMatch:e,lastWord:t,isLastWordCompleted:n,inputString:r},o,s=[])=>{if(n||e===""){let[c]=s;return s.length===1&&c&&!r.trim()?Um("",[c]):CI}let i=$m({wordList:o,inputToMatch:e,overlapThreshold:1});return Um(t,i)},Um=(e,t)=>{let n=t[0]??"",r=Mi(e.toLowerCase(),n.toLowerCase()),[o,s]=n.split(":"),i=r<(o??"").length,c=!!s,m=(c&&i?o:n)+(c&&i?":":" "),f=m.slice(r);return{hint:m,hints:t,overlap:r,remainder:f}}});var ro,Li,Sr=g(()=>{"use strict";ro=e=>{let t=typeof e=="number"?e:Number(e.trim());return!Number.isFinite(t)||!Number.isInteger(t)||t<3e3||t>864e5?null:t},Li=e=>e==null||!Number.isFinite(e)?1e4:Math.min(864e5,Math.max(1,e))});import wI from"node:os";import AI from"node:path";var Jt,kn,Pi=g(()=>{"use strict";Jt=".epiq-global",kn=()=>process.env.EPIQ_GLOBAL_DIR??AI.join(wI.homedir(),Jt)});var Bl,qm=g(()=>{"use strict";N();Bl=(e,t)=>{let n=new Map,r=t??((...s)=>JSON.stringify(s)),o=((...s)=>{let i=r(...s);if(!n.has(i)){let c=e(...s).then(u=>(a(u)&&n.delete(i),u));n.set(i,c)}return n.get(i)});return o.clear=()=>n.clear(),o}});import Qt from"fs";import Wl from"path";import TI from"util";function PI(e){if(!Qt.existsSync(e))return;let t=Qt.statSync(e).size,n=LI(e,ql).split(`
14
+ `);if(n[n.length-1]===""&&n.pop(),t<=ql&&n.length<=Gm)return;let r=n.slice(-Gm).join(`
19
15
  `)+`
20
- `),o.stdin.end()}),nr=async({cwd:e,message:t,pathspec:n})=>{let o=await Ne.commit({cwd:e,message:t,pathspec:n});if(a(o))return l(`Failed to create commit
21
- ${o.message}`);let r=await W({args:["rev-parse","HEAD"],cwd:e});return a(r)?l(`Commit created, but failed to read HEAD SHA
22
- ${r.message}`):d("Created commit and resolved SHA",r.value.stdout.trim())},Ol=async e=>{let t=await W({cwd:e,args:["rev-parse","--git-dir"]});if(a(t))return l(t.message);let n=t.value.stdout.trim();return d("Resolved git dir",Tn.isAbsolute(n)?n:Tn.resolve(e,n))},II=async e=>{let t=await Ol(e);if(a(t))return l(t.message);let n=t.value,o={MERGE_HEAD:"merge in progress"};for(let[s,i]of Object.entries(o))if(An.existsSync(Tn.join(n,s)))return d("Checked for in-progress Git operation",i);let r={"rebase-merge":"rebase in progress","rebase-apply":"rebase in progress"};for(let[s,i]of Object.entries(r))if(An.existsSync(Tn.join(n,s)))return d("Checked for in-progress Git operation",i);return d("Checked for in-progress Git operation",null)},Ci=async e=>{let t=await II(e);return a(t)?l(t.message):d("Checked for in-progress Git operation",t.value!==null)},kn=async({repoRoot:e})=>{let n=(await Le({args:["remote","get-url",Tt],cwd:e})).exitCode===0;return d(`Checked remote ${n}`,n)},ms=async({repoRoot:e,branch:t})=>{let n=await Le({args:["ls-remote","--heads",Tt,t],cwd:e});return n.exitCode!==0?l(n.stderr.trim()||`Unable to inspect remote branch ${Tt}/${t}`):d("Checked remote branch",n.stdout.trim().length>0)},Ai=async({repoRoot:e,branch:t})=>{let n=await Le({args:["show-ref","--verify","--quiet",`refs/heads/${t}`],cwd:e});return n.exitCode===0?d("Local branch exists",!0):n.exitCode===1?d("Local branch missing",!1):l(n.stderr.trim()||`Unable to inspect branch ${t}`)},tr=e=>{try{return An.realpathSync.native(e)}catch{return Tn.resolve(e)}},Gm=async({repoRoot:e,worktreeRoot:t})=>{let n=await W({args:["worktree","list","--porcelain"],cwd:e});if(a(n))return l(n.message);let o=tr(t),r=n.value.stdout.split(`
23
- `).filter(s=>s.startsWith("worktree ")).map(s=>s.slice(9)).map(tr).includes(o);return d("Checked worktree registration",r)},Fl=async e=>{let t=await Le({args:["rev-parse","--abbrev-ref","--symbolic-full-name","@{u}"],cwd:e});return d("Checked upstream",t.exitCode===0&&t.stdout.trim().length>0)},Ti=async e=>{let t=await W({args:["rev-parse","--abbrev-ref","HEAD"],cwd:e});return a(t)?l(t.message):d("Resolved current branch",t.value.stdout.trim())},zm=async e=>{let t=await W({args:["rev-parse","--short","HEAD"],cwd:e});return a(t)?l(t.message):d("Resolved short HEAD sha",t.value.stdout.trim())},Vm=e=>e.includes("fetch first")||e.includes("non-fast-forward"),Km=async e=>{let t=await Le({cwd:e,args:["rev-parse","--absolute-git-dir"]});if(t.exitCode!==0)return!1;let n=t.stdout.trim();return n?An.existsSync(Tn.join(n,"rebase-merge"))||An.existsSync(Tn.join(n,"rebase-apply")):!1},EI=3,RI=120,SI=e=>new Promise(t=>setTimeout(t,e)),NI=async(e,t)=>{let n=await Ne.rebaseOnto({cwd:e,ref:t});for(let o=1;o<EI;o+=1){if(!a(n)||await Km(e))return n;await SI(RI),n=await Ne.rebaseOnto({cwd:e,ref:t})}return n},wI=async e=>{if(!await Km(e))return d("No rebase to abort",!1);let t=await Le({cwd:e,args:["rebase","--abort"]});return t.exitCode!==0?l(`Failed to abort the rebase in progress at ${e}
24
- ${t.stderr.trim()}`):d("Aborted stale rebase",!0)},jm=async e=>{let t=await Le({args:["rev-parse","HEAD"],cwd:e});return t.exitCode===0?t.stdout.trim():null},ps=e=>/could not resolve host/i.test(e)||/connection refused|connection timed out|operation timed out/i.test(e)||/network is unreachable|no route to host/i.test(e)||/failed to connect to/i.test(e),CI=e=>e.includes("couldn't find remote ref")||e.includes("Could not find remote branch"),fs=async({cwd:e,branch:t})=>{let n=await wI(e);if(a(n))return l(n.message);let o=await jm(e),r=await Ne.fetch({cwd:e,remote:Tt,branch:t});if(a(r))return CI(r.message)?d("Remote branch missing, skipped pull",!1):l(`Failed to fetch ${t}
25
- ${r.message}`);let s=await NI(e,`${Tt}/${t}`);if(a(s))return l(`Failed during rebase
26
- ${s.message}`);let i=await jm(e),c=o!==null&&i!==null&&o!==i;return d(c?"Pulled with rebase":"Already up to date",c)},Ym=async e=>{let t=await Le({args:["rev-list","--count","@{u}..HEAD"],cwd:e});return t.exitCode!==0?d("No upstream to compare against",!1):d("Compared against upstream",Number(t.stdout.trim())>0)},Xm=async e=>{let t=await Le({args:["status","--porcelain","--untracked-files=all"],cwd:e});return t.exitCode!==0?l(t.stderr.trim()||"Unable to inspect the worktree for changes"):d("Inspected worktree for changes",t.stdout.trim().length>0)},Jm=async(e,t)=>{let n=await Le({args:["diff","--cached","--quiet",...t?.length?["--",...t]:[]],cwd:e});return n.exitCode===0?d("No staged changes",!1):n.exitCode===1?d("Has staged changes",!0):l(n.stderr.trim()||"Unable to inspect staged changes")},Qm=async e=>{let t=await Ti(e);return a(t)?l(t.message):d("Checked detached HEAD state",t.value==="HEAD")}});import Kn from"node:fs";import yt from"node:path";var tp,np,op,rp,No,Ie,AI,Zm,gs,hs,sp,TI,kI,_l,Bl,ep,ip,ap,kt,lk,rt=g(()=>{"use strict";Jt();w();Ni();ee();$m();$t();Ke();tp="4b825dc642cb6eb9a060e54bf8d69288fbee4904",np=e=>yt.join(ut,Mn,e),op=()=>yt.join(ut,$l),rp=wn,No=()=>yt.join(rp(),"worktrees"),Ie=({repoRoot:e})=>{let t=un(e);return a(t)?l(t.message):d("Resolved state branch root",yt.join(No(),t.value))},AI=e=>yt.join(e,ut),Zm=e=>yt.join(AI(e),Mn),gs=e=>{try{return Kn.mkdirSync(e,{recursive:!0}),d("Ensured directory",void 0)}catch(t){return l(t instanceof Error?t.message:String(t))}},hs=()=>{let e=rp(),t=No(),n=!Kn.existsSync(e)||!Kn.existsSync(t),o=gs(e);if(a(o))return l(`Ensure epiq home failed.
27
- `+o.message);let r=gs(t);return a(r)?l(`Ensure worktrees dir failed.
28
- `+r.message):d("Ensured epiq storage",n)},sp=e=>{Kn.existsSync(e)&&(ce.debug("[sync] remove path",e),Kn.rmSync(e,{recursive:!0,force:!0}))},TI=`*.jsonl merge=union
29
- `,kI=`*~pending*.jsonl
30
- `,_l=()=>yt.join(ut,Mn,".gitattributes"),Bl=()=>yt.join(ut,Mn,".gitignore"),ep=(e,t)=>{try{Kn.readFileSync(e,"utf8")!==t&&Kn.writeFileSync(e,t)}catch{Kn.writeFileSync(e,t)}},ip=(e,t)=>{for(let n of[Zm(e),Zm(t)]){let o=gs(n);if(a(o))return l(o.message)}return ep(yt.join(t,_l()),TI),ep(yt.join(t,Bl()),kI),d("Ensured state branch",void 0)},ap=async e=>{let t=await W({args:["ls-tree","--name-only","HEAD"],cwd:e});if(a(t))return l(`ensure state branch is storage only failed
31
- `+t.message);let o=t.value.stdout.trim().split(`
32
- `).filter(Boolean).filter(i=>i!==ut);if(o.length===0)return d("State branch is storage-only",!1);let r=await W({args:["rm","-r","--ignore-unmatch","--",...o],cwd:e});if(a(r))return l(`Failed to clean storage branch
33
- ${r.message}`);let s=await nr({cwd:e,message:"[epiq:repair-storage-branch]",pathspec:o});return a(s)?l(s.message):d("Cleaned storage branch",!0)},kt=Ll(async(e=process.cwd())=>{let t=await W({args:["rev-parse","--show-toplevel"],cwd:e});return a(t)?l("Not inside a Git repository"):d("Resolved repo root",t.value.stdout.trim())},e=>yt.resolve(e)),lk=Ll(async e=>{let t=await W({args:["rev-parse","--git-dir"],cwd:e});if(a(t))return l(t.message);let n=t.value.stdout.trim(),o=yt.isAbsolute(n)?n:yt.join(e,n);return d("Resolved git dir",o)},e=>yt.resolve(e))});import vs from"node:fs";import mn from"node:path";var gk,ut,Mn,$l,MI,So,er,bt,ki,lp,LI,ys,Mi,PI,we,cp,Ee,ee=g(()=>{"use strict";w();rt();Ni();gk=process.env.IS_LOCAL==="true",ut=".epiq",Mn="events",$l="media",MI="project.json",So=e=>mn.join(e,ut),er=e=>mn.join(So(e),MI),bt=e=>mn.join(So(e),Mn),ki=e=>mn.join(So(e),$l),lp=e=>mn.join(e,ut),LI=e=>{let t=mn.join(e,ut);return vs.existsSync(t)&&vs.statSync(t).isDirectory()},ys=e=>{let t=er(e);return vs.existsSync(t)&&vs.statSync(t).isFile()},Mi=e=>{let t=mn.resolve(e);for(;;){if(LI(t))return d("Resolved closest .epiq root",t);let n=mn.dirname(t);if(n===t)return l("No .epiq directory found in any parent");t=n}},PI="No .epiq/project.json found in any parent",we=e=>{let t=mn.resolve(e);for(;;){if(ys(t))return d("Resolved closest epiq project root",t);let n=mn.dirname(t);if(n===t)return l(PI);t=n}},cp=e=>{let t=bt(e);try{return vs.mkdirSync(t,{recursive:!0}),d("Resolved events dir",t)}catch(n){return l(n instanceof Error?`Failed to ensure events dir: ${n.message}`:"Failed to ensure events dir")}},Ee=async()=>{let e=await kt(process.cwd());if(a(e))return e;let t=Ie({repoRoot:e.value});return a(t)?t:d("Resolved persist root",t.value)}});import Zt from"fs";import ql from"path";import DI from"util";function BI(e){if(!Zt.existsSync(e))return;let t=Zt.statSync(e).size,n=_I(e,Gl).split(`
34
- `);if(n[n.length-1]===""&&n.pop(),t<=Gl&&n.length<=dp)return;let o=n.slice(-dp).join(`
16
+ `;Qt.writeFileSync(e,r,"utf8")}function Ul(e,t,n=!1){let r=MI();if(!r)return;let o=DI(TI.format(...t)),s=new Date,c=`[${n?s.toISOString().slice(11,19):s.toISOString()}] ${e} ${o}
17
+ `;try{Qt.mkdirSync(Wl.dirname(r),{recursive:!0}),Qt.appendFileSync(r,c,"utf8"),jl++,(jl>=kI||Qt.statSync(r).size>ql)&&(jl=0,PI(r))}catch{}}var Gm,ql,$l,kI,jl,zm,MI,LI,DI,Hl,ce,_t=g(()=>{"use strict";N();ee();Gm=500,ql=4*1024*1024,$l=16*1024,kI=50,jl=0,zm=()=>process.env.EPIQ_MCP==="true",MI=()=>{let e=process.cwd(),t=Di(e);return a(t)?zm()?Wl.join(kn(),"epiq-mcp.log"):void 0:Wl.join(t.value,ct,"log","epiq.log")},LI=(e,t)=>{let n=Qt.statSync(e).size;if(n<=t)return Qt.readFileSync(e,"utf8");let r=Qt.openSync(e,"r");try{let o=Buffer.alloc(t);Qt.readSync(r,o,0,t,n-t);let s=o.toString("utf8"),i=s.indexOf(`
18
+ `);return i===-1?"":s.slice(i+1)}finally{Qt.closeSync(r)}};DI=e=>{if(e.length<=$l)return e;let t=e.length-$l;return`${e.slice(0,$l)} \u2026 [${t} more chars]`};Hl=()=>zm()?process.env.EPIQ_MCP_LOG_LEVEL??"error":process.env.EPIQ_LOG_LEVEL??"debug",ce={info(...e){let t=Hl();(t==="info"||t==="debug")&&Ul("[Info]",e,!1)},debug(...e){Hl()==="debug"&&Ul("[Debug]",e,!0)},error(...e){let t=Hl();if(t==="error"||t==="info"||t==="debug"){let r=e.some(o=>o instanceof Error)?void 0:new Error().stack;Ul("[Error]",[...e,r].filter(Boolean),!1)}}};globalThis.logger=ce});var Ne,Oi=g(()=>{"use strict";Ke();Ne={stage:({cwd:e,pathspec:t,ignoreRemoval:n=!1})=>W({args:["add",...n?["--ignore-removal"]:[],...t],cwd:e}),commit:({cwd:e,message:t,allowEmpty:n=!1,pathspec:r})=>W({args:["commit","--no-verify",...n?["--allow-empty"]:[],"-m",t,...r?.length?["--",...r]:[]],cwd:e}),fetch:({cwd:e,remote:t,branch:n})=>W({args:["fetch",t,`+refs/heads/${n}:refs/remotes/${t}/${n}`],cwd:e}),rebaseOnto:({cwd:e,ref:t})=>W({args:["-c","rebase.autoStash=true","rebase",t],cwd:e}),checkout:({cwd:e,branch:t})=>W({args:["checkout",t],cwd:e}),push:({cwd:e,remote:t,branch:n,setUpstream:r=!1})=>{let o=t&&n?["push","--no-verify",...r?["-u"]:[],t,n]:["push","--no-verify"];return W({args:o,cwd:e})},setUpstream:({cwd:e,branch:t,upstream:n})=>W({args:["branch","--set-upstream-to",n,t],cwd:e}),worktreeAdd:({cwd:e,worktreeRoot:t,branch:n})=>W({args:["worktree","add",t,n],cwd:e}),worktreeRemove:({cwd:e,worktreeRoot:t})=>W({args:["worktree","remove","--force",t],cwd:e}),worktreePrune:({cwd:e})=>W({args:["worktree","prune"],cwd:e})}});var dt,At,mn=g(()=>{"use strict";Zt();N();ee();dt=e=>{let t=Ce(e);if(a(t))return l("Unable to resolve epiq project root");let n=Tt(t.value);return a(n)?l("Unable to read project.json"):d("Resolved state branch",n.value.stateBranch)},At="origin"});import{spawn as Km}from"node:child_process";import en from"node:fs";import pn from"node:path";var Gl,OI,_I,FI,BI,Ym,Xm,Jm,W,Le,zl,so,_i,Vl,Qm,Mn,ps,Fi,oo,Zm,Kl,Bi,ep,tp,np,$I,jI,UI,HI,rp,Yl,Vm,fs,WI,gs,op,sp,ip,ap,Ke=g(()=>{"use strict";N();Oi();mn();Gl=1e4,OI=12e4,_I=new Set(["fetch","push","pull","clone","ls-remote","rebase","checkout","worktree"]),FI=e=>{let t=e.find((n,r)=>!n.startsWith("-")&&e[r-1]!=="-c");return t&&_I.has(t)?OI:Gl},BI=()=>{let e=process.platform==="win32"?["git.exe","git"]:["git"];for(let t of(process.env.PATH??"").split(pn.delimiter))if(t)for(let n of e){let r=pn.join(t,n);try{if(!en.statSync(r).isFile())continue;return en.accessSync(r,en.constants.X_OK),r}catch{continue}}return"git"},Ym=BI(),Xm={...process.env,GIT_TERMINAL_PROMPT:"0",GIT_ASKPASS:"echo",GIT_SSH_COMMAND:process.env.GIT_SSH_COMMAND??"ssh -o BatchMode=yes -o ConnectTimeout=10"},Jm=({args:e,cwd:t,allowFail:n})=>new Promise(r=>{if(!en.existsSync(t)){let f=`Git cwd does not exist: ${t}`;if(n){r({stdout:"",stderr:f,exitCode:1});return}r(l(f));return}let o=Km(Ym,e,{cwd:t,stdio:["ignore","pipe","pipe"],env:Xm}),s=!1,i="",c="",u=f=>{s||(s=!0,clearTimeout(m),r(f))},p=FI(e),m=setTimeout(()=>{o.kill("SIGTERM");let f=[`git ${e.join(" ")}`,`cwd=${t}`,`Git command timed out after ${p}ms`].join(`
19
+ `);u(n?{stdout:i,stderr:f,exitCode:124}:l(f))},p);o.stdout.setEncoding("utf8"),o.stderr.setEncoding("utf8"),o.stdout.on("data",f=>{i+=f}),o.stderr.on("data",f=>{c+=f}),o.on("error",f=>{if(n){u({stdout:i,stderr:f.message,exitCode:1});return}u(l([`git ${e.join(" ")}`,`cwd=${t}`,f.message].join(`
20
+ `)))}),o.on("close",f=>{let h=f??1;if(n){u({stdout:i,stderr:c,exitCode:h});return}if(h!==0){u(l([`git ${e.join(" ")}`,c.trim()||i.trim()||"Git command failed"].filter(Boolean).join(`
21
+ `)));return}u(d("Git command succeeded",{stdout:i,stderr:c,exitCode:h}))})}),W=({args:e,cwd:t})=>Jm({args:e,cwd:t,allowFail:!1}),Le=({args:e,cwd:t})=>Jm({args:e,cwd:t,allowFail:!0}),zl=(e,t)=>new Promise(n=>{if(e.length===0){n(d("No blobs to read",new Map));return}let r=Km(Ym,["cat-file","--batch"],{cwd:t,stdio:["pipe","pipe","pipe"],env:Xm}),o=[],s="",i=!1,c=p=>{i||(i=!0,clearTimeout(u),n(p))},u=setTimeout(()=>{r.kill("SIGTERM"),c(l(`git cat-file --batch timed out after ${Gl}ms`))},Gl);r.stdout.on("data",p=>o.push(p)),r.stderr.setEncoding("utf8"),r.stderr.on("data",p=>{s+=p}),r.on("error",p=>c(l(p.message))),r.on("close",p=>{if(p!==0){c(l(`git cat-file --batch exited ${p}${s?`
22
+ ${s}`:""}`));return}let m=Buffer.concat(o),f=new Map,h=0;for(let b of e){let E=m.indexOf(10,h);if(E===-1){c(l(`git cat-file --batch output ended before a header for ${b}`));return}let S=m.toString("utf8",h,E);h=E+1;let w=/^[0-9a-f]{4,64} \S+ (\d+)$/.exec(S);if(!w||!w[1]){c(l(`Unexpected git cat-file --batch header: "${S}"`));return}let R=Number(w[1]);f.set(b,m.toString("utf8",h,h+R)),h+=R+1}c(d("Read blobs",f))}),r.stdin.write(e.join(`
35
23
  `)+`
36
- `;Zt.writeFileSync(e,o,"utf8")}function Hl(e,t,n=!1){let o=FI();if(!o)return;let r=$I(DI.format(...t)),s=new Date,c=`[${n?s.toISOString().slice(11,19):s.toISOString()}] ${e} ${r}
37
- `;try{Zt.mkdirSync(ql.dirname(o),{recursive:!0}),Zt.appendFileSync(o,c,"utf8"),Ul++,(Ul>=OI||Zt.statSync(o).size>Gl)&&(Ul=0,BI(o))}catch{}}var dp,Gl,jl,OI,Ul,up,FI,_I,$I,Wl,ce,$t=g(()=>{"use strict";w();ee();dp=500,Gl=4*1024*1024,jl=16*1024,OI=50,Ul=0,up=()=>process.env.EPIQ_MCP==="true",FI=()=>{let e=process.cwd(),t=Mi(e);return a(t)?up()?ql.join(wn(),"epiq-mcp.log"):void 0:ql.join(t.value,ut,"log","epiq.log")},_I=(e,t)=>{let n=Zt.statSync(e).size;if(n<=t)return Zt.readFileSync(e,"utf8");let o=Zt.openSync(e,"r");try{let r=Buffer.alloc(t);Zt.readSync(o,r,0,t,n-t);let s=r.toString("utf8"),i=s.indexOf(`
38
- `);return i===-1?"":s.slice(i+1)}finally{Zt.closeSync(o)}};$I=e=>{if(e.length<=jl)return e;let t=e.length-jl;return`${e.slice(0,jl)} \u2026 [${t} more chars]`};Wl=()=>up()?process.env.EPIQ_MCP_LOG_LEVEL??"error":process.env.EPIQ_LOG_LEVEL??"debug",ce={info(...e){let t=Wl();(t==="info"||t==="debug")&&Hl("[Info]",e,!1)},debug(...e){Wl()==="debug"&&Hl("[Debug]",e,!0)},error(...e){let t=Wl();if(t==="error"||t==="info"||t==="debug"){let o=e.some(r=>r instanceof Error)?void 0:new Error().stack;Hl("[Error]",[...e,o].filter(Boolean),!1)}}};globalThis.logger=ce});import zl from"node:fs";import jI from"node:path";var bs,Vl,Kl,wo,mp,Yl,Yn,pp,fp,gp,or=g(()=>{"use strict";ee();bs=e=>e?.code==="ENOENT",Vl=3,Kl=e=>zl.readdirSync(e).filter(t=>t.endsWith(".jsonl")).sort(),wo=e=>{let t=bt(e);for(let n=1;;n++){if(!zl.existsSync(t))return"none";let o=[],r=!1;for(let s of Kl(t))try{let{size:i,mtimeMs:c}=zl.statSync(jI.join(t,s));o.push(`${s}:${i}:${c}`)}catch(i){if(!bs(i))throw i;if(n<Vl){r=!0;break}}if(!r)return o.join("|")}},mp=e=>new Map(e.split("|").filter(Boolean).map(t=>{let n=t.indexOf(":");return[t.slice(0,n),t.slice(n+1)]})),Yl=(e,t,n)=>{let o=mp(t),r=wo(e),s=mp(r);for(let[i,c]of s)if(i!==n&&o.get(i)!==c)return null;for(let i of o.keys())if(i!==n&&!s.has(i))return null;return r},Yn=null,pp=e=>Yn&&Yn.root===e?Yn.signature:null,fp=(e,t)=>{Yn={root:e,signature:t}},gp=(e,t)=>{if(!Yn||Yn.root!==e)return;let n=Yl(e,Yn.signature,t);Yn=n===null?null:{root:e,signature:n}}});import _e from"node:fs";import Co from"node:path";import{ulid as UI}from"ulid";var Pi,Xl,vp,yp,Di,HI,Jl,Ao,xs,bp,WI,qI,xp,GI,Ip,zI,Ep,VI,Li,hp,Oi,To=g(()=>{"use strict";w();ee();Pi="~pending",Xl=/~pending(-[0-9a-z]+)*$/i,vp=/-f(\d+)$/,yp=e=>{let t=e.indexOf(".");return t===-1?`${e}${Pi}`:e.slice(0,t)+Pi+e.slice(t)},Di=e=>{let t=e.indexOf(".");return t===-1?[e,""]:[e.slice(0,t),e.slice(t)]},HI=e=>{let[t,n]=Di(e);return Xl.test(t)?t.replace(Xl,"")+n:null},Jl=e=>e.replace(Xl,""),Ao=e=>e.endsWith(".jsonl")&&HI(e)!==null,xs=e=>Jl(Di(e)[0]),bp=e=>{let[t]=Di(e),n=vp.exec(t);return n&&Ao(e)?Number(n[1]):null},WI=e=>yp(e).replace(Pi,`${Pi}-${UI().toLowerCase()}`),qI=(e,t)=>{let[n,o]=Di(e);return`${n.replace(vp,"")}-f${t}${o}`},xp=(e,t)=>Co.join(bt(e),yp(t)),GI=(e,t)=>Math.max(0,_e.statSync(e).size-(bp(t)??0)),Ip=e=>{let t=bt(e);try{return _e.existsSync(t)?_e.readdirSync(t).filter(Ao).some(n=>GI(Co.join(t,n),n)>0):!1}catch{return!0}},zI=3,Ep=(e,t)=>{for(let n=1;;n++){let o=_e.openSync(e,"a"),r;try{_e.writeSync(o,t),r=_e.fstatSync(o).ino}finally{_e.closeSync(o)}let s;try{s=_e.statSync(e).ino}catch{s=null}if(s===r||n>=zI)return}},VI=e=>{let t;try{t=_e.openSync(e,"r")}catch{return!0}try{let{size:n}=_e.fstatSync(t);if(n===0)return!0;let o=Buffer.alloc(1);return _e.readSync(t,o,0,1,n-1),o[0]===10}finally{_e.closeSync(t)}},Li=10,hp=(e,t,n=!1)=>{let o=n?t.length:t.lastIndexOf(Li)+1;if(o===0)return{bytes:0,lines:0};let r=t.subarray(0,o);if(r.toString("utf8").trim().length===0)return{bytes:o,lines:0};_e.appendFileSync(e,Buffer.concat([Buffer.from(VI(e)?"":`
39
- `),r,Buffer.from(r[r.length-1]===Li?"":`
40
- `)]));let s=0;for(let i of r)i===Li&&s++;return r[r.length-1]!==Li&&s++,{bytes:o,lines:s}},Oi=(e,t)=>{let n=bt(e);if(!_e.existsSync(n))return d("No events directory",0);try{let o=xs(t),r=_e.readdirSync(n).filter(c=>Ao(c)&&xs(c)===o),s=Co.join(n,t),i=0;for(let c of r){let u=bp(c);if(u!==null){let h=Co.join(n,c),x=_e.readFileSync(h).subarray(u);i+=hp(s,x,!0).lines,_e.rmSync(h,{force:!0});continue}let p=/~pending-/i.test(c)?c:WI(t),m=Co.join(n,p);p!==c&&_e.renameSync(Co.join(n,c),m);let f=hp(s,_e.readFileSync(m));i+=f.lines,_e.renameSync(m,Co.join(n,qI(p,f.bytes)))}return d("Folded pending logs",i)}catch(o){return l(`Unable to fold pending event logs in ${n}: ${o instanceof Error?o.message:String(o)}`)}}});import _i from"node:fs";import Bi from"node:path";import{decodeTime as KI}from"ulid";import{z as Ql}from"zod";var $i,YI,Np,Fi,XI,JI,wp,QI,ZI,Cp,Rp,Zl,Sp,ec,Ap,Tp,tc=g(()=>{"use strict";$t();w();ee();ft();ds();or();To();$i="unknown",YI=Ql.object({userId:Ql.string().min(1).default($i),userName:Ql.string().min(1).default($i)}),Np=new Set(["id","v","userId","userName"]),Fi=e=>{let t=Object.entries(e).filter(([r])=>!Np.has(r));if(t.length!==1)return null;let n=t[0]?.[1];if(typeof n!="object"||n===null)return null;let o=n.id;return typeof o=="string"&&o.length>0?o:null},XI=/^[0-9a-hjkmnp-tv-z]{26}$/i,JI=e=>XI.test(e)?e.toUpperCase():e,wp=e=>{let t=Bi.basename(e,".jsonl"),n=t.indexOf("."),o=Jl(n===-1?t:t.slice(0,n)),r=n===-1?void 0:t.slice(n+1),s=YI.safeParse({userId:JI(o),userName:r});return s.success?d("Parsed event file actor",s.data):l(`Invalid event file name ${Bi.basename(e)}: ${s.error.issues.map(i=>i.path.join(".")||i.message).join(", ")}`)},QI=e=>{let t=Object.keys(e).filter(n=>n!=="id"&&n!=="v");return t.length!==1?l(`Invalid persisted event: expected exactly 1 action key, got ${t.length}`):!t[0]||!(t[0]in e)?l("Invalid persisted event: action key is missing or invalid"):d("Resolved persisted action",t[0])},ZI=(e,t)=>t in e,Cp=(e,t)=>{let n=wp(e);if(a(n))return l(n.message);let o;try{o=_i.readFileSync(e,"utf8")}catch(c){if(bs(c))return d("Event file missing",null);throw c}let r=[],s=Bi.basename(e),i=(c,u)=>{t?.push({eventId:null,reason:"corrupt-line",detail:`${s}:${c} (${u})`,targetNodeId:null})};for(let[c,u]of o.split(`
41
- `).entries()){let p=u.trim();if(!p)continue;let m;try{m=JSON.parse(p)}catch{i(c+1,"invalid JSON");continue}let f=_m(m);if(a(f)){i(c+1,f.message);continue}r.push({...f.value,userId:n.value.userId,userName:n.value.userName})}return d("Parsed persisted events file",r)},Rp=(e,t)=>e<t?-1:e>t?1:0,Zl=(e,t)=>{let n=Rp(e.id[0],t.id[0]);return n!==0?n:Rp(JSON.stringify(e),JSON.stringify(t))},Sp=(e,t)=>{let n=new Map,o=new Map;for(let m of e){let f=m.id[0],h=m.id[1]??null;n.set(f,m);let x=o.get(h)??[];x.push(m),o.set(h,x)}for(let m of o.values())m.sort(Zl);let r=[],s=new Set,i=m=>{let f=[m];for(;f.length>0;){let h=f.pop(),x=h.id[0];if(s.has(x))continue;r.push(h),s.add(x);let E=o.get(x)??[];for(let S=E.length-1;S>=0;S--)f.push(E[S])}},c=(o.get(null)??[]).filter(m=>{let f=Object.keys(m).filter(h=>!Np.has(h));return f.length===1&&f[0]===t});for(let m of c)i(m);let u=e.filter(m=>{let f=m.id[0],h=m.id[1]??null;return s.has(f)?!1:h===null||!n.has(h)}).sort(Zl);for(let m of u)i(m);let p=e.filter(m=>!s.has(m.id[0])).sort(Zl);for(let m of p)i(m);return r},ec=e=>os(e.map(t=>{try{return KI(t.id[0])}catch{return null}})),Ap=(e,t)=>{let n=new Set,o=[],r=[],s=ec(e);for(let i=0;i<e.length;i++){let c=e[i],u=c.id[0],p=c.id[1],m=s[i]??null;!(m!==null&&m<t)||p&&n.has(p)?(n.add(u),r.push(c)):o.push(c)}return{appliedEvents:o,unappliedEvents:r}},Tp=e=>{let t=new Set(e.actions),n=R=>t.has(R),o=R=>{let{userId:A,userName:L,..._}=R,j=QI(_);if(a(j))return l(j.message);let z=j.value,X=R.id?.[0];return X?ZI(_,z)?d("Decoded persisted event",{id:X,action:z,payload:_[z],userId:A}):l(`Persisted event is missing payload for action: ${z}`):l("Persisted event is missing id")},r=(R,A)=>{let L=[],_=new Map,j=new Map;for(let z of R){if(!Tl(z.v)){j.set(z.v,(j.get(z.v)??0)+1),A?.push({eventId:z.id[0],reason:"unsupported-schema-version",detail:`v${z.v}`,targetNodeId:Fi(z)});continue}let X=o(z);if(a(X)){A?.push({eventId:z.id[0],reason:"invalid-payload",detail:X.message,targetNodeId:Fi(z)});continue}let ue=X.value.action;if(!n(ue)){_.set(ue,(_.get(ue)??0)+1),A?.push({eventId:z.id[0],reason:"unknown-action",detail:ue,targetNodeId:Fi(z)});continue}let ze=e.readPayload(ue,X.value.payload);if(a(ze)){A?.push({eventId:z.id[0],reason:"invalid-payload",detail:ze.message,targetNodeId:Fi(z)});continue}L.push(X.value)}if(_.size>0){let z=[..._.entries()].map(([X,ue])=>`${X} (x${ue})`).join(", ");ce.info(`Skipped events with unknown actions, likely created by a newer epiq version: ${z}. Upgrade to apply them.`)}if(j.size>0){let z=[...j.entries()].map(([X,ue])=>`v${X} (x${ue})`).join(", ");ce.info(`Skipped events with unsupported schema versions, created by a newer epiq version: ${z}. Upgrade to apply them.`)}return d("Decoded reconstructed events",L)},s=null;function i(R,A){let L=bt(R),_=wo(R);if(!_i.existsSync(L))return d("No events found",[]);let j=[],z=[];for(let ue=1;;ue++){j=[],z=[];let ze=!1;for(let q of Kl(L)){let ae=Cp(Bi.join(L,q),z);if(a(ae))return l(ae.message);if(ae.value===null){if(ue<Vl){ze=!0;break}continue}j.push(...ae.value)}if(!ze)break}A?.push(...z);let X=Sp(j,e.genesis);return s={root:R,signature:_,edge:X.at(-1)?.id?.[0]??null},d("All events loaded",X)}function c(R){let A=[],L=i(R,A);if(a(L))return l(L.message);let _=r(L.value,A);return a(_)?l(_.message):d("Loaded merged events",{events:_.value,unreadable:A})}function u(R){let A=i(R);return a(A)?l(A.message):d("Loaded event actors",A.value.map(({userId:L,userName:_})=>({userId:L,userName:_})))}function p(R){let A=new Map,L=bt(R),_;try{if(!_i.existsSync(L))return A;_=_i.readdirSync(L)}catch{return A}let j=new Set;for(let X of _){if(!X.endsWith(".jsonl"))continue;let ue=wp(X);if(a(ue))continue;let{userId:ze,userName:q}=ue.value;if(!ze||!q||q===$i)continue;let ae=A.get(ze);ae!==void 0&&ae!==q&&j.add(ze),A.set(ze,q)}if(j.size===0)return A;let z=u(R);if(a(z))return A;for(let{userId:X,userName:ue}of z.value)j.has(X)&&(!ue||ue===$i||A.set(X,ue));return A}function m(R){let A=c(R);return a(A)?l(A.message):d("Loaded merged events",A.value.events)}function f(R,A){let L=i(R);if(a(L))return l(L.message);let{appliedEvents:_,unappliedEvents:j}=Ap(L.value,A),z=r(_);if(a(z))return l(z.message);let X=r(j);return a(X)?l(X.message):d("Loaded merged events before time",{appliedEvents:z.value,unappliedEvents:X.value})}function h(R=process.cwd()){let A=wo(R);if(s&&s.root===R&&s.signature===A)return d("Loaded edge reference, unchanged",s.edge);let L=i(R);return a(L)?l(L.message):d("Loaded edge reference",L.value.at(-1)?.id?.[0]??null)}function x(R,A,L){if(!s||s.root!==R)return;let _=Yl(R,s.signature,A);s=_===null?null:{root:R,signature:_,edge:L}}function E(){s=null}let S=R=>Sp(R,e.genesis);function C(R){let A=i(R);if(a(A))return l(A.message);let L=ec(A.value);return d("Loaded effective event times",new Map(A.value.map((_,j)=>[_.id[0],L[j]??null])))}return{fromPersistedEvent:o,decodeReconstructedEvents:r,loadMergedEventsWithUnreadable:c,loadEventActors:u,loadActorNames:p,loadMergedEvents:m,loadMergedEventsBefore:f,getEdgeRef:h,advanceEdgeRef:x,clearEdgeCache:E,getSortedEvents:S,loadEffectiveEventTimes:C}}});var ji,B,rr,Xn,Jn,eE,kp,Ui=g(()=>{"use strict";$t();w();ji=(e,t)=>l(`${t.action.split(".").join(" ")+" failed, "+e.toLowerCase()}. Evt id: ${t.id}`),B=(e,t)=>({...ji(e,t),convergence:!0}),rr=e=>a(e)&&e.convergence===!0,Xn=e=>{let t=e.filter(a);return{fatal:t.filter(n=>!rr(n)),skipped:t.filter(rr)}},Jn=e=>{e.length!==0&&ce.info(`Skipped ${e.length} event(s) that could not be applied to this state: ${e.map(t=>t.message).join("; ")}`)},eE=e=>e.userId?.length?null:ji("Invalid user ID format",e),kp=e=>{let t=null;function n(r,s=!1){let i=e.apply[r.action];if(!i)return l(`Unknown event action "${r.action}", likely created by a newer epiq version. Evt id: ${r.id}`);if(!e.replay.isInitialized()&&r.action!==e.genesis)return B(`${r.action} arrived before the state was initialized`,r);if(r.action===e.genesis&&t){if(t.genesisApplied)return B("the state is already initialized",r);t.genesisApplied=!0}let c;try{c=i(r)}catch(m){return B(`threw while materializing (${m instanceof Error?m.message:String(m)})`,r)}if(a(c))return c;let u=eE(r);if(u)return u;let p=e.replay.afterApply(r,{batched:t!==null,bypassLogging:s});return p||c}return{materialize:n,materializeAll:r=>{let s=e.replay.batch(()=>{let i=t===null;i&&(t={genesisApplied:!1});let c=!1;try{let u=r.map(p=>n(p));if(i){c=!0;let p=e.replay.flush();if(p)return r.map(()=>p)}return u}finally{i&&(t=null,c||e.replay.flush())}});return a(s)?r.map(()=>l(s.message)):s.value}}}});var Mp,Lp=g(()=>{"use strict";Mp=e=>e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/\.jsonl/g,"-jsonl").replace(/^-+|-+$/g,"")||"unknown"});import Pp from"node:fs";import nc from"node:path";import{decodeTime as tE,monotonicFactory as nE}from"ulid";var oE,rE,sE,Qn,Dp,Op,Fp,Hi=g(()=>{"use strict";$t();w();ee();Lp();ft();ds();Ft();or();To();oE=0xffffffffffff,rE=hi,sE=e=>{let t=Date.now(),n;try{n=tE(e)}catch{return t}return n>=oE?t:n>t+rE?(ce.error("[persist] edge id is too far in the future; seeding from the wall clock instead",{edgeRef:e,edgeTime:n,now:t}),t):Math.max(t,n+1)},Qn=({userId:e})=>`${Mp(e)}.jsonl`,Dp=(e,t)=>{let n;try{if(!Pp.existsSync(e))return[t];n=Pp.readdirSync(e)}catch{return[t]}let o=xs(t);return[...n.filter(s=>!s.endsWith(".jsonl")||s===t||Ao(s)?!1:xs(s)===o).sort(),t]},Op=(e,{userId:t})=>{let n=Qn({userId:t});if(!/^(?!.*\.jsonl.*\.jsonl).*\.jsonl$/.test(n))return l(`Invalid event log file name: ${n}`);let r=nc.join(bt(e),n);return d("Successfully resolved event log path",r)},Fp=e=>{let t=nE();function n(r,s){let i;if(s&&s.current!==void 0)i=s.current;else{let u=e.getEdgeRef(r);if(a(u))return l(u.message);i=u.value}let c=i?t(sE(i)):t();return d("Minted event id",[c,i])}function o({event:r,rootDir:s,edge:i,id:c}){try{let u=cp(s);if(a(u))return u;let p=Op(s,{userId:r.userId});if(a(p))return p;let m=xp(s,nc.basename(p.value)),f=c?d("Minted event id",c):n(s,i);if(a(f))return l(f.message);let[h,x]=f.value,E=kl(Pm(r),[h,x]);if(a(E))return l(E.message);Ep(m,`${JSON.stringify(E.value)}
42
- `),i&&(i.current=h);let S=nc.basename(m);return e.advanceEdgeRef(s,S,h),gp(s,S),d("Event persisted",{path:m,entry:E.value})}catch(u){let p=u instanceof Error?u.message:"Unknown persist error";return l(`Failed to persist event: ${p}`)}}return{mintEventId:n,persist:o}}});var _p,Bp=g(()=>{"use strict";w();_p=(e,t,n)=>{function o(s,i,c){let u=n.mintEventId(i,c);if(a(u))return l(u.message);let p={...s,id:u.value[0]},m=t.materialize(p);if(m.status!==Sn.Success)return m;let f=n.persist({event:p,rootDir:i,edge:c,id:u.value});return a(f)?f:m}function r(s,i){if(s.length===0||!s[0])return l("No events provided");let c=e.write.readOnlyReason();if(c)return l(c);let u=e.replay.batch(()=>{let p={},m=e.write.beforeWrite(s[0],x=>o(x,i,p));if(a(m))return l(m.message);let f=s.map(x=>o(x,i,p)),h=f.filter(a);return h.length>0?l("Materialize and persist failed: "+h.map(x=>x.message).join(", ")):d("Materialization succeeded",f.map(x=>x.value))});return a(u)?l(u.message):u.value??l("Materialize and persist produced nothing")}return{materializeAndPersist:o,materializeAndPersistAll:r}}});var $p,jp=g(()=>{"use strict";tc();Ui();Hi();Bp();$p=e=>{let t=kp(e),n=Tp(e),o=Fp(n),r=_p(e,t,o);return{...t,...n,...o,...r}}});import{z as te}from"zod";var K,en,Zn,Wi,oc,iE,Up,Hp=g(()=>{"use strict";w();K=te.string().min(1),en=te.string(),Zn=te.string(),Wi=te.looseObject({id:K}),oc=te.looseObject({id:K,name:en,parent:K,rank:Zn}),iE={"init.workspace":te.looseObject({id:K,name:en,rank:Zn}),"add.workspace":te.looseObject({id:K,name:en,rank:Zn}),"add.board":oc,"add.swimlane":oc,"add.issue":oc,"add.field":te.looseObject({id:K,name:en,parent:K,rank:Zn}),"edit.title":te.looseObject({id:K,name:en}),"delete.node":Wi,"lock.node":Wi,"move.node":te.looseObject({id:K,parent:K,rank:Zn}),"edit.description":te.looseObject({id:K,md:te.string()}),"close.issue":te.looseObject({id:K,parent:K,rank:Zn}),"reopen.issue":te.looseObject({id:K,parent:K,rank:Zn}),"create.tag":te.looseObject({id:K,name:en}),"tombstone.tag":Wi,"restore.tag":te.looseObject({id:K,name:en}),"create.contributor":te.looseObject({id:K,name:en}),"rename.contributor":te.looseObject({id:K,name:en}),"tombstone.contributor":Wi,"restore.contributor":te.looseObject({id:K,name:en}),"link.contributor.user":te.looseObject({contributor:K}),"link.contributor.email":te.looseObject({contributor:K,email:K}),"unlink.contributor.email":te.looseObject({contributor:K,email:K}),"add.issue.assignee":te.looseObject({id:K,assignee:K}),"remove.issue.assignee":te.looseObject({id:K,assignee:K}),"add.issue.tag":te.looseObject({id:K,tag:K}),"remove.issue.tag":te.looseObject({id:K,tag:K}),"add.issue.comment":te.looseObject({id:K,issue:K,md:te.string()}),"edit.issue.comment":te.looseObject({id:K,issue:K,md:te.string()}),"delete.issue.comment":te.looseObject({id:K,issue:K}),"add.issue.attachment":te.looseObject({id:K,issue:K,hash:te.string().min(1),ext:te.string().min(1),name:en,bytes:te.number()}),"delete.issue.attachment":te.looseObject({id:K,issue:K}),"rebalance.children":te.looseObject({parent:K,ranks:te.record(te.string(),Zn)})},Up=(e,t)=>{let o=iE[e].safeParse(t);return o.success?d("Payload is readable",void 0):l(`${e}: ${o.error.issues.map(r=>`${r.path.join(".")||"payload"} ${r.message}`).join(", ")}`)}});import{ulid as aE}from"ulid";var Wp,qp=g(()=>{"use strict";w();pe();Fe();Wp=(e,t)=>{if(e.action==="create.contributor"||e.action==="rename.contributor")return d("Contributor write already in flight",void 0);let{userId:n,userName:o}=le();if(!o||n!==e.userId)return d("Not this actor own write",void 0);let r=N.getContributor(e.userId),s={id:aE(),action:r?"rename.contributor":"create.contributor",payload:{id:e.userId,name:o},userId:e.userId};if(r&&(r.tombstoned||r.name===o))return d("Contributor name is current",void 0);let i=t(s);return a(i)?l(i.message):d("Contributor name recorded",void 0)}});var Ce,sr=g(()=>{"use strict";Ce={DESCRIPTION:"Description",ASSIGNEES:"Assignees",TAGS:"Tags",HISTORY:"History",DIFF:"Diff",COMMENTS:"Comments",ATTACHMENTS:"Attachments"}});var V,Is,mt=g(()=>{"use strict";V=e=>e.slice(-7).toUpperCase(),Is=(e,t)=>{let n=t.replace(/-/g,"").trim().toUpperCase();return n?V(e).includes(n):!0}});var Be,eo=g(()=>{"use strict";me();mt();Be={workspace:(e,t,n)=>({id:e,title:t,rank:n,isDeleted:!1,props:{},context:se.WORKSPACE,childRenderAxis:"vertical",parentNodeId:null,readonly:!0,log:[]}),board:(e,t,n,o,r=!1)=>({id:e,title:t,rank:o,isDeleted:!1,props:{ref:V(e)},context:se.BOARD,childRenderAxis:"horizontal",parentNodeId:n,readonly:r,log:[]}),swimlane:(e,t,n,o)=>({id:e,title:t,rank:o,isDeleted:!1,props:{},context:se.SWIMLANE,childRenderAxis:"vertical",childNavigationAcrossParents:!0,parentNodeId:n,readonly:!1,log:[]}),field:({id:e,name:t,parentNodeId:n,rank:o,props:r={},childRenderAxis:s="horizontal",isVirtual:i=!1})=>({id:e,title:t,rank:o,isDeleted:!1,props:r,context:se.FIELD,childRenderAxis:s,parentNodeId:n,readonly:!1,log:[],isVirtual:i}),fieldList:({id:e,name:t,parentNodeId:n,rank:o,childRenderAxis:r="horizontal",isVirtual:s=!1})=>({id:e,title:t,rank:o,isDeleted:!1,props:{},context:se.FIELD_LIST,childRenderAxis:r,parentNodeId:n,readonly:!1,log:[],isVirtual:s}),ticket:(e,t,n,o)=>({id:e,title:t,rank:o,isDeleted:!1,props:{ref:V(e)},context:se.TICKET,childRenderAxis:"vertical",parentNodeId:n,readonly:!1,log:[]}),text:({id:e,name:t,parentNodeId:n,rank:o,readonly:r=!0,isVirtual:s=!0,disabled:i=!1})=>({id:e,title:t,rank:o,isDeleted:!1,props:i?{disabled:!0}:{},context:se.TEXT,childRenderAxis:"vertical",parentNodeId:n,readonly:r,log:[],isVirtual:s}),comment:({id:e,name:t,parentNodeId:n,rank:o,props:r={},readonly:s=!0,isVirtual:i=!0})=>({id:e,title:t,rank:o,isDeleted:!1,props:r,context:se.COMMENT,childRenderAxis:"vertical",parentNodeId:n,readonly:s,log:[],isVirtual:i})}});var lE,Ae,qi,tn=g(()=>{"use strict";lE=["00KM6CZ900T7180RM46K0JAYNF","00JR3R8E00A1Z4X9FGP9DV0SM5"],[Ae,qi]=lE});var Es,Gp,zp=g(()=>{"use strict";me();w();sr();wt();pe();eo();O();Ui();tn();Es=(e,t,n)=>N.getNode(e)?B(`a node with id ${e} already exists`,n):t===e?B("a node cannot be its own parent",n):null,Gp={"init.workspace":e=>{let{id:t,name:n,rank:o}=e.payload,r=Be.workspace(t,n,o),s=Rs(r);if(a(s))return ji(s.message,e);let i=N.createNode(r);return a(i)?B(i.message??"Failed to initialize workspace",e):Nl(i.value)?d("Workspace initialized",{action:e.action,result:i.value}):l("Unexpected create node return value")},"add.workspace":e=>{let{id:t,name:n,rank:o}=e.payload,r=Es(t,void 0,e);if(r)return r;let s=N.createNode(Be.workspace(t,n,o));return a(s)?B(s.message??"Failed to add workspace",e):Nl(s.value)?d("Added workspace",{action:e.action,result:s.value}):l("Unexpected create node return value")},"add.board":e=>{let{id:t,name:n,parent:o,rank:r}=e.payload,s=Es(t,o,e);if(s)return s;let i=N.createNode(Be.board(t,n,o,r));return a(i)?B(i.message??"Unable to create board",e):xo(i.value)?d("Added board",{action:e.action,result:i.value}):l("Unexpected create node return value")},"add.swimlane":e=>{let{id:t,name:n,parent:o,rank:r}=e.payload,s=Es(t,o,e);if(s)return s;let i=N.createNode(Be.swimlane(t,n,o,r));return a(i)?B(i.message??"Unable to create swimlane",e):bo(i.value)?d("Added swimlane",{action:e.action,result:i.value}):l("Unexpected create node return value")},"add.issue":e=>{let{id:t,name:n,parent:o,rank:r}=e.payload,s=Es(t,o,e);if(s)return s;let i=N.createNode(Be.ticket(t,n,o,r));return a(i)?B(i.message??"Unable to create issue",e):U(i.value)?d("Added issue",{action:e.action,result:i.value}):l("Unexpected create node return value")},"add.field":e=>{let{id:t,name:n,parent:o,val:r,rank:s}=e.payload,i=Es(t,o,e);if(i)return i;let c=N.createNode(Be.field({id:t,name:n,parentNodeId:o,rank:s,props:{value:r},childRenderAxis:n.includes(Ce.DESCRIPTION)?"vertical":"horizontal"}));return a(c)?B(c.message??`Unable to create field: ${n}`,e):ot(c.value)?d("Added field",{action:e.action,result:c.value}):l("Unexpected create node return value")},"edit.title":e=>{let{id:t,name:n}=e.payload;if(!N.getNode(t))return B(`Unable to locate node with id ${t}`,e);let r=N.renameNode(t,n);return a(r)?B(r.message??"Unable to edit title",e):d("Edited title",{action:e.action,result:r.value})},"delete.node":e=>{let{id:t}=e.payload,n=N.tombstoneNode(t);return a(n)?B(n.message??"Unable to delete node",e):d("Deleted node",{action:e.action,result:n.value})},"create.tag":e=>{let{id:t,name:n}=e.payload,o=N.createTag({id:t,name:n});return a(o)?B(o.message??"Unable to create tag",e):d("Tag added",{action:e.action,result:o.value})},"tombstone.tag":e=>{let{id:t}=e.payload,n=N.tombstoneTag(t);return a(n)?B(n.message??"Unable to delete tag",e):d("Tag tombstoned",{action:e.action,result:n.value})},"restore.tag":e=>{let{id:t,name:n}=e.payload,o=N.restoreTag(t,n);return a(o)?B(o.message??"Unable to restore tag",e):d("Tag restored",{action:e.action,result:o.value})},"create.contributor":e=>{let{id:t,name:n}=e.payload,o=N.createContributor({id:t,name:n});return a(o)?B(o.message??"Unable to create contributor",e):d("Contributor created",{action:e.action,result:o.value})},"rename.contributor":e=>{let{id:t,name:n}=e.payload,o=N.renameContributor(t,n);return a(o)?B(o.message??"Unable to rename contributor",e):d("Contributor renamed",{action:e.action,result:o.value})},"tombstone.contributor":e=>{let{id:t}=e.payload,n=N.tombstoneContributor(t);return a(n)?B(n.message??"Unable to remove contributor",e):d("Contributor tombstoned",{action:e.action,result:n.value})},"restore.contributor":e=>{let{id:t,name:n}=e.payload,o=N.restoreContributor(t,n);return a(o)?B(o.message??"Unable to restore contributor",e):d("Contributor restored",{action:e.action,result:o.value})},"add.issue.tag":e=>{let{id:t,tag:n}=e.payload,o=N.tag(t,n);return a(o)?B(o.message??"Unable to tag issue",e):d("Issue tagged",{action:e.action,result:{tag:n}})},"remove.issue.tag":e=>{let{id:t,tag:n}=e.payload,o=N.untag(t,n);return a(o)?B(o.message??"Unable to untag issue",e):d("Issue untagged",{action:e.action,result:{tag:n}})},"add.issue.assignee":e=>{let{id:t,assignee:n}=e.payload,o=N.assign(t,n);return a(o)?B(o.message??"Unable to assign issue",e):d("Assigned successfully",{action:e.action,result:{assignee:n}})},"remove.issue.assignee":e=>{let{id:t,assignee:n}=e.payload,o=N.unassign(t,n);return a(o)?B(o.message??"Unable to unassign issue",e):d("Issue unassigned",{action:e.action,result:{assignee:n}})},"move.node":e=>{let{id:t,parent:n,rank:o}=e.payload,r=N.moveNodeToRank({id:t,parentId:n,rank:o});return a(r)?B(r.message??"Failed to move node",e):d("Moved node",{action:e.action,result:r.value})},"edit.description":e=>{let{id:t,md:n}=e.payload,o=N.editValue(t,n);return a(o)?B(o.message??"Unable to edit description",e):d("Set node value",{action:e.action,result:o.value})},"close.issue":e=>{let{id:t,parent:n,rank:o}=e.payload,r=N.getNode(t);if(!r)return B("Unable to locate issue",e);if(!U(r))return B("Can only close issues",e);let s=N.getNode(Ae);if(!s)return B("Unable to locate target swimlane",e);if(n!==s.id)return B("Close target must be closed swimlane",e);let i=N.moveNodeToRank({id:t,parentId:n,rank:o});return a(i)?B(i.message??"Unable to close issue",e):d("Issue closed",{action:e.action,result:{id:t}})},"reopen.issue":e=>{let{id:t,parent:n,rank:o}=e.payload,r=N.getNode(t);if(!r)return B("Unable to locate issue",e);if(!U(r))return B("Can only reopen issues",e);let s=N.getNode(Ae);if(!s)return B("Unable to locate closed swimlane",e);if(n===s.id)return B("Cannot reopen issue into closed swimlane",e);if(!N.getNode(n))return B("Reopen parent no longer exists",e);let c=N.moveNodeToRank({id:t,parentId:n,rank:o});return a(c)?B(c.message??"Unable to reopen issue",e):d("Issue reopened",{action:e.action,result:{id:t}})},"lock.node":e=>{let{id:t}=e.payload,n=N.lockNode(t);return a(n)?B(n.message??"Unable to lock node",e):d("Node locked",{action:e.action,result:n.value})},"rebalance.children":e=>{let{parent:t,ranks:n}=e.payload;for(let[o,r]of Object.entries(n)){let s=N.getNode(o);if(!s)return B(`Unable to locate node ${o}`,e);if(s.parentNodeId!==t)return B(`Node ${o} is not child of ${t}`,e);let i=N.updateNode({...s,rank:r});if(a(i))return B(i.message??"Unable to rebalance child",e)}return d("Rebalanced children",{action:e.action,result:{parent:t}})},"add.issue.comment":e=>{let{id:t,issue:n,author:o,md:r}=e.payload,s=N.createComment({id:t,issue:n,authorId:o,md:r,deleted:!1});return a(s)?B(s.message??"Unable to add comment",e):d("Comment added",{action:e.action,result:{id:t,issue:n,author:o,md:r}})},"edit.issue.comment":e=>{let{id:t,issue:n,md:o}=e.payload,r=N.getComment(t);if(!r)return B("Unable to locate comment",e);if(r.issue!==n)return B("Comment does not belong to issue",e);let s=N.editComment(t,o);return a(s)?B(s.message??"Unable to edit comment",e):d("Comment edited",{action:e.action,result:{id:t,issue:n,md:o}})},"delete.issue.comment":e=>{let{id:t,issue:n}=e.payload,o=N.getComment(t);if(!o)return B("Unable to locate comment",e);if(o.issue!==n)return B("Comment does not belong to issue",e);let r=N.deleteComment(t);return a(r)?B(r.message??"Unable to delete comment",e):d("Comment deleted",{action:e.action,result:{id:t,issue:n}})},"add.issue.attachment":e=>{let{id:t,issue:n,hash:o,ext:r,name:s,bytes:i}=e.payload,c=N.createAttachment({id:t,issue:n,hash:o,ext:r,name:s,bytes:i,deleted:!1});return a(c)?B(c.message??"Unable to add attachment",e):d("Attachment added",{action:e.action,result:{id:t,issue:n,hash:o}})},"delete.issue.attachment":e=>{let{id:t,issue:n}=e.payload,o=N.getAttachment(t);if(!o)return B("Unable to locate attachment",e);if(o.issue!==n)return B("Attachment does not belong to issue",e);let r=N.deleteAttachment(t);return a(r)?B(r.message??"Unable to delete attachment",e):d("Attachment deleted",{action:e.action,result:{id:t,issue:n}})},"link.contributor.email":e=>{let{contributor:t,email:n}=e.payload;if(!Gn(n))return B(`not an email address: ${n}`,e);let o=N.linkContributorEmail({email:n,contributor:t,authorId:e.userId});return a(o)?B(o.message??"Unable to link email",e):d("Email linked to contributor",{action:e.action,result:o.value})},"unlink.contributor.email":e=>{let{contributor:t,email:n}=e.payload,o=N.unlinkContributorEmail(n,t,e.userId);return a(o)?B(o.message??"Unable to unlink email",e):d("Email unlinked from contributor",{action:e.action,result:o.value})},"link.contributor.user":e=>{let{contributor:t}=e.payload,n=N.linkUserId({contributorId:t,userId:e.userId});return a(n)?B(n.message??"Unable to link contributor",e):d("Contributor linked to user",{action:e.action,result:{contributor:t,userId:e.userId}})}}});var Vp,Kp,cE,dE,rc,uE,Ln,mE,Yp,sc=g(()=>{"use strict";me();w();pe();O();ic();Vp=e=>{let t=N.getNode(e);if(!t||!U(t)||t.isDeleted)return null;let n=zi(t);return a(n)?n:null},Kp=e=>{if(!Vi())return null;for(let t of e){let n=Vp(t);if(n)return n;let o=v().nodes[t]?.parentNodeId;if(!o)continue;let r=Vp(o);if(r)return r}return null},cE=(e,t)=>{let n=N.getNode(e);n&&N.updateNode({...n,log:[...n.log??[],t]})},dE=e=>{let t=[e],n=v().nodes[e]?.parentNodeId;return n&&t.push(n),t},rc=e=>{switch(e.action){case"add.issue.comment":case"edit.issue.comment":case"delete.issue.comment":case"add.issue.attachment":case"delete.issue.attachment":return[e.payload.issue];case"delete.node":case"edit.description":return dE(e.payload.id);case"init.workspace":case"add.workspace":case"add.board":case"add.swimlane":case"add.issue":case"add.field":case"edit.title":case"lock.node":case"move.node":case"close.issue":case"reopen.issue":case"add.issue.tag":case"remove.issue.tag":case"add.issue.assignee":case"remove.issue.assignee":return[e.payload.id];case"rebalance.children":return Object.keys(e.payload.ranks);case"create.tag":case"tombstone.tag":case"restore.tag":case"create.contributor":case"rename.contributor":case"link.contributor.user":case"link.contributor.email":case"unlink.contributor.email":default:return[]}},uE=e=>{Pe(t=>({...t,eventLog:[...t.eventLog,e]}))},Ln=null,mE=e=>{for(let[t,n]of e.nodeLog){let o=N.getNode(t);o&&N.updateNode({...o,log:[...o.log??[],...n]})}return e.appLog.length>0&&Pe(t=>({...t,eventLog:[...t.eventLog,...e.appLog]})),Kp([...e.virtualNodeIds])},Yp={isInitialized:()=>jt(),batch:e=>Gi(e),afterApply(e,{batched:t,bypassLogging:n}){let o=[...new Set(rc(e))];if(t){Ln??={appLog:[],nodeLog:new Map,virtualNodeIds:new Set};for(let r of o){if(!n){let s=Ln.nodeLog.get(r);s?s.push(e):Ln.nodeLog.set(r,[e])}if(Vi()){Ln.virtualNodeIds.add(r);let s=v().nodes[r]?.parentNodeId;s&&Ln.virtualNodeIds.add(s)}}return n||Ln.appLog.push(e),null}return n||(o.forEach(r=>cE(r,e)),uE(e)),Kp(o)},flush(){if(!Ln)return null;let e=Ln;return Ln=null,mE(e)}}});var ge,Xp=g(()=>{"use strict";w();Fe();vo();ge=()=>{let{userName:e,userId:t}=le();return e?t?gi(t)?ts(e)?d("Successfully resolved actor ID",{userId:t,userName:e}):l("Invalid user name in config"):l("Invalid user ID in config"):l("User ID not configured"):l("User name not configured")}});var pE,fE,Ss,Pn,TL,kL,nn,Jp,ko,Mo,ac,ML,LL,PL,DL,lc,OL,Qp,FL,F,$=g(()=>{"use strict";ds();jp();Hp();O();qp();_t();zp();sc();Xp();ds();tc();Ui();Hi();pE={genesis:"init.workspace",actions:Cl,readPayload:Up,apply:Gp,replay:Yp,write:{readOnlyReason:()=>{let e=v();return e.readOnly?e.readOnlyReason??"Cannot change the board while time travelling":null},beforeWrite:Wp}},fE=$p(pE),{materialize:Ss,materializeAll:Pn,fromPersistedEvent:TL,decodeReconstructedEvents:kL,loadMergedEventsWithUnreadable:nn,loadEventActors:Jp,loadActorNames:ko,loadMergedEvents:Mo,loadMergedEventsBefore:ac,getEdgeRef:ML,advanceEdgeRef:LL,clearEdgeCache:PL,getSortedEvents:DL,loadEffectiveEventTimes:lc,mintEventId:OL,persist:Qp,materializeAndPersist:FL,materializeAndPersistAll:F}=fE});var Lo,cc,Zp=g(()=>{"use strict";mt();Lo=e=>e.trim().toLocaleLowerCase(),cc=(e,t)=>Lo(e).includes(Lo(t))});var gE,hE,ef,tf,vE,yE,nf,of=g(()=>{"use strict";O();mt();Zp();gE=e=>{let{tags:t}=v();return(e.props.tags??[]).map(n=>t[n]).filter(n=>n!==void 0&&!n.tombstoned).map(n=>n.name)},hE=e=>{let{contributors:t}=v();return(e.props.assignees??[]).map(n=>{let o=t[n];return o?o.name:void 0}).filter(n=>!!n)},ef=null,tf=new Map,vE=()=>{let e=v().eventLog??[];if(e===ef)return tf;let t=new Map;for(let n of e){if(!n.userId)continue;let o=n.payload;for(let r of[o.id,o.issue]){if(typeof r!="string")continue;let s=t.get(r)??new Set;s.add(n.userId),t.set(r,s)}}return ef=e,tf=t,t},yE=e=>{let{contributors:t}=v(),n=vE().get(e.id);return n?[...n].map(o=>t[o]?.name).filter(o=>!!o):[]},nf=(e,t)=>{let n=Lo(t.value);if(!n)return!0;switch(t.target){case"title":return cc(e.title??"",n);case"description":return cc(e.props.description??"",n);case"tag":return gE(e).map(Lo).some(r=>r.includes(n));case"assignee":return hE(e).map(Lo).some(r=>r.includes(n));case"actor":return yE(e).map(Lo).some(r=>r.includes(n));case"ref":return Is(e.id,t.value);default:return!0}}});var dc,bE,rf,sf,af,uc=g(()=>{"use strict";me();of();dc=(e,t)=>e.rank<t.rank?-1:e.rank>t.rank?1:0,bE=(e,t)=>!!e&&!e.isDeleted&&e.parentNodeId===t,rf=(e,t)=>Object.values(e).filter(n=>bE(n,t)).sort(dc),sf=(e,t)=>{let n={};for(let o of Object.values(e)){if(U(o)&&t.length>0&&!t.every(s=>nf(o,s))||!o.parentNodeId||o.isDeleted)continue;let r=n[o.parentNodeId];r?r.push(o):n[o.parentNodeId]=[o]}for(let o of Object.keys(n))n[o].sort(dc);return n},af=(e,t)=>{let n={};for(let o of Object.values(e)){if(!o.parentNodeId||o.isDeleted||!t.has(o.parentNodeId))continue;let r=n[o.parentNodeId];r?r.push(o):n[o.parentNodeId]=[o]}for(let o of Object.keys(n))n[o].sort(dc);return n}});var lf,Ki,ke,cf,df,pn,Dn,Bt=g(()=>{"use strict";Dm();$();w();O();uc();Zo();lf=e=>Ki(ke(e),{at:"end"}),Ki=(e,t={at:"end"})=>{let n=r=>a(r)?d("Rank space exhausted",{rank:"",needsRebalance:!0}):d("Resolved rank",{rank:r.value,needsRebalance:!1});if(e.length===0)return n(dt(void 0,void 0));let o=()=>n(dt(e[e.length-1]?.rank,void 0));switch(t.at){case"start":{let r=e[0];return r?n(dt(void 0,r.rank)):l("Unable to resolve first sibling")}case"end":{let r=e[e.length-1];return r?n(dt(r.rank,void 0)):l("Unable to resolve last sibling")}case"before":{let r=cf(e,t.sibling),s=r<0?void 0:e[r];if(!s)return o();let i=r>0?e[r-1]:void 0;return n(dt(i?.rank,s.rank))}case"after":{let r=cf(e,t.sibling),s=r<0?void 0:e[r];if(!s)return o();let i=r<e.length-1?e[r+1]:void 0;return n(dt(s.rank,i?.rank))}}},ke=e=>{let t=v();if(!uf()&&t.filters.length===0){let n=t.renderedChildrenIndex[e];if(n)return n}return rf(t.nodes,e)},cf=(e,t)=>e.findIndex(n=>n.id===t),df=(e,t,n={at:"end"})=>Ki(ke(t).filter(o=>o.id!==e),n),pn=(e,t,n,o,r)=>{let s=df(t,e,n);if(a(s))return s;if(!s.value.needsRebalance)return d("Resolved rank",s.value.rank);let i=Al(e,o);if(a(i))return i;let c=F([i.value],r);if(a(c))return c;let u=df(t,e,n);return a(u)?u:u.value.needsRebalance?l("Rank rebalance failed to create space"):d("Resolved rank after rebalance",u.value.rank)},Dn=(e,t,n)=>{let o=lf(e);if(a(o))return o;if(!o.value.needsRebalance)return d("Resolved rank",o.value.rank);let r=Al(e,t);if(a(r))return r;let s=F([r.value],n);if(a(s))return s;let i=lf(e);return a(i)?i:i.value.needsRebalance?l("Rank rebalance failed to create space"):d("Resolved rank after rebalance",i.value.rank)}});var Ns,H,mf,pf,ff,xt=g(()=>{"use strict";O();Ns=5,H={exit(){process.exit(0)},enterChildNode(){let e=v(),t=e.contextNode,n=Math.max(0,e.selectedIndex),o=ve(t.id),r=o[n];r&&(t.context==="FIELD"&&o.length===0||r.context==="COMMENT"||r.context==="TEXT"||H.navigate({contextNode:r,selectedIndex:ve(r.id).length?0:-1}))},enterParentNode(){let{contextNode:e,nodes:t}=v();if(!e.parentNodeId){logger.info("Missing parent node id");return}let n=t[e.parentNodeId];if(!n){logger.error("Parent not found");return}let o=ve(n.id),r=o.findIndex(({id:i})=>i===e.id),s=o.length===0?-1:r>=0?r:0;H.navigate({contextNode:n,selectedIndex:s})},navigateToNextItem:()=>mf(1),navigateToPreviousItem:()=>mf(-1),jumpToNextItem:()=>pf(Ns),jumpToPreviousItem:()=>pf(-Ns),navigateToNextContainer:()=>ff(1),navigateToPreviousContainer:()=>ff(-1),navigate:({contextNode:e,selectedIndex:t})=>{T({contextNodeId:e.id,selectedIndex:t})}},mf=e=>{let{selectedIndex:t,contextNode:n}=v(),o=ve(n.id).length;if(o===0)return;let s=(Math.max(0,t)+e+o)%o;H.navigate({selectedIndex:s,contextNode:n})},pf=e=>{let{selectedIndex:t,contextNode:n}=v(),o=ve(n.id).length;if(o===0)return;let r=Math.max(0,t),s=Math.min(Math.max(r+e,0),o-1);H.navigate({selectedIndex:s,contextNode:n})},ff=e=>{let{contextNode:t,nodes:n,selectedIndex:o}=v();if(!t.childNavigationAcrossParents)return;if(!t.parentNodeId){logger.error("Missing parent node id");return}let r=n[t.parentNodeId];if(!r)return;let s=ve(r.id),i=s.findIndex(h=>h.id===t.id);if(i<0)return;let c=s.at(i+e)??s.at(0);if(!c)return;let u=ve(c.id),p=Math.max(0,u.length-1),m=Math.min(Math.max(0,o),p),f=u.length?m:-1;H.navigate({contextNode:c,selectedIndex:f})}});var hf,vf,xE,Yi,yf,gf,IE,bf,xf=g(()=>{"use strict";me();w();Bt();O();xt();hf=(e,t)=>t<=0?-1:Math.max(0,Math.min(e,t-1)),vf=()=>{let{contextNode:e,selectedIndex:t,selectedNode:n}=v();return{contextNodeId:e.id,selectedNodeId:n?.id??null,parentNodeId:e.id,selectedIndex:t}},xE=e=>{let t=v().nodes[e];return!!t&&!t.isDeleted&&ot(t)&&t.childRenderAxis==="vertical"},Yi=(e,t)=>{let{nodes:n}=v(),o=n[e];if(!o||o.isDeleted)return!1;let r=ke(o.id);return H.navigate({contextNode:o,selectedIndex:hf(t,r.length)}),!0},yf=e=>{let{nodes:t}=v(),n=t[e];if(!n||n.isDeleted)return!1;let o=n.parentNodeId;if(!o)return Yi(n.id,0);let r=t[o];if(!r||r.isDeleted)return!1;let i=ke(r.id).findIndex(c=>c.id===n.id);return i>=0?(H.navigate({contextNode:r,selectedIndex:i}),!0):yf(r.id)},gf=e=>{let{nodes:t}=v(),n=e,o=new Set;for(;n&&!o.has(n);){if(o.add(n),yf(n))return!0;n=t[n]?.parentNodeId}return!1},IE=e=>{if(!e)return!1;let t=v().nodes[e];return!!t&&!t.isDeleted},bf=e=>{let{nodes:t,rootNodeId:n}=v();if(xE(e.contextNodeId)&&Yi(e.contextNodeId,e.selectedIndex))return d("Restored navigation inside text container",null);if(IE(e.selectedNodeId)&&e.selectedNodeId&&gf(e.selectedNodeId))return d("Restored navigation to selected node or ancestor",null);if(Yi(e.contextNodeId,e.selectedIndex))return d("Restored navigation to previous container",null);if(e.parentNodeId&&Yi(e.parentNodeId,e.selectedIndex))return d("Restored navigation to previous parent",null);if(gf(e.contextNodeId))return d("Restored navigation to previous container or ancestor",null);let o=t[n];if(!o||o.isDeleted)return l("Unable to restore navigation");let r=ke(o.id);return H.navigate({contextNode:o,selectedIndex:hf(e.selectedIndex,r.length)}),d("Restored navigation to root",null)}});import{monotonicFactory as EE,ulid as fn}from"ulid";function RE(){let e=Me();if(a(e))return l("Unable to boot. State not initialized");let t=e.value,n=Object.values(t.nodes).find(s=>s.context==="WORKSPACE");if(!n)return l("No workspace found in event log");let[o]=ve(n.id),[r]=o?ve(o.id):[];if(r){let s=t.renderedChildrenIndex?.[r.id]??[];return d("Resolved boot nav target",{contextNode:r,selectedIndex:s.length>0?0:-1})}else return o?d("Resolved boot nav target",{contextNode:o,selectedIndex:0}):d("Resolved boot nav target",{contextNode:n,selectedIndex:0})}function SE(){let e=RE();return a(e)?e:H.navigate(e.value)}function If({userId:e,userName:t}){let n=ws(),o=ws(),r=ws(),s=ws(),i=ws(),c=dt(void 0,void 0);if(a(c))return c;let u=dt(void 0,void 0);if(a(u))return u;let p=dt(u.value,void 0);if(a(p))return p;let m=dt(void 0,void 0);if(a(m))return m;let f=dt(m.value,void 0);if(a(f))return f;let h=dt(f.value,void 0);if(a(h))return h;let x=dt(void 0,void 0);return a(x)?x:d("Created default events",[{id:fn(),userId:e,action:"init.workspace",payload:{id:n,name:"Workspace",rank:c.value}},{id:fn(),userId:e,action:"create.contributor",payload:{id:e,name:t}},{id:fn(),userId:e,action:"add.board",payload:{id:o,name:"Default",parent:n,rank:u.value}},{id:fn(),userId:e,action:"add.swimlane",payload:{id:r,name:"Todo",parent:o,rank:m.value}},{id:fn(),userId:e,action:"add.swimlane",payload:{id:s,name:"In progress",parent:o,rank:f.value}},{id:fn(),userId:e,action:"add.swimlane",payload:{id:i,name:"Done",parent:o,rank:h.value}},{id:fn(),userId:e,action:"add.board",payload:{id:qi,name:"Closed",parent:n,rank:p.value}},{id:fn(),userId:e,action:"add.swimlane",payload:{id:Ae,name:"Closed",parent:qi,rank:x.value}},{id:fn(),userId:e,action:"lock.node",payload:{id:qi}},{id:fn(),userId:e,action:"lock.node",payload:{id:Ae}}])}function gn(e,t=[]){if(NE())return d("Skipped boot while checked out at a historical point",null);if(!e.length){let s=Be.workspace("temporary-uninitialized-workspace","Workspace","a0"),i=Rs(s);return a(i)?i:(T({hasProjectDefinition:!1,mode:b.DEFAULT}),d("Booted uninitialized workspace placeholder",null))}if(!e.some(s=>s.action==="init.workspace"))return l("Initialized Epiq project has no workspace init event");let n=Pn(e),{fatal:o,skipped:r}=Xn(n);return o.length>0?l(`Materializing failed:
43
- ${o.map(s=>s.message).join(`
44
- `)}`):(Jn(r),SE(),T({hasProjectDefinition:!0}),wE(t),d("State booted successfully",null))}var ws,NE,wE,Po=g(()=>{"use strict";$t();xt();Oe();w();eo();O();Zo();$();tn();ws=EE();NE=()=>{let e=Me();if(a(e))return!1;let{timeMode:t}=e.value;return t==="peek"||t==="replay"},wE=e=>{if(e.length===0)return;let t=e.filter(o=>o.reason==="corrupt-line"||o.reason==="invalid-payload"),n=e.filter(o=>o.reason==="unsupported-schema-version"||o.reason==="unknown-action");if(n.length>0){let o=[...new Set(n.map(r=>r.detail))].join(", ");ce.info(`This build cannot read ${n.length} event(s) in the log (${o}). They are skipped, so anything they changed may be out of date until you upgrade.`)}if(t.length>0){let o=[...new Set(t.map(r=>r.detail))].join(", ");ce.info(`Skipped ${t.length} corrupt line(s) in the event log (${o}). The rest of the board loaded normally; those events are unrecoverable.`)}}});import{WebSocket as CE}from"ws";var AE,Ef,Rf=g(()=>{"use strict";AE=new Set,Ef=e=>{let t=JSON.stringify(e);for(let n of AE)n.readyState===CE.OPEN&&n.send(t)}});var Xi,ir,Do,mc,Ji,$e,Cs=g(()=>{"use strict";Rf();w();O();Xi=e=>{jt()&&(T({syncStatus:e}),Ef({type:"sync-status",payload:e}))},ir=(e="Syncing...")=>{Xi({status:"syncing",msg:e})},Do=(e="Synced")=>{Xi({status:"synced",msg:e})},mc=e=>{Xi({status:"failed",msg:e})},Ji=e=>{Xi({status:"offline",msg:e})},$e=e=>(mc(e),l(e))});var ar,Sf,ye,Qi=g(()=>{"use strict";w();ar=(e,t)=>(logger.error(`[boot:${e}] ${t}`),l(`[boot:${e}] ${t}`)),Sf=e=>{if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},ye=(e,t)=>(a(t)&&logger.info(`[${e}]:failed`,t.message),t)});import Zi from"node:fs";import Nf from"node:path";var st,wf,TE,pc,kE,Cf,fc=g(()=>{"use strict";Cn();Ke();w();ee();Jt();st=".epiq/project.json",wf=e=>Nf.join(e,st),TE=e=>{if(!Zi.existsSync(wf(e)))return d("State branch carries no identity yet",null);let t=At(e);return a(t)?l(`On the state branch: ${t.message}`):d("Read the state branch identity",t.value)},pc=(e,t)=>{try{let n=wf(e);return Zi.mkdirSync(Nf.dirname(n),{recursive:!0}),Zi.writeFileSync(n,JSON.stringify(t,null,2)+`
45
- `,"utf8"),d("Wrote the state branch identity",void 0)}catch(n){return l(n instanceof Error?`Failed to write the state branch identity: ${n.message}`:"Failed to write the state branch identity")}},kE=({checkout:e,branch:t,stateBranch:n})=>[`This checkout's ${st} names project ${e.projectId}`,`(created ${e.createdAt}), but the state branch ${n}`,`belongs to project ${t.projectId} (created ${t.createdAt}).`,"","The branch holds the board, so its id is the one that counts. Point the","checkout at it and commit the change:","",` git show ${n}:${st} > ${st}`,"","A second id is minted when init runs in a checkout that has no","project file while the state branch already exists; nothing on the","board is lost by it, but every checkout has to agree on one."].join(`
46
- `),Cf=({repoRoot:e,stateBranchRoot:t,stateBranch:n})=>{if(!Zi.existsSync(er(e)))return d("No project file to compare","no-checkout-file");let o=At(e);if(a(o))return l(o.message);let r=TE(t);if(a(r))return l(r.message);if(r.value===null){let s=pc(t,o.value);return a(s)?l(s.message):d("Stamped the state branch with this project","stamped")}return r.value.projectId!==o.value.projectId?l(kE({checkout:o.value,branch:r.value,stateBranch:n})):d("The checkout and the state branch agree","matched")}});import hn from"node:fs";import As from"node:path";var lr,Af,Tf,kf,ME,Mf,LE,PE,Lf,gc=g(()=>{"use strict";Ke();w();To();or();ee();lr=e=>e.split(`
47
- `).filter(t=>t.trim().length>0),Af=e=>{let t=As.join(e,ut,Mn);try{if(!hn.existsSync(t))return d("No events directory",[]);let n=hn.readdirSync(t).filter(o=>o.endsWith(".jsonl")).filter(o=>lr(hn.readFileSync(As.join(t,o),"utf8")).length>0);return d("Looked for stranded event logs",n)}catch(n){return l(`Unable to check ${t} for event logs before deleting it: ${n instanceof Error?n.message:String(n)}`)}},Tf=e=>As.join(e,ut,Mn),kf=e=>{let t=Tf(e),n=new Map;try{if(!hn.existsSync(t))return n;for(let o of hn.readdirSync(t))if(o.endsWith(".jsonl")&&!Ao(o))try{n.set(o,lr(hn.readFileSync(As.join(t,o),"utf8")))}catch(r){if(!bs(r))throw r}}catch{return n}return n},ME=e=>{try{let t=JSON.parse(e);return typeof t=="object"&&t!==null}catch{return!1}},Mf=(e,t)=>{if(t.size===0)return[];let n=Tf(e),o=[];for(let[r,s]of t){if(s.length===0)continue;let i=As.join(n,r);try{let c=hn.existsSync(i)?hn.readFileSync(i,"utf8"):null,u=new Set(c===null?[]:lr(c)),p=s.filter(f=>!u.has(f)).filter(ME);if(p.length===0)continue;hn.mkdirSync(n,{recursive:!0});let m=c!==null&&c.length>0&&!c.endsWith(`
48
- `);hn.appendFileSync(i,`${m?`
24
+ `),r.stdin.end()}),so=async({cwd:e,message:t,pathspec:n})=>{let r=await Ne.commit({cwd:e,message:t,pathspec:n});if(a(r))return l(`Failed to create commit
25
+ ${r.message}`);let o=await W({args:["rev-parse","HEAD"],cwd:e});return a(o)?l(`Commit created, but failed to read HEAD SHA
26
+ ${o.message}`):d("Created commit and resolved SHA",o.value.stdout.trim())},_i=async e=>{let t=await W({cwd:e,args:["rev-parse","--git-dir"]});if(a(t))return l(t.message);let n=t.value.stdout.trim();return d("Resolved git dir",pn.isAbsolute(n)?n:pn.resolve(e,n))},Vl=async e=>{let t=await _i(e);if(a(t))return l(t.message);let n=t.value,r={MERGE_HEAD:"merge in progress"};for(let[s,i]of Object.entries(r))if(en.existsSync(pn.join(n,s)))return d("Checked for in-progress Git operation",i);let o={"rebase-merge":"rebase in progress","rebase-apply":"rebase in progress"};for(let[s,i]of Object.entries(o))if(en.existsSync(pn.join(n,s)))return d("Checked for in-progress Git operation",i);return d("Checked for in-progress Git operation",null)},Qm=async e=>{let t=await Vl(e);return a(t)?l(t.message):d("Checked for in-progress Git operation",t.value!==null)},Mn=async({repoRoot:e})=>{let n=(await Le({args:["remote","get-url",At],cwd:e})).exitCode===0;return d(`Checked remote ${n}`,n)},ps=async({repoRoot:e,branch:t})=>{let n=await Le({args:["ls-remote","--heads",At,t],cwd:e});return n.exitCode!==0?l(n.stderr.trim()||`Unable to inspect remote branch ${At}/${t}`):d("Checked remote branch",n.stdout.trim().length>0)},Fi=async({repoRoot:e,branch:t})=>{let n=await Le({args:["show-ref","--verify","--quiet",`refs/heads/${t}`],cwd:e});return n.exitCode===0?d("Local branch exists",!0):n.exitCode===1?d("Local branch missing",!1):l(n.stderr.trim()||`Unable to inspect branch ${t}`)},oo=e=>{try{return en.realpathSync.native(e)}catch{return pn.resolve(e)}},Zm=async({repoRoot:e,worktreeRoot:t})=>{let n=await W({args:["worktree","list","--porcelain"],cwd:e});if(a(n))return l(n.message);let r=oo(t),o=n.value.stdout.split(`
27
+ `).filter(s=>s.startsWith("worktree ")).map(s=>s.slice(9)).map(oo).includes(r);return d("Checked worktree registration",o)},Kl=async e=>{let t=await Le({args:["rev-parse","--abbrev-ref","--symbolic-full-name","@{u}"],cwd:e});return d("Checked upstream",t.exitCode===0&&t.stdout.trim().length>0)},Bi=async e=>{let t=await W({args:["rev-parse","--abbrev-ref","HEAD"],cwd:e});return a(t)?l(t.message):d("Resolved current branch",t.value.stdout.trim())},ep=async e=>{let t=await W({args:["rev-parse","--short","HEAD"],cwd:e});return a(t)?l(t.message):d("Resolved short HEAD sha",t.value.stdout.trim())},tp=e=>e.includes("fetch first")||e.includes("non-fast-forward"),np=async e=>{let t=await Le({cwd:e,args:["rev-parse","--absolute-git-dir"]});if(t.exitCode!==0)return!1;let n=t.stdout.trim();return n?en.existsSync(pn.join(n,"rebase-merge"))||en.existsSync(pn.join(n,"rebase-apply")):!1},$I=3,jI=120,UI=e=>new Promise(t=>setTimeout(t,e)),HI=async(e,t)=>{let n=await Ne.rebaseOnto({cwd:e,ref:t});for(let r=1;r<$I;r+=1){if(!a(n)||await np(e))return n;await UI(jI),n=await Ne.rebaseOnto({cwd:e,ref:t})}return n},rp=async(e,{preserve:t=[]}={})=>{let n=await _i(e);if(a(n))return l(n.message);let r=n.value,o=[];for(let s of en.readdirSync(r))if(s.endsWith(".lock")&&!t.includes(s))try{en.rmSync(pn.join(r,s),{force:!0}),o.push(s)}catch{}return d("Cleared stale git lock files",o)},Yl=async e=>{if(!await np(e))return d("No rebase to abort",!1);let t=await Le({cwd:e,args:["rebase","--abort"]});return t.exitCode!==0?l(`Failed to abort the rebase in progress at ${e}
28
+ ${t.stderr.trim()}`):d("Aborted stale rebase",!0)},Vm=async e=>{let t=await Le({args:["rev-parse","HEAD"],cwd:e});return t.exitCode===0?t.stdout.trim():null},fs=e=>/could not resolve host/i.test(e)||/connection refused|connection timed out|operation timed out/i.test(e)||/network is unreachable|no route to host/i.test(e)||/failed to connect to/i.test(e),WI=e=>e.includes("couldn't find remote ref")||e.includes("Could not find remote branch"),gs=async({cwd:e,branch:t})=>{let n=await Yl(e);if(a(n))return l(n.message);let r=await Vm(e),o=await Ne.fetch({cwd:e,remote:At,branch:t});if(a(o))return WI(o.message)?d("Remote branch missing, skipped pull",!1):l(`Failed to fetch ${t}
29
+ ${o.message}`);let s=await HI(e,`${At}/${t}`);if(a(s))return l(`Failed during rebase
30
+ ${s.message}`);let i=await Vm(e),c=r!==null&&i!==null&&r!==i;return d(c?"Pulled with rebase":"Already up to date",c)},op=async e=>{let t=await Le({args:["rev-list","--count","@{u}..HEAD"],cwd:e});return t.exitCode!==0?d("No upstream to compare against",!1):d("Compared against upstream",Number(t.stdout.trim())>0)},sp=async e=>{let t=await Le({args:["status","--porcelain","--untracked-files=all"],cwd:e});return t.exitCode!==0?l(t.stderr.trim()||"Unable to inspect the worktree for changes"):d("Inspected worktree for changes",t.stdout.trim().length>0)},ip=async(e,t)=>{let n=await Le({args:["diff","--cached","--quiet",...t?.length?["--",...t]:[]],cwd:e});return n.exitCode===0?d("No staged changes",!1):n.exitCode===1?d("Has staged changes",!0):l(n.stderr.trim()||"Unable to inspect staged changes")},ap=async e=>{let t=await Bi(e);return a(t)?l(t.message):d("Checked detached HEAD state",t.value==="HEAD")}});import Yn from"node:fs";import yt from"node:path";var dp,up,mp,pp,Nr,Ie,qI,lp,hs,vs,fp,GI,zI,Xl,Jl,cp,gp,hp,kt,uk,rt=g(()=>{"use strict";Zt();N();Pi();ee();qm();_t();Ke();dp="4b825dc642cb6eb9a060e54bf8d69288fbee4904",up=e=>yt.join(ct,Ln,e),mp=()=>yt.join(ct,Ql),pp=kn,Nr=()=>yt.join(pp(),"worktrees"),Ie=({repoRoot:e})=>{let t=fn(e);return a(t)?l(t.message):d("Resolved state branch root",yt.join(Nr(),t.value))},qI=e=>yt.join(e,ct),lp=e=>yt.join(qI(e),Ln),hs=e=>{try{return Yn.mkdirSync(e,{recursive:!0}),d("Ensured directory",void 0)}catch(t){return l(t instanceof Error?t.message:String(t))}},vs=()=>{let e=pp(),t=Nr(),n=!Yn.existsSync(e)||!Yn.existsSync(t),r=hs(e);if(a(r))return l(`Ensure epiq home failed.
31
+ `+r.message);let o=hs(t);return a(o)?l(`Ensure worktrees dir failed.
32
+ `+o.message):d("Ensured epiq storage",n)},fp=e=>{Yn.existsSync(e)&&(ce.debug("[sync] remove path",e),Yn.rmSync(e,{recursive:!0,force:!0}))},GI=`*.jsonl merge=union
33
+ `,zI=`*~pending*.jsonl
34
+ `,Xl=()=>yt.join(ct,Ln,".gitattributes"),Jl=()=>yt.join(ct,Ln,".gitignore"),cp=(e,t)=>{try{Yn.readFileSync(e,"utf8")!==t&&Yn.writeFileSync(e,t)}catch{Yn.writeFileSync(e,t)}},gp=(e,t)=>{for(let n of[lp(e),lp(t)]){let r=hs(n);if(a(r))return l(r.message)}return cp(yt.join(t,Xl()),GI),cp(yt.join(t,Jl()),zI),d("Ensured state branch",void 0)},hp=async e=>{let t=await W({args:["ls-tree","--name-only","HEAD"],cwd:e});if(a(t))return l(`ensure state branch is storage only failed
35
+ `+t.message);let r=t.value.stdout.trim().split(`
36
+ `).filter(Boolean).filter(i=>i!==ct);if(r.length===0)return d("State branch is storage-only",!1);let o=await W({args:["rm","-r","--ignore-unmatch","--",...r],cwd:e});if(a(o))return l(`Failed to clean storage branch
37
+ ${o.message}`);let s=await so({cwd:e,message:"[epiq:repair-storage-branch]",pathspec:r});return a(s)?l(s.message):d("Cleaned storage branch",!0)},kt=Bl(async(e=process.cwd())=>{let t=await W({args:["rev-parse","--show-toplevel"],cwd:e});return a(t)?l("Not inside a Git repository"):d("Resolved repo root",t.value.stdout.trim())},e=>yt.resolve(e)),uk=Bl(async e=>{let t=await W({args:["rev-parse","--git-dir"],cwd:e});if(a(t))return l(t.message);let n=t.value.stdout.trim(),r=yt.isAbsolute(n)?n:yt.join(e,n);return d("Resolved git dir",r)},e=>yt.resolve(e))});import ys from"node:fs";import gn from"node:path";var yk,ct,Ln,Ql,VI,Cr,io,bt,$i,vp,KI,bs,Di,YI,Ce,yp,Ee,ee=g(()=>{"use strict";N();rt();Pi();yk=process.env.IS_LOCAL==="true",ct=".epiq",Ln="events",Ql="media",VI="project.json",Cr=e=>gn.join(e,ct),io=e=>gn.join(Cr(e),VI),bt=e=>gn.join(Cr(e),Ln),$i=e=>gn.join(Cr(e),Ql),vp=e=>gn.join(e,ct),KI=e=>{let t=gn.join(e,ct);return ys.existsSync(t)&&ys.statSync(t).isDirectory()},bs=e=>{let t=io(e);return ys.existsSync(t)&&ys.statSync(t).isFile()},Di=e=>{let t=gn.resolve(e);for(;;){if(KI(t))return d("Resolved closest .epiq root",t);let n=gn.dirname(t);if(n===t)return l("No .epiq directory found in any parent");t=n}},YI="No .epiq/project.json found in any parent",Ce=e=>{let t=gn.resolve(e);for(;;){if(bs(t))return d("Resolved closest epiq project root",t);let n=gn.dirname(t);if(n===t)return l(YI);t=n}},yp=e=>{let t=bt(e);try{return ys.mkdirSync(t,{recursive:!0}),d("Resolved events dir",t)}catch(n){return l(n instanceof Error?`Failed to ensure events dir: ${n.message}`:"Failed to ensure events dir")}},Ee=async()=>{let e=await kt(process.cwd());if(a(e))return e;let t=Ie({repoRoot:e.value});return a(t)?t:d("Resolved persist root",t.value)}});import xs from"node:fs";import{ulid as XI}from"ulid";import{z as ji}from"zod";var JI,QI,Ui,Tt,fn,Zl,Zt=g(()=>{"use strict";N();ee();JI="__epiq_state__",QI=ji.object({projectId:ji.string().min(1),stateBranch:ji.string().min(1),createdAt:ji.iso.datetime()}),Ui=()=>({projectId:XI(),stateBranch:JI,createdAt:new Date().toISOString()}),Tt=e=>{let t=io(e);if(!xs.existsSync(t))return l("Missing .epiq/project.json");try{let n=xs.readFileSync(t,"utf8"),r=JSON.parse(n),o=QI.safeParse(r);return o.success?d("Read project.json",o.data):l(`Invalid .epiq/project.json: ${o.error.issues.map(s=>`${s.path.join(".")}: ${s.message}`).join(", ")}`)}catch(n){return l(n instanceof Error?`Failed to read .epiq/project.json: ${n.message}`:"Failed to read .epiq/project.json")}},fn=e=>{let t=Tt(e);return a(t)?l(t.message):d("Read projectId",t.value.projectId)},Zl=({repoRoot:e,fileContents:t})=>{let n=Cr(e),r=io(e);try{if(xs.mkdirSync(n,{recursive:!0}),xs.existsSync(r)){let o=Tt(e);return a(o)?l(o.message):d("Project already initialized",null)}return xs.writeFileSync(r,JSON.stringify(t,null,2)+`
38
+ `,"utf8"),d("Created project.json",null)}catch(o){return l(o instanceof Error?`Failed to initialize project: ${o.message}`:"Failed to initialize project")}}});import Is from"node:fs";import Es from"node:path";import{z as ao}from"zod";var Hi,ZI,eE,tE,xp,Ip,bp,Ep,Rp,Sp,nE,Wi,Rs,lo=g(()=>{"use strict";N();Zt();Pi();ee();Hi="recent-projects.json",ZI=20,eE=ao.object({projectId:ao.string().min(1),root:ao.string().min(1),lastOpenedAt:ao.number().finite()}),tE=ao.object({projects:ao.array(eE)}),xp=()=>Es.join(kn(),Hi),Ip=e=>Es.basename(e)||e,bp=e=>{let t=Es.resolve(e);try{return Is.realpathSync(t)}catch{return t}},Ep=(e,t)=>t.lastOpenedAt-e.lastOpenedAt,Rp=e=>{if(!bs(e.root))return!1;let t=fn(e.root);return!a(t)&&t.value===e.projectId},Sp=()=>{let e=xp();if(!Is.existsSync(e))return d("No recent projects recorded",[]);let t;try{t=JSON.parse(Is.readFileSync(e,"utf8"))}catch(r){return l(`Invalid ${Hi}: ${r instanceof Error?r.message:String(r)}`)}let n=tE.safeParse(t);return n.success?d("Read recent projects",n.data.projects):l(`Invalid ${Hi} shape: ${n.error.issues.map(r=>r.path.join(".")||r.message).join(", ")}`)},nE=e=>{let t=xp();try{Is.mkdirSync(Es.dirname(t),{recursive:!0}),Is.writeFileSync(t,JSON.stringify({projects:e},null,2)+`
39
+ `,"utf8")}catch(n){return l(`Unable to write ${Hi}: ${n instanceof Error?n.message:String(n)}`)}return d("Recorded recent project",e)},Wi=({exclude:e}={})=>{let t=Sp();if(a(t))return t;let n=e===void 0?null:bp(e);return d("Listed recent projects",t.value.filter(r=>n===null||bp(r.root)!==n).filter(Rp).sort(Ep))},Rs=({root:e,now:t=Date.now()})=>{let n=Es.resolve(e),r=fn(n);if(a(r))return l(r.message);let o=r.value,s=Sp(),i=a(s)?[]:s.value,c=[{projectId:o,root:n,lastOpenedAt:t},...i.filter(u=>u.projectId!==o&&u.root!==n)].filter(Rp).sort(Ep).slice(0,ZI);return nE(c)}});import{useSyncExternalStore as Bk}from"react";var qi,rE,oE,de,ut,Ue=g(()=>{"use strict";qi={logLevel:"info",autoSyncIntervalMs:null,attachmentMaxKb:null,autoSync:null,preferredEditor:null,userName:null,userId:null,gitEmail:null,gitName:null,declinedEmailBoards:[],viewMode:null},rE=new Set,oE=()=>{for(let e of rE)e()},de=()=>qi,ut=e=>(qi={...qi,...e},oE(),qi)});var ec,Np,Cp,tc=g(()=>{"use strict";ec=null,Np=e=>{ec=e},Cp=e=>ec?ec(e):[]});var wp,Ap,co,Ss=g(()=>{"use strict";wp=[],Ap=e=>{wp=e},co=()=>wp});var Ns,nc,Tp,kp,rc,Mp,Lp,Pp,wr=g(()=>{"use strict";wt();N();Zt();Ue();tc();Ss();ee();Ns=()=>{let e=de(),t=!!e.userName?.trim(),n=!!e.preferredEditor?.trim(),r=e.autoSync===!0||e.autoSync===!1,o=Tp(),s=o.length>0?null:nc(),i=s!==null&&(e.declinedEmailBoards??[]).includes(s),c=o.length>0||i||s===null;return{isSetupDone:n&&t&&r&&c,isSetPreferredEditor:n,isSetUserName:t,userName:e.userName,preferredEditor:e.preferredEditor,autoSync:e.autoSync===void 0?null:e.autoSync,isSetAutoSync:r,isSetEmails:c,claimedEmails:o,emailSetupDeclined:i}},nc=()=>{let e=Ce(process.cwd());if(a(e))return null;let t=fn(e.value);return a(t)?null:t.value||null},Tp=()=>{let{userId:e}=de();return e?Cp(e):[]},kp=()=>Tp().length>0,rc=()=>{let e=Ce(process.cwd());if(a(e))return!1;let t=Tt(e.value);return Dt(t)},Mp=e=>e===!0?"on":e===!1?"off":null,Lp=e=>e==="on"?!0:e==="off"?!1:null,Pp=()=>{let e=Ns();if(!e.isSetUserName)return"config username ";if(!e.isSetPreferredEditor)return"config editor ";if(!e.isSetAutoSync)return"config autoSync ";if(!rc())return"init";if(!e.isSetEmails){let{gitEmail:t}=de(),n=co()[0]??t;return n&&zn(n)?`config emails ${n}`:"config emails "}return null}});var sE,we,Gi,tn=g(()=>{"use strict";sE=["00KM6CZ900T7180RM46K0JAYNF","00JR3R8E00A1Z4X9FGP9DV0SM5"],[we,Gi]=sE});var iE,aE,hn,vn,zi,Vi,uo=g(()=>{"use strict";me();N();pe();D();iE=e=>e.props.tags??[],aE=e=>e.props.assignees??[],hn=e=>iE(e).map(t=>C.getTag(t)).filter(t=>!!t),vn=e=>aE(e).map(t=>C.getContributor(t)).filter(t=>!!t),zi=()=>{let{breadCrumb:e,selectedNode:t}=v(),n=[...e,t].find(r=>r?.context==="TICKET");return!n||!U(n)?l("Invalid untag target"):d("Retrieved tags from ticket in breadcrumb",hn(n))},Vi=()=>{let{breadCrumb:e,selectedNode:t}=v(),n=[...e,t].find(r=>r?.context==="TICKET");return!n||!U(n)?l("Invalid unassign target"):d("Retrieved assignees from ticket in breadcrumb",vn(n))}});var I,Ar=g(()=>{"use strict";I={PALETTE:"?",EXIT:"exit",INIT:"init",OPEN:"open",HELP:"help",NEW:"new",TAG:"tag",UNTAG:"untag",MOVE:"move",PEEK:"peek",REPLAY:"replay",FILTER:"filter",ASSIGN:"assign",UNASSIGN:"unassign",DELETE:"delete",CLOSE_ISSUE:"close",RE_OPEN_ISSUE:"reopen",COMMENT:"comment",CONFIG:"config",EDIT:"edit",YANK:"yank",SYNC:"sync",EXPORT:"export",NONE:""}});var lE,cE,dE,uE,mE,Tr,Dp,Ki,Yi,Op,pE,oc,Cs=g(()=>{"use strict";lE=/^(\d+)(h|d|w|mo|y)$/,cE=/^(\d{4})-(\d{2})-(\d{2})(?:(?::|\s)(\d{2}):(\d{2}))?$/,dE=({year:e,month:t,day:n,hour:r=0,minute:o=0})=>{let s=new Date(e,t-1,n,r,o);return s.getFullYear()===e&&s.getMonth()===t-1&&s.getDate()===n&&s.getHours()===r&&s.getMinutes()===o},uE=(e,t=new Date)=>{let n=e.match(lE);if(!n)return null;let[,r,o]=n,s=Number(r);if(!Number.isInteger(s)||s<=0)return null;let i=new Date(t);switch(o){case"h":return i.setHours(i.getHours()-s),i;case"d":return i.setDate(i.getDate()-s),i;case"w":return i.setDate(i.getDate()-s*7),i;case"mo":return i.setMonth(i.getMonth()-s),i;case"y":return i.setFullYear(i.getFullYear()-s),i;default:return null}},mE=e=>{let t=e.match(cE);if(!t)return null;let[,n,r,o,s,i]=t,c=Number(n),u=Number(r),p=Number(o),m=s?Number(s):0,f=i?Number(i):0;return dE({year:c,month:u,day:p,hour:m,minute:f})?new Date(c,u-1,p,m,f):null},Tr=e=>{let t=e.trim().toLowerCase();return uE(t)??mE(t)},Dp=/^(\d+)(s|m)?$/,Ki=e=>{let t=e.trim().toLowerCase().match(Dp);if(!t)return null;let n=Number(t[1]);return!Number.isInteger(n)||n<=0?null:t[2]==="m"?n*6e4:n*1e3},Yi=(e,t)=>{let n=(t??"").trim().split(/\s+/).filter(Boolean),r=n.length>0&&Dp.test(n.at(-1))?n.pop():"";return{dateInput:e||n.join(" "),durationInput:r}},Op=({date:e,horizonDate:t})=>t?e.getTime()>=t.getTime():!0,pE=[{unit:"h",from:1,to:24},{unit:"d",from:1,to:7},{unit:"w",from:1,to:52},{unit:"mo",from:1,to:12},{unit:"y",from:1,to:5}],oc=(e=pE)=>{let t=[];for(let{unit:n,from:r,to:o}of e)for(let s=r;s<=o;s++)t.push(`${s}${n}`);return t}});var fE,ye,Mt,He,gE,hE,ic,ac,Bp,kr,Xi,sc,_p,vE,yE,ws,Fp,bE,xE,lc,IE,We,Pn=g(()=>{"use strict";Sr();lo();N();wr();tn();me();pe();D();kl();uo();Ar();Cs();fE=["BOARD","TICKET","SWIMLANE","COMMENT"],ye={EDITOR:"editor",VIEW:"view",USERNAME:"username",EMAILS:"emails",EMAILS_UNCLAIM:"emails-unclaim",AUTOSYNC:"autoSync",SYNC_DEBOUNCE_MS:"syncDebounceMs",ATTACHMENT_MAX_KB:"attachmentMaxKb",LOG_LEVEL:"logLevel"},Mt={TITLE:"title",DESCRIPTION:"description",COMMENT:"comment"},He={REF:"ref",TITLE:"title",DESCRIPTION:"description",TAGS:"tags",ASSIGNEES:"assignees"},gE=[ye.EDITOR,ye.VIEW,ye.USERNAME,ye.EMAILS,ye.EMAILS_UNCLAIM,ye.AUTOSYNC,ye.SYNC_DEBOUNCE_MS,ye.ATTACHMENT_MAX_KB,ye.LOG_LEVEL],hE=(e=v().selectedNode?.context)=>{switch(e){case"TICKET":return[Mt.TITLE,Mt.DESCRIPTION];case"BOARD":case"SWIMLANE":return[Mt.TITLE];case"COMMENT":return[Mt.COMMENT];default:return[]}},ic=[String(3e3),"5000","15000","30000","60000"],ac=["250","500","1000"],Bp=["10s","20s","30s","45s"],kr=[I.EXIT,I.SYNC,I.HELP,I.EXPORT,I.CONFIG,I.YANK],Xi=[I.NEW,I.EDIT,I.DELETE,I.MOVE],sc=[I.TAG,I.UNTAG,I.ASSIGN,I.UNASSIGN,I.CLOSE_ISSUE,I.RE_OPEN_ISSUE,I.EDIT,I.COMMENT],_p=[I.FILTER,I.PEEK,I.REPLAY],vE={WORKSPACE:[...kr,...Xi],BOARD:[..._p,...kr,...Xi],SWIMLANE:[..._p,...kr,...Xi],TICKET:[...kr,...Xi,...sc],FIELD:[...kr,...sc],FIELD_LIST:[...kr,...sc],TEXT:[...kr],COMMENT:[I.EDIT,I.DELETE,I.YANK]},yE=e=>e==="WORKSPACE"?["board"]:["issue","swimlane","board"],ws=({breadCrumb:e,selectedNode:t})=>[...e,t].find(n=>n!=null&&U(n)),Fp=e=>e.parentNodeId===we,bE=({selectedNode:e,breadCrumb:t})=>{let n=hE(e?.context);return ws({breadCrumb:t,selectedNode:e})?n.includes(Mt.DESCRIPTION)?n:[...n,Mt.DESCRIPTION]:n},xE=({selectedNode:e,breadCrumb:t})=>{let n=ws({breadCrumb:t,selectedNode:e});return n?[He.REF,He.TITLE,...n.props?.description?.trim()?[He.DESCRIPTION]:[],...hn(n).length>0?[He.TAGS]:[],...vn(n).length>0?[He.ASSIGNEES]:[]]:e?[He.REF,He.TITLE]:[]},lc=()=>{let e=Wi({exclude:process.cwd()});return a(e)?[]:[...e.value.map((t,n)=>String(n+1)),...e.value.map(t=>t.root)]},IE=({selectedNode:e,readOnly:t,breadCrumb:n})=>{let{isSetupDone:r}=Ns();if(!r)return[I.HELP,I.CONFIG];if(!rc())return[I.HELP,I.INIT,I.OPEN];if(t)return[I.HELP,I.PEEK,I.REPLAY,I.EXPORT,I.CONFIG,I.YANK];let o=e?.context,s=o&&fE.includes(o),i=[...new Set([...n,e].map(u=>u?.context).flatMap(u=>u?vE[u]:[]))],c=ws({breadCrumb:n,selectedNode:e});return i.filter(u=>u===I.MOVE?!1:u===I.YANK?!!(c??e):u===I.EDIT?s||!!c:u===I.DELETE?s:u===I.UNTAG?!!(c&&hn(c).length>0):u===I.UNASSIGN?!!(c&&vn(c).length>0):u===I.RE_OPEN_ISSUE?!!(c&&Fp(c)):u===I.CLOSE_ISSUE?!!(c&&!Fp(c)):!0)},We=(e,{contextNode:t,selectedNode:n,readOnly:r,breadCrumb:o}=v())=>{let s=t.context??"WORKSPACE";return{[I.NONE]:IE({breadCrumb:o,readOnly:r,selectedNode:n}),[I.EXIT]:["confirm"],[I.EXPORT]:[],[I.SYNC]:[],[I.INIT]:[],[I.OPEN]:e===I.OPEN?lc():[],[I.HELP]:[],[I.PEEK]:[...oc(),"now","prev","next"],[I.REPLAY]:[...oc()],[I.EDIT]:bE({selectedNode:n,breadCrumb:o}),[I.YANK]:xE({selectedNode:n,breadCrumb:o}),[I.COMMENT]:[],[I.DELETE]:["confirm"],[I.RE_OPEN_ISSUE]:["confirm"],[I.CLOSE_ISSUE]:["confirm"],[I.MOVE]:["start","confirm","next","previous","jump-next","jump-previous","to-next","to-previous","cancel"],[I.FILTER]:["tag","assignee","actor","description","title","ref","clear"],[I.TAG]:[...new Set([...Object.keys(wi),...C.getExistingTags()])],[I.UNTAG]:[...zi()?.value?.map(({name:c})=>c)??[]],[I.UNASSIGN]:[...Vi()?.value?.map(({name:c})=>c)??[]],[I.ASSIGN]:C.getExistingAssignees(),[I.NEW]:yE(s),[I.CONFIG]:[...gE]}[e]??[]}});var $p,jp=g(()=>{"use strict";$p=["vim","nvim","nano","micro","emacs","hx","code","code-insiders","subl","notepad","notepad++","idea","webstorm","default","system","$EDITOR","$VISUAL"]});import{accessSync as EE,copyFileSync as RE,existsSync as Ji,mkdirSync as Up,readdirSync as Hp,readFileSync as SE,renameSync as NE,rmSync as CE,statSync as Wp,unlinkSync as wE,writeFileSync as AE}from"node:fs";import mo from"node:path";var cc,Qe,Qi=g(()=>{"use strict";cc=e=>typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string",Qe={writeToFile:(e,t)=>{try{let n=mo.dirname(e);Ji(n)||Up(n,{recursive:!0});let r=typeof t=="string"?t:JSON.stringify(t,null,2);AE(e,r,"utf-8")}catch(n){logger.error(`Failed to write file at ${e}:`,n)}},readFile:e=>{try{return SE(e,"utf-8")}catch(t){return logger.error(`Failed to read file at ${e}:`,t),null}},readFileJSON(e){try{let t=Qe.readFile(e);return t===null?null:JSON.parse(t)}catch(t){return logger.error(`Failed to read JSON at ${e}:`,t),null}},dirExists:e=>{try{return Ji(e)&&Wp(e).isDirectory()}catch{return!1}},async fileExists(e){try{return await EE(e),!0}catch{return!1}},mkDir:e=>Up(e,{recursive:!0}),locateFolder:e=>{let t=process.cwd(),{root:n}=mo.parse(t);for(;;){let r=mo.join(t,e);try{if(Ji(r)&&Wp(r).isDirectory())return r}catch{logger.error(`Unable to locate folder ${e}`)}if(t===n)break;t=mo.dirname(t)}return null},readFirstJSON(e){try{if(!Qe.dirExists(e))return null;let t=Hp(e).filter(r=>r.endsWith(".json")).sort()[0];if(!t)return null;let n=mo.join(e,t);return Qe.readFileJSON(n)}catch(t){return logger.error(`Could not read first JSON in folder ${e}`,t),null}},listDir:e=>{try{return Qe.dirExists(e)?Hp(e):[]}catch(t){return logger.error(`Failed to list dir ${e}`,t),[]}},rmFile(e){try{wE(e)}catch(t){(!cc(t)||t.code!=="ENOENT")&&logger.error(`Unable to remove file ${e}`)}},rmDir(e){try{CE(e,{recursive:!0,force:!0})}catch(t){(!cc(t)||t.code!=="ENOENT")&&logger.error(`Unable to remove dir ${e}`)}},moveFile(e,t,n){if(this.mkDir(mo.dirname(t)),!n?.overwrite&&Ji(t))throw new Error(`moveFile: destination exists: ${t}`);n?.overwrite&&this.rmFile(t);try{NE(e,t)}catch(r){if(cc(r)&&r.code==="EXDEV"){RE(e,t),this.rmFile(e);return}throw r}}}});import TE from"node:path";import{z as nn}from"zod";var kE,Gp,ME,zp,dc,uc,LE,yn,Vp,xt,Xn,bn=g(()=>{"use strict";yr();Sr();ee();N();Qi();kE={logLevel:"info",userId:"",userName:"",preferredEditor:"",autoSync:!1},Gp=nn.object({logLevel:nn.enum(["info","error","debug"]),preferredEditor:nn.string().optional(),userName:nn.string().optional(),userId:nn.string().optional(),autoSync:nn.boolean().nullable().optional(),autoSyncDebounceMs:nn.number().optional(),attachmentMaxKb:nn.number().optional(),viewMode:nn.enum(["dense","wide"]).optional(),declinedEmailBoards:nn.array(nn.string()).optional()}).partial(),ME="config.json",zp=kn,dc=()=>TE.join(zp(),ME),uc=()=>{try{return Qe.mkDir(zp()),d(`Ensured ~/${Jt} exists`,null)}catch{return l(`Unable to create ~/${Jt}`)}},LE=e=>{let t;try{t=JSON.parse(e)}catch{return l(`Invalid ~/${Jt}/config.json JSON`)}let n=Gp.safeParse(t??{});return n.success?d("Parsed config",n.data):l(`Invalid ~/${Jt}/config.json shape: ${n.error.issues.map(r=>r.path.join(".")||r.message).join(", ")}`)},yn=()=>{let e=uc();if(a(e))return l(e.message);let t=dc(),n=Qe.readFile(t);return n==null||n.trim()===""?d("No config found, using empty config",{logLevel:"info",autoSync:null,preferredEditor:"",userId:"",userName:"",autoSyncIntervalMs:1e4}):LE(n)},Vp=e=>{let t=uc();if(a(t))return l(t.message);let n=Gp.safeParse(e);if(!n.success)return l(`Invalid config: ${n.error.issues.map(o=>o.path.join(".")||o.message).join(", ")}`);let r=dc();try{return Qe.writeToFile(r,JSON.stringify(n.data,null,2)+`
40
+ `),d("Config written",null)}catch{return l(`Unable to write ~/${Jt}/config.json`)}},xt=e=>{let t=yn();if(a(t))return l("Failed to read existing config");let n={...t.value,...e};return Vp(n)},Xn=()=>{let e=dc(),t=uc();if(a(t))return l(`Unable to create ~/${Jt}`);if(!(Qe.readFile(e)!==null)){let S=Vp(kE);if(a(S))throw new Error(`Unable to create ~/${Jt}/config.json`)}let r=yn();if(a(r))throw new Error(r.message||"Unable to load settings");let{preferredEditor:o,userName:s,userId:i,declinedEmailBoards:c,autoSync:u,autoSyncDebounceMs:p,attachmentMaxKb:m,logLevel:f,viewMode:h}=r.value,b=Cl({userId:i,userName:s});if(a(b))return l(b.message);let E=b.value??{userId:i,userName:s};return!E.userName||!E.userId?l(`User name or ID not configured in ~/${Jt}/config.json`):(process.env.EPIQ_LOG_LEVEL=f,d("successfully loaded settings",{gitEmail:null,gitName:null,declinedEmailBoards:c??[],logLevel:f??"debug",preferredEditor:o??"",userName:E.userName,userId:E.userId,autoSync:u??!1,autoSyncIntervalMs:p??1e4,attachmentMaxKb:m??null,viewMode:h??"dense"}))}});var Kp,Yp,mc,Xp=g(()=>{"use strict";Kp="/media/",Yp=e=>`${Kp}${e}`,mc=(e,t)=>`![${e}](${Yp(t)})`});import PE from"node:crypto";import pc from"node:fs";import DE from"node:path";var Dn,po,OE,_E,FE,Jp,fo=g(()=>{"use strict";Xt();N();ee();Xp();Dn=500,po=(e,t)=>`${e}.${t}`,OE=e=>e.length>=8&&e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))?d("Sniffed image type","png"):e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?d("Sniffed image type","jpg"):e.length>=6&&(e.subarray(0,6).equals(Buffer.from("GIF87a","ascii"))||e.subarray(0,6).equals(Buffer.from("GIF89a","ascii")))?d("Sniffed image type","gif"):e.length>=12&&e.subarray(0,4).equals(Buffer.from("RIFF","ascii"))&&e.subarray(8,12).equals(Buffer.from("WEBP","ascii"))?d("Sniffed image type","webp"):l(`Unsupported image format. Allowed: ${km.join(", ")}`),_E=e=>PE.createHash("sha256").update(e).digest("hex"),FE=(e,t=Dn)=>{if(e.length===0)return l("Attachment is empty");if(e.length>t*1024)return l(`Attachment exceeds the ${t} KB size cap (${Math.ceil(e.length/1024)} KB)`);let n=OE(e);return a(n)?n:d("Validated attachment data",{hash:_E(e),ext:n.value,bytes:e.length})},Jp=(e,t,n=Dn)=>{let r=FE(t,n);if(a(r))return r;let o=$i(e),s=DE.join(o,po(r.value.hash,r.value.ext));try{pc.existsSync(s)||(pc.mkdirSync(o,{recursive:!0}),pc.writeFileSync(s,t))}catch(i){return l(`Unable to write attachment blob: ${i instanceof Error?i.message:String(i)}`)}return d("Wrote attachment blob",r.value)}});import BE from"zod";var As,Ts,Qp,fc=g(()=>{"use strict";bn();fo();N();ge();Ue();As=50,Ts=5e3,Qp=()=>{let e=fe().commandMeta.inputString,t=BE.coerce.number().int().min(As).max(Ts).safeParse(e);if(!t.success)return l(`Attachment size cap must be ${As}-${Ts} KB (default ${Dn})`);let n=xt({attachmentMaxKb:t.data});return a(n)?n:(ut({attachmentMaxKb:t.data}),d(`Attachment size cap set to ${t.data} KB`,null))}});var ot,On=g(()=>{"use strict";ot=(e,t,n)=>t.length>n?`${e} cannot exceed ${n} characters (got ${t.length})`:null});import{createHash as $E}from"node:crypto";var jE,UE,Zp,Te,Jn=g(()=>{"use strict";jE="0123456789ABCDEFGHJKMNPQRSTVWXYZ",UE=e=>{let t=$E("sha256").update(e).digest(),n=0n;for(let o=0;o<16;o++)n=n<<8n|BigInt(t[o]);let r="";for(let o=0;o<26;o++){let s=BigInt((25-o)*5);r+=jE[Number(n>>s&31n)]}return r},Zp=new Map,Te=(e,t)=>{let n=`${e}:virtual:${t}`,r=Zp.get(n);if(r!==void 0)return r;let o=UE(n);return Zp.set(n,o),o}});import ef from"chalk";var Re,_e,Fe,tf=g(()=>{"use strict";un();Je();Re=e=>ef.dim(e),_e=e=>ef.hex(T.primary)(e),Fe=({prefix:e="",wordList:t,postfix:n="",noOfHints:r=100,inputString:o,minLengthForHints:s=1})=>{let i=o.trim();if(i.length<s)return"";let m=[...t.filter(Boolean).filter(f=>f.startsWith(i))].sort((f,h)=>Ai(f)-Ai(h)).slice(0,r).map(f=>Ti(f)).join(" ");return m?`${Re(e)}${m}${Re(n)}`:""}});var Qn,Zi=g(()=>{"use strict";Qn={None:"none",Invalid:"invalid",Valid:"valid"}});import of from"chalk";var HE,nf,xe,WE,ae,K,ho,rf,ea,gc,qE,go,GE,zE,VE,KE,YE,sf,af=g(()=>{"use strict";Sr();wr();jp();lt();Xt();N();pe();Ue();fc();fo();wt();D();un();On();uo();Jn();tf();Ss();Ar();Zi();Pn();Cs();HE=["BOARD","TICKET","SWIMLANE"],nf=()=>{let e=v().selectedNode;if(!e?.context)return K({message:Re("Missing target context")});if(HE.includes(e.context))return ae();if(e.parentNodeId){let t=v().nodes[e.parentNodeId];if(t?.id===Te(t?.parentNodeId??"","comments"))return ae()}return K({message:Re("Command not available in this context")})},xe="<ENTER> to confirm",WE=()=>{let{userId:e}=de(),t=ke();return!e||a(t)?[]:Vn(t.value.emailLinks,e)},ae=(e="",t=[],n=!0)=>({message:n?Re(e):e,validity:Qn.Valid,completionWordList:t}),K=({message:e,completionWordList:t=[]})=>({validity:Qn.Invalid,message:e,completionWordList:t}),ho=e=>e.length===0,rf=(e,t)=>{let n=Ct(v().breadCrumb,"BOARD");if(a(n))return K({message:_e("Command is not applicable in this context")});let r=Tl(n.value.id);return a(r)?K({message:_e(`Unable to ${t}: board id is not a valid ULID`)}):Op({date:e,horizonDate:r.value})?null:K({message:_e(`nothing to ${t} before ${r.value.toISOString().slice(0,16).replace("T"," ")}`)})},ea=e=>` ${of.hex("#000").bgHex(tt(e))(` ${e} `)} `,gc=({modifier:e})=>{let t="confirm";return e===t?ae(xe):K({message:ho(e)?Re("if you are certain, enter ")+Ti(t):"",completionWordList:[t]})},qE=({list:e,hint:t,onValue:n})=>({modifier:r,inputString:o})=>e.includes(r)?o.trim().length<1?K({message:Re(n)}):ae():K({message:ho(r)?t:"",completionWordList:[...e]}),go=({hint:e,onOk:t})=>({modifier:n,inputString:r})=>ho(n)&&ho(r)?K({message:e,completionWordList:[]}):ae(t??xe),GE=({modifier:e,inputString:t})=>{let n=lc();return!ho(e)||!ho(t)?ae(xe):K({message:n.length?Re("number from the list, or a path"):Re("path to an epiq project"),completionWordList:n})},zE=({modifier:e,inputString:t})=>{let n=We(I.CONFIG);if(!n.includes(e))return K({message:Fe({prefix:"... ",wordList:n,inputString:e,minLengthForHints:0}),completionWordList:n});switch(e){case ye.EDITOR:{let r=[...$p];return t.trim()?r.includes(t.trim())?ae(xe):K({message:Fe({prefix:"editors: ",wordList:r,inputString:t,minLengthForHints:0}),completionWordList:r}):K({message:Fe({prefix:"editors: ",wordList:r,inputString:t,minLengthForHints:0}),completionWordList:r})}case ye.VIEW:{let r=["dense","wide"];return r.includes(t.trim())?ae(xe):K({message:Fe({prefix:"view... ",wordList:r,inputString:t,minLengthForHints:0}),completionWordList:r})}case ye.USERNAME:{let r=de().gitName,o=r?[r]:[],s=t.trim(),i=o.filter(p=>p.startsWith(s)),u=i.length===1&&i[0]===s?"":Fe({prefix:"name: ",wordList:o,inputString:s,minLengthForHints:0});return s?u?ae(`${u} ${Re(xe)}`,o,!1):ae(xe,o):K({message:u||_e("Enter a user name. Saved in ")+of.bgBlack("~/.epiq-global/config.json"),completionWordList:o})}case ye.EMAILS:{let r=de().gitEmail,o=co(),s=o.length>0||!r?o:[r],i=[...s,"none"],c=t.trim(),u=(E,S)=>K({message:Fe({prefix:E,wordList:i,noOfHints:3,inputString:S,minLengthForHints:0}),completionWordList:i});if(!c)return ae(`${xe} to see your addresses, or name one`,i);let p=c.split(/[,\s]+/).filter(Boolean),m=p[p.length-1]??"",f=E=>E==="none"||s.includes(E.toLowerCase()),h=E=>i.some(S=>S.startsWith(E.toLowerCase())),b=p.filter(E=>!f(E)&&!h(E));return b.length>0?K({message:_e(`no address here matches ${b.join(", ")} \u2014 pick one from the list, or its number`),completionWordList:i}):f(m)?ae(xe):u("",m)}case ye.EMAILS_UNCLAIM:{let r=WE(),o=t.trim();return r.length===0?K({message:_e("you have not claimed any addresses"),completionWordList:[]}):o&&r.includes(o.toLowerCase())?ae(xe):K({message:Fe({prefix:"give an address back ",wordList:r,noOfHints:3,inputString:o,minLengthForHints:0}),completionWordList:r})}case ye.LOG_LEVEL:{let r=["debug","error","info"],o=t.trim();return r.includes(o)?ae(xe):K({message:Fe({prefix:"one of: ",wordList:[...r],inputString:o,postfix:" persisted in ~/.epiq-global/config.json",minLengthForHints:0}),completionWordList:[...r]})}case ye.AUTOSYNC:{let r=["on","off"],o=de().autoSync;if(!r.includes(t.trim())){let s=Mp(o);return K({message:Fe({prefix:`should auto-sync (recommended)${s!==null?", currently: "+s:""} `,wordList:r,noOfHints:3,inputString:t,minLengthForHints:0}),completionWordList:r})}return ae(xe)}case ye.ATTACHMENT_MAX_KB:{let r=de().attachmentMaxKb,o=Number.parseInt(t.trim(),10);if(!t.trim()||Number.isNaN(o)||o<As||o>Ts){let s=Fe({prefix:" examples: ",wordList:ac,minLengthForHints:0,inputString:t});return K({message:_e(`provide a size cap in KB (${As}-${Ts}). current: ${r??Dn} KB.`)+s,completionWordList:ac})}return ae(xe)}case ye.SYNC_DEBOUNCE_MS:{let r=de().autoSyncIntervalMs,o=ro(t);if(!t.trim()||o===null){let s=Fe({prefix:" examples: ",wordList:ic,minLengthForHints:0,inputString:t});return K({message:_e(`provide a duration between ${3e3}ms and ${864e5}ms. current duration: ${r}ms.`)+s,completionWordList:ic})}return ae(xe)}default:return K({message:_e("Unknown config option"),completionWordList:n})}},VE=({modifier:e,inputString:t})=>{let n=We(I.EDIT);if(!n.length)return K({message:_e("Command not available in this context")});if(!n.includes(e)){let r=Fe({prefix:"edit... ",wordList:n,inputString:e,minLengthForHints:0});return K({message:r||_e("Unknown edit option"),completionWordList:n})}switch(e){case Mt.COMMENT:return t.trim()?ae(xe):K({message:Re("write a comment...")});case Mt.TITLE:return ae(xe);case Mt.DESCRIPTION:{let{preferredEditor:r}=de();return r?ae(Re("<ENTER> to edit in ")+r):K({message:"No editor selected"})}default:return K({message:_e("Unknown edit option"),completionWordList:n})}},KE=({modifier:e})=>{let t=We(I.YANK);return t.length?t.includes(e)?ae(xe+Re(" and copy to clipboard")):K({message:Fe({prefix:"yank... ",wordList:t,inputString:e,minLengthForHints:0}),completionWordList:t}):K({message:_e("Nothing selected to copy from")})},YE={[I.EXPORT]:()=>ae(xe+Re(", and create export markdown file")),[I.PEEK]:e=>{let t=e.modifier;if(t==="now"||t==="prev"||t==="next")return ae(xe);let n={message:Re("historical state from: '1h', '2d', '23h', '1mo', '2y', 'prev', 'next' or full date as YYYY-MM-DD")},r=t||e.inputString.trim(),o=Tr(r);if(!r||!o)return K(n);let s=rf(o,"peek");return s||ae(xe)},[I.REPLAY]:e=>{let{dateInput:t,durationInput:n}=Yi(e.modifier,e.inputString),r={message:Re("replay forward from: '1h', '2d', '1mo', '2y' or full date as YYYY-MM-DD, with optional duration (e.g. '2y 30s')")},o=Tr(t);if(!t||!o)return K(r);let s=rf(o,"replay");return s||(n&&Ki(n)===null?K({message:_e("duration must be positive (e.g. 30s, 2m, or a number of seconds)")}):ae("<ENTER> to replay board history",n?Bp:[]))},[I.EXIT]:()=>ae(xe+Re(" and exit the application")),[I.INIT]:()=>ae(xe),[I.OPEN]:GE,[I.PALETTE]:()=>ae(xe),[I.FILTER]:e=>{if(e.modifier==="clear")return ae(xe);let t=s=>We(I.FILTER).includes(s);if(!e.modifier||!t(e.modifier))return K({message:Fe({wordList:We(I.FILTER),inputString:e.inputString,minLengthForHints:0}),completionWordList:We(I.FILTER)});let n=Object.values(v().tags).map(s=>s.name),r=Object.values(v().contributors).map(s=>s.name),o=e.modifier==="tag"?n:e.modifier==="assignee"?r:[];return e.inputString?o.length&&!o.includes(e.inputString.trim())?K({message:Fe({prefix:`existing ${e.modifier}s... `,wordList:o,noOfHints:10,inputString:e.inputString,minLengthForHints:0}),completionWordList:o}):ae():K({message:Fe({prefix:"one of... ",wordList:o,noOfHints:10,inputString:e.inputString,minLengthForHints:0}),completionWordList:o})},[I.NONE]:e=>{let t=We(I.NONE);return K({message:Fe({prefix:"... ",wordList:t,inputString:e.inputString,minLengthForHints:0}),completionWordList:t})},[I.NEW]:e=>qE({list:We(I.NEW),hint:Fe({wordList:We(I.NEW),noOfHints:3,inputString:e.inputString,minLengthForHints:0}),onValue:"provide a name..."})(e),[I.HELP]:()=>ae(xe),[I.EDIT]:VE,[I.COMMENT]:e=>{let t=go({hint:Re(`write a comment (max ${4e3} char)...`),onOk:Re(`(${e.inputString.length}/${4e3})`)})(e);return t.validity===Qn.Invalid?t:e.inputString.length>4e3?ae(_e("max input exceeded")):t},[I.CONFIG]:zE,[I.YANK]:KE,[I.DELETE]:e=>{let t=nf();return t.validity==="invalid"?t:gc(e)},[I.CLOSE_ISSUE]:e=>gc(e),[I.RE_OPEN_ISSUE]:e=>gc(e),[I.MOVE]:e=>{let t=nf();return t.validity==="invalid"?t:go({hint:Fe({prefix:"hey hacker! These commands are blocked for you... ",wordList:We(I.MOVE),noOfHints:10,inputString:e.inputString})})(e)},[I.TAG]:e=>{let n=C.getExistingTags().slice(0,10).map(ea).join("");return go({hint:n.length?Re("create tag or reuse:")+n+Re(""):Re("create tag ...")})(e)},[I.UNTAG]:e=>{let t=zi();if(a(t))return K({message:_e("Invalid untag target"),completionWordList:[]});let n=t.value.map(({name:r})=>r).map(ea).slice(0,10);return n.length?go({hint:Re(" ... ")+n.join("")})(e):K({message:_e("Issue has no tags"),completionWordList:[]})},[I.ASSIGN]:e=>{let t=C.getExistingAssignees().map(ea).slice(0,10);return go({hint:Re("assignees... ")+t.join("")})(e)},[I.UNASSIGN]:e=>{let t=Vi();if(a(t))return K({message:_e("Invalid unassign target"),completionWordList:[]});let n=t.value.map(({name:r})=>r).map(ea).slice(0,10);return n.length?go({hint:Re("remove assignee... ")+n.join("")})(e):K({message:_e("Issue has no assignees"),completionWordList:[]})},[I.SYNC]:()=>ae(xe)},sf=Object.fromEntries(Object.entries(YE).map(([e,t])=>[e,{validate:(n,r,o)=>t({modifier:r,command:n,inputString:o})}]))});var ta,lf=g(()=>{"use strict";ta=["add","fix","bug","log","run","api","cli","ui","ux","test","mock","stub","sync","hash","sign","fork","push","pull","lock","warn","leak","hang","node","seed","lint","edit","save","load","read","send","drop","swap","wrap","port","host","role","user","auth","flag","diff","perf","docs","todo","task","team","epic","spec","remove","update","change","improve","enhance","refactor","rewrite","redesign","implement","build","create","delete","rename","migrate","upgrade","downgrade","revert","rollback","restore","replace","deprecate","cleanup","simplify","optimize","stabilize","harden","document","clarify","investigate","debug","reproduce","triage","mitigate","remediate","resolve","escalate","verify","validate","benchmark","profile","audit","monitor","instrument","configure","provision","deploy","release","publish","integrate","automate","support","enable","disable","prevent","handle","ensure","prioritize","estimate","schedule","track","install","uninstall","enforce","expose","extract","inject","override","extend","customize","localize","translate","redirect","forward","dispatch","broadcast","subscribe","unsubscribe","register","allocate","reserve","persist","retrieve","archive","expire","refresh","reload","reset","recover","replay","retry","scaffold","bootstrap","finalize","terminate","suspend","resume","cancel","abort","notify","alert","trigger","debounce","frontend","backend","fullstack","infrastructure","architecture","integration","application","environment","framework","platform","service","component","module","gateway","pipeline","container","orchestrator","middleware","endpoint","interface","database","datastore","cache","queue","scheduler","worker","daemon","runtime","library","package","plugin","extension","webhook","microservice","monolith","repository","namespace","cluster","sandbox","tenant","dashboard","console","portal","client","server","browser","mobile","desktop","kernel","driver","protocol","schema","migration","fixture","template","snippet","config","manifest","bundle","exception","incident","defect","regression","degradation","malfunction","instability","intermittent","workaround","failure","outage","crash","freeze","corruption","inconsistency","severity","criticality","diagnostics","analysis","blocker","flaky","timeout","mismatch","misconfiguration","boundary","overflow","underflow","panic","stacktrace","breakage","breaking","oversight","ambiguity","discrepancy","anomaly","authorize","authenticate","confidentiality","availability","accessibility","reliability","compliance","governance","encrypt","decrypt","integrity","traceability","accountability","protection","privileges","permissions","sanitize","escape","vulnerability","exposure","secrets","credentials","certificate","session","cookie","identity","tokenization","rotation","scanning","hardening","threat","exploit","payload","injection","phishing","breach","dependency","orchestrate","synchronize","compatibility","incompatibility","interoperability","observability","telemetry","discovery","registration","coordination","distribution","isolation","virtualization","networking","routing","proxy","firewall","balancer","failover","topology","replica","shard","region","capacity","quota","metrics","logging","tracing","alerting","monitoring","heartbeat","liveness","rollover","serialize","deserialize","initialize","instantiate","propagate","aggregate","consolidate","normalize","standardize","transform","reconcile","correlate","index","partition","enrich","filter","stream","batch","parse","encode","decode","compress","decompress","deduplicate","paginate","query","ingest","export","import","backup","snapshot","mapping","record","dataset","metadata","checksum","rollup","lookup","cursor","truncate","concurrency","parallelism","contention","deadlock","throttle","backpressure","fragmentation","saturation","exhaustion","replicate","redundancy","obsolescence","starvation","overload","latency","throughput","scalability","bottleneck","memoize","prefetch","warmup","autoscale","horizontal","vertical","elasticity","recursion","allocation","leakage","garbage","collection","pooling","buffering","caching","eviction","staleness","modularize","encapsulate","abstraction","extensibility","configurability","maintainability","recoverability","readability","testability","debuggability","reusability","simplicity","consistency","linting","formatting","typecheck","coverage","tooling","scaffolding","boilerplate","technical","cleanliness","naming","comments","docstring","testing","unittest","mocking","stubbing","assertion","smoke","sanity","fuzzing","flakiness","harness","scenario","baseline","performance","functionality","requirement","recommendation","improvement","enhancement","description","acceptance","criteria","deliverable","milestone","iteration","backlog","roadmap","followup","hotfix","patch","changelog","rollout","feature","spike","proposal","specification","priority","sprint","story","subtask","assignee","reviewer","reproduction","context","expected","actual","impact","workflow","version","tracking","discussion","decision","tradeoff","feedback","approval","planning","breakdown","scoping"]});var XE,JE,QE,ZE,eR,cf,df,uf,mf=g(()=>{"use strict";N();D();lf();XE=3,JE=new Set(["the","and","for","are","but","not","you","all","any","can","was","one","our","out","use","this","that","with","have","from","will","your","they","them","then","than","when","what","were","been","into","should","would","could","about"]),QE=e=>{let t=[];for(let n of Object.values(e.nodes)){n.title&&t.push(n.title);let r=n.props;typeof r.description=="string"&&t.push(r.description),typeof r.value=="string"&&t.push(r.value)}for(let n of Object.values(e.tags))t.push(n.name);for(let n of Object.values(e.contributors))t.push(n.name);for(let n of Object.values(e.comments))t.push(n.md);return t},ZE=e=>e.toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>=XE&&!JE.has(t)&&!/^\d+$/.test(t)),eR=e=>{let t=new Map;for(let s of QE(e))for(let i of ZE(s))t.set(i,(t.get(i)??0)+1);let n=[...t.entries()].sort((s,i)=>i[1]-s[1]||s[0].localeCompare(i[0])).map(([s])=>s),r=new Set(n),o=ta.filter(s=>!r.has(s));return[...n,...o]},cf=ta,df=-1,uf=()=>{let e=ke();if(a(e))return ta;let t=e.value,n=t.eventLog.length;return n!==df&&(cf=eR(t),df=n),cf}});var pf,ff,hc=g(()=>{"use strict";Wm();Pn();Ar();af();mf();D();Oe();pf=e=>Object.values(I).includes(e),ff=(e,t)=>{let n=e.command??"",{modifier:r,target:o,inputString:s}=e,{message:i,validity:c,completionWordList:u}=sf[n].validate(n,r,s),p=n!==I.PEEK&&n!==I.REPLAY,m=o==="command"||o==="modifier"?We(n):p?uf():[],{mode:f}=v(),h=f===x.COMMAND_LINE?i??"":"",b=[...u,...m];return{validity:c,command:e.command,modifier:e.modifier,inputString:e.inputString,infoMessage:h,autoCompletion:t?Hm(e,b,u):{hint:"",hints:[],remainder:"",overlap:0}}}});var gf,tR,nR,rR,hf=g(()=>{"use strict";hc();Pn();gf=e=>{let t=e.trimStart(),n=nR(t),r=n[0]??"",o=n[1]??"",s=/\s$/.test(e),i=rR(e),c=pf(r)?r:null,u=c!==null,p=r!=="",m=c?We(c)??[]:[],f=c&&m.includes(o)?o:"",h="word";n.length===0||n.length===1&&!s?h="command":(n.length===1&&s||n.length===2&&!s)&&(h="modifier");let b=s?"":i,E=tR(t,c,f);return{raw:e,trimmedStart:t,words:n,firstWord:r,lastWord:i,hasCommand:p,command:c,isCommandKeyword:u,isLastWordCompleted:s,modifier:f,target:h,inputToMatch:b,inputString:E}},tR=(e,t,n)=>{let r=e;return t&&r.startsWith(t)&&(r=r.slice(t.length)),r=r.replace(/^\s+/,""),n&&r.startsWith(n)&&(r=r.slice(n.length),r=r.replace(/^\s+/,"")),r},nR=e=>e.trim()?e.trim().split(/\s+/):[],rR=e=>e.trimEnd().split(/\s+/).at(-1)??""});import{useSyncExternalStore as iP}from"react";var vo,vc,Ms,yo,oR,vf,Ft,Ls,yc,bc,yf,bf,na,xf,ne,If,Ef,Rf,Sf,Nf,fe,ra,ge=g(()=>{"use strict";hc();hf();N();Zi();vo=e=>e===vc||e===":",vc=" ",Ms=40,yo={commandHistory:[],value:"",commandHistoryIndex:-1,cursorPosition:0,commandIsPending:!1,commandMeta:{command:null,modifier:"",infoMessage:"",inputString:"",validity:Qn.None,autoCompletion:{hint:"",hints:[],remainder:"",overlap:0}}},oR=new Set,vf=()=>{for(let e of oR)e()},Ft=e=>{let n=e(yo),r=gf(n.value),o=n.cursorPosition===n.value.length;yo={...n,commandMeta:ff(r,o)},vf()},Ls=({message:e,status:t})=>{let n=structuredClone(yo);return n.commandMeta={...n.commandMeta,infoMessage:e??"",validity:t==="fail"?"invalid":"valid"},n.commandIsPending=!0,yo=n,vf(),d(e,null)},yc=e=>{Ft(t=>({...t,cursorPosition:Math.max(0,Math.min(t.value.length,t.cursorPosition+e))}))},bc=e=>{Ft(t=>{let{value:n,cursorPosition:r}=t,o=r;if(e==="left"){for(;o>0&&vo(n[o-1]);)o--;for(;o>0&&!vo(n[o-1]);)o--}else{for(;o<n.length&&!vo(n[o]);)o++;for(;o<n.length&&vo(n[o]);)o++}return{...t,cursorPosition:o}})},yf=()=>{Ft(e=>{let t=e.value.slice(e.cursorPosition),n=Math.max(0,e.cursorPosition-1);return{...e,value:e.value.slice(0,n)+t,cursorPosition:n,commandIsPending:!1}})},bf=()=>{Ft(e=>{let{value:t,cursorPosition:n}=e,r=n;for(;r>0&&vo(t[r-1]);)r--;for(;r>0&&!vo(t[r-1]);)r--;let o=t.slice(n);return{...e,value:t.slice(0,r)+o,cursorPosition:r,commandIsPending:!1}})},na=e=>{Ft(t=>{let n=Math.max(0,Math.min(t.cursorPosition,t.value.length)),r=t.value.slice(0,n),o=t.value.slice(n),s=e(r,t.commandMeta.autoCompletion),i=s+o,c=Math.max(0,Math.min(s.length,i.length));return{...t,value:i,cursorPosition:c,commandIsPending:!1}})},xf=()=>{Ft(e=>({...e,commandIsPending:!0}))},ne=e=>{Ft(t=>({...t,value:e,cursorPosition:e.length,commandIsPending:!1}))},If=({addToHistory:e=!0,line:t})=>{Ft(n=>{let r=t??n.value;return{...n,commandHistory:e&&r.trim()?[r,...n.commandHistory].slice(0,Ms):n.commandHistory,commandHistoryIndex:-1,commandIsPending:!1,value:"",cursorPosition:0}})},Ef=e=>{Ft(t=>({...t,commandHistory:e.slice(0,Ms),commandHistoryIndex:-1}))},Rf=()=>{Ft(e=>e.commandHistoryIndex===-1?e:{...e,commandHistoryIndex:-1})},Sf=()=>{Ft(e=>{let t=Math.min(e.commandHistoryIndex+1,e.commandHistory.length-1),n=e.commandHistory[t]??"";return{...e,commandHistoryIndex:t,value:n,cursorPosition:n.length}})},Nf=()=>{Ft(e=>{let t=Math.max(e.commandHistoryIndex-1,-1),n=t===-1?"":e.commandHistory[t]??"";return{...e,commandHistoryIndex:t,value:n,cursorPosition:n.length}})},fe=()=>yo,ra=()=>{let[e,...t]=yo.value.split(vc);return t.join(vc).trim()}});var P,hP,Kn=g(()=>{"use strict";Oe();Pm();D();ge();Ue();P={NavPreviousItem:"navPreviousItem",NavNextItem:"navNextItem",NavPreviousItemJump:"navPreviousItemJump",NavNextItemJump:"navNextItemJump",NavToPreviousContainer:"navToPreviousContainer",NavToNextContainer:"navToNextContainer",MovePreviousItem:"movePreviousItem",MoveNextItem:"moveNextItem",MovePreviousItemJump:"movePreviousItemJump",MoveNextItemJump:"moveNextItemJump",MoveToPreviousContainer:"moveToPreviousContainer",MoveToNextContainer:"moveToNextContainer",Confirm:"confirm",Exit:"exit",ViewHelp:"viewHelp",HideHelp:"hideHelp",InitMove:"initMove",ConfirmMove:"confirmMove",Delete:"Delete",InitCommandPalette:"initCommandPalette",InitCommandLine:"initCommandLine",ExitCommandLine:"exitCommandLine",CaptureInput:"captureInput",EraseInput:"eraseInput",AddItem:"addItem",GetLastCommandFromHistory:"getLastCommandFromHistory",GetNextCommandFromHistory:"getNextCommandFromHistory",AutoCompleteCommand:"autoCompleteCommand",MoveCursorLeft:"MoveCursorLeft",MoveCursorRight:"MoveCursorRight",MoveCursorLeftOfWord:"MoveCursorLeftOfWord",MoveCursorRightOfWord:"MoveCursorRightOfWord",EraseInputWord:"EraseInputWord",None:"None",Edit:"edit",EditTitle:"editTitle",EditDescription:"editDescription",Yank:"yank",OpenInEditor:"openInEditor",MarkDiffLine:"markDiffLine",CommentOnDiffLine:"commentOnDiffLine",SetViewDense:"SetViewDense",SetViewWide:"SetViewWide"},hP={[P.NavPreviousItem]:P.NavPreviousItemJump,[P.NavNextItem]:P.NavNextItemJump,[P.MovePreviousItem]:P.MovePreviousItemJump,[P.MoveNextItem]:P.MoveNextItemJump}});function Cf(e){return!e||!iR.test(e)?l(`Invalid hex rank: ${e}`):d("Converted rank to bigint",BigInt("0x"+e))}function Lt(e,t=Ps){if(e<0n)return l("Negative rank not allowed");let n=e.toString(16);return d("Converted bigint to hex rank",n.padStart(Number(t),"0"))}function pt(e,t){if(!e&&!t)return Lt(rn/2n,Ps);let n=e?Cf(e):d("Resolved lower bound",0n);if(a(n))return n;let r=t?Cf(t):d("Resolved upper bound",rn);if(a(r))return r;let o=n.value,s=r.value;if(s<=o)return l("Neighbouring ranks leave no space between them");let i=(o+s)/2n;return i===o||i===s?l("No rank space available between neighbors"):Lt(i,Ps)}function wf(e){if(e<=0)return d("Resolved empty rank list",[]);let t=BigInt(e),n=[];for(let r=0;r<e;r++){let o=rn*BigInt(r+1)/(t+1n),s=Lt(o,Ps);if(a(s))return s;n.push(s.value)}return d("Resolved evenly spaced ranks",n)}var Ps,sR,rn,iR,bo=g(()=>{"use strict";N();Ps=24n,sR=Ps*4n,rn=(1n<<sR)-1n,iR=/^[0-9a-f]+$/});var O,Af,Bt=g(()=>{"use strict";O=({userId:e})=>({userId:e}),Af=e=>({action:e.action,payload:e.payload})});var xc,wP,$t=g(()=>{"use strict";Bt();xc=["init.workspace","add.workspace","add.board","add.swimlane","add.issue","add.field","edit.title","delete.node","create.tag","tombstone.tag","restore.tag","create.contributor","rename.contributor","tombstone.contributor","restore.contributor","add.issue.assignee","remove.issue.assignee","add.issue.tag","remove.issue.tag","move.node","edit.description","add.issue.comment","edit.issue.comment","delete.issue.comment","add.issue.attachment","delete.issue.attachment","close.issue","reopen.issue","lock.node","rebalance.children","link.contributor.user","link.contributor.email","unlink.contributor.email"],wP=new Set(xc)});import{ulid as aR}from"ulid";var Ic,Tf=g(()=>{"use strict";N();jt();bo();$t();Ic=(e,t)=>{let n=Me(e),r=wf(n.length);if(a(r))return r;let o={};for(let s=0;s<n.length;s++){let i=n[s],c=r.value[s];if(!i||!c)return l("Unable to assign rebalance rank");o[i.id]=c}return d("Created rebalance event",{id:aR(),action:"rebalance.children",payload:{parent:e,ranks:o},...O(t)})}});import{z as Lr}from"zod";var kf,Mf,lR,UP,cR,dR,Lf,uR,mR,Ec,Pf,Rc,Ds=g(()=>{"use strict";N();kf=1,Mf=Lr.tuple([Lr.string().min(1),Lr.string().min(1).nullable()]),lR=Lr.looseObject({v:Lr.literal(kf),id:Mf}),UP=Lr.looseObject({v:Lr.number().int().positive(),id:Mf}),cR=e=>Object.prototype.hasOwnProperty.call(e,"__proto__"),dR=e=>{let t={};for(let n of Object.keys(e))n!=="__proto__"&&(t[n]=e[n]);return t},Lf=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return l("Invalid persisted event envelope: expected an object");let{v:t,id:n}=e;if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)return l("Invalid persisted event envelope: v");if(!Array.isArray(n)||n.length!==2)return l("Invalid persisted event envelope: id");let[r,o]=n;return typeof r!="string"||r.length===0?l("Invalid persisted event envelope: id.0"):o!==null&&(typeof o!="string"||o.length===0)?l("Invalid persisted event envelope: id.1"):d("Parsed persisted event envelope",cR(e)?dR(e):e)},uR=[1],mR=new Set(uR),Ec=e=>mR.has(e),Pf=e=>{let t=lR.safeParse(e);return t.success?d("Parsed persisted event",t.data):l(`Invalid persisted event: ${t.error.issues.map(n=>n.path.join(".")||n.message).join(", ")}`)},Rc=(e,t)=>{let n={[e.action]:e.payload,v:kf,id:t};return Pf(n)}});import Sc from"node:fs";import pR from"node:path";var Os,Nc,Cc,Pr,Df,wc,Zn,Of,_f,Ff,xo=g(()=>{"use strict";ee();Os=e=>e?.code==="ENOENT",Nc=3,Cc=e=>Sc.readdirSync(e).filter(t=>t.endsWith(".jsonl")).sort(),Pr=e=>{let t=bt(e);for(let n=1;;n++){if(!Sc.existsSync(t))return"none";let r=[],o=!1;for(let s of Cc(t))try{let{size:i,mtimeMs:c}=Sc.statSync(pR.join(t,s));r.push(`${s}:${i}:${c}`)}catch(i){if(!Os(i))throw i;if(n<Nc){o=!0;break}}if(!o)return r.join("|")}},Df=e=>new Map(e.split("|").filter(Boolean).map(t=>{let n=t.indexOf(":");return[t.slice(0,n),t.slice(n+1)]})),wc=(e,t,n)=>{let r=Df(t),o=Pr(e),s=Df(o);for(let[i,c]of s)if(i!==n&&r.get(i)!==c)return null;for(let i of r.keys())if(i!==n&&!s.has(i))return null;return o},Zn=null,Of=e=>Zn&&Zn.root===e?Zn.signature:null,_f=(e,t)=>{Zn={root:e,signature:t}},Ff=(e,t)=>{if(!Zn||Zn.root!==e)return;let n=wc(e,Zn.signature,t);Zn=n===null?null:{root:e,signature:n}}});import Be from"node:fs";import Dr from"node:path";import{ulid as fR}from"ulid";var sa,Ac,$f,jf,ia,gR,Tc,Or,_s,Uf,hR,vR,Hf,yR,Wf,bR,qf,xR,oa,Bf,aa,_r=g(()=>{"use strict";N();ee();sa="~pending",Ac=/~pending(-[0-9a-z]+)*$/i,$f=/-f(\d+)$/,jf=e=>{let t=e.indexOf(".");return t===-1?`${e}${sa}`:e.slice(0,t)+sa+e.slice(t)},ia=e=>{let t=e.indexOf(".");return t===-1?[e,""]:[e.slice(0,t),e.slice(t)]},gR=e=>{let[t,n]=ia(e);return Ac.test(t)?t.replace(Ac,"")+n:null},Tc=e=>e.replace(Ac,""),Or=e=>e.endsWith(".jsonl")&&gR(e)!==null,_s=e=>Tc(ia(e)[0]),Uf=e=>{let[t]=ia(e),n=$f.exec(t);return n&&Or(e)?Number(n[1]):null},hR=e=>jf(e).replace(sa,`${sa}-${fR().toLowerCase()}`),vR=(e,t)=>{let[n,r]=ia(e);return`${n.replace($f,"")}-f${t}${r}`},Hf=(e,t)=>Dr.join(bt(e),jf(t)),yR=(e,t)=>Math.max(0,Be.statSync(e).size-(Uf(t)??0)),Wf=e=>{let t=bt(e);try{return Be.existsSync(t)?Be.readdirSync(t).filter(Or).some(n=>yR(Dr.join(t,n),n)>0):!1}catch{return!0}},bR=3,qf=(e,t)=>{for(let n=1;;n++){let r=Be.openSync(e,"a"),o;try{Be.writeSync(r,t),o=Be.fstatSync(r).ino}finally{Be.closeSync(r)}let s;try{s=Be.statSync(e).ino}catch{s=null}if(s===o||n>=bR)return}},xR=e=>{let t;try{t=Be.openSync(e,"r")}catch{return!0}try{let{size:n}=Be.fstatSync(t);if(n===0)return!0;let r=Buffer.alloc(1);return Be.readSync(t,r,0,1,n-1),r[0]===10}finally{Be.closeSync(t)}},oa=10,Bf=(e,t,n=!1)=>{let r=n?t.length:t.lastIndexOf(oa)+1;if(r===0)return{bytes:0,lines:0};let o=t.subarray(0,r);if(o.toString("utf8").trim().length===0)return{bytes:r,lines:0};Be.appendFileSync(e,Buffer.concat([Buffer.from(xR(e)?"":`
41
+ `),o,Buffer.from(o[o.length-1]===oa?"":`
42
+ `)]));let s=0;for(let i of o)i===oa&&s++;return o[o.length-1]!==oa&&s++,{bytes:r,lines:s}},aa=(e,t)=>{let n=bt(e);if(!Be.existsSync(n))return d("No events directory",0);try{let r=_s(t),o=Be.readdirSync(n).filter(c=>Or(c)&&_s(c)===r),s=Dr.join(n,t),i=0;for(let c of o){let u=Uf(c);if(u!==null){let h=Dr.join(n,c),b=Be.readFileSync(h).subarray(u);i+=Bf(s,b,!0).lines,Be.rmSync(h,{force:!0});continue}let p=/~pending-/i.test(c)?c:hR(t),m=Dr.join(n,p);p!==c&&Be.renameSync(Dr.join(n,c),m);let f=Bf(s,Be.readFileSync(m));i+=f.lines,Be.renameSync(m,Dr.join(n,vR(p,f.bytes)))}return d("Folded pending logs",i)}catch(r){return l(`Unable to fold pending event logs in ${n}: ${r instanceof Error?r.message:String(r)}`)}}});import Bs from"node:fs";import ca from"node:path";import{decodeTime as IR}from"ulid";import{z as kc}from"zod";var da,ER,Kf,la,RR,SR,Yf,NR,CR,er,wR,AR,Fs,Mc,TR,kR,MR,Gf,LR,Xf,zf,Lc,Vf,Pc,Jf,Qf,Dc=g(()=>{"use strict";_t();N();ee();lt();Ds();xo();_r();da="unknown",ER=kc.object({userId:kc.string().min(1).default(da),userName:kc.string().min(1).default(da)}),Kf=new Set(["id","v","userId","userName"]),la=e=>{let t=Object.entries(e).filter(([o])=>!Kf.has(o));if(t.length!==1)return null;let n=t[0]?.[1];if(typeof n!="object"||n===null)return null;let r=n.id;return typeof r=="string"&&r.length>0?r:null},RR=/^[0-9a-hjkmnp-tv-z]{26}$/i,SR=e=>RR.test(e)?e.toUpperCase():e,Yf=e=>{let t=ca.basename(e,".jsonl"),n=t.indexOf("."),r=Tc(n===-1?t:t.slice(0,n)),o=n===-1?void 0:t.slice(n+1),s=ER.safeParse({userId:SR(r),userName:o});return s.success?d("Parsed event file actor",s.data):l(`Invalid event file name ${ca.basename(e)}: ${s.error.issues.map(i=>i.path.join(".")||i.message).join(", ")}`)},NR=e=>{let t=Object.keys(e).filter(n=>n!=="id"&&n!=="v");return t.length!==1?l(`Invalid persisted event: expected exactly 1 action key, got ${t.length}`):!t[0]||!(t[0]in e)?l("Invalid persisted event: action key is missing or invalid"):d("Resolved persisted action",t[0])},CR=(e,t)=>t in e,er=new Map,wR=3e5,AR=512,Fs=0,Mc=e=>e.entries.length+e.quarantined.length,TR=(e,t,n,r)=>{let o=er.get(e);o&&(Fs-=Mc(o));let s={stamp:t,entries:n,quarantined:r};er.delete(e),er.set(e,s),Fs+=Mc(s);for(let[i,c]of er){if(Fs<=wR&&er.size<=AR)break;i!==e&&(er.delete(i),Fs-=Mc(c))}},kR=()=>{er.clear(),Fs=0},MR=2n,Gf=1000000n,LR=e=>{try{let{size:t,mtimeNs:n}=Bs.statSync(e,{bigint:!0});return{value:`${t}:${n}`,settled:BigInt(Date.now())*Gf-n>MR*Gf}}catch{return null}},Xf=(e,t)=>{let n=Yf(e);if(a(n))return l(n.message);let r=LR(e),o=r?er.get(e):void 0;if(r&&o&&o.stamp===r.value){if(t)for(let m of o.quarantined)t.push(m);return d("Parsed persisted events file",[...o.entries])}let s;try{s=Bs.readFileSync(e,"utf8")}catch(m){if(Os(m))return d("Event file missing",null);throw m}let i=[],c=ca.basename(e),u=[],p=(m,f)=>{u.push({eventId:null,reason:"corrupt-line",detail:`${c}:${m} (${f})`,targetNodeId:null})};for(let[m,f]of s.split(`
43
+ `).entries()){let h=f.trim();if(!h)continue;let b;try{b=JSON.parse(h)}catch{p(m+1,"invalid JSON");continue}let E=Lf(b);if(a(E)){p(m+1,E.message);continue}i.push({...E.value,userId:n.value.userId,userName:n.value.userName})}if(t)for(let m of u)t.push(m);return r?.settled&&TR(e,r.value,i,u),d("Parsed persisted events file",[...i])},zf=(e,t)=>e<t?-1:e>t?1:0,Lc=(e,t)=>{let n=zf(e.id[0],t.id[0]);return n!==0?n:zf(JSON.stringify(e),JSON.stringify(t))},Vf=(e,t)=>{let n=new Map,r=new Map;for(let m of e){let f=m.id[0],h=m.id[1]??null;n.set(f,m);let b=r.get(h)??[];b.push(m),r.set(h,b)}for(let m of r.values())m.sort(Lc);let o=[],s=new Set,i=m=>{let f=[m];for(;f.length>0;){let h=f.pop(),b=h.id[0];if(s.has(b))continue;o.push(h),s.add(b);let E=r.get(b)??[];for(let S=E.length-1;S>=0;S--)f.push(E[S])}},c=(r.get(null)??[]).filter(m=>{let f=Object.keys(m).filter(h=>!Kf.has(h));return f.length===1&&f[0]===t});for(let m of c)i(m);let u=e.filter(m=>{let f=m.id[0],h=m.id[1]??null;return s.has(f)?!1:h===null||!n.has(h)}).sort(Lc);for(let m of u)i(m);let p=e.filter(m=>!s.has(m.id[0])).sort(Lc);for(let m of p)i(m);return o},Pc=e=>as(e.map(t=>{try{return IR(t.id[0])}catch{return null}})),Jf=(e,t)=>{let n=new Set,r=[],o=[],s=Pc(e);for(let i=0;i<e.length;i++){let c=e[i],u=c.id[0],p=c.id[1],m=s[i]??null;!(m!==null&&m<t)||p&&n.has(p)?(n.add(u),o.push(c)):r.push(c)}return{appliedEvents:r,unappliedEvents:o}},Qf=e=>{let t=new Set(e.actions),n=R=>t.has(R),r=R=>{let{userId:k,userName:M,...F}=R,j=NR(F);if(a(j))return l(j.message);let z=j.value,J=R.id?.[0];return J?CR(F,z)?d("Decoded persisted event",{id:J,action:z,payload:F[z],userId:k}):l(`Persisted event is missing payload for action: ${z}`):l("Persisted event is missing id")},o=(R,k)=>{let M=[],F=new Map,j=new Map;for(let z of R){if(!Ec(z.v)){j.set(z.v,(j.get(z.v)??0)+1),k?.push({eventId:z.id[0],reason:"unsupported-schema-version",detail:`v${z.v}`,targetNodeId:la(z)});continue}let J=r(z);if(a(J)){k?.push({eventId:z.id[0],reason:"invalid-payload",detail:J.message,targetNodeId:la(z)});continue}let se=J.value.action;if(!n(se)){F.set(se,(F.get(se)??0)+1),k?.push({eventId:z.id[0],reason:"unknown-action",detail:se,targetNodeId:la(z)});continue}let ze=e.readPayload(se,J.value.payload);if(a(ze)){k?.push({eventId:z.id[0],reason:"invalid-payload",detail:ze.message,targetNodeId:la(z)});continue}M.push(J.value)}if(F.size>0){let z=[...F.entries()].map(([J,se])=>`${J} (x${se})`).join(", ");ce.info(`Skipped events with unknown actions, likely created by a newer epiq version: ${z}. Upgrade to apply them.`)}if(j.size>0){let z=[...j.entries()].map(([J,se])=>`v${J} (x${se})`).join(", ");ce.info(`Skipped events with unsupported schema versions, created by a newer epiq version: ${z}. Upgrade to apply them.`)}return d("Decoded reconstructed events",M)},s=null;function i(R,k){let M=bt(R),F=Pr(R);if(!Bs.existsSync(M))return d("No events found",[]);let j=[],z=[];for(let se=1;;se++){j=[],z=[];let ze=!1;for(let q of Cc(M)){let le=Xf(ca.join(M,q),z);if(a(le))return l(le.message);if(le.value===null){if(se<Nc){ze=!0;break}continue}for(let gt of le.value)j.push(gt)}if(!ze)break}if(k)for(let se of z)k.push(se);let J=Vf(j,e.genesis);return s={root:R,signature:F,edge:J.at(-1)?.id?.[0]??null},d("All events loaded",J)}function c(R){let k=[],M=i(R,k);if(a(M))return l(M.message);let F=o(M.value,k);return a(F)?l(F.message):d("Loaded merged events",{events:F.value,unreadable:k})}function u(R){let k=i(R);return a(k)?l(k.message):d("Loaded event actors",k.value.map(({userId:M,userName:F})=>({userId:M,userName:F})))}function p(R){let k=new Map,M=bt(R),F;try{if(!Bs.existsSync(M))return k;F=Bs.readdirSync(M)}catch{return k}let j=new Set;for(let J of F){if(!J.endsWith(".jsonl"))continue;let se=Yf(J);if(a(se))continue;let{userId:ze,userName:q}=se.value;if(!ze||!q||q===da)continue;let le=k.get(ze);le!==void 0&&le!==q&&j.add(ze),k.set(ze,q)}if(j.size===0)return k;let z=u(R);if(a(z))return k;for(let{userId:J,userName:se}of z.value)j.has(J)&&(!se||se===da||k.set(J,se));return k}function m(R){let k=c(R);return a(k)?l(k.message):d("Loaded merged events",k.value.events)}function f(R,k){let M=i(R);if(a(M))return l(M.message);let{appliedEvents:F,unappliedEvents:j}=Jf(M.value,k),z=o(F);if(a(z))return l(z.message);let J=o(j);return a(J)?l(J.message):d("Loaded merged events before time",{appliedEvents:z.value,unappliedEvents:J.value})}function h(R=process.cwd()){let k=Pr(R);if(s&&s.root===R&&s.signature===k)return d("Loaded edge reference, unchanged",s.edge);let M=i(R);return a(M)?l(M.message):d("Loaded edge reference",M.value.at(-1)?.id?.[0]??null)}function b(R,k,M){if(!s||s.root!==R)return;let F=wc(R,s.signature,k);s=F===null?null:{root:R,signature:F,edge:M}}function E(){s=null,kR()}let S=R=>Vf(R,e.genesis);function w(R){let k=i(R);if(a(k))return l(k.message);let M=Pc(k.value);return d("Loaded effective event times",new Map(k.value.map((F,j)=>[F.id[0],M[j]??null])))}return{fromPersistedEvent:r,decodeReconstructedEvents:o,loadMergedEventsWithUnreadable:c,loadEventActors:u,loadActorNames:p,loadMergedEvents:m,loadMergedEventsBefore:f,getEdgeRef:h,advanceEdgeRef:b,clearEdgeCache:E,getSortedEvents:S,loadEffectiveEventTimes:w}}});var ua,B,Io,tr,nr,PR,Zf,ma=g(()=>{"use strict";_t();N();ua=(e,t)=>l(`${t.action.split(".").join(" ")+" failed, "+e.toLowerCase()}. Evt id: ${t.id}`),B=(e,t)=>({...ua(e,t),convergence:!0}),Io=e=>a(e)&&e.convergence===!0,tr=e=>{let t=e.filter(a);return{fatal:t.filter(n=>!Io(n)),skipped:t.filter(Io)}},nr=e=>{e.length!==0&&ce.info(`Skipped ${e.length} event(s) that could not be applied to this state: ${e.map(t=>t.message).join("; ")}`)},PR=e=>e.userId?.length?null:ua("Invalid user ID format",e),Zf=e=>{let t=null;function n(o,s=!1){let i=e.apply[o.action];if(!i)return l(`Unknown event action "${o.action}", likely created by a newer epiq version. Evt id: ${o.id}`);if(!e.replay.isInitialized()&&o.action!==e.genesis)return B(`${o.action} arrived before the state was initialized`,o);if(o.action===e.genesis&&t){if(t.genesisApplied)return B("the state is already initialized",o);t.genesisApplied=!0}let c;try{c=i(o)}catch(m){return B(`threw while materializing (${m instanceof Error?m.message:String(m)})`,o)}if(a(c))return c;let u=PR(o);if(u)return u;let p=e.replay.afterApply(o,{batched:t!==null,bypassLogging:s});return p||c}return{materialize:n,materializeAll:o=>{let s=e.replay.batch(()=>{let i=t===null;i&&(t={genesisApplied:!1});let c=!1;try{let u=o.map(p=>n(p));if(i){c=!0;let p=e.replay.flush();if(p)return o.map(()=>p)}return u}finally{i&&(t=null,c||e.replay.flush())}});return a(s)?o.map(()=>l(s.message)):s.value}}}});var eg,tg=g(()=>{"use strict";eg=e=>e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/\.jsonl/g,"-jsonl").replace(/^-+|-+$/g,"")||"unknown"});import ng from"node:fs";import Oc from"node:path";import{decodeTime as DR,monotonicFactory as OR}from"ulid";var _R,FR,BR,rr,rg,og,sg,pa=g(()=>{"use strict";_t();N();ee();tg();lt();Ds();Bt();xo();_r();_R=0xffffffffffff,FR=Ci,BR=e=>{let t=Date.now(),n;try{n=DR(e)}catch{return t}return n>=_R?t:n>t+FR?(ce.error("[persist] edge id is too far in the future; seeding from the wall clock instead",{edgeRef:e,edgeTime:n,now:t}),t):Math.max(t,n+1)},rr=({userId:e})=>`${eg(e)}.jsonl`,rg=(e,t)=>{let n;try{if(!ng.existsSync(e))return[t];n=ng.readdirSync(e)}catch{return[t]}let r=_s(t);return[...n.filter(s=>!s.endsWith(".jsonl")||s===t||Or(s)?!1:_s(s)===r).sort(),t]},og=(e,{userId:t})=>{let n=rr({userId:t});if(!/^(?!.*\.jsonl.*\.jsonl).*\.jsonl$/.test(n))return l(`Invalid event log file name: ${n}`);let o=Oc.join(bt(e),n);return d("Successfully resolved event log path",o)},sg=e=>{let t=OR();function n(o,s){let i;if(s&&s.current!==void 0)i=s.current;else{let u=e.getEdgeRef(o);if(a(u))return l(u.message);i=u.value}let c=i?t(BR(i)):t();return d("Minted event id",[c,i])}function r({event:o,rootDir:s,edge:i,id:c}){try{let u=yp(s);if(a(u))return u;let p=og(s,{userId:o.userId});if(a(p))return p;let m=Hf(s,Oc.basename(p.value)),f=c?d("Minted event id",c):n(s,i);if(a(f))return l(f.message);let[h,b]=f.value,E=Rc(Af(o),[h,b]);if(a(E))return l(E.message);qf(m,`${JSON.stringify(E.value)}
44
+ `),i&&(i.current=h);let S=Oc.basename(m);return e.advanceEdgeRef(s,S,h),Ff(s,S),d("Event persisted",{path:m,entry:E.value})}catch(u){let p=u instanceof Error?u.message:"Unknown persist error";return l(`Failed to persist event: ${p}`)}}return{mintEventId:n,persist:r}}});var ig,ag=g(()=>{"use strict";N();ig=(e,t,n)=>{function r(s,i,c){let u=n.mintEventId(i,c);if(a(u))return l(u.message);let p={...s,id:u.value[0]},m=t.materialize(p);if(m.status!==An.Success)return m;let f=n.persist({event:p,rootDir:i,edge:c,id:u.value});return a(f)?f:m}function o(s,i){if(s.length===0||!s[0])return l("No events provided");let c=e.write.readOnlyReason();if(c)return l(c);let u=e.replay.batch(()=>{let p={},m=e.write.beforeWrite(s[0],b=>r(b,i,p));if(a(m))return l(m.message);let f=s.map(b=>r(b,i,p)),h=f.filter(a);return h.length>0?l("Materialize and persist failed: "+h.map(b=>b.message).join(", ")):d("Materialization succeeded",f.map(b=>b.value))});return a(u)?l(u.message):u.value??l("Materialize and persist produced nothing")}return{materializeAndPersist:r,materializeAndPersistAll:o}}});var lg,cg=g(()=>{"use strict";Dc();ma();pa();ag();lg=e=>{let t=Zf(e),n=Qf(e),r=sg(n),o=ig(e,t,r);return{...t,...n,...r,...o}}});import{z as re}from"zod";var Y,on,or,fa,_c,$R,dg,ug=g(()=>{"use strict";N();Y=re.string().min(1),on=re.string(),or=re.string(),fa=re.looseObject({id:Y}),_c=re.looseObject({id:Y,name:on,parent:Y,rank:or}),$R={"init.workspace":re.looseObject({id:Y,name:on,rank:or}),"add.workspace":re.looseObject({id:Y,name:on,rank:or}),"add.board":_c,"add.swimlane":_c,"add.issue":_c,"add.field":re.looseObject({id:Y,name:on,parent:Y,rank:or}),"edit.title":re.looseObject({id:Y,name:on}),"delete.node":fa,"lock.node":fa,"move.node":re.looseObject({id:Y,parent:Y,rank:or}),"edit.description":re.looseObject({id:Y,md:re.string()}),"close.issue":re.looseObject({id:Y,parent:Y,rank:or}),"reopen.issue":re.looseObject({id:Y,parent:Y,rank:or}),"create.tag":re.looseObject({id:Y,name:on}),"tombstone.tag":fa,"restore.tag":re.looseObject({id:Y,name:on}),"create.contributor":re.looseObject({id:Y,name:on}),"rename.contributor":re.looseObject({id:Y,name:on}),"tombstone.contributor":fa,"restore.contributor":re.looseObject({id:Y,name:on}),"link.contributor.user":re.looseObject({contributor:Y}),"link.contributor.email":re.looseObject({contributor:Y,email:Y}),"unlink.contributor.email":re.looseObject({contributor:Y,email:Y}),"add.issue.assignee":re.looseObject({id:Y,assignee:Y}),"remove.issue.assignee":re.looseObject({id:Y,assignee:Y}),"add.issue.tag":re.looseObject({id:Y,tag:Y}),"remove.issue.tag":re.looseObject({id:Y,tag:Y}),"add.issue.comment":re.looseObject({id:Y,issue:Y,md:re.string()}),"edit.issue.comment":re.looseObject({id:Y,issue:Y,md:re.string()}),"delete.issue.comment":re.looseObject({id:Y,issue:Y}),"add.issue.attachment":re.looseObject({id:Y,issue:Y,hash:re.string().min(1),ext:re.string().min(1),name:on,bytes:re.number()}),"delete.issue.attachment":re.looseObject({id:Y,issue:Y}),"rebalance.children":re.looseObject({parent:Y,ranks:re.record(re.string(),or)})},dg=(e,t)=>{let r=$R[e].safeParse(t);return r.success?d("Payload is readable",void 0):l(`${e}: ${r.error.issues.map(o=>`${o.path.join(".")||"payload"} ${o.message}`).join(", ")}`)}});import{ulid as jR}from"ulid";var mg,pg=g(()=>{"use strict";N();pe();Ue();mg=(e,t)=>{if(e.action==="create.contributor"||e.action==="rename.contributor")return d("Contributor write already in flight",void 0);let{userId:n,userName:r}=de();if(!r||n!==e.userId)return d("Not this actor own write",void 0);let o=C.getContributor(e.userId),s={id:jR(),action:o?"rename.contributor":"create.contributor",payload:{id:e.userId,name:r},userId:e.userId};if(o&&(o.tombstoned||o.name===r))return d("Contributor name is current",void 0);let i=t(s);return a(i)?l(i.message):d("Contributor name recorded",void 0)}});var Ae,Eo=g(()=>{"use strict";Ae={DESCRIPTION:"Description",ASSIGNEES:"Assignees",TAGS:"Tags",HISTORY:"History",DIFF:"Diff",COMMENTS:"Comments",ATTACHMENTS:"Attachments"}});var V,$s,ft=g(()=>{"use strict";V=e=>e.slice(-7).toUpperCase(),$s=(e,t)=>{let n=t.replace(/-/g,"").trim().toUpperCase();return n?V(e).includes(n):!0}});var $e,sr=g(()=>{"use strict";me();ft();$e={workspace:(e,t,n)=>({id:e,title:t,rank:n,isDeleted:!1,props:{},context:ie.WORKSPACE,childRenderAxis:"vertical",parentNodeId:null,readonly:!0,log:[]}),board:(e,t,n,r,o=!1)=>({id:e,title:t,rank:r,isDeleted:!1,props:{ref:V(e)},context:ie.BOARD,childRenderAxis:"horizontal",parentNodeId:n,readonly:o,log:[]}),swimlane:(e,t,n,r)=>({id:e,title:t,rank:r,isDeleted:!1,props:{},context:ie.SWIMLANE,childRenderAxis:"vertical",childNavigationAcrossParents:!0,parentNodeId:n,readonly:!1,log:[]}),field:({id:e,name:t,parentNodeId:n,rank:r,props:o={},childRenderAxis:s="horizontal",isVirtual:i=!1})=>({id:e,title:t,rank:r,isDeleted:!1,props:o,context:ie.FIELD,childRenderAxis:s,parentNodeId:n,readonly:!1,log:[],isVirtual:i}),fieldList:({id:e,name:t,parentNodeId:n,rank:r,childRenderAxis:o="horizontal",isVirtual:s=!1})=>({id:e,title:t,rank:r,isDeleted:!1,props:{},context:ie.FIELD_LIST,childRenderAxis:o,parentNodeId:n,readonly:!1,log:[],isVirtual:s}),ticket:(e,t,n,r)=>({id:e,title:t,rank:r,isDeleted:!1,props:{ref:V(e)},context:ie.TICKET,childRenderAxis:"vertical",parentNodeId:n,readonly:!1,log:[]}),text:({id:e,name:t,parentNodeId:n,rank:r,readonly:o=!0,isVirtual:s=!0,disabled:i=!1})=>({id:e,title:t,rank:r,isDeleted:!1,props:i?{disabled:!0}:{},context:ie.TEXT,childRenderAxis:"vertical",parentNodeId:n,readonly:o,log:[],isVirtual:s}),comment:({id:e,name:t,parentNodeId:n,rank:r,props:o={},readonly:s=!0,isVirtual:i=!0})=>({id:e,title:t,rank:r,isDeleted:!1,props:o,context:ie.COMMENT,childRenderAxis:"vertical",parentNodeId:n,readonly:s,log:[],isVirtual:i})}});var js,fg,gg=g(()=>{"use strict";me();N();Eo();wt();pe();sr();D();ma();tn();js=(e,t,n)=>C.getNode(e)?B(`a node with id ${e} already exists`,n):t===e?B("a node cannot be its own parent",n):null,fg={"init.workspace":e=>{let{id:t,name:n,rank:r}=e.payload,o=$e.workspace(t,n,r),s=Us(o);if(a(s))return ua(s.message,e);let i=C.createNode(o);return a(i)?B(i.message??"Failed to initialize workspace",e):_l(i.value)?d("Workspace initialized",{action:e.action,result:i.value}):l("Unexpected create node return value")},"add.workspace":e=>{let{id:t,name:n,rank:r}=e.payload,o=js(t,void 0,e);if(o)return o;let s=C.createNode($e.workspace(t,n,r));return a(s)?B(s.message??"Failed to add workspace",e):_l(s.value)?d("Added workspace",{action:e.action,result:s.value}):l("Unexpected create node return value")},"add.board":e=>{let{id:t,name:n,parent:r,rank:o}=e.payload,s=js(t,r,e);if(s)return s;let i=C.createNode($e.board(t,n,r,o));return a(i)?B(i.message??"Unable to create board",e):Ir(i.value)?d("Added board",{action:e.action,result:i.value}):l("Unexpected create node return value")},"add.swimlane":e=>{let{id:t,name:n,parent:r,rank:o}=e.payload,s=js(t,r,e);if(s)return s;let i=C.createNode($e.swimlane(t,n,r,o));return a(i)?B(i.message??"Unable to create swimlane",e):xr(i.value)?d("Added swimlane",{action:e.action,result:i.value}):l("Unexpected create node return value")},"add.issue":e=>{let{id:t,name:n,parent:r,rank:o}=e.payload,s=js(t,r,e);if(s)return s;let i=C.createNode($e.ticket(t,n,r,o));return a(i)?B(i.message??"Unable to create issue",e):U(i.value)?d("Added issue",{action:e.action,result:i.value}):l("Unexpected create node return value")},"add.field":e=>{let{id:t,name:n,parent:r,val:o,rank:s}=e.payload,i=js(t,r,e);if(i)return i;let c=C.createNode($e.field({id:t,name:n,parentNodeId:r,rank:s,props:{value:o},childRenderAxis:n.includes(Ae.DESCRIPTION)?"vertical":"horizontal"}));return a(c)?B(c.message??`Unable to create field: ${n}`,e):nt(c.value)?d("Added field",{action:e.action,result:c.value}):l("Unexpected create node return value")},"edit.title":e=>{let{id:t,name:n}=e.payload;if(!C.getNode(t))return B(`Unable to locate node with id ${t}`,e);let o=C.renameNode(t,n);return a(o)?B(o.message??"Unable to edit title",e):d("Edited title",{action:e.action,result:o.value})},"delete.node":e=>{let{id:t}=e.payload,n=C.tombstoneNode(t);return a(n)?B(n.message??"Unable to delete node",e):d("Deleted node",{action:e.action,result:n.value})},"create.tag":e=>{let{id:t,name:n}=e.payload,r=C.createTag({id:t,name:n});return a(r)?B(r.message??"Unable to create tag",e):d("Tag added",{action:e.action,result:r.value})},"tombstone.tag":e=>{let{id:t}=e.payload,n=C.tombstoneTag(t);return a(n)?B(n.message??"Unable to delete tag",e):d("Tag tombstoned",{action:e.action,result:n.value})},"restore.tag":e=>{let{id:t,name:n}=e.payload,r=C.restoreTag(t,n);return a(r)?B(r.message??"Unable to restore tag",e):d("Tag restored",{action:e.action,result:r.value})},"create.contributor":e=>{let{id:t,name:n}=e.payload,r=C.createContributor({id:t,name:n});return a(r)?B(r.message??"Unable to create contributor",e):d("Contributor created",{action:e.action,result:r.value})},"rename.contributor":e=>{let{id:t,name:n}=e.payload,r=C.renameContributor(t,n);return a(r)?B(r.message??"Unable to rename contributor",e):d("Contributor renamed",{action:e.action,result:r.value})},"tombstone.contributor":e=>{let{id:t}=e.payload,n=C.tombstoneContributor(t);return a(n)?B(n.message??"Unable to remove contributor",e):d("Contributor tombstoned",{action:e.action,result:n.value})},"restore.contributor":e=>{let{id:t,name:n}=e.payload,r=C.restoreContributor(t,n);return a(r)?B(r.message??"Unable to restore contributor",e):d("Contributor restored",{action:e.action,result:r.value})},"add.issue.tag":e=>{let{id:t,tag:n}=e.payload,r=C.tag(t,n);return a(r)?B(r.message??"Unable to tag issue",e):d("Issue tagged",{action:e.action,result:{tag:n}})},"remove.issue.tag":e=>{let{id:t,tag:n}=e.payload,r=C.untag(t,n);return a(r)?B(r.message??"Unable to untag issue",e):d("Issue untagged",{action:e.action,result:{tag:n}})},"add.issue.assignee":e=>{let{id:t,assignee:n}=e.payload,r=C.assign(t,n);return a(r)?B(r.message??"Unable to assign issue",e):d("Assigned successfully",{action:e.action,result:{assignee:n}})},"remove.issue.assignee":e=>{let{id:t,assignee:n}=e.payload,r=C.unassign(t,n);return a(r)?B(r.message??"Unable to unassign issue",e):d("Issue unassigned",{action:e.action,result:{assignee:n}})},"move.node":e=>{let{id:t,parent:n,rank:r}=e.payload,o=C.moveNodeToRank({id:t,parentId:n,rank:r});return a(o)?B(o.message??"Failed to move node",e):d("Moved node",{action:e.action,result:o.value})},"edit.description":e=>{let{id:t,md:n}=e.payload,r=C.editValue(t,n);return a(r)?B(r.message??"Unable to edit description",e):d("Set node value",{action:e.action,result:r.value})},"close.issue":e=>{let{id:t,parent:n,rank:r}=e.payload,o=C.getNode(t);if(!o)return B("Unable to locate issue",e);if(!U(o))return B("Can only close issues",e);let s=C.getNode(we);if(!s)return B("Unable to locate target swimlane",e);if(n!==s.id)return B("Close target must be closed swimlane",e);let i=C.moveNodeToRank({id:t,parentId:n,rank:r});return a(i)?B(i.message??"Unable to close issue",e):d("Issue closed",{action:e.action,result:{id:t}})},"reopen.issue":e=>{let{id:t,parent:n,rank:r}=e.payload,o=C.getNode(t);if(!o)return B("Unable to locate issue",e);if(!U(o))return B("Can only reopen issues",e);let s=C.getNode(we);if(!s)return B("Unable to locate closed swimlane",e);if(n===s.id)return B("Cannot reopen issue into closed swimlane",e);if(!C.getNode(n))return B("Reopen parent no longer exists",e);let c=C.moveNodeToRank({id:t,parentId:n,rank:r});return a(c)?B(c.message??"Unable to reopen issue",e):d("Issue reopened",{action:e.action,result:{id:t}})},"lock.node":e=>{let{id:t}=e.payload,n=C.lockNode(t);return a(n)?B(n.message??"Unable to lock node",e):d("Node locked",{action:e.action,result:n.value})},"rebalance.children":e=>{let{parent:t,ranks:n}=e.payload;for(let[r,o]of Object.entries(n)){let s=C.getNode(r);if(!s)return B(`Unable to locate node ${r}`,e);if(s.parentNodeId!==t)return B(`Node ${r} is not child of ${t}`,e);let i=C.updateNode({...s,rank:o});if(a(i))return B(i.message??"Unable to rebalance child",e)}return d("Rebalanced children",{action:e.action,result:{parent:t}})},"add.issue.comment":e=>{let{id:t,issue:n,author:r,md:o}=e.payload,s=C.createComment({id:t,issue:n,authorId:r,md:o,deleted:!1});return a(s)?B(s.message??"Unable to add comment",e):d("Comment added",{action:e.action,result:{id:t,issue:n,author:r,md:o}})},"edit.issue.comment":e=>{let{id:t,issue:n,md:r}=e.payload,o=C.getComment(t);if(!o)return B("Unable to locate comment",e);if(o.issue!==n)return B("Comment does not belong to issue",e);let s=C.editComment(t,r);return a(s)?B(s.message??"Unable to edit comment",e):d("Comment edited",{action:e.action,result:{id:t,issue:n,md:r}})},"delete.issue.comment":e=>{let{id:t,issue:n}=e.payload,r=C.getComment(t);if(!r)return B("Unable to locate comment",e);if(r.issue!==n)return B("Comment does not belong to issue",e);let o=C.deleteComment(t);return a(o)?B(o.message??"Unable to delete comment",e):d("Comment deleted",{action:e.action,result:{id:t,issue:n}})},"add.issue.attachment":e=>{let{id:t,issue:n,hash:r,ext:o,name:s,bytes:i}=e.payload,c=C.createAttachment({id:t,issue:n,hash:r,ext:o,name:s,bytes:i,deleted:!1});return a(c)?B(c.message??"Unable to add attachment",e):d("Attachment added",{action:e.action,result:{id:t,issue:n,hash:r}})},"delete.issue.attachment":e=>{let{id:t,issue:n}=e.payload,r=C.getAttachment(t);if(!r)return B("Unable to locate attachment",e);if(r.issue!==n)return B("Attachment does not belong to issue",e);let o=C.deleteAttachment(t);return a(o)?B(o.message??"Unable to delete attachment",e):d("Attachment deleted",{action:e.action,result:{id:t,issue:n}})},"link.contributor.email":e=>{let{contributor:t,email:n}=e.payload;if(!zn(n))return B(`not an email address: ${n}`,e);let r=C.linkContributorEmail({email:n,contributor:t,authorId:e.userId});return a(r)?B(r.message??"Unable to link email",e):d("Email linked to contributor",{action:e.action,result:r.value})},"unlink.contributor.email":e=>{let{contributor:t,email:n}=e.payload,r=C.unlinkContributorEmail(n,t,e.userId);return a(r)?B(r.message??"Unable to unlink email",e):d("Email unlinked from contributor",{action:e.action,result:r.value})},"link.contributor.user":e=>{let{contributor:t}=e.payload,n=C.linkUserId({contributorId:t,userId:e.userId});return a(n)?B(n.message??"Unable to link contributor",e):d("Contributor linked to user",{action:e.action,result:{contributor:t,userId:e.userId}})}}});var hg,vg,UR,HR,Fc,WR,_n,qR,yg,Bc=g(()=>{"use strict";me();N();pe();D();$c();hg=e=>{let t=C.getNode(e);if(!t||!U(t)||t.isDeleted)return null;let n=ha(t);return a(n)?n:null},vg=e=>{if(!va())return null;for(let t of e){let n=hg(t);if(n)return n;let r=v().nodes[t]?.parentNodeId;if(!r)continue;let o=hg(r);if(o)return o}return null},UR=(e,t)=>{let n=C.getNode(e);n&&C.updateNode({...n,log:[...n.log??[],t]})},HR=e=>{let t=[e],n=v().nodes[e]?.parentNodeId;return n&&t.push(n),t},Fc=e=>{switch(e.action){case"add.issue.comment":case"edit.issue.comment":case"delete.issue.comment":case"add.issue.attachment":case"delete.issue.attachment":return[e.payload.issue];case"delete.node":case"edit.description":return HR(e.payload.id);case"init.workspace":case"add.workspace":case"add.board":case"add.swimlane":case"add.issue":case"add.field":case"edit.title":case"lock.node":case"move.node":case"close.issue":case"reopen.issue":case"add.issue.tag":case"remove.issue.tag":case"add.issue.assignee":case"remove.issue.assignee":return[e.payload.id];case"rebalance.children":return Object.keys(e.payload.ranks);case"create.tag":case"tombstone.tag":case"restore.tag":case"create.contributor":case"rename.contributor":case"link.contributor.user":case"link.contributor.email":case"unlink.contributor.email":default:return[]}},WR=e=>{Pe(t=>({...t,eventLog:[...t.eventLog,e]}))},_n=null,qR=e=>{for(let[t,n]of e.nodeLog){let r=C.getNode(t);r&&C.updateNode({...r,log:[...r.log??[],...n]})}return e.appLog.length>0&&Pe(t=>({...t,eventLog:[...t.eventLog,...e.appLog]})),vg([...e.virtualNodeIds])},yg={isInitialized:()=>Ut(),batch:e=>ga(e),afterApply(e,{batched:t,bypassLogging:n}){let r=[...new Set(Fc(e))];if(t){_n??={appLog:[],nodeLog:new Map,virtualNodeIds:new Set};for(let o of r){if(!n){let s=_n.nodeLog.get(o);s?s.push(e):_n.nodeLog.set(o,[e])}if(va()){_n.virtualNodeIds.add(o);let s=v().nodes[o]?.parentNodeId;s&&_n.virtualNodeIds.add(s)}}return n||_n.appLog.push(e),null}return n||(r.forEach(o=>UR(o,e)),WR(e)),vg(r)},flush(){if(!_n)return null;let e=_n;return _n=null,qR(e)}}});var he,bg=g(()=>{"use strict";N();Ue();yr();he=()=>{let{userName:e,userId:t}=de();return e?t?Ni(t)?ss(e)?d("Successfully resolved actor ID",{userId:t,userName:e}):l("Invalid user name in config"):l("Invalid user ID in config"):l("User ID not configured"):l("User name not configured")}});var GR,zR,Hs,Fn,V0,K0,sn,xg,Fr,Br,jc,Y0,X0,J0,Q0,Uc,Z0,Ig,eO,_,$=g(()=>{"use strict";Ds();cg();ug();D();pg();$t();gg();Bc();bg();Ds();Dc();ma();pa();GR={genesis:"init.workspace",actions:xc,readPayload:dg,apply:fg,replay:yg,write:{readOnlyReason:()=>{let e=v();return e.readOnly?e.readOnlyReason??"Cannot change the board while time travelling":null},beforeWrite:mg}},zR=lg(GR),{materialize:Hs,materializeAll:Fn,fromPersistedEvent:V0,decodeReconstructedEvents:K0,loadMergedEventsWithUnreadable:sn,loadEventActors:xg,loadActorNames:Fr,loadMergedEvents:Br,loadMergedEventsBefore:jc,getEdgeRef:Y0,advanceEdgeRef:X0,clearEdgeCache:J0,getSortedEvents:Q0,loadEffectiveEventTimes:Uc,mintEventId:Z0,persist:Ig,materializeAndPersist:eO,materializeAndPersistAll:_}=zR});var $r,Hc,Eg=g(()=>{"use strict";ft();$r=e=>e.trim().toLocaleLowerCase(),Hc=(e,t)=>$r(e).includes($r(t))});var VR,KR,Rg,Sg,YR,XR,Ng,Cg=g(()=>{"use strict";D();ft();Eg();VR=e=>{let{tags:t}=v();return(e.props.tags??[]).map(n=>t[n]).filter(n=>n!==void 0&&!n.tombstoned).map(n=>n.name)},KR=e=>{let{contributors:t}=v();return(e.props.assignees??[]).map(n=>{let r=t[n];return r?r.name:void 0}).filter(n=>!!n)},Rg=null,Sg=new Map,YR=()=>{let e=v().eventLog??[];if(e===Rg)return Sg;let t=new Map;for(let n of e){if(!n.userId)continue;let r=n.payload;for(let o of[r.id,r.issue]){if(typeof o!="string")continue;let s=t.get(o)??new Set;s.add(n.userId),t.set(o,s)}}return Rg=e,Sg=t,t},XR=e=>{let{contributors:t}=v(),n=YR().get(e.id);return n?[...n].map(r=>t[r]?.name).filter(r=>!!r):[]},Ng=(e,t)=>{let n=$r(t.value);if(!n)return!0;switch(t.target){case"title":return Hc(e.title??"",n);case"description":return Hc(e.props.description??"",n);case"tag":return VR(e).map($r).some(o=>o.includes(n));case"assignee":return KR(e).map($r).some(o=>o.includes(n));case"actor":return XR(e).map($r).some(o=>o.includes(n));case"ref":return $s(e.id,t.value);default:return!0}}});var Wc,JR,wg,Ag,Tg,qc=g(()=>{"use strict";me();Cg();Wc=(e,t)=>e.rank<t.rank?-1:e.rank>t.rank?1:0,JR=(e,t)=>!!e&&!e.isDeleted&&e.parentNodeId===t,wg=(e,t)=>Object.values(e).filter(n=>JR(n,t)).sort(Wc),Ag=(e,t)=>{let n={};for(let r of Object.values(e)){if(U(r)&&t.length>0&&!t.every(s=>Ng(r,s))||!r.parentNodeId||r.isDeleted)continue;let o=n[r.parentNodeId];o?o.push(r):n[r.parentNodeId]=[r]}for(let r of Object.keys(n))n[r].sort(Wc);return n},Tg=(e,t)=>{let n={};for(let r of Object.values(e)){if(!r.parentNodeId||r.isDeleted||!t.has(r.parentNodeId))continue;let o=n[r.parentNodeId];o?o.push(r):n[r.parentNodeId]=[r]}for(let r of Object.keys(n))n[r].sort(Wc);return n}});var kg,ya,Me,Mg,Lg,xn,Bn,jt=g(()=>{"use strict";Tf();$();N();D();qc();bo();kg=e=>ya(Me(e),{at:"end"}),ya=(e,t={at:"end"})=>{let n=o=>a(o)?d("Rank space exhausted",{rank:"",needsRebalance:!0}):d("Resolved rank",{rank:o.value,needsRebalance:!1});if(e.length===0)return n(pt(void 0,void 0));let r=()=>n(pt(e[e.length-1]?.rank,void 0));switch(t.at){case"start":{let o=e[0];return o?n(pt(void 0,o.rank)):l("Unable to resolve first sibling")}case"end":{let o=e[e.length-1];return o?n(pt(o.rank,void 0)):l("Unable to resolve last sibling")}case"before":{let o=Mg(e,t.sibling),s=o<0?void 0:e[o];if(!s)return r();let i=o>0?e[o-1]:void 0;return n(pt(i?.rank,s.rank))}case"after":{let o=Mg(e,t.sibling),s=o<0?void 0:e[o];if(!s)return r();let i=o<e.length-1?e[o+1]:void 0;return n(pt(s.rank,i?.rank))}}},Me=e=>{let t=v();if(!Pg()&&t.filters.length===0){let n=t.renderedChildrenIndex[e];if(n)return n}return wg(t.nodes,e)},Mg=(e,t)=>e.findIndex(n=>n.id===t),Lg=(e,t,n={at:"end"})=>ya(Me(t).filter(r=>r.id!==e),n),xn=(e,t,n,r,o)=>{let s=Lg(t,e,n);if(a(s))return s;if(!s.value.needsRebalance)return d("Resolved rank",s.value.rank);let i=Ic(e,r);if(a(i))return i;let c=_([i.value],o);if(a(c))return c;let u=Lg(t,e,n);return a(u)?u:u.value.needsRebalance?l("Rank rebalance failed to create space"):d("Resolved rank after rebalance",u.value.rank)},Bn=(e,t,n)=>{let r=kg(e);if(a(r))return r;if(!r.value.needsRebalance)return d("Resolved rank",r.value.rank);let o=Ic(e,t);if(a(o))return o;let s=_([o.value],n);if(a(s))return s;let i=kg(e);return a(i)?i:i.value.needsRebalance?l("Rank rebalance failed to create space"):d("Resolved rank after rebalance",i.value.rank)}});var Ws,H,Dg,Og,_g,It=g(()=>{"use strict";D();Ws=5,H={exit(){process.exit(0)},enterChildNode(){let e=v(),t=e.contextNode,n=Math.max(0,e.selectedIndex),r=be(t.id),o=r[n];o&&(t.context==="FIELD"&&r.length===0||o.context==="COMMENT"||o.context==="TEXT"||H.navigate({contextNode:o,selectedIndex:be(o.id).length?0:-1}))},enterParentNode(){let{contextNode:e,nodes:t}=v();if(!e.parentNodeId){logger.info("Missing parent node id");return}let n=t[e.parentNodeId];if(!n){logger.error("Parent not found");return}let r=be(n.id),o=r.findIndex(({id:i})=>i===e.id),s=r.length===0?-1:o>=0?o:0;H.navigate({contextNode:n,selectedIndex:s})},navigateToNextItem:()=>Dg(1),navigateToPreviousItem:()=>Dg(-1),jumpToNextItem:()=>Og(Ws),jumpToPreviousItem:()=>Og(-Ws),navigateToNextContainer:()=>_g(1),navigateToPreviousContainer:()=>_g(-1),navigate:({contextNode:e,selectedIndex:t})=>{A({contextNodeId:e.id,selectedIndex:t})}},Dg=e=>{let{selectedIndex:t,contextNode:n}=v(),r=be(n.id).length;if(r===0)return;let s=(Math.max(0,t)+e+r)%r;H.navigate({selectedIndex:s,contextNode:n})},Og=e=>{let{selectedIndex:t,contextNode:n}=v(),r=be(n.id).length;if(r===0)return;let o=Math.max(0,t),s=Math.min(Math.max(o+e,0),r-1);H.navigate({selectedIndex:s,contextNode:n})},_g=e=>{let{contextNode:t,nodes:n,selectedIndex:r}=v();if(!t.childNavigationAcrossParents)return;if(!t.parentNodeId){logger.error("Missing parent node id");return}let o=n[t.parentNodeId];if(!o)return;let s=be(o.id),i=s.findIndex(h=>h.id===t.id);if(i<0)return;let c=s.at(i+e)??s.at(0);if(!c)return;let u=be(c.id),p=Math.max(0,u.length-1),m=Math.min(Math.max(0,r),p),f=u.length?m:-1;H.navigate({contextNode:c,selectedIndex:f})}});var Bg,$g,QR,ba,jg,Fg,ZR,Ug,Hg=g(()=>{"use strict";me();N();jt();D();It();Bg=(e,t)=>t<=0?-1:Math.max(0,Math.min(e,t-1)),$g=()=>{let{contextNode:e,selectedIndex:t,selectedNode:n}=v();return{contextNodeId:e.id,selectedNodeId:n?.id??null,parentNodeId:e.id,selectedIndex:t}},QR=e=>{let t=v().nodes[e];return!!t&&!t.isDeleted&&nt(t)&&t.childRenderAxis==="vertical"},ba=(e,t)=>{let{nodes:n}=v(),r=n[e];if(!r||r.isDeleted)return!1;let o=Me(r.id);return H.navigate({contextNode:r,selectedIndex:Bg(t,o.length)}),!0},jg=e=>{let{nodes:t}=v(),n=t[e];if(!n||n.isDeleted)return!1;let r=n.parentNodeId;if(!r)return ba(n.id,0);let o=t[r];if(!o||o.isDeleted)return!1;let i=Me(o.id).findIndex(c=>c.id===n.id);return i>=0?(H.navigate({contextNode:o,selectedIndex:i}),!0):jg(o.id)},Fg=e=>{let{nodes:t}=v(),n=e,r=new Set;for(;n&&!r.has(n);){if(r.add(n),jg(n))return!0;n=t[n]?.parentNodeId}return!1},ZR=e=>{if(!e)return!1;let t=v().nodes[e];return!!t&&!t.isDeleted},Ug=e=>{let{nodes:t,rootNodeId:n}=v();if(QR(e.contextNodeId)&&ba(e.contextNodeId,e.selectedIndex))return d("Restored navigation inside text container",null);if(ZR(e.selectedNodeId)&&e.selectedNodeId&&Fg(e.selectedNodeId))return d("Restored navigation to selected node or ancestor",null);if(ba(e.contextNodeId,e.selectedIndex))return d("Restored navigation to previous container",null);if(e.parentNodeId&&ba(e.parentNodeId,e.selectedIndex))return d("Restored navigation to previous parent",null);if(Fg(e.contextNodeId))return d("Restored navigation to previous container or ancestor",null);let r=t[n];if(!r||r.isDeleted)return l("Unable to restore navigation");let o=Me(r.id);return H.navigate({contextNode:r,selectedIndex:Bg(e.selectedIndex,o.length)}),d("Restored navigation to root",null)}});import{monotonicFactory as eS,ulid as In}from"ulid";function tS(){let e=ke();if(a(e))return l("Unable to boot. State not initialized");let t=e.value,n=Object.values(t.nodes).find(s=>s.context==="WORKSPACE");if(!n)return l("No workspace found in event log");let[r]=be(n.id),[o]=r?be(r.id):[];if(o){let s=t.renderedChildrenIndex?.[o.id]??[];return d("Resolved boot nav target",{contextNode:o,selectedIndex:s.length>0?0:-1})}else return r?d("Resolved boot nav target",{contextNode:r,selectedIndex:0}):d("Resolved boot nav target",{contextNode:n,selectedIndex:0})}function nS(){let e=tS();return a(e)?e:H.navigate(e.value)}function Wg({userId:e,userName:t}){let n=qs(),r=qs(),o=qs(),s=qs(),i=qs(),c=pt(void 0,void 0);if(a(c))return c;let u=pt(void 0,void 0);if(a(u))return u;let p=pt(u.value,void 0);if(a(p))return p;let m=pt(void 0,void 0);if(a(m))return m;let f=pt(m.value,void 0);if(a(f))return f;let h=pt(f.value,void 0);if(a(h))return h;let b=pt(void 0,void 0);return a(b)?b:d("Created default events",[{id:In(),userId:e,action:"init.workspace",payload:{id:n,name:"Workspace",rank:c.value}},{id:In(),userId:e,action:"create.contributor",payload:{id:e,name:t}},{id:In(),userId:e,action:"add.board",payload:{id:r,name:"Default",parent:n,rank:u.value}},{id:In(),userId:e,action:"add.swimlane",payload:{id:o,name:"Todo",parent:r,rank:m.value}},{id:In(),userId:e,action:"add.swimlane",payload:{id:s,name:"In progress",parent:r,rank:f.value}},{id:In(),userId:e,action:"add.swimlane",payload:{id:i,name:"Done",parent:r,rank:h.value}},{id:In(),userId:e,action:"add.board",payload:{id:Gi,name:"Closed",parent:n,rank:p.value}},{id:In(),userId:e,action:"add.swimlane",payload:{id:we,name:"Closed",parent:Gi,rank:b.value}},{id:In(),userId:e,action:"lock.node",payload:{id:Gi}},{id:In(),userId:e,action:"lock.node",payload:{id:we}}])}function En(e,t=[]){if(rS())return d("Skipped boot while checked out at a historical point",null);if(!e.length){let s=$e.workspace("temporary-uninitialized-workspace","Workspace","a0"),i=Us(s);return a(i)?i:(A({hasProjectDefinition:!1,mode:x.DEFAULT}),d("Booted uninitialized workspace placeholder",null))}if(!e.some(s=>s.action==="init.workspace"))return l("Initialized Epiq project has no workspace init event");let n=Fn(e),{fatal:r,skipped:o}=tr(n);return r.length>0?l(`Materializing failed:
45
+ ${r.map(s=>s.message).join(`
46
+ `)}`):(nr(o),nS(),A({hasProjectDefinition:!0}),oS(t),d("State booted successfully",null))}var qs,rS,oS,jr=g(()=>{"use strict";_t();It();Oe();N();sr();D();bo();$();tn();qs=eS();rS=()=>{let e=ke();if(a(e))return!1;let{timeMode:t}=e.value;return t==="peek"||t==="replay"},oS=e=>{if(e.length===0)return;let t=e.filter(r=>r.reason==="corrupt-line"||r.reason==="invalid-payload"),n=e.filter(r=>r.reason==="unsupported-schema-version"||r.reason==="unknown-action");if(n.length>0){let r=[...new Set(n.map(o=>o.detail))].join(", ");ce.info(`This build cannot read ${n.length} event(s) in the log (${r}). They are skipped, so anything they changed may be out of date until you upgrade.`)}if(t.length>0){let r=[...new Set(t.map(o=>o.detail))].join(", ");ce.info(`Skipped ${t.length} corrupt line(s) in the event log (${r}). The rest of the board loaded normally; those events are unrecoverable.`)}}});import{WebSocket as sS}from"ws";var iS,qg,Gg=g(()=>{"use strict";iS=new Set,qg=e=>{let t=JSON.stringify(e);for(let n of iS)n.readyState===sS.OPEN&&n.send(t)}});var xa,Ro,Ur,Gc,Ia,je,Gs=g(()=>{"use strict";Gg();N();D();xa=e=>{Ut()&&(A({syncStatus:e}),qg({type:"sync-status",payload:e}))},Ro=(e="Syncing...")=>{xa({status:"syncing",msg:e})},Ur=(e="Synced")=>{xa({status:"synced",msg:e})},Gc=e=>{xa({status:"failed",msg:e})},Ia=e=>{xa({status:"offline",msg:e})},je=e=>(Gc(e),l(e))});var So,zg,ve,Ea=g(()=>{"use strict";N();So=(e,t)=>(logger.error(`[boot:${e}] ${t}`),l(`[boot:${e}] ${t}`)),zg=e=>{if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},ve=(e,t)=>(a(t)&&logger.info(`[${e}]:failed`,t.message),t)});import Ra from"node:fs";import Vg from"node:path";var st,Kg,aS,zc,lS,Yg,Vc=g(()=>{"use strict";mn();Ke();N();ee();Zt();st=".epiq/project.json",Kg=e=>Vg.join(e,st),aS=e=>{if(!Ra.existsSync(Kg(e)))return d("State branch carries no identity yet",null);let t=Tt(e);return a(t)?l(`On the state branch: ${t.message}`):d("Read the state branch identity",t.value)},zc=(e,t)=>{try{let n=Kg(e);return Ra.mkdirSync(Vg.dirname(n),{recursive:!0}),Ra.writeFileSync(n,JSON.stringify(t,null,2)+`
47
+ `,"utf8"),d("Wrote the state branch identity",void 0)}catch(n){return l(n instanceof Error?`Failed to write the state branch identity: ${n.message}`:"Failed to write the state branch identity")}},lS=({checkout:e,branch:t,stateBranch:n})=>[`This checkout's ${st} names project ${e.projectId}`,`(created ${e.createdAt}), but the state branch ${n}`,`belongs to project ${t.projectId} (created ${t.createdAt}).`,"","The branch holds the board, so its id is the one that counts. Point the","checkout at it and commit the change:","",` git show ${n}:${st} > ${st}`,"","A second id is minted when init runs in a checkout that has no","project file while the state branch already exists; nothing on the","board is lost by it, but every checkout has to agree on one."].join(`
48
+ `),Yg=({repoRoot:e,stateBranchRoot:t,stateBranch:n})=>{if(!Ra.existsSync(io(e)))return d("No project file to compare","no-checkout-file");let r=Tt(e);if(a(r))return l(r.message);let o=aS(t);if(a(o))return l(o.message);if(o.value===null){let s=zc(t,r.value);return a(s)?l(s.message):d("Stamped the state branch with this project","stamped")}return o.value.projectId!==r.value.projectId?l(lS({checkout:r.value,branch:o.value,stateBranch:n})):d("The checkout and the state branch agree","matched")}});import Rn from"node:fs";import zs from"node:path";var No,Xg,Jg,Qg,cS,Zg,dS,uS,eh,Kc=g(()=>{"use strict";Ke();N();_r();xo();ee();No=e=>e.split(`
49
+ `).filter(t=>t.trim().length>0),Xg=e=>{let t=zs.join(e,ct,Ln);try{if(!Rn.existsSync(t))return d("No events directory",[]);let n=Rn.readdirSync(t).filter(r=>r.endsWith(".jsonl")).filter(r=>No(Rn.readFileSync(zs.join(t,r),"utf8")).length>0);return d("Looked for stranded event logs",n)}catch(n){return l(`Unable to check ${t} for event logs before deleting it: ${n instanceof Error?n.message:String(n)}`)}},Jg=e=>zs.join(e,ct,Ln),Qg=e=>{let t=Jg(e),n=new Map;try{if(!Rn.existsSync(t))return n;for(let r of Rn.readdirSync(t))if(r.endsWith(".jsonl")&&!Or(r))try{n.set(r,No(Rn.readFileSync(zs.join(t,r),"utf8")))}catch(o){if(!Os(o))throw o}}catch{return n}return n},cS=e=>{try{let t=JSON.parse(e);return typeof t=="object"&&t!==null}catch{return!1}},Zg=(e,t)=>{if(t.size===0)return[];let n=Jg(e),r=[];for(let[o,s]of t){if(s.length===0)continue;let i=zs.join(n,o);try{let c=Rn.existsSync(i)?Rn.readFileSync(i,"utf8"):null,u=new Set(c===null?[]:No(c)),p=s.filter(f=>!u.has(f)).filter(cS);if(p.length===0)continue;Rn.mkdirSync(n,{recursive:!0});let m=c!==null&&c.length>0&&!c.endsWith(`
50
+ `);Rn.appendFileSync(i,`${m?`
49
51
  `:""}${p.join(`
50
52
  `)}
51
- `,"utf8"),o.push(`${r} (${p.length})`)}catch{continue}}return o},LE=(e,t)=>{let n=new Set(lr(t));return lr(e).filter(o=>!n.has(o))},PE=(e,t,n)=>[`Refusing to commit ${e}: it is missing ${t.length} of the ${n} event(s) already committed.`,"","The event log is append-only, so a line can never legitimately go","missing. The working copy on disk is damaged; committing it would","publish that damage to everyone who pulls, and the log carries no way","to undo it.","","Nothing has been committed. The committed history is intact \u2014 recover","the file from it before syncing again:",` git show HEAD:${e}`,"","First dropped event:",` ${t[0]?.slice(0,200)??"<none>"}`].join(`
52
- `),Lf=async({stateBranchRoot:e,relativePath:t,workingContent:n})=>{let o=await Le({args:["show",`HEAD:${t}`],cwd:e});if(o.exitCode!==0)return d("No committed log to compare against",void 0);let r=LE(o.stdout,n);return r.length>0?l(PE(t,r,lr(o.stdout).length)):d("Event log only grew",void 0)}});import On from"node:fs";import Fn from"node:path";var DE,Df,Pf,OE,hc,Ts,FE,_E,to,BE,$E,jE,UE,ea,Of,Ff,_f,ks,Bf,Ms=g(()=>{"use strict";To();w();fc();$t();wi();Cn();gc();rt();Ke();DE="[epiq:init-repo]",Df=async e=>{let t=await Le({args:["rev-parse","--verify","--quiet","HEAD"],cwd:e});if(t.exitCode===0)return d("Initial commit already exists",!1);if(!(t.exitCode===1&&t.stdout.trim()===""&&t.stderr.trim()===""))return l(["Could not determine whether the repository has any commits, so nothing was written.",`git rev-parse exited ${t.exitCode}`,t.stderr.trim()].filter(Boolean).join(`
53
- `));ce.info("Creating initial commit");let o=await W({args:["hash-object","-w","-t","tree","/dev/null"],cwd:e});if(a(o))return l(o.message);let r=await W({args:["commit-tree",o.value.stdout.trim(),"-m",DE],cwd:e});if(a(r))return l(r.message);let s=await W({args:["update-ref","HEAD",r.value.stdout.trim()],cwd:e});return a(s)?l(s.message):d("Created initial commit",!0)},Pf=e=>e.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/^[-/.]+|[-/.]+$/g,"")||"unknown",OE=async e=>{let t=await Ti(e);if(a(t))return l(t.message);let n=await zm(e);return a(n)?l(n.message):d("Built sync commit message",`[sync|branch:${Pf(t.value)}:sha:${Pf(n.value)}]`)},hc=async({repoRoot:e,stateBranchName:t})=>{ce.info(`Creating ${t}`);let n=await W({args:["commit-tree",tp,"-m","[epiq:init-state-branch]"],cwd:e});if(a(n))return l(`Failed to create state branch commit
54
- ${n.message}`);let o=n.value.stdout.trim(),r=await W({args:["update-ref",`refs/heads/${t}`,o],cwd:e});return a(r)?l(`Failed to create ${t}
55
- ${r.message}`):d("Created state branch",!0)},Ts=async({repoRoot:e,stateBranchName:t})=>{let n=await Ai({repoRoot:e,branch:t});if(a(n))return l(`Ensure local state branch failed
56
- `+n.message);if(n.value)return d("Local state branch already exists",!1);let o=await kn({repoRoot:e});if(a(o))return l(`Ensure local state branch failed
57
- `+o.message);let r=o.value,s=r?await ms({repoRoot:e,branch:t}):d("No remote, no remote state branch",!1);if(a(s))return l(`Ensure local state branch failed
58
- `+s.message);let i=s.value;if(r&&i){let c=await Ne.fetch({cwd:e,remote:Tt,branch:t});if(a(c))return l(`Failed to fetch ${t} from remote
59
- ${c.message}`)}if(i){let c=await W({args:["branch","--track",t,`${Tt}/${t}`],cwd:e});return a(c)?l(`Failed to create local ${t} from remote
60
- ${c.message}`):d("Created local state branch from remote",!0)}return hc({repoRoot:e,stateBranchName:t})},FE=async({repoRoot:e,branch:t})=>{let n=await W({args:["worktree","list","--porcelain"],cwd:e});if(a(n))return l(n.message);let o=n.value.stdout.split(`
61
- `),r=null;for(let s of o){if(s.startsWith("worktree ")){r=s.slice(9);continue}if(s===`branch refs/heads/${t}`&&r)return d("Found worktree for branch",r)}return d("No worktree found for branch",null)},_E=async({repoRoot:e,stateBranchRoot:t,stateBranchName:n})=>{let o=gs(Fn.dirname(t));if(a(o))return l(`Failed to create state branch worktree
62
- `+o.message);if(On.existsSync(t)&&!On.existsSync(Fn.join(t,".git"))){let s=Af(t);if(a(s))return l(s.message);if(s.value.length>0)return l([`Refusing to delete ${t}.`,"","It is not a usable worktree \u2014 it has no .git \u2014 but it still holds",`${s.value.length} event log(s) with content:`,...s.value.map(i=>` ${i}`),"","Deleting it would destroy them, and with no .git here there is no","committed copy to recover from. Move the directory aside and","salvage the logs before letting epiq recreate the worktree."].join(`
63
- `));ce.info("Removing broken state branch worktree path"),sp(t)}ce.info("Creating state branch worktree");let r=await Ne.worktreeAdd({cwd:e,worktreeRoot:t,branch:n});return a(r)?l(`Failed to create state branch worktree
64
- ${r.message}`):d("Created state branch worktree",!0)},to=async({repoRoot:e,stateBranchRoot:t,stateBranchName:n})=>{let o=await $E({repoRoot:e,stateBranchRoot:t,stateBranchName:n});if(a(o))return o;let r=Cf({repoRoot:e,stateBranchRoot:t,stateBranch:n});return a(r)?l(r.message):(r.value==="stamped"&&ce.info("Stamped the state branch with this project\u2019s identity"),o)},BE=(e,t)=>{let n=tr(No());return Fn.dirname(e)===n&&Fn.dirname(t)===n},$E=async({repoRoot:e,stateBranchRoot:t,stateBranchName:n})=>{let o=await FE({repoRoot:e,branch:n});if(a(o))return l(o.message);let r=tr(t),s=o.value?tr(o.value):null;if(s&&s===r&&On.existsSync(s))return d("State branch already checked out in expected worktree",!1);if(s&&s!==r&&BE(s,r))return l([`The state branch ${n} is checked out under project ${Fn.basename(s)}, but this checkout names project ${Fn.basename(r)}.`,"","Two ids for one branch means a checkout minted a second identity for","a board that already existed. Nothing on the board is lost by it, but",`every checkout has to agree on one: compare ${st} here`,`with \`git show ${n}:${st}\`, and keep the branch's.`].join(`
65
- `));if(s&&s!==r){let u=await Xm(s);if(a(u))return l(u.message);if(u.value||Ip(s))return l([`Refusing to move the state branch worktree away from ${s}.`,"","It holds changes that are not committed yet, which for this","branch means events no sync has published. Removing it would","destroy them outright \u2014 there is no stash or reflog to recover","a deleted worktree from.","",`This worktree is expected at ${r}, so something else is`,"using a different EPIQ_GLOBAL_DIR against the same repository.","Sync from that location first, or point both at the same one."].join(`
53
+ `,"utf8"),r.push(`${o} (${p.length})`)}catch{continue}}return r},dS=(e,t)=>{let n=new Set(No(t));return No(e).filter(r=>!n.has(r))},uS=(e,t,n)=>[`Refusing to commit ${e}: it is missing ${t.length} of the ${n} event(s) already committed.`,"","The event log is append-only, so a line can never legitimately go","missing. The working copy on disk is damaged; committing it would","publish that damage to everyone who pulls, and the log carries no way","to undo it.","","Nothing has been committed. The committed history is intact \u2014 recover","the file from it before syncing again:",` git show HEAD:${e}`,"","First dropped event:",` ${t[0]?.slice(0,200)??"<none>"}`].join(`
54
+ `),eh=async({stateBranchRoot:e,relativePath:t,workingContent:n})=>{let r=await Le({args:["show",`HEAD:${t}`],cwd:e});if(r.exitCode!==0)return d("No committed log to compare against",void 0);let o=dS(r.stdout,n);return o.length>0?l(uS(t,o,No(r.stdout).length)):d("Event log only grew",void 0)}});import $n from"node:fs";import jn from"node:path";var mS,nh,th,pS,Yc,Vs,fS,gS,ir,hS,vS,yS,bS,Sa,rh,oh,sh,Ks,ih,Ys=g(()=>{"use strict";_r();N();Vc();_t();Oi();mn();Kc();rt();Ke();mS="[epiq:init-repo]",nh=async e=>{let t=await Le({args:["rev-parse","--verify","--quiet","HEAD"],cwd:e});if(t.exitCode===0)return d("Initial commit already exists",!1);if(!(t.exitCode===1&&t.stdout.trim()===""&&t.stderr.trim()===""))return l(["Could not determine whether the repository has any commits, so nothing was written.",`git rev-parse exited ${t.exitCode}`,t.stderr.trim()].filter(Boolean).join(`
55
+ `));ce.info("Creating initial commit");let r=await W({args:["hash-object","-w","-t","tree","/dev/null"],cwd:e});if(a(r))return l(r.message);let o=await W({args:["commit-tree",r.value.stdout.trim(),"-m",mS],cwd:e});if(a(o))return l(o.message);let s=await W({args:["update-ref","HEAD",o.value.stdout.trim()],cwd:e});return a(s)?l(s.message):d("Created initial commit",!0)},th=e=>e.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/^[-/.]+|[-/.]+$/g,"")||"unknown",pS=async e=>{let t=await Bi(e);if(a(t))return l(t.message);let n=await ep(e);return a(n)?l(n.message):d("Built sync commit message",`[sync|branch:${th(t.value)}:sha:${th(n.value)}]`)},Yc=async({repoRoot:e,stateBranchName:t})=>{ce.info(`Creating ${t}`);let n=await W({args:["commit-tree",dp,"-m","[epiq:init-state-branch]"],cwd:e});if(a(n))return l(`Failed to create state branch commit
56
+ ${n.message}`);let r=n.value.stdout.trim(),o=await W({args:["update-ref",`refs/heads/${t}`,r],cwd:e});return a(o)?l(`Failed to create ${t}
57
+ ${o.message}`):d("Created state branch",!0)},Vs=async({repoRoot:e,stateBranchName:t})=>{let n=await Fi({repoRoot:e,branch:t});if(a(n))return l(`Ensure local state branch failed
58
+ `+n.message);if(n.value)return d("Local state branch already exists",!1);let r=await Mn({repoRoot:e});if(a(r))return l(`Ensure local state branch failed
59
+ `+r.message);let o=r.value,s=o?await ps({repoRoot:e,branch:t}):d("No remote, no remote state branch",!1);if(a(s))return l(`Ensure local state branch failed
60
+ `+s.message);let i=s.value;if(o&&i){let c=await Ne.fetch({cwd:e,remote:At,branch:t});if(a(c))return l(`Failed to fetch ${t} from remote
61
+ ${c.message}`)}if(i){let c=await W({args:["branch","--track",t,`${At}/${t}`],cwd:e});return a(c)?l(`Failed to create local ${t} from remote
62
+ ${c.message}`):d("Created local state branch from remote",!0)}return Yc({repoRoot:e,stateBranchName:t})},fS=async({repoRoot:e,branch:t})=>{let n=await W({args:["worktree","list","--porcelain"],cwd:e});if(a(n))return l(n.message);let r=n.value.stdout.split(`
63
+ `),o=null;for(let s of r){if(s.startsWith("worktree ")){o=s.slice(9);continue}if(s===`branch refs/heads/${t}`&&o)return d("Found worktree for branch",o)}return d("No worktree found for branch",null)},gS=async({repoRoot:e,stateBranchRoot:t,stateBranchName:n})=>{let r=hs(jn.dirname(t));if(a(r))return l(`Failed to create state branch worktree
64
+ `+r.message);if($n.existsSync(t)&&!$n.existsSync(jn.join(t,".git"))){let s=Xg(t);if(a(s))return l(s.message);if(s.value.length>0)return l([`Refusing to delete ${t}.`,"","It is not a usable worktree \u2014 it has no .git \u2014 but it still holds",`${s.value.length} event log(s) with content:`,...s.value.map(i=>` ${i}`),"","Deleting it would destroy them, and with no .git here there is no","committed copy to recover from. Move the directory aside and","salvage the logs before letting epiq recreate the worktree."].join(`
65
+ `));ce.info("Removing broken state branch worktree path"),fp(t)}ce.info("Creating state branch worktree");let o=await Ne.worktreeAdd({cwd:e,worktreeRoot:t,branch:n});return a(o)?l(`Failed to create state branch worktree
66
+ ${o.message}`):d("Created state branch worktree",!0)},ir=async({repoRoot:e,stateBranchRoot:t,stateBranchName:n})=>{let r=await vS({repoRoot:e,stateBranchRoot:t,stateBranchName:n});if(a(r))return r;let o=Yg({repoRoot:e,stateBranchRoot:t,stateBranch:n});return a(o)?l(o.message):(o.value==="stamped"&&ce.info("Stamped the state branch with this project\u2019s identity"),r)},hS=(e,t)=>{let n=oo(Nr());return jn.dirname(e)===n&&jn.dirname(t)===n},vS=async({repoRoot:e,stateBranchRoot:t,stateBranchName:n})=>{let r=await fS({repoRoot:e,branch:n});if(a(r))return l(r.message);let o=oo(t),s=r.value?oo(r.value):null;if(s&&s===o&&$n.existsSync(s))return d("State branch already checked out in expected worktree",!1);if(s&&s!==o&&hS(s,o))return l([`The state branch ${n} is checked out under project ${jn.basename(s)}, but this checkout names project ${jn.basename(o)}.`,"","Two ids for one branch means a checkout minted a second identity for","a board that already existed. Nothing on the board is lost by it, but",`every checkout has to agree on one: compare ${st} here`,`with \`git show ${n}:${st}\`, and keep the branch's.`].join(`
67
+ `));if(s&&s!==o){let u=await sp(s);if(a(u))return l(u.message);if(u.value||Wf(s))return l([`Refusing to move the state branch worktree away from ${s}.`,"","It holds changes that are not committed yet, which for this","branch means events no sync has published. Removing it would","destroy them outright \u2014 there is no stash or reflog to recover","a deleted worktree from.","",`This worktree is expected at ${o}, so something else is`,"using a different EPIQ_GLOBAL_DIR against the same repository.","Sync from that location first, or point both at the same one."].join(`
66
68
  `));ce.info("Moving state branch worktree to expected location");let p=await Ne.worktreeRemove({cwd:e,worktreeRoot:s});if(a(p))return l(`Failed to remove existing state branch worktree
67
- ${p.message}`)}if(s&&!On.existsSync(s)){ce.info("Pruning stale state branch worktree");let u=await Ne.worktreePrune({cwd:e});if(a(u))return l(`Failed to prune stale worktrees
68
- ${u.message}`)}let i=await Gm({repoRoot:e,worktreeRoot:t});if(a(i))return l(i.message);let c=On.existsSync(t);if(i.value&&c)return d("State branch worktree already exists",!1);if(i.value&&!c){ce.info("Pruning missing registered state branch worktree");let u=await Ne.worktreePrune({cwd:e});if(a(u))return l(`Failed to prune stale worktrees
69
- ${u.message}`)}return _E({repoRoot:e,stateBranchRoot:t,stateBranchName:n})},jE=async({stateBranchRoot:e,stateBranchName:t})=>{let n=await Ti(e);if(a(n))return l(n.message);if(n.value===t)return d("State branch already checked out",!1);(await Le({cwd:e,args:["rebase","--abort"]})).exitCode===0&&ce.info("Aborted stale state branch rebase");let r=await Ne.checkout({cwd:e,branch:t});return a(r)?l(`Failed to checkout ${t}
70
- ${r.message}`):d("Checked out state branch",!0)},UE=async({repoRoot:e,stateBranchRoot:t})=>{let n=await Fl(t);if(a(n))return l(n.message);if(n.value)return d("State branch upstream already configured",!1);let o=await kn({repoRoot:t});if(a(o))return l(o.message);if(!o.value)return d("No remote available for state branch upstream",!1);let r=vt(e);if(a(r))return r;let s=r.value,i=await ms({repoRoot:t,branch:s});if(a(i))return l(i.message);if(!i.value)return d("Remote state branch missing; upstream will be configured on first push",!1);ce.info(`Configuring ${s} upstream`);let c=await Ne.fetch({cwd:t,remote:Tt,branch:s});if(a(c))return l(`Failed to fetch ${s}
71
- ${c.message}`);let u=await Ne.setUpstream({cwd:t,branch:s,upstream:`${Tt}/${s}`});return a(u)?l(`Failed to set state branch upstream
72
- ${u.message}`):d("Configured state branch upstream",!0)},ea=async({stateBranchRoot:e,eventFileName:t})=>{let n=np(t),o=Fn.join(e,n);if(!On.existsSync(o))return d("No event file to stage",null);let r=await Lf({stateBranchRoot:e,relativePath:n,workingContent:On.readFileSync(o,"utf8")});if(a(r))return l(r.message);let s=await Ne.stage({cwd:e,pathspec:[n]});return a(s)?l(`Failed to stage state branch event file
73
- ${s.message}`):d("Staged state branch event file",n)},Of=async({stateBranchRoot:e})=>{let t=op(),n=Fn.join(e,t);if(!On.existsSync(n))return d("No media directory to stage",null);let o=await Ne.stage({cwd:e,pathspec:[t],ignoreRemoval:!0});return a(o)?l(`Failed to stage state branch media files
74
- ${o.message}`):d("Staged state branch media files",t)},Ff=async({stateBranchRoot:e})=>{let t=[_l(),Bl(),st].filter(o=>On.existsSync(Fn.join(e,o)));if(t.length===0)return d("No event log config to stage",[]);let n=await Ne.stage({cwd:e,pathspec:t});return a(n)?l(`Failed to stage event log config
75
- ${n.message}`):d("Staged event log config",t)},_f=async({repoRoot:e,stateBranchRoot:t,pathspec:n})=>{let o=await OE(e);return a(o)?l(`Create state branch sync commit failed
76
- `+o.message):nr({cwd:t,message:o.value,pathspec:n})},ks=async({repoRoot:e,stateBranchRoot:t})=>{let n=await Fl(t);if(a(n))return l(n.message);let o=vt(e);if(a(o))return o;let r=o.value,s=n.value?await Ne.push({cwd:t}):await Ne.push({cwd:t,remote:Tt,branch:r,setUpstream:!0});if(a(s))return l(`Failed during state branch push
77
- ${s.message}`);let i=!`${s.value.stdout}${s.value.stderr}`.includes("Everything up-to-date");return d(i?"Pushed state branch":"Remote already up to date",i)},Bf=async({repoRoot:e,stateBranchRoot:t,ensureUpstream:n})=>{let o=!1,r=vt(e);if(a(r))return r;let s=r.value,i=[hs(),await Ts({repoRoot:e,stateBranchName:s}),await to({repoRoot:e,stateBranchRoot:t,stateBranchName:s}),await jE({stateBranchRoot:t,stateBranchName:s}),await ap(t),n?await UE({stateBranchRoot:t,repoRoot:e}):d("Skipped state branch upstream bootstrap",!1)];for(let c of i){if(a(c))return l(c.message);o=o||!!c.value}return d(n?"Bootstrapped state storage":"Bootstrapped state storage readonly",o)}});import ta from"node:fs";import yc from"node:os";import HE from"node:path";var WE,$f,qE,GE,zE,Uf,vc,jf,VE,na,bc=g(()=>{"use strict";w();Ke();$t();WE="epiq-sync.lock",$f=600*1e3,qE=e=>{try{let t=JSON.parse(e);return typeof t.pid!="number"||typeof t.hostname!="string"||typeof t.startedAt!="number"||typeof t.operation!="string"?null:t}catch{return null}},GE=e=>{try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}},zE=e=>e&&(e.hostname!==yc.hostname()||GE(e.pid))?Date.now()-e.startedAt>$f:!0,Uf=e=>`${e.operation} (pid ${e.pid} on ${e.hostname}, started ${new Date(e.startedAt).toISOString()})`,vc=e=>{try{return qE(ta.readFileSync(e,"utf8"))}catch{return null}},jf=(e,t)=>{let n={pid:process.pid,hostname:yc.hostname(),startedAt:Date.now(),operation:t};try{return ta.writeFileSync(e,JSON.stringify(n),{flag:"wx"}),!0}catch{return!1}},VE=async({worktreeRoot:e,operation:t})=>{let n=await Ol(e);if(a(n))return l(n.message);let o=HE.join(n.value,WE),r=()=>{try{let c=vc(o);c&&c.pid===process.pid&&ta.rmSync(o)}catch{}};if(jf(o,t))return d("Acquired sync lock",{acquired:!0,release:r});let s=vc(o);if(!zE(s))return d("Sync lock is held",{acquired:!1,heldBy:s});ce.info(`Breaking an abandoned sync lock: ${s?Uf(s):"unreadable lock file"}`);try{ta.rmSync(o,{force:!0})}catch{}if(jf(o,t))return d("Acquired sync lock after breaking a stale one",{acquired:!0,release:r});let i=vc(o);return d("Sync lock taken by another process",{acquired:!1,heldBy:i??{pid:-1,hostname:yc.hostname(),startedAt:Date.now(),operation:"unknown"}})},na=async({worktreeRoot:e,operation:t,fn:n})=>{let o=await VE({worktreeRoot:e,operation:t});if(a(o))return l(o.message);if(!o.value.acquired)return ce.info(`Skipping ${t}: the state worktree is held by ${Uf(o.value.heldBy)}`),d("State worktree is held by another process",null);let{release:r}=o.value;try{return d("Ran under the sync lock",await n())}finally{r()}}});import KE from"node:fs";var YE,XE,xc,Hf,Ic,oa,ra=g(()=>{"use strict";w();Cs();Hi();ee();Qi();Cn();rt();Ke();Ms();gc();To();bc();YE=async({cwd:e,ensureUpstream:t})=>{logger.debug("[sync] ensureSyncReady:start",{cwd:e,ensureUpstream:t});let n=ye("getRepoRootDir",await kt(e));if(a(n))return l(n.message);let o=n.value;logger.debug("[sync] repo root",o);let r=ye("getStateBranchRoot",Ie({repoRoot:o}));if(a(r))return l(r.message);let s=r.value;logger.debug("[sync] state branch root",s),logger.debug("[sync] bootstrapping state branch storage",{repoRoot:o,stateBranchRoot:s,ensureUpstream:t});let i=ye("bootstrapStateBranchStorage",await Bf({repoRoot:o,stateBranchRoot:s,ensureUpstream:t}));if(a(i))return l(i.message);logger.debug("[sync] bootstrap result",{bootstrapped:i.value,stateBranchRoot:s}),logger.debug("[sync] checking state branch git operation",{stateBranchRoot:s});let c=ye("hasInProgressGitOperation(stateBranchRoot)",await Ci(s));if(a(c))return l(c.message);if(logger.debug("[sync] state branch git operation check result",{inProgress:c.value}),c.value)return logger.info("[sync] state branch git operation in progress"),l("Cannot sync while a git operation is in progress in the state branch");logger.debug("[sync] ensuring state branch layout",{repoRoot:o,stateBranchRoot:s});let u=ye("ensureStateBranchLayout",ip(o,s));return a(u)?l(u.message):(logger.debug("[sync] state branch layout ready"),logger.debug("[sync] ensureSyncReady:done",{repoRoot:o,stateBranchRoot:s,bootstrapped:i.value}),d("Sync preconditions satisfied",{repoRoot:o,stateBranchRoot:s,bootstrapped:i.value}))},XE=async({repoRoot:e,stateBranchRoot:t,ownEventFileName:n})=>{logger.debug("[sync] committing own event file from state branch",{ownEventFileName:n,stateBranchRoot:t}),logger.debug("[sync] staging own event file",{stateBranchRoot:t,ownEventFileName:n});let o=[];for(let p of Dp(bt(t),n)){let m=ye("stageStateBranchOwnEventFile",await ea({stateBranchRoot:t,eventFileName:p}));if(a(m))return l(m.message);o.push(m.value)}let r=ye("stageStateBranchMediaFiles",await Of({stateBranchRoot:t}));if(a(r))return l(r.message);let s=ye("stageStateBranchEventConfig",await Ff({stateBranchRoot:t}));if(a(s))return l(s.message);let i=[...o,r.value,...s.value].filter(p=>p!==null);if(i.length===0)return d("Nothing to stage",{createdCommit:!1});let c=ye("hasStagedChanges(after stage)",await Jm(t,i));if(a(c))return l(c.message);if(logger.debug("[sync] state branch change check after stage result",{changed:c.value}),!c.value)return logger.info("[sync] no own event file changes to commit"),d("No own event file changes to commit",{createdCommit:!1});logger.debug("[sync] creating sync commit");let u=ye("createStateBranchSyncCommit",await _f({repoRoot:e,stateBranchRoot:t,pathspec:i}));return a(u)?l(u.message):(logger.debug("[sync] created sync commit",u.value),d("Committed own event file",{createdCommit:!0,commitSha:u.value}))},xc=(e,t="offline")=>{let n=e.createdCommit?`Committed locally, ${t}`:t==="offline"?"Offline":"No remote";return Ji(n),d(n,{...e,pulled:!1,pushed:!1,offline:!0})},Hf=async({cwd:e=process.cwd(),ownEventFileName:t})=>{if(logger.debug("[sync] syncEpiqWithRemote:start",{cwd:e,ownEventFileName:t}),t.includes("/")||t.includes("\\"))return logger.error("[sync] invalid own event file name: contains path separator",{ownEventFileName:t}),l("Own event file must be a file name, not a path");if(!t.endsWith(".jsonl"))return logger.error("[sync] invalid own event file name: missing .jsonl suffix",{ownEventFileName:t}),l("Own event file must end with .jsonl");ir();let n=ye("ensureSyncReady",await YE({cwd:e,ensureUpstream:!0}));if(a(n))return $e(n.message);let{repoRoot:o,stateBranchRoot:r,bootstrapped:s}=n.value,i=ye("isDetachedHead(stateBranchRoot)",await Qm(r));if(a(i))return $e(i.message);if(logger.debug("[sync] detached state branch check result",{detached:i.value}),i.value)return $e("Cannot run :sync while the state branch is in detached HEAD state");let c=!1,u,p=!1,m=!1,f=ye("getStateBranch",vt(o));if(a(f))return $e(f.message);let h=f.value;logger.debug("[sync] resolved state branch",{stateBranch:h,stateBranchRoot:r});let x=ye("flushPendingLogs",Oi(r,t));a(x)&&logger.error(`[sync] ${x.message}`);let E=ye("commitOwnEventFileToStateBranch",await XE({repoRoot:o,stateBranchRoot:r,ownEventFileName:t}));if(a(E))return $e(E.message);c=E.value.createdCommit,u=E.value.commitSha;let S=ye("hasRemote",await kn({repoRoot:r}));if(a(S))return $e(S.message);if(!S.value)return xc({repoRoot:o,stateBranchRoot:r,createdCommit:c,commitSha:u,bootstrapped:s},"no remote");let C=ye("pullBranchRebaseIfPresent",await fs({cwd:r,branch:h}));if(a(C))return ps(C.message)?xc({repoRoot:o,stateBranchRoot:r,createdCommit:c,commitSha:u,bootstrapped:s}):$e(C.message);p=C.value;let R=ye("isAheadOfUpstream",await Ym(r));if(a(R))return $e(R.message);if(c||s||R.value){logger.info("[sync] pushing state branch",{createdCommit:c,bootstrapped:s,stateBranchRoot:r});let A=ye("pushStateBranch",await ks({stateBranchRoot:r,repoRoot:o}));if(a(A)&&Vm(A.message)){let L=ye("pullBranchRebaseIfPresent(retry)",await fs({cwd:r,branch:h}));if(a(L))return $e(L.message);p=p||L.value,A=ye("pushStateBranch(retry)",await ks({stateBranchRoot:r,repoRoot:o}))}if(a(A))return ps(A.message)?xc({repoRoot:o,stateBranchRoot:r,createdCommit:c,commitSha:u,bootstrapped:s}):$e(A.message);m=A.value}if(c){logger.debug("[sync] resolving final sync commit sha",{stateBranchRoot:r});let A=ye("git rev-parse HEAD",await W({args:["rev-parse","HEAD"],cwd:r}));if(a(A))return $e(A.message);u=A.value.stdout.trim(),logger.debug("[sync] final sync commit sha",u)}return Do(m?"Synced and pushed":p||c?"Synced local state":"Already synced"),logger.debug("[sync] syncEpiqWithRemote:done"),d("Synced event logs with state branch",{repoRoot:o,stateBranchRoot:r,createdCommit:c,commitSha:u,pulled:p,pushed:m,bootstrapped:s,offline:!1})},Ic=async(e,t)=>{let n=kf(e);try{return await t()}finally{let o=Mf(e,n);o.length>0&&logger.error(`[sync] restored event log lines git dropped from the worktree: ${o.join(", ")}`)}},oa=async e=>{let t=e.cwd??process.cwd(),n=await kt(t);if(a(n))return $e(n.message);let o=Ie({repoRoot:n.value});if(a(o))return $e(o.message);let r=o.value;if(!KE.existsSync(r))return Hf(e);let s=await na({worktreeRoot:r,operation:"sync",fn:()=>Ic(r,()=>Hf(e))});return a(s)?$e(s.message):s.value===null?d("Another process is syncing this board",{repoRoot:n.value,stateBranchRoot:r,createdCommit:!1,pulled:!1,pushed:!1,bootstrapped:!1,offline:!1,skipped:!0}):s.value}});var vn,sa,JE,Ec,Wf,ia=g(()=>{"use strict";xf();Po();$();$();Oe();w();O();Cs();Qi();ra();vn=null,sa=async()=>{if(logger.debug("[sync] syncAndReloadState enter",{hasPromise:!!vn,currentStatus:v().syncStatus?.status,currentMessage:v().syncStatus?.msg}),vn)return logger.debug("[sync] syncAndReloadState joining existing promise"),vn;logger.debug("[sync] syncAndReloadState creating promise"),vn=JE();try{let e=await vn;return logger.debug("[sync] syncAndReloadState promise resolved",{success:!a(e),message:(a(e),e.message),statusAfterResolve:v().syncStatus?.status,statusMessageAfterResolve:v().syncStatus?.msg}),a(e)&&v().syncStatus?.status==="syncing"&&(logger.debug("[sync] syncAndReloadState correcting stale syncing status"),T({syncStatus:{msg:e.message,status:"failed"}})),e}catch(e){let t=e instanceof Error?e.message:String(e);return logger.error("[sync] syncAndReloadState promise threw",{message:t,error:e}),vn||l(t)}finally{logger.debug("[sync] syncAndReloadState clearing promise",{statusBeforeClear:v().syncStatus?.status,statusMessageBeforeClear:v().syncStatus?.msg}),vn=null}},JE=async()=>{logger.debug("[sync] syncAndReloadStateUnsafe:start",{mode:v().mode,syncStatus:v().syncStatus});let e=Wf();if(e)return logger.debug("[sync] syncAndReloadStateUnsafe:blocked by mode",{mode:v().mode,message:e.message,syncStatus:v().syncStatus}),e;if(vn)return vn;logger.debug("[sync] syncAndReloadState:start");let t=ye("resolveActorId",ge());if(a(t)||!t.value)return logger.info("[sync] unable to resolve actor id",{message:a(t)?t.message:"Missing actor id"}),l("Unable to resolve event log path");T({syncStatus:{msg:"Reloading synced state",status:"syncing"}}),logger.debug("[sync] sync status patched to syncing",{syncStatus:v().syncStatus});let n=Qn(t.value);logger.debug("[sync] resolved own event file name",{ownEventFileName:n}),logger.debug("[sync] syncEpiqWithRemote:start");let o=ye("syncEpiqWithRemote",await oa({ownEventFileName:n}));if(logger.debug("[sync] syncEpiqWithRemote:result",{success:!a(o),message:(a(o),o.message)}),a(o))return logger.error("[sync] syncAndReloadState:sync failed",o.message),T({syncStatus:{msg:"Sync failed",status:"failed"}}),logger.debug("[sync] sync status patched to failed after sync failure",{syncStatus:v().syncStatus}),$e(`Unable to sync state. ${o.message}`);let{stateBranchRoot:r,offline:s}=o.value,i=Ec(r);return a(i)?i:(T({hasProjectDefinition:!0,syncStatus:s?{msg:"Committed locally, offline",status:"offline"}:{msg:"Synced",status:"synced"}}),logger.debug("[sync] syncAndReloadState:done",{syncStatus:v().syncStatus}),d("Synced",!0))},Ec=e=>{logger.debug("[sync] loading merged events after sync",{stateBranchRoot:e});let t=ye("loadMergedEvents",nn(e));if(logger.debug("[sync] loadMergedEvents:result",{success:!a(t),message:(a(t),t.message),count:a(t)?void 0:t.value.events.length}),a(t))return T({syncStatus:{msg:"Reload failed",status:"failed"}}),logger.debug("[sync] sync status patched to failed after load failure",{syncStatus:v().syncStatus}),l(`Unable to load events. ${t.message}`);logger.debug("[sync] loaded merged events after sync",{count:t.value.events.length});let n=Wf();if(n)return logger.debug("[sync] syncAndReloadStateUnsafe:blocked by late mode check",{mode:v().mode,message:n.message,syncStatus:v().syncStatus}),n;let o=vf(),r=v().filters;if(logger.debug("[sync] captured navigation anchor",{navigationAnchor:o,selectedNodeId:v().selectedNode?.id,contextNodeId:v().contextNode?.id,selectedNodeIsVirtual:v().selectedNode?.isVirtual,contextNodeIsVirtual:v().contextNode?.isVirtual}),!v().selectedNode?.isVirtual&&!v().contextNode?.isVirtual){logger.debug("[sync] bootStateFromEventLog:start",{eventCount:t.value.events.length});let i=ye("bootStateFromEventLog",gn(t.value.events,t.value.unreadable));if(logger.debug("[sync] bootStateFromEventLog:result",{success:!a(i),message:(a(i),i.message)}),a(i))return T({syncStatus:{msg:"Reload failed",status:"failed"}}),logger.debug("[sync] sync status patched to failed after boot failure",{syncStatus:v().syncStatus}),l(`Unable to boot synced state. ${i.message}`)}else logger.debug("[sync] skipped bootStateFromEventLog for virtual node",{selectedNodeIsVirtual:v().selectedNode?.isVirtual,contextNodeIsVirtual:v().contextNode?.isVirtual});logger.debug("[sync] booted state from synced events"),T({filters:r}),logger.debug("[sync] restoreNavigationAnchor:start");let s=ye("restoreNavigationAnchor",bf(o));return logger.debug("[sync] restoreNavigationAnchor:result",{success:!a(s),message:a(s)?s.message:"Navigation restored",selectedNodeId:v().selectedNode?.id,contextNodeId:v().contextNode?.id}),a(s)?(T({syncStatus:{msg:"Reload failed",status:"failed"}}),logger.debug("[sync] sync status patched to failed after restore failure",{syncStatus:v().syncStatus}),s):d("Reloaded state from event log",null)},Wf=()=>v().mode===b.DEFAULT?null:(logger.debug("[sync] failReloadIfNotDefaultMode",{mode:v().mode,syncStatus:v().syncStatus}),T({syncStatus:{msg:"Reload skipped while editing",status:"pending"}}),l("Will not re-materialize if not in default mode, to not lose edit data"))});var cr,qf,Gf,Rc,Sc,Ls,Nc,QE,zf,ZE,Vf,aa=g(()=>{"use strict";w();Fe();O();ia();cr=3e3,qf=e=>{let t=Number(e.trim());return!Number.isFinite(t)||!Number.isInteger(t)||t<cr?null:t},Gf=0,Sc=!1,Ls=!1,Nc=()=>{if(Sc)return!0;let e=Me();return a(e)?!1:e.value.syncStatus.status==="syncing"},QE=()=>{let e=le().autoSyncIntervalMs??1e4,t=Date.now()-Gf;return Math.max(0,e-t)},zf=()=>{Rc||(Rc=setTimeout(async()=>{if(Rc=void 0,!!jt()){if(Nc()){Ls=!0;return}Ls=!1,await ZE()}},QE()))},ZE=async()=>{if(v().readOnly||v().timeMode==="peek"||v().timeMode==="replay")return l("Cannot auto-sync while peeking");if(!jt())return l("Cannot auto-sync before state is initialized");if(Nc())return Ls=!0,l("Sync already in progress");Sc=!0,Gf=Date.now(),T({syncStatus:{msg:"Auto-syncing",status:"syncing"}});try{return await sa()}finally{Sc=!1,Ls&&zf()}},Vf=()=>{jt()&&(Ls=!0,!Nc()&&zf())}});import Ps from"node:fs";import Ds from"node:path";import{z as dr}from"zod";var la,eR,tR,nR,Yf,Xf,Kf,Jf,Qf,Zf,oR,ca,Os,ur=g(()=>{"use strict";w();Jt();Ni();ee();la="recent-projects.json",eR=20,tR=dr.object({projectId:dr.string().min(1),root:dr.string().min(1),lastOpenedAt:dr.number().finite()}),nR=dr.object({projects:dr.array(tR)}),Yf=()=>Ds.join(wn(),la),Xf=e=>Ds.basename(e)||e,Kf=e=>{let t=Ds.resolve(e);try{return Ps.realpathSync(t)}catch{return t}},Jf=(e,t)=>t.lastOpenedAt-e.lastOpenedAt,Qf=e=>{if(!ys(e.root))return!1;let t=un(e.root);return!a(t)&&t.value===e.projectId},Zf=()=>{let e=Yf();if(!Ps.existsSync(e))return d("No recent projects recorded",[]);let t;try{t=JSON.parse(Ps.readFileSync(e,"utf8"))}catch(o){return l(`Invalid ${la}: ${o instanceof Error?o.message:String(o)}`)}let n=nR.safeParse(t);return n.success?d("Read recent projects",n.data.projects):l(`Invalid ${la} shape: ${n.error.issues.map(o=>o.path.join(".")||o.message).join(", ")}`)},oR=e=>{let t=Yf();try{Ps.mkdirSync(Ds.dirname(t),{recursive:!0}),Ps.writeFileSync(t,JSON.stringify({projects:e},null,2)+`
78
- `,"utf8")}catch(n){return l(`Unable to write ${la}: ${n instanceof Error?n.message:String(n)}`)}return d("Recorded recent project",e)},ca=({exclude:e}={})=>{let t=Zf();if(a(t))return t;let n=e===void 0?null:Kf(e);return d("Listed recent projects",t.value.filter(o=>n===null||Kf(o.root)!==n).filter(Qf).sort(Jf))},Os=({root:e,now:t=Date.now()})=>{let n=Ds.resolve(e),o=un(n);if(a(o))return l(o.message);let r=o.value,s=Zf(),i=a(s)?[]:s.value,c=[{projectId:r,root:n,lastOpenedAt:t},...i.filter(u=>u.projectId!==r&&u.root!==n)].filter(Qf).sort(Jf).slice(0,eR);return oR(c)}});var wc,eg,tg,Cc=g(()=>{"use strict";wc=null,eg=e=>{wc=e},tg=e=>wc?wc(e):[]});var ng,og,mr,Fs=g(()=>{"use strict";ng=[],og=e=>{ng=e},mr=()=>ng});var _s,Ac,rg,sg,Tc,ig,ag,lg,Oo=g(()=>{"use strict";wt();w();Jt();Fe();Cc();Fs();ee();_s=()=>{let e=le(),t=!!e.userName?.trim(),n=!!e.preferredEditor?.trim(),o=e.autoSync===!0||e.autoSync===!1,r=rg(),s=r.length>0?null:Ac(),i=s!==null&&(e.declinedEmailBoards??[]).includes(s),c=r.length>0||i||s===null;return{isSetupDone:n&&t&&o&&c,isSetPreferredEditor:n,isSetUserName:t,userName:e.userName,preferredEditor:e.preferredEditor,autoSync:e.autoSync===void 0?null:e.autoSync,isSetAutoSync:o,isSetEmails:c,claimedEmails:r,emailSetupDeclined:i}},Ac=()=>{let e=we(process.cwd());if(a(e))return null;let t=un(e.value);return a(t)?null:t.value||null},rg=()=>{let{userId:e}=le();return e?tg(e):[]},sg=()=>rg().length>0,Tc=()=>{let e=we(process.cwd());if(a(e))return!1;let t=At(e.value);return Dt(t)},ig=e=>e===!0?"on":e===!1?"off":null,ag=e=>e==="on"?!0:e==="off"?!1:null,lg=()=>{let e=_s();if(!e.isSetUserName)return"config username ";if(!e.isSetPreferredEditor)return"config editor ";if(!e.isSetAutoSync)return"config autoSync ";if(!Tc())return"init";if(!e.isSetEmails){let{gitEmail:t}=le(),n=mr()[0]??t;return n&&Gn(n)?`config emails ${n}`:"config emails "}return null}});var rR,sR,yn,bn,da,ua,pr=g(()=>{"use strict";me();w();pe();O();rR=e=>e.props.tags??[],sR=e=>e.props.assignees??[],yn=e=>rR(e).map(t=>N.getTag(t)).filter(t=>!!t),bn=e=>sR(e).map(t=>N.getContributor(t)).filter(t=>!!t),da=()=>{let{breadCrumb:e,selectedNode:t}=v(),n=[...e,t].find(o=>o?.context==="TICKET");return!n||!U(n)?l("Invalid untag target"):d("Retrieved tags from ticket in breadcrumb",yn(n))},ua=()=>{let{breadCrumb:e,selectedNode:t}=v(),n=[...e,t].find(o=>o?.context==="TICKET");return!n||!U(n)?l("Invalid unassign target"):d("Retrieved assignees from ticket in breadcrumb",bn(n))}});var I,Fo=g(()=>{"use strict";I={PALETTE:"?",EXIT:"exit",INIT:"init",OPEN:"open",HELP:"help",NEW:"new",TAG:"tag",UNTAG:"untag",MOVE:"move",PEEK:"peek",REPLAY:"replay",FILTER:"filter",ASSIGN:"assign",UNASSIGN:"unassign",DELETE:"delete",CLOSE_ISSUE:"close",RE_OPEN_ISSUE:"reopen",COMMENT:"comment",CONFIG:"config",EDIT:"edit",YANK:"yank",SYNC:"sync",EXPORT:"export",NONE:""}});var iR,aR,lR,cR,dR,_o,cg,ma,pa,dg,uR,kc,Bs=g(()=>{"use strict";iR=/^(\d+)(h|d|w|mo|y)$/,aR=/^(\d{4})-(\d{2})-(\d{2})(?:(?::|\s)(\d{2}):(\d{2}))?$/,lR=({year:e,month:t,day:n,hour:o=0,minute:r=0})=>{let s=new Date(e,t-1,n,o,r);return s.getFullYear()===e&&s.getMonth()===t-1&&s.getDate()===n&&s.getHours()===o&&s.getMinutes()===r},cR=(e,t=new Date)=>{let n=e.match(iR);if(!n)return null;let[,o,r]=n,s=Number(o);if(!Number.isInteger(s)||s<=0)return null;let i=new Date(t);switch(r){case"h":return i.setHours(i.getHours()-s),i;case"d":return i.setDate(i.getDate()-s),i;case"w":return i.setDate(i.getDate()-s*7),i;case"mo":return i.setMonth(i.getMonth()-s),i;case"y":return i.setFullYear(i.getFullYear()-s),i;default:return null}},dR=e=>{let t=e.match(aR);if(!t)return null;let[,n,o,r,s,i]=t,c=Number(n),u=Number(o),p=Number(r),m=s?Number(s):0,f=i?Number(i):0;return lR({year:c,month:u,day:p,hour:m,minute:f})?new Date(c,u-1,p,m,f):null},_o=e=>{let t=e.trim().toLowerCase();return cR(t)??dR(t)},cg=/^(\d+)(s|m)?$/,ma=e=>{let t=e.trim().toLowerCase().match(cg);if(!t)return null;let n=Number(t[1]);return!Number.isInteger(n)||n<=0?null:t[2]==="m"?n*6e4:n*1e3},pa=(e,t)=>{let n=(t??"").trim().split(/\s+/).filter(Boolean),o=n.length>0&&cg.test(n.at(-1))?n.pop():"";return{dateInput:e||n.join(" "),durationInput:o}},dg=({date:e,horizonDate:t})=>t?e.getTime()>=t.getTime():!0,uR=[{unit:"h",from:1,to:24},{unit:"d",from:1,to:7},{unit:"w",from:1,to:52},{unit:"mo",from:1,to:12},{unit:"y",from:1,to:5}],kc=(e=uR)=>{let t=[];for(let{unit:n,from:o,to:r}of e)for(let s=o;s<=r;s++)t.push(`${s}${n}`);return t}});var mR,be,Mt,He,pR,fR,Lc,Pc,pg,Bo,fa,Mc,ug,gR,hR,$s,mg,vR,yR,Dc,bR,We,_n=g(()=>{"use strict";aa();ur();w();Oo();tn();me();pe();O();bl();pr();Fo();Bs();mR=["BOARD","TICKET","SWIMLANE","COMMENT"],be={EDITOR:"editor",VIEW:"view",USERNAME:"username",EMAILS:"emails",EMAILS_UNCLAIM:"emails-unclaim",AUTOSYNC:"autoSync",SYNC_DEBOUNCE_MS:"syncDebounceMs",ATTACHMENT_MAX_KB:"attachmentMaxKb",LOG_LEVEL:"logLevel"},Mt={TITLE:"title",DESCRIPTION:"description",COMMENT:"comment"},He={REF:"ref",TITLE:"title",DESCRIPTION:"description",TAGS:"tags",ASSIGNEES:"assignees"},pR=[be.EDITOR,be.VIEW,be.USERNAME,be.EMAILS,be.EMAILS_UNCLAIM,be.AUTOSYNC,be.SYNC_DEBOUNCE_MS,be.ATTACHMENT_MAX_KB,be.LOG_LEVEL],fR=(e=v().selectedNode?.context)=>{switch(e){case"TICKET":return[Mt.TITLE,Mt.DESCRIPTION];case"BOARD":case"SWIMLANE":return[Mt.TITLE];case"COMMENT":return[Mt.COMMENT];default:return[]}},Lc=[String(cr),"5000","15000","30000","60000"],Pc=["250","500","1000"],pg=["10s","20s","30s","45s"],Bo=[I.EXIT,I.SYNC,I.HELP,I.EXPORT,I.CONFIG,I.YANK],fa=[I.NEW,I.EDIT,I.DELETE,I.MOVE],Mc=[I.TAG,I.UNTAG,I.ASSIGN,I.UNASSIGN,I.CLOSE_ISSUE,I.RE_OPEN_ISSUE,I.EDIT,I.COMMENT],ug=[I.FILTER,I.PEEK,I.REPLAY],gR={WORKSPACE:[...Bo,...fa],BOARD:[...ug,...Bo,...fa],SWIMLANE:[...ug,...Bo,...fa],TICKET:[...Bo,...fa,...Mc],FIELD:[...Bo,...Mc],FIELD_LIST:[...Bo,...Mc],TEXT:[...Bo],COMMENT:[I.EDIT,I.DELETE,I.YANK]},hR=e=>e==="WORKSPACE"?["board"]:["issue","swimlane","board"],$s=({breadCrumb:e,selectedNode:t})=>[...e,t].find(n=>n!=null&&U(n)),mg=e=>e.parentNodeId===Ae,vR=({selectedNode:e,breadCrumb:t})=>{let n=fR(e?.context);return $s({breadCrumb:t,selectedNode:e})?n.includes(Mt.DESCRIPTION)?n:[...n,Mt.DESCRIPTION]:n},yR=({selectedNode:e,breadCrumb:t})=>{let n=$s({breadCrumb:t,selectedNode:e});return n?[He.REF,He.TITLE,...n.props?.description?.trim()?[He.DESCRIPTION]:[],...yn(n).length>0?[He.TAGS]:[],...bn(n).length>0?[He.ASSIGNEES]:[]]:e?[He.REF,He.TITLE]:[]},Dc=()=>{let e=ca({exclude:process.cwd()});return a(e)?[]:[...e.value.map((t,n)=>String(n+1)),...e.value.map(t=>t.root)]},bR=({selectedNode:e,readOnly:t,breadCrumb:n})=>{let{isSetupDone:o}=_s();if(!o)return[I.HELP,I.CONFIG];if(!Tc())return[I.HELP,I.INIT,I.OPEN];if(t)return[I.HELP,I.PEEK,I.REPLAY,I.EXPORT,I.CONFIG,I.YANK];let r=e?.context,s=r&&mR.includes(r),i=[...new Set([...n,e].map(u=>u?.context).flatMap(u=>u?gR[u]:[]))],c=$s({breadCrumb:n,selectedNode:e});return i.filter(u=>u===I.MOVE?!1:u===I.YANK?!!(c??e):u===I.EDIT?s||!!c:u===I.DELETE?s:u===I.UNTAG?!!(c&&yn(c).length>0):u===I.UNASSIGN?!!(c&&bn(c).length>0):u===I.RE_OPEN_ISSUE?!!(c&&mg(c)):u===I.CLOSE_ISSUE?!!(c&&!mg(c)):!0)},We=(e,{contextNode:t,selectedNode:n,readOnly:o,breadCrumb:r}=v())=>{let s=t.context??"WORKSPACE";return{[I.NONE]:bR({breadCrumb:r,readOnly:o,selectedNode:n}),[I.EXIT]:["confirm"],[I.EXPORT]:[],[I.SYNC]:[],[I.INIT]:[],[I.OPEN]:e===I.OPEN?Dc():[],[I.HELP]:[],[I.PEEK]:[...kc(),"now","prev","next"],[I.REPLAY]:[...kc()],[I.EDIT]:vR({selectedNode:n,breadCrumb:r}),[I.YANK]:yR({selectedNode:n,breadCrumb:r}),[I.COMMENT]:[],[I.DELETE]:["confirm"],[I.RE_OPEN_ISSUE]:["confirm"],[I.CLOSE_ISSUE]:["confirm"],[I.MOVE]:["start","confirm","next","previous","jump-next","jump-previous","to-next","to-previous","cancel"],[I.FILTER]:["tag","assignee","actor","description","title","ref","clear"],[I.TAG]:[...new Set([...Object.keys(vi),...N.getExistingTags()])],[I.UNTAG]:[...da()?.value?.map(({name:c})=>c)??[]],[I.UNASSIGN]:[...ua()?.value?.map(({name:c})=>c)??[]],[I.ASSIGN]:N.getExistingAssignees(),[I.NEW]:hR(s),[I.CONFIG]:[...pR]}[e]??[]}});var fg,gg=g(()=>{"use strict";fg=["vim","nvim","nano","micro","emacs","hx","code","code-insiders","subl","notepad","notepad++","idea","webstorm","default","system","$EDITOR","$VISUAL"]});import{accessSync as xR,copyFileSync as IR,existsSync as ga,mkdirSync as hg,readdirSync as vg,readFileSync as ER,renameSync as RR,rmSync as SR,statSync as yg,unlinkSync as NR,writeFileSync as wR}from"node:fs";import fr from"node:path";var Oc,Ze,ha=g(()=>{"use strict";Oc=e=>typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string",Ze={writeToFile:(e,t)=>{try{let n=fr.dirname(e);ga(n)||hg(n,{recursive:!0});let o=typeof t=="string"?t:JSON.stringify(t,null,2);wR(e,o,"utf-8")}catch(n){logger.error(`Failed to write file at ${e}:`,n)}},readFile:e=>{try{return ER(e,"utf-8")}catch(t){return logger.error(`Failed to read file at ${e}:`,t),null}},readFileJSON(e){try{let t=Ze.readFile(e);return t===null?null:JSON.parse(t)}catch(t){return logger.error(`Failed to read JSON at ${e}:`,t),null}},dirExists:e=>{try{return ga(e)&&yg(e).isDirectory()}catch{return!1}},async fileExists(e){try{return await xR(e),!0}catch{return!1}},mkDir:e=>hg(e,{recursive:!0}),locateFolder:e=>{let t=process.cwd(),{root:n}=fr.parse(t);for(;;){let o=fr.join(t,e);try{if(ga(o)&&yg(o).isDirectory())return o}catch{logger.error(`Unable to locate folder ${e}`)}if(t===n)break;t=fr.dirname(t)}return null},readFirstJSON(e){try{if(!Ze.dirExists(e))return null;let t=vg(e).filter(o=>o.endsWith(".json")).sort()[0];if(!t)return null;let n=fr.join(e,t);return Ze.readFileJSON(n)}catch(t){return logger.error(`Could not read first JSON in folder ${e}`,t),null}},listDir:e=>{try{return Ze.dirExists(e)?vg(e):[]}catch(t){return logger.error(`Failed to list dir ${e}`,t),[]}},rmFile(e){try{NR(e)}catch(t){(!Oc(t)||t.code!=="ENOENT")&&logger.error(`Unable to remove file ${e}`)}},rmDir(e){try{SR(e,{recursive:!0,force:!0})}catch(t){(!Oc(t)||t.code!=="ENOENT")&&logger.error(`Unable to remove dir ${e}`)}},moveFile(e,t,n){if(this.mkDir(fr.dirname(t)),!n?.overwrite&&ga(t))throw new Error(`moveFile: destination exists: ${t}`);n?.overwrite&&this.rmFile(t);try{RR(e,t)}catch(o){if(Oc(o)&&o.code==="EXDEV"){IR(e,t),this.rmFile(e);return}throw o}}}});import CR from"node:path";import{z as on}from"zod";var AR,bg,TR,xg,Fc,_c,kR,no,Ig,it,gr,rn=g(()=>{"use strict";vo();ee();w();ha();AR={logLevel:"info",userId:"",userName:"",preferredEditor:"",autoSync:!1},bg=on.object({logLevel:on.enum(["info","error","debug"]),preferredEditor:on.string().optional(),userName:on.string().optional(),userId:on.string().optional(),autoSync:on.boolean().nullable().optional(),autoSyncDebounceMs:on.number().optional(),attachmentMaxKb:on.number().optional(),viewMode:on.enum(["dense","wide"]).optional(),declinedEmailBoards:on.array(on.string()).optional()}).partial(),TR="config.json",xg=wn,Fc=()=>CR.join(xg(),TR),_c=()=>{try{return Ze.mkDir(xg()),d(`Ensured ~/${Qt} exists`,null)}catch{return l(`Unable to create ~/${Qt}`)}},kR=e=>{let t;try{t=JSON.parse(e)}catch{return l(`Invalid ~/${Qt}/config.json JSON`)}let n=bg.safeParse(t??{});return n.success?d("Parsed config",n.data):l(`Invalid ~/${Qt}/config.json shape: ${n.error.issues.map(o=>o.path.join(".")||o.message).join(", ")}`)},no=()=>{let e=_c();if(a(e))return l(e.message);let t=Fc(),n=Ze.readFile(t);return n==null||n.trim()===""?d("No config found, using empty config",{logLevel:"info",autoSync:null,preferredEditor:"",userId:"",userName:"",autoSyncIntervalMs:1e4}):kR(n)},Ig=e=>{let t=_c();if(a(t))return l(t.message);let n=bg.safeParse(e);if(!n.success)return l(`Invalid config: ${n.error.issues.map(r=>r.path.join(".")||r.message).join(", ")}`);let o=Fc();try{return Ze.writeToFile(o,JSON.stringify(n.data,null,2)+`
79
- `),d("Config written",null)}catch{return l(`Unable to write ~/${Qt}/config.json`)}},it=e=>{let t=no();if(a(t))return l("Failed to read existing config");let n={...t.value,...e};return Ig(n)},gr=()=>{let e=Fc(),t=_c();if(a(t))return l(`Unable to create ~/${Qt}`);if(!(Ze.readFile(e)!==null)){let S=Ig(AR);if(a(S))throw new Error(`Unable to create ~/${Qt}/config.json`)}let o=no();if(a(o))throw new Error(o.message||"Unable to load settings");let{preferredEditor:r,userName:s,userId:i,declinedEmailBoards:c,autoSync:u,autoSyncDebounceMs:p,attachmentMaxKb:m,logLevel:f,viewMode:h}=o.value,x=hl({userId:i,userName:s});if(a(x))return l(x.message);let E=x.value??{userId:i,userName:s};return!E.userName||!E.userId?l(`User name or ID not configured in ~/${Qt}/config.json`):(process.env.EPIQ_LOG_LEVEL=f,d("successfully loaded settings",{gitEmail:null,gitName:null,declinedEmailBoards:c??[],logLevel:f??"debug",preferredEditor:r??"",userName:E.userName,userId:E.userId,autoSync:u??!1,autoSyncIntervalMs:p??1e4,attachmentMaxKb:m??null,viewMode:h??"dense"}))}});var Eg,Rg,Bc,Sg=g(()=>{"use strict";Eg="/media/",Rg=e=>`${Eg}${e}`,Bc=(e,t)=>`![${e}](${Rg(t)})`});import MR from"node:crypto";import $c from"node:fs";import LR from"node:path";var Bn,hr,PR,DR,OR,Ng,vr=g(()=>{"use strict";Yt();w();ee();Sg();Bn=500,hr=(e,t)=>`${e}.${t}`,PR=e=>e.length>=8&&e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))?d("Sniffed image type","png"):e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?d("Sniffed image type","jpg"):e.length>=6&&(e.subarray(0,6).equals(Buffer.from("GIF87a","ascii"))||e.subarray(0,6).equals(Buffer.from("GIF89a","ascii")))?d("Sniffed image type","gif"):e.length>=12&&e.subarray(0,4).equals(Buffer.from("RIFF","ascii"))&&e.subarray(8,12).equals(Buffer.from("WEBP","ascii"))?d("Sniffed image type","webp"):l(`Unsupported image format. Allowed: ${vm.join(", ")}`),DR=e=>MR.createHash("sha256").update(e).digest("hex"),OR=(e,t=Bn)=>{if(e.length===0)return l("Attachment is empty");if(e.length>t*1024)return l(`Attachment exceeds the ${t} KB size cap (${Math.ceil(e.length/1024)} KB)`);let n=PR(e);return a(n)?n:d("Validated attachment data",{hash:DR(e),ext:n.value,bytes:e.length})},Ng=(e,t,n=Bn)=>{let o=OR(t,n);if(a(o))return o;let r=ki(e),s=LR.join(r,hr(o.value.hash,o.value.ext));try{$c.existsSync(s)||($c.mkdirSync(r,{recursive:!0}),$c.writeFileSync(s,t))}catch(i){return l(`Unable to write attachment blob: ${i instanceof Error?i.message:String(i)}`)}return d("Wrote attachment blob",o.value)}});import FR from"zod";var js,Us,wg,jc=g(()=>{"use strict";rn();vr();w();he();Fe();js=50,Us=5e3,wg=()=>{let e=fe().commandMeta.inputString,t=FR.coerce.number().int().min(js).max(Us).safeParse(e);if(!t.success)return l(`Attachment size cap must be ${js}-${Us} KB (default ${Bn})`);let n=it({attachmentMaxKb:t.data});return a(n)?n:(Qe({attachmentMaxKb:t.data}),d(`Attachment size cap set to ${t.data} KB`,null))}});var at,$n=g(()=>{"use strict";at=(e,t,n)=>t.length>n?`${e} cannot exceed ${n} characters (got ${t.length})`:null});import{createHash as _R}from"node:crypto";var BR,$R,Te,oo=g(()=>{"use strict";BR="0123456789ABCDEFGHJKMNPQRSTVWXYZ",$R=e=>{let t=_R("sha256").update(e).digest(),n=0n;for(let r=0;r<16;r++)n=n<<8n|BigInt(t[r]);let o="";for(let r=0;r<26;r++){let s=BigInt((25-r)*5);o+=BR[Number(n>>s&31n)]}return o},Te=(e,t)=>$R(`${e}:virtual:${t}`)});import Cg from"chalk";var Re,je,Ue,Ag=g(()=>{"use strict";dn();Je();Re=e=>Cg.dim(e),je=e=>Cg.hex(k.primary)(e),Ue=({prefix:e="",wordList:t,postfix:n="",noOfHints:o=100,inputString:r,minLengthForHints:s=1})=>{let i=r.trim();if(i.length<s)return"";let m=[...t.filter(Boolean).filter(f=>f.startsWith(i))].sort((f,h)=>yi(f)-yi(h)).slice(0,o).map(f=>bi(f)).join(" ");return m?`${Re(e)}${m}${Re(n)}`:""}});var ro,va=g(()=>{"use strict";ro={None:"none",Invalid:"invalid",Valid:"valid"}});import Mg from"chalk";var jR,Tg,xe,UR,ie,Y,br,kg,ya,Uc,HR,yr,WR,qR,GR,zR,VR,Lg,Pg=g(()=>{"use strict";aa();Oo();gg();ft();Yt();w();pe();Fe();jc();vr();wt();O();dn();$n();pr();oo();Ag();Fs();Fo();va();_n();Bs();jR=["BOARD","TICKET","SWIMLANE"],Tg=()=>{let e=v().selectedNode;if(!e?.context)return Y({message:Re("Missing target context")});if(jR.includes(e.context))return ie();if(e.parentNodeId){let t=v().nodes[e.parentNodeId];if(t?.id===Te(t?.parentNodeId??"","comments"))return ie()}return Y({message:Re("Command not available in this context")})},xe="<ENTER> to confirm",UR=()=>{let{userId:e}=le(),t=Me();return!e||a(t)?[]:zn(t.value.emailLinks,e)},ie=(e="",t=[],n=!0)=>({message:n?Re(e):e,validity:ro.Valid,completionWordList:t}),Y=({message:e,completionWordList:t=[]})=>({validity:ro.Invalid,message:e,completionWordList:t}),br=e=>e.length===0,kg=(e,t)=>{let n=Nt(v().breadCrumb,"BOARD");if(a(n))return Y({message:je("Command is not applicable in this context")});let o=dm(n.value.id);return a(o)?Y({message:je(`Unable to ${t}: board id is not a valid ULID`)}):dg({date:e,horizonDate:o.value})?null:Y({message:je(`nothing to ${t} before ${o.value.toISOString().slice(0,16).replace("T"," ")}`)})},ya=e=>` ${Mg.hex("#000").bgHex(nt(e))(` ${e} `)} `,Uc=({modifier:e})=>{let t="confirm";return e===t?ie(xe):Y({message:br(e)?Re("if you are certain, enter ")+bi(t):"",completionWordList:[t]})},HR=({list:e,hint:t,onValue:n})=>({modifier:o,inputString:r})=>e.includes(o)?r.trim().length<1?Y({message:Re(n)}):ie():Y({message:br(o)?t:"",completionWordList:[...e]}),yr=({hint:e,onOk:t})=>({modifier:n,inputString:o})=>br(n)&&br(o)?Y({message:e,completionWordList:[]}):ie(t??xe),WR=({modifier:e,inputString:t})=>{let n=Dc();return!br(e)||!br(t)?ie(xe):Y({message:n.length?Re("number from the list, or a path"):Re("path to an epiq project"),completionWordList:n})},qR=({modifier:e,inputString:t})=>{let n=We(I.CONFIG);if(!n.includes(e))return Y({message:Ue({prefix:"... ",wordList:n,inputString:e,minLengthForHints:0}),completionWordList:n});switch(e){case be.EDITOR:{let o=[...fg];return t.trim()?o.includes(t.trim())?ie(xe):Y({message:Ue({prefix:"editors: ",wordList:o,inputString:t,minLengthForHints:0}),completionWordList:o}):Y({message:Ue({prefix:"editors: ",wordList:o,inputString:t,minLengthForHints:0}),completionWordList:o})}case be.VIEW:{let o=["dense","wide"];return o.includes(t.trim())?ie(xe):Y({message:Ue({prefix:"view... ",wordList:o,inputString:t,minLengthForHints:0}),completionWordList:o})}case be.USERNAME:{let o=le().gitName,r=o?[o]:[],s=t.trim(),i=r.filter(p=>p.startsWith(s)),u=i.length===1&&i[0]===s?"":Ue({prefix:"name: ",wordList:r,inputString:s,minLengthForHints:0});return s?u?ie(`${u} ${Re(xe)}`,r,!1):ie(xe,r):Y({message:u||je("Enter a user name. Saved in ")+Mg.bgBlack("~/.epiq-global/config.json"),completionWordList:r})}case be.EMAILS:{let o=le().gitEmail,r=mr(),s=r.length>0||!o?r:[o],i=[...s,"none"],c=t.trim(),u=(E,S)=>Y({message:Ue({prefix:E,wordList:i,noOfHints:3,inputString:S,minLengthForHints:0}),completionWordList:i});if(!c)return ie(`${xe} to see your addresses, or name one`,i);let p=c.split(/[,\s]+/).filter(Boolean),m=p[p.length-1]??"",f=E=>E==="none"||s.includes(E.toLowerCase()),h=E=>i.some(S=>S.startsWith(E.toLowerCase())),x=p.filter(E=>!f(E)&&!h(E));return x.length>0?Y({message:je(`no address here matches ${x.join(", ")} \u2014 pick one from the list, or its number`),completionWordList:i}):f(m)?ie(xe):u("",m)}case be.EMAILS_UNCLAIM:{let o=UR(),r=t.trim();return o.length===0?Y({message:je("you have not claimed any addresses"),completionWordList:[]}):r&&o.includes(r.toLowerCase())?ie(xe):Y({message:Ue({prefix:"give an address back ",wordList:o,noOfHints:3,inputString:r,minLengthForHints:0}),completionWordList:o})}case be.LOG_LEVEL:{let o=["debug","error","info"],r=t.trim();return o.includes(r)?ie(xe):Y({message:Ue({prefix:"one of: ",wordList:[...o],inputString:r,postfix:" persisted in ~/.epiq-global/config.json",minLengthForHints:0}),completionWordList:[...o]})}case be.AUTOSYNC:{let o=["on","off"],r=le().autoSync;if(!o.includes(t.trim())){let s=ig(r);return Y({message:Ue({prefix:`should auto-sync (recommended)${s!==null?", currently: "+s:""} `,wordList:o,noOfHints:3,inputString:t,minLengthForHints:0}),completionWordList:o})}return ie(xe)}case be.ATTACHMENT_MAX_KB:{let o=le().attachmentMaxKb,r=Number.parseInt(t.trim(),10);if(!t.trim()||Number.isNaN(r)||r<js||r>Us){let s=Ue({prefix:" examples: ",wordList:Pc,minLengthForHints:0,inputString:t});return Y({message:je(`provide a size cap in KB (${js}-${Us}). current: ${o??Bn} KB.`)+s,completionWordList:Pc})}return ie(xe)}case be.SYNC_DEBOUNCE_MS:{let o=le().autoSyncIntervalMs,r=qf(t);if(!t.trim()||r===null||r<cr){let s=Ue({prefix:" examples: ",wordList:Lc,minLengthForHints:0,inputString:t});return Y({message:je(`provide duration above ${cr}ms. current duration: ${o}ms.`)+s,completionWordList:Lc})}return ie(xe)}default:return Y({message:je("Unknown config option"),completionWordList:n})}},GR=({modifier:e,inputString:t})=>{let n=We(I.EDIT);if(!n.length)return Y({message:je("Command not available in this context")});if(!n.includes(e)){let o=Ue({prefix:"edit... ",wordList:n,inputString:e,minLengthForHints:0});return Y({message:o||je("Unknown edit option"),completionWordList:n})}switch(e){case Mt.COMMENT:return t.trim()?ie(xe):Y({message:Re("write a comment...")});case Mt.TITLE:return ie(xe);case Mt.DESCRIPTION:{let{preferredEditor:o}=le();return o?ie(Re("<ENTER> to edit in ")+o):Y({message:"No editor selected"})}default:return Y({message:je("Unknown edit option"),completionWordList:n})}},zR=({modifier:e})=>{let t=We(I.YANK);return t.length?t.includes(e)?ie(xe+Re(" and copy to clipboard")):Y({message:Ue({prefix:"yank... ",wordList:t,inputString:e,minLengthForHints:0}),completionWordList:t}):Y({message:je("Nothing selected to copy from")})},VR={[I.EXPORT]:()=>ie(xe+Re(", and create export markdown file")),[I.PEEK]:e=>{let t=e.modifier;if(t==="now"||t==="prev"||t==="next")return ie(xe);let n={message:Re("historical state from: '1h', '2d', '23h', '1mo', '2y', 'prev', 'next' or full date as YYYY-MM-DD")},o=t||e.inputString.trim(),r=_o(o);if(!o||!r)return Y(n);let s=kg(r,"peek");return s||ie(xe)},[I.REPLAY]:e=>{let{dateInput:t,durationInput:n}=pa(e.modifier,e.inputString),o={message:Re("replay forward from: '1h', '2d', '1mo', '2y' or full date as YYYY-MM-DD, with optional duration (e.g. '2y 30s')")},r=_o(t);if(!t||!r)return Y(o);let s=kg(r,"replay");return s||(n&&ma(n)===null?Y({message:je("duration must be positive (e.g. 30s, 2m, or a number of seconds)")}):ie("<ENTER> to replay board history",n?pg:[]))},[I.EXIT]:()=>ie(xe+Re(" and exit the application")),[I.INIT]:()=>ie(xe),[I.OPEN]:WR,[I.PALETTE]:()=>ie(xe),[I.FILTER]:e=>{if(e.modifier==="clear")return ie(xe);let t=s=>We(I.FILTER).includes(s);if(!e.modifier||!t(e.modifier))return Y({message:Ue({wordList:We(I.FILTER),inputString:e.inputString,minLengthForHints:0}),completionWordList:We(I.FILTER)});let n=Object.values(v().tags).map(s=>s.name),o=Object.values(v().contributors).map(s=>s.name),r=e.modifier==="tag"?n:e.modifier==="assignee"?o:[];return e.inputString?r.length&&!r.includes(e.inputString.trim())?Y({message:Ue({prefix:`existing ${e.modifier}s... `,wordList:r,noOfHints:10,inputString:e.inputString,minLengthForHints:0}),completionWordList:r}):ie():Y({message:Ue({prefix:"one of... ",wordList:r,noOfHints:10,inputString:e.inputString,minLengthForHints:0}),completionWordList:r})},[I.NONE]:e=>{let t=We(I.NONE);return Y({message:Ue({prefix:"... ",wordList:t,inputString:e.inputString,minLengthForHints:0}),completionWordList:t})},[I.NEW]:e=>HR({list:We(I.NEW),hint:Ue({wordList:We(I.NEW),noOfHints:3,inputString:e.inputString,minLengthForHints:0}),onValue:"provide a name..."})(e),[I.HELP]:()=>ie(xe),[I.EDIT]:GR,[I.COMMENT]:e=>{let t=yr({hint:Re(`write a comment (max ${4e3} char)...`),onOk:Re(`(${e.inputString.length}/${4e3})`)})(e);return t.validity===ro.Invalid?t:e.inputString.length>4e3?ie(je("max input exceeded")):t},[I.CONFIG]:qR,[I.YANK]:zR,[I.DELETE]:e=>{let t=Tg();return t.validity==="invalid"?t:Uc(e)},[I.CLOSE_ISSUE]:e=>Uc(e),[I.RE_OPEN_ISSUE]:e=>Uc(e),[I.MOVE]:e=>{let t=Tg();return t.validity==="invalid"?t:yr({hint:Ue({prefix:"hey hacker! These commands are blocked for you... ",wordList:We(I.MOVE),noOfHints:10,inputString:e.inputString})})(e)},[I.TAG]:e=>{let n=N.getExistingTags().slice(0,10).map(ya).join("");return yr({hint:n.length?Re("create tag or reuse:")+n+Re(""):Re("create tag ...")})(e)},[I.UNTAG]:e=>{let t=da();if(a(t))return Y({message:je("Invalid untag target"),completionWordList:[]});let n=t.value.map(({name:o})=>o).map(ya).slice(0,10);return n.length?yr({hint:Re(" ... ")+n.join("")})(e):Y({message:je("Issue has no tags"),completionWordList:[]})},[I.ASSIGN]:e=>{let t=N.getExistingAssignees().map(ya).slice(0,10);return yr({hint:Re("assignees... ")+t.join("")})(e)},[I.UNASSIGN]:e=>{let t=ua();if(a(t))return Y({message:je("Invalid unassign target"),completionWordList:[]});let n=t.value.map(({name:o})=>o).map(ya).slice(0,10);return n.length?yr({hint:Re("remove assignee... ")+n.join("")})(e):Y({message:je("Issue has no assignees"),completionWordList:[]})},[I.SYNC]:()=>ie(xe)},Lg=Object.fromEntries(Object.entries(VR).map(([e,t])=>[e,{validate:(n,o,r)=>t({modifier:o,command:n,inputString:r})}]))});var ba,Dg=g(()=>{"use strict";ba=["add","fix","bug","log","run","api","cli","ui","ux","test","mock","stub","sync","hash","sign","fork","push","pull","lock","warn","leak","hang","node","seed","lint","edit","save","load","read","send","drop","swap","wrap","port","host","role","user","auth","flag","diff","perf","docs","todo","task","team","epic","spec","remove","update","change","improve","enhance","refactor","rewrite","redesign","implement","build","create","delete","rename","migrate","upgrade","downgrade","revert","rollback","restore","replace","deprecate","cleanup","simplify","optimize","stabilize","harden","document","clarify","investigate","debug","reproduce","triage","mitigate","remediate","resolve","escalate","verify","validate","benchmark","profile","audit","monitor","instrument","configure","provision","deploy","release","publish","integrate","automate","support","enable","disable","prevent","handle","ensure","prioritize","estimate","schedule","track","install","uninstall","enforce","expose","extract","inject","override","extend","customize","localize","translate","redirect","forward","dispatch","broadcast","subscribe","unsubscribe","register","allocate","reserve","persist","retrieve","archive","expire","refresh","reload","reset","recover","replay","retry","scaffold","bootstrap","finalize","terminate","suspend","resume","cancel","abort","notify","alert","trigger","debounce","frontend","backend","fullstack","infrastructure","architecture","integration","application","environment","framework","platform","service","component","module","gateway","pipeline","container","orchestrator","middleware","endpoint","interface","database","datastore","cache","queue","scheduler","worker","daemon","runtime","library","package","plugin","extension","webhook","microservice","monolith","repository","namespace","cluster","sandbox","tenant","dashboard","console","portal","client","server","browser","mobile","desktop","kernel","driver","protocol","schema","migration","fixture","template","snippet","config","manifest","bundle","exception","incident","defect","regression","degradation","malfunction","instability","intermittent","workaround","failure","outage","crash","freeze","corruption","inconsistency","severity","criticality","diagnostics","analysis","blocker","flaky","timeout","mismatch","misconfiguration","boundary","overflow","underflow","panic","stacktrace","breakage","breaking","oversight","ambiguity","discrepancy","anomaly","authorize","authenticate","confidentiality","availability","accessibility","reliability","compliance","governance","encrypt","decrypt","integrity","traceability","accountability","protection","privileges","permissions","sanitize","escape","vulnerability","exposure","secrets","credentials","certificate","session","cookie","identity","tokenization","rotation","scanning","hardening","threat","exploit","payload","injection","phishing","breach","dependency","orchestrate","synchronize","compatibility","incompatibility","interoperability","observability","telemetry","discovery","registration","coordination","distribution","isolation","virtualization","networking","routing","proxy","firewall","balancer","failover","topology","replica","shard","region","capacity","quota","metrics","logging","tracing","alerting","monitoring","heartbeat","liveness","rollover","serialize","deserialize","initialize","instantiate","propagate","aggregate","consolidate","normalize","standardize","transform","reconcile","correlate","index","partition","enrich","filter","stream","batch","parse","encode","decode","compress","decompress","deduplicate","paginate","query","ingest","export","import","backup","snapshot","mapping","record","dataset","metadata","checksum","rollup","lookup","cursor","truncate","concurrency","parallelism","contention","deadlock","throttle","backpressure","fragmentation","saturation","exhaustion","replicate","redundancy","obsolescence","starvation","overload","latency","throughput","scalability","bottleneck","memoize","prefetch","warmup","autoscale","horizontal","vertical","elasticity","recursion","allocation","leakage","garbage","collection","pooling","buffering","caching","eviction","staleness","modularize","encapsulate","abstraction","extensibility","configurability","maintainability","recoverability","readability","testability","debuggability","reusability","simplicity","consistency","linting","formatting","typecheck","coverage","tooling","scaffolding","boilerplate","technical","cleanliness","naming","comments","docstring","testing","unittest","mocking","stubbing","assertion","smoke","sanity","fuzzing","flakiness","harness","scenario","baseline","performance","functionality","requirement","recommendation","improvement","enhancement","description","acceptance","criteria","deliverable","milestone","iteration","backlog","roadmap","followup","hotfix","patch","changelog","rollout","feature","spike","proposal","specification","priority","sprint","story","subtask","assignee","reviewer","reproduction","context","expected","actual","impact","workflow","version","tracking","discussion","decision","tradeoff","feedback","approval","planning","breakdown","scoping"]});var KR,YR,XR,JR,QR,Og,Fg,_g,Bg=g(()=>{"use strict";w();O();Dg();KR=3,YR=new Set(["the","and","for","are","but","not","you","all","any","can","was","one","our","out","use","this","that","with","have","from","will","your","they","them","then","than","when","what","were","been","into","should","would","could","about"]),XR=e=>{let t=[];for(let n of Object.values(e.nodes)){n.title&&t.push(n.title);let o=n.props;typeof o.description=="string"&&t.push(o.description),typeof o.value=="string"&&t.push(o.value)}for(let n of Object.values(e.tags))t.push(n.name);for(let n of Object.values(e.contributors))t.push(n.name);for(let n of Object.values(e.comments))t.push(n.md);return t},JR=e=>e.toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>=KR&&!YR.has(t)&&!/^\d+$/.test(t)),QR=e=>{let t=new Map;for(let s of XR(e))for(let i of JR(s))t.set(i,(t.get(i)??0)+1);let n=[...t.entries()].sort((s,i)=>i[1]-s[1]||s[0].localeCompare(i[0])).map(([s])=>s),o=new Set(n),r=ba.filter(s=>!o.has(s));return[...n,...r]},Og=ba,Fg=-1,_g=()=>{let e=Me();if(a(e))return ba;let t=e.value,n=t.eventLog.length;return n!==Fg&&(Og=QR(t),Fg=n),Og}});var $g,jg,Hc=g(()=>{"use strict";km();_n();Fo();Pg();Bg();O();Oe();$g=e=>Object.values(I).includes(e),jg=(e,t)=>{let n=e.command??"",{modifier:o,target:r,inputString:s}=e,{message:i,validity:c,completionWordList:u}=Lg[n].validate(n,o,s),p=n!==I.PEEK&&n!==I.REPLAY,m=r==="command"||r==="modifier"?We(n):p?_g():[],{mode:f}=v(),h=f===b.COMMAND_LINE?i??"":"",x=[...u,...m];return{validity:c,command:e.command,modifier:e.modifier,inputString:e.inputString,infoMessage:h,autoCompletion:t?Tm(e,x,u):{hint:"",hints:[],remainder:"",overlap:0}}}});var Ug,ZR,eS,tS,Hg=g(()=>{"use strict";Hc();_n();Ug=e=>{let t=e.trimStart(),n=eS(t),o=n[0]??"",r=n[1]??"",s=/\s$/.test(e),i=tS(e),c=$g(o)?o:null,u=c!==null,p=o!=="",m=c?We(c)??[]:[],f=c&&m.includes(r)?r:"",h="word";n.length===0||n.length===1&&!s?h="command":(n.length===1&&s||n.length===2&&!s)&&(h="modifier");let x=s?"":i,E=ZR(t,c,f);return{raw:e,trimmedStart:t,words:n,firstWord:o,lastWord:i,hasCommand:p,command:c,isCommandKeyword:u,isLastWordCompleted:s,modifier:f,target:h,inputToMatch:x,inputString:E}},ZR=(e,t,n)=>{let o=e;return t&&o.startsWith(t)&&(o=o.slice(t.length)),o=o.replace(/^\s+/,""),n&&o.startsWith(n)&&(o=o.slice(n.length),o=o.replace(/^\s+/,"")),o},eS=e=>e.trim()?e.trim().split(/\s+/):[],tS=e=>e.trimEnd().split(/\s+/).at(-1)??""});import{useSyncExternalStore as AF}from"react";var xr,Wc,Hs,Ir,nS,Wg,sn,Ws,qc,Gc,qg,Gg,xa,zg,ne,Vg,Kg,Yg,Xg,fe,Ia,he=g(()=>{"use strict";Hc();Hg();w();va();xr=e=>e===Wc||e===":",Wc=" ",Hs=40,Ir={commandHistory:[],value:"",commandHistoryIndex:-1,cursorPosition:0,commandIsPending:!1,commandMeta:{command:null,modifier:"",infoMessage:"",inputString:"",validity:ro.None,autoCompletion:{hint:"",hints:[],remainder:"",overlap:0}}},nS=new Set,Wg=()=>{for(let e of nS)e()},sn=e=>{let n=e(Ir),o=Ug(n.value),r=n.cursorPosition===n.value.length;Ir={...n,commandMeta:jg(o,r)},Wg()},Ws=({message:e,status:t})=>{let n=structuredClone(Ir);return n.commandMeta={...n.commandMeta,infoMessage:e??"",validity:t==="fail"?"invalid":"valid"},n.commandIsPending=!0,Ir=n,Wg(),d(e,null)},qc=e=>{sn(t=>({...t,cursorPosition:Math.max(0,Math.min(t.value.length,t.cursorPosition+e))}))},Gc=e=>{sn(t=>{let{value:n,cursorPosition:o}=t,r=o;if(e==="left"){for(;r>0&&xr(n[r-1]);)r--;for(;r>0&&!xr(n[r-1]);)r--}else{for(;r<n.length&&!xr(n[r]);)r++;for(;r<n.length&&xr(n[r]);)r++}return{...t,cursorPosition:r}})},qg=()=>{sn(e=>{let t=e.value.slice(e.cursorPosition),n=Math.max(0,e.cursorPosition-1);return{...e,value:e.value.slice(0,n)+t,cursorPosition:n,commandIsPending:!1}})},Gg=()=>{sn(e=>{let{value:t,cursorPosition:n}=e,o=n;for(;o>0&&xr(t[o-1]);)o--;for(;o>0&&!xr(t[o-1]);)o--;let r=t.slice(n);return{...e,value:t.slice(0,o)+r,cursorPosition:o,commandIsPending:!1}})},xa=e=>{sn(t=>{let n=Math.max(0,Math.min(t.cursorPosition,t.value.length)),o=t.value.slice(0,n),r=t.value.slice(n),s=e(o,t.commandMeta.autoCompletion),i=s+r,c=Math.max(0,Math.min(s.length,i.length));return{...t,value:i,cursorPosition:c,commandIsPending:!1}})},zg=()=>{sn(e=>({...e,commandIsPending:!0}))},ne=e=>{sn(t=>({...t,value:e,cursorPosition:e.length,commandIsPending:!1}))},Vg=({addToHistory:e=!0,line:t})=>{sn(n=>{let o=t??n.value;return{...n,commandHistory:e&&o.trim()?[o,...n.commandHistory].slice(0,Hs):n.commandHistory,commandHistoryIndex:-1,commandIsPending:!1,value:"",cursorPosition:0}})},Kg=e=>{sn(t=>({...t,commandHistory:e.slice(0,Hs),commandHistoryIndex:-1}))},Yg=()=>{sn(e=>{let t=Math.min(e.commandHistoryIndex+1,e.commandHistory.length-1),n=e.commandHistory[t]??"";return{...e,commandHistoryIndex:t,value:n,cursorPosition:n.length}})},Xg=()=>{sn(e=>{let t=Math.max(e.commandHistoryIndex-1,-1),n=t===-1?"":e.commandHistory[t]??"";return{...e,commandHistoryIndex:t,value:n,cursorPosition:n.length}})},fe=()=>Ir,Ia=()=>{let[e,...t]=Ir.value.split(Wc);return t.join(Wc).trim()}});var P,BF,Vn=g(()=>{"use strict";Oe();xm();O();he();Fe();P={NavPreviousItem:"navPreviousItem",NavNextItem:"navNextItem",NavPreviousItemJump:"navPreviousItemJump",NavNextItemJump:"navNextItemJump",NavToPreviousContainer:"navToPreviousContainer",NavToNextContainer:"navToNextContainer",MovePreviousItem:"movePreviousItem",MoveNextItem:"moveNextItem",MovePreviousItemJump:"movePreviousItemJump",MoveNextItemJump:"moveNextItemJump",MoveToPreviousContainer:"moveToPreviousContainer",MoveToNextContainer:"moveToNextContainer",Confirm:"confirm",Exit:"exit",ViewHelp:"viewHelp",HideHelp:"hideHelp",InitMove:"initMove",ConfirmMove:"confirmMove",Delete:"Delete",InitCommandPalette:"initCommandPalette",InitCommandLine:"initCommandLine",ExitCommandLine:"exitCommandLine",CaptureInput:"captureInput",EraseInput:"eraseInput",AddItem:"addItem",GetLastCommandFromHistory:"getLastCommandFromHistory",GetNextCommandFromHistory:"getNextCommandFromHistory",AutoCompleteCommand:"autoCompleteCommand",MoveCursorLeft:"MoveCursorLeft",MoveCursorRight:"MoveCursorRight",MoveCursorLeftOfWord:"MoveCursorLeftOfWord",MoveCursorRightOfWord:"MoveCursorRightOfWord",EraseInputWord:"EraseInputWord",None:"None",Edit:"edit",EditTitle:"editTitle",EditDescription:"editDescription",Yank:"yank",OpenInEditor:"openInEditor",MarkDiffLine:"markDiffLine",CommentOnDiffLine:"commentOnDiffLine",SetViewDense:"SetViewDense",SetViewWide:"SetViewWide"},BF={[P.NavPreviousItem]:P.NavPreviousItemJump,[P.NavNextItem]:P.NavNextItemJump,[P.MovePreviousItem]:P.MovePreviousItemJump,[P.MoveNextItem]:P.MoveNextItemJump}});var Jg,G,zc=g(()=>{"use strict";O();Fo();Jg=e=>{let{context:t}=v().contextNode;if(!t)return G.None;switch(e){case I.EXIT:return G.Exit;case I.EXPORT:return G.Export;case I.INIT:return G.Init;case I.OPEN:return G.OpenProject;case I.DELETE:return G.Delete;case I.EDIT:return G.Edit;case I.COMMENT:return G.Comment;case I.HELP:return G.ViewHelp;case I.RE_OPEN_ISSUE:return G.ReopenIssue;case I.CLOSE_ISSUE:return G.CloseIssue;case I.TAG:return G.TagTicket;case I.UNTAG:return G.UntagTicket;case I.ASSIGN:return G.AssignUserToTicket;case I.UNASSIGN:return G.UnassignUserFromTicket;case I.NEW:return G.NewItem;case I.FILTER:return G.Filter;case I.MOVE:return G.Move;case I.PEEK:return G.Peek;case I.REPLAY:return G.Replay;case I.CONFIG:return G.Config;case I.YANK:return G.Yank;case I.SYNC:return G.Sync;default:return G.None}},G={Exit:"exit",Init:"init",OpenProject:"open-project",None:"none",ViewHelp:"view-help",Rename:"rename",Edit:"edit",Delete:"delete",Filter:"filter",Move:"move",Peek:"peek",Replay:"replay",Yank:"yank",Config:"config",NewItem:"add-new-item",TagTicket:"ticket-tag",UntagTicket:"ticket-untag",AssignUserToTicket:"ticket-assign-user",UnassignUserFromTicket:"ticket-unassign-user",CloseIssue:"close-issue",ReopenIssue:"re-open-issue",Comment:"comment-issue",Sync:"sync",Export:"export"}});import{Text as Qg}from"ink";import Zg,{useEffect as eh,useState as oS}from"react";var th,Ut,Er=g(()=>{"use strict";O();Je();th={help:["\u276F "],default:["\u276F "],move:["\u25C6 ","\u25C6 "],"cmd-line":["\u276F "],palette:["\u276F "],identity:["\u276F "]},Ut=({isSelected:e,placeholder:t=" "})=>{let{mode:n}=Ye(),o=th[n]??th.default,[r,s]=oS(0);if(eh(()=>{s(0)},[o]),eh(()=>{if(!e)return;let c=setInterval(()=>{s(u=>(u+1)%o.length)},500);return()=>clearInterval(c)},[e,o]),!e)return Zg.createElement(Qg,null,t);let i=o[r]??o[0]??t;return Zg.createElement(Qg,{color:k.accent,dimColor:r===1},i)}});import{Box as Vc,Text as rS}from"ink";import Ea from"react";var sS,Ht,$o=g(()=>{"use strict";Je();sS=(e,t,n,o)=>{let r=u=>Math.max(1,e[u]??1),s=n,i=n+1,c=r(n);for(;i<t&&c+r(i)<=o;)c+=r(i),i++;for(;s>0&&c+r(s-1)<=o;)s--,c+=r(s);return{start:s,end:i}},Ht=({children:e=[],height:t,selectedIndex:n,itemHeight:o=1,itemHeights:r,scrollByOne:s=!1})=>{if(e.length===0)return null;let i=Math.max(1,Math.floor(t)),c=Math.max(1,Math.ceil(o)),u=Math.max(0,Math.min(n,e.length-1)),p=Math.max(1,Math.floor(i/c)),m=Math.max(0,e.length-p),{start:f,end:h}=r?sS(r,e.length,u,i):s?{start:Math.min(m,Math.max(0,u-p+1)),end:Math.min(m,Math.max(0,u-p+1))+p}:{start:Math.min(m,Math.floor(u/p)*p),end:Math.min(m,Math.floor(u/p)*p)+p},x=Math.max(1,h-f),E=e.slice(f,h),S=e.length>x,C=i,R=S?Math.max(1,Math.floor(x/e.length*C)):C,A=Math.max(0,C-R),L=Math.max(1,e.length-x),_=S?Math.floor(f/L*A):0;return Ea.createElement(Vc,{flexDirection:"row",height:i,width:"100%"},Ea.createElement(Vc,{flexDirection:"column",flexGrow:1,height:i},E),Ea.createElement(Vc,{flexDirection:"column",width:1,height:C},Array.from({length:C}).map((j,z)=>Ea.createElement(rS,{key:z,color:S&&z>=_&&z<_+R?k.accent:k.secondary},S?"\u2502":" "))))}});var nh,Kc,iS,Ra,Yc=g(()=>{"use strict";O();iS=()=>{let{eventLog:e=[]}=v();if(Kc&&nh===e)return Kc;let t=new Set;for(let n of e)n?.userId&&t.add(n.userId);return nh=e,Kc=t,t},Ra=e=>iS().has(e)});import{Text as aS}from"ink";import lS from"react";var Rr,Sa=g(()=>{"use strict";dn();pe();Yc();ht();Rr=({id:e,isSelected:t,maxWidth:n})=>{let o=N.getContributor(e);if(!o)return;let r=o.name,s=n===void 0?r:Io(r,n);return lS.createElement(aS,{underline:t,color:nt(r)},"@"+s,Ra(e)?"":"\u2197")}});import{Text as cS}from"ink";import dS from"react";var Na,Xc=g(()=>{"use strict";pe();Je();dn();ht();Na=({id:e,isSelected:t,maxWidth:n})=>{let o=N.getTag(e);if(!o)return;let r=n===void 0?o.name:Io(o.name,n);return dS.createElement(cS,{underline:t,backgroundColor:nt(o.name),color:k.secondary}," "+r+" ")}});import{useEffect as uS,useState as mS}from"react";var pS,oh,wa,qs,fS,gS,Sr,Ca=g(()=>{"use strict";dn();pS=80,oh=1400,wa=new Set,qs=null,fS=e=>(wa.add(e),qs||(qs=setInterval(()=>{for(let t of wa)t()},pS)),()=>{wa.delete(e),wa.size===0&&qs&&(clearInterval(qs),qs=null)}),gS=()=>{let e=Date.now()%oh/oh;return e<.5?e*2:(1-e)*2},Sr=e=>{let[,t]=mS(0);return uS(()=>{if(e)return fS(()=>t(n=>n+1))},[e]),hm(gS())}});import{Box as Nr,Text as wr}from"ink";import It from"react";var hS,rh,vS,yS,sh,ih=g(()=>{"use strict";pe();Je();ht();Yc();mt();pr();Sa();Xc();Ca();hS=(e,t,n)=>{if(e.length<=t)return[e,null];let o=e.lastIndexOf(" ",t),r=o>0?o:t;return[e.slice(0,r),Io(e.slice(r).trim(),n)]},rh=3,vS=2,yS=(e,t)=>{let n=[],o=0;for(let[r,s]of e.entries()){let i=e.length-r-1,c=i>0?String(i).length+1:0;if(o+s.width+c>t)break;o+=s.width,n.push(s)}return{shown:n,hidden:e.length-n.length}},sh=({width:e,ticket:t,isSelected:n,isFlashing:o=!1})=>{let r=Sr(o),s=e-4,i=s-7-1,[c,u]=hS(Se(t.title),i,s),p=u?null:Io(Se(t.props.description),s)||null,m=yn(t),f=bn(t).map(R=>({...R,name:R.name})),h=Math.max(1,s-rh),x=N.getCommentsByIssue(t.id),E=x.length?String(x.length).length+2+1:0,{shown:S,hidden:C}=yS([...m.map(R=>({id:R.id,isTag:!0,width:Math.min(R.name.length,h)+rh})),...f.map(R=>({id:R.id,isTag:!1,width:Math.min(R.name.length,h)+vS+(Ra(R.id)?0:1)}))],s-E);return It.createElement(Nr,{borderStyle:"round",height:5,flexDirection:"column",overflow:"hidden",borderDimColor:!n,borderColor:o?r:n?k.accent:k.secondary,justifyContent:"space-between"},It.createElement(Nr,{paddingLeft:1,paddingRight:1,flexDirection:"column"},It.createElement(Nr,{justifyContent:"space-between"},It.createElement(wr,{color:k.primary},c),It.createElement(wr,{color:k.secondary2,dimColor:!0},V(t.id))),u&&It.createElement(wr,{color:k.primary},u),p&&It.createElement(wr,{color:k.secondary2,dimColor:!0},p)),It.createElement(Nr,{flexDirection:"row",paddingLeft:1,paddingRight:1,justifyContent:"space-between"},It.createElement(Nr,{flexDirection:"row"},S.map(R=>It.createElement(Nr,{paddingRight:1,key:R.id},R.isTag?It.createElement(Na,{id:R.id,maxWidth:h}):It.createElement(Rr,{id:R.id,maxWidth:h}))),C>0&&It.createElement(wr,{color:k.secondary2,dimColor:!0},"+",C)),x.length>0&&It.createElement(wr,{color:k.accent},"[",x.length,"]")))}});import{Box as jo,Text as Gs}from"ink";import Lt from"react";var bS,ah,lh=g(()=>{"use strict";Oe();pe();Je();dn();Er();Ca();bS=(e,t)=>e.length>t?e.slice(0,Math.max(0,t-1))+"\u2026":e,ah=({index:e,labelWidth:t,width:n,ticket:o,isSelected:r,isFlashing:s=!1,mode:i})=>{let c=Sr(s),u=(o.props.tags??[]).map(j=>N.getTag(j)).filter(j=>!!j),p=(o.props.assignees??[]).map(j=>N.getContributor(j)).map(j=>j&&{...j,name:j.name}).filter(j=>!!j),m=1,f=u.length*(1+m),h=p.length*(2+m),x=u.map(j=>Lt.createElement(jo,{key:j.id,paddingRight:m},Lt.createElement(Gs,{color:nt(j.name)},"\u25A0"))),E=p.map(j=>Lt.createElement(jo,{key:j.id,paddingRight:m},Lt.createElement(Gs,{color:El(j.name)},"@"+j.name.at(0)))),S=s?c:r?k.accent:i===b.MOVE?k.secondary:k.primary,C=N.getCommentsByIssue(o.id),R=C.length?String(C.length).length+2+m:0,A=C.length?Lt.createElement(jo,{paddingRight:m},Lt.createElement(Gs,{color:k.accent},"[",C.length,"]")):null,L=f+h+R,_=Math.max(1,n-t-L-(L>0?1:0));return Lt.createElement(jo,{justifyContent:"space-between"},Lt.createElement(jo,null,Lt.createElement(jo,{width:t},r?Lt.createElement(Ut,{isSelected:!0}):Lt.createElement(Gs,{color:"gray",dimColor:!0},String(e+1).padStart(t-1)+" ")),Lt.createElement(Gs,{wrap:"truncate",color:S},bS(o.title,_))),Lt.createElement(jo,null,x,E,A))}});import xS from"chalk";import{Box as Jc,Text as IS}from"ink";import xn from"react";var ES,ch,dh=g(()=>{"use strict";me();O();Je();Er();$o();ih();lh();Ca();ES=({swimlane:e,isSelected:t,width:n,height:o,isDense:r,isFocused:s,listSelectedIndex:i,mode:c})=>{let{renderedChildrenIndex:u,replay:p}=Ye(),m=u[e.id]??[],f=p?new Set(p.flashNodeIds):null,h=f?.has(e.id)??!1,x=Sr(h),E=`${e.title} ${xS.hex(k.secondary2).dim("("+m.length+")")}`,S=3,C=r?1:5,R=s&&i===-1,A=n-3-(r?1:0)-(R?2:0),L=Math.max(2,String(m.length).length+1),_=o-S-1,j=xn.createElement(Jc,{borderStyle:"round",borderColor:k.secondary,justifyContent:"flex-start",borderLeft:!1,borderTop:!1,borderRight:!1,marginRight:r?1:0},xn.createElement(Ut,{isSelected:t}),xn.createElement(IS,{bold:!0,color:h?x:t?k.accent:k.primary},E," ",e.readonly?"\u{1F512}":"")),z=(X,ue)=>{let ze=s&&i===ue;if(!U(X))return null;let q=f?.has(X.id)??!1;return r?xn.createElement(ah,{key:X.id,index:ue,labelWidth:L,width:A,ticket:X,isSelected:ze,isFlashing:q,mode:c}):xn.createElement(sh,{key:X.id,width:A,ticket:X,isSelected:ze,isFlashing:q})};return xn.createElement(Jc,{flexDirection:"column",width:n,borderStyle:"round",borderColor:t?k.accent:k.secondary,paddingRight:0,paddingLeft:r?1:0,height:o},j,xn.createElement(Jc,null,m.length>0&&xn.createElement(Ht,{selectedIndex:i,height:_,itemHeight:C},m.map(z)),R&&xn.createElement(Ut,{isSelected:!0})))},ch=xn.memo(ES)});var uh,mh,ph,Aa=g(()=>{"use strict";eo();uh=e=>{let t=new Set((e.log??[]).filter(n=>n.action==="delete.issue.comment").map(n=>n.payload.id));return(e.log??[]).filter(n=>n.action==="add.issue.comment"&&n.payload.issue===e.id&&!t.has(n.payload.id)).length},mh=(e,t,n)=>Be.comment({id:e.id,parentNodeId:n,rank:String(t).padStart(6,"0"),name:e.id,props:{value:e.md},readonly:!1,isVirtual:!0}),ph=e=>e.action==="add.issue.comment"});var so,zs=g(()=>{"use strict";so=e=>{let t=Date.now()-e,n=[{label:"y",ms:1e3*60*60*24*365},{label:"mo",ms:1e3*60*60*24*30},{label:"w",ms:1e3*60*60*24*7},{label:"d",ms:1e3*60*60*24},{label:"h",ms:1e3*60*60},{label:"m",ms:1e3*60},{label:"s",ms:1e3}];for(let{label:o,ms:r}of n){let s=Math.floor(t/r);if(s>=1)return`${s}${o} ago`}return"just now"}});import{Box as Ar,Text as jn}from"ink";import lt,{useEffect as RS,useMemo as SS,useRef as NS}from"react";import{decodeTime as fh}from"ulid";function hh({ticket:e,width:t,height:n}){let o=SS(()=>CS(e),[e]),r=NS([]);RS(()=>(gh(r.current),r.current=TS(e,o),()=>{gh(r.current),r.current=[]}),[e,o]);let{selectedIndex:s}=Ye(),c=Math.max(1,n-4),u=Math.max(12,t-32);return o.length===0?lt.createElement(Ar,{flexDirection:"column",width:t,height:n,padding:1},lt.createElement(jn,{color:k.primary},"No attachments yet."),lt.createElement(Ar,{paddingTop:1},lt.createElement(jn,{color:k.primary},"Attach images from the browser GUI"),lt.createElement(jn,{color:k.accent}," epiq gui "),lt.createElement(jn,{color:k.primary},"by dropping or pasting them."))):lt.createElement(Ar,{flexDirection:"column",width:t,height:n},lt.createElement(Ar,{paddingLeft:4,borderLeft:!1,borderRight:!1,borderBottom:!1,borderTop:!0,borderColor:k.secondary,borderStyle:"single",paddingBottom:1},lt.createElement(jn,{color:k.secondary2},"Attachments (",o.length,") \u2014 enter to open"," ")),lt.createElement(Ht,{height:c,itemHeight:2,selectedIndex:s},o.map((p,m)=>{let f=m===s,h=p.name.length>u?p.name.slice(0,u-1)+"\u2026":p.name;return lt.createElement(Ar,{key:p.id,flexDirection:"row",paddingX:1,paddingBottom:1},lt.createElement(jn,{color:k.accent},f?"\u276F ":" "),lt.createElement(Ar,{paddingLeft:1},lt.createElement(jn,{color:k.secondary2},`#${m+1} `),lt.createElement(jn,{color:f?k.accent:k.primary},h),lt.createElement(jn,{color:k.secondary2}," "+kS(p.bytes)+" "+so(ct(p.id)))))})))}var wS,CS,gh,AS,TS,kS,vh=g(()=>{"use strict";xt();ft();zs();me();w();pe();eo();O();Je();oo();$o();wS=e=>Te(e,"attachments"),CS=e=>N.getAttachmentsByIssue(e.id).sort((t,n)=>fh(t.id)-fh(n.id)),gh=e=>{for(let t of e)N.deleteNode(t.id)},AS=(e,t,n)=>Be.field({id:e.id,name:e.name,parentNodeId:n,rank:String(t).padStart(6,"0"),isVirtual:!0}),TS=(e,t)=>{let n=N.getNode(wS(e.id));if(!n||!ot(n))return[];let o=t.map((r,s)=>AS(r,s,n.id)).map(r=>N.createNode(r)).filter(Dt).map(({value:r})=>r).filter(ot);return t.length>0&&v().selectedIndex<0&&H.navigate({contextNode:n,selectedIndex:0}),o},kS=e=>`${Math.max(1,Math.round(e/1024))} KB`});var bh,Qc,MS,yh,Vs,xh,Ih,LS,Eh,Rh,Zc,PS,Sh,Ta=g(()=>{"use strict";bh=/<!--\s*epiq-diff-comment:(.+?)-->\n?/,Qc=e=>e.replace(bh,""),MS=e=>`<!-- epiq-diff-comment:${JSON.stringify(e).replaceAll(">","\\u003e")} -->`,yh=e=>e==="additions"||e==="deletions",Vs=e=>{let t=bh.exec(e);if(!t?.[1])return null;let n;try{n=JSON.parse(t[1])}catch{return null}let o=n;return typeof o?.filePath!="string"||typeof o.start!="number"||typeof o.end!="number"||typeof o.note!="string"||!yh(o.side)||!yh(o.endSide)||o.sha!==void 0&&typeof o.sha!="string"||o.issueRef!==void 0&&typeof o.issueRef!="string"?null:o},xh=/```\n([\s\S]*?)\n?```\s*$/,Ih=e=>xh.exec(e)?.[1]??null,LS=/`[^`\n]+`[^\n]*\n?$/,Eh=e=>Qc(e).replace(xh,"").replace(LS,"").trim(),Rh=e=>{let n=(e.endSide??e.side)==="deletions"?"removed":"added";return e.start===e.end?`line ${e.start} (${n})`:`lines ${e.start}-${e.end} (${n})`},Zc=e=>`${e.issueRef?`${e.issueRef} \xB7 `:""}${e.filePath} ${Rh(e)}`,PS=e=>{let t=e.split(`
80
- `),n=t.filter(o=>o.trim()!=="").reduce((o,r)=>{let s=/^[ \t]*/.exec(r)?.[0].length??0;return o===null?s:Math.min(o,s)},null);return n?t.map(o=>o.slice(n)).join(`
81
- `):e},Sh=({snippet:e,...t})=>{let n=t.note.trim();return[...n?[n,""]:[],MS({...t,note:n}),`\`${t.filePath}\` ${Rh(t)}`,"```",PS(e),"```"].join(`
82
- `)}});var DS,Ks,OS,FS,_S,BS,Ys,ed,wh,Nh,Ch,ka=g(()=>{"use strict";Ta();DS=(e,t)=>{let n=Math.max(1,Math.floor(t)),o=e.split(/\s+/).filter(Boolean);if(o.length===0)return[""];let r=[],s="";for(let i of o){let c=i;for(;c.length>n;)s&&(r.push(s),s=""),r.push(c.slice(0,n)),c=c.slice(n);s?s.length+1+c.length<=n?s=`${s} ${c}`:(r.push(s),s=c):s=c}return s&&r.push(s),r},Ks=e=>{let t=e.split("`");return t.length%2===0?[{text:e}]:t.map((n,o)=>o%2===1?{text:n,code:!0}:{text:n}).filter(n=>n.text.length>0)},OS=/!\[([^\]]*)\]\([^)]*\)/g,FS=e=>e.replace(OS,(t,n)=>n.trim()?`[image: ${n.trim()}]`:"[image]"),_S=e=>e.map(t=>t.code?`\`${t.text}\``:t.text).join(""),BS=4,Ys=e=>e.replace(/\r$/,"").replaceAll(" "," ".repeat(BS)),ed=e=>{let t=!1;return e.map(Ys).map(n=>{if(/^\s*```/.test(n))return t=!t,{kind:"fence"};if(t)return{kind:"code",text:n};let o=Vs(n);if(o)return{kind:"caption",text:Zc(o)};let r=FS(n);if(r.trim()==="")return{kind:"blank"};let s=/^#{1,6}\s+(.*)$/.exec(r);return s?{kind:"heading",spans:Ks(s[1]??"")}:{kind:"text",spans:Ks(r)}})},wh=(e,t)=>e.length<=t?[e]:e.match(new RegExp(`.{1,${t}}`,"g"))??[""],Nh=(e,t)=>{let n=[];for(let o of ed(e))if(o.kind!=="fence"){if(o.kind==="blank"){n.length>0&&n[n.length-1]?.kind!=="blank"&&n.push(o);continue}if(o.kind==="code"){for(let r of wh(o.text,t))n.push({kind:"code",text:r});continue}if(o.kind==="caption"){n.push(o);continue}for(let r of DS(_S(o.spans),t))n.push({kind:o.kind,spans:Ks(r)})}for(;n.length>0&&n[n.length-1]?.kind==="blank";)n.pop();return n},Ch=(e,t)=>{let n=Vs(e),o=n?Ih(e):null;if(!n||o===null)return Nh(Qc(e).split(`
83
- `),t);let r=Eh(e),s=o.split(`
84
- `).map(Ys),i=n.side===n.endSide?n.start:void 0,c=i===void 0?0:String(i+s.length-1).length+3;return[...r?[...Nh(r.split(`
85
- `),t),{kind:"blank"}]:[],{kind:"caption",text:Zc(n)},...s.flatMap((u,p)=>wh(u,Math.max(1,t-c)).map((m,f)=>({kind:"code",text:m,number:i===void 0||f>0?void 0:i+p})))]}});import{Box as Ah,Text as Uo}from"ink";import Wt from"react";var Th,td,kh,nd=g(()=>{"use strict";Je();Th=({spans:e,bold:t,wrap:n})=>Wt.createElement(Uo,{color:k.primary,bold:t,wrap:n},e.map((o,r)=>o.code?Wt.createElement(Uo,{key:r,color:k.yellow},o.text):Wt.createElement(Uo,{key:r},o.text))),td=({line:e,width:t,gutter:n=0,wrap:o})=>{switch(e.kind){case"blank":return Wt.createElement(Uo,null," ");case"fence":return Wt.createElement(Uo,{color:k.secondary2},"```");case"caption":return Wt.createElement(Uo,{color:k.accent,wrap:o},e.text);case"heading":return Wt.createElement(Th,{spans:e.spans,bold:!0,wrap:o});case"text":return Wt.createElement(Th,{spans:e.spans,wrap:o});case"code":{let r=n>0?`${e.number===void 0?"":String(e.number)}`.padStart(n-3)+" \u2502 ":"";return Wt.createElement(Uo,{backgroundColor:k.secondary,color:k.primary,wrap:o},r,e.text.padEnd(Math.max(0,t-r.length)))}}},kh=({lines:e,width:t})=>{let n=e.flatMap(r=>r.kind==="code"&&r.number!==void 0?[r.number]:[]),o=n.length>0?String(Math.max(...n)).length+3:0;return Wt.createElement(Ah,{flexDirection:"column"},e.map((r,s)=>Wt.createElement(Ah,{key:s},Wt.createElement(td,{line:r,width:t,gutter:o}))))}});import{Box as io,Text as ao}from"ink";import qe,{useEffect as $S,useMemo as Mh,useRef as jS}from"react";import{decodeTime as Lh}from"ulid";function Dh({ticket:e,width:t,height:n}){let o=Mh(()=>WS(e),[e]),r=jS([]);$S(()=>(Ph(r.current),r.current=qS(e,o),()=>{Ph(r.current),r.current=[]}),[e,o]);let{selectedIndex:s}=Ye(),c=Math.max(1,n-4),u=Math.max(20,t-8),p=Mh(()=>o.map(f=>{let h=Ch(f.md,u);return h.length>0?h:[{kind:"blank"}]}),[o,u]),m=p.map(f=>f.length+US);return o.length===0?qe.createElement(io,{flexDirection:"column",width:t,height:n,padding:1},qe.createElement(ao,{color:k.primary},"No comments yet."),qe.createElement(io,{paddingTop:1},qe.createElement(ao,{color:k.primary},"Use"),qe.createElement(ao,{color:k.accent}," :comment "),qe.createElement(ao,{color:k.primary},"to add the first one."))):qe.createElement(io,{flexDirection:"column",width:t,height:n},qe.createElement(io,{paddingLeft:4,borderLeft:!1,borderRight:!1,borderBottom:!1,borderTop:!0,borderColor:k.secondary,borderStyle:"single",paddingBottom:1},qe.createElement(ao,{color:k.secondary2},"Comments (",o.length,") ")),qe.createElement(Ht,{height:c,itemHeights:m,selectedIndex:s},o.map((f,h)=>{let x=h===s;return qe.createElement(io,{key:f.id,flexDirection:"column",paddingX:1,borderLeft:!1,borderBottom:!1,borderRight:!1,borderColor:k.secondary,borderStyle:"single"},qe.createElement(io,{flexDirection:"row",paddingBottom:1},qe.createElement(ao,{color:k.accent},x?"\u276F ":" "),qe.createElement(io,{paddingLeft:1},qe.createElement(ao,{color:k.secondary2},`#${h+1} `),qe.createElement(Rr,{id:f.authorId}),qe.createElement(ao,{color:k.secondary2}," "+so(ct(f.id))))),qe.createElement(io,{paddingLeft:3,paddingBottom:1},qe.createElement(kh,{lines:p[h]??[],width:u})))})))}var US,HS,WS,Ph,qS,Oh=g(()=>{"use strict";xt();ft();zs();me();w();pe();O();Je();oo();Sa();$o();Aa();ka();nd();US=4,HS=e=>Te(e,"comments"),WS=e=>N.getCommentsByIssue(e.id).sort((t,n)=>Lh(t.id)-Lh(n.id)).map(t=>({id:t.id,issue:t.issue,authorId:t.authorId,md:t.md})),Ph=e=>{for(let t of e)N.deleteNode(t.id)},qS=(e,t)=>{let n=N.getNode(HS(e.id));if(!n||!ot(n))return[];let o=t.map((r,s)=>mh(r,s,n.id)).map(N.createNode).filter(Dt).map(({value:r})=>r).filter(ls);return t.length>0&&v().selectedIndex<0&&H.navigate({contextNode:n,selectedIndex:0}),o}});var lo,Xs,Tr=g(()=>{"use strict";w();ee();lo=e=>{let t=we(e??process.cwd());return a(t)?l(t.message):d("Resolved Epiq repo root",t.value)},Xs=e=>/^[0-9a-f]{7,40}$/i.test(e)});var kr,Fh,_h,Mr,Bh,Lr,od=g(()=>{"use strict";Ke();w();Jt();mt();Tr();kr="",Fh="",_h=5e3,Mr=null,Bh=async(e={})=>{let t=lo(e.repoRoot);if(a(t))return l(t.message);let n=At(t.value);if(a(n))return l(n.message);let o=e.start===void 0&&e.end===void 0;if(o&&Mr&&Mr.repoRoot===t.value&&Mr.stateBranch===n.value.stateBranch&&Date.now()-Mr.fetchedAt<_h)return d("Computed commit timeline",Mr.result);let r=await W({cwd:t.value,args:["log","--branches","--not",n.value.stateBranch,...e.start!==void 0?[`--since=@${Math.floor(e.start/1e3)}`]:[],...e.end!==void 0?[`--until=@${Math.floor(e.end/1e3)}`]:[],"--shortstat",`--format=${Fh}%H${kr}%at${kr}%an${kr}%ae${kr}%s`]});if(a(r))return l(r.message);let s=r.value.stdout.split(Fh).filter(i=>i.trim().length>0).map(i=>{let[c,...u]=i.split(`
86
- `),[p,m,f,h,...x]=(c??"").split(kr);if(!p||!m)return null;let E=u.join(" "),S=Number(/(\d+) insertion/.exec(E)?.[1]??0),C=Number(/(\d+) deletion/.exec(E)?.[1]??0);return{sha:p,time:Number(m)*1e3,author:f??"unknown",authorEmail:h??"",subject:x.join(kr),linesChanged:S+C,insertions:S,deletions:C}}).filter(i=>i!==null).filter(i=>(e.start===void 0||i.time>=e.start)&&(e.end===void 0||i.time<=e.end));return o&&(Mr={repoRoot:t.value,stateBranch:n.value.stateBranch,fetchedAt:Date.now(),result:s}),d("Computed commit timeline",s)},Lr=async e=>{let t=e.ref.trim();if(!t)return l("ref must not be empty");if(t.length!==7)return l(`"${t}" is ${t.length} characters; a ref is ${7}. Read it off the issue rather than slicing the id by hand.`);let n=await Bh({repoRoot:e.repoRoot});if(a(n))return l(n.message);let o=`${t.toUpperCase()} `,r=c=>c.subject.toUpperCase().startsWith(o),s=n.value,i=[];for(let[c,u]of s.entries()){if(!r(u))continue;let p=s[c+1];i.push({...u,precedingSha:p&&r(p)?p.sha:null})}return d("Matched commits by ref",i)}});var rd,$h=g(()=>{"use strict";Ke();w();Tr();od();rd=async e=>{if(!Xs(e.sha))return l("Invalid commit sha");let t=lo(e.repoRoot);if(a(t))return l(t.message);let n=await W({cwd:t.value,args:["show","--no-ext-diff","--no-color","--patch","--find-renames","--format=",e.sha]});return a(n)?l(n.message):d("Read commit patch",n.value.stdout)}});var GS,Ma,jh,id,sd,ad,La,ld,Uh,zS,Hh,Wh,qh,cd,Pa=g(()=>{"use strict";Ta();GS=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/,Ma=e=>{if(!e.startsWith('"')||!e.endsWith('"'))return e;let t=e.slice(1,-1),n="";for(let o=0;o<t.length;o++){if(t[o]!=="\\"){n+=t[o];continue}let r=t[++o];if(r==="n")n+=`
87
- `;else if(r==="t")n+=" ";else if(r==='"'||r==="\\")n+=r;else if(r&&/[0-7]/.test(r)){let s=t.slice(o,o+3);n+=String.fromCharCode(parseInt(s,8)),o+=2}else r!==void 0&&(n+=r)}try{return decodeURIComponent(escape(n))}catch{return n}},jh=e=>{let t=Ma(e.trim());return t==="/dev/null"?null:t.replace(/^[ab]\//,"")},id=e=>{let t=[],n=null,o=0,r=0,s=()=>{let i={path:"",oldPath:null,binary:!1,added:0,removed:0,lines:[]};return t.push(i),i};for(let i of e.split(`
88
- `)){if(i.startsWith("diff --git ")){n=s();let m=i.slice(11),f=m.lastIndexOf(" b/");f!==-1&&(n.path=Ma(m.slice(f+1)).replace(/^b\//,""));continue}if(!n){if(!i.trim())continue;n=s()}let c=n,u=c.lines.length===0;if(u&&i.startsWith("--- ")){let m=jh(i.slice(4));m&&(c.oldPath=m);continue}if(u&&i.startsWith("+++ ")){let m=jh(i.slice(4));m&&(c.path=m);continue}if(u&&i.startsWith("rename from ")){c.oldPath=Ma(i.slice(12));continue}if(u&&i.startsWith("rename to ")){c.path=Ma(i.slice(10));continue}if(u&&(i.startsWith("Binary files ")||i.startsWith("GIT binary patch"))){c.binary=!0,c.lines.push({kind:"note",text:"Binary file"});continue}let p=GS.exec(i);if(p){o=Number(p[1]),r=Number(p[3]),c.lines.push({kind:"hunk",text:i});continue}if(!u){if(i.startsWith("\\")){c.lines.push({kind:"note",text:i.slice(1).trim()});continue}if(i.startsWith("+")){c.added++,c.lines.push({kind:"added",text:i.slice(1),newLine:r++});continue}if(i.startsWith("-")){c.removed++,c.lines.push({kind:"removed",text:i.slice(1),oldLine:o++});continue}if(i.startsWith(" ")){c.lines.push({kind:"context",text:i.slice(1),oldLine:o++,newLine:r++});continue}i===""&&c.lines.push({kind:"context",text:"",oldLine:o++,newLine:r++})}}for(let i of t)!i.path&&i.oldPath&&(i.path=i.oldPath);return t.filter(i=>i.path!=="")},sd=e=>e.oldPath&&e.oldPath!==e.path?e.oldPath:null,ad=e=>e.flatMap(t=>[{kind:"file",text:`${sd(t)?`${sd(t)} \u2192 `:""}${t.path}`,file:t},...t.lines]),La=e=>{let t="",n=-1;return e.map(o=>(o.kind==="file"&&(t=o.file.path),o.kind==="hunk"&&n++,{file:t,hunk:n}))},ld=(e,t,n)=>{let o=t.map(i=>Vs(i.md)).filter(i=>i!==null&&i.sha===n&&i.side==="additions");if(o.length===0)return new Set;let r=La(e),s=new Set;return e.forEach((i,c)=>{let u=i.newLine;if(u===void 0)return;let p=r[c]?.file;o.some(m=>m.filePath===p&&m.start<=u&&u<=m.end)&&s.add(c)}),s},Uh=(e,t)=>e===t?`line:${e}`:`lines:${e}-${t}`,zS=/^lines?:(\d+)(?:-(\d+))?(?:\s+|$)/,Hh=e=>{let t=zS.exec(e);if(!t)return null;let n=Number(t[1]),o=t[2]===void 0?n:Number(t[2]);return{start:Math.min(n,o),end:Math.max(n,o),note:e.slice(t[0].length)}},Wh=(e,t)=>La(e)[t]?.file??null,qh=(e,t,n,o)=>{let r=La(e),s=u=>e.findIndex((p,m)=>r[m]?.file===t&&(p.kind==="added"||p.kind==="context")&&p.newLine===u),i=s(n),c=s(o);return i===-1||c===-1?{ok:!1,reason:`${t} has no line ${i===-1?n:o} on the new side`}:cd(e,i,c)},cd=(e,t,n)=>{let[o,r]=t<=n?[t,n]:[n,t],s=e[o],i=e[r];if(!s||!i)return{ok:!1,reason:"That line is not in the diff"};let c=h=>(h.kind==="added"||h.kind==="context")&&h.newLine!==void 0;if(!c(s)||!c(i))return{ok:!1,reason:"Comments anchor to the new side: pick an added or unchanged line"};let u=La(e),p=u[o],m=u[r];if(p.file!==m.file)return{ok:!1,reason:"A comment covers one file at a time"};if(p.hunk!==m.hunk)return{ok:!1,reason:"A comment covers one hunk at a time"};let f=e.slice(o,r+1).filter(c);return{ok:!0,value:{filePath:p.file,start:f[0].newLine,end:f[f.length-1].newLine,snippet:f.map(h=>h.text).join(`
89
- `)}}}});import{spawn as VS,spawnSync as KS}from"node:child_process";import YS from"node:os";import Gh from"node:path";import{ulid as XS}from"ulid";function dd(e){let t=[],n="",o=!1,r=null;for(let s of e.trim()){if(r){s===r?r=null:n+=s;continue}if(s==='"'||s==="'"){r=s,o=!0;continue}if(/\s/.test(s)){o&&t.push(n),n="",o=!1;continue}n+=s,o=!0}return o&&t.push(n),t}function JS(e){let t=e.trim();return t==="$EDITOR"?process.env.EDITOR:t==="$VISUAL"?process.env.VISUAL:t}function Da(){let{preferredEditor:e}=le(),t=[e?JS(e):void 0,process.env.VISUAL,process.env.EDITOR].filter(n=>!!n?.trim());return[...new Set(t)]}function ud(e){let[t=""]=dd(e);return/(^|\/)code(-insiders)?$/.test(t)}function zh(e,t){let[n="",...o]=dd(e);return{command:n,args:[...o,...t]}}function Vh(e,t){return zh(e,ud(e)?["--wait",t]:[t])}function QS(e,t,n,o="new"){return zh(e,[o==="new"?"--new-window":"--reuse-window","--diff",t,n])}function Kh(e){let t=Gh.join(YS.tmpdir(),"epiq");Ze.mkDir(t);let n=Gh.join(t,XS());Ze.writeToFile(n,e??"");let o=Da();for(let r of o){let{command:s,args:i}=Vh(r,n);if(!s)continue;let c=KS(s,i,{stdio:"inherit"});if(!c.error&&c.status===0){let u=Ze.readFile(n);if(u==null)return l("Unable to read edited file");let p=u.replace(/\r?\n$/,"");return d("Successfully edited",p)}}return l("Unable to open editor")}function eN(e){let[t=""]=dd(e),n=t.split("/").pop()??t;return ZS.has(n)}function Yh({command:e,args:t},n){return new Promise(o=>{if(!e){o(l(`"${n}" is not a usable editor command`));return}let r=VS(e,t,{stdio:"ignore",detached:!0}),s=!1,i=u=>{s||(s=!0,clearTimeout(c),o(u))};r.on("error",u=>i(l(u.message))),r.on("exit",u=>{i(u===0?d("Opened editor",!0):l(`"${n}" exited with code ${u}`))});let c=setTimeout(()=>{r.unref(),i(d("Opened editor",!0))},tN)})}function nN(e,t){return eN(e)?Promise.resolve(l(`"${e}" is a terminal editor and can't open from the GUI (no terminal attached). Set preferredEditor to a GUI editor (e.g. "code"), or open the file yourself: ${t}`)):Yh(Vh(e,t),e)}function md(e,t,n,o="new"){return Yh(QS(e,t,n,o),e)}async function Xh(e){let t=Da();if(t.length===0)return l("No editor configured (preferredEditor, VISUAL, or EDITOR)");let n=l("Unable to open editor");for(let o of t){let r=await nN(o,e);if(!a(r))return r;n=r,logger.error(`Failed to open editor "${o}" for ${e}: ${r.message}`)}return n}var ZS,tN,pd=g(()=>{"use strict";w();Fe();ha();ZS=new Set(["vim","vi","nvim","nano","pico","ed"]);tN=600});import{chmodSync as oN,existsSync as rN,lstatSync as sN,mkdirSync as iN}from"node:fs";import aN from"node:os";import lN from"node:path";var Js,fd=g(()=>{"use strict";w();Js=(...e)=>{let t=lN.join(aN.tmpdir(),"epiq",...e);try{return rN(t)&&sN(t).isSymbolicLink()?l(`Refusing to write through a symlink at ${t}`):(iN(t,{recursive:!0,mode:448}),oN(t,448),d("Prepared private temp dir",t))}catch(n){return l(`Unable to prepare ${t}: ${n instanceof Error?n.message:String(n)}`)}}});import{existsSync as gd}from"node:fs";import{chmod as hd}from"node:fs/promises";import Oa from"node:path";var cN,dN,uN,Jh,mN,pN,vd,Qh=g(()=>{"use strict";Ke();pd();w();ha();fd();Tr();cN=async(e,t)=>{let n=await W({cwd:e,args:["show",t]});if(a(n))return l(n.message);let o=Js("commit-diffs");if(a(o))return l(o.message);let r=Oa.join(o.value,`${t}.diff`);return gd(r)||(Ze.writeToFile(r,n.value.stdout),await hd(r,292)),Xh(r)},dN=12,uN=800,Jh=async(e,t,n)=>{let o=await W({cwd:e,args:["show",`${t}:${n}`]});return a(o)?"":o.value.stdout},mN=async(e,t)=>{let n=await W({cwd:e,args:["diff","--name-only",`${t}~1`,t]});if(a(n))return l(n.message);let o=n.value.stdout.split(`
90
- `).map(r=>r.trim()).filter(Boolean);return o.length===0?l("No changed files found for this commit"):d("Listed changed files",o)},pN=async(e,t,n)=>{let o=await mN(e,t);if(a(o))return l(o.message);let r=o.value;if(r.length>dN)return l(`Commit touches ${r.length} files \u2014 too many for a side-by-side view`);let s=Js("commit-diffs",t);if(a(s))return l(s.message);let i=s.value,c=await Promise.all(r.map(async(h,x)=>{let[E,S]=await Promise.all([Jh(e,`${t}~1`,h),Jh(e,t,h)]),C=Oa.basename(h),R=Oa.join(i,String(x),"before",C),A=Oa.join(i,String(x),"after",C);return gd(R)||(Ze.writeToFile(R,E),await hd(R,292)),gd(A)||(Ze.writeToFile(A,S),await hd(A,292)),{beforePath:R,afterPath:A}})),[u,...p]=c;if(!u)return l("No changed files found for this commit");let m=await md(n,u.beforePath,u.afterPath,"new");if(a(m)||p.length===0)return m;await new Promise(h=>setTimeout(h,uN));let f=await Promise.all(p.map(({beforePath:h,afterPath:x})=>md(n,h,x,"reuse")));for(let h of f)a(h)&&logger.error(`Failed to open an additional diff tab for ${t}: ${h.message}`);return m},vd=async e=>{if(!Xs(e.sha))return l("Invalid commit sha");let t=lo(e.repoRoot);if(a(t))return l(t.message);let n=t.value,o=Da()[0];if(o&&ud(o)){let r=await pN(n,e.sha,o);if(!a(r))return r;logger.error(`Side-by-side diff failed for ${e.sha}, falling back to unified diff: ${r.message}`)}return cN(n,e.sha)}});var Qs=g(()=>{"use strict";Tr();od();$h();Pa();Qh()});var Fa,Pr,yd=g(()=>{"use strict";w();eo();O();Zo();pe();Fa=(e,t,n)=>{let o=[],r=Gi(()=>{for(let s=0;s<t;s++){let i=Ct(BigInt(s+1));if(!Dt(i))continue;let c=N.createNode(Be.text({id:n(s),name:`Line ${s+1}`,parentNodeId:e,rank:i.value,readonly:!0,isVirtual:!0}));Dt(c)&&o.push(c.value)}});return a(r)&&logger.error(`Line nodes: ${r.message}`),o},Pr=e=>{N.deleteNodes(e.map(t=>t.id))}});import{useSyncExternalStore as fN}from"react";var Ba,_a,bd,Zh,xd,$a,ev,Ho,Id,tv,co,ja=g(()=>{"use strict";O();Ba=null,_a=null,bd=new Set,Zh=()=>{for(let e of bd)e()},xd=e=>{Ba=e,Zh()},$a=()=>Ba,ev={mark:null},Ho=e=>{_a=e,ev={mark:e},Zh()},Id=e=>_a&&_a.sha===e?_a.row:null,tv=()=>fN(e=>(bd.add(e),()=>{bd.delete(e)}),()=>ev),co=()=>{let{contextNode:e}=v();return Ba&&Ba.sha===e.id?e.id:null}});var nv=g(()=>{"use strict"});import{Box as an,Text as Un}from"ink";import De,{useEffect as Ed,useMemo as ov,useRef as hN,useState as vN}from"react";import yN from"string-width";function iv({ticket:e,sha:t,subject:n,width:o,height:r}){let[s,i]=vN({state:"loading"});Ed(()=>{let L=!0;return i({state:"loading"}),rd({sha:t}).then(_=>{L&&i(a(_)?{state:"failed",message:_.message}:{state:"loaded",rows:ad(id(_.value))})}),()=>{L=!1}},[t]);let c=s.state==="loaded"?s.rows:null,u=c!==null&&c.length>4e3,p=hN([]);Ed(()=>(Pr(p.current),p.current=c&&!u?Fa(t,c.length,L=>Rd(t,L)):[],()=>{Pr(p.current),p.current=[]}),[t,c,u]),Ed(()=>(xd(c?{sha:t,rows:c}:null),Ho(null),()=>{xd(null),Ho(null)}),[t,c]);let{selectedIndex:m}=Ye(),{mark:f}=tv(),h=ov(()=>c?ld(c,N.getCommentsByIssue(e.id),t):new Set,[c,t,e]),x=f&&f.sha===t?f.row:null,E=L=>x!==null&&L>=Math.min(x,m)&&L<=Math.max(x,m),S=ov(()=>c?Math.max(5,c.reduce((L,_)=>Math.max(L,sv(_).length),0)+2):5,[c]),C=Math.max(1,r-4),R=Math.max(8,o-S-6);if(s.state!=="loaded")return De.createElement(an,{flexDirection:"column",width:o,height:r,padding:1},De.createElement(Un,{color:k.primary},s.state==="loading"?"Reading the diff\u2026":`Could not read the diff: ${s.message}`));let A=L=>De.createElement(an,{paddingLeft:4,borderLeft:!1,borderRight:!1,borderBottom:!1,borderTop:!0,borderColor:k.secondary,borderStyle:"single",paddingBottom:1},De.createElement(Un,{color:k.secondary2,wrap:"truncate-end"},Eo(`${t.slice(0,7)} ${n} \u2014 ${L}`,Math.max(8,o-6))));return s.rows.length===0?De.createElement(an,{flexDirection:"column",width:o,height:r},A("no changes"),De.createElement(an,{paddingX:1},De.createElement(Un,{color:k.primary},"This commit changed no files."))):u?De.createElement(an,{flexDirection:"column",width:o,height:r},A("too large to draw here"),De.createElement(an,{paddingX:1,flexDirection:"column"},De.createElement(Un,{color:k.primary},`${s.rows.length.toLocaleString()} lines of diff.`),De.createElement(Un,{color:k.secondary2},"Press o to open it in your editor."))):De.createElement(an,{flexDirection:"column",width:o,height:r},A(x===null?"enter to comment on a line, s to start a range, o editor, q back":"move to the other end, then enter to comment \u2014 s clears the mark"),De.createElement(Ht,{scrollByOne:!0,height:C,selectedIndex:m,itemHeight:1},s.rows.map((L,_)=>{let j=_===m,z=bN(L.kind);if(L.kind==="file")return De.createElement(an,{key:Rd(t,_),paddingX:1},De.createElement(Un,{backgroundColor:k.secondary,color:j?k.accent:z,bold:!0,wrap:"truncate-end"},rv(` ${Eo(Ys(L.text),R)}`,R+S+1)));let X=E(_),ue=`${xN(L.kind)}${Eo(Ys(L.text),R)}`;return De.createElement(an,{key:Rd(t,_),paddingX:1},De.createElement(an,{flexShrink:0},De.createElement(Un,{color:j||X?k.accent:k.secondary2,dimColor:!j&&!X,wrap:"truncate-end"},`${j?"\u276F":"\xA0"}${X?"\u258C":"\xA0"}${sv(L).padStart(S-2,"\xA0")}`)),De.createElement(an,{flexShrink:0},De.createElement(Un,{color:k.yellow,wrap:"truncate-end"},h.has(_)?"\u2502":"\xA0")),De.createElement(Un,{color:j?k.accent:z,backgroundColor:j||X?k.secondary:void 0,wrap:"truncate-end"},j||X?rv(ue,R+1):ue))})))}var Rd,bN,rv,xN,sv,av=g(()=>{"use strict";Qs();pe();w();yd();ja();O();Je();nv();ka();ht();$o();Rd=(e,t)=>`${e}::patch::${t}`,bN=e=>{switch(e){case"added":return k.green;case"removed":return k.red;case"hunk":return k.accent;case"file":return k.primary;default:return k.secondary2}},rv=(e,t)=>{let n=yN(e);return n>=t?e:e+"\xA0".repeat(t-n)},xN=e=>e==="added"?"+":e==="removed"?"-":" ",sv=e=>e.kind==="file"||e.kind==="hunk"||e.kind==="note"||e.newLine===void 0?"":String(e.newLine)});import{Box as Wo,Text as In}from"ink";import Ge,{useEffect as lv,useRef as IN,useState as EN}from"react";function dv({ticket:e,width:t,height:n}){let[o,r]=EN({state:"loading"}),s=V(e.id);lv(()=>{let E=!0;return r({state:"loading"}),Lr({ref:s}).then(S=>{E&&r(a(S)?{state:"failed",message:S.message}:{state:"loaded",commits:S.value})}),()=>{E=!1}},[s]);let i=IN([]),c=o.state==="loaded"?o.commits:null;lv(()=>(cv(i.current),i.current=c?NN(e,c):[],()=>{cv(i.current),i.current=[]}),[e,c]);let{selectedIndex:u,contextNode:p}=Ye(),m=c?.find(E=>E.sha===p.id)??null,h=Math.max(1,n-4),x=Math.max(12,t-34);return o.state!=="loaded"?Ge.createElement(Wo,{flexDirection:"column",width:t,height:n,padding:1},Ge.createElement(In,{color:k.primary},o.state==="loading"?"Reading commits\u2026":`Could not read commits: ${o.message}`)):m?Ge.createElement(iv,{ticket:e,sha:m.sha,subject:m.subject,width:t,height:n}):o.commits.length===0?Ge.createElement(Wo,{flexDirection:"column",width:t,height:n,padding:1},Ge.createElement(In,{color:k.primary},"No commits reference this ticket."),Ge.createElement(Wo,{paddingTop:1},Ge.createElement(In,{color:k.primary},"Commits are matched by the"),Ge.createElement(In,{color:k.accent},` ${s} `),Ge.createElement(In,{color:k.primary},"prefix on their subject line."))):Ge.createElement(Wo,{flexDirection:"column",width:t,height:n},Ge.createElement(Wo,{paddingLeft:4,borderLeft:!1,borderRight:!1,borderBottom:!1,borderTop:!0,borderColor:k.secondary,borderStyle:"single",paddingBottom:1},Ge.createElement(In,{color:k.secondary2},`Diff (${o.commits.length}) \u2014 enter to read, o to open in your editor `)),Ge.createElement(Ht,{height:h,itemHeight:2,selectedIndex:u},o.commits.map((E,S)=>{let C=S===u,R=E.subject.length>x?E.subject.slice(0,x-1)+"\u2026":E.subject;return Ge.createElement(Wo,{key:E.sha,flexDirection:"row",paddingX:1,paddingBottom:1},Ge.createElement(In,{color:k.accent},C?"\u276F ":" "),Ge.createElement(Wo,{paddingLeft:1},Ge.createElement(In,{color:k.secondary2},`${E.sha.slice(0,7)} `),Ge.createElement(In,{color:C?k.accent:k.primary},R),Ge.createElement(In,{color:k.secondary2},` ${wN(E)} ${so(E.time)}`)))})))}var RN,cv,SN,NN,wN,uv=g(()=>{"use strict";xt();Qs();me();w();pe();eo();O();Je();zs();mt();oo();av();$o();RN=e=>Te(e,"diff"),cv=e=>{for(let t of e)N.deleteNode(t.id)},SN=(e,t,n)=>Be.field({id:e.sha,name:e.subject,parentNodeId:n,rank:String(t).padStart(6,"0"),childRenderAxis:"vertical",isVirtual:!0}),NN=(e,t)=>{let n=N.getNode(RN(e.id));if(!n||!ot(n))return[];let o=t.map((r,s)=>SN(r,s,n.id)).map(r=>N.createNode(r)).filter(Dt).map(({value:r})=>r).filter(ot);return t.length>0&&v().selectedIndex<0&&v().contextNode.id===n.id&&H.navigate({contextNode:n,selectedIndex:0}),o},wN=e=>`+${e.insertions} -${e.deletions}`});import{Box as Ua,Text as CN}from"ink";import Hn from"react";var mv,pv=g(()=>{"use strict";me();pe();sr();O();Je();Sa();Er();Xc();mv=({selectedIndex:e,parent:t,selected:n})=>{let{contextNode:o}=Ye(),{title:r}=t,s=t.parentNodeId?N.getNode(t.parentNodeId):void 0,i=s&&U(s)?r===Ce.ASSIGNEES?s.props.assignees??[]:r===Ce.TAGS?(s.props.tags??[]).filter(c=>N.getTag(c)):[]:[];return Hn.createElement(Ua,{alignItems:"center",paddingTop:1},Hn.createElement(Ua,{minWidth:12},Hn.createElement(Ut,{isSelected:n}),Hn.createElement(CN,{color:n?k.accent:k.secondary2},r,":")),Hn.createElement(Ua,{flexDirection:"row",marginLeft:1,paddingRight:1},i.map((c,u)=>{let p=o.id===t.id&&u===e;return Hn.createElement(Ua,{key:`${r}-${c}`,paddingRight:2,minHeight:1},Hn.createElement(Ut,{isSelected:p}),r===Ce.ASSIGNEES?Hn.createElement(Rr,{isSelected:p,id:c}):r===Ce.TAGS?Hn.createElement(Na,{isSelected:p,id:c}):null)})))}});var Sd,fv,Nd,wd=g(()=>{"use strict";Sd=e=>Math.max(5,String(Math.max(e,1)).length+3),fv=(e,t)=>Math.max(0,e-6-Sd(t)),Nd=(e,t=0,n=0)=>Math.max(1,e-5-2*t-(n>0?1+n:0))});import{Box as Dr,Text as Cd}from"ink";import qt,{useEffect as AN,useMemo as Ad,useRef as TN}from"react";var kN,gv,Td,hv=g(()=>{"use strict";yd();O();Je();ht();wd();Er();$o();nd();ka();kN="\u2029",gv=(e,t)=>`${e}::inline-line::${t}`,Td=({id:e,label:t,text:n,rows:o,selected:r,maxWidth:s})=>{let{selectedIndex:i,contextNode:c}=Ye(),u=Ad(()=>typeof n=="string"?n.split(/\r?\n|\u2028|\u2029/):[],[n]),p=Ad(()=>u.join("\0"),[u]),m=TN([]);AN(()=>(Pr(m.current),m.current=Fa(e,u.length,S=>gv(e,S)),()=>{Pr(m.current),m.current=[]}),[e,p]);let f=Sd(u.length),h=fv(s,u.length),E=Ad(()=>ed(u).map(S=>{if(S.kind==="code"||S.kind==="caption")return{...S,text:Eo(S.text,h)};if(S.kind==="text"||S.kind==="heading"){let C=S.spans.map(R=>R.code?`\`${R.text}\``:R.text).join("");return{...S,spans:Ks(Eo(C,h))}}return S}),[u,h]).map((S,C)=>{let R=c.id===e&&i===C;return qt.createElement(Dr,{key:gv(e,C)},qt.createElement(Dr,{flexShrink:0},qt.createElement(Cd,{color:R?k.primary:k.secondary2,dimColor:!R},`${C+1} `.padStart(f,"\xA0"))),S.kind==="blank"?qt.createElement(Cd,{backgroundColor:R?"gray":void 0},kN):qt.createElement(Dr,null,qt.createElement(td,{line:S,width:S.kind==="code"?h:0,wrap:"truncate-end"})))});return qt.createElement(Dr,{flexDirection:"column",paddingTop:1},qt.createElement(Dr,null,qt.createElement(Ut,{isSelected:r}),qt.createElement(Cd,{color:r?k.accent:k.secondary2},t)),qt.createElement(Dr,{flexDirection:"row",borderStyle:"round",borderColor:k.secondary,paddingLeft:1,marginLeft:1,overflowY:"hidden"},qt.createElement(Ht,{scrollByOne:!0,height:o,selectedIndex:i,itemHeight:1},E)))}});import{Box as Or,Text as MN}from"ink";import Et,{useMemo as Fr}from"react";var LN,PN,DN,ON,FN,vv,yv=g(()=>{"use strict";me();pe();O();Je();Aa();oo();vh();Oh();Er();uv();pv();hv();wd();LN=e=>Te(e,"description"),PN=e=>Te(e,"comments"),DN=e=>Te(e,"history"),ON=e=>Te(e,"diff"),FN=e=>Te(e,"attachments"),vv=({ticket:e,height:t})=>{let n=Fr(()=>uh(e),[e]),{selectedIndex:o,contextNode:r}=Ye(),s=process.stdout.columns||120,i=Fr(()=>LN(e.id),[e.id]),c=Fr(()=>PN(e.id),[e.id]),u=Fr(()=>DN(e.id),[e.id]),p=Fr(()=>ON(e.id),[e.id]),m=Fr(()=>FN(e.id),[e.id]),f=N.getAttachmentsByIssue(e.id).length,h=r.id===e.id,x=r.id===c||r.parentNodeId===c,E=r.id===u||r.parentNodeId===u,S=r.id===m||r.parentNodeId===m,C=r.id===p||r.parentNodeId===p,R=ve(e.id);if(x){let ae=t-3;return Et.createElement(Or,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},Et.createElement(Dh,{ticket:e,width:s,height:ae}))}if(S){let ae=t-3;return Et.createElement(Or,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},Et.createElement(hh,{ticket:e,width:s,height:ae}))}if(C){let ae=t-3;return Et.createElement(Or,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},Et.createElement(dv,{ticket:e,width:s,height:ae}))}if(E){let q=N.getNode(u),ae=q&&ot(q)?q.props.value??"":"",Pt=Nd(t);return Et.createElement(Or,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},q?Et.createElement(Td,{id:q.id,label:"Event log",text:ae,selected:!1,maxWidth:s,rows:Pt}):null)}let A=[u,p,c,m],L=q=>A.includes(q),_=R.reduce((q,ae)=>as(ae)?q+1:q,0),j=R.reduce((q,ae)=>L(ae.id)?q+1:q,0),z=R.findIndex(q=>L(q.id)),X=Nd(t,_,j),ue=(q,ae,Pt,Qr)=>Et.createElement(Or,{key:q.id,paddingTop:ae===z?1:0},Et.createElement(Ut,{isSelected:Pt}),Et.createElement(MN,{backgroundColor:k.secondary,color:Pt?k.accent:k.primary},Qr)),ze=(q,ae,Pt)=>q.id===i?Et.createElement(Td,{key:q.id,id:i,label:"Description (press e to edit)",text:e.props.description??"",selected:ae,maxWidth:s,rows:X}):as(q)?Et.createElement(mv,{key:q.id,parent:q,selected:ae,selectedIndex:o}):q.id===c?ue(q,Pt,ae,` Comments (${n}) \u203A\u203A `):q.id===m?ue(q,Pt,ae,` Attachments (${f}) \u203A\u203A `):q.id===u?ue(q,Pt,ae," History \u203A\u203A "):q.id===p?ue(q,Pt,ae," Diff \u203A\u203A "):null;return Et.createElement(Or,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},R.map((q,ae)=>ze(q,h&&o===ae,ae)))}});import{Box as _N}from"ink";import Ha from"react";var BN,bv,xv=g(()=>{"use strict";me();dh();yv();BN=({swimlanes:e,contextNode:t,selectedIndex:n,breadCrumb:o,mode:r,viewMode:s,height:i,width:c})=>{let u=t.context,p=u===se.TICKET||u===se.FIELD_LIST||u===se.FIELD,m=u===se.BOARD||u===se.SWIMLANE,f=u===se.TICKET?t:o.find(C=>C.context===se.TICKET),h=Math.floor(c/3),x=Math.floor(c/Math.max(e.length,1)),E=Math.min(x,h),S=s==="dense";return Ha.createElement(_N,{flexDirection:"row",height:i},m&&e.map((C,R)=>{let A=t.id===C.id,L=A?n:-1,_=t.context===se.BOARD&&n===R;return Ha.createElement(ch,{key:C.id,height:i,width:E,swimlane:C,isSelected:_,isDense:S,isFocused:A,listSelectedIndex:L,mode:r})}),p&&f&&Ha.createElement(vv,{height:i,ticket:f}))},bv=Ha.memo(BN)});import Iv from"node:fs";import $N from"node:path";import jN from"react";import{render as UN}from"ink";import{Writable as HN}from"node:stream";var Zs,WN,qN,GN,zN,Ev,Rv=g(()=>{"use strict";xv();me();w();O();ee();Fe();Zs=e=>String(e).padStart(2,"0"),WN=e=>{let t=e.getUTCFullYear(),n=Zs(e.getUTCMonth()+1),o=Zs(e.getUTCDate()),r=Zs(e.getUTCHours()),s=Zs(e.getUTCMinutes()),i=Zs(e.getUTCSeconds());return`${t}-${n}-${o}_${r}-${s}-${i}`},qN=e=>e.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^[-.]+|[-.]+$/g,"").toLowerCase()||"board",GN=async(e,{width:t,height:n})=>{let o="",r=new HN({write(i,c,u){let p=zN(i.toString()).trimEnd();p.trim().length>0&&p.includes("\u256D")&&(o=p),u()}});r.columns=t,r.rows=n,r.isTTY=!0;let s=UN(e,{stdout:r,debug:!1,exitOnCtrlC:!1,patchConsole:!1,incrementalRendering:!1});return await new Promise(i=>setTimeout(i,0)),s.unmount(),o},zN=e=>e.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,""),Ev=async()=>{let{viewMode:e}=le(),{contextNode:t,selectedIndex:n,breadCrumb:o,mode:r,renderedChildrenIndex:s}=v(),i=o.find(R=>R.context==="BOARD");if(!i)return l("No board found to export");let c=120,u=40,p=await GN(jN.createElement(bv,{height:u,width:c,swimlanes:(s[i.id]??[]).filter(R=>R!==void 0&&bo(R)),contextNode:t,selectedIndex:n,breadCrumb:o,viewMode:e??"dense",mode:r}),{width:c,height:u});if(!p)return l("Failed to render board export");let m=Mi(process.cwd());if(a(m))return l("Unable to export, epiq root not found");let f=new Date,h=WN(f),x=`board_${qN(i.title)}_${h}.md`,E=lp(m.value);Iv.mkdirSync(E,{recursive:!0});let S=$N.join(E,x),C=`# Board - ${i.title}
69
+ ${p.message}`)}if(s&&!$n.existsSync(s)){ce.info("Pruning stale state branch worktree");let u=await Ne.worktreePrune({cwd:e});if(a(u))return l(`Failed to prune stale worktrees
70
+ ${u.message}`)}let i=await Zm({repoRoot:e,worktreeRoot:t});if(a(i))return l(i.message);let c=$n.existsSync(t);if(i.value&&c)return d("State branch worktree already exists",!1);if(i.value&&!c){ce.info("Pruning missing registered state branch worktree");let u=await Ne.worktreePrune({cwd:e});if(a(u))return l(`Failed to prune stale worktrees
71
+ ${u.message}`)}return gS({repoRoot:e,stateBranchRoot:t,stateBranchName:n})},yS=async({stateBranchRoot:e,stateBranchName:t})=>{let n=await Bi(e);if(a(n))return l(n.message);if(n.value===t)return d("State branch already checked out",!1);(await Le({cwd:e,args:["rebase","--abort"]})).exitCode===0&&ce.info("Aborted stale state branch rebase");let o=await Ne.checkout({cwd:e,branch:t});return a(o)?l(`Failed to checkout ${t}
72
+ ${o.message}`):d("Checked out state branch",!0)},bS=async({repoRoot:e,stateBranchRoot:t})=>{let n=await Kl(t);if(a(n))return l(n.message);if(n.value)return d("State branch upstream already configured",!1);let r=await Mn({repoRoot:t});if(a(r))return l(r.message);if(!r.value)return d("No remote available for state branch upstream",!1);let o=dt(e);if(a(o))return o;let s=o.value,i=await ps({repoRoot:t,branch:s});if(a(i))return l(i.message);if(!i.value)return d("Remote state branch missing; upstream will be configured on first push",!1);ce.info(`Configuring ${s} upstream`);let c=await Ne.fetch({cwd:t,remote:At,branch:s});if(a(c))return l(`Failed to fetch ${s}
73
+ ${c.message}`);let u=await Ne.setUpstream({cwd:t,branch:s,upstream:`${At}/${s}`});return a(u)?l(`Failed to set state branch upstream
74
+ ${u.message}`):d("Configured state branch upstream",!0)},Sa=async({stateBranchRoot:e,eventFileName:t})=>{let n=up(t),r=jn.join(e,n);if(!$n.existsSync(r))return d("No event file to stage",null);let o=await eh({stateBranchRoot:e,relativePath:n,workingContent:$n.readFileSync(r,"utf8")});if(a(o))return l(o.message);let s=await Ne.stage({cwd:e,pathspec:[n]});return a(s)?l(`Failed to stage state branch event file
75
+ ${s.message}`):d("Staged state branch event file",n)},rh=async({stateBranchRoot:e})=>{let t=mp(),n=jn.join(e,t);if(!$n.existsSync(n))return d("No media directory to stage",null);let r=await Ne.stage({cwd:e,pathspec:[t],ignoreRemoval:!0});return a(r)?l(`Failed to stage state branch media files
76
+ ${r.message}`):d("Staged state branch media files",t)},oh=async({stateBranchRoot:e})=>{let t=[Xl(),Jl(),st].filter(r=>$n.existsSync(jn.join(e,r)));if(t.length===0)return d("No event log config to stage",[]);let n=await Ne.stage({cwd:e,pathspec:t});return a(n)?l(`Failed to stage event log config
77
+ ${n.message}`):d("Staged event log config",t)},sh=async({repoRoot:e,stateBranchRoot:t,pathspec:n})=>{let r=await pS(e);return a(r)?l(`Create state branch sync commit failed
78
+ `+r.message):so({cwd:t,message:r.value,pathspec:n})},Ks=async({repoRoot:e,stateBranchRoot:t})=>{let n=await Kl(t);if(a(n))return l(n.message);let r=dt(e);if(a(r))return r;let o=r.value,s=n.value?await Ne.push({cwd:t}):await Ne.push({cwd:t,remote:At,branch:o,setUpstream:!0});if(a(s))return l(`Failed during state branch push
79
+ ${s.message}`);let i=!`${s.value.stdout}${s.value.stderr}`.includes("Everything up-to-date");return d(i?"Pushed state branch":"Remote already up to date",i)},ih=async({repoRoot:e,stateBranchRoot:t,ensureUpstream:n})=>{let r=!1,o=dt(e);if(a(o))return o;let s=o.value,i=[vs(),await Vs({repoRoot:e,stateBranchName:s}),await ir({repoRoot:e,stateBranchRoot:t,stateBranchName:s}),await yS({stateBranchRoot:t,stateBranchName:s}),await hp(t),n?await bS({stateBranchRoot:t,repoRoot:e}):d("Skipped state branch upstream bootstrap",!1)];for(let c of i){if(a(c))return l(c.message);r=r||!!c.value}return d(n?"Bootstrapped state storage":"Bootstrapped state storage readonly",r)}});import Co from"node:fs";import Jc from"node:os";import xS from"node:path";var Qc,ah,IS,ES,RS,ch,Xc,lh,SS,Xs,Zc=g(()=>{"use strict";N();Ke();_t();Qc="epiq-sync.lock",ah=600*1e3,IS=e=>{try{let t=JSON.parse(e);return typeof t.pid!="number"||typeof t.hostname!="string"||typeof t.startedAt!="number"||typeof t.operation!="string"?null:t}catch{return null}},ES=e=>{try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}},RS=e=>e?e.hostname!==Jc.hostname()||ES(e.pid)?Date.now()-e.startedAt>ah?"stale":null:"dead":"stale",ch=e=>`${e.operation} (pid ${e.pid} on ${e.hostname}, started ${new Date(e.startedAt).toISOString()})`,Xc=e=>{try{return IS(Co.readFileSync(e,"utf8"))}catch{return null}},lh=(e,t)=>{let n={pid:process.pid,hostname:Jc.hostname(),startedAt:Date.now(),operation:t},r=`${e}.${process.pid}.pending.lock`;try{return Co.writeFileSync(r,JSON.stringify(n)),Co.linkSync(r,e),!0}catch{return!1}finally{try{Co.rmSync(r,{force:!0})}catch{}}},SS=async({worktreeRoot:e,operation:t})=>{let n=await _i(e);if(a(n))return l(n.message);let r=xS.join(n.value,Qc),o=()=>{try{let u=Xc(r);u&&u.pid===process.pid&&Co.rmSync(r)}catch{}};if(lh(r,t))return d("Acquired sync lock",{acquired:!0,claim:"clean",release:o});let s=Xc(r),i=RS(s);if(i===null)return d("Sync lock is held",{acquired:!1,heldBy:s});ce.info(`Breaking an abandoned sync lock: ${s?ch(s):"unreadable lock file"}`);try{Co.rmSync(r,{force:!0})}catch{}if(lh(r,t))return d("Acquired sync lock after breaking a stale one",{acquired:!0,claim:i,release:o});let c=Xc(r);return d("Sync lock taken by another process",{acquired:!1,heldBy:c??{pid:-1,hostname:Jc.hostname(),startedAt:Date.now(),operation:"unknown"}})},Xs=async({worktreeRoot:e,operation:t,fn:n})=>{let r=await SS({worktreeRoot:e,operation:t});if(a(r))return l(r.message);if(!r.value.acquired)return ce.info(`Skipping ${t}: the state worktree is held by ${ch(r.value.heldBy)}`),d("State worktree is held by another process",null);let{claim:o,release:s}=r.value;try{return d("Ran under the sync lock",await n(o))}finally{s()}}});import uh from"node:fs";var NS,CS,ed,dh,Na,Ca,wa=g(()=>{"use strict";N();Gs();pa();ee();Ea();mn();rt();Ke();Ys();Kc();_r();Zc();NS=async({claim:e,cwd:t,ensureUpstream:n})=>{logger.debug("[sync] ensureSyncReady:start",{cwd:t,ensureUpstream:n});let r=ve("getRepoRootDir",await kt(t));if(a(r))return l(r.message);let o=r.value;logger.debug("[sync] repo root",o);let s=ve("getStateBranchRoot",Ie({repoRoot:o}));if(a(s))return l(s.message);let i=s.value;if(logger.debug("[sync] state branch root",i),e!=="stale"&&uh.existsSync(i)){let m=await rp(i,{preserve:[Qc]});if(a(m))return l(m.message);m.value.length>0&&logger.info("[sync] cleared git lock files left by a dead process",{removed:m.value,stateBranchRoot:i});let f=ve("abortRebaseIfPresent(stateBranchRoot)",await Yl(i));if(a(f))return l(f.message)}logger.debug("[sync] bootstrapping state branch storage",{repoRoot:o,stateBranchRoot:i,ensureUpstream:n});let c=ve("bootstrapStateBranchStorage",await ih({repoRoot:o,stateBranchRoot:i,ensureUpstream:n}));if(a(c))return l(c.message);logger.debug("[sync] bootstrap result",{bootstrapped:c.value,stateBranchRoot:i}),logger.debug("[sync] checking state branch git operation",{stateBranchRoot:i});let u=ve("getInProgressGitOperation(stateBranchRoot)",await Vl(i));if(a(u))return l(u.message);if(logger.debug("[sync] state branch git operation check result",{inProgress:u.value}),u.value!==null)return logger.info("[sync] state branch git operation in progress",{claim:e}),l(`Cannot sync while there is a ${u.value} in the state branch at ${i}`);logger.debug("[sync] ensuring state branch layout",{repoRoot:o,stateBranchRoot:i});let p=ve("ensureStateBranchLayout",gp(o,i));return a(p)?l(p.message):(logger.debug("[sync] state branch layout ready"),logger.debug("[sync] ensureSyncReady:done",{repoRoot:o,stateBranchRoot:i,bootstrapped:c.value}),d("Sync preconditions satisfied",{repoRoot:o,stateBranchRoot:i,bootstrapped:c.value}))},CS=async({repoRoot:e,stateBranchRoot:t,ownEventFileName:n})=>{logger.debug("[sync] committing own event file from state branch",{ownEventFileName:n,stateBranchRoot:t}),logger.debug("[sync] staging own event file",{stateBranchRoot:t,ownEventFileName:n});let r=[];for(let p of rg(bt(t),n)){let m=ve("stageStateBranchOwnEventFile",await Sa({stateBranchRoot:t,eventFileName:p}));if(a(m))return l(m.message);r.push(m.value)}let o=ve("stageStateBranchMediaFiles",await rh({stateBranchRoot:t}));if(a(o))return l(o.message);let s=ve("stageStateBranchEventConfig",await oh({stateBranchRoot:t}));if(a(s))return l(s.message);let i=[...r,o.value,...s.value].filter(p=>p!==null);if(i.length===0)return d("Nothing to stage",{createdCommit:!1});let c=ve("hasStagedChanges(after stage)",await ip(t,i));if(a(c))return l(c.message);if(logger.debug("[sync] state branch change check after stage result",{changed:c.value}),!c.value)return logger.info("[sync] no own event file changes to commit"),d("No own event file changes to commit",{createdCommit:!1});logger.debug("[sync] creating sync commit");let u=ve("createStateBranchSyncCommit",await sh({repoRoot:e,stateBranchRoot:t,pathspec:i}));return a(u)?l(u.message):(logger.debug("[sync] created sync commit",u.value),d("Committed own event file",{createdCommit:!0,commitSha:u.value}))},ed=(e,t="offline")=>{let n=e.createdCommit?`Committed locally, ${t}`:t==="offline"?"Offline":"No remote";return Ia(n),d(n,{...e,pulled:!1,pushed:!1,offline:!0})},dh=async({cwd:e=process.cwd(),ownEventFileName:t},n)=>{if(logger.debug("[sync] syncEpiqWithRemote:start",{cwd:e,ownEventFileName:t}),t.includes("/")||t.includes("\\"))return logger.error("[sync] invalid own event file name: contains path separator",{ownEventFileName:t}),l("Own event file must be a file name, not a path");if(!t.endsWith(".jsonl"))return logger.error("[sync] invalid own event file name: missing .jsonl suffix",{ownEventFileName:t}),l("Own event file must end with .jsonl");Ro();let r=ve("ensureSyncReady",await NS({claim:n,cwd:e,ensureUpstream:!0}));if(a(r))return je(r.message);let{repoRoot:o,stateBranchRoot:s,bootstrapped:i}=r.value,c=ve("isDetachedHead(stateBranchRoot)",await ap(s));if(a(c))return je(c.message);if(logger.debug("[sync] detached state branch check result",{detached:c.value}),c.value)return je("Cannot run :sync while the state branch is in detached HEAD state");let u=!1,p,m=!1,f=!1,h=ve("getStateBranch",dt(o));if(a(h))return je(h.message);let b=h.value;logger.debug("[sync] resolved state branch",{stateBranch:b,stateBranchRoot:s});let E=ve("flushPendingLogs",aa(s,t));a(E)&&logger.error(`[sync] ${E.message}`);let S=ve("commitOwnEventFileToStateBranch",await CS({repoRoot:o,stateBranchRoot:s,ownEventFileName:t}));if(a(S))return je(S.message);u=S.value.createdCommit,p=S.value.commitSha;let w=ve("hasRemote",await Mn({repoRoot:s}));if(a(w))return je(w.message);if(!w.value)return ed({repoRoot:o,stateBranchRoot:s,createdCommit:u,commitSha:p,bootstrapped:i},"no remote");let R=ve("pullBranchRebaseIfPresent",await gs({cwd:s,branch:b}));if(a(R))return fs(R.message)?ed({repoRoot:o,stateBranchRoot:s,createdCommit:u,commitSha:p,bootstrapped:i}):je(R.message);m=R.value;let k=ve("isAheadOfUpstream",await op(s));if(a(k))return je(k.message);if(u||i||k.value){logger.info("[sync] pushing state branch",{createdCommit:u,bootstrapped:i,stateBranchRoot:s});let M=ve("pushStateBranch",await Ks({stateBranchRoot:s,repoRoot:o}));if(a(M)&&tp(M.message)){let F=ve("pullBranchRebaseIfPresent(retry)",await gs({cwd:s,branch:b}));if(a(F))return je(F.message);m=m||F.value,M=ve("pushStateBranch(retry)",await Ks({stateBranchRoot:s,repoRoot:o}))}if(a(M))return fs(M.message)?ed({repoRoot:o,stateBranchRoot:s,createdCommit:u,commitSha:p,bootstrapped:i}):je(M.message);f=M.value}if(u){logger.debug("[sync] resolving final sync commit sha",{stateBranchRoot:s});let M=ve("git rev-parse HEAD",await W({args:["rev-parse","HEAD"],cwd:s}));if(a(M))return je(M.message);p=M.value.stdout.trim(),logger.debug("[sync] final sync commit sha",p)}return Ur(f?"Synced and pushed":m||u?"Synced local state":"Already synced"),logger.debug("[sync] syncEpiqWithRemote:done"),d("Synced event logs with state branch",{repoRoot:o,stateBranchRoot:s,createdCommit:u,commitSha:p,pulled:m,pushed:f,bootstrapped:i,offline:!1})},Na=async(e,t)=>{let n=Qg(e);try{return await t()}finally{let r=Zg(e,n);r.length>0&&logger.error(`[sync] restored event log lines git dropped from the worktree: ${r.join(", ")}`)}},Ca=async e=>{let t=e.cwd??process.cwd(),n=await kt(t);if(a(n))return je(n.message);let r=Ie({repoRoot:n.value});if(a(r))return je(r.message);let o=r.value;if(!uh.existsSync(o))return dh(e,"clean");let s=await Xs({worktreeRoot:o,operation:"sync",fn:i=>Na(o,()=>dh(e,i))});return a(s)?je(s.message):s.value===null?d("Another process is syncing this board",{repoRoot:n.value,stateBranchRoot:o,createdCommit:!1,pulled:!1,pushed:!1,bootstrapped:!1,offline:!1,skipped:!0}):s.value}});var Sn,Aa,wS,td,mh,Ta=g(()=>{"use strict";Hg();jr();$();$();Oe();N();D();Gs();Ea();wa();Sn=null,Aa=async()=>{if(logger.debug("[sync] syncAndReloadState enter",{hasPromise:!!Sn,currentStatus:v().syncStatus?.status,currentMessage:v().syncStatus?.msg}),Sn)return logger.debug("[sync] syncAndReloadState joining existing promise"),Sn;logger.debug("[sync] syncAndReloadState creating promise"),Sn=wS();try{let e=await Sn;return logger.debug("[sync] syncAndReloadState promise resolved",{success:!a(e),message:(a(e),e.message),statusAfterResolve:v().syncStatus?.status,statusMessageAfterResolve:v().syncStatus?.msg}),a(e)&&v().syncStatus?.status==="syncing"&&(logger.debug("[sync] syncAndReloadState correcting stale syncing status"),A({syncStatus:{msg:e.message,status:"failed"}})),e}catch(e){let t=e instanceof Error?e.message:String(e);return logger.error("[sync] syncAndReloadState promise threw",{message:t,error:e}),Sn||l(t)}finally{logger.debug("[sync] syncAndReloadState clearing promise",{statusBeforeClear:v().syncStatus?.status,statusMessageBeforeClear:v().syncStatus?.msg}),Sn=null}},wS=async()=>{logger.debug("[sync] syncAndReloadStateUnsafe:start",{mode:v().mode,syncStatus:v().syncStatus});let e=mh();if(e)return logger.debug("[sync] syncAndReloadStateUnsafe:blocked by mode",{mode:v().mode,message:e.message,syncStatus:v().syncStatus}),e;if(Sn)return Sn;logger.debug("[sync] syncAndReloadState:start");let t=ve("resolveActorId",he());if(a(t)||!t.value)return logger.info("[sync] unable to resolve actor id",{message:a(t)?t.message:"Missing actor id"}),l("Unable to resolve event log path");A({syncStatus:{msg:"Reloading synced state",status:"syncing"}}),logger.debug("[sync] sync status patched to syncing",{syncStatus:v().syncStatus});let n=rr(t.value);logger.debug("[sync] resolved own event file name",{ownEventFileName:n}),logger.debug("[sync] syncEpiqWithRemote:start");let r=ve("syncEpiqWithRemote",await Ca({ownEventFileName:n}));if(logger.debug("[sync] syncEpiqWithRemote:result",{success:!a(r),message:(a(r),r.message)}),a(r))return logger.error("[sync] syncAndReloadState:sync failed",r.message),A({syncStatus:{msg:"Sync failed",status:"failed"}}),logger.debug("[sync] sync status patched to failed after sync failure",{syncStatus:v().syncStatus}),je(`Unable to sync state. ${r.message}`);let{stateBranchRoot:o,offline:s}=r.value,i=td(o);return a(i)?i:(A({hasProjectDefinition:!0,syncStatus:s?{msg:"Committed locally, offline",status:"offline"}:{msg:"Synced",status:"synced"}}),logger.debug("[sync] syncAndReloadState:done",{syncStatus:v().syncStatus}),d("Synced",!0))},td=e=>{logger.debug("[sync] loading merged events after sync",{stateBranchRoot:e});let t=ve("loadMergedEvents",sn(e));if(logger.debug("[sync] loadMergedEvents:result",{success:!a(t),message:(a(t),t.message),count:a(t)?void 0:t.value.events.length}),a(t))return A({syncStatus:{msg:"Reload failed",status:"failed"}}),logger.debug("[sync] sync status patched to failed after load failure",{syncStatus:v().syncStatus}),l(`Unable to load events. ${t.message}`);logger.debug("[sync] loaded merged events after sync",{count:t.value.events.length});let n=mh();if(n)return logger.debug("[sync] syncAndReloadStateUnsafe:blocked by late mode check",{mode:v().mode,message:n.message,syncStatus:v().syncStatus}),n;let r=$g(),o=v().filters;if(logger.debug("[sync] captured navigation anchor",{navigationAnchor:r,selectedNodeId:v().selectedNode?.id,contextNodeId:v().contextNode?.id,selectedNodeIsVirtual:v().selectedNode?.isVirtual,contextNodeIsVirtual:v().contextNode?.isVirtual}),!v().selectedNode?.isVirtual&&!v().contextNode?.isVirtual){logger.debug("[sync] bootStateFromEventLog:start",{eventCount:t.value.events.length});let i=ve("bootStateFromEventLog",En(t.value.events,t.value.unreadable));if(logger.debug("[sync] bootStateFromEventLog:result",{success:!a(i),message:(a(i),i.message)}),a(i))return A({syncStatus:{msg:"Reload failed",status:"failed"}}),logger.debug("[sync] sync status patched to failed after boot failure",{syncStatus:v().syncStatus}),l(`Unable to boot synced state. ${i.message}`)}else logger.debug("[sync] skipped bootStateFromEventLog for virtual node",{selectedNodeIsVirtual:v().selectedNode?.isVirtual,contextNodeIsVirtual:v().contextNode?.isVirtual});logger.debug("[sync] booted state from synced events"),A({filters:o}),logger.debug("[sync] restoreNavigationAnchor:start");let s=ve("restoreNavigationAnchor",Ug(r));return logger.debug("[sync] restoreNavigationAnchor:result",{success:!a(s),message:a(s)?s.message:"Navigation restored",selectedNodeId:v().selectedNode?.id,contextNodeId:v().contextNode?.id}),a(s)?(A({syncStatus:{msg:"Reload failed",status:"failed"}}),logger.debug("[sync] sync status patched to failed after restore failure",{syncStatus:v().syncStatus}),s):d("Reloaded state from event log",null)},mh=()=>v().mode===x.DEFAULT?null:(logger.debug("[sync] failReloadIfNotDefaultMode",{mode:v().mode,syncStatus:v().syncStatus}),A({syncStatus:{msg:"Reload skipped while editing",status:"pending"}}),l("Will not re-materialize if not in default mode, to not lose edit data"))});var ph,nd,rd,Js,od,AS,fh,TS,gh,hh=g(()=>{"use strict";Sr();N();Ue();D();Ta();ph=0,rd=!1,Js=!1,od=()=>{if(rd)return!0;let e=ke();return a(e)?!1:e.value.syncStatus.status==="syncing"},AS=()=>{let e=Li(de().autoSyncIntervalMs),t=Date.now()-ph;return Math.max(0,e-t)},fh=()=>{nd||(nd=setTimeout(async()=>{if(nd=void 0,!!Ut()){if(od()){Js=!0;return}Js=!1,await TS()}},AS()))},TS=async()=>{if(v().readOnly||v().timeMode==="peek"||v().timeMode==="replay")return l("Cannot auto-sync while peeking");if(!Ut())return l("Cannot auto-sync before state is initialized");if(od())return Js=!0,l("Sync already in progress");rd=!0,ph=Date.now(),A({syncStatus:{msg:"Auto-syncing",status:"syncing"}});try{return await Aa()}finally{rd=!1,Js&&fh()}},gh=()=>{Ut()&&(Js=!0,!od()&&fh())}});var vh,G,sd=g(()=>{"use strict";D();Ar();vh=e=>{let{context:t}=v().contextNode;if(!t)return G.None;switch(e){case I.EXIT:return G.Exit;case I.EXPORT:return G.Export;case I.INIT:return G.Init;case I.OPEN:return G.OpenProject;case I.DELETE:return G.Delete;case I.EDIT:return G.Edit;case I.COMMENT:return G.Comment;case I.HELP:return G.ViewHelp;case I.RE_OPEN_ISSUE:return G.ReopenIssue;case I.CLOSE_ISSUE:return G.CloseIssue;case I.TAG:return G.TagTicket;case I.UNTAG:return G.UntagTicket;case I.ASSIGN:return G.AssignUserToTicket;case I.UNASSIGN:return G.UnassignUserFromTicket;case I.NEW:return G.NewItem;case I.FILTER:return G.Filter;case I.MOVE:return G.Move;case I.PEEK:return G.Peek;case I.REPLAY:return G.Replay;case I.CONFIG:return G.Config;case I.YANK:return G.Yank;case I.SYNC:return G.Sync;default:return G.None}},G={Exit:"exit",Init:"init",OpenProject:"open-project",None:"none",ViewHelp:"view-help",Rename:"rename",Edit:"edit",Delete:"delete",Filter:"filter",Move:"move",Peek:"peek",Replay:"replay",Yank:"yank",Config:"config",NewItem:"add-new-item",TagTicket:"ticket-tag",UntagTicket:"ticket-untag",AssignUserToTicket:"ticket-assign-user",UnassignUserFromTicket:"ticket-unassign-user",CloseIssue:"close-issue",ReopenIssue:"re-open-issue",Comment:"comment-issue",Sync:"sync",Export:"export"}});import{Text as yh}from"ink";import bh,{useEffect as xh,useState as kS}from"react";var Ih,Ht,wo=g(()=>{"use strict";D();Je();Ih={help:["\u276F "],default:["\u276F "],move:["\u25C6 ","\u25C6 "],"cmd-line":["\u276F "],palette:["\u276F "],identity:["\u276F "]},Ht=({isSelected:e,placeholder:t=" "})=>{let{mode:n}=Ye(),r=Ih[n]??Ih.default,[o,s]=kS(0);if(xh(()=>{s(0)},[r]),xh(()=>{if(!e)return;let c=setInterval(()=>{s(u=>(u+1)%r.length)},500);return()=>clearInterval(c)},[e,r]),!e)return bh.createElement(yh,null,t);let i=r[o]??r[0]??t;return bh.createElement(yh,{color:T.accent,dimColor:o===1},i)}});import{Box as id,Text as MS}from"ink";import ka from"react";var LS,Wt,Hr=g(()=>{"use strict";Je();LS=(e,t,n,r)=>{let o=u=>Math.max(1,e[u]??1),s=n,i=n+1,c=o(n);for(;i<t&&c+o(i)<=r;)c+=o(i),i++;for(;s>0&&c+o(s-1)<=r;)s--,c+=o(s);return{start:s,end:i}},Wt=({children:e=[],height:t,selectedIndex:n,itemHeight:r=1,itemHeights:o,scrollByOne:s=!1})=>{if(e.length===0)return null;let i=Math.max(1,Math.floor(t)),c=Math.max(1,Math.ceil(r)),u=Math.max(0,Math.min(n,e.length-1)),p=Math.max(1,Math.floor(i/c)),m=Math.max(0,e.length-p),{start:f,end:h}=o?LS(o,e.length,u,i):s?{start:Math.min(m,Math.max(0,u-p+1)),end:Math.min(m,Math.max(0,u-p+1))+p}:{start:Math.min(m,Math.floor(u/p)*p),end:Math.min(m,Math.floor(u/p)*p)+p},b=Math.max(1,h-f),E=e.slice(f,h),S=e.length>b,w=i,R=S?Math.max(1,Math.floor(b/e.length*w)):w,k=Math.max(0,w-R),M=Math.max(1,e.length-b),F=S?Math.floor(f/M*k):0;return ka.createElement(id,{flexDirection:"row",height:i,width:"100%"},ka.createElement(id,{flexDirection:"column",flexGrow:1,height:i},E),ka.createElement(id,{flexDirection:"column",width:1,height:w},Array.from({length:w}).map((j,z)=>ka.createElement(MS,{key:z,color:S&&z>=F&&z<F+R?T.accent:T.secondary},S?"\u2502":" "))))}});var Eh,ad,PS,Ma,ld=g(()=>{"use strict";D();PS=()=>{let{eventLog:e=[]}=v();if(ad&&Eh===e)return ad;let t=new Set;for(let n of e)n?.userId&&t.add(n.userId);return Eh=e,ad=t,t},Ma=e=>PS().has(e)});import{Text as DS}from"ink";import OS from"react";var Ao,La=g(()=>{"use strict";un();pe();ld();vt();Ao=({id:e,isSelected:t,maxWidth:n})=>{let r=C.getContributor(e);if(!r)return;let o=r.name,s=n===void 0?o:Er(o,n);return OS.createElement(DS,{underline:t,color:tt(o)},"@"+s,Ma(e)?"":"\u2197")}});import{Text as _S}from"ink";import FS from"react";var Pa,cd=g(()=>{"use strict";pe();Je();un();vt();Pa=({id:e,isSelected:t,maxWidth:n})=>{let r=C.getTag(e);if(!r)return;let o=n===void 0?r.name:Er(r.name,n);return FS.createElement(_S,{underline:t,backgroundColor:tt(r.name),color:T.secondary}," "+o+" ")}});import{useEffect as BS,useState as $S}from"react";var jS,Rh,Da,Qs,US,HS,To,Oa=g(()=>{"use strict";un();jS=80,Rh=1400,Da=new Set,Qs=null,US=e=>(Da.add(e),Qs||(Qs=setInterval(()=>{for(let t of Da)t()},jS)),()=>{Da.delete(e),Da.size===0&&Qs&&(clearInterval(Qs),Qs=null)}),HS=()=>{let e=Date.now()%Rh/Rh;return e<.5?e*2:(1-e)*2},To=e=>{let[,t]=$S(0);return BS(()=>{if(e)return US(()=>t(n=>n+1))},[e]),Tm(HS())}});import{Box as ko,Text as Mo}from"ink";import Et from"react";var WS,Sh,qS,GS,Nh,Ch=g(()=>{"use strict";pe();Je();vt();ld();ft();uo();La();cd();Oa();WS=(e,t,n)=>{if(e.length<=t)return[e,null];let r=e.lastIndexOf(" ",t),o=r>0?r:t;return[e.slice(0,o),Er(e.slice(o).trim(),n)]},Sh=3,qS=2,GS=(e,t)=>{let n=[],r=0;for(let[o,s]of e.entries()){let i=e.length-o-1,c=i>0?String(i).length+1:0;if(r+s.width+c>t)break;r+=s.width,n.push(s)}return{shown:n,hidden:e.length-n.length}},Nh=({width:e,ticket:t,isSelected:n,isFlashing:r=!1})=>{let o=To(r),s=e-4,i=s-7-1,[c,u]=WS(Se(t.title),i,s),p=u?null:Er(Se(t.props.description),s)||null,m=hn(t),f=vn(t).map(R=>({...R,name:R.name})),h=Math.max(1,s-Sh),b=C.getCommentsByIssue(t.id),E=b.length?String(b.length).length+2+1:0,{shown:S,hidden:w}=GS([...m.map(R=>({id:R.id,isTag:!0,width:Math.min(R.name.length,h)+Sh})),...f.map(R=>({id:R.id,isTag:!1,width:Math.min(R.name.length,h)+qS+(Ma(R.id)?0:1)}))],s-E);return Et.createElement(ko,{borderStyle:"round",height:5,flexDirection:"column",overflow:"hidden",borderDimColor:!n,borderColor:r?o:n?T.accent:T.secondary,justifyContent:"space-between"},Et.createElement(ko,{paddingLeft:1,paddingRight:1,flexDirection:"column"},Et.createElement(ko,{justifyContent:"space-between"},Et.createElement(Mo,{color:T.primary},c),Et.createElement(Mo,{color:T.secondary2,dimColor:!0},V(t.id))),u&&Et.createElement(Mo,{color:T.primary},u),p&&Et.createElement(Mo,{color:T.secondary2,dimColor:!0},p)),Et.createElement(ko,{flexDirection:"row",paddingLeft:1,paddingRight:1,justifyContent:"space-between"},Et.createElement(ko,{flexDirection:"row"},S.map(R=>Et.createElement(ko,{paddingRight:1,key:R.id},R.isTag?Et.createElement(Pa,{id:R.id,maxWidth:h}):Et.createElement(Ao,{id:R.id,maxWidth:h}))),w>0&&Et.createElement(Mo,{color:T.secondary2,dimColor:!0},"+",w)),b.length>0&&Et.createElement(Mo,{color:T.accent},"[",b.length,"]")))}});import{Box as Wr,Text as Zs}from"ink";import Pt from"react";var zS,wh,Ah=g(()=>{"use strict";Oe();pe();Je();un();wo();Oa();zS=(e,t)=>e.length>t?e.slice(0,Math.max(0,t-1))+"\u2026":e,wh=({index:e,labelWidth:t,width:n,ticket:r,isSelected:o,isFlashing:s=!1,mode:i})=>{let c=To(s),u=(r.props.tags??[]).map(j=>C.getTag(j)).filter(j=>!!j),p=(r.props.assignees??[]).map(j=>C.getContributor(j)).map(j=>j&&{...j,name:j.name}).filter(j=>!!j),m=1,f=u.length*(1+m),h=p.length*(2+m),b=u.map(j=>Pt.createElement(Wr,{key:j.id,paddingRight:m},Pt.createElement(Zs,{color:tt(j.name)},"\u25A0"))),E=p.map(j=>Pt.createElement(Wr,{key:j.id,paddingRight:m},Pt.createElement(Zs,{color:Pl(j.name)},"@"+j.name.at(0)))),S=s?c:o?T.accent:i===x.MOVE?T.secondary:T.primary,w=C.getCommentsByIssue(r.id),R=w.length?String(w.length).length+2+m:0,k=w.length?Pt.createElement(Wr,{paddingRight:m},Pt.createElement(Zs,{color:T.accent},"[",w.length,"]")):null,M=f+h+R,F=Math.max(1,n-t-M-(M>0?1:0));return Pt.createElement(Wr,{justifyContent:"space-between"},Pt.createElement(Wr,null,Pt.createElement(Wr,{width:t},o?Pt.createElement(Ht,{isSelected:!0}):Pt.createElement(Zs,{color:"gray",dimColor:!0},String(e+1).padStart(t-1)+" ")),Pt.createElement(Zs,{wrap:"truncate",color:S},zS(r.title,F))),Pt.createElement(Wr,null,b,E,k))}});import VS from"chalk";import{Box as dd,Text as KS}from"ink";import Nn from"react";var YS,Th,kh=g(()=>{"use strict";me();D();Je();wo();Hr();Ch();Ah();Oa();YS=({swimlane:e,isSelected:t,width:n,height:r,isDense:o,isFocused:s,listSelectedIndex:i,mode:c})=>{let{renderedChildrenIndex:u,replay:p}=Ye(),m=u[e.id]??[],f=p?new Set(p.flashNodeIds):null,h=f?.has(e.id)??!1,b=To(h),E=`${e.title} ${VS.hex(T.secondary2).dim("("+m.length+")")}`,S=3,w=o?1:5,R=s&&i===-1,k=n-3-(o?1:0)-(R?2:0),M=Math.max(2,String(m.length).length+1),F=r-S-1,j=Nn.createElement(dd,{borderStyle:"round",borderColor:T.secondary,justifyContent:"flex-start",borderLeft:!1,borderTop:!1,borderRight:!1,marginRight:o?1:0},Nn.createElement(Ht,{isSelected:t}),Nn.createElement(KS,{bold:!0,color:h?b:t?T.accent:T.primary},E," ",e.readonly?"\u{1F512}":"")),z=(J,se)=>{let ze=s&&i===se;if(!U(J))return null;let q=f?.has(J.id)??!1;return o?Nn.createElement(wh,{key:J.id,index:se,labelWidth:M,width:k,ticket:J,isSelected:ze,isFlashing:q,mode:c}):Nn.createElement(Nh,{key:J.id,width:k,ticket:J,isSelected:ze,isFlashing:q})};return Nn.createElement(dd,{flexDirection:"column",width:n,borderStyle:"round",borderColor:t?T.accent:T.secondary,paddingRight:0,paddingLeft:o?1:0,height:r},j,Nn.createElement(dd,null,m.length>0&&Nn.createElement(Wt,{selectedIndex:i,height:F,itemHeight:w},m.map(z)),R&&Nn.createElement(Ht,{isSelected:!0})))},Th=Nn.memo(YS)});var Mh,Lh,Ph,_a=g(()=>{"use strict";sr();Mh=e=>{let t=new Set((e.log??[]).filter(n=>n.action==="delete.issue.comment").map(n=>n.payload.id));return(e.log??[]).filter(n=>n.action==="add.issue.comment"&&n.payload.issue===e.id&&!t.has(n.payload.id)).length},Lh=(e,t,n)=>$e.comment({id:e.id,parentNodeId:n,rank:String(t).padStart(6,"0"),name:e.id,props:{value:e.md},readonly:!1,isVirtual:!0}),Ph=e=>e.action==="add.issue.comment"});var ar,ei=g(()=>{"use strict";ar=e=>{let t=Date.now()-e,n=[{label:"y",ms:1e3*60*60*24*365},{label:"mo",ms:1e3*60*60*24*30},{label:"w",ms:1e3*60*60*24*7},{label:"d",ms:1e3*60*60*24},{label:"h",ms:1e3*60*60},{label:"m",ms:1e3*60},{label:"s",ms:1e3}];for(let{label:r,ms:o}of n){let s=Math.floor(t/o);if(s>=1)return`${s}${r} ago`}return"just now"}});import{Box as Po,Text as Un}from"ink";import it,{useEffect as XS,useMemo as JS,useRef as QS}from"react";import{decodeTime as Dh}from"ulid";function _h({ticket:e,width:t,height:n}){let r=JS(()=>eN(e),[e]),o=QS([]);XS(()=>(Oh(o.current),o.current=nN(e,r),()=>{Oh(o.current),o.current=[]}),[e,r]);let{selectedIndex:s}=Ye(),c=Math.max(1,n-4),u=Math.max(12,t-32);return r.length===0?it.createElement(Po,{flexDirection:"column",width:t,height:n,padding:1},it.createElement(Un,{color:T.primary},"No attachments yet."),it.createElement(Po,{paddingTop:1},it.createElement(Un,{color:T.primary},"Attach images from the browser GUI"),it.createElement(Un,{color:T.accent}," epiq gui "),it.createElement(Un,{color:T.primary},"by dropping or pasting them."))):it.createElement(Po,{flexDirection:"column",width:t,height:n},it.createElement(Po,{paddingLeft:4,borderLeft:!1,borderRight:!1,borderBottom:!1,borderTop:!0,borderColor:T.secondary,borderStyle:"single",paddingBottom:1},it.createElement(Un,{color:T.secondary2},"Attachments (",r.length,") \u2014 enter to open"," ")),it.createElement(Wt,{height:c,itemHeight:2,selectedIndex:s},r.map((p,m)=>{let f=m===s,h=p.name.length>u?p.name.slice(0,u-1)+"\u2026":p.name;return it.createElement(Po,{key:p.id,flexDirection:"row",paddingX:1,paddingBottom:1},it.createElement(Un,{color:T.accent},f?"\u276F ":" "),it.createElement(Po,{paddingLeft:1},it.createElement(Un,{color:T.secondary2},`#${m+1} `),it.createElement(Un,{color:f?T.accent:T.primary},h),it.createElement(Un,{color:T.secondary2}," "+rN(p.bytes)+" "+ar(at(p.id)))))})))}var ZS,eN,Oh,tN,nN,rN,Fh=g(()=>{"use strict";It();lt();ei();me();N();pe();sr();D();Je();Jn();Hr();ZS=e=>Te(e,"attachments"),eN=e=>C.getAttachmentsByIssue(e.id).sort((t,n)=>Dh(t.id)-Dh(n.id)),Oh=e=>{for(let t of e)C.deleteNode(t.id)},tN=(e,t,n)=>$e.field({id:e.id,name:e.name,parentNodeId:n,rank:String(t).padStart(6,"0"),isVirtual:!0}),nN=(e,t)=>{let n=C.getNode(ZS(e.id));if(!n||!nt(n))return[];let r=t.map((o,s)=>tN(o,s,n.id)).map(o=>C.createNode(o)).filter(Dt).map(({value:o})=>o).filter(nt);return t.length>0&&v().selectedIndex<0&&H.navigate({contextNode:n,selectedIndex:0}),r},rN=e=>`${Math.max(1,Math.round(e/1024))} KB`});var $h,ud,oN,Bh,ti,jh,Uh,sN,Hh,Wh,md,iN,qh,Fa=g(()=>{"use strict";$h=/<!--\s*epiq-diff-comment:(.+?)-->\n?/,ud=e=>e.replace($h,""),oN=e=>`<!-- epiq-diff-comment:${JSON.stringify(e).replaceAll(">","\\u003e")} -->`,Bh=e=>e==="additions"||e==="deletions",ti=e=>{let t=$h.exec(e);if(!t?.[1])return null;let n;try{n=JSON.parse(t[1])}catch{return null}let r=n;return typeof r?.filePath!="string"||typeof r.start!="number"||typeof r.end!="number"||typeof r.note!="string"||!Bh(r.side)||!Bh(r.endSide)||r.sha!==void 0&&typeof r.sha!="string"||r.issueRef!==void 0&&typeof r.issueRef!="string"?null:r},jh=/```\n([\s\S]*?)\n?```\s*$/,Uh=e=>jh.exec(e)?.[1]??null,sN=/`[^`\n]+`[^\n]*\n?$/,Hh=e=>ud(e).replace(jh,"").replace(sN,"").trim(),Wh=e=>{let n=(e.endSide??e.side)==="deletions"?"removed":"added";return e.start===e.end?`line ${e.start} (${n})`:`lines ${e.start}-${e.end} (${n})`},md=e=>`${e.issueRef?`${e.issueRef} \xB7 `:""}${e.filePath} ${Wh(e)}`,iN=e=>{let t=e.split(`
80
+ `),n=t.filter(r=>r.trim()!=="").reduce((r,o)=>{let s=/^[ \t]*/.exec(o)?.[0].length??0;return r===null?s:Math.min(r,s)},null);return n?t.map(r=>r.slice(n)).join(`
81
+ `):e},qh=({snippet:e,...t})=>{let n=t.note.trim();return[...n?[n,""]:[],oN({...t,note:n}),`\`${t.filePath}\` ${Wh(t)}`,"```",iN(e),"```"].join(`
82
+ `)}});var aN,ni,lN,cN,dN,uN,ri,pd,zh,Gh,Vh,Ba=g(()=>{"use strict";Fa();aN=(e,t)=>{let n=Math.max(1,Math.floor(t)),r=e.split(/\s+/).filter(Boolean);if(r.length===0)return[""];let o=[],s="";for(let i of r){let c=i;for(;c.length>n;)s&&(o.push(s),s=""),o.push(c.slice(0,n)),c=c.slice(n);s?s.length+1+c.length<=n?s=`${s} ${c}`:(o.push(s),s=c):s=c}return s&&o.push(s),o},ni=e=>{let t=e.split("`");return t.length%2===0?[{text:e}]:t.map((n,r)=>r%2===1?{text:n,code:!0}:{text:n}).filter(n=>n.text.length>0)},lN=/!\[([^\]]*)\]\([^)]*\)/g,cN=e=>e.replace(lN,(t,n)=>n.trim()?`[image: ${n.trim()}]`:"[image]"),dN=e=>e.map(t=>t.code?`\`${t.text}\``:t.text).join(""),uN=4,ri=e=>e.replace(/\r$/,"").replaceAll(" "," ".repeat(uN)),pd=e=>{let t=!1;return e.map(ri).map(n=>{if(/^\s*```/.test(n))return t=!t,{kind:"fence"};if(t)return{kind:"code",text:n};let r=ti(n);if(r)return{kind:"caption",text:md(r)};let o=cN(n);if(o.trim()==="")return{kind:"blank"};let s=/^#{1,6}\s+(.*)$/.exec(o);return s?{kind:"heading",spans:ni(s[1]??"")}:{kind:"text",spans:ni(o)}})},zh=(e,t)=>e.length<=t?[e]:e.match(new RegExp(`.{1,${t}}`,"g"))??[""],Gh=(e,t)=>{let n=[];for(let r of pd(e))if(r.kind!=="fence"){if(r.kind==="blank"){n.length>0&&n[n.length-1]?.kind!=="blank"&&n.push(r);continue}if(r.kind==="code"){for(let o of zh(r.text,t))n.push({kind:"code",text:o});continue}if(r.kind==="caption"){n.push(r);continue}for(let o of aN(dN(r.spans),t))n.push({kind:r.kind,spans:ni(o)})}for(;n.length>0&&n[n.length-1]?.kind==="blank";)n.pop();return n},Vh=(e,t)=>{let n=ti(e),r=n?Uh(e):null;if(!n||r===null)return Gh(ud(e).split(`
83
+ `),t);let o=Hh(e),s=r.split(`
84
+ `).map(ri),i=n.side===n.endSide?n.start:void 0,c=i===void 0?0:String(i+s.length-1).length+3;return[...o?[...Gh(o.split(`
85
+ `),t),{kind:"blank"}]:[],{kind:"caption",text:md(n)},...s.flatMap((u,p)=>zh(u,Math.max(1,t-c)).map((m,f)=>({kind:"code",text:m,number:i===void 0||f>0?void 0:i+p})))]}});import{Box as Kh,Text as qr}from"ink";import qt from"react";var Yh,fd,Xh,gd=g(()=>{"use strict";Je();Yh=({spans:e,bold:t,wrap:n})=>qt.createElement(qr,{color:T.primary,bold:t,wrap:n},e.map((r,o)=>r.code?qt.createElement(qr,{key:o,color:T.yellow},r.text):qt.createElement(qr,{key:o},r.text))),fd=({line:e,width:t,gutter:n=0,wrap:r})=>{switch(e.kind){case"blank":return qt.createElement(qr,null," ");case"fence":return qt.createElement(qr,{color:T.secondary2},"```");case"caption":return qt.createElement(qr,{color:T.accent,wrap:r},e.text);case"heading":return qt.createElement(Yh,{spans:e.spans,bold:!0,wrap:r});case"text":return qt.createElement(Yh,{spans:e.spans,wrap:r});case"code":{let o=n>0?`${e.number===void 0?"":String(e.number)}`.padStart(n-3)+" \u2502 ":"";return qt.createElement(qr,{backgroundColor:T.secondary,color:T.primary,wrap:r},o,e.text.padEnd(Math.max(0,t-o.length)))}}},Xh=({lines:e,width:t})=>{let n=e.flatMap(o=>o.kind==="code"&&o.number!==void 0?[o.number]:[]),r=n.length>0?String(Math.max(...n)).length+3:0;return qt.createElement(Kh,{flexDirection:"column"},e.map((o,s)=>qt.createElement(Kh,{key:s},qt.createElement(fd,{line:o,width:t,gutter:r}))))}});import{Box as lr,Text as cr}from"ink";import qe,{useEffect as mN,useMemo as Jh,useRef as pN}from"react";import{decodeTime as Qh}from"ulid";function ev({ticket:e,width:t,height:n}){let r=Jh(()=>hN(e),[e]),o=pN([]);mN(()=>(Zh(o.current),o.current=vN(e,r),()=>{Zh(o.current),o.current=[]}),[e,r]);let{selectedIndex:s}=Ye(),c=Math.max(1,n-4),u=Math.max(20,t-8),p=Jh(()=>r.map(f=>{let h=Vh(f.md,u);return h.length>0?h:[{kind:"blank"}]}),[r,u]),m=p.map(f=>f.length+fN);return r.length===0?qe.createElement(lr,{flexDirection:"column",width:t,height:n,padding:1},qe.createElement(cr,{color:T.primary},"No comments yet."),qe.createElement(lr,{paddingTop:1},qe.createElement(cr,{color:T.primary},"Use"),qe.createElement(cr,{color:T.accent}," :comment "),qe.createElement(cr,{color:T.primary},"to add the first one."))):qe.createElement(lr,{flexDirection:"column",width:t,height:n},qe.createElement(lr,{paddingLeft:4,borderLeft:!1,borderRight:!1,borderBottom:!1,borderTop:!0,borderColor:T.secondary,borderStyle:"single",paddingBottom:1},qe.createElement(cr,{color:T.secondary2},"Comments (",r.length,") ")),qe.createElement(Wt,{height:c,itemHeights:m,selectedIndex:s},r.map((f,h)=>{let b=h===s;return qe.createElement(lr,{key:f.id,flexDirection:"column",paddingX:1,borderLeft:!1,borderBottom:!1,borderRight:!1,borderColor:T.secondary,borderStyle:"single"},qe.createElement(lr,{flexDirection:"row",paddingBottom:1},qe.createElement(cr,{color:T.accent},b?"\u276F ":" "),qe.createElement(lr,{paddingLeft:1},qe.createElement(cr,{color:T.secondary2},`#${h+1} `),qe.createElement(Ao,{id:f.authorId}),qe.createElement(cr,{color:T.secondary2}," "+ar(at(f.id))))),qe.createElement(lr,{paddingLeft:3,paddingBottom:1},qe.createElement(Xh,{lines:p[h]??[],width:u})))})))}var fN,gN,hN,Zh,vN,tv=g(()=>{"use strict";It();lt();ei();me();N();pe();D();Je();Jn();La();Hr();_a();Ba();gd();fN=4,gN=e=>Te(e,"comments"),hN=e=>C.getCommentsByIssue(e.id).sort((t,n)=>Qh(t.id)-Qh(n.id)).map(t=>({id:t.id,issue:t.issue,authorId:t.authorId,md:t.md})),Zh=e=>{for(let t of e)C.deleteNode(t.id)},vN=(e,t)=>{let n=C.getNode(gN(e.id));if(!n||!nt(n))return[];let r=t.map((o,s)=>Lh(o,s,n.id)).map(C.createNode).filter(Dt).map(({value:o})=>o).filter(ms);return t.length>0&&v().selectedIndex<0&&H.navigate({contextNode:n,selectedIndex:0}),r}});var dr,oi,Do=g(()=>{"use strict";N();ee();dr=e=>{let t=Ce(e??process.cwd());return a(t)?l(t.message):d("Resolved Epiq repo root",t.value)},oi=e=>/^[0-9a-f]{7,40}$/i.test(e)});var yN,$a,hd=g(()=>{"use strict";yN="EPIQ_CACHE_MS",$a=e=>{let t=process.env[yN];if(t===void 0||t.trim()==="")return e;let n=Number(t);return Number.isFinite(n)&&n>=0?n:e}});var Oo,nv,rv,_o,bN,ov,Fo,vd=g(()=>{"use strict";Ke();N();Zt();hd();ft();Do();Oo="",nv="",rv=5e3,_o=null,bN=(e,t,n)=>(t===void 0||e>=Math.floor(t/1e3)*1e3)&&(n===void 0||e<=n),ov=async(e={})=>{let t=dr(e.repoRoot);if(a(t))return l(t.message);let n=Tt(t.value);if(a(n))return l(n.message);let r=e.start===void 0&&e.end===void 0;if(r&&_o&&_o.repoRoot===t.value&&_o.stateBranch===n.value.stateBranch&&Date.now()-_o.fetchedAt<$a(rv))return d("Computed commit timeline",_o.result);let o=await W({cwd:t.value,args:["log","--branches","--not",n.value.stateBranch,...e.start!==void 0?[`--since=@${Math.floor(e.start/1e3)}`]:[],...e.end!==void 0?[`--until=@${Math.floor(e.end/1e3)}`]:[],"--shortstat",`--format=${nv}%H${Oo}%at${Oo}%an${Oo}%ae${Oo}%s`]});if(a(o))return l(o.message);let s=o.value.stdout.split(nv).filter(i=>i.trim().length>0).map(i=>{let[c,...u]=i.split(`
86
+ `),[p,m,f,h,...b]=(c??"").split(Oo);if(!p||!m)return null;let E=u.join(" "),S=Number(/(\d+) insertion/.exec(E)?.[1]??0),w=Number(/(\d+) deletion/.exec(E)?.[1]??0);return{sha:p,time:Number(m)*1e3,author:f??"unknown",authorEmail:h??"",subject:b.join(Oo),linesChanged:S+w,insertions:S,deletions:w}}).filter(i=>i!==null).filter(i=>bN(i.time,e.start,e.end));return r&&(_o={repoRoot:t.value,stateBranch:n.value.stateBranch,fetchedAt:Date.now(),result:s}),d("Computed commit timeline",s)},Fo=async e=>{let t=e.ref.trim();if(!t)return l("ref must not be empty");if(t.length!==7)return l(`"${t}" is ${t.length} characters; a ref is ${7}. Read it off the issue rather than slicing the id by hand.`);let n=await ov({repoRoot:e.repoRoot});if(a(n))return l(n.message);let r=`${t.toUpperCase()} `,o=c=>c.subject.toUpperCase().startsWith(r),s=n.value,i=[];for(let[c,u]of s.entries()){if(!o(u))continue;let p=s[c+1];i.push({...u,precedingSha:p&&o(p)?p.sha:null})}return d("Matched commits by ref",i)}});var yd,sv=g(()=>{"use strict";Ke();N();Do();vd();yd=async e=>{if(!oi(e.sha))return l("Invalid commit sha");let t=dr(e.repoRoot);if(a(t))return l(t.message);let n=await W({cwd:t.value,args:["show","--no-ext-diff","--no-color","--patch","--find-renames","--format=",e.sha]});return a(n)?l(n.message):d("Read commit patch",n.value.stdout)}});var xN,ja,iv,xd,bd,Id,Ua,Ed,av,IN,lv,cv,dv,Rd,Ha=g(()=>{"use strict";Fa();xN=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/,ja=e=>{if(!e.startsWith('"')||!e.endsWith('"'))return e;let t=e.slice(1,-1),n="";for(let r=0;r<t.length;r++){if(t[r]!=="\\"){n+=t[r];continue}let o=t[++r];if(o==="n")n+=`
87
+ `;else if(o==="t")n+=" ";else if(o==='"'||o==="\\")n+=o;else if(o&&/[0-7]/.test(o)){let s=t.slice(r,r+3);n+=String.fromCharCode(parseInt(s,8)),r+=2}else o!==void 0&&(n+=o)}try{return decodeURIComponent(escape(n))}catch{return n}},iv=e=>{let t=ja(e.trim());return t==="/dev/null"?null:t.replace(/^[ab]\//,"")},xd=e=>{let t=[],n=null,r=0,o=0,s=()=>{let i={path:"",oldPath:null,binary:!1,added:0,removed:0,lines:[]};return t.push(i),i};for(let i of e.split(`
88
+ `)){if(i.startsWith("diff --git ")){n=s();let m=i.slice(11),f=m.lastIndexOf(" b/");f!==-1&&(n.path=ja(m.slice(f+1)).replace(/^b\//,""));continue}if(!n){if(!i.trim())continue;n=s()}let c=n,u=c.lines.length===0;if(u&&i.startsWith("--- ")){let m=iv(i.slice(4));m&&(c.oldPath=m);continue}if(u&&i.startsWith("+++ ")){let m=iv(i.slice(4));m&&(c.path=m);continue}if(u&&i.startsWith("rename from ")){c.oldPath=ja(i.slice(12));continue}if(u&&i.startsWith("rename to ")){c.path=ja(i.slice(10));continue}if(u&&(i.startsWith("Binary files ")||i.startsWith("GIT binary patch"))){c.binary=!0,c.lines.push({kind:"note",text:"Binary file"});continue}let p=xN.exec(i);if(p){r=Number(p[1]),o=Number(p[3]),c.lines.push({kind:"hunk",text:i});continue}if(!u){if(i.startsWith("\\")){c.lines.push({kind:"note",text:i.slice(1).trim()});continue}if(i.startsWith("+")){c.added++,c.lines.push({kind:"added",text:i.slice(1),newLine:o++});continue}if(i.startsWith("-")){c.removed++,c.lines.push({kind:"removed",text:i.slice(1),oldLine:r++});continue}if(i.startsWith(" ")){c.lines.push({kind:"context",text:i.slice(1),oldLine:r++,newLine:o++});continue}i===""&&c.lines.push({kind:"context",text:"",oldLine:r++,newLine:o++})}}for(let i of t)!i.path&&i.oldPath&&(i.path=i.oldPath);return t.filter(i=>i.path!=="")},bd=e=>e.oldPath&&e.oldPath!==e.path?e.oldPath:null,Id=e=>e.flatMap(t=>[{kind:"file",text:`${bd(t)?`${bd(t)} \u2192 `:""}${t.path}`,file:t},...t.lines]),Ua=e=>{let t="",n=-1;return e.map(r=>(r.kind==="file"&&(t=r.file.path),r.kind==="hunk"&&n++,{file:t,hunk:n}))},Ed=(e,t,n)=>{let r=t.map(i=>ti(i.md)).filter(i=>i!==null&&i.sha===n&&i.side==="additions");if(r.length===0)return new Set;let o=Ua(e),s=new Set;return e.forEach((i,c)=>{let u=i.newLine;if(u===void 0)return;let p=o[c]?.file;r.some(m=>m.filePath===p&&m.start<=u&&u<=m.end)&&s.add(c)}),s},av=(e,t)=>e===t?`line:${e}`:`lines:${e}-${t}`,IN=/^lines?:(\d+)(?:-(\d+))?(?:\s+|$)/,lv=e=>{let t=IN.exec(e);if(!t)return null;let n=Number(t[1]),r=t[2]===void 0?n:Number(t[2]);return{start:Math.min(n,r),end:Math.max(n,r),note:e.slice(t[0].length)}},cv=(e,t)=>Ua(e)[t]?.file??null,dv=(e,t,n,r)=>{let o=Ua(e),s=u=>e.findIndex((p,m)=>o[m]?.file===t&&(p.kind==="added"||p.kind==="context")&&p.newLine===u),i=s(n),c=s(r);return i===-1||c===-1?{ok:!1,reason:`${t} has no line ${i===-1?n:r} on the new side`}:Rd(e,i,c)},Rd=(e,t,n)=>{let[r,o]=t<=n?[t,n]:[n,t],s=e[r],i=e[o];if(!s||!i)return{ok:!1,reason:"That line is not in the diff"};let c=h=>(h.kind==="added"||h.kind==="context")&&h.newLine!==void 0;if(!c(s)||!c(i))return{ok:!1,reason:"Comments anchor to the new side: pick an added or unchanged line"};let u=Ua(e),p=u[r],m=u[o];if(p.file!==m.file)return{ok:!1,reason:"A comment covers one file at a time"};if(p.hunk!==m.hunk)return{ok:!1,reason:"A comment covers one hunk at a time"};let f=e.slice(r,o+1).filter(c);return{ok:!0,value:{filePath:p.file,start:f[0].newLine,end:f[f.length-1].newLine,snippet:f.map(h=>h.text).join(`
89
+ `)}}}});import{spawn as EN,spawnSync as RN}from"node:child_process";import SN from"node:os";import uv from"node:path";import{ulid as NN}from"ulid";function Sd(e){let t=[],n="",r=!1,o=null;for(let s of e.trim()){if(o){s===o?o=null:n+=s;continue}if(s==='"'||s==="'"){o=s,r=!0;continue}if(/\s/.test(s)){r&&t.push(n),n="",r=!1;continue}n+=s,r=!0}return r&&t.push(n),t}function CN(e){let t=e.trim();return t==="$EDITOR"?process.env.EDITOR:t==="$VISUAL"?process.env.VISUAL:t}function Wa(){let{preferredEditor:e}=de(),t=[e?CN(e):void 0,process.env.VISUAL,process.env.EDITOR].filter(n=>!!n?.trim());return[...new Set(t)]}function Nd(e){let[t=""]=Sd(e);return/(^|\/)code(-insiders)?$/.test(t)}function mv(e,t){let[n="",...r]=Sd(e);return{command:n,args:[...r,...t]}}function pv(e,t){return mv(e,Nd(e)?["--wait",t]:[t])}function wN(e,t,n,r="new"){return mv(e,[r==="new"?"--new-window":"--reuse-window","--diff",t,n])}function fv(e){let t=uv.join(SN.tmpdir(),"epiq");Qe.mkDir(t);let n=uv.join(t,NN());Qe.writeToFile(n,e??"");let r=Wa();for(let o of r){let{command:s,args:i}=pv(o,n);if(!s)continue;let c=RN(s,i,{stdio:"inherit"});if(!c.error&&c.status===0){let u=Qe.readFile(n);if(u==null)return l("Unable to read edited file");let p=u.replace(/\r?\n$/,"");return d("Successfully edited",p)}}return l("Unable to open editor")}function TN(e){let[t=""]=Sd(e),n=t.split("/").pop()??t;return AN.has(n)}function gv({command:e,args:t},n){return new Promise(r=>{if(!e){r(l(`"${n}" is not a usable editor command`));return}let o=EN(e,t,{stdio:"ignore",detached:!0}),s=!1,i=u=>{s||(s=!0,clearTimeout(c),r(u))};o.on("error",u=>i(l(u.message))),o.on("exit",u=>{i(u===0?d("Opened editor",!0):l(`"${n}" exited with code ${u}`))});let c=setTimeout(()=>{o.unref(),i(d("Opened editor",!0))},kN)})}function MN(e,t){return TN(e)?Promise.resolve(l(`"${e}" is a terminal editor and can't open from the GUI (no terminal attached). Set preferredEditor to a GUI editor (e.g. "code"), or open the file yourself: ${t}`)):gv(pv(e,t),e)}function Cd(e,t,n,r="new"){return gv(wN(e,t,n,r),e)}async function hv(e){let t=Wa();if(t.length===0)return l("No editor configured (preferredEditor, VISUAL, or EDITOR)");let n=l("Unable to open editor");for(let r of t){let o=await MN(r,e);if(!a(o))return o;n=o,logger.error(`Failed to open editor "${r}" for ${e}: ${o.message}`)}return n}var AN,kN,wd=g(()=>{"use strict";N();Ue();Qi();AN=new Set(["vim","vi","nvim","nano","pico","ed"]);kN=600});import{chmodSync as LN,existsSync as PN,lstatSync as DN,mkdirSync as ON}from"node:fs";import _N from"node:os";import FN from"node:path";var si,Ad=g(()=>{"use strict";N();si=(...e)=>{let t=FN.join(_N.tmpdir(),"epiq",...e);try{return PN(t)&&DN(t).isSymbolicLink()?l(`Refusing to write through a symlink at ${t}`):(ON(t,{recursive:!0,mode:448}),LN(t,448),d("Prepared private temp dir",t))}catch(n){return l(`Unable to prepare ${t}: ${n instanceof Error?n.message:String(n)}`)}}});import{existsSync as Td}from"node:fs";import{chmod as kd}from"node:fs/promises";import qa from"node:path";var BN,$N,jN,vv,UN,HN,Md,yv=g(()=>{"use strict";Ke();wd();N();Qi();Ad();Do();BN=async(e,t)=>{let n=await W({cwd:e,args:["show",t]});if(a(n))return l(n.message);let r=si("commit-diffs");if(a(r))return l(r.message);let o=qa.join(r.value,`${t}.diff`);return Td(o)||(Qe.writeToFile(o,n.value.stdout),await kd(o,292)),hv(o)},$N=12,jN=800,vv=async(e,t,n)=>{let r=await W({cwd:e,args:["show",`${t}:${n}`]});return a(r)?"":r.value.stdout},UN=async(e,t)=>{let n=await W({cwd:e,args:["diff","--name-only",`${t}~1`,t]});if(a(n))return l(n.message);let r=n.value.stdout.split(`
90
+ `).map(o=>o.trim()).filter(Boolean);return r.length===0?l("No changed files found for this commit"):d("Listed changed files",r)},HN=async(e,t,n)=>{let r=await UN(e,t);if(a(r))return l(r.message);let o=r.value;if(o.length>$N)return l(`Commit touches ${o.length} files \u2014 too many for a side-by-side view`);let s=si("commit-diffs",t);if(a(s))return l(s.message);let i=s.value,c=await Promise.all(o.map(async(h,b)=>{let[E,S]=await Promise.all([vv(e,`${t}~1`,h),vv(e,t,h)]),w=qa.basename(h),R=qa.join(i,String(b),"before",w),k=qa.join(i,String(b),"after",w);return Td(R)||(Qe.writeToFile(R,E),await kd(R,292)),Td(k)||(Qe.writeToFile(k,S),await kd(k,292)),{beforePath:R,afterPath:k}})),[u,...p]=c;if(!u)return l("No changed files found for this commit");let m=await Cd(n,u.beforePath,u.afterPath,"new");if(a(m)||p.length===0)return m;await new Promise(h=>setTimeout(h,jN));let f=await Promise.all(p.map(({beforePath:h,afterPath:b})=>Cd(n,h,b,"reuse")));for(let h of f)a(h)&&logger.error(`Failed to open an additional diff tab for ${t}: ${h.message}`);return m},Md=async e=>{if(!oi(e.sha))return l("Invalid commit sha");let t=dr(e.repoRoot);if(a(t))return l(t.message);let n=t.value,r=Wa()[0];if(r&&Nd(r)){let o=await HN(n,e.sha,r);if(!a(o))return o;logger.error(`Side-by-side diff failed for ${e.sha}, falling back to unified diff: ${o.message}`)}return BN(n,e.sha)}});var ii=g(()=>{"use strict";Do();vd();sv();Ha();yv()});var Ga,Bo,Ld=g(()=>{"use strict";N();sr();D();bo();pe();Ga=(e,t,n)=>{let r=[],o=ga(()=>{for(let s=0;s<t;s++){let i=Lt(BigInt(s+1));if(!Dt(i))continue;let c=C.createNode($e.text({id:n(s),name:`Line ${s+1}`,parentNodeId:e,rank:i.value,readonly:!0,isVirtual:!0}));Dt(c)&&r.push(c.value)}});return a(o)&&logger.error(`Line nodes: ${o.message}`),r},Bo=e=>{C.deleteNodes(e.map(t=>t.id))}});import{useSyncExternalStore as WN}from"react";var Va,za,Pd,bv,Dd,Ka,xv,Gr,Od,Iv,ur,Ya=g(()=>{"use strict";D();Va=null,za=null,Pd=new Set,bv=()=>{for(let e of Pd)e()},Dd=e=>{Va=e,bv()},Ka=()=>Va,xv={mark:null},Gr=e=>{za=e,xv={mark:e},bv()},Od=e=>za&&za.sha===e?za.row:null,Iv=()=>WN(e=>(Pd.add(e),()=>{Pd.delete(e)}),()=>xv),ur=()=>{let{contextNode:e}=v();return Va&&Va.sha===e.id?e.id:null}});var Ev=g(()=>{"use strict"});import{Box as an,Text as Hn}from"ink";import De,{useEffect as _d,useMemo as Rv,useRef as GN,useState as zN}from"react";import VN from"string-width";function Cv({ticket:e,sha:t,subject:n,width:r,height:o}){let[s,i]=zN({state:"loading"});_d(()=>{let M=!0;return i({state:"loading"}),yd({sha:t}).then(F=>{M&&i(a(F)?{state:"failed",message:F.message}:{state:"loaded",rows:Id(xd(F.value))})}),()=>{M=!1}},[t]);let c=s.state==="loaded"?s.rows:null,u=c!==null&&c.length>4e3,p=GN([]);_d(()=>(Bo(p.current),p.current=c&&!u?Ga(t,c.length,M=>Fd(t,M)):[],()=>{Bo(p.current),p.current=[]}),[t,c,u]),_d(()=>(Dd(c?{sha:t,rows:c}:null),Gr(null),()=>{Dd(null),Gr(null)}),[t,c]);let{selectedIndex:m}=Ye(),{mark:f}=Iv(),h=Rv(()=>c?Ed(c,C.getCommentsByIssue(e.id),t):new Set,[c,t,e]),b=f&&f.sha===t?f.row:null,E=M=>b!==null&&M>=Math.min(b,m)&&M<=Math.max(b,m),S=Rv(()=>c?Math.max(5,c.reduce((M,F)=>Math.max(M,Nv(F).length),0)+2):5,[c]),w=Math.max(1,o-4),R=Math.max(8,r-S-6);if(s.state!=="loaded")return De.createElement(an,{flexDirection:"column",width:r,height:o,padding:1},De.createElement(Hn,{color:T.primary},s.state==="loading"?"Reading the diff\u2026":`Could not read the diff: ${s.message}`));let k=M=>De.createElement(an,{paddingLeft:4,borderLeft:!1,borderRight:!1,borderBottom:!1,borderTop:!0,borderColor:T.secondary,borderStyle:"single",paddingBottom:1},De.createElement(Hn,{color:T.secondary2,wrap:"truncate-end"},Rr(`${t.slice(0,7)} ${n} \u2014 ${M}`,Math.max(8,r-6))));return s.rows.length===0?De.createElement(an,{flexDirection:"column",width:r,height:o},k("no changes"),De.createElement(an,{paddingX:1},De.createElement(Hn,{color:T.primary},"This commit changed no files."))):u?De.createElement(an,{flexDirection:"column",width:r,height:o},k("too large to draw here"),De.createElement(an,{paddingX:1,flexDirection:"column"},De.createElement(Hn,{color:T.primary},`${s.rows.length.toLocaleString()} lines of diff.`),De.createElement(Hn,{color:T.secondary2},"Press o to open it in your editor."))):De.createElement(an,{flexDirection:"column",width:r,height:o},k(b===null?"enter to comment on a line, s to start a range, o editor, q back":"move to the other end, then enter to comment \u2014 s clears the mark"),De.createElement(Wt,{scrollByOne:!0,height:w,selectedIndex:m,itemHeight:1},s.rows.map((M,F)=>{let j=F===m,z=KN(M.kind);if(M.kind==="file")return De.createElement(an,{key:Fd(t,F),paddingX:1},De.createElement(Hn,{backgroundColor:T.secondary,color:j?T.accent:z,bold:!0,wrap:"truncate-end"},Sv(` ${Rr(ri(M.text),R)}`,R+S+1)));let J=E(F),se=`${YN(M.kind)}${Rr(ri(M.text),R)}`;return De.createElement(an,{key:Fd(t,F),paddingX:1},De.createElement(an,{flexShrink:0},De.createElement(Hn,{color:j||J?T.accent:T.secondary2,dimColor:!j&&!J,wrap:"truncate-end"},`${j?"\u276F":"\xA0"}${J?"\u258C":"\xA0"}${Nv(M).padStart(S-2,"\xA0")}`)),De.createElement(an,{flexShrink:0},De.createElement(Hn,{color:T.yellow,wrap:"truncate-end"},h.has(F)?"\u2502":"\xA0")),De.createElement(Hn,{color:j?T.accent:z,backgroundColor:j||J?T.secondary:void 0,wrap:"truncate-end"},j||J?Sv(se,R+1):se))})))}var Fd,KN,Sv,YN,Nv,wv=g(()=>{"use strict";ii();pe();N();Ld();Ya();D();Je();Ev();Ba();vt();Hr();Fd=(e,t)=>`${e}::patch::${t}`,KN=e=>{switch(e){case"added":return T.green;case"removed":return T.red;case"hunk":return T.accent;case"file":return T.primary;default:return T.secondary2}},Sv=(e,t)=>{let n=VN(e);return n>=t?e:e+"\xA0".repeat(t-n)},YN=e=>e==="added"?"+":e==="removed"?"-":" ",Nv=e=>e.kind==="file"||e.kind==="hunk"||e.kind==="note"||e.newLine===void 0?"":String(e.newLine)});import{Box as zr,Text as Cn}from"ink";import Ge,{useEffect as Av,useRef as XN,useState as JN}from"react";function kv({ticket:e,width:t,height:n}){let[r,o]=JN({state:"loading"}),s=V(e.id);Av(()=>{let E=!0;return o({state:"loading"}),Fo({ref:s}).then(S=>{E&&o(a(S)?{state:"failed",message:S.message}:{state:"loaded",commits:S.value})}),()=>{E=!1}},[s]);let i=XN([]),c=r.state==="loaded"?r.commits:null;Av(()=>(Tv(i.current),i.current=c?eC(e,c):[],()=>{Tv(i.current),i.current=[]}),[e,c]);let{selectedIndex:u,contextNode:p}=Ye(),m=c?.find(E=>E.sha===p.id)??null,h=Math.max(1,n-4),b=Math.max(12,t-34);return r.state!=="loaded"?Ge.createElement(zr,{flexDirection:"column",width:t,height:n,padding:1},Ge.createElement(Cn,{color:T.primary},r.state==="loading"?"Reading commits\u2026":`Could not read commits: ${r.message}`)):m?Ge.createElement(Cv,{ticket:e,sha:m.sha,subject:m.subject,width:t,height:n}):r.commits.length===0?Ge.createElement(zr,{flexDirection:"column",width:t,height:n,padding:1},Ge.createElement(Cn,{color:T.primary},"No commits reference this ticket."),Ge.createElement(zr,{paddingTop:1},Ge.createElement(Cn,{color:T.primary},"Commits are matched by the"),Ge.createElement(Cn,{color:T.accent},` ${s} `),Ge.createElement(Cn,{color:T.primary},"prefix on their subject line."))):Ge.createElement(zr,{flexDirection:"column",width:t,height:n},Ge.createElement(zr,{paddingLeft:4,borderLeft:!1,borderRight:!1,borderBottom:!1,borderTop:!0,borderColor:T.secondary,borderStyle:"single",paddingBottom:1},Ge.createElement(Cn,{color:T.secondary2},`Diff (${r.commits.length}) \u2014 enter to read, o to open in your editor `)),Ge.createElement(Wt,{height:h,itemHeight:2,selectedIndex:u},r.commits.map((E,S)=>{let w=S===u,R=E.subject.length>b?E.subject.slice(0,b-1)+"\u2026":E.subject;return Ge.createElement(zr,{key:E.sha,flexDirection:"row",paddingX:1,paddingBottom:1},Ge.createElement(Cn,{color:T.accent},w?"\u276F ":" "),Ge.createElement(zr,{paddingLeft:1},Ge.createElement(Cn,{color:T.secondary2},`${E.sha.slice(0,7)} `),Ge.createElement(Cn,{color:w?T.accent:T.primary},R),Ge.createElement(Cn,{color:T.secondary2},` ${tC(E)} ${ar(E.time)}`)))})))}var QN,Tv,ZN,eC,tC,Mv=g(()=>{"use strict";It();ii();me();N();pe();sr();D();Je();ei();ft();Jn();wv();Hr();QN=e=>Te(e,"diff"),Tv=e=>{for(let t of e)C.deleteNode(t.id)},ZN=(e,t,n)=>$e.field({id:e.sha,name:e.subject,parentNodeId:n,rank:String(t).padStart(6,"0"),childRenderAxis:"vertical",isVirtual:!0}),eC=(e,t)=>{let n=C.getNode(QN(e.id));if(!n||!nt(n))return[];let r=t.map((o,s)=>ZN(o,s,n.id)).map(o=>C.createNode(o)).filter(Dt).map(({value:o})=>o).filter(nt);return t.length>0&&v().selectedIndex<0&&v().contextNode.id===n.id&&H.navigate({contextNode:n,selectedIndex:0}),r},tC=e=>`+${e.insertions} -${e.deletions}`});import{Box as Xa,Text as nC}from"ink";import Wn from"react";var Lv,Pv=g(()=>{"use strict";me();pe();Eo();D();Je();La();wo();cd();Lv=({selectedIndex:e,parent:t,selected:n})=>{let{contextNode:r}=Ye(),{title:o}=t,s=t.parentNodeId?C.getNode(t.parentNodeId):void 0,i=s&&U(s)?o===Ae.ASSIGNEES?s.props.assignees??[]:o===Ae.TAGS?(s.props.tags??[]).filter(c=>C.getTag(c)):[]:[];return Wn.createElement(Xa,{alignItems:"center",paddingTop:1},Wn.createElement(Xa,{minWidth:12},Wn.createElement(Ht,{isSelected:n}),Wn.createElement(nC,{color:n?T.accent:T.secondary2},o,":")),Wn.createElement(Xa,{flexDirection:"row",marginLeft:1,paddingRight:1},i.map((c,u)=>{let p=r.id===t.id&&u===e;return Wn.createElement(Xa,{key:`${o}-${c}`,paddingRight:2,minHeight:1},Wn.createElement(Ht,{isSelected:p}),o===Ae.ASSIGNEES?Wn.createElement(Ao,{isSelected:p,id:c}):o===Ae.TAGS?Wn.createElement(Pa,{isSelected:p,id:c}):null)})))}});var Bd,Dv,$d,jd=g(()=>{"use strict";Bd=e=>Math.max(5,String(Math.max(e,1)).length+3),Dv=(e,t)=>Math.max(0,e-6-Bd(t)),$d=(e,t=0,n=0)=>Math.max(1,e-5-2*t-(n>0?1+n:0))});import{Box as $o,Text as Ud}from"ink";import Gt,{useEffect as rC,useMemo as Hd,useRef as oC}from"react";var sC,Ov,Wd,_v=g(()=>{"use strict";Ld();D();Je();vt();jd();wo();Hr();gd();Ba();sC="\u2029",Ov=(e,t)=>`${e}::inline-line::${t}`,Wd=({id:e,label:t,text:n,rows:r,selected:o,maxWidth:s})=>{let{selectedIndex:i,contextNode:c}=Ye(),u=Hd(()=>typeof n=="string"?n.split(/\r?\n|\u2028|\u2029/):[],[n]),p=Hd(()=>u.join("\0"),[u]),m=oC([]);rC(()=>(Bo(m.current),m.current=Ga(e,u.length,S=>Ov(e,S)),()=>{Bo(m.current),m.current=[]}),[e,p]);let f=Bd(u.length),h=Dv(s,u.length),E=Hd(()=>pd(u).map(S=>{if(S.kind==="code"||S.kind==="caption")return{...S,text:Rr(S.text,h)};if(S.kind==="text"||S.kind==="heading"){let w=S.spans.map(R=>R.code?`\`${R.text}\``:R.text).join("");return{...S,spans:ni(Rr(w,h))}}return S}),[u,h]).map((S,w)=>{let R=c.id===e&&i===w;return Gt.createElement($o,{key:Ov(e,w)},Gt.createElement($o,{flexShrink:0},Gt.createElement(Ud,{color:R?T.primary:T.secondary2,dimColor:!R},`${w+1} `.padStart(f,"\xA0"))),S.kind==="blank"?Gt.createElement(Ud,{backgroundColor:R?"gray":void 0},sC):Gt.createElement($o,null,Gt.createElement(fd,{line:S,width:S.kind==="code"?h:0,wrap:"truncate-end"})))});return Gt.createElement($o,{flexDirection:"column",paddingTop:1},Gt.createElement($o,null,Gt.createElement(Ht,{isSelected:o}),Gt.createElement(Ud,{color:o?T.accent:T.secondary2},t)),Gt.createElement($o,{flexDirection:"row",borderStyle:"round",borderColor:T.secondary,paddingLeft:1,marginLeft:1,overflowY:"hidden"},Gt.createElement(Wt,{scrollByOne:!0,height:r,selectedIndex:i,itemHeight:1},E)))}});import{Box as jo,Text as iC}from"ink";import Rt,{useMemo as Uo}from"react";var aC,lC,cC,dC,uC,Fv,Bv=g(()=>{"use strict";me();pe();D();Je();_a();Jn();Fh();tv();wo();Mv();Pv();_v();jd();aC=e=>Te(e,"description"),lC=e=>Te(e,"comments"),cC=e=>Te(e,"history"),dC=e=>Te(e,"diff"),uC=e=>Te(e,"attachments"),Fv=({ticket:e,height:t})=>{let n=Uo(()=>Mh(e),[e]),{selectedIndex:r,contextNode:o}=Ye(),s=process.stdout.columns||120,i=Uo(()=>aC(e.id),[e.id]),c=Uo(()=>lC(e.id),[e.id]),u=Uo(()=>cC(e.id),[e.id]),p=Uo(()=>dC(e.id),[e.id]),m=Uo(()=>uC(e.id),[e.id]),f=C.getAttachmentsByIssue(e.id).length,h=o.id===e.id,b=o.id===c||o.parentNodeId===c,E=o.id===u||o.parentNodeId===u,S=o.id===m||o.parentNodeId===m,w=o.id===p||o.parentNodeId===p,R=be(e.id);if(b){let le=t-3;return Rt.createElement(jo,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},Rt.createElement(ev,{ticket:e,width:s,height:le}))}if(S){let le=t-3;return Rt.createElement(jo,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},Rt.createElement(_h,{ticket:e,width:s,height:le}))}if(w){let le=t-3;return Rt.createElement(jo,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},Rt.createElement(kv,{ticket:e,width:s,height:le}))}if(E){let q=C.getNode(u),le=q&&nt(q)?q.props.value??"":"",gt=$d(t);return Rt.createElement(jo,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},q?Rt.createElement(Wd,{id:q.id,label:"Event log",text:le,selected:!1,maxWidth:s,rows:gt}):null)}let k=[u,p,c,m],M=q=>k.includes(q),F=R.reduce((q,le)=>us(le)?q+1:q,0),j=R.reduce((q,le)=>M(le.id)?q+1:q,0),z=R.findIndex(q=>M(q.id)),J=$d(t,F,j),se=(q,le,gt,ns)=>Rt.createElement(jo,{key:q.id,paddingTop:le===z?1:0},Rt.createElement(Ht,{isSelected:gt}),Rt.createElement(iC,{backgroundColor:T.secondary,color:gt?T.accent:T.primary},ns)),ze=(q,le,gt)=>q.id===i?Rt.createElement(Wd,{key:q.id,id:i,label:"Description (press e to edit)",text:e.props.description??"",selected:le,maxWidth:s,rows:J}):us(q)?Rt.createElement(Lv,{key:q.id,parent:q,selected:le,selectedIndex:r}):q.id===c?se(q,gt,le,` Comments (${n}) \u203A\u203A `):q.id===m?se(q,gt,le,` Attachments (${f}) \u203A\u203A `):q.id===u?se(q,gt,le," History \u203A\u203A "):q.id===p?se(q,gt,le," Diff \u203A\u203A "):null;return Rt.createElement(jo,{width:s,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},R.map((q,le)=>ze(q,h&&r===le,le)))}});import{Box as mC}from"ink";import Ja from"react";var pC,$v,jv=g(()=>{"use strict";me();kh();Bv();pC=({swimlanes:e,contextNode:t,selectedIndex:n,breadCrumb:r,mode:o,viewMode:s,height:i,width:c})=>{let u=t.context,p=u===ie.TICKET||u===ie.FIELD_LIST||u===ie.FIELD,m=u===ie.BOARD||u===ie.SWIMLANE,f=u===ie.TICKET?t:r.find(w=>w.context===ie.TICKET),h=Math.floor(c/3),b=Math.floor(c/Math.max(e.length,1)),E=Math.min(b,h),S=s==="dense";return Ja.createElement(mC,{flexDirection:"row",height:i},m&&e.map((w,R)=>{let k=t.id===w.id,M=k?n:-1,F=t.context===ie.BOARD&&n===R;return Ja.createElement(Th,{key:w.id,height:i,width:E,swimlane:w,isSelected:F,isDense:S,isFocused:k,listSelectedIndex:M,mode:o})}),p&&f&&Ja.createElement(Fv,{height:i,ticket:f}))},$v=Ja.memo(pC)});import Uv from"node:fs";import fC from"node:path";import gC from"react";import{render as hC}from"ink";import{Writable as vC}from"node:stream";var ai,yC,bC,xC,IC,Hv,Wv=g(()=>{"use strict";jv();me();N();D();ee();Ue();ai=e=>String(e).padStart(2,"0"),yC=e=>{let t=e.getUTCFullYear(),n=ai(e.getUTCMonth()+1),r=ai(e.getUTCDate()),o=ai(e.getUTCHours()),s=ai(e.getUTCMinutes()),i=ai(e.getUTCSeconds());return`${t}-${n}-${r}_${o}-${s}-${i}`},bC=e=>e.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^[-.]+|[-.]+$/g,"").toLowerCase()||"board",xC=async(e,{width:t,height:n})=>{let r="",o=new vC({write(i,c,u){let p=IC(i.toString()).trimEnd();p.trim().length>0&&p.includes("\u256D")&&(r=p),u()}});o.columns=t,o.rows=n,o.isTTY=!0;let s=hC(e,{stdout:o,debug:!1,exitOnCtrlC:!1,patchConsole:!1,incrementalRendering:!1});return await new Promise(i=>setTimeout(i,0)),s.unmount(),r},IC=e=>e.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,""),Hv=async()=>{let{viewMode:e}=de(),{contextNode:t,selectedIndex:n,breadCrumb:r,mode:o,renderedChildrenIndex:s}=v(),i=r.find(R=>R.context==="BOARD");if(!i)return l("No board found to export");let c=120,u=40,p=await xC(gC.createElement($v,{height:u,width:c,swimlanes:(s[i.id]??[]).filter(R=>R!==void 0&&xr(R)),contextNode:t,selectedIndex:n,breadCrumb:r,viewMode:e??"dense",mode:o}),{width:c,height:u});if(!p)return l("Failed to render board export");let m=Di(process.cwd());if(a(m))return l("Unable to export, epiq root not found");let f=new Date,h=yC(f),b=`board_${bC(i.title)}_${h}.md`,E=vp(m.value);Uv.mkdirSync(E,{recursive:!0});let S=fC.join(E,b),w=`# Board - ${i.title}
91
91
  Date: ${f.toISOString()}
92
92
 
93
93
  \`\`\`text
94
94
  ${p}
95
95
  \`\`\`
96
- `;return Iv.writeFileSync(S,C,"utf8"),d("Exported board layout",S)}});import{useSyncExternalStore as e1}from"react";var kd,VN,KN,_r,YN,uo,Wa=g(()=>{"use strict";w();VN=new Set,KN=()=>{for(let e of VN)e()},_r=()=>{if(!kd)throw new Error("Ui state not initialized. Call initUiState() first.");return kd},YN=e=>{let t=_r();return kd=e(t),KN(),d("UX state updated",null)},uo=e=>YN(t=>({...t,...e}))});import{ulid as Md}from"ulid";var Sv,XN,JN,Nv=g(()=>{"use strict";pd();$();$();Yt();me();w();sr();pe();O();ee();_n();Ft();Sv=async e=>{let{contextNode:t,selectedIndex:n}=v(),o=ve(t.id)[n];if(e.modifier===Mt.DESCRIPTION)return JN();if(o&&ls(o))return XN(e);if(e.modifier===Mt.TITLE){let r=ge();if(a(r))return l("Unable to resolve user ID");let s=o;if(!s)return l("Missing node");if(s.readonly)return l("Cannot rename readonly node");let i=e.inputString.trim();if(!i)return l("Provide a title");let c=await Ee();return a(c)?c:F([{id:Md(),action:"edit.title",payload:{id:s.id,name:i},...D(r.value)}],c.value)}return l("Unknown edit command")},XN=async e=>{let t=ge();if(a(t))return l("Unable to resolve user ID");let{contextNode:n,selectedIndex:o}=v(),r=ve(n.id)[o];if(!r||!ls(r))return l("Select a comment first");if(r.readonly)return l("Cannot edit readonly comment");let s=n.parentNodeId;if(!s)return l("Unable to resolve comment issue");let i=v().nodes[s];if(!i||!U(i))return l("Unable to resolve comment issue");if(i.readonly)return l("Cannot edit readonly issue");let c=r.id.split(":").at(0)??"",u=N.getComment(c);if(!u||u.deleted)return l("Unable to resolve comment");if(u.issue!==i.id)return l("Comment does not belong to selected issue");if(u.authorId!==t.value.userId)return l("You can only edit your own comments"+u.authorId+"<->"+t.value.userId);let p=e.inputString.trim();if(!p)return l("Provide a comment");let m=await Ee();if(a(m))return m;let f=m.value;return F([{id:Md(),action:"edit.issue.comment",payload:{id:u.id,issue:i.id,md:p},...D(t.value)}],f)},JN=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let t=await Ee();if(a(t))return t;let n=t.value,{breadCrumb:o,selectedNode:r}=v(),s=Nt([...o,r],"TICKET");if(a(s))return l("Edit target must be an issue");let i=s.value;if(!U(i))return l("Edit target must be an issue");if(i.readonly)return l("Cannot edit readonly issue");let c=ve(i.id).find(f=>f.title===Ce.DESCRIPTION);if(!c)return l("No target found");if(c.readonly)return l("Cannot edit readonly field");let u=i.props.description??"";if(typeof u!="string")return l("Selected field is not editable text");let p=Kh(u);if(a(p))return l("Failed to edit field");let m=p.value;return m===u?d("No changes made",null):F([{id:Md(),action:"edit.description",payload:{id:i.id,md:m},...D(e.value)}],n)}});import Ld from"node:fs";import QN from"node:path";var wv,Cv=g(()=>{"use strict";w();$t();wv=async e=>{let t=QN.join(e,".gitignore"),n=Ld.existsSync(t)?Ld.readFileSync(t,"utf8"):"",o=[".epiq/events/",".epiq/log/"],r=n.split(`
97
- `).map(u=>u.trim()),s=o.filter(u=>!r.some(p=>p===u||p===u.replace(/\/$/,"")||p==="/"+u||p==="/"+u.replace(/\/$/,"")));if(s.length===0)return d("Local epiq paths already ignored",!1);let c=["# [epiq]: local hydrated state is never committed",...s].join(`
96
+ `;return Uv.writeFileSync(S,w,"utf8"),d("Exported board layout",S)}});import{useSyncExternalStore as F1}from"react";var qd,EC,RC,Ho,SC,mr,Qa=g(()=>{"use strict";N();EC=new Set,RC=()=>{for(let e of EC)e()},Ho=()=>{if(!qd)throw new Error("Ui state not initialized. Call initUiState() first.");return qd},SC=e=>{let t=Ho();return qd=e(t),RC(),d("UX state updated",null)},mr=e=>SC(t=>({...t,...e}))});import{ulid as Gd}from"ulid";var qv,NC,CC,Gv=g(()=>{"use strict";wd();$();$();Xt();me();N();Eo();pe();D();ee();Pn();Bt();qv=async e=>{let{contextNode:t,selectedIndex:n}=v(),r=be(t.id)[n];if(e.modifier===Mt.DESCRIPTION)return CC();if(r&&ms(r))return NC(e);if(e.modifier===Mt.TITLE){let o=he();if(a(o))return l("Unable to resolve user ID");let s=r;if(!s)return l("Missing node");if(s.readonly)return l("Cannot rename readonly node");let i=e.inputString.trim();if(!i)return l("Provide a title");let c=await Ee();return a(c)?c:_([{id:Gd(),action:"edit.title",payload:{id:s.id,name:i},...O(o.value)}],c.value)}return l("Unknown edit command")},NC=async e=>{let t=he();if(a(t))return l("Unable to resolve user ID");let{contextNode:n,selectedIndex:r}=v(),o=be(n.id)[r];if(!o||!ms(o))return l("Select a comment first");if(o.readonly)return l("Cannot edit readonly comment");let s=n.parentNodeId;if(!s)return l("Unable to resolve comment issue");let i=v().nodes[s];if(!i||!U(i))return l("Unable to resolve comment issue");if(i.readonly)return l("Cannot edit readonly issue");let c=o.id.split(":").at(0)??"",u=C.getComment(c);if(!u||u.deleted)return l("Unable to resolve comment");if(u.issue!==i.id)return l("Comment does not belong to selected issue");if(u.authorId!==t.value.userId)return l("You can only edit your own comments"+u.authorId+"<->"+t.value.userId);let p=e.inputString.trim();if(!p)return l("Provide a comment");let m=await Ee();if(a(m))return m;let f=m.value;return _([{id:Gd(),action:"edit.issue.comment",payload:{id:u.id,issue:i.id,md:p},...O(t.value)}],f)},CC=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let t=await Ee();if(a(t))return t;let n=t.value,{breadCrumb:r,selectedNode:o}=v(),s=Ct([...r,o],"TICKET");if(a(s))return l("Edit target must be an issue");let i=s.value;if(!U(i))return l("Edit target must be an issue");if(i.readonly)return l("Cannot edit readonly issue");let c=be(i.id).find(f=>f.title===Ae.DESCRIPTION);if(!c)return l("No target found");if(c.readonly)return l("Cannot edit readonly field");let u=i.props.description??"";if(typeof u!="string")return l("Selected field is not editable text");let p=fv(u);if(a(p))return l("Failed to edit field");let m=p.value;return m===u?d("No changes made",null):_([{id:Gd(),action:"edit.description",payload:{id:i.id,md:m},...O(e.value)}],n)}});import zd from"node:fs";import wC from"node:path";var zv,Vv=g(()=>{"use strict";N();_t();zv=async e=>{let t=wC.join(e,".gitignore"),n=zd.existsSync(t)?zd.readFileSync(t,"utf8"):"",r=[".epiq/events/",".epiq/log/"],o=n.split(`
97
+ `).map(u=>u.trim()),s=r.filter(u=>!o.some(p=>p===u||p===u.replace(/\/$/,"")||p==="/"+u||p==="/"+u.replace(/\/$/,"")));if(s.length===0)return d("Local epiq paths already ignored",!1);let c=["# [epiq]: local hydrated state is never committed",...s].join(`
98
98
  `);return n=n.trimEnd()+`
99
99
 
100
100
  ${c}
101
- `,Ld.writeFileSync(t,n,"utf8"),ce.info(`Added ${s.join(", ")} to .gitignore (epiq local state)`),d("Local epiq paths ignored",!0)}});import ZN from"node:fs";import Pd from"node:path";var ew,de,qa,tw,nw,Dd=g(()=>{"use strict";Cv();wi();rt();Ke();Ms();Po();$();To();w();ee();Jt();fc();ew=async e=>{let t=await W({cwd:e,args:["status","--porcelain"]});return a(t)?t:d("Checked git diff",t.value.stdout.split(`
102
- `).filter(n=>n.trim().length>0).map(n=>n.slice(3)))},de=(e,t)=>l(`[${e}] ${t}`),qa=async({cwd:e,user:t})=>{let n=Si(),o=await kt(e);if(a(o))return de(1,o.message);let r=o.value,s=await Ci(r);if(a(s))return de(2,s.message);if(s.value)return de(2,`Cannot initialize Epiq while a git operation is in progress: ${s.value}`);let i=await ew(r);if(a(i))return de(2.5,i.message);if(i.value.length>0)return de(3,`Cannot initialize Epiq with uncommitted changes (${i.value.join(", ")}). Commit or stash your changes first.`);if(ys(r))return de(4,"Epiq project already initialized");let{userId:c,userName:u}=t;if(!c||!u)return de(5,"Missing Epiq user id");let p=await Df(r);if(a(p))return de(6,p.message);let m=n.stateBranch,f=await Ai({repoRoot:r,branch:m});if(a(f))return de(6,f.message);if(f.value)return de(6,`State branch already exists: ${m}`);let h=await tw({repoRoot:r,stateBranch:m});if(a(h))return de(6,h.message);if(h.value)return nw({repoRoot:r,stateBranch:m});let x=await hc({repoRoot:r,stateBranchName:m});if(a(x))return de(6,x.message);let E=hs();if(a(E))return de(7,E.message);let S=Pd.join(No(),n.projectId),C=await to({repoRoot:r,stateBranchRoot:S,stateBranchName:m});if(a(C))return de(8,C.message);let R=Pd.join(S,".epiq");ZN.mkdirSync(R,{recursive:!0});let A=If({userId:c,userName:u});if(a(A))return de(9,A.message);for(let jx of A.value){let tm=Qp({event:jx,rootDir:S});if(a(tm))return de(9,tm.message)}let L=Qn({userId:c}),_=Oi(S,L);if(a(_))return de(9,_.message);let j=pc(S,n);if(a(j))return de(9,j.message);let z=await ea({stateBranchRoot:S,eventFileName:L});if(a(z))return de(10,z.message);let X=await Ne.stage({cwd:S,pathspec:[st]});if(a(X))return de(10,X.message);let ue=await nr({cwd:S,message:"[epiq:init]"});if(a(ue))return de(10,ue.message);let ze=await wv(r);if(a(ze))return de(11,ze.message);let q=Ml({repoRoot:r,fileContents:n});if(a(q))return de(12,q.message);let ae=await Ne.stage({cwd:r,pathspec:[".epiq/project.json",".gitignore"]});if(a(ae))return de(13,ae.message);let Pt=await Ne.commit({cwd:r,message:"[epiq:init-project]",pathspec:[".epiq/project.json",".gitignore"]});if(a(Pt))return de(13,Pt.message);let Qr=[],Zu=await W({cwd:r,args:["push","-u","origin","HEAD"]});a(Zu)&&Qr.push(`[init:14] ${Zu.message}`);let em=await ks({repoRoot:r,stateBranchRoot:S});return a(em)&&Qr.push(`[init:15] ${em.message}`),d("Project initialized",{repoRoot:r,projectId:n.projectId,stateBranch:m,stateBranchRoot:S,defaultEvents:A.value,warnings:Qr})},tw=async({repoRoot:e,stateBranch:t})=>{let n=await kn({repoRoot:e});if(a(n))return l(n.message);if(!n.value)return d("No remote",!1);let o=await ms({repoRoot:e,branch:t});return a(o)?l(`Could not ask origin whether ${t} exists: ${o.message}`):o},nw=async({repoRoot:e,stateBranch:t})=>{let n=await W({cwd:e,args:["fetch","origin",t]});if(a(n))return de(6,n.message);let o=await W({cwd:e,args:["show",`origin/${t}:${st}`]});if(a(o))return de(6,[`This repository is already an epiq project: origin has the state branch ${t}.`,"Initialising again would mint a second id for the same board.","","The branch was written before branches carried their identity, so restore",`${st} from a checkout that has it, for example:`,"",` git show origin/main:${st} > ${st}`,"","and commit it; every later boot then stamps the branch, and the next clone adopts it."].join(`
103
- `));let r;try{r=JSON.parse(o.value.stdout)}catch(E){return de(6,`The identity on origin/${t} is not readable: ${E instanceof Error?E.message:String(E)}`)}let s=Ml({repoRoot:e,fileContents:r});if(a(s))return de(12,s.message);let i=await Ne.stage({cwd:e,pathspec:[st]});if(a(i))return de(13,i.message);let c=await Ne.commit({cwd:e,message:"[epiq:adopt-project]",pathspec:[st]});if(a(c))return de(13,c.message);let u=hs();if(a(u))return de(7,u.message);let p=Pd.join(No(),r.projectId),m=await Ts({repoRoot:e,stateBranchName:t});if(a(m))return de(8,m.message);let f=await to({repoRoot:e,stateBranchRoot:p,stateBranchName:t});if(a(f))return de(8,f.message);let h=[],x=await W({cwd:e,args:["push","-u","origin","HEAD"]});return a(x)&&h.push(`[init:14] ${x.message}`),d("Adopted the project origin already holds",{repoRoot:e,projectId:r.projectId,stateBranch:r.stateBranch,stateBranchRoot:p,defaultEvents:[],warnings:h})}});var ei,Av,Tv=g(()=>{"use strict";xt();Oo();$();w();Dd();he();Fe();O();ei=(e,t)=>l(`[${e}] ${t}`),Av=async()=>{ne("");let e=_s();if(!e.isSetupDone||!e.userName)return ei(5,"Missing Epiq user configuration (userId / userName). Run setup first.");let t=le(),n=t.userName,o=t.userId;if(!o||!n)return ei(5,"Missing Epiq user id");let r=await qa({cwd:process.cwd(),user:{userId:o,userName:n}});if(a(r))return r;let s="Project initialized!";for(let h of r.value.warnings)s+=` Warn: ${h}`;let c=Pn(r.value.defaultEvents).filter(a);if(c.length>0)return ei(16,c.map(h=>h.message).join(`
104
- `));let u=Me();if(a(u))return ei(16,u.message);let{rootNodeId:p,nodes:m}=u.value,f=m[p];return f?(H.navigate({contextNode:f,selectedIndex:0}),T({hasProjectDefinition:!0}),d(s,null)):ei(16,"Unable to resolve initialized root node")}});import{ulid as ow}from"ulid";function Fd(e){let t=Mv();if(a(t))return t;let{contextNode:n,nodes:o}=v();if(!n.parentNodeId)return l("Missing parent node id");let r=o[n.parentNodeId];if(!r)return l("Missing parent node");let s=ke(r.id),i=s.findIndex(({id:p})=>p===n.id);if(i<0)return l("Current node not found among siblings");let c=s[i+e];if(!c)return l("Missing sibling node");let u=Lv({id:t.value.id,parentId:c.id,position:{at:"end"}});return a(u)?u:Pv(u.value)}function ni(e,t=1){let n=Mv();if(a(n))return n;let{contextNode:o,selectedIndex:r}=v(),s=ke(o.id),i=Math.min(Math.max(r+e*t,0),s.length-1),c=i===r?void 0:s[i];if(!c)return l("Missing sibling node");let u=Lv({id:n.value.id,parentId:o.id,position:{at:e===1?"after":"before",sibling:c.id}});return a(u)?u:Pv(u.value)}var kv,ln,ti,Mv,Od,Lv,Pv,_d=g(()=>{"use strict";$();$();w();Bt();O();kv=null,ln=()=>structuredClone(kv),ti=e=>{kv=e},Mv=()=>{let{contextNode:e,selectedIndex:t}=v(),o=ke(e.id)[t];return o?d("Resolved selected child",o):l("Target node not found")},Od=({id:e,parentId:t,position:n={at:"end"}})=>{let o=ke(t).filter(r=>r.id!==e);return Ki(o,n)},Lv=({id:e,parentId:t,position:n={at:"end"}})=>{let o=ge();if(a(o))return l("Unable to resolve user ID");let r=Od({parentId:t,id:e,position:n});return a(r)?r:d("Created pending move state",{id:ow(),...o.value,action:"move.node",payload:{id:e,parent:t,rank:r.value.rank}})},Pv=e=>{ti(e);let t=Ss(e,!0);return a(t)?t:d("Node moved successfully",t.value)}});import{ulid as rw}from"ulid";var Dv,Br,Ov,Fv=g(()=>{"use strict";xt();_d();$();$();_t();Oe();w();Bt();he();O();ee();Dv=()=>{let e=ln();if(!e)return l("No pending move state");let t=e.payload.id,n=e.payload.parent,o=v().nodes[n];if(!o)return l("Move parent not found");let r=ke(n).findIndex(s=>s.id===t);return r===-1?l("Moved node not found among rendered children"):(H.navigate({contextNode:o,selectedIndex:r}),d("Synchronized navigation to moved node",null))},Br=(e,t="Moved preview")=>{if(a(e))return ln()&&T({mode:b.MOVE}),e;let n=Dv();return a(n)?n:(T({mode:b.MOVE}),d(t,null))},Ov=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let{modifier:t}=fe().commandMeta,{contextNode:n,selectedIndex:o}=v(),r=ke(n.id)[o];if(!r)return T({mode:b.DEFAULT}),l("No move target");if(t==="start"){if(r.readonly)return l("Target node is read-only");if(o===-1)return l("No item selected");if(!r.parentNodeId)return l("Target has no parent");let s=ke(r.parentNodeId),i=s.findIndex(({id:f})=>f===r.id);if(i===-1)return l("Target not found among siblings");let c=s[i-1],u=s[i+1],p=u!=null?{at:"before",sibling:u.id}:c!=null?{at:"after",sibling:c.id}:{at:"start"},m=Od({parentId:r.parentNodeId,id:r.id,position:p});return a(m)?m:(ti({id:rw(),action:"move.node",payload:{id:r.id,parent:r.parentNodeId,rank:m.value.rank},...D(e.value)}),T({mode:b.MOVE}),d("Move initialized",null))}if(t==="next")return Br(ni(1));if(t==="previous")return Br(ni(-1));if(t==="jump-next")return Br(ni(1,Ns));if(t==="jump-previous")return Br(ni(-1,Ns));if(t==="to-next")return Br(Fd(1));if(t==="to-previous")return Br(Fd(-1));if(t==="confirm"){let s=ln();if(!s)return l("No pending move to confirm");let i=await Ee();if(a(i))return i;let c=F([s],i.value);if(a(c))return c;let u=Dv();return a(u)?u:(ti(null),T({mode:b.DEFAULT}),d("Moved item",null))}return t==="cancel"?(ti(null),T({mode:b.DEFAULT}),d("Cancelling move",null)):l("Invalid move modifier")}});import{monotonicFactory as sw,ulid as iw}from"ulid";var aw,Ga,Bd=g(()=>{"use strict";w();aw=sw(),Ga=({name:e,parent:t,rank:n,user:{userId:o}})=>{let r=aw();return d("Created issue events",[{id:iw(),userId:o,action:"add.issue",payload:{id:r,parent:t,name:e,rank:n}}])}});import{ulid as za}from"ulid";var _v,Bv=g(()=>{"use strict";xt();Bd();$();$();_t();Yt();w();pe();Bt();O();ee();_v=async(e,t)=>{let n=ge();if(a(n))return l("Unable to resolve user ID");let o=await Ee();if(a(o))return o;let r=o.value;if(!t.inputString)return l(`provide a name for your ${t.modifier}`);let{breadCrumb:s,contextNode:i,selectedIndex:c}=v(),u=p=>{let m=F([p],r);if(a(m))return m;let f=N.getNode(m.value[0].result.id);if(!f)return l("Created node not found");if(!f.parentNodeId)return m;let h=N.getNode(f.parentNodeId);return h?(H.navigate({contextNode:h,selectedIndex:N.getSiblings(f.parentNodeId).findIndex(({id:x})=>x===f.id)}),m):l("Parent node not found")};if(t.modifier==="board"){let{rootNodeId:p}=v(),m=N.getNode(p);if(!m)return l("Workspace not found");let f=Dn(m.id,n.value,r);return a(f)?f:u({id:za(),action:"add.board",payload:{id:za(),name:t.inputString,parent:m.id,rank:f.value},...D(n.value)})}if(t.modifier==="swimlane"){let p=Nt(s,"BOARD");if(a(p))return l("Unable to add swimlane in this context");let m=Dn(p.value.id,n.value,r);return a(m)?m:u({id:za(),action:"add.swimlane",payload:{id:za(),name:t.inputString,parent:p.value.id,rank:m.value},...D(n.value)})}if(t.modifier==="issue"){let p=ve(i.id)[c],m=i.context==="SWIMLANE"?i:i.context==="BOARD"&&p?.context==="SWIMLANE"?p:(()=>{let A=Nt(s,"SWIMLANE");return a(A)?null:A.value})();if(!m)return l("Unable to add issue in this context");let f=Dn(m.id,n.value,r);if(a(f))return f;let h=Ga({name:t.inputString,parent:m.id,rank:f.value,user:n.value});if(a(h))return h;let x=h.value,E=F([...x],r);if(a(E))return E;if(!E.value[0])return l("Issue creation failed");let R=x.find(A=>A.action==="add.issue")?.payload.id;return R?(H.navigate({contextNode:m,selectedIndex:N.getSiblings(m.id).findIndex(({id:A})=>A===R)}),d("Issue created",null)):l("Unable to determine ticket id")}return d("Success",null)}});import oi from"node:fs";import lw from"node:path";import{z as qo}from"zod";var ri,cw,dw,uw,$v,mw,jv,Uv,Hv,$d=g(()=>{"use strict";w();Jt();he();fd();ee();ri="command-history.json",cw=20,dw=qo.object({projectId:qo.string().min(1),commands:qo.array(qo.string()),lastUsedAt:qo.number().finite()}),uw=qo.object({projects:qo.array(dw)}),$v=()=>{let e=Js();return a(e)?e:d("Resolved command history path",lw.join(e.value,ri))},mw=()=>{try{let e=we(process.cwd());return a(e)?null:e.value}catch{return null}},jv=e=>{if(!oi.existsSync(e))return d("No command history recorded",{state:"read",projects:[]});let t;try{t=oi.readFileSync(e,"utf8")}catch(r){return l(`Unable to read ${ri}: ${r instanceof Error?r.message:String(r)}`)}let n;try{n=JSON.parse(t)}catch(r){return d("Unparsable command history",{state:"corrupt",reason:`Invalid ${ri}: ${r instanceof Error?r.message:String(r)}`})}let o=uw.safeParse(n);return o.success?d("Read command history",{state:"read",projects:o.data.projects}):d("Command history in an unknown shape",{state:"corrupt",reason:`Invalid ${ri} shape: ${o.error.issues.map(r=>r.path.join(".")||r.message).join(", ")}`})},Uv=({root:e})=>{let t=un(e);if(a(t))return l(t.message);let n=$v();if(a(n))return n;let o=jv(n.value);if(a(o))return o;let r=o.value;if(r.state==="corrupt")return l(r.reason);let s=r.projects.find(i=>i.projectId===t.value);return d("Read command history",s?.commands.slice(0,Hs)??[])},Hv=({commands:e,root:t=mw(),now:n=Date.now()})=>{if(t===null)return d("No project; command history not stored",null);let o=un(t);if(a(o))return l(o.message);let r=$v();if(a(r))return r;let s=r.value,i=jv(s);if(a(i))return i;let c=i.value,u=c.state==="read"?c.projects:[],p=[{projectId:o.value,commands:e.slice(0,Hs),lastUsedAt:n},...u.filter(f=>f.projectId!==o.value)].sort((f,h)=>h.lastUsedAt-f.lastUsedAt).slice(0,cw),m=`${s}.${process.pid}.tmp`;try{oi.writeFileSync(m,JSON.stringify({projects:p},null,2)+`
105
- `,"utf8"),oi.renameSync(m,s)}catch(f){try{oi.rmSync(m,{force:!0})}catch{}return l(`Unable to write ${ri}: ${f instanceof Error?f.message:String(f)}`)}return d("Stored command history",null)}});var pw,Wv,fw,qv,gw,Gv,zv=g(()=>{"use strict";Cn();rt();Ke();Ms();ia();bc();ra();$d();ur();Po();$();w();Jt();he();O();Cs();ee();Qi();pw=e=>e.some(t=>t.action==="init.workspace"),Wv=async(e,t)=>{let n=vt(e);return a(n)?l(n.message):fs({cwd:t,branch:n.value})},fw=e=>{let t=we(process.cwd());if(a(t))return!1;let n=Ie({repoRoot:t.value});return!a(n)&&n.value===e},qv=async e=>{let t=Ie({repoRoot:e});if(a(t))return ar(3,t.message);let n=t.value,o=await to({repoRoot:e,stateBranchRoot:n,stateBranchName:Si().stateBranch});if(a(o))return ar(3,o.message);let r=nn(n);if(a(r))return ar(3,r.message);if(!pw(r.value.events)){let m=await Wv(e,n);if(a(m)&&logger.info(3,m.message),r=nn(n),a(r))return ar(3,r.message)}let{events:s,unreadable:i}=r.value,c=gn(s,i);if(a(c))return ar(4,c.message);T({hasProjectDefinition:!0,hasInitializingEvents:!!s.length});let u=Os({root:e});a(u)&&logger.info(u.message);let p=Uv({root:e});return a(p)&&logger.info(p.message),Kg(a(p)?[]:p.value),d("Loaded project",void 0)},gw=async e=>{let t=Ie({repoRoot:e});if(a(t))return l(t.message);let n=t.value,o=await kn({repoRoot:n});if(a(o))return l(o.message);if(!o.value)return d("No remote to pull",void 0);let r=await na({worktreeRoot:n,operation:"boot pull",fn:()=>Ic(n,()=>(ir("Pulling"),Wv(e,n)))});if(a(r))return $e(r.message);if(r.value===null)return d("Another process holds the state worktree",void 0);let s=r.value;if(a(s))return ps(s.message)?(Ji("Offline"),d("Offline",void 0)):$e(s.message);if(!s.value)return Do("Already synced"),d("Already synced",void 0);if(!fw(n))return d("Project changed during the pull",void 0);let i=Ec(n);return a(i)?i:(Do("Pulled"),d("Pulled and reloaded",void 0))},Gv=e=>{gw(e).then(t=>{a(t)&&logger.info(3,t.message)}).catch(t=>{logger.error(`[boot] pull failed: ${Sf(t)}`)})}});import hw from"node:os";import Vv from"node:path";var vw,yw,Kv,Yv=g(()=>{"use strict";zv();ur();w();he();O();ee();vw=e=>e==="~"||e.startsWith("~/")?Vv.join(hw.homedir(),e.slice(1)):e,yw=(e,t)=>{let n=e.trim();if(!n)return l("Provide a number from the list or a path to a project");if(/^\d+$/.test(n)){let r=t[Number(n)-1];return r?d("Resolved recent project",r.root):l(`No recent project #${n}`)}let o=we(Vv.resolve(vw(n)));return a(o)?l(`No epiq project at ${n}`):d("Resolved project path",o.value)},Kv=async()=>{let e=Ia();if(ne(""),v().hasProjectDefinition)return l("Already in a project; run epiq from another directory");let t=ca({exclude:process.cwd()}),n=a(t)?[]:t.value,o=yw(e,n);if(a(o))return l(o.message);let r=o.value,s=process.cwd();try{process.chdir(r)}catch(c){return l(`Unable to enter ${r}: ${c instanceof Error?c.message:String(c)}`)}let i=await qv(r);return a(i)?(process.chdir(s),l(i.message)):(Gv(r),d(`Opened ${Xf(r)}`,null))}});var Va,jd=g(()=>{"use strict";xt();$();$();w();O();Va=({boardId:e,targetTime:t,stateBranchRoot:n,selectedIndex:o})=>{let r=v(),s=ac(n,t);if(a(s))return l(s.message);let{appliedEvents:i,unappliedEvents:c}=s.value,u=Wn();if(a(u))return u;let p=Pn(i),{fatal:m,skipped:f}=Xn(p);if(m.length>0)return Wn(),T(r),l(m.map(x=>x.message).join(", "));Jn(f);let h=v().nodes[e];return h?(H.navigate({contextNode:h,selectedIndex:o}),d("",{unappliedEvents:c})):(Wn(),T(r),l("Board did not exist at that date"))}});var Xv,Jv=g(()=>{"use strict";Xv=e=>{let t=[],n=0;for(let r=0;r<e.length;r++){let s=r===0?0:Math.max(0,e[r]-e[r-1]);n+=Math.sqrt(s),t[r]=n}let o=n;return t.map((r,s)=>o>0?r/o:(s+1)/e.length)}});var bw,xw,Iw,Ka,Ya,Go,Qv,Zv,Ud=g(()=>{"use strict";ft();si();$();sc();Oe();w();Jv();O();bw=20,xw=16,Iw=150,Ka=null,Ya=null,Go=()=>{Ka!==null&&(clearInterval(Ka),Ka=null),Ya!==null&&(clearTimeout(Ya),Ya=null)},Qv=()=>{Go(),T({mode:b.DEFAULT,readOnly:!1,readOnlyReason:void 0,timeMode:"live",unappliedEvents:[],replay:null,selectedIndex:0})},Zv=({events:e,startTime:t,durationMs:n})=>{Go();let o=e.length,r=os(e.map(f=>yo(f))).map(f=>f??t),s=r[o-1]??Date.now(),i=Xv(r),c=Math.max(1,Math.round(n*bw/1e3)),u=Math.max(Math.round(n/c),xw),p=0,m=0;T({mode:b.DEFAULT,readOnly:!0,timeMode:"replay",unappliedEvents:e,replay:{progress:0,appliedCount:0,totalCount:o,currentTime:t,startTime:t,endTime:s,currentLabel:"",flashNodeIds:[]}}),Ka=setInterval(()=>{p++;let f=p/c,h=[],x,E;for(;m<o&&i[m]<=f;){let C=e[m],R=Ss(C);if(a(R)){if(rr(R)){m++;continue}Qv();return}h.push(...rc(C)),x=C,E=r[m],m++}if(m>=o||p>=c){for(;m<o;m++){let R=Ss(e[m]);if(a(R)&&!rr(R))break}let C=v().replay;T({unappliedEvents:[],replay:C&&{...C,progress:1,appliedCount:o}}),Go(),Ya=setTimeout(Qv,Iw);return}let S=v().replay;T({unappliedEvents:e.slice(m),replay:{progress:Math.min(1,f),appliedCount:m,totalCount:o,startTime:t,endTime:s,currentTime:x?E??S?.currentTime??t:S?.currentTime??t,currentLabel:x?Hd(x):S?.currentLabel??"",flashNodeIds:x?[...new Set(h)]:S?.flashNodeIds??[]}})},u)}});var ey,ty=g(()=>{"use strict";rt();ft();$();$();Oe();Yt();w();he();O();Bs();jd();Ud();ey=async()=>{let e=Nt(v().breadCrumb,"BOARD");if(a(e))return e;let t=await kt(process.cwd());if(a(t))return l("Unable to locate repo root");let n=Ie({repoRoot:t.value});if(a(n))return n;let{modifier:o,inputString:r}=fe().commandMeta;if(Go(),o==="now"){let c=Mo(n.value);if(a(c))return l(c.message);let u=Wn();if(a(u))return u;let p=Pn(c.value),{fatal:m,skipped:f}=Xn(p);return m.length>0?l(m.map(h=>h.message).join(", ")):(Jn(f),T({mode:b.DEFAULT,readOnly:!1,readOnlyReason:void 0,timeMode:"live",unappliedEvents:[],replay:null}),d("Peeking now",!0))}let s;if(o==="prev"||o==="next"){let c=lc(n.value);if(a(c))return c;let u=o==="prev"?v().eventLog.at(-1):v().unappliedEvents.at(0),p=u===void 0?null:yo(u),m=(u===void 0?null:c.value.get(u.id)??null)??(p===null?null:ns(p));if(m===null)return l(o==="prev"?"No previous event to peek":"No next event to peek");s=o==="prev"?m:m+1}else{let c=_o(o||r.trim());if(!c)return l("Invalid peek date");s=c.getTime()}let i=Va({boardId:e.value.id,targetTime:s,stateBranchRoot:n.value,selectedIndex:0});return a(i)?i:(T({mode:b.DEFAULT,readOnly:!0,timeMode:"peek",unappliedEvents:i.value.unappliedEvents,replay:null}),d("Peeking",!0))}});var ny,oy=g(()=>{"use strict";rt();Yt();w();he();O();Bs();jd();Ud();ny=async()=>{let e=Nt(v().breadCrumb,"BOARD");if(a(e))return e;let t=await kt(process.cwd());if(a(t))return l("Unable to locate repo root");let n=Ie({repoRoot:t.value});if(a(n))return n;let{modifier:o,inputString:r}=fe().commandMeta,{dateInput:s,durationInput:i}=pa(o,r);if(Go(),v().syncStatus.status==="syncing")return l("Cannot replay while syncing, try again in a moment");let c=_o(s);if(!c)return l("Invalid replay date");let u=i?ma(i):15e3;if(u===null)return l("Invalid replay duration (try e.g. 30s or 2m)");let p=c.getTime(),m=v(),f=Va({boardId:e.value.id,targetTime:p,stateBranchRoot:n.value,selectedIndex:-1});if(a(f))return f;let{unappliedEvents:h}=f.value;return h.length===0?(Wn(),T(m),d("Nothing to replay from that point",!0)):(Zv({events:h,startTime:p,durationMs:u}),d("Replaying board history",!0))}});import{spawn as Rw}from"node:child_process";var Sw,ry,sy=g(()=>{"use strict";w();Sw=()=>{switch(process.platform){case"darwin":return{command:"pbcopy",args:[]};case"win32":return{command:"clip",args:[]};default:return process.env.WAYLAND_DISPLAY?{command:"wl-copy",args:[]}:{command:"xclip",args:["-selection","clipboard"]}}},ry=async e=>new Promise(t=>{let{command:n,args:o}=Sw();try{let r=Rw(n,o,{stdio:["pipe","ignore","ignore"]});r.on("error",()=>t(l(`Clipboard tool not available (${n})`))),r.on("close",s=>t(s===0?d("Copied to clipboard",null):l(`Clipboard tool failed (${n})`))),r.stdin.on("error",()=>{}),r.stdin.write(e),r.stdin.end()}catch{t(l(`Clipboard tool not available (${n})`))}})});var ii,iy,ay=g(()=>{"use strict";w();O();sy();mt();pr();_n();ii=async(e,t)=>{if(!e.trim())return l(`Nothing to copy: ${t} is empty`);let n=await ry(e);return a(n)?n:d(`Copied ${t} to clipboard`,null)},iy=async e=>{let{breadCrumb:t,selectedNode:n}=v(),o=$s({breadCrumb:t,selectedNode:n}),r=o??n;if(!r)return l("Nothing selected to copy from");switch(e.modifier){case He.REF:return ii(V(r.id),"ref");case He.TITLE:return ii(r.title,"title");case He.DESCRIPTION:return o?ii(o.props?.description??"","description"):l("No issue in scope");case He.TAGS:{if(!o)return l("No issue in scope");let s=yn(o).map(({name:i})=>i);return ii(s.join(", "),"tags")}case He.ASSIGNEES:{if(!o)return l("No issue in scope");let s=bn(o).map(({name:i})=>i);return ii(s.join(", "),"assignees")}default:return l("Yank one of: ref, title, description, tags, assignees")}}});var ly,cy=g(()=>{"use strict";ia();Oe();w();he();O();ly=async()=>{ne(""),T({mode:b.DEFAULT});let e=Me();if(a(e))return l(e.message);if(e.value.syncStatus.status==="syncing")return l("Sync already in progress");T({syncStatus:{msg:"Syncing",status:"syncing"}});let t=await sa();return a(t)?(T({syncStatus:{msg:t.message,status:"failed"}}),t):(T({mode:b.DEFAULT,syncStatus:{msg:"Synced",status:"synced"}}),t)}});import{ulid as dy}from"ulid";var uy,my=g(()=>{"use strict";$();$();me();w();O();Aa();ee();_t();uy=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),o=ve(t.id)[n];if(!o)return l("Unable to resolve child to delete");let r=await Ee();if(a(r))return r;if(o.context==="COMMENT"){let s=o.id,i=U(t)?t.id:t.parentNodeId;if(!i)return l("Unable to resolve comment issue");let c=v().nodes[i];if(!c||!U(c))return l("Unable to resolve comment issue");let u=c.log?.filter(ph).find(p=>p.payload.id===s);return u?u.payload.author!==e.value.userId?l("You can only delete your own comments"):F([{id:dy(),action:"delete.issue.comment",payload:{id:s,issue:i},...D(e.value)}],r.value):l("Unable to resolve comment")}return F([{id:dy(),action:"delete.node",payload:{id:o.id},...D(e.value)}],r.value)}});import{ulid as Nw}from"ulid";var py,fy=g(()=>{"use strict";$();$();tn();me();w();Bt();O();ee();Ft();py=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),o=ve(t.id)[n];if(!o)return l("Unable to close issue, no target found");if(!U(o))return l("Cannot close in this context");let r=v().nodes[Ae];if(!r)return l("Unable to locate closed swimlane");if(o.parentNodeId===r.id)return l("Issue is already closed");let s=await Ee();if(a(s))return s;let i=s.value,c=pn(r.id,o.id,{at:"end"},e.value,i);if(a(c))return c;let u=F([{id:Nw(),action:"close.issue",payload:{id:o.id,parent:r.id,rank:c.value},...D(e.value)}],i);return a(u)?u:d("Issue closed",null)}});var Xa,Wd=g(()=>{"use strict";Xa=e=>{let t=e.log??[];for(let n=t.length-1;n>=0;n--){let o=t[n];if(o&&o.action==="close.issue"&&o.payload.id===e.id){for(let r=n-1;r>=0;r--){let s=t[r];if(s&&"id"in s.payload&&s.payload.id===e.id&&"parent"in s.payload&&s.payload.parent)return s.payload.parent}return null}}return null}});import{ulid as ww}from"ulid";var gy,hy=g(()=>{"use strict";$();$();Wd();tn();me();w();pe();Bt();O();ee();Ft();gy=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),o=ve(t.id)[n];if(!o)return l("Unable to reopen issue, no target found");let r=o.context==="TICKET"?d("Resolved ticket",o):Gt(o.id,"TICKET");if(a(r))return l("Cannot reopen in this context");let s=r.value,i=v().nodes[Ae];if(!i)return l("Unable to locate closed swimlane");if(s.parentNodeId!==i.id)return l("Issue is not closed");if(!U(s))return l("Target node is not issue");let c=Xa(s);if(!c)return l("Unable to resolve previous parent from issue history");if(c===i.id)return l("Previous parent resolves to closed swimlane");let u=v().nodes[c];if(!u)return l("Previous parent no longer exists");let p=await Ee();if(a(p))return p;let m=p.value,f=pn(u.id,s.id,{at:"end"},e.value,m);if(a(f))return f;let h=F([{id:ww(),action:"reopen.issue",payload:{id:s.id,parent:u.id,rank:f.value},...D(e.value)}],m);return a(h)?h:d("Issue reopened",null)}});import{ulid as Cw}from"ulid";var vy,yy=g(()=>{"use strict";$();$();w();he();O();ee();Ft();vy=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),o=ve(t.id)[n];if(!o)return l("Missing node");if(o.readonly)return l("Cannot rename readonly node");let r=Ia();if(!r)return l("Provide a title");let s=await Ee();return a(s)?s:F([{id:Cw(),action:"edit.title",payload:{id:o.id,name:r},...D(e.value)}],s.value)}});import{ulid as Aw}from"ulid";var by,xy=g(()=>{"use strict";pe();$();$();me();w();he();O();ee();Ft();by=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let{modifier:t,inputString:n}=fe().commandMeta,o=(t||n).trim();if(!o)return l("Provide a tag");let r=N.findTagByName(o);if(!r)return l(`Tag "${o}" does not exist`);let{selectedNode:s}=v();if(!s)return l("Invalid untag target");let i=Gt(s.id,"TICKET");if(a(i))return l("Unable to untag issue in this context");let c=i.value;if(!U(c))return l("Target node is not issue");if(!(c.props.tags??[]).includes(r.id))return l("Issue is not tagged with that tag");let p=await Ee();return a(p)?p:F([{id:Aw(),action:"remove.issue.tag",payload:{id:c.id,tag:r.id},...D(e.value)}],p.value)}});import{ulid as qd}from"ulid";var Iy,Ey=g(()=>{"use strict";pe();$();$();me();w();he();O();ee();Ft();Iy=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let{modifier:t,inputString:n}=fe().commandMeta,o=(t||n).trim();if(!o)return l("Provide a tag");let{selectedNode:r}=v();if(!r)return l("Invalid tag target");let s=Gt(r.id,"TICKET");if(a(s))return l("Unable to tag issue in this context");let i=s.value;if(!U(i))return l("Target node is not issue");let c=await Ee();if(a(c))return c;let u=N.findTagByName(o),p=u?.id??qd();return(i.props.tags??[]).includes(p)?l("Already tagged with that tag"):F([...u?[]:[{id:qd(),action:"create.tag",payload:{id:p,name:o},...D(e.value)}],{id:qd(),action:"add.issue.tag",payload:{id:i.id,tag:p},...D(e.value)}],c.value)}});var ai,Ry,Ja=g(()=>{"use strict";wt();Nn();ai=({events:e,registry:t,logFileNames:n})=>{let o=new Map(n),r=new Set;for(let s of e)s.userId&&(o.has(s.userId)||o.set(s.userId,""),r.add(s.userId));for(let s of Object.values(t))o.set(s.id,s.name);return[...o.entries()].map(([s,i])=>({id:s,name:i,isExternal:!r.has(s)}))},Ry=({authorName:e,authorEmail:t,owners:n,registry:o})=>{let r=Ve(t),s=n.get(r),i=s?o[s]:void 0;return s?{...gt(s,i?.name),resolved:!0}:{...gt(r||e,e),resolved:!1}}});var Qa,Gd=g(()=>{"use strict";$();Ja();O();Qa=e=>{let{eventLog:t=[],contributors:n}=v();return ai({events:t,registry:n,logFileNames:ko(e)})}});import{ulid as zd}from"ulid";var Sy,Ny=g(()=>{"use strict";$();$();me();w();pe();he();O();Gd();ee();Ft();Sy=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let{modifier:t,inputString:n}=fe().commandMeta,o=(t||n).trim();if(!o)return l("Provide an assignee");let r=o.startsWith("!"),s=(r?o.slice(1):o).trim();if(!s)return l("Provide an assignee");let{selectedIndex:i,contextNode:c}=v(),u=ve(c.id)[i];if(!u)return l("Invalid assign target");let p=Gt(u.id,"TICKET");if(a(p))return l("Unable to assign issue in this context");let m=p.value;if(!U(m))return l("Target node is not issue");let f=await Ee();if(a(f))return f;let h=Qa(f.value),x=!r&&s.toLowerCase()==="me",E,S;if(x)E=e.value.userId,S=h.find(A=>A.id===E)?.name??e.value.userName;else{let A=h.filter(_=>_.name===s);if(A.length>1)return l(`"${s}" matches ${A.length} contributors (${A.map(_=>_.id).join(", ")}). Assign from the GUI to choose by id.`);let L=A[0];if(!L&&!r)return l(`No contributor named "${s}". Use "!${s}" to add them as an external assignee.`);E=L?.id??zd(),S=L?.name??s}if((m.props.assignees??[]).includes(E))return l("Assignee already assigned");let R=!!v().contributors[E];return F([...R?[]:[{id:zd(),action:"create.contributor",payload:{id:E,name:S},...D(e.value)}],{id:zd(),action:"add.issue.assignee",payload:{id:m.id,assignee:E},...D(e.value)}],f.value)}});import{ulid as Tw}from"ulid";var wy,Cy=g(()=>{"use strict";$();$();me();w();pe();he();O();Gd();ee();Ft();wy=async()=>{let e=ge();if(a(e))return l("Unable to resolve user ID");let{modifier:t,inputString:n}=fe().commandMeta,o=(t||n).trim();if(!o)return l("Provide an assignee to remove");let{selectedNode:r}=v();if(!r)return l("Invalid unassign target");let s=Gt(r.id,"TICKET");if(a(s))return l("Unable to unassign in this context");let i=s.value;if(!U(i))return l("Target node is not issue");let c=i.props.assignees??[],u=o.toLowerCase()==="me",p=await Ee();if(a(p))return p;let m=u?c.filter(h=>h===e.value.userId):Qa(p.value).filter(h=>h.name===o&&c.includes(h.id)).map(h=>h.id);if(m.length>1)return l(`"${o}" matches ${m.length} assignees (${m.join(", ")}). Unassign from the GUI to choose by id.`);let f=m[0];return f?F([{id:Tw(),action:"remove.issue.assignee",payload:{id:i.id,assignee:f},...D(e.value)}],p.value):l(u?"Issue is not assigned to you":`Issue is not assigned to "${o}"`)}});import{ulid as Ay}from"ulid";var kw,Ty,ky=g(()=>{"use strict";$();$();Yt();me();w();pe();O();$n();ee();Ft();Pa();ja();Ta();kw=e=>{let t=e.trim(),n=co(),o=n?Hh(t):null;if(!n||!o)return{ok:!0,md:t,anchored:!1};let r=$a();if(!r||r.sha!==n)return{ok:!1,reason:"No diff is open"};let s=Wh(r.rows,Math.max(0,v().selectedIndex));if(!s)return{ok:!1,reason:"That line is not in a file"};let i=qh(r.rows,s,o.start,o.end);return i.ok?{ok:!0,anchored:!0,md:Sh({filePath:i.value.filePath,start:i.value.start,end:i.value.end,side:"additions",endSide:"additions",note:o.note,sha:n,snippet:i.value.snippet})}:{ok:!1,reason:i.reason}},Ty=async e=>{let t=kw(e.inputString);if(!t.ok)return l(t.reason);let{md:n,anchored:o}=t;if(!n)return l("Provide a comment");if(n.length>4e3)return l(o?`The note and the ${n.length} characters of quoted lines exceed ${4e3}; comment on fewer lines`:`Cannot exceed ${4e3} characters`);let r=ge();if(a(r))return l("Unable to resolve user ID");let{breadCrumb:s,selectedNode:i}=v(),c=Nt([...s,i],"TICKET");if(a(c))return l("Edit target must be an issue");let u=c.value;if(!u)return l("Invalid comment target");let p=u.context==="TICKET"?d("Resolved ticket",u):Gt(u.id,"TICKET");if(a(p))return l("Unable to comment on issue in this context");let m=p.value;if(!U(m))return l("Target node is not issue");let f=await Ee();if(a(f))return f;let h=await F([{id:Ay(),action:"add.issue.comment",payload:{id:Ay(),issue:m.id,author:r.value.userId,md:n},...D(r.value)}],f.value);return o&&!a(h)&&Ho(null),h}});import Mw from"zod";var My,Ly=g(()=>{"use strict";rn();w();he();Fe();My=()=>{let e=fe().commandMeta.inputString,t=Mw.coerce.number().int().min(3e3).safeParse(e);if(!t.success)return l("Auto sync duration must be a number of at least 3000 ms");let n=it({autoSyncDebounceMs:t.data});return a(n)?n:(Qe({autoSyncIntervalMs:t.data}),d(`Auto sync interval set to ${t.data}ms`,null))}});var Py,Dy=g(()=>{"use strict";Oo();rn();w();he();Fe();Py=()=>{let e=fe().commandMeta.inputString.trim();if(e!=="on"&&e!=="off")return l("Invalid response");let t=ag(e),n=it({autoSync:t});return a(n)?n:(Qe({autoSync:t}),d(`Auto sync set to "${e}"`,null))}});var Vd,Oy,Fy,Lw,Pw,Za,el,Kd=g(()=>{"use strict";Ke();wt();w();Vd=e=>e.toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>=2),Oy="",Fy=new Map,Lw=15e3,Pw=async(e,t)=>{let n=`${e} ${t??""}`,o=Fy.get(n);if(o&&Date.now()-o.at<Lw)return d("Cached author scan",o.authors);let r=await Le({cwd:e,args:["log","--branches",...t?["--not",t]:[],`--format=%an${Oy}%ae`]});if(r.exitCode!==0)return l(`Could not read this repository's history: ${(r.stderr??"").trim()||`git exited ${r.exitCode}`}`);let s=new Map;for(let i of(r.stdout??"").split(`
106
- `)){let c=i.lastIndexOf(Oy);if(c===-1)continue;let u=i.slice(0,c),p=Ve(i.slice(c+1));if(!Gn(p))continue;let m=s.get(p)??{names:new Set,commits:0};u&&m.names.add(u),m.commits+=1,s.set(p,m)}return Fy.set(n,{at:Date.now(),authors:s}),d("Scanned repository authors",s)},Za=async({repoRoot:e,stateBranch:t,names:n,links:o})=>{let r=await Pw(e,t);if(a(r))return l(r.message);let s=r.value,i=new Map;for(let u of Object.values(o)){if(u.tombstoned)continue;let p=i.get(u.email)??new Set;p.add(u.contributor),i.set(u.email,p)}let c=new Set(n.flatMap(u=>Vd(u??"")));return d("Found candidates",[...s.entries()].map(([u,p])=>({email:u,names:[...p.names],commits:p.commits,looksLikeYours:[...p.names].some(m=>Vd(m).some(f=>c.has(f)))||Vd(u.split("@")[0]??"").some(m=>c.has(m)),claimedBy:[...i.get(u)??[]]})).sort((u,p)=>u.looksLikeYours===p.looksLikeYours?p.commits-u.commits:Number(p.looksLikeYours)-Number(u.looksLikeYours)))},el=e=>e.filter(t=>t.claimedBy.length===0)});import{ulid as Dw}from"ulid";var _y,By,$y=g(()=>{"use strict";$();Cn();rt();wt();w();Oe();Kd();he();Fs();Fe();O();rn();Oo();ee();_y=()=>{let e=Ac();if(!e)return d("Nothing here to decline",null);let t=no(),n=a(t)?[]:t.value.declinedEmailBoards??[],o=[...new Set([...n,e])],r=it({declinedEmailBoards:o});return a(r)?l(r.message):(Qe({declinedEmailBoards:[...new Set([...le().declinedEmailBoards??[],e])]}),d("Declined",null))},By=async()=>{let e=fe().commandMeta.inputString.trim();if(e==="none"){let C=_y();return a(C)?C:d("Left unlinked. Your commits will show the name git signed them with. Run :config emails again to change that.",null)}let{userId:t,userName:n,gitName:o}=le();if(!t)return l("Set a username first with :config username");let r=Me();if(a(r))return l("Board is not loaded");let s=we(process.cwd());if(a(s))return l(s.message);let i=vt(s.value),c=await Za({repoRoot:s.value,stateBranch:a(i)?void 0:i.value,names:[n,o],links:r.value.emailLinks});if(a(c))return c;let p=el(c.value);if(og(p.map(C=>C.email)),p.length===0){if(!sg()){let C=_y();if(a(C))return C}return d("No unclaimed addresses in this history.",null)}if(!e)return T({mode:b.IDENTITY}),d("Opened identity",null);let m=e.split(/[,\s]+/).filter(Boolean),f=[],h=[];for(let C of m){let R=p.find(A=>A.email===Ve(C));if(!R){h.push(C);continue}f.includes(R)||f.push(R)}if(h.length>0)return l(`Not on the list: ${h.join(", ")}. Pick one of ${p.map(C=>C.email).join(", ")}.`);let x=Ie({repoRoot:s.value});if(a(x))return x;let E=f.map(C=>({id:Dw(),action:"link.contributor.email",payload:{contributor:t,email:C.email},userId:t})),S=F(E,x.value);return a(S)?l(S.message):d(`Claimed ${f.map(C=>C.email).join(", ")}. Every commit by ${f.length===1?"that address":"those addresses"} is now yours.`,null)}});import{ulid as Ow}from"ulid";var jy,Uy=g(()=>{"use strict";$();rt();wt();w();he();Fe();O();ee();jy=()=>{let e=fe().commandMeta.inputString.trim(),{userId:t}=le();if(!t)return l("Set a username first with :config username");let n=Me();if(a(n))return l("Board is not loaded");let o=zn(n.value.emailLinks,t);if(o.length===0)return l("You have not claimed any addresses.");if(!e)return l(`Which one? ${o.join(", ")}.`);let r=o.find(u=>u===Ve(e));if(!r)return l(`You have not claimed ${e}. Yours: ${o.join(", ")}.`);let s=we(process.cwd());if(a(s))return s;let i=Ie({repoRoot:s.value});if(a(i))return i;let c=F([{id:Ow(),action:"unlink.contributor.email",payload:{contributor:t,email:r},userId:t}],i.value);return a(c)?l(c.message):d(`Unclaimed ${r}`,null)}});var Hy,Wy=g(()=>{"use strict";rn();w();he();Fe();Hy=()=>{let e=fe().commandMeta.inputString.trim();if(!["debug","error","info"].includes(e))return l("Invalid response");let n=it({logLevel:e});return a(n)?n:(Qe({logLevel:e}),d(`Auto sync set to "${e}"`,null))}});import{ulid as Fw}from"ulid";var qy,Gy=g(()=>{"use strict";vo();rn();w();Fe();_n();Ly();jc();Dy();$y();Uy();Wy();qy=e=>{let t=e.inputString.trim();switch(e.modifier){case be.USERNAME:{if(process.env[Ot])return l(`Cannot change the configured user while ${Ot} names this process`);let n=no();if(a(n))return n;let{userId:o,preferredEditor:r,userName:s}=n.value,i=t||s,c=o||Fw();if(!i||!c)return l("Unable to resolve user name or id");let u=it({userName:i,userId:c,preferredEditor:r??""});return a(u)?u:(Qe({userName:i,userId:c}),d(`Username set to "${i}"`,null))}case be.EDITOR:{if(!t)return l("No editor provided");let n=it({preferredEditor:t});return a(n)?n:(Qe({preferredEditor:t}),d(`Editor configuration set to "${t}"`,null))}case be.VIEW:{if(t!=="wide"&&t!=="dense")return l("Invalid view mode");let n=it({viewMode:t});return a(n)?n:(Qe({viewMode:t}),d(`View set to "${t}"`,null))}case be.EMAILS:return By();case be.EMAILS_UNCLAIM:return jy();case be.AUTOSYNC:return Py();case be.LOG_LEVEL:return Hy();case be.SYNC_DEBOUNCE_MS:return My();case be.ATTACHMENT_MAX_KB:return wg();default:return l("Unknown config command")}}});var Yd,zy=g(()=>{"use strict";Oo();Oe();he();O();Yd=()=>{let e=lg(),t=v().mode;if(!(t!==b.COMMAND_LINE&&t!==b.DEFAULT)){if(!e){T({mode:b.DEFAULT});return}T({mode:b.COMMAND_LINE}),ne(e)}}});var Vy,Ky=g(()=>{"use strict";Rv();xt();Oe();w();he();O();Wa();Fo();zc();_n();Nv();Tv();Fv();Bv();Yv();ty();oy();ay();cy();my();fy();hy();yy();xy();Ey();Ny();Cy();ky();Gy();zy();Vy=[{systemOnly:!0,intent:G.Move,description:"Internal move-state command",mode:b.COMMAND_LINE,action:Ov},{intent:G.Delete,description:"Delete the currently selected node",mode:b.COMMAND_LINE,action:uy,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.Filter,description:"Filter the board, for example `:filter tag urgent`",mode:b.COMMAND_LINE,action:()=>{let{modifier:e,inputString:t}=fe().commandMeta,n=/(!=|=)/,[o]=e.split(n);if(!o||!(i=>We(I.FILTER).map(c=>c.split(n)[0]).includes(i))(o))return l("Invalid filter modifier");let s={target:o,operator:"=",value:t.trim()};return Pe(i=>({...i,filters:e==="clear"?[]:[...i.filters,s],mode:b.DEFAULT})),d("Filter updated",null)}},{intent:G.ViewHelp,description:"Open the help screen",mode:b.COMMAND_LINE,action:()=>{let{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:o}=v();return uo({pendingNavTarget:{contextNode:e,breadCrumb:o,selectedIndex:t,selectedNode:n}}),T({mode:b.HELP}),d("Viewing help",null)}},{intent:G.CloseIssue,description:"Move the selected issue to the closed swimlane",mode:b.COMMAND_LINE,action:py,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.ReopenIssue,description:"Move a closed issue back to its previous swimlane",mode:b.COMMAND_LINE,action:gy,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.Init,description:"Initialize Epiq in the current git repository",mode:b.COMMAND_LINE,action:Av,onSuccess:Yd},{intent:G.OpenProject,description:"Open a recently used epiq project, by number or path",mode:b.COMMAND_LINE,action:Kv,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.NewItem,description:"Create a new board, swimlane, or issue",mode:b.COMMAND_LINE,action:_v,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.Rename,description:"Rename the currently selected node",mode:b.COMMAND_LINE,action:vy,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.UntagTicket,description:"Remove a tag from the selected issue",mode:b.COMMAND_LINE,action:by,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.TagTicket,description:"Add or create a tag on the selected issue",mode:b.COMMAND_LINE,action:Iy,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.AssignUserToTicket,description:"Assign a user to the selected issue",mode:b.COMMAND_LINE,action:Sy,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.UnassignUserFromTicket,description:"Remove an assignee from the selected issue",mode:b.COMMAND_LINE,action:wy,onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.Comment,description:"Add a comment to the selected issue",mode:b.COMMAND_LINE,action:async(e,t)=>Ty(t),onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.Sync,description:"Pull, commit, and push Epiq state",mode:b.COMMAND_LINE,action:ly},{intent:G.Peek,description:"View board state at another point in time",mode:b.COMMAND_LINE,action:ey},{intent:G.Replay,description:"Replay board history forward from a point in time",mode:b.COMMAND_LINE,action:ny},{intent:G.Export,description:"Export the current board layout to markdown",mode:b.COMMAND_LINE,action:async()=>{let e=await Ev();return a(e)?e:(T({mode:b.DEFAULT}),d("Export successful",!0))}},{intent:G.Exit,description:"Exit the application",mode:b.COMMAND_LINE,action:async()=>(H.exit(),d("Exit successful",!0))},{intent:G.Edit,description:"Edit title or description",mode:b.COMMAND_LINE,action:async(e,t)=>Sv(t),onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.Yank,description:"Yank (copy) ref, title, description, tags, or assignees to the clipboard",mode:b.COMMAND_LINE,action:async(e,t)=>iy(t),onSuccess:()=>T({mode:b.DEFAULT})},{intent:G.Config,description:"Update editor, username, view, autosync, or sync debounce",mode:b.COMMAND_LINE,action:(e,t)=>qy(t),onSuccess:Yd}]});var _w,zt,Xd=g(()=>{"use strict";aa();va();zc();Ky();$d();w();he();Fe();O();_w=new Set(["peek","replay","filter","view-help","yank"]),zt=async({isForceExecutedBySystem:e=!1}={})=>{let{value:t,commandMeta:{command:n,validity:o,modifier:r,inputString:s}}=fe();if(!n)return l("No command to confirm");if(!e&&o===ro.Invalid)return l("Invalid command");let i=Jg(n);zg();let{readOnly:c}=v();if(c&&!_w.has(i))return Ws({status:Sn.Fail,message:"Command not available in readonly state",value:null});let u=Vy.filter(f=>e||f.systemOnly!==!0).find(f=>f.intent===i);if(!u)return Ws({status:Sn.Fail,message:"Command not found",value:null});let p;try{p=await u.action(u,{command:n,inputString:s,modifier:r})}catch(f){return Ws({status:Sn.Fail,message:f instanceof Error?f.message:"Command failed",value:null})}if(a(p))return Ws(p);let m=!e;if(Vg({addToHistory:m,line:t}),m){let f=Hv({commands:fe().commandHistory});a(f)&&logger.info(f.message)}return u.onSuccess?.(),le().autoSync&&Vf(),p}});var tl,nl,Yy,Xy=g(()=>{"use strict";w();Oe();O();Vn();Xd();_d();he();tl=[{intent:P.Exit,mode:b.MOVE,description:"[<Esc>] exit context / cancel",action:()=>(T({mode:b.COMMAND_LINE}),ne("move cancel"),zt({isForceExecutedBySystem:!0}))},{intent:P.InitMove,mode:b.DEFAULT,description:"[m] move",action:()=>(T({mode:b.COMMAND_LINE}),ne("move start"),zt({isForceExecutedBySystem:!0}))},{intent:P.ConfirmMove,mode:b.MOVE,description:"[m] confirm move",action:()=>(T({mode:b.COMMAND_LINE}),ne("move confirm"),zt({isForceExecutedBySystem:!0}))}],nl=[{intent:P.MovePreviousItem,mode:b.MOVE,action:()=>ln()?(T({mode:b.COMMAND_LINE}),ne("move previous"),zt({isForceExecutedBySystem:!0})):l("No pending move")},{intent:P.MoveNextItem,mode:b.MOVE,description:"[arrows/hjkl] move (shift x5)",action:()=>ln()?(T({mode:b.COMMAND_LINE}),ne("move next"),zt({isForceExecutedBySystem:!0})):l("No pending move")},{intent:P.MovePreviousItemJump,mode:b.MOVE,action:()=>ln()?(T({mode:b.COMMAND_LINE}),ne("move jump-previous"),zt({isForceExecutedBySystem:!0})):l("No pending move")},{intent:P.MoveNextItemJump,mode:b.MOVE,action:()=>ln()?(T({mode:b.COMMAND_LINE}),ne("move jump-next"),zt({isForceExecutedBySystem:!0})):l("No pending move")}],Yy=[{intent:P.MoveToNextContainer,mode:b.MOVE,action:()=>ln()?(T({mode:b.COMMAND_LINE}),ne("move to-next"),zt({isForceExecutedBySystem:!0})):l("No pending move")},{intent:P.MoveToPreviousContainer,mode:b.MOVE,action:()=>ln()?(T({mode:b.COMMAND_LINE}),ne("move to-previous"),zt({isForceExecutedBySystem:!0})):l("No pending move")}]});var Jy,Qy=g(()=>{"use strict";me();Xy();Jy={[se.WORKSPACE]:[...tl,...nl],[se.BOARD]:[...tl,...nl],[se.SWIMLANE]:[...tl,...nl,...Yy],[se.TICKET]:[],[se.FIELD]:[],[se.FIELD_LIST]:[],[se.TEXT]:[],[se.COMMENT]:[]}});import{spawn as Bw}from"node:child_process";function Zy(e){let t=process.platform,r=Bw(t==="darwin"?"open":t==="win32"?"cmd":"xdg-open",t==="win32"?["/c","start","",e]:[e],{detached:!0,stdio:"ignore",shell:!1});return r.unref(),r.on("error",()=>{}),!0}var eb=g(()=>{"use strict"});import $w from"node:fs";import jw from"node:path";var tb,nb=g(()=>{"use strict";rt();vr();w();ee();eb();tb=e=>{let t=we(process.cwd());if(a(t))return l("Unable to resolve project root");let n=Ie({repoRoot:t.value});if(a(n))return l(n.message);let o=hr(e.hash,e.ext),r=jw.join(ki(n.value),o);return $w.existsSync(r)?(Zy(r),d(`Opened ${e.name}`,null)):l("Attachment file not found \u2014 run :sync to fetch it")}});var ob,rb,sb=g(()=>{"use strict";Oe();w();he();O();Wa();Vn();xt();ob=()=>{ne("");let{pendingNavTarget:e}=_r();T({mode:b.DEFAULT}),e&&H.navigate(e),uo({pendingNavTarget:void 0})},rb=[{intent:P.ExitCommandLine,mode:b.HELP,action:()=>(ob(),d("Exiting help",null))},{intent:P.Exit,mode:b.HELP,action:()=>(ob(),d("Closed help",null))},{intent:P.NavPreviousItem,mode:b.HELP,description:"[arrows/hjkl] navigate (shift x5)",action:()=>(H.navigateToPreviousItem(),d("Navigating to previous help item",null))},{intent:P.NavNextItem,mode:b.HELP,action:()=>(H.navigateToNextItem(),d("Navigating to next help item",null))},{intent:P.NavPreviousItemJump,mode:b.HELP,action:()=>(H.jumpToPreviousItem(),d("Jumping to previous help item",null))},{intent:P.NavNextItemJump,mode:b.HELP,action:()=>(H.jumpToNextItem(),d("Jumping to next help item",null))},{intent:P.NavToPreviousContainer,mode:b.HELP,action:()=>(H.navigateToPreviousContainer(),d("Navigating to previous help container",null))},{intent:P.NavToNextContainer,mode:b.HELP,action:()=>(H.navigateToNextContainer(),d("Navigating to next help container",null))}]});var ib,ab,lb=g(()=>{"use strict";Oe();w();he();Fs();O();Vn();ib=()=>{ne(""),T({mode:b.DEFAULT})},ab=[{intent:P.Confirm,mode:b.IDENTITY,description:"[enter] claim the first",action:()=>{let[e]=mr();return e?(T({mode:b.COMMAND_LINE}),ne(`config emails ${e}`),d("Proposed claim",null)):d("Nothing left to claim",null)}},{intent:P.ExitCommandLine,mode:b.IDENTITY,action:()=>(ib(),d("Closed identity",null))},{intent:P.Exit,mode:b.IDENTITY,description:"[esc] close",action:()=>(ib(),d("Closed identity",null))}]});var Uw,cb,db,ub=g(()=>{"use strict";Oe();me();w();he();O();Wa();Vn();xt();Uw=e=>{T({mode:b.COMMAND_LINE});let{pendingNavTarget:t}=_r();t&&H.navigate(t),uo({pendingNavTarget:void 0}),ne(`${e} `)},cb=()=>{ne("");let{pendingNavTarget:e}=_r();e&&H.navigate(e),uo({pendingNavTarget:void 0}),T({mode:b.DEFAULT})},db=[{intent:P.InitCommandPalette,mode:b.DEFAULT,description:"[?] command palette",action:()=>{ne("");let{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:o}=v();return uo({pendingNavTarget:{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:o}}),T({mode:b.PALETTE}),d("Opening command palette",null)}},{intent:P.Confirm,mode:b.PALETTE,action:()=>{let{selectedNode:e}=v();if(!e||!bm(e))return l("Command only applicable on text nodes");if(e.props.disabled)return l("Command is not available in this context");let t=e.title;return t?(Uw(t),d("Selected command",t)):d("No command selected",null)}},{intent:P.ExitCommandLine,mode:b.PALETTE,action:()=>(cb(),d("Exiting palette",null))},{intent:P.Exit,mode:b.PALETTE,action:()=>(cb(),d("Closed command palette",null))},{intent:P.NavPreviousItem,mode:b.PALETTE,description:"[arrows/hjkl] navigate",action:()=>(H.navigateToPreviousItem(),d("Navigating to previous item",null))},{intent:P.NavNextItem,mode:b.PALETTE,action:()=>(H.navigateToNextItem(),d("Navigating to next item",null))},{intent:P.NavToPreviousContainer,mode:b.PALETTE,action:()=>(H.navigateToPreviousContainer(),d("Navigating to previous container",null))},{intent:P.NavToNextContainer,mode:b.PALETTE,action:()=>(H.navigateToNextContainer(),d("Navigating to next container",null))}]});var mb,pb,fb=g(()=>{"use strict";Fo();_n();Qs();Pa();Oe();w();ja();sr();pe();Bt();he();O();nb();Vn();oo();sb();lb();ub();xt();mb=()=>{let e=co();if(!e)return d("Nothing to comment on here",null);let t=$a();if(!t||t.sha!==e)return l("The diff is still loading");let{selectedIndex:n}=v(),o=Math.max(0,n),r=cd(t.rows,Id(e)??o,o);return r.ok?(T({mode:b.COMMAND_LINE}),ne(`${I.COMMENT} ${Uh(r.value.start,r.value.end)} `),d("Commenting on a diff line",null)):l(r.reason)},pb=[{intent:P.InitCommandLine,mode:b.DEFAULT,description:"[:] write command",action:()=>(T({mode:b.COMMAND_LINE}),ne(""),d("Entering command line mode",null))},...rb,...ab,...db,{intent:P.AddItem,mode:b.DEFAULT,description:"[n] new...",action:()=>(T({mode:b.COMMAND_LINE}),ne(`${I.NEW} `),d("Adding new item",null))},{intent:P.Delete,mode:b.DEFAULT,description:"[d] delete",action:()=>(T({mode:b.COMMAND_LINE}),ne(`${I.DELETE} `),d("Deleting item",null))},{intent:P.Confirm,mode:b.DEFAULT,description:"[<Enter>] confirm/enter",action:()=>{let{selectedNode:e,contextNode:t}=v();if(!ke(e?.id??"")?.length){let o=e?N.getAttachment(e.id):void 0;if(o)return tb(o);if(co())return mb();if(e?.title===Ce.DESCRIPTION)return T({mode:b.COMMAND_LINE}),ne(`${I.EDIT} description `),d("Propose command",!0);if(e?.title===Ce.ASSIGNEES)return T({mode:b.COMMAND_LINE}),ne(`${I.ASSIGN} `),d("Propose command",!0);if(e?.title===Ce.TAGS)return T({mode:b.COMMAND_LINE}),ne(`${I.TAG} `),d("Propose command",!0);if(t.title===Ce.DESCRIPTION&&e?.context==="TEXT")return T({mode:b.COMMAND_LINE}),ne(`${I.EDIT} description `),d("Propose command",!0)}return H.enterChildNode(),d("Entering context",null)}},{intent:P.OpenInEditor,mode:b.DEFAULT,action:()=>{let{selectedNode:e,contextNode:t}=v(),n=t.parentNodeId,r=!!n&&t.id===Te(n,"diff")?e?.id:co()??void 0;return r?vd({sha:r}):d("Nothing here opens in an editor",null)}},{intent:P.MarkDiffLine,mode:b.DEFAULT,action:()=>{let e=co();if(!e)return d("Nothing to mark here",null);let{selectedIndex:t}=v(),n=Id(e);return Ho(n===t?null:{sha:e,row:Math.max(0,t)}),d("Marked diff line",null)}},{intent:P.CommentOnDiffLine,mode:b.DEFAULT,action:()=>co()?mb():d("Nothing to comment on here",null)},{intent:P.Yank,mode:b.DEFAULT,description:"[y] yank",action:()=>{let{selectedNode:e}=v(),t=e?.title===Ce.DESCRIPTION?He.DESCRIPTION:e?.title===Ce.TAGS?He.TAGS:e?.title===Ce.ASSIGNEES?He.ASSIGNEES:He.REF,o=We(I.YANK).includes(t)?t:He.REF;return T({mode:b.COMMAND_LINE}),ne(`${I.YANK} ${o}`),d("Propose command",!0)}},{intent:P.EditTitle,mode:b.DEFAULT,description:"[r] rename title",action:()=>(T({mode:b.COMMAND_LINE}),ne(`${I.EDIT} title ${v().selectedNode?.title}`),d("Exiting context",null))},{intent:P.EditDescription,mode:b.DEFAULT,description:"[e] edit desc",action:()=>(T({mode:b.COMMAND_LINE}),ne(`${I.EDIT} description `),d("Exiting context",null))},{intent:P.Exit,mode:b.DEFAULT,description:"[q] exit context",action:()=>(H.enterParentNode(),d("Exiting context",null))},{intent:P.NavPreviousItem,mode:b.DEFAULT,description:"[arrows/hjkl] navigate (shift x5)",action:()=>(H.navigateToPreviousItem(),d("Navigating to previous item",null))},{intent:P.NavNextItem,mode:b.DEFAULT,action:()=>(H.navigateToNextItem(),d("Navigating to next item",null))},{intent:P.NavPreviousItemJump,mode:b.DEFAULT,action:()=>(H.jumpToPreviousItem(),d("Jumping to previous item",null))},{intent:P.NavNextItemJump,mode:b.DEFAULT,action:()=>(H.jumpToNextItem(),d("Jumping to next item",null))},{intent:P.NavToPreviousContainer,mode:b.DEFAULT,action:()=>(H.navigateToPreviousContainer(),d("Navigating to previous container",null))},{intent:P.NavToNextContainer,mode:b.DEFAULT,action:()=>(H.navigateToNextContainer(),d("Navigating to next container",null))}]});var Hw,Ww,gb,hb=g(()=>{"use strict";he();Hw=500,Ww=e=>e.replace(/[\r\n]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,""),gb=e=>{let t=Ww(e);t&&xa(n=>(n+t).slice(0,Hw))}});var qw,Gw,zw,vb,yb=g(()=>{"use strict";hb();Oe();w();he();O();Vn();Xd();qw=[b.COMMAND_LINE,b.PALETTE],Gw=e=>e==="edit title "?v().selectedNode?.title??"":"",zw=e=>[{intent:P.MoveCursorLeft,mode:e,action:()=>(qc(-1),d("Moving cursor left",null))},{intent:P.MoveCursorRight,mode:e,action:()=>(qc(1),d("Moving cursor right",null))},{intent:P.MoveCursorLeftOfWord,mode:e,action:()=>(Gc("left"),d("Moving cursor left of word",null))},{intent:P.MoveCursorRightOfWord,mode:e,action:()=>(Gc("right"),d("Moving cursor right of word",null))},{intent:P.AutoCompleteCommand,mode:e,action:()=>(xa((t,{remainder:n})=>{let o=n?t+n:t;return o+Gw(o)}),d("Auto-completing command",null))},{intent:P.CaptureInput,mode:e,action:(t,{sequence:n})=>(gb(n??""),d("Capturing input",null))},{intent:P.EraseInput,mode:e,action:()=>(qg(),d("Erasing input",null))},{intent:P.EraseInputWord,mode:e,action:()=>(Gg(),d("Erasing input word",null))}],vb=[{intent:P.Confirm,mode:b.COMMAND_LINE,action:()=>(zt(),d("Executing command",null))},{intent:P.ViewHelp,mode:b.DEFAULT,action:()=>(T({mode:b.HELP}),d("Viewing help",null))},...qw.flatMap(zw),{intent:P.ExitCommandLine,mode:b.COMMAND_LINE,action:()=>(T({mode:b.DEFAULT}),d("Exiting command line",null))},{intent:P.GetLastCommandFromHistory,mode:b.COMMAND_LINE,action:()=>(Yg(),d("Getting last command from history",null))},{intent:P.GetNextCommandFromHistory,mode:b.COMMAND_LINE,action:()=>(Xg(),d("Getting next command from history",null))}]});var Vw,bb,xb,Ib=g(()=>{"use strict";Vw=e=>{let t=/^\[(.+?)\]\s*(.+)$/.exec(e);return t?{keys:t[1]??"",label:t[2]??""}:null},bb=({keys:e})=>e.length===1?0:1,xb=(e,t)=>{let n=new Set;for(let o of e)o.mode!==t||!o.description||n.add(o.description);return[...n].map(Vw).filter(o=>o!==null).sort((o,r)=>bb(o)-bb(r))}});function Eb(e,t,n){let o=t[e];if(!o)return l("buildBreadCrumb(): current node not found");let r=[],s=new Set,i=o;for(;i&&!s.has(i.id)&&(r.push(i),s.add(i.id),!(i.id===n||!i.parentNodeId));)i=t[i.parentNodeId];let c=r[r.length-1];return!c||c.id!==n?l("buildBreadCrumb(): node is not connected to root"):(r.reverse(),d("Breadcrumb built",r))}var Rb=g(()=>{"use strict";w()});var Sb,Nb=g(()=>{"use strict";Sb=e=>{let t={};for(let n of e)n.intent&&(t[n.mode]||(t[n.mode]={}),t[n.mode][n.intent]=n);return t}});import{useSyncExternalStore as Kw}from"react";function eu(e){let{contextNodeId:t,mode:n,rootNodeId:o,nodes:r,filters:s}=e;if(!t)return l("derive(): contextNodeId is missing");if(!o)return l("derive(): rootNode is missing");if(!r[o])return l("derive(): unable to find root node");let c=r[t];if(!c)return l("Unable to derive state, contextNode not found");let u=Eb(t,r,o);if(a(u))return logger.error(u.message),u;let p=u.value,{context:m}=c,f=[...pb,...Jy[m]??[],...vb],h=xb(f,n),x=Sb(f),E=Xw(r,s),S=E[t]?.[e.selectedIndex]??null;return d("Derived successfully",{...e,contextNode:c,breadCrumb:p,availableHints:h,availableActions:f,actionIndex:x,selectedNode:S,renderedChildrenIndex:E})}function Rs(e){Jd=e;let t=we(process.cwd()),n=!1;if(!a(t)){let s=At(t.value);if(a(s))return l(s.message);n=!0}let o={readOnly:!1,filters:[],tags:{},contributors:{},emailLinks:{},mode:b.DEFAULT,nodes:{[e.id]:e},rootNodeId:e.id,contextNodeId:e.id,renderedChildrenIndex:{},selectedIndex:-1,syncStatus:{status:"synced",msg:""},eventLog:[],unappliedEvents:[],replay:null,timeMode:"live",hasProjectDefinition:n,hasInitializingEvents:!1,comments:{},attachments:{}},r=eu(o);return a(r)?r:(Rt=r.value,Zd(),d("State initialized",null))}function Pe(e){let t=v(),n=e(t);if(zo)return n.nodes!==t.nodes&&(mo=null),li=n,Rt={...t,...n},d("State updated",null);let o=eu(n);return a(o)?l(o.message??"Unable to update state"):(Rt=o.value,Zd(),d("State updated",null))}function Gi(e){if(zo)return d("Joined batch",e());zo=!0,li=null,mo=new Set;let t=()=>{let n=li;if(zo=!1,li=null,n===null)return null;let o=eu(n);return a(o)?l(o.message??"Unable to update state"):(Rt=o.value,Zd(),d("State updated",null))};try{let n=e(),o=t();return o&&a(o)?l(o.message):d("State updated",n)}finally{zo&&t()}}function Vo(e,t,n){if(!zo)return Pe(i=>({...i,[e]:{...i[e]??{},[t]:n}}));let o=v(),r=o[e]??{};if(e==="nodes"){let i=r[t],c=n;i?.parentNodeId&&mo?.add(i.parentNodeId),c.parentNodeId&&mo?.add(c.parentNodeId)}r[t]=n;let s={...o,[e]:r};return li=s,Rt={...o,...s},d("State updated",null)}var Rt,Jd,Qd,Zd,Yw,v,Me,zo,li,uf,T,Ye,mo,wb,Xw,ve,Wn,jt,O=g(()=>{"use strict";Qy();fb();yb();Ib();Jt();Oe();w();ee();uc();Rb();Nb();wt();Cc();Qd=new Set,Zd=()=>{for(let e of Qd)e()},Yw=e=>(Qd.add(e),()=>Qd.delete(e));v=()=>{if(!Rt)throw new Error("State not initialized. Call initWorkspaceState() first.");return Rt},Me=()=>Rt?d("Retrieved state",Rt):l("State not initialized. Call initWorkspaceState() first.");eg(e=>Rt?zn(Rt.emailLinks,e):[]);zo=!1,li=null;uf=()=>zo,T=e=>Pe(t=>({...t,...e}));Ye=()=>Kw(Yw,v,v),mo=null,wb=null,Xw=(e,t)=>{let n=Rt?.renderedChildrenIndex,o=n!==void 0&&mo!==null&&e===wb&&t.length===0&&Rt?.filters.length===0,r;if(o){r={...n};let s=af(e,mo);for(let i of mo){let c=s[i];c?r[i]=c:delete r[i]}}else r=sf(e,t);return wb=e,mo=new Set,r},ve=e=>v()?.renderedChildrenIndex[e]??[],Wn=()=>Jd?Rs(Jd):l("Cannot reset state: no initial workspace found"),jt=()=>Rt!==void 0});var Gt,Jw,po,N,pe=g(()=>{"use strict";Yt();wt();me();w();O();Bt();Gt=(e,t)=>{let{nodes:n}=v(),o=n[e];if(!o)return l("Node not found");if(o.context===t)return d("Resolved ancestor node",o);let r=new Set([o.id]),s=o.parentNodeId?n[o.parentNodeId]:void 0;for(;s&&!r.has(s.id);){if(s.context===t)return d("Resolved ancestor node",s);r.add(s.id),s=s.parentNodeId?n[s.parentNodeId]:void 0}return l(`No ancestor found for context: ${t}`)},Jw=(e,t)=>{let{nodes:n}=v(),o=new Set,r=n[e];for(;r?.parentNodeId&&!o.has(r.id);){if(r.parentNodeId===t)return!0;o.add(r.id),r=n[r.parentNodeId]}return!1},po=(e,t)=>e?e.readonly?l({move:"Cannot move readonly node",rename:"Cannot rename readonly node",edit:"Cannot edit readonly node",delete:"Cannot delete readonly node"}[t]):null:l("Node not found"),N={linkUserId({contributorId:e,userId:t}){let n=this.getContributor(e);if(!n)return l("Contributor not found");if(n.userId&&n.userId!==t)return l("Contributor is already linked to another user");let o={...n,userId:t},r=Pe(s=>({...s,contributors:{...s.contributors,[e]:o}}));return a(r)?l("Unable to link contributor to user"):d("Linked contributor to user",o)},deleteNode(e){N.deleteNodes([e])},deleteNodes(e){e.length!==0&&Pe(t=>{let n={...t.nodes};for(let o of e)delete n[o];return{...t,nodes:n}})},createComment(e){let t=this.getNode(e.issue);if(!t)return l("Unable to create comment, missing issue");if(!U(t))return l("Can only comment on issues");let n=Vo("comments",e.id,{...e,deleted:!1});return a(n)?l("Unable to create comment"):d("Created comment",{...e,deleted:!1})},editComment(e,t){let n=this.getComment(e);if(!n)return l("Unable to edit comment, missing comment");let o=this.getNode(n.issue);if(!o)return l("Unable to edit comment, missing issue");if(!U(o))return l("Can only edit issue comments");let r={...n,md:t,deleted:!1},s=Vo("comments",e,r);return a(s)?l("Unable to edit comment"):d("Edited comment",r)},deleteComment(e){let t=this.getComment(e);if(!t)return l("Unable to delete comment, missing comment");let n={...t,deleted:!0},o=Vo("comments",e,n);return a(o)?l("Unable to delete comment"):d("Deleted comment",n)},getComment(e){return v().comments?.[e]},getCommentsByIssue(e){return Object.values(v().comments??{}).filter(t=>t.issue===e&&!t.deleted)},getCommentsGroupedByIssue(){let e=new Map;for(let t of Object.values(v().comments??{})){if(t.deleted)continue;let n=e.get(t.issue);n?n.push(t):e.set(t.issue,[t])}return e},createAttachment(e){let t=this.getNode(e.issue);if(!t)return l("Unable to create attachment, missing issue");if(!U(t))return l("Can only attach to issues");let n=Pe(o=>({...o,attachments:{...o.attachments??{},[e.id]:{...e,deleted:!1}}}));return a(n)?l("Unable to create attachment"):d("Created attachment",{...e,deleted:!1})},deleteAttachment(e){let t=this.getAttachment(e);if(!t)return l("Unable to delete attachment, missing attachment");let n={...t,deleted:!0},o=Pe(r=>({...r,attachments:{...r.attachments??{},[e]:n}}));return a(o)?l("Unable to delete attachment"):d("Deleted attachment",n)},getAttachment(e){return v().attachments?.[e]},getAttachmentsByIssue(e){return Object.values(v().attachments??{}).filter(t=>t.issue===e&&!t.deleted)},getAttachmentsGroupedByIssue(){let e=new Map;for(let t of Object.values(v().attachments??{})){if(t.deleted)continue;let n=e.get(t.issue);n?n.push(t):e.set(t.issue,[t])}return e},editValue(e,t){let{nodes:n}=v(),o=n[e];if(!o)return l("Edit target node not found");let r=po(o,"edit");if(r)return r;let s={...o,props:{...o.props,description:t}};return this.updateNode(s),d("Issue description updated",{md:t})},renameNode(e,t){let n=this.getNode(e);if(!n)return l("Rename target node not found");let o=po(n,"rename");if(o)return o;let r={...n,title:t};return this.updateNode(r),d("Renamed node",r)},getExistingTags(){let{tags:e}=v();return[...new Set(Object.values(e).map(t=>t.name).filter(Boolean))]},getExistingAssignees(){let{contributors:e}=v();return["me",...new Set(Object.values(e).map(t=>t.name).filter(Boolean))]},getFieldByTitle(e,t){return ke(e).find(n=>n.title===t)},moveNodeToRank({id:e,parentId:t,rank:n}){let{rootNodeId:o}=v(),r=this.getNode(e),s=this.getNode(t);if(!r)return l("Node not found");if(!s)return l("Target parent not found");if(o===e)return l("Cannot move root node");if(e===t)return l("Cannot move node into itself");let i=po(r,"move");if(i)return i;if(Jw(t,e))return l("Cannot move node into its own descendant");let c={...r,parentNodeId:t,rank:n};return this.updateNode(c),d("Moved node successfully",c)},tombstoneNode(e){let{nodes:t,contextNodeId:n,rootNodeId:o}=v(),r=this.getNode(e);if(!r)return l("Node not found");if(o===e)return l("Cannot delete root node");let s=po(r,"delete");if(s)return s;let i=new Set,c=p=>{let m=t[p];if(!(!m||i.has(p))){i.add(p);for(let f of ke(m.id))c(f.id)}};c(e);let u={...structuredClone(t)};for(let p of i){if(!u[p])return l("Unable to locate node to delete");u[p]={...u[p],isDeleted:!0}}return n?(T({nodes:u}),d("Successfully tomb stoned",r)):l("Unable to delete undefined")},tombstoneContributor(e){let t=this.getContributor(e);if(!t)return l("Contributor not found");let n={...t,name:ss,tombstoned:!0},o=Pe(r=>({...r,contributors:{...r.contributors,[e]:n}}));return a(o)?l("Unable to remove contributor"):d("Tombstoned contributor",n)},renameContributor(e,t){let n=this.getContributor(e);if(!n)return l("Contributor not found");if(n.tombstoned)return l("Cannot rename a removed contributor");let o={...n,name:t},r=Pe(s=>({...s,contributors:{...s.contributors,[e]:o}}));return a(r)?l("Unable to rename contributor"):d("Renamed contributor",o)},restoreContributor(e,t){let n=this.getContributor(e);if(!n)return l("Contributor not found");let o={...n,name:t,tombstoned:!1},r=Pe(s=>({...s,contributors:{...s.contributors,[e]:o}}));return a(r)?l("Unable to restore contributor"):d("Restored contributor",o)},linkContributorEmail({email:e,contributor:t,authorId:n}){if(!this.getContributor(t))return l("Unable to link email, missing contributor");let o={email:Ve(e),contributor:t,authorId:n},r=is(o.email,t),s=v().emailLinks[r];if(s&&!s.tombstoned)return d("Email already linked",s);let i=Pe(c=>({...c,emailLinks:{...c.emailLinks,[r]:o}}));return a(i)?l("Unable to link email"):d("Linked email to contributor",o)},unlinkContributorEmail(e,t,n){let o=is(e,t),r=v().emailLinks[o];if(!r)return l("Unable to unlink, no such link");if(r.tombstoned)return d("Email already unlinked",r);if(!xi(n,r))return l("Only the author of a link or the contributor it names may remove it");let s={...r,tombstoned:!0},i=Pe(c=>({...c,emailLinks:{...c.emailLinks,[o]:s}}));return a(i)?l("Unable to unlink email"):d("Unlinked email from contributor",s)},getEmailLinks(){return v().emailLinks},createContributor(e){let t=Pe(n=>({...n,contributors:{...n.contributors,[e.id]:e}}));return a(t)?l("Unable to create contributor"):d("Created contributor",e)},assign(e,t){let n=this.getContributor(t),o=this.getNode(e);if(!n)return l("Unable to assign contributor, missing contributor");if(!o)return l("Unable to assign contributor, missing target");let r=po(o,"edit");if(r)return r;if(!U(o))return l("Target is not an issue");let s=o.props.assignees??[];if(s.includes(t))return l("Contributor already assigned");let i={...o,props:{...o.props,assignees:[...s,t]}};return this.updateNode(i),d("Assigned contributor",{assignee:t})},unassign(e,t){let n=this.getContributor(t),o=this.getNode(e);if(!n)return l("Unable to unassign, missing contributor");if(!o)return l("Unable to unassign, missing target");let r=po(o,"edit");if(r)return r;if(!U(o))return l("Target is not an issue");let s=o.props.assignees??[];if(!s.includes(t))return d("Issue is not assigned to that contributor",{assignee:t});let i={...o,props:{...o.props,assignees:s.filter(c=>c!==t)}};return this.updateNode(i),d("Assignee removed",{assignee:t})},tag(e,t){let n=this.getTag(t),o=this.getNode(e);if(!n)return l("Unable to add tag, missing tag");if(!o)return l("Unable to add tag, missing target");let r=po(o,"edit");if(r)return r;if(!U(o))return l("Target is not an issue");let s=o.props.tags??[];if(s.includes(t))return l("Tag already assigned");let i={...o,props:{...o.props,tags:[...s,t]}};return this.updateNode(i),d("Tag added",{tag:t})},untag(e,t){let n=this.getTagRecord(t),o=this.getNode(e);if(!n)return l("Unable to remove tag, missing tag");if(!o)return l("Unable to remove tag, missing target");let r=po(o,"edit");if(r)return r;if(!U(o))return l("Target is not an issue");let s=o.props.tags??[];if(!s.includes(t))return d("Issue is not tagged with that tag",{tag:t});let i={...o,props:{...o.props,tags:s.filter(c=>c!==t)}};return this.updateNode(i),d("Tag removed",{tag:t})},tombstoneTag(e){let t=this.getTagRecord(e);if(!t)return l("Tag not found");let n={...t,tombstoned:!0},o=Pe(r=>({...r,tags:{...r.tags,[e]:n}}));return a(o)?l("Unable to delete tag"):d("Tombstoned tag",n)},restoreTag(e,t){let n=this.getTagRecord(e);if(!n)return l("Tag not found");let o={...n,name:t,tombstoned:!1},r=Pe(s=>({...s,tags:{...s.tags,[e]:o}}));return a(r)?l("Unable to restore tag"):d("Restored tag",o)},createTag(e){let t=Pe(n=>({...n,tags:{...n.tags,[e.id]:e}}));return a(t)?l("Could not create tag"):d("Tag created",e)},createNode(e){let t=Vo("nodes",e.id,e);return a(t)?l("Unable to create node"):d("Node created",e)},lockNode(e){let t=this.getNode(e);if(!t)return l("Failed to locate node");let n={...t,readonly:!0},o=Vo("nodes",e,n);return a(o)?l(o.message):d("Locked node",n)},updateNode(e){let t=Vo("nodes",e.id,e);return a(t)?t:d("Updated node",e)},getContributor(e){return v().contributors[e]},getTag(e){let t=v().tags[e];return t?.tombstoned?void 0:t},getTagRecord(e){return v().tags[e]},getTags(){return Object.values(v().tags).filter(e=>!e.tombstoned)},findTagByName(e){return this.getTags().find(t=>t.name===e)},getNode(e){return v().nodes[e]},getSiblings(e){return ke(e)}}});import fo from"chalk";import Cb from"string-width";var Qw,Zw,tu,eC,tC,Ab,Tb,nC,oC,rC,sC,iC,aC,Hd,kb,si=g(()=>{"use strict";ft();w();Nn();pe();O();dn();zs();Qw=(e,t)=>e+" ".repeat(Math.max(0,t-Cb(e))),Zw=(e,t)=>" ".repeat(Math.max(0,t-Cb(e)))+e,tu=e=>({"add.issue":"Created with title","add.issue.assignee":"Assigned to","remove.issue.assignee":"Unassigned from","close.issue":"Closed","delete.node":"Deleted","edit.title":"Changed title to","edit.description":"Changed description","reopen.issue":"Reopened","add.issue.tag":"Tagged with","remove.issue.tag":"Removed tag","lock.node":"Locked node","move.node":"Moved issue","add.issue.comment":"Commented","delete.issue.comment":"Deleted comment","add.issue.attachment":"Attached","delete.issue.attachment":"Removed attachment","edit.issue.comment":"Edited comment","init.workspace":"Created workspace","add.workspace":"Created workspace","add.board":"Created board","add.swimlane":"Created swimlane","add.field":"Added field","create.tag":"Created tag","tombstone.tag":"Deleted tag","restore.tag":"Restored tag","create.contributor":"Added contributor","rename.contributor":"Renamed contributor","link.contributor.user":"Linked contributor","link.contributor.email":"Claimed","unlink.contributor.email":"Unclaimed","tombstone.contributor":"Removed contributor","restore.contributor":"Restored contributor","rebalance.children":"Rebalanced order"})[e]??(e.endsWith("e")?`${e}d`:`${e}ed`),eC=(e,t)=>t?e<t?"up":e>t?"down":null:null,tC=(e,t)=>{let n=N.getNode(e.payload.parent),o=n?fo.dim.bgBlack(` ${n.title} `):"unknown",r=t.at(-1);if(r&&"parent"in r&&"rank"in r&&r.parent===e.payload.parent){let s=eC(e.payload.rank,r.rank);if(s)return`Moved ${s} in ${o}`}return`Moved issue to ${o}`},Ab=e=>`${Math.max(1,Math.round(e/1024))} KB`,Tb=e=>N.getAttachment(e)?.name??"",nC=e=>{switch(e.action){case"add.issue.tag":{let t=v().tags[e.payload.tag];return t?fo.bgHex(nt(t.name))(` ${t.name} `):"unknown tag"}case"remove.issue.tag":{let t=v().tags[e.payload.tag];return t?fo.bgHex(nt(t.name))(` ${t.name} `):"unknown tag"}case"tombstone.tag":{let t=v().tags[e.payload.id];return t?`"${t.name}"`:""}case"add.issue.assignee":{let t=v().contributors[e.payload.assignee];return t?fo.hex(nt(t.name))(` ${t.name} `):"unknown user"}case"remove.issue.assignee":{let t=v().contributors[e.payload.assignee];return t?fo.hex(nt(t.name))(` ${t.name} `):"unknown user"}case"add.board":case"add.swimlane":case"add.issue":case"add.field":case"create.tag":case"restore.tag":case"create.contributor":case"rename.contributor":case"edit.title":return`"${"name"in e.payload?e.payload.name:""}"`;case"link.contributor.email":case"unlink.contributor.email":return e.payload.email;case"add.issue.attachment":return`"${e.payload.name}" ${fo.dim(`(${Ab(e.payload.bytes)})`)}`;case"delete.issue.attachment":{let t=Tb(e.payload.id);return t?`"${t}"`:""}default:return""}},oC=e=>{let t=so(ct(e));return fo.gray(Zw(t,8))},rC=12,sC=e=>Qw(`${e}`,rC),iC=e=>{let t=Me();return a(t)?e:rs(e,t.value.contributors[e]?.name)},aC=e=>{switch(e.action){case"add.issue.tag":case"remove.issue.tag":{let t=v().tags[e.payload.tag];return t?t.name:""}case"add.issue.assignee":case"remove.issue.assignee":{let t=v().contributors[e.payload.assignee];return t?t.name:""}case"tombstone.tag":{let t=v().tags[e.payload.id];return t?`"${t.name}"`:""}case"add.board":case"add.swimlane":case"add.issue":case"add.field":case"create.tag":case"restore.tag":case"create.contributor":case"rename.contributor":case"edit.title":return"name"in e.payload?`"${e.payload.name}"`:"";case"link.contributor.email":case"unlink.contributor.email":return e.payload.email;case"move.node":{let t=N.getNode(e.payload.parent);return t?`to ${t.title}`:""}case"add.issue.attachment":return`"${e.payload.name}" (${Ab(e.payload.bytes)})`;case"delete.issue.attachment":{let t=Tb(e.payload.id);return t?`"${t}"`:""}default:return""}},Hd=e=>[tu(e.action),aC(e)].filter(Boolean).join(" "),kb=(e,t)=>{let n=oC(e.id),o=sC(iC(e.userId)),r=fo.dim("\u203A"),s=e.action==="move.node"?tC(e,t):[tu(e.action),nC(e)].filter(Boolean).join(" ");return`${o} ${n} ${r} ${s}`}});var Lb={};Zr(Lb,{areVirtualNodesEnabled:()=>Vi,createOrUpdateVirtualField:()=>$r,createOrUpdateVirtualFieldList:()=>nu,materializeTicketVirtualNodes:()=>zi,materializeVirtualNodes:()=>vC,setVirtualNodesEnabled:()=>hC});var lC,cC,dC,uC,mC,pC,fC,$r,nu,zi,gC,Mb,hC,Vi,vC,ic=g(()=>{"use strict";si();me();w();sr();pe();eo();O();Zo();oo();lC=e=>Te(e,"comments"),cC=e=>Te(e,"description"),dC=e=>Te(e,"assignees"),uC=e=>Te(e,"tags"),mC=e=>Te(e,"history"),pC=e=>Te(e,"diff"),fC=e=>Te(e,"attachments"),$r=({id:e,name:t,parentNodeId:n,rank:o,value:r,readonly:s=!1,childRenderAxis:i="horizontal"})=>{let c=N.getNode(e);if(!c){let m=N.createNode({...Be.field({id:e,name:t,parentNodeId:n,rank:o,props:{value:r},isVirtual:!0}),readonly:s,childRenderAxis:i});return a(m)?m:d("Virtual field created",void 0)}if(!ot(c))return l(`Existing virtual node ${e} is not a field`);if(!(c.title!==t||c.parentNodeId!==n||c.rank!==o||c.props.value!==r||c.readonly!==s||c.childRenderAxis!==i))return d("Virtual field unchanged",void 0);let p=N.updateNode({...c,title:t,parentNodeId:n,rank:o,props:{...c.props,value:r},readonly:s,childRenderAxis:i});return a(p)?p:d("Virtual field updated",void 0)},nu=({id:e,name:t,parentNodeId:n,rank:o,readonly:r=!1,childRenderAxis:s="horizontal"})=>{let i=N.getNode(e);if(!i){let p=N.createNode({...Be.fieldList({id:e,name:t,parentNodeId:n,rank:o,isVirtual:!0}),readonly:r,childRenderAxis:s});return a(p)?p:d("Virtual field list created",void 0)}if(!as(i))return l(`Existing virtual node ${e} is not a field list`);if(!(i.title!==t||i.parentNodeId!==n||i.rank!==o||i.readonly!==r||i.childRenderAxis!==s))return d("Virtual field list unchanged",void 0);let u=N.updateNode({...i,title:t,parentNodeId:n,rank:o,readonly:r,childRenderAxis:s});return a(u)?u:d("Virtual field list updated",void 0)},zi=e=>{let t=Ct(Xt/4n),n=Ct(Xt/2n),o=Ct(Xt*3n/4n),r=Ct(Xt*7n/8n),s=Ct(Xt*15n/16n),i=Ct(Xt*13n/16n),c=Ct(Xt*27n/32n);if(a(t))return t;if(a(n))return n;if(a(o))return o;if(a(r))return r;if(a(s))return s;if(a(i))return i;if(a(c))return c;let u=$r({id:cC(e.id),name:Ce.DESCRIPTION,parentNodeId:e.id,rank:t.value,value:e.props.description??"",childRenderAxis:"vertical"});if(a(u))return u;let p=nu({id:dC(e.id),name:Ce.ASSIGNEES,parentNodeId:e.id,rank:n.value,readonly:!0});if(a(p))return p;let m=nu({id:uC(e.id),name:Ce.TAGS,parentNodeId:e.id,rank:o.value,readonly:!0});if(a(m))return m;let f=$r({id:lC(e.id),name:Ce.COMMENTS,parentNodeId:e.id,rank:r.value,value:"",readonly:!1,childRenderAxis:"vertical"});if(a(f))return f;let h=$r({id:fC(e.id),name:Ce.ATTACHMENTS,parentNodeId:e.id,rank:s.value,value:"",readonly:!0,childRenderAxis:"vertical"});if(a(h))return h;let x=$r({id:mC(e.id),name:Ce.HISTORY,parentNodeId:e.id,rank:i.value,value:gC(e),readonly:!0,childRenderAxis:"vertical"});if(a(x))return x;let E=$r({id:pC(e.id),name:Ce.DIFF,parentNodeId:e.id,rank:c.value,value:"",readonly:!0,childRenderAxis:"vertical"});return a(E)?E:d("Ticket virtual nodes materialized",void 0)},gC=e=>{let t=[...e.log].reverse(),n=new Map;for(let o of t){let r=n.get(o.action)??[];r.push(o.payload),n.set(o.action,r)}return t.map(o=>kb(o,n.get(o.action)??[])).join(`
107
- `)},Mb=!0,hC=e=>{Mb=e},Vi=()=>Mb,vC=()=>{let{nodes:e}=v();for(let t of Object.values(e)){if(!U(t))continue;let n=zi(t);if(a(n))return n}return d("Virtual nodes materialized",void 0)}});var yC,bC,ol,ou=g(()=>{"use strict";ft();yC=e=>{switch(e.action){case"add.issue":case"move.node":case"close.issue":case"reopen.issue":return e.payload.parent;default:return null}},bC=(e,t)=>{let n=[];for(let o of e){let r=yC(o);if(r===null||r===n.at(-1)?.laneId)continue;let s=yo(o);n.push({laneId:r,enteredAt:s===null?t:ns(s)})}return n},ol=(e,t)=>bC(e,t).at(-1)?.enteredAt??t});var Pb=g(()=>{"use strict";Yt()});var xC,Db,rl=g(()=>{"use strict";ft();$();or();si();w();Pb();Nn();tn();xC=e=>{let t=new Map,n=new Set,o=r=>{let s=new Set,i=r;for(;i&&!s.has(i);){if(n.has(i))return i;s.add(i),i=t.get(i)}return null};return e.map(r=>{let s=r.payload,i=s?.id;if(!i)return null;r.action==="add.board"&&n.add(i);let c=r.action==="close.issue"?o(i):null,u=s.parent??s.issue;return u&&t.set(i,u),c!==null?c:n.has(i)?i:o(i)})},Db=(e,t)=>{let n=xC(e);return e.filter((o,r)=>n[r]===t)}});var IC,Ob,Fb,Ko,ci=g(()=>{"use strict";rt();Tr();rl();$();$();w();O();tn();rl();IC=null,Ob=Promise.resolve(),Fb=e=>{let t=Ob.then(e,e);return Ob=t.then(()=>{},()=>{}),t},Ko=()=>{if(!jt())return{mode:"live",asOfTime:null};let{timeMode:e}=v();return e==="live"?{mode:"live",asOfTime:null}:{mode:"scrub",asOfTime:IC}}});var _b,EC,Bb,$b,jr,sl=g(()=>{"use strict";Ke();wt();_b=new Map,EC=3e4,Bb=async e=>{let t=_b.get(e);if(t&&Date.now()-t.readAt<EC)return{name:t.name,email:t.email};let n=await Le({args:["config","--get-regexp","^user\\.(name|email)$"],cwd:e}),o=null,r=null;if(n.exitCode===0)for(let s of(n.stdout??"").split(`
108
- `)){let i=s.indexOf(" ");if(i===-1)continue;let c=s.slice(0,i),u=s.slice(i+1);c==="user.name"&&(o=u.trim()||null),c==="user.email"&&(r=Ve(u)||null)}return _b.set(e,{name:o,email:r,readAt:Date.now()}),{name:o,email:r}},$b=async e=>(await Bb(e)).email,jr=async e=>(await Bb(e)).name});import RC from"node:fs";var Yo,il,Z,oe,J,En=g(()=>{"use strict";rt();Ke();Cn();Ms();sl();rn();Fe();Po();or();ee();$();w();O();$t();ci();Yo=e=>{let t=we(e??process.cwd());return a(t)?l(t.message):d("Resolved Epiq repo root",t.value)},il=null,Z=async(e,t)=>{let n=Yo(e);if(a(n))return n;let o=Ie({repoRoot:n.value});if(a(o))return l(o.message);let r=vt(n.value);if(a(r))return l(r.message);if(!(il!==null&&il.repoRoot===n.value&&il.stateBranchRoot===o.value&&RC.existsSync(So(o.value)))){let f=await Ts({repoRoot:n.value,stateBranchName:r.value});if(a(f))return l(f.message);let h=await to({repoRoot:n.value,stateBranchRoot:o.value,stateBranchName:r.value});if(a(h))return l(h.message);il={repoRoot:n.value,stateBranchRoot:o.value}}if(t?.pull??!1){let f=await W({cwd:o.value,args:["pull","--ff-only"]});a(f)&&ce.info(3,f.message)}let i={repoRoot:n.value,stateBranchRoot:o.value},c=gr();a(c)||Qe(c.value),Qe({gitEmail:await $b(n.value),gitName:await jr(n.value)});let u=wo(o.value);if(pp(o.value)===u&&jt()&&Ko().mode==="live")return d("Booted Epiq state, unchanged",i);let p=nn(o.value);if(a(p))return l(p.message);let m=gn(p.value.events,p.value.unreadable);return a(m)?l(m.message):(fp(o.value,u),d("Booted Epiq state",i))},oe=()=>{let e=gr();return a(e)?l(e.message):e.value.userId?e.value.userName?d("Resolved actor",{userId:e.value.userId,userName:e.value.userName}):l("Unable to retrieve user name"):l("Unable to retrieve user id")},J=()=>{let e=Me();return a(e)?l(e.message):e}});var Ur,jb,Hr,ru=g(()=>{"use strict";ft();pe();Nn();pr();Ur=e=>yn(e).map(t=>gt(t.id,t.name)),jb=e=>N.getCommentsByIssue(e).sort((t,n)=>t.id<n.id?-1:t.id>n.id?1:0).map(t=>({id:t.id,author:rs(t.authorId,N.getContributor(t.authorId)?.name),createdAt:ct(t.id),body:t.md})),Hr=e=>bn(e).map(({id:t,name:n})=>gt(t,n))});var et,go,su,Xo=g(()=>{"use strict";me();w();En();et=e=>{let t=J();if(a(t))return t;let n=t.value.nodes[e];return!n||n.isDeleted?l("Issue not found"):U(n)?n.readonly?l("Issue is readonly"):d("Found issue",n):l("Target must be an issue")},go=e=>{let t=J();if(a(t))return t;let n=t.value.nodes[e];return!n||n.isDeleted?l("Swimlane not found"):bo(n)?n.readonly?l("Swimlane is readonly"):d("Found swimlane",n):l("Target must be a swimlane")},su=e=>{let t=J();if(a(t))return t;let n=t.value.nodes[e];return!n||n.isDeleted?l("Board not found"):xo(n)?n.readonly?l("Board is readonly"):d("Found board",n):l("Target must be a board")}});import SC from"node:fs";import NC from"node:path";import{ulid as Ub}from"ulid";var wC,Hb,iu,au=g(()=>{"use strict";rn();$();_t();w();ht();Xo();vr();En();wC=e=>{if(e.filePath)try{return d("Read attachment file",{data:SC.readFileSync(e.filePath),name:e.name??NC.basename(e.filePath)})}catch(t){return l(`Unable to read ${e.filePath}: ${t instanceof Error?t.message:String(t)}`)}return e.dataBase64?d("Decoded attachment data",{data:Buffer.from(e.dataBase64,"base64"),name:e.name??"image"}):l("Provide either filePath or dataBase64")},Hb=()=>{let e=gr();return a(e)?Bn:e.value.attachmentMaxKb??Bn},iu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=et(e.issueId);if(a(r))return r;let s=wC(e);if(a(s))return s;let i=Ng(t.value.stateBranchRoot,s.value.data,Hb());if(a(i))return i;let c=Se(s.value.name).trim()||"image",u=Ub(),p={id:Ub(),...D(n.value),action:"add.issue.attachment",payload:{id:u,issue:e.issueId,author:n.value.userId,hash:i.value.hash,ext:i.value.ext,name:c,bytes:i.value.bytes}},m=F([p],t.value.stateBranchRoot);if(a(m))return l(m.message);let f=hr(i.value.hash,i.value.ext);return d("Added issue attachment",{id:u,issueId:e.issueId,fileName:f,bytes:i.value.bytes,markdown:Bc(c,f)})}});var lu,x6,cu,Wb=g(()=>{"use strict";rn();ft();tn();me();w();pe();ur();Nn();dn();ou();mt();ht();vr();$t();ci();En();ru();au();ra();$();Cs();lu=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=J();return a(n)?n:d("Retrieved Epiq state",{root:t.value.repoRoot,stateBranchRoot:t.value.stateBranchRoot,nodes:n.value.nodes,rootNodeId:n.value.rootNodeId,contextNode:n.value.contextNode,selectedIndex:n.value.selectedIndex,eventLog:n.value.eventLog})},x6=365*24*60*60*1e3,cu=async(e={})=>{ir();let t=Yo(e.repoRoot);if(a(t))return l("Sync failed");let n=oe();if(a(n))return n;let o=await oa({cwd:t.value,ownEventFileName:Qn(n.value)});return a(o)?(mc(o.message),o):(Do(),d("Synced",o.value))}});var di,Wr,ui,du=g(()=>{"use strict";w();mt();di=e=>{let t=[...new Set([...e.issueIds??[],...e.issueId?[e.issueId]:[]])];return t.length?d("Resolved targets",t):l("Provide issueId or issueIds")},Wr=(e,t)=>{let n=t.done.length,o=`${e} ${n} issue${n===1?"":"s"}`+(t.failed.length?`, ${t.failed.length} failed`:"");return n?d(o,t):l(`${o}: ${t.failed.map(r=>`${r.ref} ${r.reason}`).join("; ")}`)},ui=(e,t)=>{let n={done:[],failed:[]};for(let o of e){let r=t(o);a(r)?n.failed.push({id:o,ref:V(o),reason:r.message}):n.done.push({id:o,ref:V(o)})}return n}});import{ulid as Vt}from"ulid";async function mu(e){let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=J();if(a(n))return n;let o=n.value.nodes,r=e.query?.trim().toLowerCase(),s=Object.values(o).filter(U).filter(c=>!c.isDeleted).filter(c=>e.includeClosed||c.parentNodeId!==Ae).filter(c=>e.boardId?(c.parentNodeId?o[c.parentNodeId]:void 0)?.parentNodeId===e.boardId:!0).filter(c=>!e.swimlaneId||c.parentNodeId===e.swimlaneId).filter(c=>!e.tag||Ur(c).some(u=>qb(u.name,e.tag))).filter(c=>!e.assignee||Hr(c).some(u=>qb(u.name,e.assignee))).filter(c=>!r||c.title.toLowerCase().includes(r)||(c.props.description??"").toLowerCase().includes(r)),i=c=>Se((c.parentNodeId?o[c.parentNodeId]?.title:void 0)??"");return e.brief?d("Listed issues",s.map(c=>({id:c.id,ref:V(c.id),title:Se(c.title),swimlane:i(c),tags:Ur(c).map(u=>u.name),assignees:Hr(c).map(u=>u.name)}))):d("Listed issues",s.map(c=>({id:c.id,ref:V(c.id),title:Se(c.title),description:c.props.description??"",createdAt:ct(c.id),enteredLaneAt:ol(c.log??[],ct(c.id)),parentNodeId:c.parentNodeId,isClosed:c.parentNodeId===Ae,readonly:!!c.readonly,tags:Ur(c),assignees:Hr(c)})))}async function fu(e){let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=di(e);if(a(o))return o;let r=s=>CC(s,n.value,t.value.stateBranchRoot);return e.issueIds?Wr("Closed",ui(o.value,r)):r(o.value[0])}async function hu(e){let t=Yo(e.repoRoot);if(a(t))return t;let n=oe();if(a(n))return n;let o=Ie({repoRoot:t.value});if(a(o))return o;let r=nn(o.value);if(a(r))return r;let s=gn(r.value.events,r.value.unreadable);if(a(s))return s;let i=di(e);if(a(i))return i;let c=u=>AC(u,e,n.value,o.value);return e.issueIds?Wr("Moved",ui(i.value,c)):c(i.value[0])}var uu,qb,pu,CC,gu,AC,vu,yu,Gb=g(()=>{"use strict";rt();Bd();ft();Po();$();$();_t();Wd();tn();me();Nn();w();pe();Bt();si();$n();ou();mt();ht();En();ru();du();Xo();uu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=J();if(a(n))return n;let o=e.idOrRef.trim();if(!o)return l("Provide an issue id or ref");let r=Object.values(n.value.nodes).filter(U).filter(u=>!u.isDeleted),s=r.find(u=>u.id===o),i=s?[s]:r.filter(u=>Is(u.id,o));if(i.length===0)return l(`No issue matches "${o}"`);if(i.length>1)return l(`"${o}" matches ${i.length} issues: ${i.map(u=>`${V(u.id)} (${Se(u.title)})`).join(", ")}. Use a full ref or id.`);let c=i[0];return d("Found issue",{id:c.id,ref:V(c.id),title:Se(c.title),description:c.props.description??"",createdAt:ct(c.id),enteredLaneAt:ol(c.log??[],ct(c.id)),parentNodeId:c.parentNodeId,isClosed:c.parentNodeId===Ae,readonly:!!c.readonly,tags:Ur(c),assignees:Hr(c),comments:jb(c.id)})},qb=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase();pu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=Se(e.title);if(!r)return l("Issue title cannot be empty");let s=e.description??"",i=at("Issue title",r,300)??at("Issue description",s,2e4);if(i)return l(i);if((e.tagNames?.length??0)>20)return l(`Cannot set more than ${20} tags at once`);if((e.assigneeNames?.length??0)>20)return l(`Cannot set more than ${20} assignees at once`);let c=go(e.parentId);if(a(c))return c;let u=Dn(e.parentId,n.value,t.value.stateBranchRoot);if(a(u))return u;let p=Ga({name:r,parent:e.parentId,user:n.value,rank:u.value});if(a(p))return p;let m=[...p.value],f=m.find(S=>S.action==="add.issue")?.payload.id;if(!f)return l("Unable to determine created issue id");s&&m.push({id:Vt(),...D(n.value),action:"edit.description",payload:{id:f,md:s}});let h=[];for(let S of e.tagNames??[]){let C=Se(S).trim();if(!C||h.some(_=>_.name===C))continue;let R=at("Tag name",C,60);if(R)return l(R);let A=N.findTagByName(C),L=A?.id??Vt();A||m.push({id:Vt(),...D(n.value),action:"create.tag",payload:{id:L,name:C}}),m.push({id:Vt(),...D(n.value),action:"add.issue.tag",payload:{id:f,tag:L}}),h.push({id:L,name:C})}let x=[];for(let S of e.assigneeNames??[]){let C=Se(S).trim();if(!C||x.some(_=>_.name===C))continue;let R=at("Assignee name",C,80);if(R)return l(R);let A=Object.values(o.value.contributors).find(_=>_.name===C),L=A?.id??Vt();A||m.push({id:Vt(),...D(n.value),action:"create.contributor",payload:{id:L,name:C}}),m.push({id:Vt(),...D(n.value),action:"add.issue.assignee",payload:{id:f,assignee:L}}),x.push({id:L,name:C})}let E=F(m,t.value.stateBranchRoot);return a(E)?l(E.message):d("Created issue",{id:f,ref:V(f),title:r,parentId:e.parentId,description:s,tags:h,assignees:x})},CC=(e,t,n)=>{let o=et(e);if(a(o))return o;let r=pn(Ae,e,{at:"end"},t,n);if(a(r))return r;let s={id:Vt(),...D(t),action:"close.issue",payload:{id:e,parent:Ae,rank:r.value}},i=F([s],n);return a(i)?l(i.message):d("Closed issue",{id:e,ref:V(e)})};gu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=o.value.nodes[e.issueId];if(!r||r.isDeleted)return l("Issue not found");if(!U(r))return l("Target must be an issue");if(r.parentNodeId!==Ae)return l("Issue is not closed");let s=Xa(r);if(!s)return l("Unable to resolve previous parent from issue history");if(s===Ae)return l("Previous parent resolves to closed swimlane");let i=go(s);if(a(i))return i;let c=i.value,u=pn(c.id,r.id,{at:"end"},n.value,t.value.stateBranchRoot);if(a(u))return u;let p={id:Vt(),...D(n.value),action:"reopen.issue",payload:{id:r.id,parent:c.id,rank:u.value}},m=F([p],t.value.stateBranchRoot);return a(m)?l(m.message):d("Reopened issue",{id:r.id,ref:V(r.id),parentId:c.id})},AC=(e,t,n,o)=>{let r=et(e);if(a(r))return r;let s=go(t.parentId);if(a(s))return s;let i=pn(t.parentId,e,t.position??{at:"end"},n,o);if(a(i))return i;let c={id:Vt(),...D(n),action:"move.node",payload:{id:e,parent:t.parentId,rank:i.value}},u=F([c],o);return a(u)?l(u.message):d("Moved issue",{id:e,ref:V(e),parentId:t.parentId})};vu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=et(e.issueId);if(a(r))return r;let s=r.value,i=at("Issue description",e.description,2e4);if(i)return l(i);let c=s.props.description??"";if(c===e.description)return d("No changes made",{id:e.issueId,ref:V(e.issueId),description:c});let u={id:Vt(),...D(n.value),action:"edit.description",payload:{id:e.issueId,md:e.description}},p=F([u],t.value.stateBranchRoot);return a(p)?l(p.message):d("Edited issue description",{id:e.issueId,ref:V(e.issueId),description:e.description})},yu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=et(e.issueId);if(a(r))return r;let s=r.value,i=Se(e.title);if(!i.trim())return l("Issue title cannot be empty");let c=at("Issue title",i,300);if(c)return l(c);if(s.title===i)return d("No changes made",{id:e.issueId,ref:V(e.issueId),title:i});let u={id:Vt(),...D(n.value),action:"edit.title",payload:{id:e.issueId,name:i}},p=F([u],t.value.stateBranchRoot);return a(p)?l(p.message):d("Edited issue title",{id:e.issueId,ref:V(e.issueId),title:i})}});import{ulid as ho}from"ulid";var bu,xu,Iu,Eu,Ru,Su,Nu,wu,zb=g(()=>{"use strict";rt();Po();$();$();_t();tn();me();w();Bt();$n();mt();ht();ci();En();Xo();bu=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=J();if(a(n))return n;let o=Object.values(n.value.nodes).filter(r=>r.context==="BOARD"&&!r.isDeleted).map(r=>({id:r.id,ref:V(r.id),title:r.title,parentId:r.parentNodeId,readonly:!!r.readonly}));return d("Listed boards",o)},xu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=o.value.nodes[o.value.rootNodeId];if(!r)return l("Workspace not found");if(Ko().mode!=="live")return l("Cannot add a board while time travelling");let s=Se(e.title);if(!s.trim())return l("Board title cannot be empty");let i=at("Board title",s,300);if(i)return l(i);let c=Dn(r.id,n.value,t.value.stateBranchRoot);if(a(c))return c;let u=ho(),p={id:ho(),...D(n.value),action:"add.board",payload:{id:u,name:s,parent:r.id,rank:c.value}},m=F([p],t.value.stateBranchRoot);return a(m)?l(m.message):d("Created board",{id:u,ref:V(u),title:s})},Iu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=o.value.nodes[e.boardId];if(!r||r.isDeleted)return l("Board not found");if(!xo(r))return l("Edit target must be a board");if(r.readonly)return l("Cannot edit readonly board");if(Ko().mode!=="live")return l("Cannot rename a board while time travelling");let s=Se(e.title);if(!s.trim())return l("Board title cannot be empty");let i=at("Board title",s,300);if(i)return l(i);if(r.title===s)return d("No changes made",{id:e.boardId,ref:V(e.boardId),title:s});let c={id:ho(),...D(n.value),action:"edit.title",payload:{id:e.boardId,name:s}},u=F([c],t.value.stateBranchRoot);return a(u)?l(u.message):d("Edited board title",{id:e.boardId,ref:V(e.boardId),title:s})},Eu=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=J();if(a(n))return n;let o=Object.values(n.value.nodes).filter(r=>r.context==="SWIMLANE"&&!r.isDeleted).filter(r=>!e.boardId||r.parentNodeId===e.boardId).map(r=>({id:r.id,title:r.title,boardId:r.parentNodeId,isClosed:r.id===Ae,readonly:!!r.readonly}));return d("Listed swimlanes",o)},Ru=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=su(e.boardId);if(a(r))return r;if(Ko().mode!=="live")return l("Cannot add a swimlane while time travelling");let s=Se(e.title);if(!s.trim())return l("Swimlane title cannot be empty");let i=at("Swimlane title",s,300);if(i)return l(i);let c=Dn(e.boardId,n.value,t.value.stateBranchRoot);if(a(c))return c;let u=ho(),p={id:ho(),...D(n.value),action:"add.swimlane",payload:{id:u,name:s,parent:e.boardId,rank:c.value}},m=F([p],t.value.stateBranchRoot);return a(m)?l(m.message):d("Created swimlane",{id:u,ref:V(u),title:s,boardId:e.boardId})},Su=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=go(e.swimlaneId);if(a(r))return r;let s=r.value,i=Se(e.title);if(!i.trim())return l("Swimlane title cannot be empty");let c=at("Swimlane title",i,300);if(c)return l(c);if(s.title===i)return d("No changes made",{id:e.swimlaneId,ref:V(e.swimlaneId),title:i});let u={id:ho(),...D(n.value),action:"edit.title",payload:{id:e.swimlaneId,name:i}},p=F([u],t.value.stateBranchRoot);return a(p)?l(p.message):d("Edited swimlane title",{id:e.swimlaneId,ref:V(e.swimlaneId),title:i})},Nu=async e=>{let t=Yo(e.repoRoot);if(a(t))return t;let n=oe();if(a(n))return n;let o=Ie({repoRoot:t.value});if(a(o))return o;let r=nn(o.value);if(a(r))return r;let s=gn(r.value.events,r.value.unreadable);if(a(s))return s;let i=go(e.swimlaneId);if(a(i))return i;let c=su(e.boardId);if(a(c))return c;let u=pn(e.boardId,e.swimlaneId,e.position??{at:"end"},n.value,o.value);if(a(u))return u;let p={id:ho(),...D(n.value),action:"move.node",payload:{id:e.swimlaneId,parent:e.boardId,rank:u.value}},m=F([p],o.value);return a(m)?l(m.message):d("Moved swimlane",{id:e.swimlaneId,ref:V(e.swimlaneId),boardId:e.boardId})},wu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=go(e.swimlaneId);if(a(r))return r;let s={id:ho(),...D(n.value),action:"delete.node",payload:{id:e.swimlaneId}},i=F([s],t.value.stateBranchRoot);return a(i)?l(i.message):d("Deleted swimlane",{id:e.swimlaneId,ref:V(e.swimlaneId)})}});import{ulid as zr}from"ulid";async function Cu(e){let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=di(e);if(a(o))return o;let r=Se(e.tagName).trim();if(!r)return l("Tag name cannot be empty");let s=at("Tag name",r,60);if(s)return l(s);let i=ui(o.value,et);if(!e.issueIds&&i.failed[0])return l(i.failed[0].reason);if(i.done.length===0)return l(Wr("Tagged",i).message);let c=N.findTagByName(r),u=c?.id??zr(),p=[...c?[]:[{id:zr(),...D(n.value),action:"create.tag",payload:{id:u,name:r}}],...i.done.map(({id:x})=>({id:zr(),...D(n.value),action:"add.issue.tag",payload:{id:x,tag:u}}))],m=F(p,t.value.stateBranchRoot);if(a(m))return l(m.message);let f={id:u,name:r};if(!e.issueIds)return d("Added issue tag",{...i.done[0],tag:f});let h=Wr("Tagged",i);return a(h)?h:d(h.message,{...h.value,tag:f})}var Au,Tu,ku,Vb=g(()=>{"use strict";$();_t();w();pe();$n();mt();ht();En();du();Xo();Au=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=o.value.tags[e.tagId];if(!r)return l("Tag not found");if(r.tombstoned)return l("Tag is already deleted");let s=[{id:zr(),...D(n.value),action:"tombstone.tag",payload:{id:e.tagId}}],i=F(s,t.value.stateBranchRoot);return a(i)?l(i.message):d("Deleted tag",{id:r.id,name:r.name})},Tu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=o.value.tags[e.tagId];if(!r)return l("Tag not found");if(!r.tombstoned)return l("Tag is not deleted");if(N.findTagByName(r.name))return l(`Cannot restore: another tag is already named "${r.name}"`);let s=[{id:zr(),...D(n.value),action:"restore.tag",payload:{id:e.tagId,name:r.name}}],i=F(s,t.value.stateBranchRoot);return a(i)?l(i.message):d("Restored tag",{id:r.id,name:r.name})},ku=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=et(e.issueId);if(a(r))return r;if(!o.value.tags[e.tagId])return l("Tag not found");let s={id:zr(),...D(n.value),action:"remove.issue.tag",payload:{id:e.issueId,tag:e.tagId}},i=F([s],t.value.stateBranchRoot);return a(i)?l(i.message):d("Removed issue tag",{id:e.issueId,ref:V(e.issueId),tagId:e.tagId})}});import{ulid as qn}from"ulid";var Mu,Kb,Lu,Pu,TC,Du,Ou,Fu,Yb=g(()=>{"use strict";w();Yt();vo();$();$();_t();Ja();Nn();rl();$n();mt();ht();En();Xo();Mu=async e=>{let t=vl(e.name,"name");if(a(t))return l(t.message);let n=await Z(e.repoRoot,{pull:!1});if(a(n))return n;let o=oe();if(a(o))return o;let r=J();if(a(r))return r;let s=o.value,i=!!r.value.contributors[s.userId];if(!i){let c=F([{id:qn(),...D(s),action:"create.contributor",payload:{id:s.userId,name:s.userName}}],n.value.stateBranchRoot);if(a(c))return l(c.message)}return d(`Assumed ${s.userName}`,{...s,registered:!i})},Kb=async(e,t)=>{let n=ko(e).get(t);return n===void 0?void 0:{id:t,name:n}},Lu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=et(e.issueId);if(a(r))return r;let s=e.self?n.value.userId:e.assigneeId;if(s){let S=o.value.contributors[s],C=S?void 0:await Kb(t.value.stateBranchRoot,s);if(!S&&!C)return l("Unknown assignee id");let R=S??C,A=[...S?[]:[{id:qn(),...D(n.value),action:"create.contributor",payload:{id:R.id,name:R.name}}],{id:qn(),...D(n.value),action:"add.issue.assignee",payload:{id:e.issueId,assignee:R.id}}],L=F(A,t.value.stateBranchRoot);return a(L)?l(L.message):d("Added issue assignee",{id:e.issueId,ref:V(e.issueId),assignee:{id:R.id,name:R.name}})}let i=Se(e.assigneeName??"").trim();if(!i)return l("Provide assigneeId, self or assigneeName");let c=at("Assignee name",i,80);if(c)return l(c);let u=ai({events:o.value.eventLog??[],registry:o.value.contributors,logFileNames:ko(t.value.stateBranchRoot)}).filter(S=>S.name===i);if(u.length>1)return l(`"${i}" matches ${u.length} contributors (${u.map(({id:S})=>S).join(", ")}). Assign by assigneeId to choose.`);let p=u[0];if(!p&&!e.createUnlinked)return l(`No contributor named "${i}". Assign by id, or pass createUnlinked to add them as an external assignee.`);let m=p?.id??qn(),f=p?.name??i,x=[...!!o.value.contributors[m]?[]:[{id:qn(),...D(n.value),action:"create.contributor",payload:{id:m,name:f}}],{id:qn(),...D(n.value),action:"add.issue.assignee",payload:{id:e.issueId,assignee:m}}],E=F(x,t.value.stateBranchRoot);return a(E)?l(E.message):d("Added issue assignee",{id:e.issueId,ref:V(e.issueId),assignee:{id:m,name:f}})},Pu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;if(!o.value.contributors[e.contributorId])return l("Contributor not found");if(await Kb(t.value.stateBranchRoot,e.contributorId))return l("Cannot remove a contributor who has authored events \u2014 their name appears throughout the log");let i=[{id:qn(),...D(n.value),action:"tombstone.contributor",payload:{id:e.contributorId}}],c=F(i,t.value.stateBranchRoot);return a(c)?l(c.message):d("Tombstoned contributor",{id:e.contributorId,name:ss})},TC=async(e,t)=>{let n=Mo(e);if(a(n))return;let o;for(let r of n.value){if(r.action!=="create.contributor")continue;let s=r.payload;s.id===t&&s.name&&(o=s.name)}return o},Du=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=o.value.contributors[e.contributorId];if(!r)return l("Contributor not found");if(!r.tombstoned)return l("Contributor is not tombstoned");let s=await TC(t.value.stateBranchRoot,e.contributorId);if(!s)return l("Cannot restore this contributor \u2014 no original name found in the event log");let i=[{id:qn(),...D(n.value),action:"restore.contributor",payload:{id:e.contributorId,name:s}}],c=F(i,t.value.stateBranchRoot);return a(c)?l(c.message):d("Restored contributor",{id:e.contributorId,name:s})},Ou=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=Mo(t.value.stateBranchRoot);if(a(r))return l(r.message);let s=e.boardId?Db(r.value,e.boardId):r.value,i=new Set,c=Jp(t.value.stateBranchRoot);if(a(c))return l(c.message);for(let m of c.value)m.userId&&i.add(m.userId);let u=o.value.contributors,p=ai({events:s,registry:u,logFileNames:ko(t.value.stateBranchRoot)}).map(({id:m,name:f,isExternal:h})=>({...gt(m,f),isSelf:m===n.value.userId,isExternal:h,isRemoved:u[m]?.tombstoned===!0,hasAuthoredAnywhere:i.has(m)}));return d("Listed board contributors",p)},Fu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=et(e.issueId);if(a(r))return r;if(!o.value.contributors[e.assigneeId])return l("Assignee not found");let s={id:qn(),...D(n.value),action:"remove.issue.assignee",payload:{id:e.issueId,assignee:e.assigneeId}},i=F([s],t.value.stateBranchRoot);return a(i)?l(i.message):d("Removed issue assignee",{id:e.issueId,ref:V(e.issueId),assigneeId:e.assigneeId})}});import{ulid as cl}from"ulid";var _u,Bu,$u,Xb=g(()=>{"use strict";$();_t();w();$n();En();Xo();_u=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=et(e.issueId);if(a(r))return r;let s=e.body.trim();if(!s)return l("Comment cannot be empty");if(s.length>4e3)return l(`Comment cannot exceed ${4e3} characters (got ${s.length})`);let i=cl(),c={id:cl(),...D(n.value),action:"add.issue.comment",payload:{id:i,issue:e.issueId,md:s,author:n.value.userId}},u=F([c],t.value.stateBranchRoot);return a(u)?l(u.message):d("Added issue comment",{id:i,issueId:e.issueId,body:s})},Bu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=o.value.eventLog.find(p=>p.action==="add.issue.comment"&&p.payload.id===e.commentId);if(!r)return l("Unable to resolve comment");if(r.payload.author!==n.value.userId)return l("You can only delete your own comments");let s=et(r.payload.issue);if(a(s))return s;if(o.value.eventLog.some(p=>p.action==="delete.issue.comment"&&p.payload.id===e.commentId))return d("Comment already deleted",{id:e.commentId,issueId:r.payload.issue});let c={id:cl(),...D(n.value),action:"delete.issue.comment",payload:{id:e.commentId,issue:r.payload.issue}},u=F([c],t.value.stateBranchRoot);return a(u)?l(u.message):d("Deleted issue comment",{id:e.commentId,issueId:r.payload.issue})},$u=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=o.value.eventLog.find(m=>m.action==="add.issue.comment"&&m.payload.id===e.commentId);if(!r)return l("Unable to resolve comment");if(r.payload.author!==n.value.userId)return l("You can only edit your own comments");let s=et(r.payload.issue);if(a(s))return s;if(o.value.eventLog.some(m=>m.action==="delete.issue.comment"&&m.payload.id===e.commentId))return l("Comment was deleted");let c=e.body.trim();if(!c)return l("Comment cannot be empty");if(c.length>4e3)return l(`Comment cannot exceed ${4e3} characters (got ${c.length})`);let u={id:cl(),...D(n.value),action:"edit.issue.comment",payload:{id:e.commentId,issue:r.payload.issue,md:c}},p=F([u],t.value.stateBranchRoot);return a(p)?l(p.message):d("Edited issue comment",{id:e.commentId,issueId:r.payload.issue,body:c})}});import{ulid as Jb}from"ulid";var ju,Uu,Hu,Wu,qu=g(()=>{"use strict";$();wt();Nn();w();Cn();sl();Kd();Fe();En();ju=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;if(!Gn(e.email))return l(`Not an email address: ${e.email}`);let r=Ve(e.email),s=e.contributorId??n.value.userId;if(!o.value.contributors[s])return l(`Unknown contributor: ${s}`);let i=Sl(o.value.emailLinks,r);if(i.includes(s))return d(`${r} is already yours`,{contributor:s,email:r,contested:i.filter(u=>u!==s)});let c=F([{id:Jb(),action:"link.contributor.email",payload:{contributor:s,email:r},userId:n.value.userId}],t.value.stateBranchRoot);return a(c)?l(c.message):d(i.length>0?`Claimed ${r}, but somebody else claims it too, so it now resolves to neither of you`:`Claimed ${r}`,{contributor:s,email:r,contested:i})},Uu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let r=Ve(e.email),s=e.contributorId??n.value.userId,i=o.value.emailLinks[is(r,s)];if(!i||i.tombstoned)return l(`No such link: ${r} to ${s}`);if(!xi(n.value.userId,i))return l("Only whoever made a claim, or the contributor it names, may undo it");let c=F([{id:Jb(),action:"unlink.contributor.email",payload:{contributor:s,email:r},userId:n.value.userId}],t.value.stateBranchRoot);return a(c)?l(c.message):d(`Unclaimed ${r}`,{contributor:s,email:r})},Hu=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=J();if(a(n))return n;let{emailLinks:o,contributors:r}=n.value,s=new Map;for(let f of Object.values(o)){if(f.tombstoned)continue;let h=s.get(f.email)??new Set;h.add(f.contributor),s.set(f.email,h)}let i=[...s.entries()].map(([f,h])=>({email:f,contested:h.size>1,claimants:[...h].map(x=>gt(x,r[x]?.name))})).sort((f,h)=>f.email.localeCompare(h.email)),c=oe(),u=a(c)?[]:zn(o,c.value.userId),p=le().gitEmail,m=p?Sl(o,p).filter(f=>a(c)||f!==c.value.userId):[];return d("Listed contributor emails",{emails:i,mine:u,git:p?{email:p,linkedToMe:u.includes(p),heldByOthers:m.map(f=>gt(f,r[f]?.name))}:null})},Wu=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=oe();if(a(n))return n;let o=J();if(a(o))return o;let{userId:r,userName:s}=n.value,i=vt(t.value.repoRoot),c=await Za({repoRoot:t.value.repoRoot,stateBranch:a(i)?void 0:i.value,names:[s,await jr(t.value.repoRoot)],links:o.value.emailLinks});if(a(c))return c;let u=el(c.value),p=u.filter(m=>m.looksLikeYours);return d(u.length===0?"No unclaimed addresses in this history":`${u.length} unclaimed address(es) in this history, ${p.length>0?`${p.length} of which look like yours`:"none obviously yours"}. Show them to the user and link only the ones they confirm; each is a permanent event that replicates to every clone.`,{contributor:r,candidates:u,likely:p.length})}});var Qb=g(()=>{"use strict";Wb();Gb();zb();Vb();Yb();Xb();au();qu()});import{ulid as kC}from"ulid";var Zb,ex,tx,nx=g(()=>{"use strict";vo();ur();sl();rn();w();Dd();$t();Zb=[{name:"userName",question:"the name they want to appear under on the board"},{name:"preferredEditor",question:'the command that opens a file for editing, e.g. "vim", "nano" or "code --wait"'},{name:"autoSync",question:"whether the TUI and GUI should sync with the git remote on their own (true or false)"}],ex=e=>e.trim().toLowerCase(),tx=async(e={})=>{let t=no();if(a(t))return l(t.message);let n=t.value,o=e.userName?.trim(),r=(process.env[Ot]??"").trim();if(o&&r&&ex(o)===ex(r))return l(`userName "${o}" is this agent's own identity. Pass the user's name, the one they want the TUI and GUI to write as.`);let s={userName:o||void 0,preferredEditor:e.preferredEditor?.trim()||void 0,autoSync:e.autoSync},i={userName:n.userName?.trim()||void 0,preferredEditor:n.preferredEditor?.trim()||void 0,autoSync:typeof n.autoSync=="boolean"?n.autoSync:void 0};for(let C of Zb){let R=s[C.name],A=i[C.name];if(!(R===void 0||A===void 0||R===A))return l(`This machine is already set up with ${C.name} ${JSON.stringify(A)}; epiq_project_init does not change it. Call again without ${C.name}, or let the user change it in the TUI with :config.`)}let c={};if(s.userName&&!i.userName&&(c.userName=s.userName),s.preferredEditor&&!i.preferredEditor&&(c.preferredEditor=s.preferredEditor),s.autoSync!==void 0&&i.autoSync===void 0&&(c.autoSync=s.autoSync),(c.userName||i.userName)&&!n.userId&&(c.userId=kC()),Object.keys(c).length>0){let C=it(c);if(a(C))return l(C.message)}let u={...n,...c},p=Zb.filter(C=>{let R=u[C.name];return typeof R=="boolean"?!1:!R?.trim()});if(p.length>0){let C=p.map(L=>`${L.name} (${L.question})`).join("; "),R=p.some(L=>L.name==="userName")?await jr(e.repoRoot??process.cwd()):null,A=R?` This repository's git user.name is ${JSON.stringify(R)} \u2014 offer it as the default for userName, and use it only if the user agrees.`:"";return l(`Setup incomplete. Ask the user for: ${C}.${A} Then call epiq_project_init again with the answers; what was given so far is saved.`)}let m={userId:u.userId??"",userName:u.userName??""};if(!m.userId||!m.userName)return l("Missing Epiq user id");let f=await qa({cwd:e.repoRoot??process.cwd(),user:m});if(a(f))return f;let{defaultEvents:h,...x}=f.value,E=Os({root:x.repoRoot});a(E)&&ce.info(E.message);let S=x.warnings.length===0?"Project initialized":`Project initialized, with warnings: ${x.warnings.join(" ")}`;return d(S,{...x,user:m})}});var Rn,dl=g(()=>{"use strict";Rn=e=>({path:e.path,sha:e.shas[e.shas.length-1]??""})});var MC,ox,rx=g(()=>{"use strict";dl();MC=e=>{let t=e.lastIndexOf("/");return t===-1?".":e.slice(0,t)},ox=({commits:e,patch:t})=>{let n=e.map(i=>i.time),r=t.files.map(i=>({...Rn(i),changed:i.addedCount+i.removed})).reduce((i,c)=>i===null||c.changed>i.changed?c:i,null),s=t.insertions+t.deletions;return{commits:e.length,authors:[...new Set(e.map(i=>i.author))].sort(),firstCommitAt:n.length?Math.min(...n):null,lastCommitAt:n.length?Math.max(...n):null,files:t.files.length,filesAdded:t.files.filter(i=>i.status==="added").length,filesModified:t.files.filter(i=>i.status==="modified").length,filesDeleted:t.files.filter(i=>i.status==="deleted").length,binaryFiles:t.files.filter(i=>i.binary).length,directories:new Set(t.files.map(i=>MC(i.path))).size,insertions:t.insertions,deletions:t.deletions,net:t.insertions-t.deletions,largestFile:r,concentration:r&&s>0?r.changed/s:0,selfChurn:t.selfChurn,truncated:t.truncated}}});var Xe,Kt,Gu,Vr,LC,Q,ul,ml,sx,PC,ix,Jo,pi,DC,OC,Kr,FC,_C,BC,cn,ax,lx,cx,$C,jC,dx,ux,Yr=g(()=>{"use strict";Xe={line:["//"],block:[["/*","*/"]]},Kt={line:["#"],block:[]},Gu={line:["--"],block:[]},Vr={line:[],block:[["<!--","-->"]]},LC={line:[],block:[]},Q=(e,t)=>({name:e,comment:t}),ul=Q("TypeScript",Xe),ml=Q("JavaScript",Xe),sx={ts:ul,tsx:ul,mts:ul,cts:ul,js:ml,jsx:ml,mjs:ml,cjs:ml,py:Q("Python",{line:["#"],block:[['"""','"""']]}),rb:Q("Ruby",{line:["#"],block:[["=begin","=end"]]}),go:Q("Go",Xe),rs:Q("Rust",Xe),java:Q("Java",Xe),kt:Q("Kotlin",Xe),swift:Q("Swift",Xe),c:Q("C",Xe),h:Q("C",Xe),cc:Q("C++",Xe),cpp:Q("C++",Xe),hpp:Q("C++",Xe),cs:Q("C#",Xe),php:Q("PHP",Xe),scala:Q("Scala",Xe),dart:Q("Dart",Xe),lua:Q("Lua",Gu),hs:Q("Haskell",Gu),sql:Q("SQL",Gu),ex:Q("Elixir",Kt),exs:Q("Elixir",Kt),pl:Q("Perl",Kt),r:Q("R",Kt),jl:Q("Julia",Kt),sh:Q("Shell",Kt),bash:Q("Shell",Kt),zsh:Q("Shell",Kt),vue:Q("Vue",Vr),svelte:Q("Svelte",Vr),html:Q("HTML",Vr),xml:Q("XML",Vr),md:Q("Markdown",Vr),mdx:Q("Markdown",Vr),css:Q("CSS",{line:[],block:[["/*","*/"]]}),scss:Q("CSS",Xe),less:Q("CSS",Xe),yml:Q("YAML",Kt),yaml:Q("YAML",Kt),toml:Q("TOML",Kt),ini:Q("INI",Kt),json:Q("JSON",LC)},PC="Other",ix=e=>{let t=e.slice(e.lastIndexOf("/")+1),n=t.lastIndexOf(".");return n<=0?"":t.slice(n+1).toLowerCase()},Jo=e=>sx[ix(e)]?.name??PC,pi=e=>sx[ix(e)]?.comment??null,DC=[/\.(test|spec)\.[a-z0-9]+$/i,/(^|\/)test_[^/]+\.py$/,/_test\.[a-z0-9]+$/i,/(^|\/)conftest\.py$/,/Tests?\.(java|kt|cs|scala)$/],OC=/(^|\/)(tests?|__tests__|spec|specs|e2e|src\/test|features)\//i,Kr=e=>OC.test(e)||DC.some(t=>t.test(e)),FC=/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock|go\.sum|poetry\.lock|Gemfile\.lock|composer\.lock)$/,_C=/(^|\/)(node_modules|dist|build|out|target|vendor|coverage|\.next|__snapshots__)\//,BC=/(\.min\.(js|css)|\.map|\.snap|\.pb\.go|_pb2\.py)$/,cn=e=>FC.test(e)||_C.test(e)||BC.test(e),ax=e=>/(^|\/)(package\.json|go\.mod|Cargo\.toml|requirements[^/]*\.txt|pyproject\.toml|Gemfile|composer\.json|pom\.xml|build\.gradle(\.kts)?)$/.test(e),lx=e=>/(^|\/)\.github\/workflows\//.test(e)||/(^|\/)(Dockerfile|docker-compose[^/]*\.ya?ml|Makefile|Jenkinsfile|\.gitlab-ci\.yml)$/.test(e)||/\.tf$/.test(e),cx=e=>/\.(md|mdx|rst|txt)$/i.test(e)||/(^|\/)docs?\//i.test(e),$C=/\b(it|test|describe|context|suite)\.skip\b|\bx(it|describe|test)\s*\(|@pytest\.mark\.skip|@unittest\.skip|\bt\.Skip\s*\(|@(Ignore|Disabled)\b/,jC=/\b(it|test|describe|context|suite)\.only\b|\bf(it|describe|test)\s*\(/,dx=e=>$C.test(e),ux=e=>jC.test(e)});var mx,UC,zu,HC,px,Vu=g(()=>{"use strict";Yr();mx=/\b(TODO|FIXME|HACK|XXX)\b/,UC=/[;{}]\s*$|^\s*(const|let|var|function|def|class|if|for|while|return|import|export|await|print)\b.*[=(]/,zu=(e,t)=>{let n=e.trim();return n===""?"blank":t&&(t.line.some(o=>n.startsWith(o))||t.block.some(([o])=>n.startsWith(o))||t.block.some(([o])=>o==="/*")&&(n.startsWith("*")||n.startsWith("*/")))?"comment":"code"},HC=(e,t)=>{let n=e.trim();for(let o of[...t.line,...t.block.flat(),"*"])if(n.startsWith(o)){n=n.slice(o.length).trim();break}return n},px=({patch:e,repoShareByLanguage:t})=>{let n=new Map,o=0,r=0,s=0,i=0,c=0,u=0;for(let m of e.files){if(m.binary||cn(m.path))continue;let f=pi(m.path);if(!f||f.line.length===0&&f.block.length===0)continue;let h=Jo(m.path),x=n.get(h)??{comment:0,code:0};for(let{text:E}of m.added){let S=zu(E,f);if(mx.test(E)&&i++,S==="blank"){s++;continue}if(S==="comment"){o++,x.comment++,f&&UC.test(HC(E,f))&&u++;continue}r++,x.code++}for(let{text:E}of m.removedLines)mx.test(E)&&c++;n.set(h,x)}let p=o+r;return{byLanguage:[...n.entries()].map(([m,f])=>({name:m,commentLines:f.comment,codeLines:f.code,share:f.comment+f.code===0?0:f.comment/(f.comment+f.code),repoShare:t?.get(m)??null})).sort((m,f)=>f.commentLines+f.codeLines-(m.commentLines+m.codeLines)),commentLines:o,codeLines:r,blankLines:s,share:p===0?0:o/p,todoLinesAdded:i,todoLinesRemoved:c,commentedOutCodeLines:u}}});var WC,pl,Ku,qC,GC,zC,fx,gx=g(()=>{"use strict";Yr();dl();WC=/\bconsole\.(log|debug|dir)\s*\(|\bdebugger\b|^\s*print\s*\(|\bfmt\.Print(ln|f)?\s*\(|\bSystem\.out\.print|\bdbg!\s*\(/,pl=6,Ku=10,qC=e=>{let t=0;for(let n of e){if(n.trim()===""||n.startsWith(" "))continue;let o=n.length-n.trimStart().length;o>0&&(t===0||o<t)&&(t=o)}return Math.min(Math.max(t,2),8)},GC=(e,t)=>{let n=e.length-e.trimStart().length;if(n===0)return 0;let o=e.slice(0,n).split(" ").length-1;return o>0?o:Math.floor(n/t)},zC=e=>{if(e.length<pl*2)return 0;let t=new Map,n=new Array(e.length).fill(!1);for(let o=0;o+pl<=e.length;o++){let r=e.slice(o,o+pl);if(r.some(c=>c.text.length<3))continue;let s=r.map(c=>c.text).join(`
109
- `),i=t.get(s);if(i===void 0){t.set(s,{...r[0],at:o});continue}if(i.file!==r[0]?.file)for(let c=0;c<pl;c++)n[i.at+c]=!0,n[o+c]=!0}return n.filter(Boolean).length},fx=({patch:e})=>{let t=[],n=[],o=[],r=!1,s=0,i=0,c=null,u=[];for(let[p,m]of e.files.entries()){if(cn(m.path)&&t.push(Rn(m)),ax(m.path)&&n.push(Rn(m)),lx(m.path)&&o.push(Rn(m)),cx(m.path)&&(r=!0),m.binary||cn(m.path))continue;let f=m.added.map(E=>E.text),h=qC(f),x=m.status!=="deleted";for(let E of f){WC.test(E)&&s++;let S=GC(E,h);S>i&&(i=S,c=Rn(m)),x&&u.push({text:E.trim(),file:p})}u.push({text:" ",file:p})}return{generatedPaths:t.slice(0,Ku),dependencyManifests:n.slice(0,Ku),buildOrCiPaths:o.slice(0,Ku),docsTouched:r,debugPrintLinesAdded:s,maxIndentLevels:i,deepestFile:c,duplicatedLines:zC(u)}}});var hx,vx=g(()=>{"use strict";Yr();hx=({patch:e,languagesBefore:t})=>{let n=new Map,o=0;for(let i of e.files){if(i.binary)continue;let c=i.addedCount+i.removed;if(cn(i.path)){o+=c;continue}let u=Jo(i.path),p=n.get(u)??{name:u,added:0,removed:0,addedInTests:0,share:0};p.added+=i.addedCount,p.removed+=i.removed,Kr(i.path)&&(p.addedInTests+=i.addedCount),n.set(u,p)}let r=[...n.values()].reduce((i,c)=>i+c.added+c.removed,0),s=[...n.values()].map(i=>({...i,share:r===0?0:(i.added+i.removed)/r})).sort((i,c)=>c.added+c.removed-(i.added+i.removed));return{languages:s,introduced:t===null?[]:s.filter(i=>!t.has(i.name)).map(i=>i.name),generatedLines:o}}});var VC,Yu,KC,yx,YC,Xu,XC,JC,bx,xx,QC,ZC,eA,Ix,Ex=g(()=>{"use strict";Ke();w();VC=200,Yu=2e5,KC=5e4,yx=25,YC=64*1024*1024,Xu="",XC=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/,JC=/^diff --git a\/(.+) b\/\1$/,bx=(e,t)=>e==="/dev/null"?null:e.startsWith(t)?e.slice(2):e,xx=(e,t)=>e===null?"added":t===null?"deleted":"modified",QC=()=>({byPath:new Map,insertions:0,deletions:0,selfChurn:0,retainedLines:0}),ZC=(e,t)=>{let n=e.byPath,o="",r=null,s=null,i=null,c=!1,u=0,p=(f,h)=>h==="modified"&&f==="added"?"added":h,m=(f,h)=>{let x=n.get(f);if(x)return x.entry.status=p(x.entry.status,h),x.entry.shas.includes(o)||x.entry.shas.push(o),x;let S={entry:{path:f,status:h,binary:!1,added:[],addedCount:0,removed:0,removedLines:[],shas:[o]},pendingByText:new Map};return n.set(f,S),S};for(let f of t.split(`
110
- `)){if(f.startsWith(Xu)){o=f.slice(Xu.length).trim(),r=null,s=null,i=null,c=!1;continue}if(f.startsWith("diff --git ")){r=null,i=null,c=!0,s=JC.exec(f)?.[1]??null;continue}if(c&&f.startsWith("Binary files ")&&s){let[,x=""]=/^Binary files (.*) differ$/.exec(f)??[],[E="",S=""]=x.split(" and ");r=m(s,xx(E==="/dev/null"?null:E,S==="/dev/null"?null:S)),r.entry.binary=!0;continue}if(c&&f.startsWith("--- ")){i=bx(f.slice(4),"a/");continue}if(c&&f.startsWith("+++ ")){let x=bx(f.slice(4),"b/"),E=x??i??s;E&&(r=m(E,xx(i,x)));continue}let h=XC.exec(f);if(h){u=Number(h[1]),c=!1;continue}if(r){if(f.startsWith("+")){let x=f.slice(1);e.insertions++,r.entry.addedCount++,e.retainedLines<Yu&&(r.entry.added.push({sha:o,line:u,text:x}),e.retainedLines++),r.pendingByText.size<KC&&r.pendingByText.set(x,(r.pendingByText.get(x)??0)+1),u++;continue}if(f.startsWith("-")){let x=f.slice(1);e.deletions++,r.entry.removed++,e.retainedLines<Yu&&(r.entry.removedLines.push({sha:o,line:0,text:x}),e.retainedLines++);let E=r.pendingByText.get(x)??0;E>0&&x.trim().length>2&&(e.selfChurn++,r.pendingByText.set(x,E-1))}}}},eA=e=>({files:[...e.byPath.values()].map(t=>t.entry),insertions:e.insertions,deletions:e.deletions,selfChurn:e.selfChurn,retainedLines:e.retainedLines}),Ix=async({repoRoot:e,shas:t})=>{if(t.length===0)return d("No commits to scan",{files:[],insertions:0,deletions:0,selfChurn:0,scannedCommits:0,truncated:!1});let n=t.slice(0,VC).reverse(),o=QC(),r=0,s=0,i=!1;for(let u=0;u<n.length;u+=yx){let p=n.slice(u,u+yx),m=await W({cwd:e,args:["-c","core.quotePath=false","show","--unified=0","--no-renames","--no-color",`--format=${Xu}%H`,...p]});if(a(m))return l(m.message);if(ZC(o,m.value.stdout),r+=m.value.stdout.length,s+=p.length,r>YC){i=!0;break}}let c=eA(o);return d("Scanned ticket patch",{files:c.files,insertions:c.insertions,deletions:c.deletions,selfChurn:c.selfChurn,scannedCommits:s,truncated:i||s<t.length||c.retainedLines>=Yu})}});var tA,nA,Rx,Sx=g(()=>{"use strict";Ke();w();Vu();Yr();tA=40,nA=/^\d{6} blob ([0-9a-f]{40})\t(.+)$/,Rx=async({repoRoot:e,sha:t})=>{let n=await Le({cwd:e,args:["-c","core.quotePath=false","ls-tree","-r",`${t}~1`]});if(n.exitCode!==0)return null;let o=new Set,r=new Map;for(let m of n.stdout.split(`
111
- `)){let f=nA.exec(m);if(!f)continue;let[,h="",x=""]=f;if(cn(x))continue;let E=Jo(x);if(o.add(E),Kr(x)||!pi(x))continue;let S=r.get(E)??[];S.length<tA&&(S.push({blob:h,path:x}),r.set(E,S))}let s=[...r.values()].flat(),i=await Dl(s.map(m=>m.blob),e);if(a(i))return{languages:o,commentShareByLanguage:new Map};let c=i.value,u=new Map;for(let{blob:m,path:f}of s){let h=c.get(m);if(h===void 0)continue;let x=pi(f),E=Jo(f),S=u.get(E)??{comment:0,code:0};for(let C of h.split(`
112
- `)){let R=zu(C,x);R==="comment"&&S.comment++,R==="code"&&S.code++}u.set(E,S)}let p=new Map;for(let[m,f]of u){let h=f.comment+f.code;h>0&&p.set(m,f.comment/h)}return{languages:o,commentShareByLanguage:p}}});var Nx,wx=g(()=>{"use strict";Yr();dl();Nx=({patch:e})=>{let t=0,n=0,o=[],r=[],s=0,i=0;for(let c of e.files)if(!(c.binary||cn(c.path))&&Kr(c.path)){t+=c.addedCount,n+=c.removed,c.status==="added"&&o.push(Rn(c)),c.status==="deleted"&&r.push(Rn(c));for(let{text:u}of c.added)dx(u)&&s++,ux(u)&&i++}return{testLinesAdded:t,testLinesRemoved:n,addedTestFiles:o,deletedTestFiles:r,skippedTestLinesAdded:s,focusedTestLinesAdded:i}}});var oA,Cx,Ax=g(()=>{"use strict";w();rx();Vu();gx();vx();Ex();Sx();wx();oA=e=>e.reduce((t,n)=>t===null||n.time<t.time?n:t,null)?.sha??null,Cx=async({repoRoot:e,ref:t,commits:n})=>{let o=await Ix({repoRoot:e,shas:n.map(c=>c.sha)});if(a(o))return l(o.message);let r=o.value,s=oA(n),i=s?await Rx({repoRoot:e,sha:s}):null;return d("Derived issue stats",{ref:t,shape:ox({commits:n,patch:r}),languages:hx({patch:r,languagesBefore:i?.languages??null}),tests:Nx({patch:r}),comments:px({patch:r,repoShareByLanguage:i?.commentShareByLanguage??null}),flags:fx({patch:r})})}});var Tx,kx=g(()=>{"use strict";Ja();w();wt();O();Tx=e=>{if(a(e))return e;let t=Me(),n=a(t)?{}:t.value.emailLinks,o=a(t)?{}:t.value.contributors,r=ym(n),s=e.value.map(i=>({...i,authorIdentity:Ry({authorName:i.author,authorEmail:i.authorEmail,owners:r,registry:o})}));return d(e.message,s)}});var rA,fi,sA,Mx,Lx=g(()=>{"use strict";w();Ax();mt();ee();kx();Qs();rA=32,fi=new Map,sA=(e,t)=>{if(fi.set(e,t),fi.size>rA){let n=fi.keys().next();n.done||fi.delete(n.value)}return t},Mx=async(e={idOrRef:""})=>{let t=e.idOrRef.trim();if(!t)return l("idOrRef must not be empty");let n=t.length>7?V(t):t.toUpperCase(),o=we(e.repoRoot??process.cwd());if(a(o))return l(o.message);let r=o.value,s=Tx(await Lr({repoRoot:r,ref:n}));if(a(s))return l(s.message);let i=s.value.map(m=>({sha:m.sha,time:m.time,author:m.authorIdentity?.resolved?m.authorIdentity.name:m.author,subject:m.subject})),c=[r,n,i.map(m=>`${m.sha}:${m.author}`).join(",")].join(" "),u=fi.get(c);if(u)return d("Derived issue stats",u);let p=await Cx({repoRoot:r,ref:n,commits:i});return a(p)?l(p.message):d("Derived issue stats",sA(c,p.value))}});var Xr,Ju,Px=g(()=>{"use strict";Xr=".claude/skills/epiq/SKILL.md",Ju="---\nname: epiq\ndescription: Workflow rules for working the epiq issue board \u2014 use the epiq MCP, sync on demand, scope tickets small, keep status/tags accurate, and communicate via comments.\n---\n\n# Epiq board workflow\n\n- **Never test against the real board.** Point any dev server, manual test or test run at a throwaway project, never at this repo's own. Deleting test tickets afterwards does not undo the events. Stop the dev server when you're done rather than leaving it autosyncing.\n- **Use the epiq MCP tools** (`epiq_*`) for all board operations \u2014 never the `epiq` CLI or hand-edited state files.\n- **Never edit the state branch directly.** Don't check it out, don't write to its worktree, don't touch the event log or any file under it by hand or by script \u2014 go through the MCP for every read and write. The event log is the system of record: an edit made outside it bypasses validation and ordering, and can corrupt history in ways no later fix can undo.\n- **Sync is on-demand only.** MCP reads/writes operate on local state and never pull/push automatically. Call `epiq_sync` explicitly when you need the latest remote state or want to publish local changes.\n- **Break work into small, scoped tickets.** One ticket per independent unit of work, not one giant ticket for a whole feature/epic. Small tickets move through the board cleanly and are easier to review.\n- **A small request tightly coupled to a ticket goes into that ticket, not a new one.** When the user asks for a tweak that only makes sense as part of work a ticket already covers \u2014 halving a limit it just introduced, moving a control it just added \u2014 do not file a fresh ticket for it. Record the new requirement as a comment on the original ticket and fold it into the description, move the ticket back to Ongoing if it had already reached Done, prefix the follow-up's commits with that ticket's ref, and add a further `Solution:` comment when it lands, so the ticket's own commit list tells the whole story. `QPPR7PE` is what this avoids: a one-line follow-up to `MBB6WY5` (halve the log cap it had just introduced) that now lives on a ticket of its own. The original does not have to be the ticket you took this session: any ticket open on the board and assigned to you counts. A new ticket is for work that stands on its own \u2014 that someone else could pick up cold, or that needs more than a line or two to describe.\n- **Keep the status column current as work progresses**\n- **Assign the ticket to yourself when you pick it up**, alongside moving it to Ongoing \u2014 so the board shows who is on what, not just what is in flight.\n- **A ticket you file for work you will do this session is assigned to you as you file it.** Filing it unassigned and picking it up a minute later leaves a window where the board shows nobody on it. Picking up a ticket assigned to somebody else is fine \u2014 but ask the user first: it may be mid-flight in another session, and the assignee is what says so.\n- **Take a name as soon as this skill loads, and say it.** Your board identity is `provider/human-name` \u2014 the model provider, a slash, then a short human first name: `claude/peter`, `codex/fred`. Announce it as your first line, exactly `Assuming claude/peter`, and work under it for the whole session so the log reads \"claude/peter did X\" rather than signing the user's name to your work. Before inventing one, call `epiq_contributor_list` and reuse an existing identity for your provider if there is one \u2014 a name is permanent once it has authored anything (`tombstoneContributor` refuses authors), and each new one adds a contributor and an event log file forever. Keep the name stable across sessions; never rename yourself mid-session.\n- **Make the name true with `epiq_actor_assume`, before your first board write.** Announcing alone changes nothing: the writes would still be signed with the user's name. The tool takes the identity for the rest of the session and registers it, so the board carries `claude/peter` rather than the sanitized `claude-peter` the log file name would give. It is idempotent, so re-announcing is free; if it refuses because the server was launched under a name, that name wins \u2014 work under the one it reports and say so. Never claim an attribution the tool did not confirm.\n- **Boot your own MCP instance, and never share one.** `epiq_actor_assume` binds the name to the server process it is called on, so two sessions on one server \u2014 or a session on the user's own instance \u2014 would sign every write with whichever name was assumed last, and the log would fold them into one contributor. Every session therefore needs a server process of its own before its first board call: the one Claude Code spawns for the session counts, and if that never connected (a `CONNECT_TIMEOUT` at boot), start one yourself \u2014 `npx -y -p epiq@latest epiq-mcp` speaks MCP JSON-RPC over stdio, so a small script holding that process and forwarding `tools/call` requests is enough \u2014 rather than waiting on the user or borrowing another session's. Assume the name on *that* process; a restart forgets it, so assume it again before the next write. Kill what you started when the session ends, including the `epiq-mcp` child, which outlives its parent.\n- **When other agents may be running, ask which name to take rather than picking one.** Nothing stops two live agents answering to one name \u2014 the log is a CRDT and takes concurrent writers happily, so they would converge into one indistinguishable identity rather than fail. Another session is likely whenever there is more than one `epiq-mcp` process, another worktree with recent changes, or the user says so; in that case list the existing names for your provider from `epiq_contributor_list` and ask the user which one is free, before `epiq_actor_assume` \u2014 a name once assumed binds the server process, and a second name is refused until it restarts. Ask with the names in the question, not \"which name?\": the user is choosing between identities they can see on the board.\n- **Name the terminal window after the identity.** Several sessions look alike; the name in the tab is how the user tells which window is `claude/peter`. The session cannot reach the terminal itself \u2014 the shell it runs has no tty \u2014 so put the request in the announcement line: `Assuming claude/peter \u2014 please /rename claude/peter so this window carries the name.`\n- **Prefix commits with the ticket ref. **Retrieve the ref programmatically, NEVER DERIVE IT.\\*\\* Read the `ref` field off the MCP response (`epiq_issue_list` and `epiq_board_list` include it on every entry). This is what link-by-reference feature matches on.\n- **Work in a worktree, and leave the root checkout alone.** Take one before the first edit (`EnterWorktree`, or `git worktree add .claude/worktrees/<ref>-<slug>` for a branch that already exists), and never check a feature branch out at the root: the root is where `main` belongs and where the user checks it out themselves, and a branch checked out anywhere is unavailable everywhere else. For the same reason `main` never goes *into* a worktree. Several sessions share this repository at once, so a shared checkout also means one session's `checkout` or `reset` quietly discarding another's work. A fresh worktree needs its own `npm install` before the hooks and suites will run there.\n- **Never work on main, and never merge into it locally. Every change reaches main through a pull request.** Branch before the first edit, push the branch, open the PR, let the gate run, then integrate it. A local merge into `main` looks like it worked and is invisible to everyone else: the work is on nobody's remote, no PR ran the gate over it, and it is one `git fetch origin +main:main` away from vanishing from the branch you are sitting on. That has already happened here \u2014 a tag-filter feature and a scrubber-URL feature lived only in one machine's local `main` for a day, and disappeared the moment somebody synced main with the remote. If you find yourself with commits on local `main`, move them onto a branch and open a PR before doing anything else.\n- **Always rebase onto the target, never merge into it.** Rebase the branch onto the target first, then integrate with a rebase merge \u2014 `gh pr merge --rebase`, never `--merge`. Main stays a flat sequence of ref-prefixed commits, which is what the commit\u2194ticket linking reads. A merge commit adds a subject carrying no ref and buries the branch's commits behind it.\n- **Squashing the branch down first is fine \u2014 one commit per ticket ref.** A branch's worth of fixups is history nobody needs on main, so collapsing it into a single commit (`git rebase -i`, or `gh pr merge --squash` with a ref-prefixed subject) is welcome, provided every commit that lands still opens with its ticket's ref. What the linking cannot survive is a squash *across* refs: fold two tickets' commits into one subject and one of them loses its commits for good. So a branch carrying two refs squashes to two commits, not one \u2014 and check the resulting subject before integrating, because `--squash` defaults to the PR title, which is only right if the title carries the ref.\n- **The git user is the sole author of every commit you write.** Commit under the repo's configured `user.name` / `user.email` and nothing else: no `Co-Authored-By:` line, no `Claude-Session:` line, no `\u{1F916} Generated with` footer, and never an `--author` override naming Claude or a tool. The commit body ends with the last line of prose. This holds for amends and rebases too \u2014 check `git log --format='%an <%ae>%n%b'` over the branch before pushing, because a trailer added by a default template survives a rebase and reaches main unnoticed. It does **not** license rewriting anyone else's authorship: commits by other contributors keep their author, and reassigning them would both misattribute their work and mean force-pushing main.\n- **Tag tickets properly.** Reuse existing tags where they fit (check current issues/tags first) instead of inventing near-duplicates.\n- **Read the ticket's comments before starting, not just its description.** The description is what was known when the ticket was written; comments carry later context \u2014 narrowed scope, a decision already taken, a dead end someone hit, a correction to the original diagnosis. Working from the description alone risks redoing settled work or implementing something that was already ruled out.\n- **Use comments to communicate deviations.** If the work diverges from what the ticket describes \u2014 scope changes, findings, blockers, test results \u2014 record it as a comment on the ticket, not just in chat.\n- When a ticket is done, **Document the outcome in a comment starting with `Solution:`.** Use that exact prefix as the comment's opening line, so `^Solution:` finds every resolved ticket on the board. Say what actually resolved it \u2014 the commit, the approach taken, and anything a reader would otherwise have to reverse-engineer from the diff; a bare commit hash is not a solution. Use the same prefix when a ticket is closed _without_ a code change, and say why.\n- **Attach a screenshot only when a picture carries what words cannot** \u2014 a layout that has to be seen, a rendering bug, a chart whose shape is the point. It is the special case, not a routine part of a `Solution:` comment: most outcomes are better described than photographed, and a screenshot of something a sentence already covers costs everyone the bytes below. When one does earn its place, use `epiq_issue_attachment_add` (it takes a file path) and paste the `markdown` it returns into the comment.\n- **Crop and compress it first.** `epiq_issue_attachment_add` stores the file exactly as it finds it \u2014 only the GUI compresses on upload \u2014 so a raw full-screen capture goes in at full size, up to the 500 KB cap. The blob lands in `.epiq/media/` on the state branch, replicates to every clone, and is never removed: deleting an attachment writes a tombstone and the bytes stay, so time travel can still resolve them. Crop to the region that makes the point, scale it down, and land well under the cap rather than against it. An oversized image is permanent, for everybody \u2014 the same reason the text limits exist.\n- **Be concise.** Titles, descriptions, and comments should be scannable, not essays.\n- If a ticket is blocked, **record the blocker in a comment** and move it to Blocked (or tag it blocked if there is no Blocked column).\n- If a you decide to take a new approach, make sure to document the fork in a new comment, and tag the ticket with a \"fork\" tag, **update the description** to reflect the new plan. Don't leave it as-is and expect readers to infer the change from comments.\n- **Park decisions that are the user's to make.** A design fork, a change with blast radius beyond its ticket, anything you'd want a second opinion on \u2014 file a ticket tagged `human-input-needed` naming the options and the trade-off, then carry on with whatever doesn't depend on the answer. Settling it alone in chat, while nobody is reading, is a decision the user never made.\n- **Findings from a code review get their own tickets**, tagged `from-review`, with the description saying which branch or PR the review covered \u2014 so the provenance survives even if the tag doesn't.\n"});import fl from"node:fs";import Dx from"node:path";var Ox,Fx=g(()=>{"use strict";rt();w();Px();Ox=async(e={})=>{let t=await kt(e.repoRoot??process.cwd());if(a(t))return l(t.message);let n=Dx.join(t.value,Xr);if(fl.existsSync(n)){if(fl.readFileSync(n,"utf8")===Ju)return d("Skill already installed and up to date",{path:n,written:!1});if(!e.force)return l(`${Xr} already exists and differs from the bundled skill. Pass force:true to overwrite it.`)}try{fl.mkdirSync(Dx.dirname(n),{recursive:!0}),fl.writeFileSync(n,Ju,"utf8")}catch(o){return l(o instanceof Error?`Failed to write ${Xr}: ${o.message}`:`Failed to write ${Xr}`)}return d(`Installed skill at ${Xr}`,{path:n,written:!0})}});var Bx={};Zr(Bx,{createMcpServer:()=>_x,resultJson:()=>Qu,startMcpServer:()=>cA});import{McpServer as aA}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as lA}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as y}from"zod";var Qu,re,_x,cA,$x=g(()=>{"use strict";w();$n();Qb();qu();nx();Lx();Fx();ci();Qu=e=>({isError:a(e),content:[{type:"text",text:JSON.stringify(e,null,2)}]}),re=e=>t=>Fb(async()=>Qu(await e(t))),_x=()=>{let e=new aA({name:"epiq",version:"0.2.30"});return e.registerTool("epiq_state_get",{description:"Get the full current Epiq state, including nodes and event log",inputSchema:y.object({repoRoot:y.string().optional()})},re(lu)),e.registerTool("epiq_issue_list",{description:"List Epiq issues. Narrow with boardId, swimlaneId, tag, assignee or query (matched against title and description), and pass brief to get id, ref, title, swimlane, tag names and assignee names only \u2014 descriptions are the bulk of a board. Read one ticket with epiq_issue_get.",inputSchema:y.object({repoRoot:y.string().optional(),includeClosed:y.boolean().optional(),boardId:y.string().optional(),swimlaneId:y.string().optional(),tag:y.string().optional(),assignee:y.string().optional(),query:y.string().optional(),brief:y.boolean().optional()})},re(mu)),e.registerTool("epiq_issue_get",{description:"Get one Epiq issue by its full id or its 7-character ref, with its comments in log order. Use this rather than listing the whole board when you already know which issue you want, and rather than epiq_state_get to read a thread.",inputSchema:y.object({idOrRef:y.string().min(1),repoRoot:y.string().optional()})},re(uu)),e.registerTool("epiq_issue_stats",{description:"Code stats for one issue, derived from the commits whose subject carries its ref: how big the change is, how it is spread, and how much of it the ticket spent rewriting its own work. Reads git only \u2014 it never touches the board \u2014 so it is safe to call while other work is in flight. No commits carrying the ref reads as a change of zero size, which is not the same as no work: a commit only links if its subject opens with the ref.",inputSchema:y.object({idOrRef:y.string().min(1),repoRoot:y.string().optional()})},async t=>Qu(await Mx(t))),e.registerTool("epiq_board_list",{description:"List Epiq boards",inputSchema:y.object({repoRoot:y.string().optional()})},re(bu)),e.registerTool("epiq_board_create",{description:"Create an Epiq board. It comes out without swimlanes; add them with epiq_swimlane_create. Refused while time travelling.",inputSchema:y.object({repoRoot:y.string().optional(),title:y.string().min(1).max(300)})},re(xu)),e.registerTool("epiq_swimlane_list",{description:"List Epiq swimlanes",inputSchema:y.object({repoRoot:y.string().optional(),boardId:y.string().optional()})},re(Eu)),e.registerTool("epiq_swimlane_create",{description:"Create an Epiq swimlane on a board",inputSchema:y.object({repoRoot:y.string().optional(),boardId:y.string().min(1),title:y.string().min(1).max(300)})},re(Ru)),e.registerTool("epiq_swimlane_title_edit",{description:"Edit an Epiq swimlane title",inputSchema:y.object({repoRoot:y.string().optional(),swimlaneId:y.string().min(1),title:y.string().min(1).max(300)})},re(Su)),e.registerTool("epiq_board_title_edit",{description:"Edit an Epiq board title. Refused while time travelling.",inputSchema:y.object({repoRoot:y.string().optional(),boardId:y.string().min(1),title:y.string().min(1).max(300)})},re(Iu)),e.registerTool("epiq_swimlane_move",{description:"Move/reorder an Epiq swimlane, optionally to another board",inputSchema:y.object({repoRoot:y.string().optional(),swimlaneId:y.string().min(1),boardId:y.string().min(1),position:y.discriminatedUnion("at",[y.object({at:y.literal("start")}),y.object({at:y.literal("end")}),y.object({at:y.literal("before"),sibling:y.string().min(1)}),y.object({at:y.literal("after"),sibling:y.string().min(1)})]).optional()})},re(Nu)),e.registerTool("epiq_swimlane_delete",{description:"Delete (archive) an Epiq swimlane. This also archives every issue contained in it.",inputSchema:y.object({repoRoot:y.string().optional(),swimlaneId:y.string().min(1)})},re(wu)),e.registerTool("epiq_issue_create",{description:"Create an Epiq issue in a swimlane: parentId is the swimlane id (epiq_swimlane_list), never a board id. Optionally set description, tags, and assignees atomically in the same call instead of separate follow-up edits.",inputSchema:y.object({title:y.string().min(1).max(300),parentId:y.string().min(1),repoRoot:y.string().optional(),description:y.string().max(2e4).optional(),tagNames:y.array(y.string().max(60)).max(20).optional(),assigneeNames:y.array(y.string().max(80)).max(20).optional()})},re(pu)),e.registerTool("epiq_issue_description_edit",{description:"Edit the markdown description of an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),description:y.string().max(2e4),repoRoot:y.string().optional()})},re(vu)),e.registerTool("epiq_issue_title_edit",{description:"Edit the title of an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),title:y.string().min(1).max(300),repoRoot:y.string().optional()})},re(yu)),e.registerTool("epiq_issue_tag_add",{description:"Add a tag to an Epiq issue, or to many at once with issueIds, creating the tag if it does not exist",inputSchema:y.object({issueId:y.string().min(1).optional(),issueIds:y.array(y.string().min(1)).min(1).max(200).optional(),tagName:y.string().min(1).max(60),repoRoot:y.string().optional()})},re(Cu)),e.registerTool("epiq_issue_tag_remove",{description:"Remove a tag from an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),tagId:y.string().min(1),repoRoot:y.string().optional()})},re(ku)),e.registerTool("epiq_contributor_list",{description:"List people who can be assigned: everyone who has authored an event (optionally scoped to one board) unioned with the contributor registry. Use these ids with epiq_issue_assignee_add rather than assigning by name.",inputSchema:y.object({boardId:y.string().min(1).optional(),repoRoot:y.string().optional()})},re(Ou)),e.registerTool("epiq_contributor_remove",{description:"Remove an external contributor from the assignee suggestion lists. Their id and every reference to it survive, so existing assignments stay intact and the event log is untouched. Refused for anyone who has authored events, since their name is in the log regardless.",inputSchema:y.object({contributorId:y.string().min(1),repoRoot:y.string().optional()})},re(Pu)),e.registerTool("epiq_tag_remove",{description:"Delete a tag from the whole workspace. It disappears from every ticket, picker and filter, but its id and history stay in the event log, and the name is free for a new tag.",inputSchema:y.object({tagId:y.string().min(1),repoRoot:y.string().optional()})},re(Au)),e.registerTool("epiq_tag_restore",{description:"Put back a tag deleted with epiq_tag_remove, on every ticket that still carried it.",inputSchema:y.object({tagId:y.string().min(1),repoRoot:y.string().optional()})},re(Tu)),e.registerTool("epiq_contributor_restore",{description:"Put a contributor removed with epiq_contributor_remove back into the suggestion lists, under the name they were created with.",inputSchema:y.object({contributorId:y.string().min(1),repoRoot:y.string().optional()})},re(Du)),e.registerTool("epiq_issue_assignee_add",{description:"Assign a contributor to an Epiq issue. Pass self:true to assign yourself. Prefer assigneeId otherwise, which assigns a known contributor (from the registry or the event log) and fails if the id is unknown. assigneeName matches an existing contributor by name; to create somebody new from a name you must also pass createUnlinked, which adds them as an external (non-contributor) assignee.",inputSchema:y.object({issueId:y.string().min(1),assigneeId:y.string().min(1).optional(),self:y.boolean().optional(),assigneeName:y.string().min(1).max(80).optional(),createUnlinked:y.boolean().optional(),repoRoot:y.string().optional()})},re(Lu)),e.registerTool("epiq_issue_assignee_remove",{description:"Remove an assignee from an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),assigneeId:y.string().min(1),repoRoot:y.string().optional()})},re(Fu)),e.registerTool("epiq_issue_comment_add",{description:"Add a comment to an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),body:y.string().min(1).max(4e3),repoRoot:y.string().optional()})},re(_u)),e.registerTool("epiq_issue_attachment_add",{description:"Attach an image file to an Epiq issue. Returns `markdown` \u2014 paste it into a comment or description body to render the image inline.",inputSchema:y.object({issueId:y.string().min(1),filePath:y.string().min(1),name:y.string().min(1).max(200).optional(),repoRoot:y.string().optional()})},re(iu)),e.registerTool("epiq_issue_comment_delete",{description:"Delete a comment from an Epiq issue",inputSchema:y.object({commentId:y.string().min(1),repoRoot:y.string().optional()})},re(Bu)),e.registerTool("epiq_issue_comment_edit",{description:"Replace the body of one of your own comments on an Epiq issue",inputSchema:y.object({commentId:y.string().min(1),body:y.string().min(1).max(4e3),repoRoot:y.string().optional()})},re($u)),e.registerTool("epiq_issue_reopen",{description:"Reopen a closed Epiq issue, restoring it to its previous swimlane",inputSchema:y.object({issueId:y.string().min(1),repoRoot:y.string().optional()})},re(gu)),e.registerTool("epiq_issue_close",{description:"Close an Epiq issue, or many at once with issueIds \u2014 one call, an outcome per ticket",inputSchema:y.object({issueId:y.string().min(1).optional(),issueIds:y.array(y.string().min(1)).min(1).max(200).optional(),repoRoot:y.string().optional()})},re(fu)),e.registerTool("epiq_issue_move",{description:"Move an Epiq issue to another swimlane (parentId is the swimlane id), or many at once with issueIds \u2014 one call, an outcome per ticket",inputSchema:y.object({issueId:y.string().min(1).optional(),issueIds:y.array(y.string().min(1)).min(1).max(200).optional(),parentId:y.string().min(1),position:y.discriminatedUnion("at",[y.object({at:y.literal("start")}),y.object({at:y.literal("end")}),y.object({at:y.literal("before"),sibling:y.string().min(1)}),y.object({at:y.literal("after"),sibling:y.string().min(1)})]).optional(),repoRoot:y.string().optional()})},re(hu)),e.registerTool("epiq_actor_assume",{description:'Take a board identity for the rest of this session, so your writes are attributed to you rather than to the user. Pass the name you announced \u2014 the model provider, a slash, then a short human first name, e.g. "claude/peter". Takes effect on the very next write; no relaunch. A name the server was launched with wins, and re-assuming the same name is harmless. Reuse an existing agent identity (epiq_contributor_list) before inventing one: a name is permanent once it has authored anything.',inputSchema:y.object({name:y.string().min(1).max(80),repoRoot:y.string().optional()})},re(Mu)),e.registerTool("epiq_contributor_email_link",{description:"Bind a git author address to a contributor, so their commits and their board activity read as one person. Defaults to you; pass contributorId to link a colleague who does not use epiq, whose commits otherwise never resolve. The address the repository's git is configured with links itself on your first write, so this is for older addresses and for other people. An address two contributors claim resolves to neither, and the reply says so.",inputSchema:y.object({email:y.string().min(1).max(254),contributorId:y.string().min(1).optional(),repoRoot:y.string().optional()})},re(ju)),e.registerTool("epiq_contributor_email_unlink",{description:"Retract a link between a git address and a contributor. Allowed only to whoever wrote the link and to the contributor it names, so nobody can strip links that are neither theirs nor about them. Forward-only: the address stops resolving and the event stays in the log.",inputSchema:y.object({email:y.string().min(1).max(254),contributorId:y.string().min(1).optional(),repoRoot:y.string().optional()})},re(Uu)),e.registerTool("epiq_contributor_email_suggest",{description:"Addresses in this repository's history that look like yours and nobody has claimed, for the user to confirm. Run it once after this feature reaches a board with history: the address git is configured with links itself, but older ones do not, and until they are linked those commits show a raw git name. Show the list and link only what the user confirms \u2014 each link is permanent and replicates to every clone.",inputSchema:y.object({repoRoot:y.string().optional()})},re(Wu)),e.registerTool("epiq_contributor_email_list",{description:"Every git address the board has bound to a contributor, and who holds it. An address with more than one claimant is flagged contested and resolves to none of them, which is the state nothing else reports.",inputSchema:y.object({repoRoot:y.string().optional()})},re(Hu)),e.registerTool("epiq_project_init",{description:`Set up a new Epiq board in a git repository without the TUI. Runs in the repository at repoRoot (default: the current directory), which must have no uncommitted changes. The first time on a machine it also records the user's setup: ask the user for userName (how they want to appear on the board), preferredEditor (e.g. "vim" or "code --wait") and autoSync (whether the TUI and GUI sync with the remote on their own) and pass them here; called without them it fails naming what is still missing, keeping whatever was given. It fills in answers the machine lacks and refuses to change ones it has. Pass the user's name, never your own agent identity. Commits the state branch and .epiq/project.json and tries to push both; a push that fails is a warning, not an error. Afterwards the other tools work in that repository.`,inputSchema:y.object({repoRoot:y.string().optional(),userName:y.string().min(1).max(80).optional(),preferredEditor:y.string().min(1).max(200).optional(),autoSync:y.boolean().optional()})},re(tx)),e.registerTool("epiq_skill_install",{description:"Write the official Epiq workflow skill into the repository at .claude/skills/epiq/SKILL.md, so agents working there follow the same board rules. Run it after epiq_project_init, not before: the new file is an uncommitted change that init refuses. In a project that already has a board, run it any time. Refuses to overwrite a differing file unless force is true; an identical file is left alone.",inputSchema:y.object({repoRoot:y.string().optional(),force:y.boolean().optional()})},re(Ox)),e.registerTool("epiq_sync",{description:"Sync Epiq state with the configured Git remote (pull remote changes and push local ones). Other Epiq MCP tools only read and write local state and never sync automatically \u2014 call this on demand when you need to see or publish the latest remote changes.",inputSchema:y.object({repoRoot:y.string().optional()})},re(cu)),e},cA=async()=>{let e=_x(),t=new lA;await e.connect(t)}});process.env.EPIQ_MCP="true";console.log=console.error;console.info=console.error;console.debug=console.error;console.warn=console.error;var{applyActorNameArgument:dA}=await Promise.resolve().then(()=>(vo(),sm)),{isFail:uA}=await Promise.resolve().then(()=>(w(),nm)),{parseMcpArgs:mA}=await Promise.resolve().then(()=>(lm(),am)),Jr=mA(process.argv.slice(2));Jr.kind==="error"&&(console.error(Jr.message),process.exit(1));Jr.kind==="print"&&(process.stdout.write(Jr.text),process.exit(0));if(Jr.kind==="name"){let e=dA(Jr.name,"The name argument");uA(e)&&(console.error(e.message),process.exit(1))}var{setVirtualNodesEnabled:pA}=await Promise.resolve().then(()=>(ic(),Lb));pA(!1);var{startMcpServer:fA}=await Promise.resolve().then(()=>($x(),Bx));await fA();
101
+ `,zd.writeFileSync(t,n,"utf8"),ce.info(`Added ${s.join(", ")} to .gitignore (epiq local state)`),d("Local epiq paths ignored",!0)}});import AC from"node:fs";import Vd from"node:path";var TC,ue,Za,kC,MC,Kd=g(()=>{"use strict";Vv();Oi();rt();Ke();Ys();jr();$();_r();N();ee();Zt();Vc();TC=async e=>{let t=await W({cwd:e,args:["status","--porcelain"]});return a(t)?t:d("Checked git diff",t.value.stdout.split(`
102
+ `).filter(n=>n.trim().length>0).map(n=>n.slice(3)))},ue=(e,t)=>l(`[${e}] ${t}`),Za=async({cwd:e,user:t})=>{let n=Ui(),r=await kt(e);if(a(r))return ue(1,r.message);let o=r.value,s=await Qm(o);if(a(s))return ue(2,s.message);if(s.value)return ue(2,`Cannot initialize Epiq while a git operation is in progress: ${s.value}`);let i=await TC(o);if(a(i))return ue(2.5,i.message);if(i.value.length>0)return ue(3,`Cannot initialize Epiq with uncommitted changes (${i.value.join(", ")}). Commit or stash your changes first.`);if(bs(o))return ue(4,"Epiq project already initialized");let{userId:c,userName:u}=t;if(!c||!u)return ue(5,"Missing Epiq user id");let p=await nh(o);if(a(p))return ue(6,p.message);let m=n.stateBranch,f=await Fi({repoRoot:o,branch:m});if(a(f))return ue(6,f.message);if(f.value)return ue(6,`State branch already exists: ${m}`);let h=await kC({repoRoot:o,stateBranch:m});if(a(h))return ue(6,h.message);if(h.value)return MC({repoRoot:o,stateBranch:m});let b=await Yc({repoRoot:o,stateBranchName:m});if(a(b))return ue(6,b.message);let E=vs();if(a(E))return ue(7,E.message);let S=Vd.join(Nr(),n.projectId),w=await ir({repoRoot:o,stateBranchRoot:S,stateBranchName:m});if(a(w))return ue(8,w.message);let R=Vd.join(S,".epiq");AC.mkdirSync(R,{recursive:!0});let k=Wg({userId:c,userName:u});if(a(k))return ue(9,k.message);for(let dI of k.value){let gm=Ig({event:dI,rootDir:S});if(a(gm))return ue(9,gm.message)}let M=rr({userId:c}),F=aa(S,M);if(a(F))return ue(9,F.message);let j=zc(S,n);if(a(j))return ue(9,j.message);let z=await Sa({stateBranchRoot:S,eventFileName:M});if(a(z))return ue(10,z.message);let J=await Ne.stage({cwd:S,pathspec:[st]});if(a(J))return ue(10,J.message);let se=await so({cwd:S,message:"[epiq:init]"});if(a(se))return ue(10,se.message);let ze=await zv(o);if(a(ze))return ue(11,ze.message);let q=Zl({repoRoot:o,fileContents:n});if(a(q))return ue(12,q.message);let le=await Ne.stage({cwd:o,pathspec:[".epiq/project.json",".gitignore"]});if(a(le))return ue(13,le.message);let gt=await Ne.commit({cwd:o,message:"[epiq:init-project]",pathspec:[".epiq/project.json",".gitignore"]});if(a(gt))return ue(13,gt.message);let ns=[],pm=await W({cwd:o,args:["push","-u","origin","HEAD"]});a(pm)&&ns.push(`[init:14] ${pm.message}`);let fm=await Ks({repoRoot:o,stateBranchRoot:S});return a(fm)&&ns.push(`[init:15] ${fm.message}`),d("Project initialized",{repoRoot:o,projectId:n.projectId,stateBranch:m,stateBranchRoot:S,defaultEvents:k.value,warnings:ns})},kC=async({repoRoot:e,stateBranch:t})=>{let n=await Mn({repoRoot:e});if(a(n))return l(n.message);if(!n.value)return d("No remote",!1);let r=await ps({repoRoot:e,branch:t});return a(r)?l(`Could not ask origin whether ${t} exists: ${r.message}`):r},MC=async({repoRoot:e,stateBranch:t})=>{let n=await W({cwd:e,args:["fetch","origin",t]});if(a(n))return ue(6,n.message);let r=await W({cwd:e,args:["show",`origin/${t}:${st}`]});if(a(r))return ue(6,[`This repository is already an epiq project: origin has the state branch ${t}.`,"Initialising again would mint a second id for the same board.","","The branch was written before branches carried their identity, so restore",`${st} from a checkout that has it, for example:`,"",` git show origin/main:${st} > ${st}`,"","and commit it; every later boot then stamps the branch, and the next clone adopts it."].join(`
103
+ `));let o;try{o=JSON.parse(r.value.stdout)}catch(E){return ue(6,`The identity on origin/${t} is not readable: ${E instanceof Error?E.message:String(E)}`)}let s=Zl({repoRoot:e,fileContents:o});if(a(s))return ue(12,s.message);let i=await Ne.stage({cwd:e,pathspec:[st]});if(a(i))return ue(13,i.message);let c=await Ne.commit({cwd:e,message:"[epiq:adopt-project]",pathspec:[st]});if(a(c))return ue(13,c.message);let u=vs();if(a(u))return ue(7,u.message);let p=Vd.join(Nr(),o.projectId),m=await Vs({repoRoot:e,stateBranchName:t});if(a(m))return ue(8,m.message);let f=await ir({repoRoot:e,stateBranchRoot:p,stateBranchName:t});if(a(f))return ue(8,f.message);let h=[],b=await W({cwd:e,args:["push","-u","origin","HEAD"]});return a(b)&&h.push(`[init:14] ${b.message}`),d("Adopted the project origin already holds",{repoRoot:e,projectId:o.projectId,stateBranch:o.stateBranch,stateBranchRoot:p,defaultEvents:[],warnings:h})}});var li,Kv,Yv=g(()=>{"use strict";It();wr();$();N();Kd();ge();Ue();D();li=(e,t)=>l(`[${e}] ${t}`),Kv=async()=>{ne("");let e=Ns();if(!e.isSetupDone||!e.userName)return li(5,"Missing Epiq user configuration (userId / userName). Run setup first.");let t=de(),n=t.userName,r=t.userId;if(!r||!n)return li(5,"Missing Epiq user id");let o=await Za({cwd:process.cwd(),user:{userId:r,userName:n}});if(a(o))return o;let s="Project initialized!";for(let h of o.value.warnings)s+=` Warn: ${h}`;let c=Fn(o.value.defaultEvents).filter(a);if(c.length>0)return li(16,c.map(h=>h.message).join(`
104
+ `));let u=ke();if(a(u))return li(16,u.message);let{rootNodeId:p,nodes:m}=u.value,f=m[p];return f?(H.navigate({contextNode:f,selectedIndex:0}),A({hasProjectDefinition:!0}),d(s,null)):li(16,"Unable to resolve initialized root node")}});import{ulid as LC}from"ulid";function Xd(e){let t=Jv();if(a(t))return t;let{contextNode:n,nodes:r}=v();if(!n.parentNodeId)return l("Missing parent node id");let o=r[n.parentNodeId];if(!o)return l("Missing parent node");let s=Me(o.id),i=s.findIndex(({id:p})=>p===n.id);if(i<0)return l("Current node not found among siblings");let c=s[i+e];if(!c)return l("Missing sibling node");let u=Qv({id:t.value.id,parentId:c.id,position:{at:"end"}});return a(u)?u:Zv(u.value)}function di(e,t=1){let n=Jv();if(a(n))return n;let{contextNode:r,selectedIndex:o}=v(),s=Me(r.id),i=Math.min(Math.max(o+e*t,0),s.length-1),c=i===o?void 0:s[i];if(!c)return l("Missing sibling node");let u=Qv({id:n.value.id,parentId:r.id,position:{at:e===1?"after":"before",sibling:c.id}});return a(u)?u:Zv(u.value)}var Xv,ln,ci,Jv,Yd,Qv,Zv,Jd=g(()=>{"use strict";$();$();N();jt();D();Xv=null,ln=()=>structuredClone(Xv),ci=e=>{Xv=e},Jv=()=>{let{contextNode:e,selectedIndex:t}=v(),r=Me(e.id)[t];return r?d("Resolved selected child",r):l("Target node not found")},Yd=({id:e,parentId:t,position:n={at:"end"}})=>{let r=Me(t).filter(o=>o.id!==e);return ya(r,n)},Qv=({id:e,parentId:t,position:n={at:"end"}})=>{let r=he();if(a(r))return l("Unable to resolve user ID");let o=Yd({parentId:t,id:e,position:n});return a(o)?o:d("Created pending move state",{id:LC(),...r.value,action:"move.node",payload:{id:e,parent:t,rank:o.value.rank}})},Zv=e=>{ci(e);let t=Hs(e,!0);return a(t)?t:d("Node moved successfully",t.value)}});import{ulid as PC}from"ulid";var ey,Wo,ty,ny=g(()=>{"use strict";It();Jd();$();$();$t();Oe();N();jt();ge();D();ee();ey=()=>{let e=ln();if(!e)return l("No pending move state");let t=e.payload.id,n=e.payload.parent,r=v().nodes[n];if(!r)return l("Move parent not found");let o=Me(n).findIndex(s=>s.id===t);return o===-1?l("Moved node not found among rendered children"):(H.navigate({contextNode:r,selectedIndex:o}),d("Synchronized navigation to moved node",null))},Wo=(e,t="Moved preview")=>{if(a(e))return ln()&&A({mode:x.MOVE}),e;let n=ey();return a(n)?n:(A({mode:x.MOVE}),d(t,null))},ty=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let{modifier:t}=fe().commandMeta,{contextNode:n,selectedIndex:r}=v(),o=Me(n.id)[r];if(!o)return A({mode:x.DEFAULT}),l("No move target");if(t==="start"){if(o.readonly)return l("Target node is read-only");if(r===-1)return l("No item selected");if(!o.parentNodeId)return l("Target has no parent");let s=Me(o.parentNodeId),i=s.findIndex(({id:f})=>f===o.id);if(i===-1)return l("Target not found among siblings");let c=s[i-1],u=s[i+1],p=u!=null?{at:"before",sibling:u.id}:c!=null?{at:"after",sibling:c.id}:{at:"start"},m=Yd({parentId:o.parentNodeId,id:o.id,position:p});return a(m)?m:(ci({id:PC(),action:"move.node",payload:{id:o.id,parent:o.parentNodeId,rank:m.value.rank},...O(e.value)}),A({mode:x.MOVE}),d("Move initialized",null))}if(t==="next")return Wo(di(1));if(t==="previous")return Wo(di(-1));if(t==="jump-next")return Wo(di(1,Ws));if(t==="jump-previous")return Wo(di(-1,Ws));if(t==="to-next")return Wo(Xd(1));if(t==="to-previous")return Wo(Xd(-1));if(t==="confirm"){let s=ln();if(!s)return l("No pending move to confirm");let i=await Ee();if(a(i))return i;let c=_([s],i.value);if(a(c))return c;let u=ey();return a(u)?u:(ci(null),A({mode:x.DEFAULT}),d("Moved item",null))}return t==="cancel"?(ci(null),A({mode:x.DEFAULT}),d("Cancelling move",null)):l("Invalid move modifier")}});import{monotonicFactory as DC,ulid as OC}from"ulid";var _C,el,Qd=g(()=>{"use strict";N();_C=DC(),el=({name:e,parent:t,rank:n,user:{userId:r}})=>{let o=_C();return d("Created issue events",[{id:OC(),userId:r,action:"add.issue",payload:{id:o,parent:t,name:e,rank:n}}])}});import{ulid as tl}from"ulid";var ry,oy=g(()=>{"use strict";It();Qd();$();$();$t();Xt();N();pe();jt();D();ee();ry=async(e,t)=>{let n=he();if(a(n))return l("Unable to resolve user ID");let r=await Ee();if(a(r))return r;let o=r.value;if(!t.inputString)return l(`provide a name for your ${t.modifier}`);let{breadCrumb:s,contextNode:i,selectedIndex:c}=v(),u=p=>{let m=_([p],o);if(a(m))return m;let f=C.getNode(m.value[0].result.id);if(!f)return l("Created node not found");if(!f.parentNodeId)return m;let h=C.getNode(f.parentNodeId);return h?(H.navigate({contextNode:h,selectedIndex:C.getSiblings(f.parentNodeId).findIndex(({id:b})=>b===f.id)}),m):l("Parent node not found")};if(t.modifier==="board"){let{rootNodeId:p}=v(),m=C.getNode(p);if(!m)return l("Workspace not found");let f=Bn(m.id,n.value,o);return a(f)?f:u({id:tl(),action:"add.board",payload:{id:tl(),name:t.inputString,parent:m.id,rank:f.value},...O(n.value)})}if(t.modifier==="swimlane"){let p=Ct(s,"BOARD");if(a(p))return l("Unable to add swimlane in this context");let m=Bn(p.value.id,n.value,o);return a(m)?m:u({id:tl(),action:"add.swimlane",payload:{id:tl(),name:t.inputString,parent:p.value.id,rank:m.value},...O(n.value)})}if(t.modifier==="issue"){let p=be(i.id)[c],m=i.context==="SWIMLANE"?i:i.context==="BOARD"&&p?.context==="SWIMLANE"?p:(()=>{let k=Ct(s,"SWIMLANE");return a(k)?null:k.value})();if(!m)return l("Unable to add issue in this context");let f=Bn(m.id,n.value,o);if(a(f))return f;let h=el({name:t.inputString,parent:m.id,rank:f.value,user:n.value});if(a(h))return h;let b=h.value,E=_([...b],o);if(a(E))return E;if(!E.value[0])return l("Issue creation failed");let R=b.find(k=>k.action==="add.issue")?.payload.id;return R?(H.navigate({contextNode:m,selectedIndex:C.getSiblings(m.id).findIndex(({id:k})=>k===R)}),d("Issue created",null)):l("Unable to determine ticket id")}return d("Success",null)}});import ui from"node:fs";import FC from"node:path";import{z as Vr}from"zod";var mi,BC,$C,jC,sy,UC,iy,ay,ly,Zd=g(()=>{"use strict";N();Zt();ge();Ad();ee();mi="command-history.json",BC=20,$C=Vr.object({projectId:Vr.string().min(1),commands:Vr.array(Vr.string()),lastUsedAt:Vr.number().finite()}),jC=Vr.object({projects:Vr.array($C)}),sy=()=>{let e=si();return a(e)?e:d("Resolved command history path",FC.join(e.value,mi))},UC=()=>{try{let e=Ce(process.cwd());return a(e)?null:e.value}catch{return null}},iy=e=>{if(!ui.existsSync(e))return d("No command history recorded",{state:"read",projects:[]});let t;try{t=ui.readFileSync(e,"utf8")}catch(o){return l(`Unable to read ${mi}: ${o instanceof Error?o.message:String(o)}`)}let n;try{n=JSON.parse(t)}catch(o){return d("Unparsable command history",{state:"corrupt",reason:`Invalid ${mi}: ${o instanceof Error?o.message:String(o)}`})}let r=jC.safeParse(n);return r.success?d("Read command history",{state:"read",projects:r.data.projects}):d("Command history in an unknown shape",{state:"corrupt",reason:`Invalid ${mi} shape: ${r.error.issues.map(o=>o.path.join(".")||o.message).join(", ")}`})},ay=({root:e})=>{let t=fn(e);if(a(t))return l(t.message);let n=sy();if(a(n))return n;let r=iy(n.value);if(a(r))return r;let o=r.value;if(o.state==="corrupt")return l(o.reason);let s=o.projects.find(i=>i.projectId===t.value);return d("Read command history",s?.commands.slice(0,Ms)??[])},ly=({commands:e,root:t=UC(),now:n=Date.now()})=>{if(t===null)return d("No project; command history not stored",null);let r=fn(t);if(a(r))return l(r.message);let o=sy();if(a(o))return o;let s=o.value,i=iy(s);if(a(i))return i;let c=i.value,u=c.state==="read"?c.projects:[],p=[{projectId:r.value,commands:e.slice(0,Ms),lastUsedAt:n},...u.filter(f=>f.projectId!==r.value)].sort((f,h)=>h.lastUsedAt-f.lastUsedAt).slice(0,BC),m=`${s}.${process.pid}.tmp`;try{ui.writeFileSync(m,JSON.stringify({projects:p},null,2)+`
105
+ `,"utf8"),ui.renameSync(m,s)}catch(f){try{ui.rmSync(m,{force:!0})}catch{}return l(`Unable to write ${mi}: ${f instanceof Error?f.message:String(f)}`)}return d("Stored command history",null)}});var HC,cy,WC,dy,qC,uy,my=g(()=>{"use strict";mn();rt();Ke();Ys();Ta();Zc();wa();Zd();lo();jr();$();N();Zt();ge();D();Gs();ee();Ea();HC=e=>e.some(t=>t.action==="init.workspace"),cy=async(e,t)=>{let n=dt(e);return a(n)?l(n.message):gs({cwd:t,branch:n.value})},WC=e=>{let t=Ce(process.cwd());if(a(t))return!1;let n=Ie({repoRoot:t.value});return!a(n)&&n.value===e},dy=async e=>{let t=Ie({repoRoot:e});if(a(t))return So(3,t.message);let n=t.value,r=await ir({repoRoot:e,stateBranchRoot:n,stateBranchName:Ui().stateBranch});if(a(r))return So(3,r.message);let o=sn(n);if(a(o))return So(3,o.message);if(!HC(o.value.events)){let m=await Xs({worktreeRoot:n,operation:"boot pull",fn:()=>Na(n,()=>cy(e,n))});if(a(m)?logger.info(3,m.message):m.value===null?logger.info(3,"Another process holds the state worktree, skipped pull"):a(m.value)&&logger.info(3,m.value.message),o=sn(n),a(o))return So(3,o.message)}let{events:s,unreadable:i}=o.value,c=En(s,i);if(a(c))return So(4,c.message);A({hasProjectDefinition:!0,hasInitializingEvents:!!s.length});let u=Rs({root:e});a(u)&&logger.info(u.message);let p=ay({root:e});return a(p)&&logger.info(p.message),Ef(a(p)?[]:p.value),d("Loaded project",void 0)},qC=async e=>{let t=Ie({repoRoot:e});if(a(t))return l(t.message);let n=t.value,r=await Mn({repoRoot:n});if(a(r))return l(r.message);if(!r.value)return d("No remote to pull",void 0);let o=await Xs({worktreeRoot:n,operation:"boot pull",fn:()=>Na(n,()=>(Ro("Pulling"),cy(e,n)))});if(a(o))return je(o.message);if(o.value===null)return d("Another process holds the state worktree",void 0);let s=o.value;if(a(s))return fs(s.message)?(Ia("Offline"),d("Offline",void 0)):je(s.message);if(!s.value)return Ur("Already synced"),d("Already synced",void 0);if(!WC(n))return d("Project changed during the pull",void 0);let i=td(n);return a(i)?i:(Ur("Pulled"),d("Pulled and reloaded",void 0))},uy=e=>{qC(e).then(t=>{a(t)&&logger.info(3,t.message)}).catch(t=>{logger.error(`[boot] pull failed: ${zg(t)}`)})}});import GC from"node:os";import py from"node:path";var zC,VC,fy,gy=g(()=>{"use strict";my();lo();N();ge();D();ee();zC=e=>e==="~"||e.startsWith("~/")?py.join(GC.homedir(),e.slice(1)):e,VC=(e,t)=>{let n=e.trim();if(!n)return l("Provide a number from the list or a path to a project");if(/^\d+$/.test(n)){let o=t[Number(n)-1];return o?d("Resolved recent project",o.root):l(`No recent project #${n}`)}let r=Ce(py.resolve(zC(n)));return a(r)?l(`No epiq project at ${n}`):d("Resolved project path",r.value)},fy=async()=>{let e=ra();if(ne(""),v().hasProjectDefinition)return l("Already in a project; run epiq from another directory");let t=Wi({exclude:process.cwd()}),n=a(t)?[]:t.value,r=VC(e,n);if(a(r))return l(r.message);let o=r.value,s=process.cwd();try{process.chdir(o)}catch(c){return l(`Unable to enter ${o}: ${c instanceof Error?c.message:String(c)}`)}let i=await dy(o);return a(i)?(process.chdir(s),l(i.message)):(uy(o),d(`Opened ${Ip(o)}`,null))}});var nl,eu=g(()=>{"use strict";It();$();$();N();D();nl=({boardId:e,targetTime:t,stateBranchRoot:n,selectedIndex:r})=>{let o=v(),s=jc(n,t);if(a(s))return l(s.message);let{appliedEvents:i,unappliedEvents:c}=s.value,u=qn();if(a(u))return u;let p=Fn(i),{fatal:m,skipped:f}=tr(p);if(m.length>0)return qn(),A(o),l(m.map(b=>b.message).join(", "));nr(f);let h=v().nodes[e];return h?(H.navigate({contextNode:h,selectedIndex:r}),d("",{unappliedEvents:c})):(qn(),A(o),l("Board did not exist at that date"))}});var hy,vy=g(()=>{"use strict";hy=e=>{let t=[],n=0;for(let o=0;o<e.length;o++){let s=o===0?0:Math.max(0,e[o]-e[o-1]);n+=Math.sqrt(s),t[o]=n}let r=n;return t.map((o,s)=>r>0?o/r:(s+1)/e.length)}});var KC,YC,XC,rl,ol,Kr,yy,by,tu=g(()=>{"use strict";lt();pi();$();Bc();Oe();N();vy();D();KC=20,YC=16,XC=150,rl=null,ol=null,Kr=()=>{rl!==null&&(clearInterval(rl),rl=null),ol!==null&&(clearTimeout(ol),ol=null)},yy=()=>{Kr(),A({mode:x.DEFAULT,readOnly:!1,readOnlyReason:void 0,timeMode:"live",unappliedEvents:[],replay:null,selectedIndex:0})},by=({events:e,startTime:t,durationMs:n})=>{Kr();let r=e.length,o=as(e.map(f=>br(f))).map(f=>f??t),s=o[r-1]??Date.now(),i=hy(o),c=Math.max(1,Math.round(n*KC/1e3)),u=Math.max(Math.round(n/c),YC),p=0,m=0;A({mode:x.DEFAULT,readOnly:!0,timeMode:"replay",unappliedEvents:e,replay:{progress:0,appliedCount:0,totalCount:r,currentTime:t,startTime:t,endTime:s,currentLabel:"",flashNodeIds:[]}}),rl=setInterval(()=>{p++;let f=p/c,h=[],b,E;for(;m<r&&i[m]<=f;){let w=e[m],R=Hs(w);if(a(R)){if(Io(R)){m++;continue}yy();return}h.push(...Fc(w)),b=w,E=o[m],m++}if(m>=r||p>=c){for(;m<r;m++){let R=Hs(e[m]);if(a(R)&&!Io(R))break}let w=v().replay;A({unappliedEvents:[],replay:w&&{...w,progress:1,appliedCount:r}}),Kr(),ol=setTimeout(yy,XC);return}let S=v().replay;A({unappliedEvents:e.slice(m),replay:{progress:Math.min(1,f),appliedCount:m,totalCount:r,startTime:t,endTime:s,currentTime:b?E??S?.currentTime??t:S?.currentTime??t,currentLabel:b?nu(b):S?.currentLabel??"",flashNodeIds:b?[...new Set(h)]:S?.flashNodeIds??[]}})},u)}});var xy,Iy=g(()=>{"use strict";rt();lt();$();$();Oe();Xt();N();ge();D();Cs();eu();tu();xy=async()=>{let e=Ct(v().breadCrumb,"BOARD");if(a(e))return e;let t=await kt(process.cwd());if(a(t))return l("Unable to locate repo root");let n=Ie({repoRoot:t.value});if(a(n))return n;let{modifier:r,inputString:o}=fe().commandMeta;if(Kr(),r==="now"){let c=Br(n.value);if(a(c))return l(c.message);let u=qn();if(a(u))return u;let p=Fn(c.value),{fatal:m,skipped:f}=tr(p);return m.length>0?l(m.map(h=>h.message).join(", ")):(nr(f),A({mode:x.DEFAULT,readOnly:!1,readOnlyReason:void 0,timeMode:"live",unappliedEvents:[],replay:null}),d("Peeking now",!0))}let s;if(r==="prev"||r==="next"){let c=Uc(n.value);if(a(c))return c;let u=r==="prev"?v().eventLog.at(-1):v().unappliedEvents.at(0),p=u===void 0?null:br(u),m=(u===void 0?null:c.value.get(u.id)??null)??(p===null?null:is(p));if(m===null)return l(r==="prev"?"No previous event to peek":"No next event to peek");s=r==="prev"?m:m+1}else{let c=Tr(r||o.trim());if(!c)return l("Invalid peek date");s=c.getTime()}let i=nl({boardId:e.value.id,targetTime:s,stateBranchRoot:n.value,selectedIndex:0});return a(i)?i:(A({mode:x.DEFAULT,readOnly:!0,timeMode:"peek",unappliedEvents:i.value.unappliedEvents,replay:null}),d("Peeking",!0))}});var Ey,Ry=g(()=>{"use strict";rt();Xt();N();ge();D();Cs();eu();tu();Ey=async()=>{let e=Ct(v().breadCrumb,"BOARD");if(a(e))return e;let t=await kt(process.cwd());if(a(t))return l("Unable to locate repo root");let n=Ie({repoRoot:t.value});if(a(n))return n;let{modifier:r,inputString:o}=fe().commandMeta,{dateInput:s,durationInput:i}=Yi(r,o);if(Kr(),v().syncStatus.status==="syncing")return l("Cannot replay while syncing, try again in a moment");let c=Tr(s);if(!c)return l("Invalid replay date");let u=i?Ki(i):15e3;if(u===null)return l("Invalid replay duration (try e.g. 30s or 2m)");let p=c.getTime(),m=v(),f=nl({boardId:e.value.id,targetTime:p,stateBranchRoot:n.value,selectedIndex:-1});if(a(f))return f;let{unappliedEvents:h}=f.value;return h.length===0?(qn(),A(m),d("Nothing to replay from that point",!0)):(by({events:h,startTime:p,durationMs:u}),d("Replaying board history",!0))}});import{spawn as QC}from"node:child_process";var ZC,Sy,Ny=g(()=>{"use strict";N();ZC=()=>{switch(process.platform){case"darwin":return{command:"pbcopy",args:[]};case"win32":return{command:"clip",args:[]};default:return process.env.WAYLAND_DISPLAY?{command:"wl-copy",args:[]}:{command:"xclip",args:["-selection","clipboard"]}}},Sy=async e=>new Promise(t=>{let{command:n,args:r}=ZC();try{let o=QC(n,r,{stdio:["pipe","ignore","ignore"]});o.on("error",()=>t(l(`Clipboard tool not available (${n})`))),o.on("close",s=>t(s===0?d("Copied to clipboard",null):l(`Clipboard tool failed (${n})`))),o.stdin.on("error",()=>{}),o.stdin.write(e),o.stdin.end()}catch{t(l(`Clipboard tool not available (${n})`))}})});var fi,Cy,wy=g(()=>{"use strict";N();D();Ny();ft();uo();Pn();fi=async(e,t)=>{if(!e.trim())return l(`Nothing to copy: ${t} is empty`);let n=await Sy(e);return a(n)?n:d(`Copied ${t} to clipboard`,null)},Cy=async e=>{let{breadCrumb:t,selectedNode:n}=v(),r=ws({breadCrumb:t,selectedNode:n}),o=r??n;if(!o)return l("Nothing selected to copy from");switch(e.modifier){case He.REF:return fi(V(o.id),"ref");case He.TITLE:return fi(o.title,"title");case He.DESCRIPTION:return r?fi(r.props?.description??"","description"):l("No issue in scope");case He.TAGS:{if(!r)return l("No issue in scope");let s=hn(r).map(({name:i})=>i);return fi(s.join(", "),"tags")}case He.ASSIGNEES:{if(!r)return l("No issue in scope");let s=vn(r).map(({name:i})=>i);return fi(s.join(", "),"assignees")}default:return l("Yank one of: ref, title, description, tags, assignees")}}});var Ay,Ty=g(()=>{"use strict";Ta();Oe();N();ge();D();Ay=async()=>{ne(""),A({mode:x.DEFAULT});let e=ke();if(a(e))return l(e.message);if(e.value.syncStatus.status==="syncing")return l("Sync already in progress");A({syncStatus:{msg:"Syncing",status:"syncing"}});let t=await Aa();return a(t)?(A({syncStatus:{msg:t.message,status:"failed"}}),t):(A({mode:x.DEFAULT,syncStatus:{msg:"Synced",status:"synced"}}),t)}});import{ulid as ky}from"ulid";var My,Ly=g(()=>{"use strict";$();$();me();N();D();_a();ee();$t();My=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=be(t.id)[n];if(!r)return l("Unable to resolve child to delete");let o=await Ee();if(a(o))return o;if(r.context==="COMMENT"){let s=r.id,i=U(t)?t.id:t.parentNodeId;if(!i)return l("Unable to resolve comment issue");let c=v().nodes[i];if(!c||!U(c))return l("Unable to resolve comment issue");let u=c.log?.filter(Ph).find(p=>p.payload.id===s);return u?u.payload.author!==e.value.userId?l("You can only delete your own comments"):_([{id:ky(),action:"delete.issue.comment",payload:{id:s,issue:i},...O(e.value)}],o.value):l("Unable to resolve comment")}return _([{id:ky(),action:"delete.node",payload:{id:r.id},...O(e.value)}],o.value)}});import{ulid as ew}from"ulid";var Py,Dy=g(()=>{"use strict";$();$();tn();me();N();jt();D();ee();Bt();Py=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=be(t.id)[n];if(!r)return l("Unable to close issue, no target found");if(!U(r))return l("Cannot close in this context");let o=v().nodes[we];if(!o)return l("Unable to locate closed swimlane");if(r.parentNodeId===o.id)return l("Issue is already closed");let s=await Ee();if(a(s))return s;let i=s.value,c=xn(o.id,r.id,{at:"end"},e.value,i);if(a(c))return c;let u=_([{id:ew(),action:"close.issue",payload:{id:r.id,parent:o.id,rank:c.value},...O(e.value)}],i);return a(u)?u:d("Issue closed",null)}});var sl,ru=g(()=>{"use strict";sl=e=>{let t=e.log??[];for(let n=t.length-1;n>=0;n--){let r=t[n];if(r&&r.action==="close.issue"&&r.payload.id===e.id){for(let o=n-1;o>=0;o--){let s=t[o];if(s&&"id"in s.payload&&s.payload.id===e.id&&"parent"in s.payload&&s.payload.parent)return s.payload.parent}return null}}return null}});import{ulid as tw}from"ulid";var Oy,_y=g(()=>{"use strict";$();$();ru();tn();me();N();pe();jt();D();ee();Bt();Oy=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=be(t.id)[n];if(!r)return l("Unable to reopen issue, no target found");let o=r.context==="TICKET"?d("Resolved ticket",r):zt(r.id,"TICKET");if(a(o))return l("Cannot reopen in this context");let s=o.value,i=v().nodes[we];if(!i)return l("Unable to locate closed swimlane");if(s.parentNodeId!==i.id)return l("Issue is not closed");if(!U(s))return l("Target node is not issue");let c=sl(s);if(!c)return l("Unable to resolve previous parent from issue history");if(c===i.id)return l("Previous parent resolves to closed swimlane");let u=v().nodes[c];if(!u)return l("Previous parent no longer exists");let p=await Ee();if(a(p))return p;let m=p.value,f=xn(u.id,s.id,{at:"end"},e.value,m);if(a(f))return f;let h=_([{id:tw(),action:"reopen.issue",payload:{id:s.id,parent:u.id,rank:f.value},...O(e.value)}],m);return a(h)?h:d("Issue reopened",null)}});import{ulid as nw}from"ulid";var Fy,By=g(()=>{"use strict";$();$();N();ge();D();ee();Bt();Fy=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=be(t.id)[n];if(!r)return l("Missing node");if(r.readonly)return l("Cannot rename readonly node");let o=ra();if(!o)return l("Provide a title");let s=await Ee();return a(s)?s:_([{id:nw(),action:"edit.title",payload:{id:r.id,name:o},...O(e.value)}],s.value)}});import{ulid as rw}from"ulid";var $y,jy=g(()=>{"use strict";pe();$();$();me();N();ge();D();ee();Bt();$y=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let{modifier:t,inputString:n}=fe().commandMeta,r=(t||n).trim();if(!r)return l("Provide a tag");let o=C.findTagByName(r);if(!o)return l(`Tag "${r}" does not exist`);let{selectedNode:s}=v();if(!s)return l("Invalid untag target");let i=zt(s.id,"TICKET");if(a(i))return l("Unable to untag issue in this context");let c=i.value;if(!U(c))return l("Target node is not issue");if(!(c.props.tags??[]).includes(o.id))return l("Issue is not tagged with that tag");let p=await Ee();return a(p)?p:_([{id:rw(),action:"remove.issue.tag",payload:{id:c.id,tag:o.id},...O(e.value)}],p.value)}});import{ulid as ou}from"ulid";var Uy,Hy=g(()=>{"use strict";pe();$();$();me();N();ge();D();ee();Bt();Uy=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let{modifier:t,inputString:n}=fe().commandMeta,r=(t||n).trim();if(!r)return l("Provide a tag");let{selectedNode:o}=v();if(!o)return l("Invalid tag target");let s=zt(o.id,"TICKET");if(a(s))return l("Unable to tag issue in this context");let i=s.value;if(!U(i))return l("Target node is not issue");let c=await Ee();if(a(c))return c;let u=C.findTagByName(r),p=u?.id??ou();return(i.props.tags??[]).includes(p)?l("Already tagged with that tag"):_([...u?[]:[{id:ou(),action:"create.tag",payload:{id:p,name:r},...O(e.value)}],{id:ou(),action:"add.issue.tag",payload:{id:i.id,tag:p},...O(e.value)}],c.value)}});var gi,Wy,il=g(()=>{"use strict";wt();Tn();gi=({events:e,registry:t,logFileNames:n})=>{let r=new Map(n),o=new Set;for(let s of e)s.userId&&(r.has(s.userId)||r.set(s.userId,""),o.add(s.userId));for(let s of Object.values(t))r.set(s.id,s.name);return[...r.entries()].map(([s,i])=>({id:s,name:i,isExternal:!o.has(s)}))},Wy=({authorName:e,authorEmail:t,owners:n,registry:r})=>{let o=Ve(t),s=n.get(o),i=s?r[s]:void 0;return s?{...ht(s,i?.name),resolved:!0}:{...ht(o||e,e),resolved:!1}}});var al,su=g(()=>{"use strict";$();il();D();al=e=>{let{eventLog:t=[],contributors:n}=v();return gi({events:t,registry:n,logFileNames:Fr(e)})}});import{ulid as iu}from"ulid";var qy,Gy=g(()=>{"use strict";$();$();me();N();pe();ge();D();su();ee();Bt();qy=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let{modifier:t,inputString:n}=fe().commandMeta,r=(t||n).trim();if(!r)return l("Provide an assignee");let o=r.startsWith("!"),s=(o?r.slice(1):r).trim();if(!s)return l("Provide an assignee");let{selectedIndex:i,contextNode:c}=v(),u=be(c.id)[i];if(!u)return l("Invalid assign target");let p=zt(u.id,"TICKET");if(a(p))return l("Unable to assign issue in this context");let m=p.value;if(!U(m))return l("Target node is not issue");let f=await Ee();if(a(f))return f;let h=al(f.value),b=!o&&s.toLowerCase()==="me",E,S;if(b)E=e.value.userId,S=h.find(k=>k.id===E)?.name??e.value.userName;else{let k=h.filter(F=>F.name===s);if(k.length>1)return l(`"${s}" matches ${k.length} contributors (${k.map(F=>F.id).join(", ")}). Assign from the GUI to choose by id.`);let M=k[0];if(!M&&!o)return l(`No contributor named "${s}". Use "!${s}" to add them as an external assignee.`);E=M?.id??iu(),S=M?.name??s}if((m.props.assignees??[]).includes(E))return l("Assignee already assigned");let R=!!v().contributors[E];return _([...R?[]:[{id:iu(),action:"create.contributor",payload:{id:E,name:S},...O(e.value)}],{id:iu(),action:"add.issue.assignee",payload:{id:m.id,assignee:E},...O(e.value)}],f.value)}});import{ulid as ow}from"ulid";var zy,Vy=g(()=>{"use strict";$();$();me();N();pe();ge();D();su();ee();Bt();zy=async()=>{let e=he();if(a(e))return l("Unable to resolve user ID");let{modifier:t,inputString:n}=fe().commandMeta,r=(t||n).trim();if(!r)return l("Provide an assignee to remove");let{selectedNode:o}=v();if(!o)return l("Invalid unassign target");let s=zt(o.id,"TICKET");if(a(s))return l("Unable to unassign in this context");let i=s.value;if(!U(i))return l("Target node is not issue");let c=i.props.assignees??[],u=r.toLowerCase()==="me",p=await Ee();if(a(p))return p;let m=u?c.filter(h=>h===e.value.userId):al(p.value).filter(h=>h.name===r&&c.includes(h.id)).map(h=>h.id);if(m.length>1)return l(`"${r}" matches ${m.length} assignees (${m.join(", ")}). Unassign from the GUI to choose by id.`);let f=m[0];return f?_([{id:ow(),action:"remove.issue.assignee",payload:{id:i.id,assignee:f},...O(e.value)}],p.value):l(u?"Issue is not assigned to you":`Issue is not assigned to "${r}"`)}});import{ulid as Ky}from"ulid";var sw,Yy,Xy=g(()=>{"use strict";$();$();Xt();me();N();pe();D();On();ee();Bt();Ha();Ya();Fa();sw=e=>{let t=e.trim(),n=ur(),r=n?lv(t):null;if(!n||!r)return{ok:!0,md:t,anchored:!1};let o=Ka();if(!o||o.sha!==n)return{ok:!1,reason:"No diff is open"};let s=cv(o.rows,Math.max(0,v().selectedIndex));if(!s)return{ok:!1,reason:"That line is not in a file"};let i=dv(o.rows,s,r.start,r.end);return i.ok?{ok:!0,anchored:!0,md:qh({filePath:i.value.filePath,start:i.value.start,end:i.value.end,side:"additions",endSide:"additions",note:r.note,sha:n,snippet:i.value.snippet})}:{ok:!1,reason:i.reason}},Yy=async e=>{let t=sw(e.inputString);if(!t.ok)return l(t.reason);let{md:n,anchored:r}=t;if(!n)return l("Provide a comment");if(n.length>4e3)return l(r?`The note and the ${n.length} characters of quoted lines exceed ${4e3}; comment on fewer lines`:`Cannot exceed ${4e3} characters`);let o=he();if(a(o))return l("Unable to resolve user ID");let{breadCrumb:s,selectedNode:i}=v(),c=Ct([...s,i],"TICKET");if(a(c))return l("Edit target must be an issue");let u=c.value;if(!u)return l("Invalid comment target");let p=u.context==="TICKET"?d("Resolved ticket",u):zt(u.id,"TICKET");if(a(p))return l("Unable to comment on issue in this context");let m=p.value;if(!U(m))return l("Target node is not issue");let f=await Ee();if(a(f))return f;let h=await _([{id:Ky(),action:"add.issue.comment",payload:{id:Ky(),issue:m.id,author:o.value.userId,md:n},...O(o.value)}],f.value);return r&&!a(h)&&Gr(null),h}});var Jy,iw,Qy,ll,au=g(()=>{"use strict";Sr();N();Ue();bn();Jy=e=>e.userName?.trim()?e.preferredEditor?.trim()?null:"no editor configured":"no username configured",iw=e=>{let t=Xn();return a(t)?Jy({userName:e.userName,preferredEditor:e.preferredEditor})??t.message:Jy(t.value)},Qy=()=>{let e=yn();return a(e)?l(e.message):d("Read auto sync settings",{enabled:e.value.autoSync===!0,intervalMs:Li(e.value.autoSyncDebounceMs),blockedReason:iw(e.value)})},ll=e=>{let t=e.intervalMs===void 0?void 0:ro(e.intervalMs);if(e.intervalMs!==void 0&&t===null)return l(`Auto sync interval must be a whole number of milliseconds between ${3e3} and ${864e5}`);let n=Qy();if(a(n))return n;let r=xt({...e.enabled===void 0?{}:{autoSync:e.enabled},...t==null?{}:{autoSyncDebounceMs:t}});if(a(r))return l(r.message);ut({...e.enabled===void 0?{}:{autoSync:e.enabled},...t==null?{}:{autoSyncIntervalMs:t}});let o=Qy();return a(o)?d("Changed auto sync settings",{...n.value,...e.enabled===void 0?{}:{enabled:e.enabled},...t==null?{}:{intervalMs:t}}):o}});var Zy,eb=g(()=>{"use strict";Sr();au();N();ge();Zy=()=>{let e=fe().commandMeta.inputString,t=ro(e);if(t===null)return l(`Auto sync duration must be a whole number of milliseconds between ${3e3} and ${864e5}`);let n=ll({intervalMs:t});return a(n)?n:d(`Auto sync interval set to ${t}ms`,null)}});var tb,nb=g(()=>{"use strict";wr();au();N();ge();tb=()=>{let e=fe().commandMeta.inputString.trim();if(e!=="on"&&e!=="off")return l("Invalid response");let t=Lp(e),n=ll({enabled:t===!0});return a(n)?n:d(`Auto sync set to "${e}"`,null)}});var lu,rb,ob,aw,lw,hi,cl,dl=g(()=>{"use strict";Ke();wt();N();hd();lu=e=>e.toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>=2),rb="",ob=new Map,aw=15e3,lw=async(e,t)=>{let n=`${e} ${t??""}`,r=ob.get(n);if(r&&Date.now()-r.at<$a(aw))return d("Cached author scan",r.authors);let o=await Le({cwd:e,args:["log","--branches",...t?["--not",t]:[],`--format=%an${rb}%ae`]});if(o.exitCode!==0)return l(`Could not read this repository's history: ${(o.stderr??"").trim()||`git exited ${o.exitCode}`}`);let s=new Map;for(let i of(o.stdout??"").split(`
106
+ `)){let c=i.lastIndexOf(rb);if(c===-1)continue;let u=i.slice(0,c),p=Ve(i.slice(c+1));if(!zn(p))continue;let m=s.get(p)??{names:new Set,commits:0};u&&m.names.add(u),m.commits+=1,s.set(p,m)}return ob.set(n,{at:Date.now(),authors:s}),d("Scanned repository authors",s)},hi=async({repoRoot:e,stateBranch:t,names:n,links:r})=>{let o=await lw(e,t);if(a(o))return l(o.message);let s=o.value,i=new Map;for(let u of Object.values(r)){if(u.tombstoned)continue;let p=i.get(u.email)??new Set;p.add(u.contributor),i.set(u.email,p)}let c=new Set(n.flatMap(u=>lu(u??"")));return d("Found candidates",[...s.entries()].map(([u,p])=>({email:u,names:[...p.names],commits:p.commits,looksLikeYours:[...p.names].some(m=>lu(m).some(f=>c.has(f)))||lu(u.split("@")[0]??"").some(m=>c.has(m)),claimedBy:[...i.get(u)??[]]})).sort((u,p)=>u.looksLikeYours===p.looksLikeYours?p.commits-u.commits:Number(p.looksLikeYours)-Number(u.looksLikeYours)))},cl=e=>e.filter(t=>t.claimedBy.length===0)});import{ulid as cw}from"ulid";var sb,ib,ab=g(()=>{"use strict";$();mn();rt();wt();N();Oe();dl();ge();Ss();Ue();D();bn();wr();ee();sb=()=>{let e=nc();if(!e)return d("Nothing here to decline",null);let t=yn(),n=a(t)?[]:t.value.declinedEmailBoards??[],r=[...new Set([...n,e])],o=xt({declinedEmailBoards:r});return a(o)?l(o.message):(ut({declinedEmailBoards:[...new Set([...de().declinedEmailBoards??[],e])]}),d("Declined",null))},ib=async()=>{let e=fe().commandMeta.inputString.trim();if(e==="none"){let w=sb();return a(w)?w:d("Left unlinked. Your commits will show the name git signed them with. Run :config emails again to change that.",null)}let{userId:t,userName:n,gitName:r}=de();if(!t)return l("Set a username first with :config username");let o=ke();if(a(o))return l("Board is not loaded");let s=Ce(process.cwd());if(a(s))return l(s.message);let i=dt(s.value),c=await hi({repoRoot:s.value,stateBranch:a(i)?void 0:i.value,names:[n,r],links:o.value.emailLinks});if(a(c))return c;let p=cl(c.value);if(Ap(p.map(w=>w.email)),p.length===0){if(!kp()){let w=sb();if(a(w))return w}return d("No unclaimed addresses in this history.",null)}if(!e)return A({mode:x.IDENTITY}),d("Opened identity",null);let m=e.split(/[,\s]+/).filter(Boolean),f=[],h=[];for(let w of m){let R=p.find(k=>k.email===Ve(w));if(!R){h.push(w);continue}f.includes(R)||f.push(R)}if(h.length>0)return l(`Not on the list: ${h.join(", ")}. Pick one of ${p.map(w=>w.email).join(", ")}.`);let b=Ie({repoRoot:s.value});if(a(b))return b;let E=f.map(w=>({id:cw(),action:"link.contributor.email",payload:{contributor:t,email:w.email},userId:t})),S=_(E,b.value);return a(S)?l(S.message):d(`Claimed ${f.map(w=>w.email).join(", ")}. Every commit by ${f.length===1?"that address":"those addresses"} is now yours.`,null)}});import{ulid as dw}from"ulid";var lb,cb=g(()=>{"use strict";$();rt();wt();N();ge();Ue();D();ee();lb=()=>{let e=fe().commandMeta.inputString.trim(),{userId:t}=de();if(!t)return l("Set a username first with :config username");let n=ke();if(a(n))return l("Board is not loaded");let r=Vn(n.value.emailLinks,t);if(r.length===0)return l("You have not claimed any addresses.");if(!e)return l(`Which one? ${r.join(", ")}.`);let o=r.find(u=>u===Ve(e));if(!o)return l(`You have not claimed ${e}. Yours: ${r.join(", ")}.`);let s=Ce(process.cwd());if(a(s))return s;let i=Ie({repoRoot:s.value});if(a(i))return i;let c=_([{id:dw(),action:"unlink.contributor.email",payload:{contributor:t,email:o},userId:t}],i.value);return a(c)?l(c.message):d(`Unclaimed ${o}`,null)}});var db,ub=g(()=>{"use strict";bn();N();ge();Ue();db=()=>{let e=fe().commandMeta.inputString.trim();if(!["debug","error","info"].includes(e))return l("Invalid response");let n=xt({logLevel:e});return a(n)?n:(ut({logLevel:e}),d(`Auto sync set to "${e}"`,null))}});import{ulid as uw}from"ulid";var mb,pb=g(()=>{"use strict";yr();bn();N();Ue();Pn();eb();fc();nb();ab();cb();ub();mb=e=>{let t=e.inputString.trim();switch(e.modifier){case ye.USERNAME:{if(process.env[Ot])return l(`Cannot change the configured user while ${Ot} names this process`);let n=yn();if(a(n))return n;let{userId:r,preferredEditor:o,userName:s}=n.value,i=t||s,c=r||uw();if(!i||!c)return l("Unable to resolve user name or id");let u=xt({userName:i,userId:c,preferredEditor:o??""});return a(u)?u:(ut({userName:i,userId:c}),d(`Username set to "${i}"`,null))}case ye.EDITOR:{if(!t)return l("No editor provided");let n=xt({preferredEditor:t});return a(n)?n:(ut({preferredEditor:t}),d(`Editor configuration set to "${t}"`,null))}case ye.VIEW:{if(t!=="wide"&&t!=="dense")return l("Invalid view mode");let n=xt({viewMode:t});return a(n)?n:(ut({viewMode:t}),d(`View set to "${t}"`,null))}case ye.EMAILS:return ib();case ye.EMAILS_UNCLAIM:return lb();case ye.AUTOSYNC:return tb();case ye.LOG_LEVEL:return db();case ye.SYNC_DEBOUNCE_MS:return Zy();case ye.ATTACHMENT_MAX_KB:return Qp();default:return l("Unknown config command")}}});var cu,fb=g(()=>{"use strict";wr();Oe();ge();D();cu=()=>{let e=Pp(),t=v().mode;if(!(t!==x.COMMAND_LINE&&t!==x.DEFAULT)){if(!e){A({mode:x.DEFAULT});return}A({mode:x.COMMAND_LINE}),ne(e)}}});var gb,hb=g(()=>{"use strict";Wv();It();Oe();N();ge();D();Qa();Ar();sd();Pn();Gv();Yv();ny();oy();gy();Iy();Ry();wy();Ty();Ly();Dy();_y();By();jy();Hy();Gy();Vy();Xy();pb();fb();gb=[{systemOnly:!0,intent:G.Move,description:"Internal move-state command",mode:x.COMMAND_LINE,action:ty},{intent:G.Delete,description:"Delete the currently selected node",mode:x.COMMAND_LINE,action:My,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.Filter,description:"Filter the board, for example `:filter tag urgent`",mode:x.COMMAND_LINE,action:()=>{let{modifier:e,inputString:t}=fe().commandMeta,n=/(!=|=)/,[r]=e.split(n);if(!r||!(i=>We(I.FILTER).map(c=>c.split(n)[0]).includes(i))(r))return l("Invalid filter modifier");let s={target:r,operator:"=",value:t.trim()};return Pe(i=>({...i,filters:e==="clear"?[]:[...i.filters,s],mode:x.DEFAULT})),d("Filter updated",null)}},{intent:G.ViewHelp,description:"Open the help screen",mode:x.COMMAND_LINE,action:()=>{let{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:r}=v();return mr({pendingNavTarget:{contextNode:e,breadCrumb:r,selectedIndex:t,selectedNode:n}}),A({mode:x.HELP}),d("Viewing help",null)}},{intent:G.CloseIssue,description:"Move the selected issue to the closed swimlane",mode:x.COMMAND_LINE,action:Py,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.ReopenIssue,description:"Move a closed issue back to its previous swimlane",mode:x.COMMAND_LINE,action:Oy,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.Init,description:"Initialize Epiq in the current git repository",mode:x.COMMAND_LINE,action:Kv,onSuccess:cu},{intent:G.OpenProject,description:"Open a recently used epiq project, by number or path",mode:x.COMMAND_LINE,action:fy,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.NewItem,description:"Create a new board, swimlane, or issue",mode:x.COMMAND_LINE,action:ry,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.Rename,description:"Rename the currently selected node",mode:x.COMMAND_LINE,action:Fy,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.UntagTicket,description:"Remove a tag from the selected issue",mode:x.COMMAND_LINE,action:$y,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.TagTicket,description:"Add or create a tag on the selected issue",mode:x.COMMAND_LINE,action:Uy,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.AssignUserToTicket,description:"Assign a user to the selected issue",mode:x.COMMAND_LINE,action:qy,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.UnassignUserFromTicket,description:"Remove an assignee from the selected issue",mode:x.COMMAND_LINE,action:zy,onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.Comment,description:"Add a comment to the selected issue",mode:x.COMMAND_LINE,action:async(e,t)=>Yy(t),onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.Sync,description:"Pull, commit, and push Epiq state",mode:x.COMMAND_LINE,action:Ay},{intent:G.Peek,description:"View board state at another point in time",mode:x.COMMAND_LINE,action:xy},{intent:G.Replay,description:"Replay board history forward from a point in time",mode:x.COMMAND_LINE,action:Ey},{intent:G.Export,description:"Export the current board layout to markdown",mode:x.COMMAND_LINE,action:async()=>{let e=await Hv();return a(e)?e:(A({mode:x.DEFAULT}),d("Export successful",!0))}},{intent:G.Exit,description:"Exit the application",mode:x.COMMAND_LINE,action:async()=>(H.exit(),d("Exit successful",!0))},{intent:G.Edit,description:"Edit title or description",mode:x.COMMAND_LINE,action:async(e,t)=>qv(t),onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.Yank,description:"Yank (copy) ref, title, description, tags, or assignees to the clipboard",mode:x.COMMAND_LINE,action:async(e,t)=>Cy(t),onSuccess:()=>A({mode:x.DEFAULT})},{intent:G.Config,description:"Update editor, username, view, autosync, or sync debounce",mode:x.COMMAND_LINE,action:(e,t)=>mb(t),onSuccess:cu}]});var mw,Vt,du=g(()=>{"use strict";hh();Zi();sd();hb();Zd();N();ge();Ue();D();mw=new Set(["peek","replay","filter","view-help","yank"]),Vt=async({isForceExecutedBySystem:e=!1}={})=>{let{value:t,commandMeta:{command:n,validity:r,modifier:o,inputString:s}}=fe();if(!n)return l("No command to confirm");if(!e&&r===Qn.Invalid)return l("Invalid command");let i=vh(n);xf();let{readOnly:c}=v();if(c&&!mw.has(i))return Ls({status:An.Fail,message:"Command not available in readonly state",value:null});let u=gb.filter(f=>e||f.systemOnly!==!0).find(f=>f.intent===i);if(!u)return Ls({status:An.Fail,message:"Command not found",value:null});let p;try{p=await u.action(u,{command:n,inputString:s,modifier:o})}catch(f){return Ls({status:An.Fail,message:f instanceof Error?f.message:"Command failed",value:null})}if(a(p))return Ls(p);let m=!e;if(If({addToHistory:m,line:t}),m){let f=ly({commands:fe().commandHistory});a(f)&&logger.info(f.message)}return u.onSuccess?.(),de().autoSync&&gh(),p}});var ul,ml,vb,yb=g(()=>{"use strict";N();Oe();D();Kn();du();Jd();ge();ul=[{intent:P.Exit,mode:x.MOVE,description:"[<Esc>] exit context / cancel",action:()=>(A({mode:x.COMMAND_LINE}),ne("move cancel"),Vt({isForceExecutedBySystem:!0}))},{intent:P.InitMove,mode:x.DEFAULT,description:"[m] move",action:()=>(A({mode:x.COMMAND_LINE}),ne("move start"),Vt({isForceExecutedBySystem:!0}))},{intent:P.ConfirmMove,mode:x.MOVE,description:"[m] confirm move",action:()=>(A({mode:x.COMMAND_LINE}),ne("move confirm"),Vt({isForceExecutedBySystem:!0}))}],ml=[{intent:P.MovePreviousItem,mode:x.MOVE,action:()=>ln()?(A({mode:x.COMMAND_LINE}),ne("move previous"),Vt({isForceExecutedBySystem:!0})):l("No pending move")},{intent:P.MoveNextItem,mode:x.MOVE,description:"[arrows/hjkl] move (shift x5)",action:()=>ln()?(A({mode:x.COMMAND_LINE}),ne("move next"),Vt({isForceExecutedBySystem:!0})):l("No pending move")},{intent:P.MovePreviousItemJump,mode:x.MOVE,action:()=>ln()?(A({mode:x.COMMAND_LINE}),ne("move jump-previous"),Vt({isForceExecutedBySystem:!0})):l("No pending move")},{intent:P.MoveNextItemJump,mode:x.MOVE,action:()=>ln()?(A({mode:x.COMMAND_LINE}),ne("move jump-next"),Vt({isForceExecutedBySystem:!0})):l("No pending move")}],vb=[{intent:P.MoveToNextContainer,mode:x.MOVE,action:()=>ln()?(A({mode:x.COMMAND_LINE}),ne("move to-next"),Vt({isForceExecutedBySystem:!0})):l("No pending move")},{intent:P.MoveToPreviousContainer,mode:x.MOVE,action:()=>ln()?(A({mode:x.COMMAND_LINE}),ne("move to-previous"),Vt({isForceExecutedBySystem:!0})):l("No pending move")}]});var bb,xb=g(()=>{"use strict";me();yb();bb={[ie.WORKSPACE]:[...ul,...ml],[ie.BOARD]:[...ul,...ml],[ie.SWIMLANE]:[...ul,...ml,...vb],[ie.TICKET]:[],[ie.FIELD]:[],[ie.FIELD_LIST]:[],[ie.TEXT]:[],[ie.COMMENT]:[]}});import{spawn as pw}from"node:child_process";function Ib(e){let t=process.platform,o=pw(t==="darwin"?"open":t==="win32"?"cmd":"xdg-open",t==="win32"?["/c","start","",e]:[e],{detached:!0,stdio:"ignore",shell:!1});return o.unref(),o.on("error",()=>{}),!0}var Eb=g(()=>{"use strict"});import fw from"node:fs";import gw from"node:path";var Rb,Sb=g(()=>{"use strict";rt();fo();N();ee();Eb();Rb=e=>{let t=Ce(process.cwd());if(a(t))return l("Unable to resolve project root");let n=Ie({repoRoot:t.value});if(a(n))return l(n.message);let r=po(e.hash,e.ext),o=gw.join($i(n.value),r);return fw.existsSync(o)?(Ib(o),d(`Opened ${e.name}`,null)):l("Attachment file not found \u2014 run :sync to fetch it")}});var Nb,Cb,wb=g(()=>{"use strict";Oe();N();ge();D();Qa();Kn();It();Nb=()=>{ne("");let{pendingNavTarget:e}=Ho();A({mode:x.DEFAULT}),e&&H.navigate(e),mr({pendingNavTarget:void 0})},Cb=[{intent:P.ExitCommandLine,mode:x.HELP,action:()=>(Nb(),d("Exiting help",null))},{intent:P.Exit,mode:x.HELP,action:()=>(Nb(),d("Closed help",null))},{intent:P.NavPreviousItem,mode:x.HELP,description:"[arrows/hjkl] navigate (shift x5)",action:()=>(H.navigateToPreviousItem(),d("Navigating to previous help item",null))},{intent:P.NavNextItem,mode:x.HELP,action:()=>(H.navigateToNextItem(),d("Navigating to next help item",null))},{intent:P.NavPreviousItemJump,mode:x.HELP,action:()=>(H.jumpToPreviousItem(),d("Jumping to previous help item",null))},{intent:P.NavNextItemJump,mode:x.HELP,action:()=>(H.jumpToNextItem(),d("Jumping to next help item",null))},{intent:P.NavToPreviousContainer,mode:x.HELP,action:()=>(H.navigateToPreviousContainer(),d("Navigating to previous help container",null))},{intent:P.NavToNextContainer,mode:x.HELP,action:()=>(H.navigateToNextContainer(),d("Navigating to next help container",null))}]});var Ab,Tb,kb=g(()=>{"use strict";Oe();N();ge();Ss();D();Kn();Ab=()=>{ne(""),A({mode:x.DEFAULT})},Tb=[{intent:P.Confirm,mode:x.IDENTITY,description:"[enter] claim the first",action:()=>{let[e]=co();return e?(A({mode:x.COMMAND_LINE}),ne(`config emails ${e}`),d("Proposed claim",null)):d("Nothing left to claim",null)}},{intent:P.ExitCommandLine,mode:x.IDENTITY,action:()=>(Ab(),d("Closed identity",null))},{intent:P.Exit,mode:x.IDENTITY,description:"[esc] close",action:()=>(Ab(),d("Closed identity",null))}]});var hw,Mb,Lb,Pb=g(()=>{"use strict";Oe();me();N();ge();D();Qa();Kn();It();hw=e=>{A({mode:x.COMMAND_LINE});let{pendingNavTarget:t}=Ho();t&&H.navigate(t),mr({pendingNavTarget:void 0}),ne(`${e} `)},Mb=()=>{ne("");let{pendingNavTarget:e}=Ho();e&&H.navigate(e),mr({pendingNavTarget:void 0}),A({mode:x.DEFAULT})},Lb=[{intent:P.InitCommandPalette,mode:x.DEFAULT,description:"[?] command palette",action:()=>{ne("");let{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:r}=v();return mr({pendingNavTarget:{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:r}}),A({mode:x.PALETTE}),d("Opening command palette",null)}},{intent:P.Confirm,mode:x.PALETTE,action:()=>{let{selectedNode:e}=v();if(!e||!Lm(e))return l("Command only applicable on text nodes");if(e.props.disabled)return l("Command is not available in this context");let t=e.title;return t?(hw(t),d("Selected command",t)):d("No command selected",null)}},{intent:P.ExitCommandLine,mode:x.PALETTE,action:()=>(Mb(),d("Exiting palette",null))},{intent:P.Exit,mode:x.PALETTE,action:()=>(Mb(),d("Closed command palette",null))},{intent:P.NavPreviousItem,mode:x.PALETTE,description:"[arrows/hjkl] navigate",action:()=>(H.navigateToPreviousItem(),d("Navigating to previous item",null))},{intent:P.NavNextItem,mode:x.PALETTE,action:()=>(H.navigateToNextItem(),d("Navigating to next item",null))},{intent:P.NavToPreviousContainer,mode:x.PALETTE,action:()=>(H.navigateToPreviousContainer(),d("Navigating to previous container",null))},{intent:P.NavToNextContainer,mode:x.PALETTE,action:()=>(H.navigateToNextContainer(),d("Navigating to next container",null))}]});var Db,Ob,_b=g(()=>{"use strict";Ar();Pn();ii();Ha();Oe();N();Ya();Eo();pe();jt();ge();D();Sb();Kn();Jn();wb();kb();Pb();It();Db=()=>{let e=ur();if(!e)return d("Nothing to comment on here",null);let t=Ka();if(!t||t.sha!==e)return l("The diff is still loading");let{selectedIndex:n}=v(),r=Math.max(0,n),o=Rd(t.rows,Od(e)??r,r);return o.ok?(A({mode:x.COMMAND_LINE}),ne(`${I.COMMENT} ${av(o.value.start,o.value.end)} `),d("Commenting on a diff line",null)):l(o.reason)},Ob=[{intent:P.InitCommandLine,mode:x.DEFAULT,description:"[:] write command",action:()=>(A({mode:x.COMMAND_LINE}),ne(""),d("Entering command line mode",null))},...Cb,...Tb,...Lb,{intent:P.AddItem,mode:x.DEFAULT,description:"[n] new...",action:()=>(A({mode:x.COMMAND_LINE}),ne(`${I.NEW} `),d("Adding new item",null))},{intent:P.Delete,mode:x.DEFAULT,description:"[d] delete",action:()=>(A({mode:x.COMMAND_LINE}),ne(`${I.DELETE} `),d("Deleting item",null))},{intent:P.Confirm,mode:x.DEFAULT,description:"[<Enter>] confirm/enter",action:()=>{let{selectedNode:e,contextNode:t}=v();if(!Me(e?.id??"")?.length){let r=e?C.getAttachment(e.id):void 0;if(r)return Rb(r);if(ur())return Db();if(e?.title===Ae.DESCRIPTION)return A({mode:x.COMMAND_LINE}),ne(`${I.EDIT} description `),d("Propose command",!0);if(e?.title===Ae.ASSIGNEES)return A({mode:x.COMMAND_LINE}),ne(`${I.ASSIGN} `),d("Propose command",!0);if(e?.title===Ae.TAGS)return A({mode:x.COMMAND_LINE}),ne(`${I.TAG} `),d("Propose command",!0);if(t.title===Ae.DESCRIPTION&&e?.context==="TEXT")return A({mode:x.COMMAND_LINE}),ne(`${I.EDIT} description `),d("Propose command",!0)}return H.enterChildNode(),d("Entering context",null)}},{intent:P.OpenInEditor,mode:x.DEFAULT,action:()=>{let{selectedNode:e,contextNode:t}=v(),n=t.parentNodeId,o=!!n&&t.id===Te(n,"diff")?e?.id:ur()??void 0;return o?Md({sha:o}):d("Nothing here opens in an editor",null)}},{intent:P.MarkDiffLine,mode:x.DEFAULT,action:()=>{let e=ur();if(!e)return d("Nothing to mark here",null);let{selectedIndex:t}=v(),n=Od(e);return Gr(n===t?null:{sha:e,row:Math.max(0,t)}),d("Marked diff line",null)}},{intent:P.CommentOnDiffLine,mode:x.DEFAULT,action:()=>ur()?Db():d("Nothing to comment on here",null)},{intent:P.Yank,mode:x.DEFAULT,description:"[y] yank",action:()=>{let{selectedNode:e}=v(),t=e?.title===Ae.DESCRIPTION?He.DESCRIPTION:e?.title===Ae.TAGS?He.TAGS:e?.title===Ae.ASSIGNEES?He.ASSIGNEES:He.REF,r=We(I.YANK).includes(t)?t:He.REF;return A({mode:x.COMMAND_LINE}),ne(`${I.YANK} ${r}`),d("Propose command",!0)}},{intent:P.EditTitle,mode:x.DEFAULT,description:"[r] rename title",action:()=>(A({mode:x.COMMAND_LINE}),ne(`${I.EDIT} title ${v().selectedNode?.title}`),d("Exiting context",null))},{intent:P.EditDescription,mode:x.DEFAULT,description:"[e] edit desc",action:()=>(A({mode:x.COMMAND_LINE}),ne(`${I.EDIT} description `),d("Exiting context",null))},{intent:P.Exit,mode:x.DEFAULT,description:"[q] exit context",action:()=>(H.enterParentNode(),d("Exiting context",null))},{intent:P.NavPreviousItem,mode:x.DEFAULT,description:"[arrows/hjkl] navigate (shift x5)",action:()=>(H.navigateToPreviousItem(),d("Navigating to previous item",null))},{intent:P.NavNextItem,mode:x.DEFAULT,action:()=>(H.navigateToNextItem(),d("Navigating to next item",null))},{intent:P.NavPreviousItemJump,mode:x.DEFAULT,action:()=>(H.jumpToPreviousItem(),d("Jumping to previous item",null))},{intent:P.NavNextItemJump,mode:x.DEFAULT,action:()=>(H.jumpToNextItem(),d("Jumping to next item",null))},{intent:P.NavToPreviousContainer,mode:x.DEFAULT,action:()=>(H.navigateToPreviousContainer(),d("Navigating to previous container",null))},{intent:P.NavToNextContainer,mode:x.DEFAULT,action:()=>(H.navigateToNextContainer(),d("Navigating to next container",null))}]});var vw,yw,Fb,Bb=g(()=>{"use strict";ge();vw=500,yw=e=>e.replace(/[\r\n]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,""),Fb=e=>{let t=yw(e);t&&na(n=>(n+t).slice(0,vw))}});var bw,xw,Iw,$b,jb=g(()=>{"use strict";Bb();Oe();N();ge();D();Kn();du();bw=[x.COMMAND_LINE,x.PALETTE],xw=e=>e==="edit title "?v().selectedNode?.title??"":"",Iw=e=>[{intent:P.MoveCursorLeft,mode:e,action:()=>(yc(-1),d("Moving cursor left",null))},{intent:P.MoveCursorRight,mode:e,action:()=>(yc(1),d("Moving cursor right",null))},{intent:P.MoveCursorLeftOfWord,mode:e,action:()=>(bc("left"),d("Moving cursor left of word",null))},{intent:P.MoveCursorRightOfWord,mode:e,action:()=>(bc("right"),d("Moving cursor right of word",null))},{intent:P.AutoCompleteCommand,mode:e,action:()=>(na((t,{remainder:n})=>{let r=n?t+n:t;return r+xw(r)}),d("Auto-completing command",null))},{intent:P.CaptureInput,mode:e,action:(t,{sequence:n})=>(Fb(n??""),d("Capturing input",null))},{intent:P.EraseInput,mode:e,action:()=>(yf(),d("Erasing input",null))},{intent:P.EraseInputWord,mode:e,action:()=>(bf(),d("Erasing input word",null))}],$b=[{intent:P.Confirm,mode:x.COMMAND_LINE,action:()=>(Vt(),d("Executing command",null))},{intent:P.ViewHelp,mode:x.DEFAULT,action:()=>(A({mode:x.HELP}),d("Viewing help",null))},...bw.flatMap(Iw),{intent:P.ExitCommandLine,mode:x.COMMAND_LINE,action:()=>(Rf(),A({mode:x.DEFAULT}),d("Exiting command line",null))},{intent:P.GetLastCommandFromHistory,mode:x.COMMAND_LINE,action:()=>(Sf(),d("Getting last command from history",null))},{intent:P.GetNextCommandFromHistory,mode:x.COMMAND_LINE,action:()=>(Nf(),d("Getting next command from history",null))}]});var Ew,Ub,Hb,Wb=g(()=>{"use strict";Ew=e=>{let t=/^\[(.+?)\]\s*(.+)$/.exec(e);return t?{keys:t[1]??"",label:t[2]??""}:null},Ub=({keys:e})=>e.length===1?0:1,Hb=(e,t)=>{let n=new Set;for(let r of e)r.mode!==t||!r.description||n.add(r.description);return[...n].map(Ew).filter(r=>r!==null).sort((r,o)=>Ub(r)-Ub(o))}});function qb(e,t,n){let r=t[e];if(!r)return l("buildBreadCrumb(): current node not found");let o=[],s=new Set,i=r;for(;i&&!s.has(i.id)&&(o.push(i),s.add(i.id),!(i.id===n||!i.parentNodeId));)i=t[i.parentNodeId];let c=o[o.length-1];return!c||c.id!==n?l("buildBreadCrumb(): node is not connected to root"):(o.reverse(),d("Breadcrumb built",o))}var Gb=g(()=>{"use strict";N()});var zb,Vb=g(()=>{"use strict";zb=e=>{let t={};for(let n of e)n.intent&&(t[n.mode]||(t[n.mode]={}),t[n.mode][n.intent]=n);return t}});import{useSyncExternalStore as Rw}from"react";function fu(e){let{contextNodeId:t,mode:n,rootNodeId:r,nodes:o,filters:s}=e;if(!t)return l("derive(): contextNodeId is missing");if(!r)return l("derive(): rootNode is missing");if(!o[r])return l("derive(): unable to find root node");let c=o[t];if(!c)return l("Unable to derive state, contextNode not found");let u=qb(t,o,r);if(a(u))return logger.error(u.message),u;let p=u.value,{context:m}=c,f=[...Ob,...bb[m]??[],...$b],h=Hb(f,n),b=zb(f),E=Nw(o,s),S=E[t]?.[e.selectedIndex]??null;return d("Derived successfully",{...e,contextNode:c,breadCrumb:p,availableHints:h,availableActions:f,actionIndex:b,selectedNode:S,renderedChildrenIndex:E})}function Us(e){uu=e;let t=Ce(process.cwd()),n=!1;if(!a(t)){let s=Tt(t.value);if(a(s))return l(s.message);n=!0}let r={readOnly:!1,filters:[],tags:{},contributors:{},emailLinks:{},mode:x.DEFAULT,nodes:{[e.id]:e},rootNodeId:e.id,contextNodeId:e.id,renderedChildrenIndex:{},selectedIndex:-1,syncStatus:{status:"synced",msg:""},eventLog:[],unappliedEvents:[],replay:null,timeMode:"live",hasProjectDefinition:n,hasInitializingEvents:!1,comments:{},attachments:{}},o=fu(r);return a(o)?o:(St=o.value,pu(),d("State initialized",null))}function Pe(e){let t=v(),n=e(t);if(Yr)return n.nodes!==t.nodes&&(pr=null),vi=n,St={...t,...n},d("State updated",null);let r=fu(n);return a(r)?l(r.message??"Unable to update state"):(St=r.value,pu(),d("State updated",null))}function ga(e){if(Yr)return d("Joined batch",e());Yr=!0,vi=null,pr=new Set;let t=()=>{let n=vi;if(Yr=!1,vi=null,n===null)return null;let r=fu(n);return a(r)?l(r.message??"Unable to update state"):(St=r.value,pu(),d("State updated",null))};try{let n=e(),r=t();return r&&a(r)?l(r.message):d("State updated",n)}finally{Yr&&t()}}function Xr(e,t,n){if(!Yr)return Pe(i=>({...i,[e]:{...i[e]??{},[t]:n}}));let r=v(),o=r[e]??{};if(e==="nodes"){let i=o[t],c=n;i?.parentNodeId&&pr?.add(i.parentNodeId),c.parentNodeId&&pr?.add(c.parentNodeId)}o[t]=n;let s={...r,[e]:o};return vi=s,St={...r,...s},d("State updated",null)}var St,uu,mu,pu,Sw,v,ke,Yr,vi,Pg,A,Ye,pr,Kb,Nw,be,qn,Ut,D=g(()=>{"use strict";xb();_b();jb();Wb();Zt();Oe();N();ee();qc();Gb();Vb();wt();tc();mu=new Set,pu=()=>{for(let e of mu)e()},Sw=e=>(mu.add(e),()=>mu.delete(e));v=()=>{if(!St)throw new Error("State not initialized. Call initWorkspaceState() first.");return St},ke=()=>St?d("Retrieved state",St):l("State not initialized. Call initWorkspaceState() first.");Np(e=>St?Vn(St.emailLinks,e):[]);Yr=!1,vi=null;Pg=()=>Yr,A=e=>Pe(t=>({...t,...e}));Ye=()=>Rw(Sw,v,v),pr=null,Kb=null,Nw=(e,t)=>{let n=St?.renderedChildrenIndex,r=n!==void 0&&pr!==null&&e===Kb&&t.length===0&&St?.filters.length===0,o;if(r){o={...n};let s=Tg(e,pr);for(let i of pr){let c=s[i];c?o[i]=c:delete o[i]}}else o=Ag(e,t);return Kb=e,pr=new Set,o},be=e=>v()?.renderedChildrenIndex[e]??[],qn=()=>uu?Us(uu):l("Cannot reset state: no initial workspace found"),Ut=()=>St!==void 0});var zt,Cw,fr,C,pe=g(()=>{"use strict";Xt();wt();me();N();D();jt();zt=(e,t)=>{let{nodes:n}=v(),r=n[e];if(!r)return l("Node not found");if(r.context===t)return d("Resolved ancestor node",r);let o=new Set([r.id]),s=r.parentNodeId?n[r.parentNodeId]:void 0;for(;s&&!o.has(s.id);){if(s.context===t)return d("Resolved ancestor node",s);o.add(s.id),s=s.parentNodeId?n[s.parentNodeId]:void 0}return l(`No ancestor found for context: ${t}`)},Cw=(e,t)=>{let{nodes:n}=v(),r=new Set,o=n[e];for(;o?.parentNodeId&&!r.has(o.id);){if(o.parentNodeId===t)return!0;r.add(o.id),o=n[o.parentNodeId]}return!1},fr=(e,t)=>e?e.readonly?l({move:"Cannot move readonly node",rename:"Cannot rename readonly node",edit:"Cannot edit readonly node",delete:"Cannot delete readonly node"}[t]):null:l("Node not found"),C={linkUserId({contributorId:e,userId:t}){let n=this.getContributor(e);if(!n)return l("Contributor not found");if(n.userId&&n.userId!==t)return l("Contributor is already linked to another user");let r={...n,userId:t},o=Pe(s=>({...s,contributors:{...s.contributors,[e]:r}}));return a(o)?l("Unable to link contributor to user"):d("Linked contributor to user",r)},deleteNode(e){C.deleteNodes([e])},deleteNodes(e){e.length!==0&&Pe(t=>{let n={...t.nodes};for(let r of e)delete n[r];return{...t,nodes:n}})},createComment(e){let t=this.getNode(e.issue);if(!t)return l("Unable to create comment, missing issue");if(!U(t))return l("Can only comment on issues");let n=Xr("comments",e.id,{...e,deleted:!1});return a(n)?l("Unable to create comment"):d("Created comment",{...e,deleted:!1})},editComment(e,t){let n=this.getComment(e);if(!n)return l("Unable to edit comment, missing comment");let r=this.getNode(n.issue);if(!r)return l("Unable to edit comment, missing issue");if(!U(r))return l("Can only edit issue comments");let o={...n,md:t,deleted:!1},s=Xr("comments",e,o);return a(s)?l("Unable to edit comment"):d("Edited comment",o)},deleteComment(e){let t=this.getComment(e);if(!t)return l("Unable to delete comment, missing comment");let n={...t,deleted:!0},r=Xr("comments",e,n);return a(r)?l("Unable to delete comment"):d("Deleted comment",n)},getComment(e){return v().comments?.[e]},getCommentsByIssue(e){return Object.values(v().comments??{}).filter(t=>t.issue===e&&!t.deleted)},getCommentsGroupedByIssue(){let e=new Map;for(let t of Object.values(v().comments??{})){if(t.deleted)continue;let n=e.get(t.issue);n?n.push(t):e.set(t.issue,[t])}return e},createAttachment(e){let t=this.getNode(e.issue);if(!t)return l("Unable to create attachment, missing issue");if(!U(t))return l("Can only attach to issues");let n=Pe(r=>({...r,attachments:{...r.attachments??{},[e.id]:{...e,deleted:!1}}}));return a(n)?l("Unable to create attachment"):d("Created attachment",{...e,deleted:!1})},deleteAttachment(e){let t=this.getAttachment(e);if(!t)return l("Unable to delete attachment, missing attachment");let n={...t,deleted:!0},r=Pe(o=>({...o,attachments:{...o.attachments??{},[e]:n}}));return a(r)?l("Unable to delete attachment"):d("Deleted attachment",n)},getAttachment(e){return v().attachments?.[e]},getAttachmentsByIssue(e){return Object.values(v().attachments??{}).filter(t=>t.issue===e&&!t.deleted)},getAttachmentsGroupedByIssue(){let e=new Map;for(let t of Object.values(v().attachments??{})){if(t.deleted)continue;let n=e.get(t.issue);n?n.push(t):e.set(t.issue,[t])}return e},editValue(e,t){let{nodes:n}=v(),r=n[e];if(!r)return l("Edit target node not found");let o=fr(r,"edit");if(o)return o;let s={...r,props:{...r.props,description:t}};return this.updateNode(s),d("Issue description updated",{md:t})},renameNode(e,t){let n=this.getNode(e);if(!n)return l("Rename target node not found");let r=fr(n,"rename");if(r)return r;let o={...n,title:t};return this.updateNode(o),d("Renamed node",o)},getExistingTags(){let{tags:e}=v();return[...new Set(Object.values(e).map(t=>t.name).filter(Boolean))]},getExistingAssignees(){let{contributors:e}=v();return["me",...new Set(Object.values(e).map(t=>t.name).filter(Boolean))]},getFieldByTitle(e,t){return Me(e).find(n=>n.title===t)},moveNodeToRank({id:e,parentId:t,rank:n}){let{rootNodeId:r}=v(),o=this.getNode(e),s=this.getNode(t);if(!o)return l("Node not found");if(!s)return l("Target parent not found");if(r===e)return l("Cannot move root node");if(e===t)return l("Cannot move node into itself");let i=fr(o,"move");if(i)return i;if(Cw(t,e))return l("Cannot move node into its own descendant");let c={...o,parentNodeId:t,rank:n};return this.updateNode(c),d("Moved node successfully",c)},tombstoneNode(e){let{nodes:t,contextNodeId:n,rootNodeId:r}=v(),o=this.getNode(e);if(!o)return l("Node not found");if(r===e)return l("Cannot delete root node");let s=fr(o,"delete");if(s)return s;let i=new Set,c=p=>{let m=t[p];if(!(!m||i.has(p))){i.add(p);for(let f of Me(m.id))c(f.id)}};c(e);let u={...structuredClone(t)};for(let p of i){if(!u[p])return l("Unable to locate node to delete");u[p]={...u[p],isDeleted:!0}}return n?(A({nodes:u}),d("Successfully tomb stoned",o)):l("Unable to delete undefined")},tombstoneContributor(e){let t=this.getContributor(e);if(!t)return l("Contributor not found");let n={...t,name:cs,tombstoned:!0},r=Pe(o=>({...o,contributors:{...o.contributors,[e]:n}}));return a(r)?l("Unable to remove contributor"):d("Tombstoned contributor",n)},renameContributor(e,t){let n=this.getContributor(e);if(!n)return l("Contributor not found");if(n.tombstoned)return l("Cannot rename a removed contributor");let r={...n,name:t},o=Pe(s=>({...s,contributors:{...s.contributors,[e]:r}}));return a(o)?l("Unable to rename contributor"):d("Renamed contributor",r)},restoreContributor(e,t){let n=this.getContributor(e);if(!n)return l("Contributor not found");let r={...n,name:t,tombstoned:!1},o=Pe(s=>({...s,contributors:{...s.contributors,[e]:r}}));return a(o)?l("Unable to restore contributor"):d("Restored contributor",r)},linkContributorEmail({email:e,contributor:t,authorId:n}){if(!this.getContributor(t))return l("Unable to link email, missing contributor");let r={email:Ve(e),contributor:t,authorId:n},o=ds(r.email,t),s=v().emailLinks[o];if(s&&!s.tombstoned)return d("Email already linked",s);let i=Pe(c=>({...c,emailLinks:{...c.emailLinks,[o]:r}}));return a(i)?l("Unable to link email"):d("Linked email to contributor",r)},unlinkContributorEmail(e,t,n){let r=ds(e,t),o=v().emailLinks[r];if(!o)return l("Unable to unlink, no such link");if(o.tombstoned)return d("Email already unlinked",o);if(!ki(n,o))return l("Only the author of a link or the contributor it names may remove it");let s={...o,tombstoned:!0},i=Pe(c=>({...c,emailLinks:{...c.emailLinks,[r]:s}}));return a(i)?l("Unable to unlink email"):d("Unlinked email from contributor",s)},getEmailLinks(){return v().emailLinks},createContributor(e){let t=Pe(n=>({...n,contributors:{...n.contributors,[e.id]:e}}));return a(t)?l("Unable to create contributor"):d("Created contributor",e)},assign(e,t){let n=this.getContributor(t),r=this.getNode(e);if(!n)return l("Unable to assign contributor, missing contributor");if(!r)return l("Unable to assign contributor, missing target");let o=fr(r,"edit");if(o)return o;if(!U(r))return l("Target is not an issue");let s=r.props.assignees??[];if(s.includes(t))return l("Contributor already assigned");let i={...r,props:{...r.props,assignees:[...s,t]}};return this.updateNode(i),d("Assigned contributor",{assignee:t})},unassign(e,t){let n=this.getContributor(t),r=this.getNode(e);if(!n)return l("Unable to unassign, missing contributor");if(!r)return l("Unable to unassign, missing target");let o=fr(r,"edit");if(o)return o;if(!U(r))return l("Target is not an issue");let s=r.props.assignees??[];if(!s.includes(t))return d("Issue is not assigned to that contributor",{assignee:t});let i={...r,props:{...r.props,assignees:s.filter(c=>c!==t)}};return this.updateNode(i),d("Assignee removed",{assignee:t})},tag(e,t){let n=this.getTag(t),r=this.getNode(e);if(!n)return l("Unable to add tag, missing tag");if(!r)return l("Unable to add tag, missing target");let o=fr(r,"edit");if(o)return o;if(!U(r))return l("Target is not an issue");let s=r.props.tags??[];if(s.includes(t))return l("Tag already assigned");let i={...r,props:{...r.props,tags:[...s,t]}};return this.updateNode(i),d("Tag added",{tag:t})},untag(e,t){let n=this.getTagRecord(t),r=this.getNode(e);if(!n)return l("Unable to remove tag, missing tag");if(!r)return l("Unable to remove tag, missing target");let o=fr(r,"edit");if(o)return o;if(!U(r))return l("Target is not an issue");let s=r.props.tags??[];if(!s.includes(t))return d("Issue is not tagged with that tag",{tag:t});let i={...r,props:{...r.props,tags:s.filter(c=>c!==t)}};return this.updateNode(i),d("Tag removed",{tag:t})},tombstoneTag(e){let t=this.getTagRecord(e);if(!t)return l("Tag not found");let n={...t,tombstoned:!0},r=Pe(o=>({...o,tags:{...o.tags,[e]:n}}));return a(r)?l("Unable to delete tag"):d("Tombstoned tag",n)},restoreTag(e,t){let n=this.getTagRecord(e);if(!n)return l("Tag not found");let r={...n,name:t,tombstoned:!1},o=Pe(s=>({...s,tags:{...s.tags,[e]:r}}));return a(o)?l("Unable to restore tag"):d("Restored tag",r)},createTag(e){let t=Pe(n=>({...n,tags:{...n.tags,[e.id]:e}}));return a(t)?l("Could not create tag"):d("Tag created",e)},createNode(e){let t=Xr("nodes",e.id,e);return a(t)?l("Unable to create node"):d("Node created",e)},lockNode(e){let t=this.getNode(e);if(!t)return l("Failed to locate node");let n={...t,readonly:!0},r=Xr("nodes",e,n);return a(r)?l(r.message):d("Locked node",n)},updateNode(e){let t=Xr("nodes",e.id,e);return a(t)?t:d("Updated node",e)},getContributor(e){return v().contributors[e]},getTag(e){let t=v().tags[e];return t?.tombstoned?void 0:t},getTagRecord(e){return v().tags[e]},getTags(){return Object.values(v().tags).filter(e=>!e.tombstoned)},findTagByName(e){return this.getTags().find(t=>t.name===e)},getNode(e){return v().nodes[e]},getSiblings(e){return Me(e)}}});import gr from"chalk";import Yb from"string-width";var ww,Aw,gu,Tw,kw,Xb,Jb,Mw,Lw,Pw,Dw,Ow,_w,nu,Qb,pi=g(()=>{"use strict";lt();N();Tn();pe();D();un();ei();ww=(e,t)=>e+" ".repeat(Math.max(0,t-Yb(e))),Aw=(e,t)=>" ".repeat(Math.max(0,t-Yb(e)))+e,gu=e=>({"add.issue":"Created with title","add.issue.assignee":"Assigned to","remove.issue.assignee":"Unassigned from","close.issue":"Closed","delete.node":"Deleted","edit.title":"Changed title to","edit.description":"Changed description","reopen.issue":"Reopened","add.issue.tag":"Tagged with","remove.issue.tag":"Removed tag","lock.node":"Locked node","move.node":"Moved issue","add.issue.comment":"Commented","delete.issue.comment":"Deleted comment","add.issue.attachment":"Attached","delete.issue.attachment":"Removed attachment","edit.issue.comment":"Edited comment","init.workspace":"Created workspace","add.workspace":"Created workspace","add.board":"Created board","add.swimlane":"Created swimlane","add.field":"Added field","create.tag":"Created tag","tombstone.tag":"Deleted tag","restore.tag":"Restored tag","create.contributor":"Added contributor","rename.contributor":"Renamed contributor","link.contributor.user":"Linked contributor","link.contributor.email":"Claimed","unlink.contributor.email":"Unclaimed","tombstone.contributor":"Removed contributor","restore.contributor":"Restored contributor","rebalance.children":"Rebalanced order"})[e]??(e.endsWith("e")?`${e}d`:`${e}ed`),Tw=(e,t)=>t?e<t?"up":e>t?"down":null:null,kw=(e,t)=>{let n=C.getNode(e.payload.parent),r=n?gr.dim.bgBlack(` ${n.title} `):"unknown",o=t.at(-1);if(o&&"parent"in o&&"rank"in o&&o.parent===e.payload.parent){let s=Tw(e.payload.rank,o.rank);if(s)return`Moved ${s} in ${r}`}return`Moved issue to ${r}`},Xb=e=>`${Math.max(1,Math.round(e/1024))} KB`,Jb=e=>C.getAttachment(e)?.name??"",Mw=e=>{switch(e.action){case"add.issue.tag":{let t=v().tags[e.payload.tag];return t?gr.bgHex(tt(t.name))(` ${t.name} `):"unknown tag"}case"remove.issue.tag":{let t=v().tags[e.payload.tag];return t?gr.bgHex(tt(t.name))(` ${t.name} `):"unknown tag"}case"tombstone.tag":{let t=v().tags[e.payload.id];return t?`"${t.name}"`:""}case"add.issue.assignee":{let t=v().contributors[e.payload.assignee];return t?gr.hex(tt(t.name))(` ${t.name} `):"unknown user"}case"remove.issue.assignee":{let t=v().contributors[e.payload.assignee];return t?gr.hex(tt(t.name))(` ${t.name} `):"unknown user"}case"add.board":case"add.swimlane":case"add.issue":case"add.field":case"create.tag":case"restore.tag":case"create.contributor":case"rename.contributor":case"edit.title":return`"${"name"in e.payload?e.payload.name:""}"`;case"link.contributor.email":case"unlink.contributor.email":return e.payload.email;case"add.issue.attachment":return`"${e.payload.name}" ${gr.dim(`(${Xb(e.payload.bytes)})`)}`;case"delete.issue.attachment":{let t=Jb(e.payload.id);return t?`"${t}"`:""}default:return""}},Lw=e=>{let t=ar(at(e));return gr.gray(Aw(t,8))},Pw=12,Dw=e=>ww(`${e}`,Pw),Ow=e=>{let t=ke();return a(t)?e:ls(e,t.value.contributors[e]?.name)},_w=e=>{switch(e.action){case"add.issue.tag":case"remove.issue.tag":{let t=v().tags[e.payload.tag];return t?t.name:""}case"add.issue.assignee":case"remove.issue.assignee":{let t=v().contributors[e.payload.assignee];return t?t.name:""}case"tombstone.tag":{let t=v().tags[e.payload.id];return t?`"${t.name}"`:""}case"add.board":case"add.swimlane":case"add.issue":case"add.field":case"create.tag":case"restore.tag":case"create.contributor":case"rename.contributor":case"edit.title":return"name"in e.payload?`"${e.payload.name}"`:"";case"link.contributor.email":case"unlink.contributor.email":return e.payload.email;case"move.node":{let t=C.getNode(e.payload.parent);return t?`to ${t.title}`:""}case"add.issue.attachment":return`"${e.payload.name}" (${Xb(e.payload.bytes)})`;case"delete.issue.attachment":{let t=Jb(e.payload.id);return t?`"${t}"`:""}default:return""}},nu=e=>[gu(e.action),_w(e)].filter(Boolean).join(" "),Qb=(e,t)=>{let n=Lw(e.id),r=Dw(Ow(e.userId)),o=gr.dim("\u203A"),s=e.action==="move.node"?kw(e,t):[gu(e.action),Mw(e)].filter(Boolean).join(" ");return`${r} ${n} ${o} ${s}`}});var ex={};rs(ex,{areVirtualNodesEnabled:()=>va,createOrUpdateVirtualField:()=>qo,createOrUpdateVirtualFieldList:()=>hu,materializeTicketVirtualNodes:()=>ha,materializeVirtualNodes:()=>Vw,setVirtualNodesEnabled:()=>zw});var Fw,Bw,$w,jw,Uw,Hw,Ww,qo,hu,pl,qw,ha,Gw,Zb,zw,va,Vw,$c=g(()=>{"use strict";pi();me();N();Eo();pe();sr();D();bo();Jn();Fw=e=>Te(e,"comments"),Bw=e=>Te(e,"description"),$w=e=>Te(e,"assignees"),jw=e=>Te(e,"tags"),Uw=e=>Te(e,"history"),Hw=e=>Te(e,"diff"),Ww=e=>Te(e,"attachments"),qo=({id:e,name:t,parentNodeId:n,rank:r,value:o,readonly:s=!1,childRenderAxis:i="horizontal"})=>{let c=C.getNode(e);if(!c){let m=C.createNode({...$e.field({id:e,name:t,parentNodeId:n,rank:r,props:{value:o},isVirtual:!0}),readonly:s,childRenderAxis:i});return a(m)?m:d("Virtual field created",void 0)}if(!nt(c))return l(`Existing virtual node ${e} is not a field`);if(!(c.title!==t||c.parentNodeId!==n||c.rank!==r||c.props.value!==o||c.readonly!==s||c.childRenderAxis!==i))return d("Virtual field unchanged",void 0);let p=C.updateNode({...c,title:t,parentNodeId:n,rank:r,props:{...c.props,value:o},readonly:s,childRenderAxis:i});return a(p)?p:d("Virtual field updated",void 0)},hu=({id:e,name:t,parentNodeId:n,rank:r,readonly:o=!1,childRenderAxis:s="horizontal"})=>{let i=C.getNode(e);if(!i){let p=C.createNode({...$e.fieldList({id:e,name:t,parentNodeId:n,rank:r,isVirtual:!0}),readonly:o,childRenderAxis:s});return a(p)?p:d("Virtual field list created",void 0)}if(!us(i))return l(`Existing virtual node ${e} is not a field list`);if(!(i.title!==t||i.parentNodeId!==n||i.rank!==r||i.readonly!==o||i.childRenderAxis!==s))return d("Virtual field list unchanged",void 0);let u=C.updateNode({...i,title:t,parentNodeId:n,rank:r,readonly:o,childRenderAxis:s});return a(u)?u:d("Virtual field list updated",void 0)},pl=null,qw=()=>{if(pl)return d("Virtual field ranks",pl);let e=Lt(rn/4n),t=Lt(rn/2n),n=Lt(rn*3n/4n),r=Lt(rn*7n/8n),o=Lt(rn*15n/16n),s=Lt(rn*13n/16n),i=Lt(rn*27n/32n);return a(e)?e:a(t)?t:a(n)?n:a(r)?r:a(o)?o:a(s)?s:a(i)?i:(pl={description:e.value,assignees:t.value,tags:n.value,comments:r.value,attachments:o.value,log:s.value,diff:i.value},d("Virtual field ranks",pl))},ha=e=>{let t=qw();if(a(t))return t;let n=t.value,r=qo({id:Bw(e.id),name:Ae.DESCRIPTION,parentNodeId:e.id,rank:n.description,value:e.props.description??"",childRenderAxis:"vertical"});if(a(r))return r;let o=hu({id:$w(e.id),name:Ae.ASSIGNEES,parentNodeId:e.id,rank:n.assignees,readonly:!0});if(a(o))return o;let s=hu({id:jw(e.id),name:Ae.TAGS,parentNodeId:e.id,rank:n.tags,readonly:!0});if(a(s))return s;let i=qo({id:Fw(e.id),name:Ae.COMMENTS,parentNodeId:e.id,rank:n.comments,value:"",readonly:!1,childRenderAxis:"vertical"});if(a(i))return i;let c=qo({id:Ww(e.id),name:Ae.ATTACHMENTS,parentNodeId:e.id,rank:n.attachments,value:"",readonly:!0,childRenderAxis:"vertical"});if(a(c))return c;let u=qo({id:Uw(e.id),name:Ae.HISTORY,parentNodeId:e.id,rank:n.log,value:Gw(e),readonly:!0,childRenderAxis:"vertical"});if(a(u))return u;let p=qo({id:Hw(e.id),name:Ae.DIFF,parentNodeId:e.id,rank:n.diff,value:"",readonly:!0,childRenderAxis:"vertical"});return a(p)?p:d("Ticket virtual nodes materialized",void 0)},Gw=e=>{let t=[...e.log].reverse(),n=new Map;for(let r of t){let o=n.get(r.action)??[];o.push(r.payload),n.set(r.action,o)}return t.map(r=>Qb(r,n.get(r.action)??[])).join(`
107
+ `)},Zb=!0,zw=e=>{Zb=e},va=()=>Zb,Vw=()=>{let{nodes:e}=v();for(let t of Object.values(e)){if(!U(t))continue;let n=ha(t);if(a(n))return n}return d("Virtual nodes materialized",void 0)}});var Kw,Yw,fl,vu=g(()=>{"use strict";lt();Kw=e=>{switch(e.action){case"add.issue":case"move.node":case"close.issue":case"reopen.issue":return e.payload.parent;default:return null}},Yw=(e,t)=>{let n=[];for(let r of e){let o=Kw(r);if(o===null||o===n.at(-1)?.laneId)continue;let s=br(r);n.push({laneId:o,enteredAt:s===null?t:is(s)})}return n},fl=(e,t)=>Yw(e,t).at(-1)?.enteredAt??t});var tx=g(()=>{"use strict";Xt()});var Xw,nx,gl=g(()=>{"use strict";lt();$();xo();pi();N();tx();Tn();tn();Xw=e=>{let t=new Map,n=new Set,r=o=>{let s=new Set,i=o;for(;i&&!s.has(i);){if(n.has(i))return i;s.add(i),i=t.get(i)}return null};return e.map(o=>{let s=o.payload,i=s?.id;if(!i)return null;o.action==="add.board"&&n.add(i);let c=o.action==="close.issue"?r(i):null,u=s.parent??s.issue;return u&&t.set(i,u),c!==null?c:n.has(i)?i:r(i)})},nx=(e,t)=>{let n=Xw(e);return e.filter((r,o)=>n[o]===t)}});var Jw,rx,ox,Jr,yi=g(()=>{"use strict";rt();Do();gl();$();$();N();D();tn();gl();Jw=null,rx=Promise.resolve(),ox=e=>{let t=rx.then(e,e);return rx=t.then(()=>{},()=>{}),t},Jr=()=>{if(!Ut())return{mode:"live",asOfTime:null};let{timeMode:e}=v();return e==="live"?{mode:"live",asOfTime:null}:{mode:"scrub",asOfTime:Jw}}});var sx,Qw,ix,ax,Qr,bi=g(()=>{"use strict";Ke();wt();sx=new Map,Qw=3e4,ix=async e=>{let t=sx.get(e);if(t&&Date.now()-t.readAt<Qw)return{name:t.name,email:t.email};let n=await Le({args:["config","--get-regexp","^user\\.(name|email)$"],cwd:e}),r=null,o=null;if(n.exitCode===0)for(let s of(n.stdout??"").split(`
108
+ `)){let i=s.indexOf(" ");if(i===-1)continue;let c=s.slice(0,i),u=s.slice(i+1);c==="user.name"&&(r=u.trim()||null),c==="user.email"&&(o=Ve(u)||null)}return sx.set(e,{name:r,email:o,readAt:Date.now()}),{name:r,email:o}},ax=async e=>(await ix(e)).email,Qr=async e=>(await ix(e)).name});import Zw from"node:fs";var Zr,hl,Z,te,X,cn=g(()=>{"use strict";rt();Ke();mn();Ys();bi();bn();Ue();jr();xo();ee();$();N();D();_t();yi();Zr=e=>{let t=Ce(e??process.cwd());return a(t)?l(t.message):d("Resolved Epiq repo root",t.value)},hl=null,Z=async(e,t)=>{let n=Zr(e);if(a(n))return n;let r=Ie({repoRoot:n.value});if(a(r))return l(r.message);let o=dt(n.value);if(a(o))return l(o.message);if(!(hl!==null&&hl.repoRoot===n.value&&hl.stateBranchRoot===r.value&&Zw.existsSync(Cr(r.value)))){let f=await Vs({repoRoot:n.value,stateBranchName:o.value});if(a(f))return l(f.message);let h=await ir({repoRoot:n.value,stateBranchRoot:r.value,stateBranchName:o.value});if(a(h))return l(h.message);hl={repoRoot:n.value,stateBranchRoot:r.value}}if(t?.pull??!1){let f=await W({cwd:r.value,args:["pull","--ff-only"]});a(f)&&ce.info(3,f.message)}let i={repoRoot:n.value,stateBranchRoot:r.value},c=Xn();a(c)||ut(c.value),ut({gitEmail:await ax(n.value),gitName:await Qr(n.value)});let u=Pr(r.value);if(Of(r.value)===u&&Ut()&&Jr().mode==="live")return d("Booted Epiq state, unchanged",i);let p=sn(r.value);if(a(p))return l(p.message);let m=En(p.value.events,p.value.unreadable);return a(m)?l(m.message):(_f(r.value,u),d("Booted Epiq state",i))},te=()=>{let e=Xn();return a(e)?l(e.message):e.value.userId?e.value.userName?d("Resolved actor",{userId:e.value.userId,userName:e.value.userName}):l("Unable to retrieve user name"):l("Unable to retrieve user id")},X=()=>{let e=ke();return a(e)?l(e.message):e}});var Go,lx,zo,yu=g(()=>{"use strict";lt();pe();Tn();uo();Go=e=>hn(e).map(t=>ht(t.id,t.name)),lx=e=>C.getCommentsByIssue(e).sort((t,n)=>t.id<n.id?-1:t.id>n.id?1:0).map(t=>({id:t.id,author:ls(t.authorId,C.getContributor(t.authorId)?.name),createdAt:at(t.id),body:t.md})),zo=e=>vn(e).map(({id:t,name:n})=>ht(t,n))});var Ze,hr,bu,eo=g(()=>{"use strict";me();N();cn();Ze=e=>{let t=X();if(a(t))return t;let n=t.value.nodes[e];return!n||n.isDeleted?l("Issue not found"):U(n)?n.readonly?l("Issue is readonly"):d("Found issue",n):l("Target must be an issue")},hr=e=>{let t=X();if(a(t))return t;let n=t.value.nodes[e];return!n||n.isDeleted?l("Swimlane not found"):xr(n)?n.readonly?l("Swimlane is readonly"):d("Found swimlane",n):l("Target must be a swimlane")},bu=e=>{let t=X();if(a(t))return t;let n=t.value.nodes[e];return!n||n.isDeleted?l("Board not found"):Ir(n)?n.readonly?l("Board is readonly"):d("Found board",n):l("Target must be a board")}});import eA from"node:fs";import tA from"node:path";import{ulid as cx}from"ulid";var nA,dx,xu,Iu=g(()=>{"use strict";bn();$();$t();N();vt();eo();fo();cn();nA=e=>{if(e.filePath)try{return d("Read attachment file",{data:eA.readFileSync(e.filePath),name:e.name??tA.basename(e.filePath)})}catch(t){return l(`Unable to read ${e.filePath}: ${t instanceof Error?t.message:String(t)}`)}return e.dataBase64?d("Decoded attachment data",{data:Buffer.from(e.dataBase64,"base64"),name:e.name??"image"}):l("Provide either filePath or dataBase64")},dx=()=>{let e=Xn();return a(e)?Dn:e.value.attachmentMaxKb??Dn},xu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Ze(e.issueId);if(a(o))return o;let s=nA(e);if(a(s))return s;let i=Jp(t.value.stateBranchRoot,s.value.data,dx());if(a(i))return i;let c=Se(s.value.name).trim()||"image",u=cx(),p={id:cx(),...O(n.value),action:"add.issue.attachment",payload:{id:u,issue:e.issueId,author:n.value.userId,hash:i.value.hash,ext:i.value.ext,name:c,bytes:i.value.bytes}},m=_([p],t.value.stateBranchRoot);if(a(m))return l(m.message);let f=po(i.value.hash,i.value.ext);return d("Added issue attachment",{id:u,issueId:e.issueId,fileName:f,bytes:i.value.bytes,markdown:mc(c,f)})}});var Eu,cJ,Ru,ux=g(()=>{"use strict";bn();lt();tn();me();N();pe();lo();Tn();un();vu();ft();vt();fo();_t();yi();cn();yu();Iu();wa();$();Gs();Eu=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=X();return a(n)?n:d("Retrieved Epiq state",{root:t.value.repoRoot,stateBranchRoot:t.value.stateBranchRoot,nodes:n.value.nodes,rootNodeId:n.value.rootNodeId,contextNode:n.value.contextNode,selectedIndex:n.value.selectedIndex,eventLog:n.value.eventLog})},cJ=365*24*60*60*1e3,Ru=async(e={})=>{Ro();let t=Zr(e.repoRoot);if(a(t))return l("Sync failed");let n=te();if(a(n))return n;let r=await Ca({cwd:t.value,ownEventFileName:rr(n.value)});return a(r)?(Gc(r.message),r):(Ur(),d("Synced",r.value))}});var xi,Vo,Ii,Su=g(()=>{"use strict";N();ft();xi=e=>{let t=[...new Set([...e.issueIds??[],...e.issueId?[e.issueId]:[]])];return t.length?d("Resolved targets",t):l("Provide issueId or issueIds")},Vo=(e,t)=>{let n=t.done.length,r=`${e} ${n} issue${n===1?"":"s"}`+(t.failed.length?`, ${t.failed.length} failed`:"");return n?d(r,t):l(`${r}: ${t.failed.map(o=>`${o.ref} ${o.reason}`).join("; ")}`)},Ii=(e,t)=>{let n={done:[],failed:[]};for(let r of e){let o=t(r);a(o)?n.failed.push({id:r,ref:V(r),reason:o.message}):n.done.push({id:r,ref:V(r)})}return n}});import{ulid as Kt}from"ulid";async function Cu(e){let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=X();if(a(n))return n;let r=n.value.nodes,o=e.query?.trim().toLowerCase(),s=Object.values(r).filter(U).filter(c=>!c.isDeleted).filter(c=>e.includeClosed||c.parentNodeId!==we).filter(c=>e.boardId?(c.parentNodeId?r[c.parentNodeId]:void 0)?.parentNodeId===e.boardId:!0).filter(c=>!e.swimlaneId||c.parentNodeId===e.swimlaneId).filter(c=>!e.tag||Go(c).some(u=>mx(u.name,e.tag))).filter(c=>!e.assignee||zo(c).some(u=>mx(u.name,e.assignee))).filter(c=>!o||c.title.toLowerCase().includes(o)||(c.props.description??"").toLowerCase().includes(o)),i=c=>Se((c.parentNodeId?r[c.parentNodeId]?.title:void 0)??"");return e.brief?d("Listed issues",s.map(c=>({id:c.id,ref:V(c.id),title:Se(c.title),swimlane:i(c),tags:Go(c).map(u=>u.name),assignees:zo(c).map(u=>u.name)}))):d("Listed issues",s.map(c=>({id:c.id,ref:V(c.id),title:Se(c.title),description:c.props.description??"",createdAt:at(c.id),enteredLaneAt:fl(c.log??[],at(c.id)),parentNodeId:c.parentNodeId,isClosed:c.parentNodeId===we,readonly:!!c.readonly,tags:Go(c),assignees:zo(c)})))}async function Au(e){let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=xi(e);if(a(r))return r;let o=s=>rA(s,n.value,t.value.stateBranchRoot);return e.issueIds?Vo("Closed",Ii(r.value,o)):o(r.value[0])}async function ku(e){let t=Zr(e.repoRoot);if(a(t))return t;let n=te();if(a(n))return n;let r=Ie({repoRoot:t.value});if(a(r))return r;let o=sn(r.value);if(a(o))return o;let s=En(o.value.events,o.value.unreadable);if(a(s))return s;let i=xi(e);if(a(i))return i;let c=u=>oA(u,e,n.value,r.value);return e.issueIds?Vo("Moved",Ii(i.value,c)):c(i.value[0])}var Nu,mx,wu,rA,Tu,oA,Mu,Lu,px=g(()=>{"use strict";rt();Qd();lt();jr();$();$();$t();ru();tn();me();Tn();N();pe();jt();pi();On();vu();ft();vt();cn();yu();Su();eo();Nu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=X();if(a(n))return n;let r=e.idOrRef.trim();if(!r)return l("Provide an issue id or ref");let o=Object.values(n.value.nodes).filter(U).filter(u=>!u.isDeleted),s=o.find(u=>u.id===r),i=s?[s]:o.filter(u=>$s(u.id,r));if(i.length===0)return l(`No issue matches "${r}"`);if(i.length>1)return l(`"${r}" matches ${i.length} issues: ${i.map(u=>`${V(u.id)} (${Se(u.title)})`).join(", ")}. Use a full ref or id.`);let c=i[0];return d("Found issue",{id:c.id,ref:V(c.id),title:Se(c.title),description:c.props.description??"",createdAt:at(c.id),enteredLaneAt:fl(c.log??[],at(c.id)),parentNodeId:c.parentNodeId,isClosed:c.parentNodeId===we,readonly:!!c.readonly,tags:Go(c),assignees:zo(c),comments:lx(c.id)})},mx=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase();wu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Se(e.title);if(!o)return l("Issue title cannot be empty");let s=e.description??"",i=ot("Issue title",o,300)??ot("Issue description",s,2e4);if(i)return l(i);if((e.tagNames?.length??0)>20)return l(`Cannot set more than ${20} tags at once`);if((e.assigneeNames?.length??0)>20)return l(`Cannot set more than ${20} assignees at once`);let c=hr(e.parentId);if(a(c))return c;let u=Bn(e.parentId,n.value,t.value.stateBranchRoot);if(a(u))return u;let p=el({name:o,parent:e.parentId,user:n.value,rank:u.value});if(a(p))return p;let m=[...p.value],f=m.find(S=>S.action==="add.issue")?.payload.id;if(!f)return l("Unable to determine created issue id");s&&m.push({id:Kt(),...O(n.value),action:"edit.description",payload:{id:f,md:s}});let h=[];for(let S of e.tagNames??[]){let w=Se(S).trim();if(!w||h.some(F=>F.name===w))continue;let R=ot("Tag name",w,60);if(R)return l(R);let k=C.findTagByName(w),M=k?.id??Kt();k||m.push({id:Kt(),...O(n.value),action:"create.tag",payload:{id:M,name:w}}),m.push({id:Kt(),...O(n.value),action:"add.issue.tag",payload:{id:f,tag:M}}),h.push({id:M,name:w})}let b=[];for(let S of e.assigneeNames??[]){let w=Se(S).trim();if(!w||b.some(F=>F.name===w))continue;let R=ot("Assignee name",w,80);if(R)return l(R);let k=Object.values(r.value.contributors).find(F=>F.name===w),M=k?.id??Kt();k||m.push({id:Kt(),...O(n.value),action:"create.contributor",payload:{id:M,name:w}}),m.push({id:Kt(),...O(n.value),action:"add.issue.assignee",payload:{id:f,assignee:M}}),b.push({id:M,name:w})}let E=_(m,t.value.stateBranchRoot);return a(E)?l(E.message):d("Created issue",{id:f,ref:V(f),title:o,parentId:e.parentId,description:s,tags:h,assignees:b})},rA=(e,t,n)=>{let r=Ze(e);if(a(r))return r;let o=xn(we,e,{at:"end"},t,n);if(a(o))return o;let s={id:Kt(),...O(t),action:"close.issue",payload:{id:e,parent:we,rank:o.value}},i=_([s],n);return a(i)?l(i.message):d("Closed issue",{id:e,ref:V(e)})};Tu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=r.value.nodes[e.issueId];if(!o||o.isDeleted)return l("Issue not found");if(!U(o))return l("Target must be an issue");if(o.parentNodeId!==we)return l("Issue is not closed");let s=sl(o);if(!s)return l("Unable to resolve previous parent from issue history");if(s===we)return l("Previous parent resolves to closed swimlane");let i=hr(s);if(a(i))return i;let c=i.value,u=xn(c.id,o.id,{at:"end"},n.value,t.value.stateBranchRoot);if(a(u))return u;let p={id:Kt(),...O(n.value),action:"reopen.issue",payload:{id:o.id,parent:c.id,rank:u.value}},m=_([p],t.value.stateBranchRoot);return a(m)?l(m.message):d("Reopened issue",{id:o.id,ref:V(o.id),parentId:c.id})},oA=(e,t,n,r)=>{let o=Ze(e);if(a(o))return o;let s=hr(t.parentId);if(a(s))return s;let i=xn(t.parentId,e,t.position??{at:"end"},n,r);if(a(i))return i;let c={id:Kt(),...O(n),action:"move.node",payload:{id:e,parent:t.parentId,rank:i.value}},u=_([c],r);return a(u)?l(u.message):d("Moved issue",{id:e,ref:V(e),parentId:t.parentId})};Mu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Ze(e.issueId);if(a(o))return o;let s=o.value,i=ot("Issue description",e.description,2e4);if(i)return l(i);let c=s.props.description??"";if(c===e.description)return d("No changes made",{id:e.issueId,ref:V(e.issueId),description:c});let u={id:Kt(),...O(n.value),action:"edit.description",payload:{id:e.issueId,md:e.description}},p=_([u],t.value.stateBranchRoot);return a(p)?l(p.message):d("Edited issue description",{id:e.issueId,ref:V(e.issueId),description:e.description})},Lu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Ze(e.issueId);if(a(o))return o;let s=o.value,i=Se(e.title);if(!i.trim())return l("Issue title cannot be empty");let c=ot("Issue title",i,300);if(c)return l(c);if(s.title===i)return d("No changes made",{id:e.issueId,ref:V(e.issueId),title:i});let u={id:Kt(),...O(n.value),action:"edit.title",payload:{id:e.issueId,name:i}},p=_([u],t.value.stateBranchRoot);return a(p)?l(p.message):d("Edited issue title",{id:e.issueId,ref:V(e.issueId),title:i})}});import{ulid as vr}from"ulid";var Pu,Du,Ou,_u,Fu,Bu,$u,ju,fx=g(()=>{"use strict";rt();jr();$();$();$t();tn();me();N();jt();On();ft();vt();yi();cn();eo();Pu=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=X();if(a(n))return n;let r=Object.values(n.value.nodes).filter(o=>o.context==="BOARD"&&!o.isDeleted).map(o=>({id:o.id,ref:V(o.id),title:o.title,parentId:o.parentNodeId,readonly:!!o.readonly}));return d("Listed boards",r)},Du=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=r.value.nodes[r.value.rootNodeId];if(!o)return l("Workspace not found");if(Jr().mode!=="live")return l("Cannot add a board while time travelling");let s=Se(e.title);if(!s.trim())return l("Board title cannot be empty");let i=ot("Board title",s,300);if(i)return l(i);let c=Bn(o.id,n.value,t.value.stateBranchRoot);if(a(c))return c;let u=vr(),p={id:vr(),...O(n.value),action:"add.board",payload:{id:u,name:s,parent:o.id,rank:c.value}},m=_([p],t.value.stateBranchRoot);return a(m)?l(m.message):d("Created board",{id:u,ref:V(u),title:s})},Ou=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=r.value.nodes[e.boardId];if(!o||o.isDeleted)return l("Board not found");if(!Ir(o))return l("Edit target must be a board");if(o.readonly)return l("Cannot edit readonly board");if(Jr().mode!=="live")return l("Cannot rename a board while time travelling");let s=Se(e.title);if(!s.trim())return l("Board title cannot be empty");let i=ot("Board title",s,300);if(i)return l(i);if(o.title===s)return d("No changes made",{id:e.boardId,ref:V(e.boardId),title:s});let c={id:vr(),...O(n.value),action:"edit.title",payload:{id:e.boardId,name:s}},u=_([c],t.value.stateBranchRoot);return a(u)?l(u.message):d("Edited board title",{id:e.boardId,ref:V(e.boardId),title:s})},_u=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=X();if(a(n))return n;let r=Object.values(n.value.nodes).filter(o=>o.context==="SWIMLANE"&&!o.isDeleted).filter(o=>!e.boardId||o.parentNodeId===e.boardId).map(o=>({id:o.id,title:o.title,boardId:o.parentNodeId,isClosed:o.id===we,readonly:!!o.readonly}));return d("Listed swimlanes",r)},Fu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=bu(e.boardId);if(a(o))return o;if(Jr().mode!=="live")return l("Cannot add a swimlane while time travelling");let s=Se(e.title);if(!s.trim())return l("Swimlane title cannot be empty");let i=ot("Swimlane title",s,300);if(i)return l(i);let c=Bn(e.boardId,n.value,t.value.stateBranchRoot);if(a(c))return c;let u=vr(),p={id:vr(),...O(n.value),action:"add.swimlane",payload:{id:u,name:s,parent:e.boardId,rank:c.value}},m=_([p],t.value.stateBranchRoot);return a(m)?l(m.message):d("Created swimlane",{id:u,ref:V(u),title:s,boardId:e.boardId})},Bu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=hr(e.swimlaneId);if(a(o))return o;let s=o.value,i=Se(e.title);if(!i.trim())return l("Swimlane title cannot be empty");let c=ot("Swimlane title",i,300);if(c)return l(c);if(s.title===i)return d("No changes made",{id:e.swimlaneId,ref:V(e.swimlaneId),title:i});let u={id:vr(),...O(n.value),action:"edit.title",payload:{id:e.swimlaneId,name:i}},p=_([u],t.value.stateBranchRoot);return a(p)?l(p.message):d("Edited swimlane title",{id:e.swimlaneId,ref:V(e.swimlaneId),title:i})},$u=async e=>{let t=Zr(e.repoRoot);if(a(t))return t;let n=te();if(a(n))return n;let r=Ie({repoRoot:t.value});if(a(r))return r;let o=sn(r.value);if(a(o))return o;let s=En(o.value.events,o.value.unreadable);if(a(s))return s;let i=hr(e.swimlaneId);if(a(i))return i;let c=bu(e.boardId);if(a(c))return c;let u=xn(e.boardId,e.swimlaneId,e.position??{at:"end"},n.value,r.value);if(a(u))return u;let p={id:vr(),...O(n.value),action:"move.node",payload:{id:e.swimlaneId,parent:e.boardId,rank:u.value}},m=_([p],r.value);return a(m)?l(m.message):d("Moved swimlane",{id:e.swimlaneId,ref:V(e.swimlaneId),boardId:e.boardId})},ju=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=hr(e.swimlaneId);if(a(o))return o;let s={id:vr(),...O(n.value),action:"delete.node",payload:{id:e.swimlaneId}},i=_([s],t.value.stateBranchRoot);return a(i)?l(i.message):d("Deleted swimlane",{id:e.swimlaneId,ref:V(e.swimlaneId)})}});import{ulid as Xo}from"ulid";async function Uu(e){let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=xi(e);if(a(r))return r;let o=Se(e.tagName).trim();if(!o)return l("Tag name cannot be empty");let s=ot("Tag name",o,60);if(s)return l(s);let i=Ii(r.value,Ze);if(!e.issueIds&&i.failed[0])return l(i.failed[0].reason);if(i.done.length===0)return l(Vo("Tagged",i).message);let c=C.findTagByName(o),u=c?.id??Xo(),p=[...c?[]:[{id:Xo(),...O(n.value),action:"create.tag",payload:{id:u,name:o}}],...i.done.map(({id:b})=>({id:Xo(),...O(n.value),action:"add.issue.tag",payload:{id:b,tag:u}}))],m=_(p,t.value.stateBranchRoot);if(a(m))return l(m.message);let f={id:u,name:o};if(!e.issueIds)return d("Added issue tag",{...i.done[0],tag:f});let h=Vo("Tagged",i);return a(h)?h:d(h.message,{...h.value,tag:f})}var Hu,Wu,qu,gx=g(()=>{"use strict";$();$t();N();pe();On();ft();vt();cn();Su();eo();Hu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=r.value.tags[e.tagId];if(!o)return l("Tag not found");if(o.tombstoned)return l("Tag is already deleted");let s=[{id:Xo(),...O(n.value),action:"tombstone.tag",payload:{id:e.tagId}}],i=_(s,t.value.stateBranchRoot);return a(i)?l(i.message):d("Deleted tag",{id:o.id,name:o.name})},Wu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=r.value.tags[e.tagId];if(!o)return l("Tag not found");if(!o.tombstoned)return l("Tag is not deleted");if(C.findTagByName(o.name))return l(`Cannot restore: another tag is already named "${o.name}"`);let s=[{id:Xo(),...O(n.value),action:"restore.tag",payload:{id:e.tagId,name:o.name}}],i=_(s,t.value.stateBranchRoot);return a(i)?l(i.message):d("Restored tag",{id:o.id,name:o.name})},qu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Ze(e.issueId);if(a(o))return o;if(!r.value.tags[e.tagId])return l("Tag not found");let s={id:Xo(),...O(n.value),action:"remove.issue.tag",payload:{id:e.issueId,tag:e.tagId}},i=_([s],t.value.stateBranchRoot);return a(i)?l(i.message):d("Removed issue tag",{id:e.issueId,ref:V(e.issueId),tagId:e.tagId})}});import{ulid as Gn}from"ulid";var Gu,hx,zu,Vu,sA,Ku,Yu,Xu,vx=g(()=>{"use strict";N();Xt();yr();$();$();$t();il();Tn();gl();On();ft();vt();cn();eo();Gu=async e=>{let t=wl(e.name,"name");if(a(t))return l(t.message);let n=await Z(e.repoRoot,{pull:!1});if(a(n))return n;let r=te();if(a(r))return r;let o=X();if(a(o))return o;let s=r.value,i=!!o.value.contributors[s.userId];if(!i){let c=_([{id:Gn(),...O(s),action:"create.contributor",payload:{id:s.userId,name:s.userName}}],n.value.stateBranchRoot);if(a(c))return l(c.message)}return d(`Assumed ${s.userName}`,{...s,registered:!i})},hx=async(e,t)=>{let n=Fr(e).get(t);return n===void 0?void 0:{id:t,name:n}},zu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Ze(e.issueId);if(a(o))return o;let s=e.self?n.value.userId:e.assigneeId;if(s){let S=r.value.contributors[s],w=S?void 0:await hx(t.value.stateBranchRoot,s);if(!S&&!w)return l("Unknown assignee id");let R=S??w,k=[...S?[]:[{id:Gn(),...O(n.value),action:"create.contributor",payload:{id:R.id,name:R.name}}],{id:Gn(),...O(n.value),action:"add.issue.assignee",payload:{id:e.issueId,assignee:R.id}}],M=_(k,t.value.stateBranchRoot);return a(M)?l(M.message):d("Added issue assignee",{id:e.issueId,ref:V(e.issueId),assignee:{id:R.id,name:R.name}})}let i=Se(e.assigneeName??"").trim();if(!i)return l("Provide assigneeId, self or assigneeName");let c=ot("Assignee name",i,80);if(c)return l(c);let u=gi({events:r.value.eventLog??[],registry:r.value.contributors,logFileNames:Fr(t.value.stateBranchRoot)}).filter(S=>S.name===i);if(u.length>1)return l(`"${i}" matches ${u.length} contributors (${u.map(({id:S})=>S).join(", ")}). Assign by assigneeId to choose.`);let p=u[0];if(!p&&!e.createUnlinked)return l(`No contributor named "${i}". Assign by id, or pass createUnlinked to add them as an external assignee.`);let m=p?.id??Gn(),f=p?.name??i,b=[...!!r.value.contributors[m]?[]:[{id:Gn(),...O(n.value),action:"create.contributor",payload:{id:m,name:f}}],{id:Gn(),...O(n.value),action:"add.issue.assignee",payload:{id:e.issueId,assignee:m}}],E=_(b,t.value.stateBranchRoot);return a(E)?l(E.message):d("Added issue assignee",{id:e.issueId,ref:V(e.issueId),assignee:{id:m,name:f}})},Vu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;if(!r.value.contributors[e.contributorId])return l("Contributor not found");if(await hx(t.value.stateBranchRoot,e.contributorId))return l("Cannot remove a contributor who has authored events \u2014 their name appears throughout the log");let i=[{id:Gn(),...O(n.value),action:"tombstone.contributor",payload:{id:e.contributorId}}],c=_(i,t.value.stateBranchRoot);return a(c)?l(c.message):d("Tombstoned contributor",{id:e.contributorId,name:cs})},sA=async(e,t)=>{let n=Br(e);if(a(n))return;let r;for(let o of n.value){if(o.action!=="create.contributor")continue;let s=o.payload;s.id===t&&s.name&&(r=s.name)}return r},Ku=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=r.value.contributors[e.contributorId];if(!o)return l("Contributor not found");if(!o.tombstoned)return l("Contributor is not tombstoned");let s=await sA(t.value.stateBranchRoot,e.contributorId);if(!s)return l("Cannot restore this contributor \u2014 no original name found in the event log");let i=[{id:Gn(),...O(n.value),action:"restore.contributor",payload:{id:e.contributorId,name:s}}],c=_(i,t.value.stateBranchRoot);return a(c)?l(c.message):d("Restored contributor",{id:e.contributorId,name:s})},Yu=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Br(t.value.stateBranchRoot);if(a(o))return l(o.message);let s=e.boardId?nx(o.value,e.boardId):o.value,i=new Set,c=xg(t.value.stateBranchRoot);if(a(c))return l(c.message);for(let m of c.value)m.userId&&i.add(m.userId);let u=r.value.contributors,p=gi({events:s,registry:u,logFileNames:Fr(t.value.stateBranchRoot)}).map(({id:m,name:f,isExternal:h})=>({...ht(m,f),isSelf:m===n.value.userId,isExternal:h,isRemoved:u[m]?.tombstoned===!0,hasAuthoredAnywhere:i.has(m)}));return d("Listed board contributors",p)},Xu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Ze(e.issueId);if(a(o))return o;if(!r.value.contributors[e.assigneeId])return l("Assignee not found");let s={id:Gn(),...O(n.value),action:"remove.issue.assignee",payload:{id:e.issueId,assignee:e.assigneeId}},i=_([s],t.value.stateBranchRoot);return a(i)?l(i.message):d("Removed issue assignee",{id:e.issueId,ref:V(e.issueId),assigneeId:e.assigneeId})}});import{ulid as bl}from"ulid";var Ju,Qu,Zu,yx=g(()=>{"use strict";$();$t();N();On();cn();eo();Ju=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Ze(e.issueId);if(a(o))return o;let s=e.body.trim();if(!s)return l("Comment cannot be empty");if(s.length>4e3)return l(`Comment cannot exceed ${4e3} characters (got ${s.length})`);let i=bl(),c={id:bl(),...O(n.value),action:"add.issue.comment",payload:{id:i,issue:e.issueId,md:s,author:n.value.userId}},u=_([c],t.value.stateBranchRoot);return a(u)?l(u.message):d("Added issue comment",{id:i,issueId:e.issueId,body:s})},Qu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=r.value.eventLog.find(p=>p.action==="add.issue.comment"&&p.payload.id===e.commentId);if(!o)return l("Unable to resolve comment");if(o.payload.author!==n.value.userId)return l("You can only delete your own comments");let s=Ze(o.payload.issue);if(a(s))return s;if(r.value.eventLog.some(p=>p.action==="delete.issue.comment"&&p.payload.id===e.commentId))return d("Comment already deleted",{id:e.commentId,issueId:o.payload.issue});let c={id:bl(),...O(n.value),action:"delete.issue.comment",payload:{id:e.commentId,issue:o.payload.issue}},u=_([c],t.value.stateBranchRoot);return a(u)?l(u.message):d("Deleted issue comment",{id:e.commentId,issueId:o.payload.issue})},Zu=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=r.value.eventLog.find(m=>m.action==="add.issue.comment"&&m.payload.id===e.commentId);if(!o)return l("Unable to resolve comment");if(o.payload.author!==n.value.userId)return l("You can only edit your own comments");let s=Ze(o.payload.issue);if(a(s))return s;if(r.value.eventLog.some(m=>m.action==="delete.issue.comment"&&m.payload.id===e.commentId))return l("Comment was deleted");let c=e.body.trim();if(!c)return l("Comment cannot be empty");if(c.length>4e3)return l(`Comment cannot exceed ${4e3} characters (got ${c.length})`);let u={id:bl(),...O(n.value),action:"edit.issue.comment",payload:{id:e.commentId,issue:o.payload.issue,md:c}},p=_([u],t.value.stateBranchRoot);return a(p)?l(p.message):d("Edited issue comment",{id:e.commentId,issueId:o.payload.issue,body:c})}});import{ulid as bx}from"ulid";var em,tm,nm,rm,om=g(()=>{"use strict";$();wt();Tn();N();mn();bi();dl();Ue();cn();em=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;if(!zn(e.email))return l(`Not an email address: ${e.email}`);let o=Ve(e.email),s=e.contributorId??n.value.userId;if(!r.value.contributors[s])return l(`Unknown contributor: ${s}`);let i=Ol(r.value.emailLinks,o);if(i.includes(s))return d(`${o} is already yours`,{contributor:s,email:o,contested:i.filter(u=>u!==s)});let c=_([{id:bx(),action:"link.contributor.email",payload:{contributor:s,email:o},userId:n.value.userId}],t.value.stateBranchRoot);return a(c)?l(c.message):d(i.length>0?`Claimed ${o}, but somebody else claims it too, so it now resolves to neither of you`:`Claimed ${o}`,{contributor:s,email:o,contested:i})},tm=async e=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let o=Ve(e.email),s=e.contributorId??n.value.userId,i=r.value.emailLinks[ds(o,s)];if(!i||i.tombstoned)return l(`No such link: ${o} to ${s}`);if(!ki(n.value.userId,i))return l("Only whoever made a claim, or the contributor it names, may undo it");let c=_([{id:bx(),action:"unlink.contributor.email",payload:{contributor:s,email:o},userId:n.value.userId}],t.value.stateBranchRoot);return a(c)?l(c.message):d(`Unclaimed ${o}`,{contributor:s,email:o})},nm=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=X();if(a(n))return n;let{emailLinks:r,contributors:o}=n.value,s=new Map;for(let f of Object.values(r)){if(f.tombstoned)continue;let h=s.get(f.email)??new Set;h.add(f.contributor),s.set(f.email,h)}let i=[...s.entries()].map(([f,h])=>({email:f,contested:h.size>1,claimants:[...h].map(b=>ht(b,o[b]?.name))})).sort((f,h)=>f.email.localeCompare(h.email)),c=te(),u=a(c)?[]:Vn(r,c.value.userId),p=de().gitEmail,m=p?Ol(r,p).filter(f=>a(c)||f!==c.value.userId):[];return d("Listed contributor emails",{emails:i,mine:u,git:p?{email:p,linkedToMe:u.includes(p),heldByOthers:m.map(f=>ht(f,o[f]?.name))}:null})},rm=async(e={})=>{let t=await Z(e.repoRoot,{pull:!1});if(a(t))return t;let n=te();if(a(n))return n;let r=X();if(a(r))return r;let{userId:o,userName:s}=n.value,i=dt(t.value.repoRoot),c=await hi({repoRoot:t.value.repoRoot,stateBranch:a(i)?void 0:i.value,names:[s,await Qr(t.value.repoRoot)],links:r.value.emailLinks});if(a(c))return c;let u=cl(c.value),p=u.filter(m=>m.looksLikeYours);return d(u.length===0?"No unclaimed addresses in this history":`${u.length} unclaimed address(es) in this history, ${p.length>0?`${p.length} of which look like yours`:"none obviously yours"}. Show them to the user and link only the ones they confirm; each is a permanent event that replicates to every clone.`,{contributor:o,candidates:u,likely:p.length})}});var xx=g(()=>{"use strict";lt();N()});var Ix=g(()=>{"use strict";mn();bi();N();dl();xx();cn()});var Ex=g(()=>{"use strict";ux();px();fx();gx();vx();yx();Iu();om();Ix()});import{ulid as iA}from"ulid";var Rx,Sx,Nx,Cx=g(()=>{"use strict";yr();lo();bi();bn();N();Kd();_t();Rx=[{name:"userName",question:"the name they want to appear under on the board"},{name:"preferredEditor",question:'the command that opens a file for editing, e.g. "vim", "nano" or "code --wait"'},{name:"autoSync",question:"whether the TUI and GUI should sync with the git remote on their own (true or false)"}],Sx=e=>e.trim().toLowerCase(),Nx=async(e={})=>{let t=yn();if(a(t))return l(t.message);let n=t.value,r=e.userName?.trim(),o=(process.env[Ot]??"").trim();if(r&&o&&Sx(r)===Sx(o))return l(`userName "${r}" is this agent's own identity. Pass the user's name, the one they want the TUI and GUI to write as.`);let s={userName:r||void 0,preferredEditor:e.preferredEditor?.trim()||void 0,autoSync:e.autoSync},i={userName:n.userName?.trim()||void 0,preferredEditor:n.preferredEditor?.trim()||void 0,autoSync:typeof n.autoSync=="boolean"?n.autoSync:void 0};for(let w of Rx){let R=s[w.name],k=i[w.name];if(!(R===void 0||k===void 0||R===k))return l(`This machine is already set up with ${w.name} ${JSON.stringify(k)}; epiq_project_init does not change it. Call again without ${w.name}, or let the user change it in the TUI with :config.`)}let c={};if(s.userName&&!i.userName&&(c.userName=s.userName),s.preferredEditor&&!i.preferredEditor&&(c.preferredEditor=s.preferredEditor),s.autoSync!==void 0&&i.autoSync===void 0&&(c.autoSync=s.autoSync),(c.userName||i.userName)&&!n.userId&&(c.userId=iA()),Object.keys(c).length>0){let w=xt(c);if(a(w))return l(w.message)}let u={...n,...c},p=Rx.filter(w=>{let R=u[w.name];return typeof R=="boolean"?!1:!R?.trim()});if(p.length>0){let w=p.map(M=>`${M.name} (${M.question})`).join("; "),R=p.some(M=>M.name==="userName")?await Qr(e.repoRoot??process.cwd()):null,k=R?` This repository's git user.name is ${JSON.stringify(R)} \u2014 offer it as the default for userName, and use it only if the user agrees.`:"";return l(`Setup incomplete. Ask the user for: ${w}.${k} Then call epiq_project_init again with the answers; what was given so far is saved.`)}let m={userId:u.userId??"",userName:u.userName??""};if(!m.userId||!m.userName)return l("Missing Epiq user id");let f=await Za({cwd:e.repoRoot??process.cwd(),user:m});if(a(f))return f;let{defaultEvents:h,...b}=f.value,E=Rs({root:b.repoRoot});a(E)&&ce.info(E.message);let S=b.warnings.length===0?"Project initialized":`Project initialized, with warnings: ${b.warnings.join(" ")}`;return d(S,{...b,user:m})}});var wn,xl=g(()=>{"use strict";wn=e=>({path:e.path,sha:e.shas[e.shas.length-1]??""})});var aA,wx,Ax=g(()=>{"use strict";xl();aA=e=>{let t=e.lastIndexOf("/");return t===-1?".":e.slice(0,t)},wx=({commits:e,patch:t})=>{let n=e.map(i=>i.time),o=t.files.map(i=>({...wn(i),changed:i.addedCount+i.removed})).reduce((i,c)=>i===null||c.changed>i.changed?c:i,null),s=t.insertions+t.deletions;return{commits:e.length,authors:[...new Set(e.map(i=>i.author))].sort(),firstCommitAt:n.length?Math.min(...n):null,lastCommitAt:n.length?Math.max(...n):null,files:t.files.length,filesAdded:t.files.filter(i=>i.status==="added").length,filesModified:t.files.filter(i=>i.status==="modified").length,filesDeleted:t.files.filter(i=>i.status==="deleted").length,binaryFiles:t.files.filter(i=>i.binary).length,directories:new Set(t.files.map(i=>aA(i.path))).size,insertions:t.insertions,deletions:t.deletions,net:t.insertions-t.deletions,largestFile:o,concentration:o&&s>0?o.changed/s:0,selfChurn:t.selfChurn,truncated:t.truncated}}});var Xe,Yt,sm,Jo,lA,Q,Il,El,Tx,cA,kx,to,Ri,dA,uA,Qo,mA,pA,fA,dn,Mx,Lx,Px,gA,hA,Dx,Ox,Zo=g(()=>{"use strict";Xe={line:["//"],block:[["/*","*/"]]},Yt={line:["#"],block:[]},sm={line:["--"],block:[]},Jo={line:[],block:[["<!--","-->"]]},lA={line:[],block:[]},Q=(e,t)=>({name:e,comment:t}),Il=Q("TypeScript",Xe),El=Q("JavaScript",Xe),Tx={ts:Il,tsx:Il,mts:Il,cts:Il,js:El,jsx:El,mjs:El,cjs:El,py:Q("Python",{line:["#"],block:[['"""','"""']]}),rb:Q("Ruby",{line:["#"],block:[["=begin","=end"]]}),go:Q("Go",Xe),rs:Q("Rust",Xe),java:Q("Java",Xe),kt:Q("Kotlin",Xe),swift:Q("Swift",Xe),c:Q("C",Xe),h:Q("C",Xe),cc:Q("C++",Xe),cpp:Q("C++",Xe),hpp:Q("C++",Xe),cs:Q("C#",Xe),php:Q("PHP",Xe),scala:Q("Scala",Xe),dart:Q("Dart",Xe),lua:Q("Lua",sm),hs:Q("Haskell",sm),sql:Q("SQL",sm),ex:Q("Elixir",Yt),exs:Q("Elixir",Yt),pl:Q("Perl",Yt),r:Q("R",Yt),jl:Q("Julia",Yt),sh:Q("Shell",Yt),bash:Q("Shell",Yt),zsh:Q("Shell",Yt),vue:Q("Vue",Jo),svelte:Q("Svelte",Jo),html:Q("HTML",Jo),xml:Q("XML",Jo),md:Q("Markdown",Jo),mdx:Q("Markdown",Jo),css:Q("CSS",{line:[],block:[["/*","*/"]]}),scss:Q("CSS",Xe),less:Q("CSS",Xe),yml:Q("YAML",Yt),yaml:Q("YAML",Yt),toml:Q("TOML",Yt),ini:Q("INI",Yt),json:Q("JSON",lA)},cA="Other",kx=e=>{let t=e.slice(e.lastIndexOf("/")+1),n=t.lastIndexOf(".");return n<=0?"":t.slice(n+1).toLowerCase()},to=e=>Tx[kx(e)]?.name??cA,Ri=e=>Tx[kx(e)]?.comment??null,dA=[/\.(test|spec)\.[a-z0-9]+$/i,/(^|\/)test_[^/]+\.py$/,/_test\.[a-z0-9]+$/i,/(^|\/)conftest\.py$/,/Tests?\.(java|kt|cs|scala)$/],uA=/(^|\/)(tests?|__tests__|spec|specs|e2e|src\/test|features)\//i,Qo=e=>uA.test(e)||dA.some(t=>t.test(e)),mA=/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock|go\.sum|poetry\.lock|Gemfile\.lock|composer\.lock)$/,pA=/(^|\/)(node_modules|dist|build|out|target|vendor|coverage|\.next|__snapshots__)\//,fA=/(\.min\.(js|css)|\.map|\.snap|\.pb\.go|_pb2\.py)$/,dn=e=>mA.test(e)||pA.test(e)||fA.test(e),Mx=e=>/(^|\/)(package\.json|go\.mod|Cargo\.toml|requirements[^/]*\.txt|pyproject\.toml|Gemfile|composer\.json|pom\.xml|build\.gradle(\.kts)?)$/.test(e),Lx=e=>/(^|\/)\.github\/workflows\//.test(e)||/(^|\/)(Dockerfile|docker-compose[^/]*\.ya?ml|Makefile|Jenkinsfile|\.gitlab-ci\.yml)$/.test(e)||/\.tf$/.test(e),Px=e=>/\.(md|mdx|rst|txt)$/i.test(e)||/(^|\/)docs?\//i.test(e),gA=/\b(it|test|describe|context|suite)\.skip\b|\bx(it|describe|test)\s*\(|@pytest\.mark\.skip|@unittest\.skip|\bt\.Skip\s*\(|@(Ignore|Disabled)\b/,hA=/\b(it|test|describe|context|suite)\.only\b|\bf(it|describe|test)\s*\(/,Dx=e=>gA.test(e),Ox=e=>hA.test(e)});var _x,vA,im,yA,Fx,am=g(()=>{"use strict";Zo();_x=/\b(TODO|FIXME|HACK|XXX)\b/,vA=/[;{}]\s*$|^\s*(const|let|var|function|def|class|if|for|while|return|import|export|await|print)\b.*[=(]/,im=(e,t)=>{let n=e.trim();return n===""?"blank":t&&(t.line.some(r=>n.startsWith(r))||t.block.some(([r])=>n.startsWith(r))||t.block.some(([r])=>r==="/*")&&(n.startsWith("*")||n.startsWith("*/")))?"comment":"code"},yA=(e,t)=>{let n=e.trim();for(let r of[...t.line,...t.block.flat(),"*"])if(n.startsWith(r)){n=n.slice(r.length).trim();break}return n},Fx=({patch:e,repoShareByLanguage:t})=>{let n=new Map,r=0,o=0,s=0,i=0,c=0,u=0;for(let m of e.files){if(m.binary||dn(m.path))continue;let f=Ri(m.path);if(!f||f.line.length===0&&f.block.length===0)continue;let h=to(m.path),b=n.get(h)??{comment:0,code:0};for(let{text:E}of m.added){let S=im(E,f);if(_x.test(E)&&i++,S==="blank"){s++;continue}if(S==="comment"){r++,b.comment++,f&&vA.test(yA(E,f))&&u++;continue}o++,b.code++}for(let{text:E}of m.removedLines)_x.test(E)&&c++;n.set(h,b)}let p=r+o;return{byLanguage:[...n.entries()].map(([m,f])=>({name:m,commentLines:f.comment,codeLines:f.code,share:f.comment+f.code===0?0:f.comment/(f.comment+f.code),repoShare:t?.get(m)??null})).sort((m,f)=>f.commentLines+f.codeLines-(m.commentLines+m.codeLines)),commentLines:r,codeLines:o,blankLines:s,share:p===0?0:r/p,todoLinesAdded:i,todoLinesRemoved:c,commentedOutCodeLines:u}}});var bA,Rl,lm,xA,IA,EA,Bx,$x=g(()=>{"use strict";Zo();xl();bA=/\bconsole\.(log|debug|dir)\s*\(|\bdebugger\b|^\s*print\s*\(|\bfmt\.Print(ln|f)?\s*\(|\bSystem\.out\.print|\bdbg!\s*\(/,Rl=6,lm=10,xA=e=>{let t=0;for(let n of e){if(n.trim()===""||n.startsWith(" "))continue;let r=n.length-n.trimStart().length;r>0&&(t===0||r<t)&&(t=r)}return Math.min(Math.max(t,2),8)},IA=(e,t)=>{let n=e.length-e.trimStart().length;if(n===0)return 0;let r=e.slice(0,n).split(" ").length-1;return r>0?r:Math.floor(n/t)},EA=e=>{if(e.length<Rl*2)return 0;let t=new Map,n=new Array(e.length).fill(!1);for(let r=0;r+Rl<=e.length;r++){let o=e.slice(r,r+Rl);if(o.some(c=>c.text.length<3))continue;let s=o.map(c=>c.text).join(`
109
+ `),i=t.get(s);if(i===void 0){t.set(s,{...o[0],at:r});continue}if(i.file!==o[0]?.file)for(let c=0;c<Rl;c++)n[i.at+c]=!0,n[r+c]=!0}return n.filter(Boolean).length},Bx=({patch:e})=>{let t=[],n=[],r=[],o=!1,s=0,i=0,c=null,u=[];for(let[p,m]of e.files.entries()){if(dn(m.path)&&t.push(wn(m)),Mx(m.path)&&n.push(wn(m)),Lx(m.path)&&r.push(wn(m)),Px(m.path)&&(o=!0),m.binary||dn(m.path))continue;let f=m.added.map(E=>E.text),h=xA(f),b=m.status!=="deleted";for(let E of f){bA.test(E)&&s++;let S=IA(E,h);S>i&&(i=S,c=wn(m)),b&&u.push({text:E.trim(),file:p})}u.push({text:" ",file:p})}return{generatedPaths:t.slice(0,lm),dependencyManifests:n.slice(0,lm),buildOrCiPaths:r.slice(0,lm),docsTouched:o,debugPrintLinesAdded:s,maxIndentLevels:i,deepestFile:c,duplicatedLines:EA(u)}}});var jx,Ux=g(()=>{"use strict";Zo();jx=({patch:e,languagesBefore:t})=>{let n=new Map,r=0;for(let i of e.files){if(i.binary)continue;let c=i.addedCount+i.removed;if(dn(i.path)){r+=c;continue}let u=to(i.path),p=n.get(u)??{name:u,added:0,removed:0,addedInTests:0,share:0};p.added+=i.addedCount,p.removed+=i.removed,Qo(i.path)&&(p.addedInTests+=i.addedCount),n.set(u,p)}let o=[...n.values()].reduce((i,c)=>i+c.added+c.removed,0),s=[...n.values()].map(i=>({...i,share:o===0?0:(i.added+i.removed)/o})).sort((i,c)=>c.added+c.removed-(i.added+i.removed));return{languages:s,introduced:t===null?[]:s.filter(i=>!t.has(i.name)).map(i=>i.name),generatedLines:r}}});var RA,cm,SA,Hx,NA,dm,CA,wA,Wx,qx,AA,TA,kA,Gx,zx=g(()=>{"use strict";Ke();N();RA=200,cm=2e5,SA=5e4,Hx=25,NA=64*1024*1024,dm="",CA=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/,wA=/^diff --git a\/(.+) b\/\1$/,Wx=(e,t)=>e==="/dev/null"?null:e.startsWith(t)?e.slice(2):e,qx=(e,t)=>e===null?"added":t===null?"deleted":"modified",AA=()=>({byPath:new Map,insertions:0,deletions:0,selfChurn:0,retainedLines:0}),TA=(e,t)=>{let n=e.byPath,r="",o=null,s=null,i=null,c=!1,u=0,p=(f,h)=>h==="modified"&&f==="added"?"added":h,m=(f,h)=>{let b=n.get(f);if(b)return b.entry.status=p(b.entry.status,h),b.entry.shas.includes(r)||b.entry.shas.push(r),b;let S={entry:{path:f,status:h,binary:!1,added:[],addedCount:0,removed:0,removedLines:[],shas:[r]},pendingByText:new Map};return n.set(f,S),S};for(let f of t.split(`
110
+ `)){if(f.startsWith(dm)){r=f.slice(dm.length).trim(),o=null,s=null,i=null,c=!1;continue}if(f.startsWith("diff --git ")){o=null,i=null,c=!0,s=wA.exec(f)?.[1]??null;continue}if(c&&f.startsWith("Binary files ")&&s){let[,b=""]=/^Binary files (.*) differ$/.exec(f)??[],[E="",S=""]=b.split(" and ");o=m(s,qx(E==="/dev/null"?null:E,S==="/dev/null"?null:S)),o.entry.binary=!0;continue}if(c&&f.startsWith("--- ")){i=Wx(f.slice(4),"a/");continue}if(c&&f.startsWith("+++ ")){let b=Wx(f.slice(4),"b/"),E=b??i??s;E&&(o=m(E,qx(i,b)));continue}let h=CA.exec(f);if(h){u=Number(h[1]),c=!1;continue}if(o){if(f.startsWith("+")){let b=f.slice(1);e.insertions++,o.entry.addedCount++,e.retainedLines<cm&&(o.entry.added.push({sha:r,line:u,text:b}),e.retainedLines++),o.pendingByText.size<SA&&o.pendingByText.set(b,(o.pendingByText.get(b)??0)+1),u++;continue}if(f.startsWith("-")){let b=f.slice(1);e.deletions++,o.entry.removed++,e.retainedLines<cm&&(o.entry.removedLines.push({sha:r,line:0,text:b}),e.retainedLines++);let E=o.pendingByText.get(b)??0;E>0&&b.trim().length>2&&(e.selfChurn++,o.pendingByText.set(b,E-1))}}}},kA=e=>({files:[...e.byPath.values()].map(t=>t.entry),insertions:e.insertions,deletions:e.deletions,selfChurn:e.selfChurn,retainedLines:e.retainedLines}),Gx=async({repoRoot:e,shas:t})=>{if(t.length===0)return d("No commits to scan",{files:[],insertions:0,deletions:0,selfChurn:0,scannedCommits:0,truncated:!1});let n=t.slice(0,RA).reverse(),r=AA(),o=0,s=0,i=!1;for(let u=0;u<n.length;u+=Hx){let p=n.slice(u,u+Hx),m=await W({cwd:e,args:["-c","core.quotePath=false","show","--unified=0","--no-renames","--no-color",`--format=${dm}%H`,...p]});if(a(m))return l(m.message);if(TA(r,m.value.stdout),o+=m.value.stdout.length,s+=p.length,o>NA){i=!0;break}}let c=kA(r);return d("Scanned ticket patch",{files:c.files,insertions:c.insertions,deletions:c.deletions,selfChurn:c.selfChurn,scannedCommits:s,truncated:i||s<t.length||c.retainedLines>=cm})}});var MA,LA,Vx,Kx=g(()=>{"use strict";Ke();N();am();Zo();MA=40,LA=/^\d{6} blob ([0-9a-f]{40})\t(.+)$/,Vx=async({repoRoot:e,sha:t})=>{let n=await Le({cwd:e,args:["-c","core.quotePath=false","ls-tree","-r",`${t}~1`]});if(n.exitCode!==0)return null;let r=new Set,o=new Map;for(let m of n.stdout.split(`
111
+ `)){let f=LA.exec(m);if(!f)continue;let[,h="",b=""]=f;if(dn(b))continue;let E=to(b);if(r.add(E),Qo(b)||!Ri(b))continue;let S=o.get(E)??[];S.length<MA&&(S.push({blob:h,path:b}),o.set(E,S))}let s=[...o.values()].flat(),i=await zl(s.map(m=>m.blob),e);if(a(i))return{languages:r,commentShareByLanguage:new Map};let c=i.value,u=new Map;for(let{blob:m,path:f}of s){let h=c.get(m);if(h===void 0)continue;let b=Ri(f),E=to(f),S=u.get(E)??{comment:0,code:0};for(let w of h.split(`
112
+ `)){let R=im(w,b);R==="comment"&&S.comment++,R==="code"&&S.code++}u.set(E,S)}let p=new Map;for(let[m,f]of u){let h=f.comment+f.code;h>0&&p.set(m,f.comment/h)}return{languages:r,commentShareByLanguage:p}}});var Yx,Xx=g(()=>{"use strict";Zo();xl();Yx=({patch:e})=>{let t=0,n=0,r=[],o=[],s=0,i=0;for(let c of e.files)if(!(c.binary||dn(c.path))&&Qo(c.path)){t+=c.addedCount,n+=c.removed,c.status==="added"&&r.push(wn(c)),c.status==="deleted"&&o.push(wn(c));for(let{text:u}of c.added)Dx(u)&&s++,Ox(u)&&i++}return{testLinesAdded:t,testLinesRemoved:n,addedTestFiles:r,deletedTestFiles:o,skippedTestLinesAdded:s,focusedTestLinesAdded:i}}});var PA,Jx,Qx=g(()=>{"use strict";N();Ax();am();$x();Ux();zx();Kx();Xx();PA=e=>e.reduce((t,n)=>t===null||n.time<t.time?n:t,null)?.sha??null,Jx=async({repoRoot:e,ref:t,commits:n})=>{let r=await Gx({repoRoot:e,shas:n.map(c=>c.sha)});if(a(r))return l(r.message);let o=r.value,s=PA(n),i=s?await Vx({repoRoot:e,sha:s}):null;return d("Derived issue stats",{ref:t,shape:wx({commits:n,patch:o}),languages:jx({patch:o,languagesBefore:i?.languages??null}),tests:Yx({patch:o}),comments:Fx({patch:o,repoShareByLanguage:i?.commentShareByLanguage??null}),flags:Bx({patch:o})})}});var Zx,eI=g(()=>{"use strict";il();N();wt();D();Zx=e=>{if(a(e))return e;let t=ke(),n=a(t)?{}:t.value.emailLinks,r=a(t)?{}:t.value.contributors,o=Mm(n),s=e.value.map(i=>({...i,authorIdentity:Wy({authorName:i.author,authorEmail:i.authorEmail,owners:o,registry:r})}));return d(e.message,s)}});var DA,Si,OA,tI,nI=g(()=>{"use strict";N();Qx();ft();ee();eI();ii();DA=32,Si=new Map,OA=(e,t)=>{if(Si.set(e,t),Si.size>DA){let n=Si.keys().next();n.done||Si.delete(n.value)}return t},tI=async(e={idOrRef:""})=>{let t=e.idOrRef.trim();if(!t)return l("idOrRef must not be empty");let n=t.length>7?V(t):t.toUpperCase(),r=Ce(e.repoRoot??process.cwd());if(a(r))return l(r.message);let o=r.value,s=Zx(await Fo({repoRoot:o,ref:n}));if(a(s))return l(s.message);let i=s.value.map(m=>({sha:m.sha,time:m.time,author:m.authorIdentity?.resolved?m.authorIdentity.name:m.author,subject:m.subject})),c=[o,n,i.map(m=>`${m.sha}:${m.author}`).join(",")].join(" "),u=Si.get(c);if(u)return d("Derived issue stats",u);let p=await Jx({repoRoot:o,ref:n,commits:i});return a(p)?l(p.message):d("Derived issue stats",OA(c,p.value))}});var es,um,rI=g(()=>{"use strict";es=".claude/skills/epiq/SKILL.md",um="---\nname: epiq\ndescription: Workflow rules for working the epiq issue board \u2014 use the epiq MCP, sync on demand, scope tickets small, keep status/tags accurate, and communicate via comments.\n---\n\n# Epiq board workflow\n\n- **Never test against the real board.** Point any dev server, manual test or test run at a throwaway project, never at this repo's own. Deleting test tickets afterwards does not undo the events. Stop the dev server when you're done rather than leaving it autosyncing.\n- **Use the epiq MCP tools** (`epiq_*`) for all board operations \u2014 never the `epiq` CLI or hand-edited state files.\n- **Never edit the state branch directly.** Don't check it out, don't write to its worktree, don't touch the event log or any file under it by hand or by script \u2014 go through the MCP for every read and write. The event log is the system of record: an edit made outside it bypasses validation and ordering, and can corrupt history in ways no later fix can undo.\n- **Sync is on-demand only.** MCP reads/writes operate on local state and never pull/push automatically. Call `epiq_sync` explicitly when you need the latest remote state or want to publish local changes.\n- **Break work into small, scoped tickets.** One ticket per independent unit of work, not one giant ticket for a whole feature/epic. Small tickets move through the board cleanly and are easier to review.\n- **A small request tightly coupled to a ticket goes into that ticket, not a new one.** When the user asks for a tweak that only makes sense as part of work a ticket already covers \u2014 halving a limit it just introduced, moving a control it just added \u2014 do not file a fresh ticket for it. Record the new requirement as a comment on the original ticket and fold it into the description, move the ticket back to Ongoing if it had already reached Done, prefix the follow-up's commits with that ticket's ref, and add a further `Solution:` comment when it lands, so the ticket's own commit list tells the whole story. `QPPR7PE` is what this avoids: a one-line follow-up to `MBB6WY5` (halve the log cap it had just introduced) that now lives on a ticket of its own. The original does not have to be the ticket you took this session: any ticket open on the board and assigned to you counts. A new ticket is for work that stands on its own \u2014 that someone else could pick up cold, or that needs more than a line or two to describe.\n- **Keep the status column current as work progresses**\n- **Assign the ticket to yourself when you pick it up**, alongside moving it to Ongoing \u2014 so the board shows who is on what, not just what is in flight.\n- **A ticket you file for work you will do this session is assigned to you as you file it.** Filing it unassigned and picking it up a minute later leaves a window where the board shows nobody on it. Picking up a ticket assigned to somebody else is fine \u2014 but ask the user first: it may be mid-flight in another session, and the assignee is what says so.\n- **Take a name as soon as this skill loads, and say it.** Your board identity is `provider/human-name` \u2014 the model provider, a slash, then a short human first name: `claude/peter`, `codex/fred`. Announce it as your first line, exactly `Assuming claude/peter`, and work under it for the whole session so the log reads \"claude/peter did X\" rather than signing the user's name to your work. Before inventing one, call `epiq_contributor_list` and reuse an existing identity for your provider if there is one \u2014 a name is permanent once it has authored anything (`tombstoneContributor` refuses authors), and each new one adds a contributor and an event log file forever. Keep the name stable across sessions; never rename yourself mid-session.\n- **Make the name true with `epiq_actor_assume`, before your first board write.** Announcing alone changes nothing: the writes would still be signed with the user's name. The tool takes the identity for the rest of the session and registers it, so the board carries `claude/peter` rather than the sanitized `claude-peter` the log file name would give. It is idempotent, so re-announcing is free; if it refuses because the server was launched under a name, that name wins \u2014 work under the one it reports and say so. Never claim an attribution the tool did not confirm.\n- **Boot your own MCP instance, and never share one.** `epiq_actor_assume` binds the name to the server process it is called on, so two sessions on one server \u2014 or a session on the user's own instance \u2014 would sign every write with whichever name was assumed last, and the log would fold them into one contributor. Every session therefore needs a server process of its own before its first board call: the one Claude Code spawns for the session counts, and if that never connected (a `CONNECT_TIMEOUT` at boot), start one yourself \u2014 `npx -y -p epiq@latest epiq-mcp` speaks MCP JSON-RPC over stdio, so a small script holding that process and forwarding `tools/call` requests is enough \u2014 rather than waiting on the user or borrowing another session's. Assume the name on *that* process; a restart forgets it, so assume it again before the next write. Kill what you started when the session ends, including the `epiq-mcp` child, which outlives its parent.\n- **When other agents may be running, ask which name to take rather than picking one.** Nothing stops two live agents answering to one name \u2014 the log is a CRDT and takes concurrent writers happily, so they would converge into one indistinguishable identity rather than fail. Another session is likely whenever there is more than one `epiq-mcp` process, another worktree with recent changes, or the user says so; in that case list the existing names for your provider from `epiq_contributor_list` and ask the user which one is free, before `epiq_actor_assume` \u2014 a name once assumed binds the server process, and a second name is refused until it restarts. Ask with the names in the question, not \"which name?\": the user is choosing between identities they can see on the board.\n- **Name the terminal window after the identity.** Several sessions look alike; the name in the tab is how the user tells which window is `claude/peter`. The session cannot reach the terminal itself \u2014 the shell it runs has no tty \u2014 so put the request in the announcement line: `Assuming claude/peter \u2014 please /rename claude/peter so this window carries the name.`\n- **Prefix commits with the ticket ref. **Retrieve the ref programmatically, NEVER DERIVE IT.\\*\\* Read the `ref` field off the MCP response (`epiq_issue_list` and `epiq_board_list` include it on every entry). This is what link-by-reference feature matches on.\n- **Work in a worktree, and leave the root checkout alone.** Take one before the first edit (`EnterWorktree`, or `git worktree add .claude/worktrees/<ref>-<slug>` for a branch that already exists), and never check a feature branch out at the root: the root is where `main` belongs and where the user checks it out themselves, and a branch checked out anywhere is unavailable everywhere else. For the same reason `main` never goes *into* a worktree. Several sessions share this repository at once, so a shared checkout also means one session's `checkout` or `reset` quietly discarding another's work. A fresh worktree needs its own `npm install` before the hooks and suites will run there.\n- **Never work on main, and never merge into it locally. Every change reaches main through a pull request.** Branch before the first edit, push the branch, open the PR, let the gate run, then integrate it. A local merge into `main` looks like it worked and is invisible to everyone else: the work is on nobody's remote, no PR ran the gate over it, and it is one `git fetch origin +main:main` away from vanishing from the branch you are sitting on. That has already happened here \u2014 a tag-filter feature and a scrubber-URL feature lived only in one machine's local `main` for a day, and disappeared the moment somebody synced main with the remote. If you find yourself with commits on local `main`, move them onto a branch and open a PR before doing anything else.\n- **Always rebase onto the target, never merge into it.** Rebase the branch onto the target first, then integrate with a rebase merge \u2014 `gh pr merge --rebase`, never `--merge`. Main stays a flat sequence of ref-prefixed commits, which is what the commit\u2194ticket linking reads. A merge commit adds a subject carrying no ref and buries the branch's commits behind it.\n- **Squashing the branch down first is fine \u2014 one commit per ticket ref.** A branch's worth of fixups is history nobody needs on main, so collapsing it into a single commit (`git rebase -i`, or `gh pr merge --squash` with a ref-prefixed subject) is welcome, provided every commit that lands still opens with its ticket's ref. What the linking cannot survive is a squash *across* refs: fold two tickets' commits into one subject and one of them loses its commits for good. So a branch carrying two refs squashes to two commits, not one \u2014 and check the resulting subject before integrating, because `--squash` defaults to the PR title, which is only right if the title carries the ref.\n- **The git user is the sole author of every commit you write.** Commit under the repo's configured `user.name` / `user.email` and nothing else: no `Co-Authored-By:` line, no `Claude-Session:` line, no `\u{1F916} Generated with` footer, and never an `--author` override naming Claude or a tool. The commit body ends with the last line of prose. This holds for amends and rebases too \u2014 check `git log --format='%an <%ae>%n%b'` over the branch before pushing, because a trailer added by a default template survives a rebase and reaches main unnoticed. It does **not** license rewriting anyone else's authorship: commits by other contributors keep their author, and reassigning them would both misattribute their work and mean force-pushing main.\n- **Tag tickets properly.** Reuse existing tags where they fit (check current issues/tags first) instead of inventing near-duplicates.\n- **Read the ticket's comments before starting, not just its description.** The description is what was known when the ticket was written; comments carry later context \u2014 narrowed scope, a decision already taken, a dead end someone hit, a correction to the original diagnosis. Working from the description alone risks redoing settled work or implementing something that was already ruled out.\n- **Use comments to communicate deviations.** If the work diverges from what the ticket describes \u2014 scope changes, findings, blockers, test results \u2014 record it as a comment on the ticket, not just in chat.\n- When a ticket is done, **Document the outcome in a comment starting with `Solution:`.** Use that exact prefix as the comment's opening line, so `^Solution:` finds every resolved ticket on the board. Say what actually resolved it \u2014 the commit, the approach taken, and anything a reader would otherwise have to reverse-engineer from the diff; a bare commit hash is not a solution. Use the same prefix when a ticket is closed _without_ a code change, and say why.\n- **Attach a screenshot only when a picture carries what words cannot** \u2014 a layout that has to be seen, a rendering bug, a chart whose shape is the point. It is the special case, not a routine part of a `Solution:` comment: most outcomes are better described than photographed, and a screenshot of something a sentence already covers costs everyone the bytes below. When one does earn its place, use `epiq_issue_attachment_add` (it takes a file path) and paste the `markdown` it returns into the comment.\n- **Crop and compress it first.** `epiq_issue_attachment_add` stores the file exactly as it finds it \u2014 only the GUI compresses on upload \u2014 so a raw full-screen capture goes in at full size, up to the 500 KB cap. The blob lands in `.epiq/media/` on the state branch, replicates to every clone, and is never removed: deleting an attachment writes a tombstone and the bytes stay, so time travel can still resolve them. Crop to the region that makes the point, scale it down, and land well under the cap rather than against it. An oversized image is permanent, for everybody \u2014 the same reason the text limits exist.\n- **Be concise.** Titles, descriptions, and comments should be scannable, not essays.\n- If a ticket is blocked, **record the blocker in a comment** and move it to Blocked (or tag it blocked if there is no Blocked column).\n- If a you decide to take a new approach, make sure to document the fork in a new comment, and tag the ticket with a \"fork\" tag, **update the description** to reflect the new plan. Don't leave it as-is and expect readers to infer the change from comments.\n- **Park decisions that are the user's to make.** A design fork, a change with blast radius beyond its ticket, anything you'd want a second opinion on \u2014 file a ticket tagged `human-input-needed` naming the options and the trade-off, then carry on with whatever doesn't depend on the answer. Settling it alone in chat, while nobody is reading, is a decision the user never made.\n- **Findings from a code review get their own tickets**, tagged `from-review`, with the description saying which branch or PR the review covered \u2014 so the provenance survives even if the tag doesn't.\n"});import Sl from"node:fs";import oI from"node:path";var sI,iI=g(()=>{"use strict";rt();N();rI();sI=async(e={})=>{let t=await kt(e.repoRoot??process.cwd());if(a(t))return l(t.message);let n=oI.join(t.value,es);if(Sl.existsSync(n)){if(Sl.readFileSync(n,"utf8")===um)return d("Skill already installed and up to date",{path:n,written:!1});if(!e.force)return l(`${es} already exists and differs from the bundled skill. Pass force:true to overwrite it.`)}try{Sl.mkdirSync(oI.dirname(n),{recursive:!0}),Sl.writeFileSync(n,um,"utf8")}catch(r){return l(r instanceof Error?`Failed to write ${es}: ${r.message}`:`Failed to write ${es}`)}return d(`Installed skill at ${es}`,{path:n,written:!0})}});var lI={};rs(lI,{createMcpServer:()=>aI,resultJson:()=>mm,startMcpServer:()=>$A});import{McpServer as FA}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as BA}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as y}from"zod";var mm,oe,aI,$A,cI=g(()=>{"use strict";N();On();Ex();om();Cx();nI();iI();yi();mm=e=>({isError:a(e),content:[{type:"text",text:JSON.stringify(e,null,2)}]}),oe=e=>t=>ox(async()=>mm(await e(t))),aI=()=>{let e=new FA({name:"epiq",version:"0.2.30"});return e.registerTool("epiq_state_get",{description:"Get the full current Epiq state, including nodes and event log",inputSchema:y.object({repoRoot:y.string().optional()})},oe(Eu)),e.registerTool("epiq_issue_list",{description:"List Epiq issues. Narrow with boardId, swimlaneId, tag, assignee or query (matched against title and description), and pass brief to get id, ref, title, swimlane, tag names and assignee names only \u2014 descriptions are the bulk of a board. Read one ticket with epiq_issue_get.",inputSchema:y.object({repoRoot:y.string().optional(),includeClosed:y.boolean().optional(),boardId:y.string().optional(),swimlaneId:y.string().optional(),tag:y.string().optional(),assignee:y.string().optional(),query:y.string().optional(),brief:y.boolean().optional()})},oe(Cu)),e.registerTool("epiq_issue_get",{description:"Get one Epiq issue by its full id or its 7-character ref, with its comments in log order. Use this rather than listing the whole board when you already know which issue you want, and rather than epiq_state_get to read a thread.",inputSchema:y.object({idOrRef:y.string().min(1),repoRoot:y.string().optional()})},oe(Nu)),e.registerTool("epiq_issue_stats",{description:"Code stats for one issue, derived from the commits whose subject carries its ref: how big the change is, how it is spread, and how much of it the ticket spent rewriting its own work. Reads git only \u2014 it never touches the board \u2014 so it is safe to call while other work is in flight. No commits carrying the ref reads as a change of zero size, which is not the same as no work: a commit only links if its subject opens with the ref.",inputSchema:y.object({idOrRef:y.string().min(1),repoRoot:y.string().optional()})},async t=>mm(await tI(t))),e.registerTool("epiq_board_list",{description:"List Epiq boards",inputSchema:y.object({repoRoot:y.string().optional()})},oe(Pu)),e.registerTool("epiq_board_create",{description:"Create an Epiq board. It comes out without swimlanes; add them with epiq_swimlane_create. Refused while time travelling.",inputSchema:y.object({repoRoot:y.string().optional(),title:y.string().min(1).max(300)})},oe(Du)),e.registerTool("epiq_swimlane_list",{description:"List Epiq swimlanes",inputSchema:y.object({repoRoot:y.string().optional(),boardId:y.string().optional()})},oe(_u)),e.registerTool("epiq_swimlane_create",{description:"Create an Epiq swimlane on a board",inputSchema:y.object({repoRoot:y.string().optional(),boardId:y.string().min(1),title:y.string().min(1).max(300)})},oe(Fu)),e.registerTool("epiq_swimlane_title_edit",{description:"Edit an Epiq swimlane title",inputSchema:y.object({repoRoot:y.string().optional(),swimlaneId:y.string().min(1),title:y.string().min(1).max(300)})},oe(Bu)),e.registerTool("epiq_board_title_edit",{description:"Edit an Epiq board title. Refused while time travelling.",inputSchema:y.object({repoRoot:y.string().optional(),boardId:y.string().min(1),title:y.string().min(1).max(300)})},oe(Ou)),e.registerTool("epiq_swimlane_move",{description:"Move/reorder an Epiq swimlane, optionally to another board",inputSchema:y.object({repoRoot:y.string().optional(),swimlaneId:y.string().min(1),boardId:y.string().min(1),position:y.discriminatedUnion("at",[y.object({at:y.literal("start")}),y.object({at:y.literal("end")}),y.object({at:y.literal("before"),sibling:y.string().min(1)}),y.object({at:y.literal("after"),sibling:y.string().min(1)})]).optional()})},oe($u)),e.registerTool("epiq_swimlane_delete",{description:"Delete (archive) an Epiq swimlane. This also archives every issue contained in it.",inputSchema:y.object({repoRoot:y.string().optional(),swimlaneId:y.string().min(1)})},oe(ju)),e.registerTool("epiq_issue_create",{description:"Create an Epiq issue in a swimlane: parentId is the swimlane id (epiq_swimlane_list), never a board id. Optionally set description, tags, and assignees atomically in the same call instead of separate follow-up edits.",inputSchema:y.object({title:y.string().min(1).max(300),parentId:y.string().min(1),repoRoot:y.string().optional(),description:y.string().max(2e4).optional(),tagNames:y.array(y.string().max(60)).max(20).optional(),assigneeNames:y.array(y.string().max(80)).max(20).optional()})},oe(wu)),e.registerTool("epiq_issue_description_edit",{description:"Edit the markdown description of an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),description:y.string().max(2e4),repoRoot:y.string().optional()})},oe(Mu)),e.registerTool("epiq_issue_title_edit",{description:"Edit the title of an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),title:y.string().min(1).max(300),repoRoot:y.string().optional()})},oe(Lu)),e.registerTool("epiq_issue_tag_add",{description:"Add a tag to an Epiq issue, or to many at once with issueIds, creating the tag if it does not exist",inputSchema:y.object({issueId:y.string().min(1).optional(),issueIds:y.array(y.string().min(1)).min(1).max(200).optional(),tagName:y.string().min(1).max(60),repoRoot:y.string().optional()})},oe(Uu)),e.registerTool("epiq_issue_tag_remove",{description:"Remove a tag from an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),tagId:y.string().min(1),repoRoot:y.string().optional()})},oe(qu)),e.registerTool("epiq_contributor_list",{description:"List people who can be assigned: everyone who has authored an event (optionally scoped to one board) unioned with the contributor registry. Use these ids with epiq_issue_assignee_add rather than assigning by name.",inputSchema:y.object({boardId:y.string().min(1).optional(),repoRoot:y.string().optional()})},oe(Yu)),e.registerTool("epiq_contributor_remove",{description:"Remove an external contributor from the assignee suggestion lists. Their id and every reference to it survive, so existing assignments stay intact and the event log is untouched. Refused for anyone who has authored events, since their name is in the log regardless.",inputSchema:y.object({contributorId:y.string().min(1),repoRoot:y.string().optional()})},oe(Vu)),e.registerTool("epiq_tag_remove",{description:"Delete a tag from the whole workspace. It disappears from every ticket, picker and filter, but its id and history stay in the event log, and the name is free for a new tag.",inputSchema:y.object({tagId:y.string().min(1),repoRoot:y.string().optional()})},oe(Hu)),e.registerTool("epiq_tag_restore",{description:"Put back a tag deleted with epiq_tag_remove, on every ticket that still carried it.",inputSchema:y.object({tagId:y.string().min(1),repoRoot:y.string().optional()})},oe(Wu)),e.registerTool("epiq_contributor_restore",{description:"Put a contributor removed with epiq_contributor_remove back into the suggestion lists, under the name they were created with.",inputSchema:y.object({contributorId:y.string().min(1),repoRoot:y.string().optional()})},oe(Ku)),e.registerTool("epiq_issue_assignee_add",{description:"Assign a contributor to an Epiq issue. Pass self:true to assign yourself. Prefer assigneeId otherwise, which assigns a known contributor (from the registry or the event log) and fails if the id is unknown. assigneeName matches an existing contributor by name; to create somebody new from a name you must also pass createUnlinked, which adds them as an external (non-contributor) assignee.",inputSchema:y.object({issueId:y.string().min(1),assigneeId:y.string().min(1).optional(),self:y.boolean().optional(),assigneeName:y.string().min(1).max(80).optional(),createUnlinked:y.boolean().optional(),repoRoot:y.string().optional()})},oe(zu)),e.registerTool("epiq_issue_assignee_remove",{description:"Remove an assignee from an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),assigneeId:y.string().min(1),repoRoot:y.string().optional()})},oe(Xu)),e.registerTool("epiq_issue_comment_add",{description:"Add a comment to an Epiq issue",inputSchema:y.object({issueId:y.string().min(1),body:y.string().min(1).max(4e3),repoRoot:y.string().optional()})},oe(Ju)),e.registerTool("epiq_issue_attachment_add",{description:"Attach an image file to an Epiq issue. Returns `markdown` \u2014 paste it into a comment or description body to render the image inline.",inputSchema:y.object({issueId:y.string().min(1),filePath:y.string().min(1),name:y.string().min(1).max(200).optional(),repoRoot:y.string().optional()})},oe(xu)),e.registerTool("epiq_issue_comment_delete",{description:"Delete a comment from an Epiq issue",inputSchema:y.object({commentId:y.string().min(1),repoRoot:y.string().optional()})},oe(Qu)),e.registerTool("epiq_issue_comment_edit",{description:"Replace the body of one of your own comments on an Epiq issue",inputSchema:y.object({commentId:y.string().min(1),body:y.string().min(1).max(4e3),repoRoot:y.string().optional()})},oe(Zu)),e.registerTool("epiq_issue_reopen",{description:"Reopen a closed Epiq issue, restoring it to its previous swimlane",inputSchema:y.object({issueId:y.string().min(1),repoRoot:y.string().optional()})},oe(Tu)),e.registerTool("epiq_issue_close",{description:"Close an Epiq issue, or many at once with issueIds \u2014 one call, an outcome per ticket",inputSchema:y.object({issueId:y.string().min(1).optional(),issueIds:y.array(y.string().min(1)).min(1).max(200).optional(),repoRoot:y.string().optional()})},oe(Au)),e.registerTool("epiq_issue_move",{description:"Move an Epiq issue to another swimlane (parentId is the swimlane id), or many at once with issueIds \u2014 one call, an outcome per ticket",inputSchema:y.object({issueId:y.string().min(1).optional(),issueIds:y.array(y.string().min(1)).min(1).max(200).optional(),parentId:y.string().min(1),position:y.discriminatedUnion("at",[y.object({at:y.literal("start")}),y.object({at:y.literal("end")}),y.object({at:y.literal("before"),sibling:y.string().min(1)}),y.object({at:y.literal("after"),sibling:y.string().min(1)})]).optional(),repoRoot:y.string().optional()})},oe(ku)),e.registerTool("epiq_actor_assume",{description:'Take a board identity for the rest of this session, so your writes are attributed to you rather than to the user. Pass the name you announced \u2014 the model provider, a slash, then a short human first name, e.g. "claude/peter". Takes effect on the very next write; no relaunch. A name the server was launched with wins, and re-assuming the same name is harmless. Reuse an existing agent identity (epiq_contributor_list) before inventing one: a name is permanent once it has authored anything.',inputSchema:y.object({name:y.string().min(1).max(80),repoRoot:y.string().optional()})},oe(Gu)),e.registerTool("epiq_contributor_email_link",{description:"Bind a git author address to a contributor, so their commits and their board activity read as one person. Defaults to you; pass contributorId to link a colleague who does not use epiq, whose commits otherwise never resolve. The address the repository's git is configured with links itself on your first write, so this is for older addresses and for other people. An address two contributors claim resolves to neither, and the reply says so.",inputSchema:y.object({email:y.string().min(1).max(254),contributorId:y.string().min(1).optional(),repoRoot:y.string().optional()})},oe(em)),e.registerTool("epiq_contributor_email_unlink",{description:"Retract a link between a git address and a contributor. Allowed only to whoever wrote the link and to the contributor it names, so nobody can strip links that are neither theirs nor about them. Forward-only: the address stops resolving and the event stays in the log.",inputSchema:y.object({email:y.string().min(1).max(254),contributorId:y.string().min(1).optional(),repoRoot:y.string().optional()})},oe(tm)),e.registerTool("epiq_contributor_email_suggest",{description:"Addresses in this repository's history that look like yours and nobody has claimed, for the user to confirm. Run it once after this feature reaches a board with history: the address git is configured with links itself, but older ones do not, and until they are linked those commits show a raw git name. Show the list and link only what the user confirms \u2014 each link is permanent and replicates to every clone.",inputSchema:y.object({repoRoot:y.string().optional()})},oe(rm)),e.registerTool("epiq_contributor_email_list",{description:"Every git address the board has bound to a contributor, and who holds it. An address with more than one claimant is flagged contested and resolves to none of them, which is the state nothing else reports.",inputSchema:y.object({repoRoot:y.string().optional()})},oe(nm)),e.registerTool("epiq_project_init",{description:`Set up a new Epiq board in a git repository without the TUI. Runs in the repository at repoRoot (default: the current directory), which must have no uncommitted changes. The first time on a machine it also records the user's setup: ask the user for userName (how they want to appear on the board), preferredEditor (e.g. "vim" or "code --wait") and autoSync (whether the TUI and GUI sync with the remote on their own) and pass them here; called without them it fails naming what is still missing, keeping whatever was given. It fills in answers the machine lacks and refuses to change ones it has. Pass the user's name, never your own agent identity. Commits the state branch and .epiq/project.json and tries to push both; a push that fails is a warning, not an error. Afterwards the other tools work in that repository.`,inputSchema:y.object({repoRoot:y.string().optional(),userName:y.string().min(1).max(80).optional(),preferredEditor:y.string().min(1).max(200).optional(),autoSync:y.boolean().optional()})},oe(Nx)),e.registerTool("epiq_skill_install",{description:"Write the official Epiq workflow skill into the repository at .claude/skills/epiq/SKILL.md, so agents working there follow the same board rules. Run it after epiq_project_init, not before: the new file is an uncommitted change that init refuses. In a project that already has a board, run it any time. Refuses to overwrite a differing file unless force is true; an identical file is left alone.",inputSchema:y.object({repoRoot:y.string().optional(),force:y.boolean().optional()})},oe(sI)),e.registerTool("epiq_sync",{description:"Sync Epiq state with the configured Git remote (pull remote changes and push local ones). Other Epiq MCP tools only read and write local state and never sync automatically \u2014 call this on demand when you need to see or publish the latest remote changes.",inputSchema:y.object({repoRoot:y.string().optional()})},oe(Ru)),e},$A=async()=>{let e=aI(),t=new BA;await e.connect(t)}});process.env.EPIQ_MCP="true";console.log=console.error;console.info=console.error;console.debug=console.error;console.warn=console.error;var{applyActorNameArgument:jA}=await Promise.resolve().then(()=>(yr(),bm)),{isFail:UA}=await Promise.resolve().then(()=>(N(),hm)),{parseMcpArgs:HA}=await Promise.resolve().then(()=>(Em(),Im)),ts=HA(process.argv.slice(2));ts.kind==="error"&&(console.error(ts.message),process.exit(1));ts.kind==="print"&&(process.stdout.write(ts.text),process.exit(0));if(ts.kind==="name"){let e=jA(ts.name,"The name argument");UA(e)&&(console.error(e.message),process.exit(1))}var{setVirtualNodesEnabled:WA}=await Promise.resolve().then(()=>($c(),ex));WA(!1);var{startMcpServer:qA}=await Promise.resolve().then(()=>(cI(),lI));await qA();