@testmuai/kane-cli 0.7.1 → 0.8.1

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 (308) hide show
  1. package/dist/ChatSurface-U37VZDCW.js +8 -0
  2. package/dist/{ChromeProfilePicker-4CDSPBWL.js → ChromeProfilePicker-AUU7JF6F.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-TLRVBA4E.js → CliFeedbackPrompt-4W74Y3UF.js} +1 -1
  4. package/dist/{CliUploadProgress-WGGFLUSF.js → CliUploadProgress-6HL7WTEX.js} +1 -1
  5. package/dist/ConfigView-6BSCZP5Y.js +2 -0
  6. package/dist/EvidenceViewOffer-62XHEEGW.js +2 -0
  7. package/dist/FolderPicker-S7U2EN2M.js +2 -0
  8. package/dist/{HelpView-FBCX32U7.js → HelpView-TU7ED43J.js} +1 -1
  9. package/dist/{InfoBox-KK2ICVS4.js → InfoBox-JLTMKVDE.js} +1 -1
  10. package/dist/{LinksBox-KKRANMR3.js → LinksBox-LREUUJDV.js} +1 -1
  11. package/dist/{ProfilesView-DGPXSAQN.js → ProfilesView-W3GX2N2E.js} +1 -1
  12. package/dist/{ProjectPicker-ESQSL4TT.js → ProjectPicker-SYQUJK2J.js} +1 -1
  13. package/dist/{SaveSessionPrompt-AQGP5W6E.js → SaveSessionPrompt-MR5NJMRP.js} +1 -1
  14. package/dist/SingleShotApp-XOKVOM7C.js +2 -0
  15. package/dist/{SummaryBox-BFZJW2KK.js → SummaryBox-UAYSVFB7.js} +1 -1
  16. package/dist/TestMdRunView-7UVSDAF4.js +2 -0
  17. package/dist/{WhoamiView-JABY3I5Q.js → WhoamiView-2YU76ASQ.js} +1 -1
  18. package/dist/adbkit-apkreader-ORZBGCJQ.js +184 -0
  19. package/dist/app-client-OEXESV4U.js +2 -0
  20. package/dist/app-download-AEEFQ63M.js +2 -0
  21. package/dist/{auth-76LVI6B5.js → auth-HET3TBRI.js} +1 -1
  22. package/dist/bind-STKXOUYI.js +12 -0
  23. package/dist/bootstrap-44YKVWWE.js +2 -0
  24. package/dist/bridge-5Z3BIB77.js +2 -0
  25. package/dist/{changelog-PSWPPOAF.js → changelog-7OWRHFHZ.js} +1 -1
  26. package/dist/chat-committer-ZWWCLJFD.js +2 -0
  27. package/dist/chat-controller-T2FAI55V.js +2 -0
  28. package/dist/{chunk-C4G7RVJ6.js → chunk-27U4PLPX.js} +1 -1
  29. package/dist/{chunk-V36ATG7A.js → chunk-2BGUUWNF.js} +2 -2
  30. package/dist/chunk-2KDGIZED.js +4 -0
  31. package/dist/chunk-2UIHS2FH.js +2 -0
  32. package/dist/chunk-2YEHV2CX.js +2 -0
  33. package/dist/{chunk-NRTHYROA.js → chunk-3LJWYRAA.js} +1 -1
  34. package/dist/chunk-3PECJD6S.js +11 -0
  35. package/dist/chunk-3POR47RC.js +8 -0
  36. package/dist/{chunk-KVQOBPAZ.js → chunk-3Q6WAK6P.js} +1 -1
  37. package/dist/chunk-4JOD47QI.js +2 -0
  38. package/dist/chunk-56PAQAX5.js +19 -0
  39. package/dist/{chunk-FCMLIK7P.js → chunk-5DBK6QNS.js} +1 -1
  40. package/dist/chunk-5DT7PIGB.js +5 -0
  41. package/dist/chunk-65ZTD5SJ.js +7 -0
  42. package/dist/chunk-6IA6QMPH.js +2 -0
  43. package/dist/{chunk-5KFS3GAZ.js → chunk-6KPPGMO2.js} +1 -1
  44. package/dist/{chunk-F6ZOJXYU.js → chunk-6O3DDOP2.js} +1 -1
  45. package/dist/chunk-6XX4LEVJ.js +2 -0
  46. package/dist/{chunk-KT6G7AF2.js → chunk-766WGMBU.js} +1 -1
  47. package/dist/chunk-7BZSCUPP.js +10 -0
  48. package/dist/{chunk-UBFKZEX3.js → chunk-7JWKHKFU.js} +2 -2
  49. package/dist/{chunk-PMHJRT3A.js → chunk-7KORP5FF.js} +1 -1
  50. package/dist/chunk-7Q6M6P4X.js +26 -0
  51. package/dist/{chunk-AM5S4KG4.js → chunk-AFPHLUQ5.js} +1 -1
  52. package/dist/chunk-AW2XUHH4.js +2 -0
  53. package/dist/chunk-BKHXPBWN.js +2 -0
  54. package/dist/chunk-BRHNRCEZ.js +3 -0
  55. package/dist/chunk-BRIEBB2U.js +2 -0
  56. package/dist/{chunk-NJPTOKW5.js → chunk-C7HSWZP6.js} +1 -1
  57. package/dist/{chunk-JEUA4UWK.js → chunk-CLGC7VEO.js} +1 -1
  58. package/dist/chunk-CTW2VQKS.js +6 -0
  59. package/dist/{chunk-L4JIMNKW.js → chunk-CUM23TLF.js} +1 -1
  60. package/dist/chunk-DBIBROYW.js +5 -0
  61. package/dist/{chunk-L7VREJTG.js → chunk-DCY6R5DP.js} +1 -1
  62. package/dist/{chunk-X3ICV5M5.js → chunk-DO5HAO3H.js} +1 -1
  63. package/dist/chunk-DPUV6OSP.js +2 -0
  64. package/dist/{chunk-M7WQM4UA.js → chunk-DUAXZYAD.js} +1 -1
  65. package/dist/{chunk-HPMS5KO6.js → chunk-DZGCXKKI.js} +3 -3
  66. package/dist/chunk-EDSZJZFG.js +4 -0
  67. package/dist/{chunk-OIYGGEUL.js → chunk-ELM6MXGJ.js} +1 -1
  68. package/dist/{chunk-R2RGSO4B.js → chunk-EWCAFKLX.js} +1 -1
  69. package/dist/chunk-EYOCNMUM.js +2 -0
  70. package/dist/{chunk-73C4PRYU.js → chunk-FEJXWJ3L.js} +1 -1
  71. package/dist/{chunk-BAL64WSI.js → chunk-FMRSMN34.js} +1 -1
  72. package/dist/chunk-FNH55WSR.js +19 -0
  73. package/dist/chunk-FQLIW3LM.js +2 -0
  74. package/dist/{chunk-JRMDGLLT.js → chunk-G7VQCS4J.js} +1 -1
  75. package/dist/chunk-GCBKDX2J.js +2 -0
  76. package/dist/{chunk-AAONIIQV.js → chunk-GFKCTYCA.js} +1 -1
  77. package/dist/chunk-GKYPNSQP.js +26 -0
  78. package/dist/chunk-GPG3FIN3.js +21 -0
  79. package/dist/chunk-GZPK6FRP.js +7 -0
  80. package/dist/{chunk-NOCIMJSN.js → chunk-HCKH44I2.js} +1 -1
  81. package/dist/chunk-HEAIJCGZ.js +2 -0
  82. package/dist/{chunk-3FN5VJMV.js → chunk-HMYMSRA4.js} +1 -1
  83. package/dist/chunk-I7TIGB7K.js +2 -0
  84. package/dist/chunk-IDX3TOPY.js +6 -0
  85. package/dist/{chunk-CVOGP253.js → chunk-IMR64OCZ.js} +1 -1
  86. package/dist/{chunk-IBNC444G.js → chunk-IOD3HQVW.js} +1 -1
  87. package/dist/chunk-IOFZSQAA.js +2 -0
  88. package/dist/chunk-IP2O264K.js +3 -0
  89. package/dist/{chunk-CSQ46PJ7.js → chunk-JJHG3BWO.js} +1 -1
  90. package/dist/{chunk-5JTUL6XL.js → chunk-JZ26R6UL.js} +1 -1
  91. package/dist/chunk-KBM3XHAM.js +2 -0
  92. package/dist/{chunk-SY3HLQMV.js → chunk-KCCSWEGA.js} +1 -1
  93. package/dist/chunk-KFSUPQAG.js +66 -0
  94. package/dist/chunk-KRKGZ2ZW.js +47 -0
  95. package/dist/chunk-KU6IXFGZ.js +9 -0
  96. package/dist/chunk-L7MXYCD7.js +2 -0
  97. package/dist/chunk-MA34UWKX.js +4 -0
  98. package/dist/chunk-MBF3FP5P.js +5 -0
  99. package/dist/chunk-MSGW4JDG.js +2 -0
  100. package/dist/chunk-MXHHMIO2.js +349 -0
  101. package/dist/chunk-N2P4MI32.js +2 -0
  102. package/dist/{chunk-CDQX6HGJ.js → chunk-NX7TM662.js} +1 -1
  103. package/dist/chunk-OMQCD3KR.js +2 -0
  104. package/dist/{chunk-QROUKGKU.js → chunk-OS4VSIHT.js} +1 -1
  105. package/dist/chunk-OTTGS2TE.js +2 -0
  106. package/dist/chunk-QGKPLOUI.js +2 -0
  107. package/dist/{chunk-JKTFTF24.js → chunk-QRZRSAZH.js} +1 -1
  108. package/dist/{chunk-WJ5HDEVH.js → chunk-QSDH5P7C.js} +1 -1
  109. package/dist/{chunk-322JEJEH.js → chunk-QW6EZC53.js} +1 -1
  110. package/dist/{chunk-2XMJ6YAE.js → chunk-R5T4RLF5.js} +1 -1
  111. package/dist/chunk-R7QAS6LZ.js +4 -0
  112. package/dist/{chunk-LR5XO2KD.js → chunk-RC52N7PC.js} +1 -1
  113. package/dist/{chunk-33QXD75Y.js → chunk-RFR4ZKIC.js} +3 -3
  114. package/dist/{chunk-3LWTUMDG.js → chunk-RLRNLIRS.js} +1 -1
  115. package/dist/{chunk-XDHZMCTA.js → chunk-SDPRO2LE.js} +2 -2
  116. package/dist/chunk-T5Y6MOLM.js +4 -0
  117. package/dist/{chunk-4OPQJ7PE.js → chunk-TFPPEOAK.js} +1 -1
  118. package/dist/chunk-TH47OOBV.js +4 -0
  119. package/dist/{chunk-XVDJ423L.js → chunk-TKGUT425.js} +1 -1
  120. package/dist/{chunk-OHRS3H7Z.js → chunk-TRJUD3XJ.js} +1 -1
  121. package/dist/chunk-TYLYFERW.js +10 -0
  122. package/dist/chunk-TZXXJWHA.js +2 -0
  123. package/dist/chunk-UD7KKHPW.js +5 -0
  124. package/dist/{chunk-APAIWBIH.js → chunk-UDIQOJEL.js} +1 -1
  125. package/dist/chunk-UV462FZR.js +2 -0
  126. package/dist/{chunk-323MLBYA.js → chunk-UXDL4XDL.js} +1 -1
  127. package/dist/chunk-V2R3LCA3.js +12 -0
  128. package/dist/chunk-VAYBKR76.js +4 -0
  129. package/dist/{chunk-AH7ZZIZY.js → chunk-VRVFPMCR.js} +1 -1
  130. package/dist/chunk-W2JFDDIB.js +2 -0
  131. package/dist/chunk-W4B5LOEX.js +4 -0
  132. package/dist/{chunk-36OC3TFE.js → chunk-W5TTF7GB.js} +2 -2
  133. package/dist/chunk-WXHQYYD5.js +2 -0
  134. package/dist/{chunk-6HEGD6H2.js → chunk-XO5ZH3ZR.js} +1 -1
  135. package/dist/chunk-XWKUZJCP.js +2 -0
  136. package/dist/{chunk-2KBD6JZX.js → chunk-YFYCCTSL.js} +1 -1
  137. package/dist/{chunk-ZM5PVRJK.js → chunk-YJELGSKJ.js} +1 -1
  138. package/dist/chunk-YRFMPIU2.js +4 -0
  139. package/dist/{chunk-2XGDWUJ5.js → chunk-ZGBSGZZM.js} +1 -1
  140. package/dist/{chunk-NBKQT7LJ.js → chunk-ZIUAOEUC.js} +1 -1
  141. package/dist/chunk-ZMNJBUAO.js +2 -0
  142. package/dist/chunk-ZVHCQMJ6.js +13 -0
  143. package/dist/committer-SWEWEYNX.js +2 -0
  144. package/dist/{config-R3GF2FZA.js → config-RS47F5SC.js} +1 -1
  145. package/dist/{controller-client-RD2YEMAH.js → controller-client-OB4WD2C4.js} +1 -1
  146. package/dist/{cover-cmd-TXICWHUU.js → cover-cmd-HDZZWJXG.js} +1 -1
  147. package/dist/{credentials-XN4ROCQ3.js → credentials-OH6AVI6N.js} +1 -1
  148. package/dist/deps-resolve-XC5S53DG.js +2 -0
  149. package/dist/descriptor-OEUZZCOK.js +2 -0
  150. package/dist/design-committer-VYT6NU3T.js +2 -0
  151. package/dist/dispatch-SE5GY3Z2.js +2 -0
  152. package/dist/doctor-FSECFZUU.js +2 -0
  153. package/dist/docx-convert-JMUMT5C4.js +2 -0
  154. package/dist/{dossier-QZV74XOS.js → dossier-KTLTGT2X.js} +1 -1
  155. package/dist/evidence-OYPHZUKI.js +2 -0
  156. package/dist/evolve-cmd-BCPNXAMV.js +2 -0
  157. package/dist/exec-P2IKJRRR.js +2 -0
  158. package/dist/exit-manager-3FVBTNYR.js +2 -0
  159. package/dist/explain-UAAQWHYR.js +2 -0
  160. package/dist/{explain-cmd-X7JZLSZZ.js → explain-cmd-3GEKR7O5.js} +1 -1
  161. package/dist/{explain-cmd-RZW6QJYM.js → explain-cmd-EX24XKD6.js} +1 -1
  162. package/dist/extract-bind-LLEASZAK.js +10 -0
  163. package/dist/extract-cmd-UZMEZMGP.js +5 -0
  164. package/dist/feeder-C3TOJPKK.js +2 -0
  165. package/dist/{gaps-cmd-BWCRLLBK.js → gaps-cmd-IVXFPFAQ.js} +1 -1
  166. package/dist/{gate-YHBPWEM5.js → gate-54BRAE7N.js} +1 -1
  167. package/dist/{generate-headless-BSTDLZZY.js → generate-headless-D3SVQ2AI.js} +3 -3
  168. package/dist/{headless-io-BL3TEAX5.js → headless-io-66RG5NN5.js} +1 -1
  169. package/dist/host-7GZPBA74.js +2 -0
  170. package/dist/identity-ADZ4PAJF.js +2 -0
  171. package/dist/index.js +85 -69
  172. package/dist/ingest-EX72IEQT.js +2 -0
  173. package/dist/ingest-cmd-EAE7N5RC.js +2 -0
  174. package/dist/{interactive-bind-43HGDF5K.js → interactive-bind-ORMN2REX.js} +7 -6
  175. package/dist/{lifecycle-cmd-D6TVTYRK.js → lifecycle-cmd-O2324GN6.js} +1 -1
  176. package/dist/{list-cmd-XCAV2FKA.js → list-cmd-N4KMA34H.js} +1 -1
  177. package/dist/list-commands-MRXL5HGS.js +2 -0
  178. package/dist/locks-cmd-CSVSWY2Y.js +2 -0
  179. package/dist/logical-ids-TEBCQJGO.js +2 -0
  180. package/dist/login-flow-QJQM3RHT.js +2 -0
  181. package/dist/maintenance-cmd-6XSVO6FO.js +2 -0
  182. package/dist/mobile-prompts-TOX35ER6.js +2 -0
  183. package/dist/pdf-convert-OZIRUADA.js +2 -0
  184. package/dist/persist-recorded-session-TLDQ5HKP.js +3 -0
  185. package/dist/phase-seed-VFHIH6FL.js +2 -0
  186. package/dist/pipeline-UOM4LNAI.js +2 -0
  187. package/dist/prepare-target-QYWIJIVQ.js +2 -0
  188. package/dist/readmodel-XOYGGQ3S.js +2 -0
  189. package/dist/reconcile-cmd-3H34KVVD.js +2 -0
  190. package/dist/reconcile-deps-XIH75ZLY.js +4 -0
  191. package/dist/reconcile-engine-UKWPG2LV.js +2 -0
  192. package/dist/{recording-banner-TALO7PUR.js → recording-banner-4M7XHVGI.js} +1 -1
  193. package/dist/records-IOZTZUZV.js +2 -0
  194. package/dist/registry-PYOTKZYZ.js +2 -0
  195. package/dist/{require-project-folder-R347LFDQ.js → require-project-folder-4UPQNEBJ.js} +1 -1
  196. package/dist/resolve-run-intent-X72V3KJA.js +7 -0
  197. package/dist/{resolver-IDCGRPFJ.js → resolver-UBOZLFFE.js} +1 -1
  198. package/dist/revert-NQ7GEVSE.js +2 -0
  199. package/dist/review-cmd-DQRKQUMG.js +4 -0
  200. package/dist/run-2COODVX2.js +2 -0
  201. package/dist/run-URPGHOQM.js +2 -0
  202. package/dist/run-channel-RGH4WIQX.js +2 -0
  203. package/dist/{run-test-md-DFNIGYB7.js → run-test-md-76ZPKXO6.js} +3 -3
  204. package/dist/session-target-UWROGOCY.js +2 -0
  205. package/dist/sessions-GIEXOCE4.js +2 -0
  206. package/dist/{sessions-cmd-AQWLL5ZN.js → sessions-cmd-ZZIZN2VB.js} +4 -4
  207. package/dist/{skill-installer-ANXTCXQV.js → skill-installer-CIS6GAYF.js} +1 -1
  208. package/dist/spawner-J67QR4QP.js +2 -0
  209. package/dist/structured-answers-5EY2AZN7.js +5 -0
  210. package/dist/tcg-generate-BDTRKY2A.js +2 -0
  211. package/dist/testmd-actions-77ELR5UU.js +2 -0
  212. package/dist/token-refresh-4BPAPXKK.js +2 -0
  213. package/dist/types-6E2HTDKJ.js +2 -0
  214. package/dist/{validate-basic-O2DP2XJL.js → validate-basic-2GVSQ2R5.js} +1 -1
  215. package/dist/verdicts-TRSTJLCL.js +2 -0
  216. package/dist/{version-check-RNR3JCQ5.js → version-check-O6PYTI4T.js} +1 -1
  217. package/dist/{view-cmd-YSEGA5PI.js → view-cmd-KPJTP4DI.js} +1 -1
  218. package/dist/walk-session-CHJXHZMO.js +2 -0
  219. package/dist/with-telemetry-CQCWLVOC.js +2 -0
  220. package/package.json +12 -6
  221. package/dist/ChatSurface-D66CACLX.js +0 -8
  222. package/dist/ConfigView-DBANTBXC.js +0 -2
  223. package/dist/EvidenceViewOffer-DNCQ3A6R.js +0 -2
  224. package/dist/FolderPicker-W7RCIFEL.js +0 -2
  225. package/dist/SingleShotApp-SMCAIKCE.js +0 -2
  226. package/dist/TestMdRunView-FMKZJ3A3.js +0 -2
  227. package/dist/bind-AACBTSAA.js +0 -12
  228. package/dist/bootstrap-CNOZ5VRB.js +0 -2
  229. package/dist/bridge-T4HL4TG7.js +0 -2
  230. package/dist/chat-committer-4BQBOKI4.js +0 -2
  231. package/dist/chat-controller-NNTMKEPG.js +0 -2
  232. package/dist/chunk-2SREGETM.js +0 -4
  233. package/dist/chunk-3STZLM5J.js +0 -4
  234. package/dist/chunk-5YPBPZUR.js +0 -2
  235. package/dist/chunk-6UJDOAYR.js +0 -26
  236. package/dist/chunk-BQHKBOSF.js +0 -11
  237. package/dist/chunk-DQ54MH7F.js +0 -13
  238. package/dist/chunk-DXV6MBTD.js +0 -8
  239. package/dist/chunk-EV3EHXEI.js +0 -4
  240. package/dist/chunk-F7WKDMX7.js +0 -47
  241. package/dist/chunk-FPFOW6BS.js +0 -2
  242. package/dist/chunk-GVIPTX6T.js +0 -6
  243. package/dist/chunk-GW5DWAXY.js +0 -2
  244. package/dist/chunk-HJERKSBK.js +0 -349
  245. package/dist/chunk-IQDWBTRJ.js +0 -3
  246. package/dist/chunk-IXVOXJP6.js +0 -6
  247. package/dist/chunk-KNDSQ4PS.js +0 -2
  248. package/dist/chunk-KRXSXQBU.js +0 -12
  249. package/dist/chunk-LQZ2BU7Q.js +0 -2
  250. package/dist/chunk-NAC7SFBE.js +0 -5
  251. package/dist/chunk-NAE7MBR2.js +0 -23
  252. package/dist/chunk-NRC2G4Y5.js +0 -5
  253. package/dist/chunk-O56PUUNL.js +0 -9
  254. package/dist/chunk-QM4S2APK.js +0 -2
  255. package/dist/chunk-RKWJG3WW.js +0 -19
  256. package/dist/chunk-RNSSM2BK.js +0 -11
  257. package/dist/chunk-SE6WNCYU.js +0 -4
  258. package/dist/chunk-SRDHPKJT.js +0 -2
  259. package/dist/chunk-SWESH2J7.js +0 -10
  260. package/dist/chunk-T63R6QT4.js +0 -4
  261. package/dist/chunk-UI7KULSI.js +0 -7
  262. package/dist/chunk-UPPEOQJQ.js +0 -3
  263. package/dist/chunk-URQUQWGW.js +0 -62
  264. package/dist/chunk-UX2B7L6K.js +0 -2
  265. package/dist/chunk-VOHQA2SP.js +0 -2
  266. package/dist/chunk-W5DOU2DV.js +0 -2
  267. package/dist/chunk-W6VD2XFO.js +0 -19
  268. package/dist/chunk-WAOCHXJ5.js +0 -2
  269. package/dist/chunk-WWNSD6FA.js +0 -6
  270. package/dist/chunk-ZLCZDAEX.js +0 -6
  271. package/dist/committer-2EJPVVCQ.js +0 -2
  272. package/dist/descriptor-KXDJ4XYD.js +0 -2
  273. package/dist/design-committer-BQUWD6AC.js +0 -2
  274. package/dist/docx-convert-ZBVQO2LG.js +0 -2
  275. package/dist/evidence-V23FPVXQ.js +0 -2
  276. package/dist/evolve-cmd-PZCPXDMR.js +0 -2
  277. package/dist/exit-manager-HNFATGSM.js +0 -2
  278. package/dist/explain-UE4IACQH.js +0 -2
  279. package/dist/extract-bind-BFY7IRL4.js +0 -10
  280. package/dist/extract-cmd-U3MGK2LP.js +0 -6
  281. package/dist/feeder-XGTFV7TZ.js +0 -2
  282. package/dist/ingest-AL6CABJT.js +0 -2
  283. package/dist/ingest-cmd-O6OWWZT4.js +0 -2
  284. package/dist/list-commands-747UTUSS.js +0 -2
  285. package/dist/locks-cmd-QAULI5LV.js +0 -2
  286. package/dist/logical-ids-4G4FAHNJ.js +0 -2
  287. package/dist/login-flow-CV76ENHV.js +0 -2
  288. package/dist/maintenance-cmd-ZRB4NTGG.js +0 -2
  289. package/dist/pdf-convert-S7VYE6AV.js +0 -2
  290. package/dist/persist-recorded-session-MDPWWUA7.js +0 -3
  291. package/dist/phase-seed-52LRE3LH.js +0 -2
  292. package/dist/pipeline-LM5JAK7F.js +0 -2
  293. package/dist/readmodel-X7L7W2BA.js +0 -2
  294. package/dist/reconcile-cmd-DGCSDML6.js +0 -2
  295. package/dist/records-5SVUXJBW.js +0 -2
  296. package/dist/revert-DXXYXJGN.js +0 -2
  297. package/dist/review-cmd-2QF5HTI7.js +0 -4
  298. package/dist/run-52UIBPXD.js +0 -2
  299. package/dist/run-VRVH4VO3.js +0 -2
  300. package/dist/sessions-BLXZVK5U.js +0 -2
  301. package/dist/spawner-AH5FTUYU.js +0 -2
  302. package/dist/structured-answers-QHFGZPSS.js +0 -5
  303. package/dist/tcg-generate-WKCBBKI5.js +0 -2
  304. package/dist/testmd-actions-RPYG6TJG.js +0 -2
  305. package/dist/token-refresh-NIDUOTRM.js +0 -2
  306. package/dist/verdicts-TJH3O5UW.js +0 -2
  307. package/dist/walk-session-HXW4OSA2.js +0 -2
  308. package/dist/with-telemetry-PNP6CAVM.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{homedir as a}from"os";import{join as t}from"path";var m="0.7.1",d="kane-cli",e=t(a(),".testmuai","kaneai"),g=t(e,"profiles"),h=t(e,"tui-config.json"),_=t(e,"media"),A="https://registry.npmjs.org/@testmuai/kane-cli",L="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",b=`https://registry.npmjs.org/${n}`,r="kane-cli",x=[{dir:t(a(),".claude","skills",r),agent:"Claude Code"},{dir:t(a(),".agents","skills",r),agent:"Codex CLI"},{dir:t(a(),".gemini","skills",r),agent:"Gemini CLI"}],u="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",R=9222,I=9230,E=t(e,"chrome-profiles"),o=t(e,"hints"),C=t(o,"state.json");function T(s){return t(o,`catalog-${s}.json`)}var c="127.0.0.1",S=18392,f=18400,i="/callback";function N(s){return`http://${c}:${s}${i}`}var P="KANE CLI",B="*",O={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com"}},k={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444"};export{m as a,d as b,e as c,h as d,_ as e,A as f,L as g,n as h,x as i,u as j,U as k,R as l,I as m,E as n,C as o,T as p,c as q,S as r,f as s,i as t,N as u,P as v,B as w,O as x,k as y};
2
+ import{homedir as a}from"os";import{join as t}from"path";var m="0.8.1",d="kane-cli",e=t(a(),".testmuai","kaneai"),g=t(e,"profiles"),h=t(e,"tui-config.json"),_=t(e,"media"),A="https://registry.npmjs.org/@testmuai/kane-cli",L="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",b=`https://registry.npmjs.org/${n}`,r="kane-cli",x=[{dir:t(a(),".claude","skills",r),agent:"Claude Code"},{dir:t(a(),".agents","skills",r),agent:"Codex CLI"},{dir:t(a(),".gemini","skills",r),agent:"Gemini CLI"}],u="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",R=9222,I=9230,E=t(e,"chrome-profiles"),o=t(e,"hints"),C=t(o,"state.json");function T(s){return t(o,`catalog-${s}.json`)}var c="127.0.0.1",S=18392,f=18400,i="/callback";function N(s){return`http://${c}:${s}${i}`}var P="KANE CLI",B="*",O={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com"}},k={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444"};export{m as a,d as b,e as c,h as d,_ as e,A as f,L as g,n as h,x as i,u as j,U as k,R as l,I as m,E as n,C as o,T as p,c as q,S as r,f as s,i as t,N as u,P as v,B as w,O as x,k as y};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-FPFOW6BS.js";import{p as a}from"./chunk-W6VD2XFO.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-JRMDGLLT.js";import{a as h}from"./chunk-F6ZOJXYU.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
2
+ import{a as k}from"./chunk-OTTGS2TE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{p as a}from"./chunk-56PAQAX5.js";import{a as y}from"./chunk-G7VQCS4J.js";import{a as h}from"./chunk-6O3DDOP2.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
3
3
  `)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
4
- `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-NIDUOTRM.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
4
+ `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-4BPAPXKK.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
5
5
  `,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
6
6
  `,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
7
7
  `,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{c as h,d as $}from"./chunk-TYLYFERW.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{c as S}from"./chunk-27U4PLPX.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as C}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Me=["emulator","simulator"];function Q(e){return y(S,"mobile",`appium-server-${e}.log`)}function m(){return y(S,"mobile","appium-servers.json")}function Z(){return y(S,"mobile","appium-servers.lock")}var ee=1e4,re=50;function M(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;C(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);M(()=>{let o=[];for(let t of te())t.owner!==r&&(ve(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function ve(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function Se(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...Se(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(v=>v.deviceClass===e&&v!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
3
+ Run \`kane-cli doctor --install\` to install them, or pass --appium-url for an external server.`);let p=await n.freePort(X[e],z),O=`http://127.0.0.1:${p}`,J=l(d.appiumHome),U=y(J,"appium","node_modules","appium","index.js"),N=Q(e);r.onProgress?.(`starting the managed Appium server (${e}, port ${p})\u2026`);let f=n.spawn(n.nodeBinary,[U,"--port",String(p)],{env:{APPIUM_HOME:d.appiumHome,...we(d,n.env,n.os)},logPath:N}),B=n.now()+D,F=Math.ceil(D/T)+1;for(let a=0;a<F&&n.now()<B;a++)if(await n.sleep(T),await n.probe(`${O}/status`)){if(f!==void 0){let v=t.filter(H=>H.deviceClass!==e);await n.writeState([...v,{port:p,pid:f,owner:n.owner,deviceClass:e,...c?{bundleVersion:c}:{},startedAt:new Date(n.now()).toISOString()}])}return r.onProgress?.("Appium server ready"),{result:"started",url:O}}throw f!==void 0&&n.kill(f),new Error(`The managed Appium server (${e}) did not answer on ${p} within ${D/1e3}s.
4
+ Check its log: ${N}`)}async function ye(e,r=[],n=[],o){let t=new Set(n),i=new Set([...G,...r]);for(let s of i)if(!t.has(s))for(let c of await e.sessions(s)){if(!c.id)continue;if(o){let d=be(c.caps);if(d&&d!==o)continue}let u=De(c.caps);return{port:s,...u?{device:u}:{}}}return null}function be(e){let r=t=>{let i=e[t];return typeof i=="string"?i.toLowerCase():""},n=r("platformName")||r("appium:platformName");if(n.includes("ios"))return"simulator";if(n.includes("android"))return"emulator";let o=r("appium:automationName")||r("automationName");if(o.includes("xcuitest"))return"simulator";if(o.includes("uiautomator"))return"emulator"}var he=["appium:deviceName","deviceName","appium:udid","udid","appium:deviceUDID","deviceUDID"];function De(e){for(let r of he){let n=e[r];if(typeof n=="string"&&n.trim())return n}}function Ue(e={}){let r={...L(),kill:k,writeState:Ae,...e.deps};try{let n=r.readState(),o=e.owner??process.pid,t=n.filter(s=>s.owner===o&&(!e.deviceClass||s.deviceClass===e.deviceClass));for(let s of t){if(!r.alive(s.pid))continue;let c=R(r.getJson(`http://127.0.0.1:${s.port}/sessions`));for(let u of c)u.id&&r.del(`http://127.0.0.1:${s.port}/session/${u.id}`);r.kill(s.pid)}let i=new Set(t.map(s=>`${s.port}:${s.pid}`));M(()=>{r.writeState(r.readState().filter(s=>!i.has(`${s.port}:${s.pid}`)))})}catch{}}function Ae(e){try{let r=m();g(l(r),{recursive:!0}),C(r,JSON.stringify(e,null,2))}catch{}}export{Me as a,Q as b,se as c,Le as d,Se as e,Je as f,ye as g,Ue as h};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as ye,c as de,e as Pt}from"./chunk-UR6MHSHU.js";var rt=de((Wi,Rt)=>{"use strict";var Yr=ye("util"),Bt=ye("stream"),Ie=Rt.exports=function(){Bt.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};Yr.inherits(Ie,Bt);Ie.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}.bind(this))};Ie.prototype.write=function(e,t){if(!this.writable)return this.emit("error",new Error("Stream not writable")),!1;let r;return Buffer.isBuffer(e)?r=e:r=Buffer.from(e,t||this._encoding),this._buffers.push(r),this._buffered+=r.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused};Ie.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))};Ie.prototype.destroySoon=Ie.prototype.end;Ie.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("Unexpected end of input")),this.destroy()};Ie.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))};Ie.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))};Ie.prototype._processRead=function(e){this._reads.shift();let t=0,r=0,i=Buffer.alloc(e.length);for(;t<e.length;){let a=this._buffers[r++],n=Math.min(a.length,e.length-t);a.copy(i,t,0,n),t+=n,n!==a.length&&(this._buffers[--r]=a.slice(n))}r>0&&this._buffers.splice(0,r),this._buffered-=e.length,e.func.call(this,i)};Ie.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit("error",e)}}});var nt=de(it=>{"use strict";var Pe=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];it.getImagePasses=function(e,t){let r=[],i=e%8,a=t%8,n=(e-i)/8,s=(t-a)/8;for(let h=0;h<Pe.length;h++){let c=Pe[h],d=n*c.x.length,g=s*c.y.length;for(let y=0;y<c.x.length&&c.x[y]<i;y++)d++;for(let y=0;y<c.y.length&&c.y[y]<a;y++)g++;d>0&&g>0&&r.push({width:d,height:g,index:h})}return r};it.getInterlaceIterator=function(e){return function(t,r,i){let a=t%Pe[i].x.length,n=(t-a)/Pe[i].x.length*8+Pe[i].x[a],s=r%Pe[i].y.length,h=(r-s)/Pe[i].y.length*8+Pe[i].y[s];return n*4+h*e*4}}});var at=de((Zi,Mt)=>{"use strict";Mt.exports=function(t,r,i){let a=t+r-i,n=Math.abs(a-t),s=Math.abs(a-r),h=Math.abs(a-i);return n<=s&&n<=h?t:s<=h?r:i}});var st=de((Ji,Ut)=>{"use strict";var Hr=nt(),Dr=at();function St(e,t,r){let i=e*t;return r!==8&&(i=Math.ceil(i/(8/r))),i}var Ye=Ut.exports=function(e,t){let r=e.width,i=e.height,a=e.interlace,n=e.bpp,s=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],a){let h=Hr.getImagePasses(r,i);for(let c=0;c<h.length;c++)this._images.push({byteWidth:St(h[c].width,n,s),height:h[c].height,lineIndex:0})}else this._images.push({byteWidth:St(r,n,s),height:i,lineIndex:0});s===8?this._xComparison=n:s===16?this._xComparison=n*2:this._xComparison=1};Ye.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};Ye.prototype._unFilterType1=function(e,t,r){let i=this._xComparison,a=i-1;for(let n=0;n<r;n++){let s=e[1+n],h=n>a?t[n-i]:0;t[n]=s+h}};Ye.prototype._unFilterType2=function(e,t,r){let i=this._lastLine;for(let a=0;a<r;a++){let n=e[1+a],s=i?i[a]:0;t[a]=n+s}};Ye.prototype._unFilterType3=function(e,t,r){let i=this._xComparison,a=i-1,n=this._lastLine;for(let s=0;s<r;s++){let h=e[1+s],c=n?n[s]:0,d=s>a?t[s-i]:0,g=Math.floor((d+c)/2);t[s]=h+g}};Ye.prototype._unFilterType4=function(e,t,r){let i=this._xComparison,a=i-1,n=this._lastLine;for(let s=0;s<r;s++){let h=e[1+s],c=n?n[s]:0,d=s>a?t[s-i]:0,g=s>a&&n?n[s-i]:0,y=Dr(d,c,g);t[s]=h+y}};Ye.prototype._reverseFilterLine=function(e){let t=e[0],r,i=this._images[this._imageIndex],a=i.byteWidth;if(t===0)r=e.slice(1,a+1);else switch(r=Buffer.alloc(a),t){case 1:this._unFilterType1(e,r,a);break;case 2:this._unFilterType2(e,r,a);break;case 3:this._unFilterType3(e,r,a);break;case 4:this._unFilterType4(e,r,a);break;default:throw new Error("Unrecognised filter type - "+t)}this.write(r),i.lineIndex++,i.lineIndex>=i.height?(this._lastLine=null,this._imageIndex++,i=this._images[this._imageIndex]):this._lastLine=r,i?this.read(i.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}});var Dt=de((Ki,Ht)=>{"use strict";var qr=ye("util"),Yt=rt(),Nr=st(),Gr=Ht.exports=function(e){Yt.call(this);let t=[],r=this;this._filter=new Nr(e,{read:this.read.bind(this),write:function(i){t.push(i)},complete:function(){r.emit("complete",Buffer.concat(t))}}),this._filter.start()};qr.inherits(Gr,Yt)});var He=de(($i,qt)=>{"use strict";qt.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var ht=de((zi,Nt)=>{"use strict";var lt=[];(function(){for(let e=0;e<256;e++){let t=e;for(let r=0;r<8;r++)t&1?t=3988292384^t>>>1:t=t>>>1;lt[e]=t}})();var ot=Nt.exports=function(){this._crc=-1};ot.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=lt[(this._crc^e[t])&255]^this._crc>>>8;return!0};ot.prototype.crc32=function(){return this._crc^-1};ot.crc32=function(e){let t=-1;for(let r=0;r<e.length;r++)t=lt[(t^e[r])&255]^t>>>8;return t^-1}});var ft=de((en,Gt)=>{"use strict";var me=He(),Vr=ht(),we=Gt.exports=function(e,t){this._options=e,e.checkCRC=e.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[me.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[me.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[me.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[me.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[me.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[me.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};we.prototype.start=function(){this.read(me.PNG_SIGNATURE.length,this._parseSignature.bind(this))};we.prototype._parseSignature=function(e){let t=me.PNG_SIGNATURE;for(let r=0;r<t.length;r++)if(e[r]!==t[r]){this.error(new Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};we.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),r=e.readUInt32BE(4),i="";for(let n=4;n<8;n++)i+=String.fromCharCode(e[n]);let a=!!(e[4]&32);if(!this._hasIHDR&&r!==me.TYPE_IHDR){this.error(new Error("Expected IHDR on beggining"));return}if(this._crc=new Vr,this._crc.write(Buffer.from(i)),this._chunks[r])return this._chunks[r](t);if(!a){this.error(new Error("Unsupported critical chunk type "+i));return}this.read(t+4,this._skipChunk.bind(this))};we.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};we.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};we.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),r=this._crc.crc32();if(this._options.checkCRC&&r!==t){this.error(new Error("Crc error - "+t+" - "+r));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))};we.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))};we.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),r=e.readUInt32BE(4),i=e[8],a=e[9],n=e[10],s=e[11],h=e[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(new Error("Unsupported bit depth "+i));return}if(!(a in me.COLORTYPE_TO_BPP_MAP)){this.error(new Error("Unsupported color type"));return}if(n!==0){this.error(new Error("Unsupported compression method"));return}if(s!==0){this.error(new Error("Unsupported filter method"));return}if(h!==0&&h!==1){this.error(new Error("Unsupported interlace method"));return}this._colorType=a;let c=me.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:r,depth:i,interlace:!!h,palette:!!(a&me.COLORTYPE_PALETTE),color:!!(a&me.COLORTYPE_COLOR),alpha:!!(a&me.COLORTYPE_ALPHA),bpp:c,colorType:a}),this._handleChunkEnd()};we.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))};we.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let r=0;r<t;r++)this._palette.push([e[r*3],e[r*3+1],e[r*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};we.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))};we.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===me.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(new Error("Transparency chunk must be after palette"));return}if(e.length>this._palette.length){this.error(new Error("More transparent colors than palette size"));return}for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===me.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===me.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()};we.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))};we.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/me.GAMMA_DIVISION),this._handleChunkEnd()};we.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))};we.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===me.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw new Error("Expected palette not found");this.inflateData(t);let r=e-t.length;r>0?this._handleIDAT(r):this._handleChunkEnd()};we.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))};we.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}});var ut=de(Xt=>{"use strict";var Vt=nt(),Xr=[function(){},function(e,t,r,i){if(i===t.length)throw new Error("Ran out of data");let a=t[i];e[r]=a,e[r+1]=a,e[r+2]=a,e[r+3]=255},function(e,t,r,i){if(i+1>=t.length)throw new Error("Ran out of data");let a=t[i];e[r]=a,e[r+1]=a,e[r+2]=a,e[r+3]=t[i+1]},function(e,t,r,i){if(i+2>=t.length)throw new Error("Ran out of data");e[r]=t[i],e[r+1]=t[i+1],e[r+2]=t[i+2],e[r+3]=255},function(e,t,r,i){if(i+3>=t.length)throw new Error("Ran out of data");e[r]=t[i],e[r+1]=t[i+1],e[r+2]=t[i+2],e[r+3]=t[i+3]}],jr=[function(){},function(e,t,r,i){let a=t[0];e[r]=a,e[r+1]=a,e[r+2]=a,e[r+3]=i},function(e,t,r){let i=t[0];e[r]=i,e[r+1]=i,e[r+2]=i,e[r+3]=t[1]},function(e,t,r,i){e[r]=t[0],e[r+1]=t[1],e[r+2]=t[2],e[r+3]=i},function(e,t,r){e[r]=t[0],e[r+1]=t[1],e[r+2]=t[2],e[r+3]=t[3]}];function Wr(e,t){let r=[],i=0;function a(){if(i===e.length)throw new Error("Ran out of data");let n=e[i];i++;let s,h,c,d,g,y,C,$;switch(t){default:throw new Error("unrecognised depth");case 16:C=e[i],i++,r.push((n<<8)+C);break;case 4:C=n&15,$=n>>4,r.push($,C);break;case 2:g=n&3,y=n>>2&3,C=n>>4&3,$=n>>6&3,r.push($,C,y,g);break;case 1:s=n&1,h=n>>1&1,c=n>>2&1,d=n>>3&1,g=n>>4&1,y=n>>5&1,C=n>>6&1,$=n>>7&1,r.push($,C,y,g,d,c,h,s);break}}return{get:function(n){for(;r.length<n;)a();let s=r.slice(0,n);return r=r.slice(n),s},resetAfterLine:function(){r.length=0},end:function(){if(i!==e.length)throw new Error("extra data found")}}}function Qr(e,t,r,i,a,n){let s=e.width,h=e.height,c=e.index;for(let d=0;d<h;d++)for(let g=0;g<s;g++){let y=r(g,d,c);Xr[i](t,a,y,n),n+=i}return n}function Zr(e,t,r,i,a,n){let s=e.width,h=e.height,c=e.index;for(let d=0;d<h;d++){for(let g=0;g<s;g++){let y=a.get(i),C=r(g,d,c);jr[i](t,y,C,n)}a.resetAfterLine()}}Xt.dataToBitMap=function(e,t){let r=t.width,i=t.height,a=t.depth,n=t.bpp,s=t.interlace,h;a!==8&&(h=Wr(e,a));let c;a<=8?c=Buffer.alloc(r*i*4):c=new Uint16Array(r*i*4);let d=Math.pow(2,a)-1,g=0,y,C;if(s)y=Vt.getImagePasses(r,i),C=Vt.getInterlaceIterator(r,i);else{let $=0;C=function(){let S=$;return $+=4,S},y=[{width:r,height:i}]}for(let $=0;$<y.length;$++)a===8?g=Qr(y[$],c,C,n,e,g):Zr(y[$],c,C,n,h,d);if(a===8){if(g!==e.length)throw new Error("extra data found")}else h.end();return c}});var ct=de((rn,jt)=>{"use strict";function Jr(e,t,r,i,a){let n=0;for(let s=0;s<i;s++)for(let h=0;h<r;h++){let c=a[e[n]];if(!c)throw new Error("index "+e[n]+" not in palette");for(let d=0;d<4;d++)t[n+d]=c[d];n+=4}}function Kr(e,t,r,i,a){let n=0;for(let s=0;s<i;s++)for(let h=0;h<r;h++){let c=!1;if(a.length===1?a[0]===e[n]&&(c=!0):a[0]===e[n]&&a[1]===e[n+1]&&a[2]===e[n+2]&&(c=!0),c)for(let d=0;d<4;d++)t[n+d]=0;n+=4}}function $r(e,t,r,i,a){let n=255,s=Math.pow(2,a)-1,h=0;for(let c=0;c<i;c++)for(let d=0;d<r;d++){for(let g=0;g<4;g++)t[h+g]=Math.floor(e[h+g]*n/s+.5);h+=4}}jt.exports=function(e,t,r=!1){let i=t.depth,a=t.width,n=t.height,s=t.colorType,h=t.transColor,c=t.palette,d=e;return s===3?Jr(e,d,a,n,c):(h&&Kr(e,d,a,n,h),i!==8&&!r&&(i===16&&(d=Buffer.alloc(a*n*4)),$r(e,d,a,n,i))),d}});var Zt=de((nn,Qt)=>{"use strict";var zr=ye("util"),dt=ye("zlib"),Wt=rt(),ei=Dt(),ti=ft(),ri=ut(),ii=ct(),Oe=Qt.exports=function(e){Wt.call(this),this._parser=new ti(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};zr.inherits(Oe,Wt);Oe.prototype._handleError=function(e){this.emit("error",e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0};Oe.prototype._inflateData=function(e){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=dt.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let r=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,i=Math.max(r,dt.Z_MIN_CHUNK);this._inflate=dt.createInflate({chunkSize:i});let a=r,n=this.emit.bind(this,"error");this._inflate.on("error",function(h){a&&n(h)}),this._filter.on("complete",this._complete.bind(this));let s=this._filter.write.bind(this._filter);this._inflate.on("data",function(h){a&&(h.length>a&&(h=h.slice(0,a)),a-=h.length,s(h))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(e)};Oe.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new ei(this._bitmapInfo)};Oe.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e};Oe.prototype._handlePalette=function(e){this._bitmapInfo.palette=e};Oe.prototype._simpleTransparency=function(){this._metaData.alpha=!0};Oe.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};Oe.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))};Oe.prototype._complete=function(e){if(this.errord)return;let t;try{let r=ri.dataToBitMap(e,this._bitmapInfo);t=ii(r,this._bitmapInfo,this._options.skipRescale),r=null}catch(r){this._handleError(r);return}this.emit("parsed",t)}});var Kt=de((an,Jt)=>{"use strict";var ke=He();Jt.exports=function(e,t,r,i){let a=[ke.COLORTYPE_COLOR_ALPHA,ke.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let S=(function(){let z=new ArrayBuffer(2);return new DataView(z).setInt16(0,256,!0),new Int16Array(z)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&S)return e}let n=i.bitDepth!==16?e:new Uint16Array(e.buffer),s=255,h=ke.COLORTYPE_TO_BPP_MAP[i.inputColorType];h===4&&!i.inputHasAlpha&&(h=3);let c=ke.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(s=65535,c*=2);let d=Buffer.alloc(t*r*c),g=0,y=0,C=i.bgColor||{};C.red===void 0&&(C.red=s),C.green===void 0&&(C.green=s),C.blue===void 0&&(C.blue=s);function $(){let S,z,P,G=s;switch(i.inputColorType){case ke.COLORTYPE_COLOR_ALPHA:G=n[g+3],S=n[g],z=n[g+1],P=n[g+2];break;case ke.COLORTYPE_COLOR:S=n[g],z=n[g+1],P=n[g+2];break;case ke.COLORTYPE_ALPHA:G=n[g+1],S=n[g],z=S,P=S;break;case ke.COLORTYPE_GRAYSCALE:S=n[g],z=S,P=S;break;default:throw new Error("input color type:"+i.inputColorType+" is not supported at present")}return i.inputHasAlpha&&(a||(G/=s,S=Math.min(Math.max(Math.round((1-G)*C.red+G*S),0),s),z=Math.min(Math.max(Math.round((1-G)*C.green+G*z),0),s),P=Math.min(Math.max(Math.round((1-G)*C.blue+G*P),0),s))),{red:S,green:z,blue:P,alpha:G}}for(let S=0;S<r;S++)for(let z=0;z<t;z++){let P=$(n,g);switch(i.colorType){case ke.COLORTYPE_COLOR_ALPHA:case ke.COLORTYPE_COLOR:i.bitDepth===8?(d[y]=P.red,d[y+1]=P.green,d[y+2]=P.blue,a&&(d[y+3]=P.alpha)):(d.writeUInt16BE(P.red,y),d.writeUInt16BE(P.green,y+2),d.writeUInt16BE(P.blue,y+4),a&&d.writeUInt16BE(P.alpha,y+6));break;case ke.COLORTYPE_ALPHA:case ke.COLORTYPE_GRAYSCALE:{let G=(P.red+P.green+P.blue)/3;i.bitDepth===8?(d[y]=G,a&&(d[y+1]=P.alpha)):(d.writeUInt16BE(G,y),a&&d.writeUInt16BE(P.alpha,y+2));break}default:throw new Error("unrecognised color Type "+i.colorType)}g+=h,y+=c}return d}});var er=de((sn,zt)=>{"use strict";var $t=at();function ni(e,t,r,i,a){for(let n=0;n<r;n++)i[a+n]=e[t+n]}function ai(e,t,r){let i=0,a=t+r;for(let n=t;n<a;n++)i+=Math.abs(e[n]);return i}function si(e,t,r,i,a,n){for(let s=0;s<r;s++){let h=s>=n?e[t+s-n]:0,c=e[t+s]-h;i[a+s]=c}}function li(e,t,r,i){let a=0;for(let n=0;n<r;n++){let s=n>=i?e[t+n-i]:0,h=e[t+n]-s;a+=Math.abs(h)}return a}function oi(e,t,r,i,a){for(let n=0;n<r;n++){let s=t>0?e[t+n-r]:0,h=e[t+n]-s;i[a+n]=h}}function hi(e,t,r){let i=0,a=t+r;for(let n=t;n<a;n++){let s=t>0?e[n-r]:0,h=e[n]-s;i+=Math.abs(h)}return i}function fi(e,t,r,i,a,n){for(let s=0;s<r;s++){let h=s>=n?e[t+s-n]:0,c=t>0?e[t+s-r]:0,d=e[t+s]-(h+c>>1);i[a+s]=d}}function ui(e,t,r,i){let a=0;for(let n=0;n<r;n++){let s=n>=i?e[t+n-i]:0,h=t>0?e[t+n-r]:0,c=e[t+n]-(s+h>>1);a+=Math.abs(c)}return a}function ci(e,t,r,i,a,n){for(let s=0;s<r;s++){let h=s>=n?e[t+s-n]:0,c=t>0?e[t+s-r]:0,d=t>0&&s>=n?e[t+s-(r+n)]:0,g=e[t+s]-$t(h,c,d);i[a+s]=g}}function di(e,t,r,i){let a=0;for(let n=0;n<r;n++){let s=n>=i?e[t+n-i]:0,h=t>0?e[t+n-r]:0,c=t>0&&n>=i?e[t+n-(r+i)]:0,d=e[t+n]-$t(s,h,c);a+=Math.abs(d)}return a}var xi={0:ni,1:si,2:oi,3:fi,4:ci},_i={0:ai,1:li,2:hi,3:ui,4:di};zt.exports=function(e,t,r,i,a){let n;if(!("filterType"in i)||i.filterType===-1)n=[0,1,2,3,4];else if(typeof i.filterType=="number")n=[i.filterType];else throw new Error("unrecognised filter types");i.bitDepth===16&&(a*=2);let s=t*a,h=0,c=0,d=Buffer.alloc((s+1)*r),g=n[0];for(let y=0;y<r;y++){if(n.length>1){let C=1/0;for(let $=0;$<n.length;$++){let S=_i[n[$]](e,c,s,a);S<C&&(g=n[$],C=S)}}d[h]=g,h++,xi[g](e,c,s,d,h,a),h+=s,c+=s}return d}});var xt=de((ln,tr)=>{"use strict";var Ee=He(),pi=ht(),vi=Kt(),gi=er(),mi=ye("zlib"),Be=tr.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32*1024,e.deflateLevel=e.deflateLevel!=null?e.deflateLevel:9,e.deflateStrategy=e.deflateStrategy!=null?e.deflateStrategy:3,e.inputHasAlpha=e.inputHasAlpha!=null?e.inputHasAlpha:!0,e.deflateFactory=e.deflateFactory||mi.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType=typeof e.colorType=="number"?e.colorType:Ee.COLORTYPE_COLOR_ALPHA,e.inputColorType=typeof e.inputColorType=="number"?e.inputColorType:Ee.COLORTYPE_COLOR_ALPHA,[Ee.COLORTYPE_GRAYSCALE,Ee.COLORTYPE_COLOR,Ee.COLORTYPE_COLOR_ALPHA,Ee.COLORTYPE_ALPHA].indexOf(e.colorType)===-1)throw new Error("option color type:"+e.colorType+" is not supported at present");if([Ee.COLORTYPE_GRAYSCALE,Ee.COLORTYPE_COLOR,Ee.COLORTYPE_COLOR_ALPHA,Ee.COLORTYPE_ALPHA].indexOf(e.inputColorType)===-1)throw new Error("option input color type:"+e.inputColorType+" is not supported at present");if(e.bitDepth!==8&&e.bitDepth!==16)throw new Error("option bit depth:"+e.bitDepth+" is not supported at present")};Be.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};Be.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};Be.prototype.filterData=function(e,t,r){let i=vi(e,t,r,this._options),a=Ee.COLORTYPE_TO_BPP_MAP[this._options.colorType];return gi(i,t,r,this._options,a)};Be.prototype._packChunk=function(e,t){let r=t?t.length:0,i=Buffer.alloc(r+12);return i.writeUInt32BE(r,0),i.writeUInt32BE(e,4),t&&t.copy(i,8),i.writeInt32BE(pi.crc32(i.slice(4,i.length-4)),i.length-4),i};Be.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*Ee.GAMMA_DIVISION),0),this._packChunk(Ee.TYPE_gAMA,t)};Be.prototype.packIHDR=function(e,t){let r=Buffer.alloc(13);return r.writeUInt32BE(e,0),r.writeUInt32BE(t,4),r[8]=this._options.bitDepth,r[9]=this._options.colorType,r[10]=0,r[11]=0,r[12]=0,this._packChunk(Ee.TYPE_IHDR,r)};Be.prototype.packIDAT=function(e){return this._packChunk(Ee.TYPE_IDAT,e)};Be.prototype.packIEND=function(){return this._packChunk(Ee.TYPE_IEND,null)}});var ar=de((on,nr)=>{"use strict";var wi=ye("util"),rr=ye("stream"),bi=He(),yi=xt(),ir=nr.exports=function(e){rr.call(this);let t=e||{};this._packer=new yi(t),this._deflate=this._packer.createDeflate(),this.readable=!0};wi.inherits(ir,rr);ir.prototype.pack=function(e,t,r,i){this.emit("data",Buffer.from(bi.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(t,r)),i&&this.emit("data",this._packer.packGAMA(i));let a=this._packer.filterData(e,t,r);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(n){this.emit("data",this._packer.packIDAT(n))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(a)}});var ur=de((Qe,fr)=>{"use strict";var sr=ye("assert").ok,De=ye("zlib"),Ei=ye("util"),lr=ye("buffer").kMaxLength;function Me(e){if(!(this instanceof Me))return new Me(e);e&&e.chunkSize<De.Z_MIN_CHUNK&&(e.chunkSize=De.Z_MIN_CHUNK),De.Inflate.call(this,e),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&e.maxLength!=null&&(this._maxLength=e.maxLength)}function Ti(e){return new Me(e)}function or(e,t){t&&process.nextTick(t),e._handle&&(e._handle.close(),e._handle=null)}Me.prototype._processChunk=function(e,t,r){if(typeof r=="function")return De.Inflate._processChunk.call(this,e,t,r);let i=this,a=e&&e.length,n=this._chunkSize-this._offset,s=this._maxLength,h=0,c=[],d=0,g;this.on("error",function(S){g=S});function y(S,z){if(i._hadError)return;let P=n-z;if(sr(P>=0,"have should not go down"),P>0){let G=i._buffer.slice(i._offset,i._offset+P);if(i._offset+=P,G.length>s&&(G=G.slice(0,s)),c.push(G),d+=G.length,s-=G.length,s===0)return!1}return(z===0||i._offset>=i._chunkSize)&&(n=i._chunkSize,i._offset=0,i._buffer=Buffer.allocUnsafe(i._chunkSize)),z===0?(h+=a-S,a=S,!0):!1}sr(this._handle,"zlib binding closed");let C;do C=this._handle.writeSync(t,e,h,a,this._buffer,this._offset,n),C=C||this._writeState;while(!this._hadError&&y(C[0],C[1]));if(this._hadError)throw g;if(d>=lr)throw or(this),new RangeError("Cannot create final Buffer. It would be larger than 0x"+lr.toString(16)+" bytes");let $=Buffer.concat(c,d);return or(this),$};Ei.inherits(Me,De.Inflate);function Ci(e,t){if(typeof t=="string"&&(t=Buffer.from(t)),!(t instanceof Buffer))throw new TypeError("Not a string or buffer");let r=e._finishFlushFlag;return r==null&&(r=De.Z_FINISH),e._processChunk(t,r)}function hr(e,t){return Ci(new Me(t),e)}fr.exports=Qe=hr;Qe.Inflate=Me;Qe.createInflate=Ti;Qe.inflateSync=hr});var _t=de((hn,dr)=>{"use strict";var cr=dr.exports=function(e){this._buffer=e,this._reads=[]};cr.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})};cr.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}if(this._reads.length>0)throw new Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw new Error("unrecognised content at end of stream")}});var _r=de(xr=>{"use strict";var Ai=_t(),ki=st();xr.process=function(e,t){let r=[],i=new Ai(e);return new ki(t,{read:i.read.bind(i),write:function(n){r.push(n)},complete:function(){}}).start(),i.process(),Buffer.concat(r)}});var mr=de((un,gr)=>{"use strict";var pr=!0,vr=ye("zlib"),Fi=ur();vr.deflateSync||(pr=!1);var Ii=_t(),Li=_r(),Oi=ft(),Pi=ut(),Bi=ct();gr.exports=function(e,t){if(!pr)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r;function i(w){r=w}let a;function n(w){a=w}function s(w){a.transColor=w}function h(w){a.palette=w}function c(){a.alpha=!0}let d;function g(w){d=w}let y=[];function C(w){y.push(w)}let $=new Ii(e);if(new Oi(t,{read:$.read.bind($),error:i,metadata:n,gamma:g,palette:h,transColor:s,inflateData:C,simpleTransparency:c}).start(),$.process(),r)throw r;let z=Buffer.concat(y);y.length=0;let P;if(a.interlace)P=vr.inflateSync(z);else{let f=((a.width*a.bpp*a.depth+7>>3)+1)*a.height;P=Fi(z,{chunkSize:f,maxLength:f})}if(z=null,!P||!P.length)throw new Error("bad png - invalid inflate data response");let G=Li.process(P,a);z=null;let Q=Pi.dataToBitMap(G,a);G=null;let p=Bi(Q,a,t.skipRescale);return a.data=p,a.gamma=d||0,a}});var Er=de((cn,yr)=>{"use strict";var wr=!0,br=ye("zlib");br.deflateSync||(wr=!1);var Ri=He(),Mi=xt();yr.exports=function(e,t){if(!wr)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let r=t||{},i=new Mi(r),a=[];a.push(Buffer.from(Ri.PNG_SIGNATURE)),a.push(i.packIHDR(e.width,e.height)),e.gamma&&a.push(i.packGAMA(e.gamma));let n=i.filterData(e.data,e.width,e.height),s=br.deflateSync(n,i.getDeflateOptions());if(n=null,!s||!s.length)throw new Error("bad png - invalid compressed data response");return a.push(i.packIDAT(s)),a.push(i.packIEND()),Buffer.concat(a)}});var Tr=de(pt=>{"use strict";var Si=mr(),Ui=Er();pt.read=function(e,t){return Si(e,t||{})};pt.write=function(e,t){return Ui(e,t)}});var kr=de(Ar=>{"use strict";var Yi=ye("util"),Cr=ye("stream"),Hi=Zt(),Di=ar(),qi=Tr(),Te=Ar.PNG=function(e){Cr.call(this),e=e||{},this.width=e.width|0,this.height=e.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new Hi(e),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(t){this.data=t,this.emit("parsed",t)}.bind(this)),this._packer=new Di(e),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};Yi.inherits(Te,Cr);Te.sync=qi;Te.prototype.pack=function(){return!this.data||!this.data.length?(this.emit("error","No data provided"),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)};Te.prototype.parse=function(e,t){if(t){let r,i;r=function(a){this.removeListener("error",i),this.data=a,t(null,this)}.bind(this),i=function(a){this.removeListener("parsed",r),t(a,null)}.bind(this),this.once("parsed",r),this.once("error",i)}return this.end(e),this};Te.prototype.write=function(e){return this._parser.write(e),!0};Te.prototype.end=function(e){this._parser.end(e)};Te.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit("metadata",e)};Te.prototype._gamma=function(e){this.gamma=e};Te.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit("close")};Te.bitblt=function(e,t,r,i,a,n,s,h){if(r|=0,i|=0,a|=0,n|=0,s|=0,h|=0,r>e.width||i>e.height||r+a>e.width||i+n>e.height)throw new Error("bitblt reading outside image");if(s>t.width||h>t.height||s+a>t.width||h+n>t.height)throw new Error("bitblt writing outside image");for(let c=0;c<n;c++)e.data.copy(t.data,(h+c)*t.width+s<<2,(i+c)*e.width+r<<2,(i+c)*e.width+r+a<<2)};Te.prototype.bitblt=function(e,t,r,i,a,n,s){return Te.bitblt(this,e,t,r,i,a,n,s),this};Te.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let r=0;r<e.width;r++){let i=e.width*t+r<<2;for(let a=0;a<3;a++){let n=e.data[i+a]/255;n=Math.pow(n,1/2.2/e.gamma),e.data[i+a]=Math.round(n*255)}}e.gamma=0}};Te.prototype.adjustGamma=function(){Te.adjustGamma(this)}});var Lr=de((_n,ze)=>{"use strict";var Ir=Ir||function(e){return Buffer.from(e).toString("base64")};function Ni(e){var t=this,r=Math.round,i=Math.floor,a=new Array(64),n=new Array(64),s=new Array(64),h=new Array(64),c,d,g,y,C=new Array(65535),$=new Array(65535),S=new Array(64),z=new Array(64),P=[],G=0,Q=7,p=new Array(64),w=new Array(64),f=new Array(64),ee=new Array(256),x=new Array(2048),H,A=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],R=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],V=[0,1,2,3,4,5,6,7,8,9,10,11],ae=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],k=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],ve=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],F=[0,1,2,3,4,5,6,7,8,9,10,11],X=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],xe=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function he(l){for(var b=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],I=0;I<64;I++){var T=i((b[I]*l+50)/100);T<1?T=1:T>255&&(T=255),a[A[I]]=T}for(var M=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],U=0;U<64;U++){var te=i((M[U]*l+50)/100);te<1?te=1:te>255&&(te=255),n[A[U]]=te}for(var re=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],pe=0,ue=0;ue<8;ue++)for(var u=0;u<8;u++)s[pe]=1/(a[A[pe]]*re[ue]*re[u]*8),h[pe]=1/(n[A[pe]]*re[ue]*re[u]*8),pe++}function j(l,b){for(var I=0,T=0,M=new Array,U=1;U<=16;U++){for(var te=1;te<=l[U];te++)M[b[T]]=[],M[b[T]][0]=I,M[b[T]][1]=U,T++,I++;I*=2}return M}function ge(){c=j(R,V),d=j(ve,F),g=j(ae,k),y=j(X,xe)}function ie(){for(var l=1,b=2,I=1;I<=15;I++){for(var T=l;T<b;T++)$[32767+T]=I,C[32767+T]=[],C[32767+T][1]=I,C[32767+T][0]=T;for(var M=-(b-1);M<=-l;M++)$[32767+M]=I,C[32767+M]=[],C[32767+M][1]=I,C[32767+M][0]=b-1+M;l<<=1,b<<=1}}function Z(){for(var l=0;l<256;l++)x[l]=19595*l,x[l+256>>0]=38470*l,x[l+512>>0]=7471*l+32768,x[l+768>>0]=-11059*l,x[l+1024>>0]=-21709*l,x[l+1280>>0]=32768*l+8421375,x[l+1536>>0]=-27439*l,x[l+1792>>0]=-5329*l}function D(l){for(var b=l[0],I=l[1]-1;I>=0;)b&1<<I&&(G|=1<<Q),I--,Q--,Q<0&&(G==255?(o(255),o(0)):o(G),Q=7,G=0)}function o(l){P.push(l)}function E(l){o(l>>8&255),o(l&255)}function se(l,b){var I,T,M,U,te,re,pe,ue,u=0,m,B=8,_e=64;for(m=0;m<B;++m){I=l[u],T=l[u+1],M=l[u+2],U=l[u+3],te=l[u+4],re=l[u+5],pe=l[u+6],ue=l[u+7];var Y=I+ue,W=I-ue,oe=T+pe,L=T-pe,ne=M+re,be=M-re,ce=U+te,Ae=U-te,Le=Y+ce,Re=Y-ce,Se=oe+ne,Ue=oe-ne;l[u]=Le+Se,l[u+4]=Le-Se;var qe=(Ue+Re)*.707106781;l[u+2]=Re+qe,l[u+6]=Re-qe,Le=Ae+be,Se=be+L,Ue=L+W;var Ne=(Le-Ue)*.382683433,Ze=.5411961*Le+Ne,Ge=1.306562965*Ue+Ne,Ve=Se*.707106781,Xe=W+Ve,je=W-Ve;l[u+5]=je+Ze,l[u+3]=je-Ze,l[u+1]=Xe+Ge,l[u+7]=Xe-Ge,u+=8}for(u=0,m=0;m<B;++m){I=l[u],T=l[u+8],M=l[u+16],U=l[u+24],te=l[u+32],re=l[u+40],pe=l[u+48],ue=l[u+56];var mt=I+ue,et=I-ue,wt=T+pe,bt=T-pe,yt=M+re,Et=M-re,Tt=U+te,Ur=U-te,We=mt+Tt,tt=mt-Tt,Je=wt+yt,Ke=wt-yt;l[u]=We+Je,l[u+32]=We-Je;var Ct=(Ke+tt)*.707106781;l[u+16]=tt+Ct,l[u+48]=tt-Ct,We=Ur+Et,Je=Et+bt,Ke=bt+et;var At=(We-Ke)*.382683433,kt=.5411961*We+At,Ft=1.306562965*Ke+At,It=Je*.707106781,Lt=et+It,Ot=et-It;l[u+40]=Ot+kt,l[u+24]=Ot-kt,l[u+8]=Lt+Ft,l[u+56]=Lt-Ft,u++}var $e;for(m=0;m<_e;++m)$e=l[m]*b[m],S[m]=$e>0?$e+.5|0:$e-.5|0;return S}function le(){E(65504),E(16),o(74),o(70),o(73),o(70),o(0),o(1),o(1),o(0),E(1),E(1),o(0),o(0)}function J(l){if(l){E(65505),l[0]===69&&l[1]===120&&l[2]===105&&l[3]===102?E(l.length+2):(E(l.length+5+2),o(69),o(120),o(105),o(102),o(0));for(var b=0;b<l.length;b++)o(l[b])}}function K(l,b){E(65472),E(17),o(8),E(b),E(l),o(3),o(1),o(17),o(0),o(2),o(17),o(1),o(3),o(17),o(1)}function q(){E(65499),E(132),o(0);for(var l=0;l<64;l++)o(a[l]);o(1);for(var b=0;b<64;b++)o(n[b])}function v(){E(65476),E(418),o(0);for(var l=0;l<16;l++)o(R[l+1]);for(var b=0;b<=11;b++)o(V[b]);o(16);for(var I=0;I<16;I++)o(ae[I+1]);for(var T=0;T<=161;T++)o(k[T]);o(1);for(var M=0;M<16;M++)o(ve[M+1]);for(var U=0;U<=11;U++)o(F[U]);o(17);for(var te=0;te<16;te++)o(X[te+1]);for(var re=0;re<=161;re++)o(xe[re])}function _(l){typeof l>"u"||l.constructor!==Array||l.forEach(b=>{if(typeof b=="string"){E(65534);var I=b.length;E(I+2);var T;for(T=0;T<I;T++)o(b.charCodeAt(T))}})}function fe(){E(65498),E(12),o(3),o(1),o(0),o(2),o(17),o(3),o(17),o(0),o(63),o(0)}function O(l,b,I,T,M){for(var U=M[0],te=M[240],re,pe=16,ue=63,u=64,m=se(l,b),B=0;B<u;++B)z[A[B]]=m[B];var _e=z[0]-I;I=z[0],_e==0?D(T[0]):(re=32767+_e,D(T[$[re]]),D(C[re]));for(var Y=63;Y>0&&z[Y]==0;Y--);if(Y==0)return D(U),I;for(var W=1,oe;W<=Y;){for(var L=W;z[W]==0&&W<=Y;++W);var ne=W-L;if(ne>=pe){oe=ne>>4;for(var be=1;be<=oe;++be)D(te);ne=ne&15}re=32767+z[W],D(M[(ne<<4)+$[re]]),D(C[re]),W++}return Y!=ue&&D(U),I}function N(){for(var l=String.fromCharCode,b=0;b<256;b++)ee[b]=l(b)}this.encode=function(l,b){var I=new Date().getTime();b&&Ce(b),P=new Array,G=0,Q=7,E(65496),le(),_(l.comments),J(l.exifBuffer),q(),K(l.width,l.height),v(),fe();var T=0,M=0,U=0;G=0,Q=7,this.encode.displayName="_encode_";for(var te=l.data,re=l.width,pe=l.height,ue=re*4,u=re*3,m,B=0,_e,Y,W,oe,L,ne,be,ce;B<pe;){for(m=0;m<ue;){for(oe=ue*B+m,L=oe,ne=-1,be=0,ce=0;ce<64;ce++)be=ce>>3,ne=(ce&7)*4,L=oe+be*ue+ne,B+be>=pe&&(L-=ue*(B+1+be-pe)),m+ne>=ue&&(L-=m+ne-ue+4),_e=te[L++],Y=te[L++],W=te[L++],p[ce]=(x[_e]+x[Y+256>>0]+x[W+512>>0]>>16)-128,w[ce]=(x[_e+768>>0]+x[Y+1024>>0]+x[W+1280>>0]>>16)-128,f[ce]=(x[_e+1280>>0]+x[Y+1536>>0]+x[W+1792>>0]>>16)-128;T=O(p,s,T,c,g),M=O(w,h,M,d,y),U=O(f,h,U,d,y),m+=32}B+=8}if(Q>=0){var Ae=[];Ae[1]=Q+1,Ae[0]=(1<<Q+1)-1,D(Ae)}if(E(65497),typeof ze>"u")return new Uint8Array(P);return Buffer.from(P);var Le,Re};function Ce(l){if(l<=0&&(l=1),l>100&&(l=100),H!=l){var b=0;l<50?b=Math.floor(5e3/l):b=Math.floor(200-l*2),he(b),H=l}}function Fe(){var l=new Date().getTime();e||(e=50),N(),ge(),ie(),Z(),Ce(e);var b=new Date().getTime()-l}Fe()}typeof ze<"u"?ze.exports=Fr:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].encode=Fr);function Fr(e,t){typeof t>"u"&&(t=50);var r=new Ni(t),i=r.encode(e,t);return{data:i,width:e.width,height:e.height}}});var Pr=de((pn,gt)=>{"use strict";var vt=(function(){"use strict";var t=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),r=4017,i=799,a=3406,n=2276,s=1567,h=3784,c=5793,d=2896;function g(){}function y(Q,p){for(var w=0,f=[],ee,x,H=16;H>0&&!Q[H-1];)H--;f.push({children:[],index:0});var A=f[0],R;for(ee=0;ee<H;ee++){for(x=0;x<Q[ee];x++){for(A=f.pop(),A.children[A.index]=p[w];A.index>0;){if(f.length===0)throw new Error("Could not recreate Huffman Table");A=f.pop()}for(A.index++,f.push(A);f.length<=ee;)f.push(R={children:[],index:0}),A.children[A.index]=R.children,A=R;w++}ee+1<H&&(f.push(R={children:[],index:0}),A.children[A.index]=R.children,A=R)}return f[0].children}function C(Q,p,w,f,ee,x,H,A,R,V){var ae=w.precision,k=w.samplesPerLine,ve=w.scanLines,F=w.mcusPerLine,X=w.progressive,xe=w.maxH,he=w.maxV,j=p,ge=0,ie=0;function Z(){if(ie>0)return ie--,ge>>ie&1;if(ge=Q[p++],ge==255){var u=Q[p++];if(u)throw new Error("unexpected marker: "+(ge<<8|u).toString(16))}return ie=7,ge>>>7}function D(u){for(var m=u,B;(B=Z())!==null;){if(m=m[B],typeof m=="number")return m;if(typeof m!="object")throw new Error("invalid huffman sequence")}return null}function o(u){for(var m=0;u>0;){var B=Z();if(B===null)return;m=m<<1|B,u--}return m}function E(u){var m=o(u);return m>=1<<u-1?m:m+(-1<<u)+1}function se(u,m){var B=D(u.huffmanTableDC),_e=B===0?0:E(B);m[0]=u.pred+=_e;for(var Y=1;Y<64;){var W=D(u.huffmanTableAC),oe=W&15,L=W>>4;if(oe===0){if(L<15)break;Y+=16;continue}Y+=L;var ne=t[Y];m[ne]=E(oe),Y++}}function le(u,m){var B=D(u.huffmanTableDC),_e=B===0?0:E(B)<<R;m[0]=u.pred+=_e}function J(u,m){m[0]|=Z()<<R}var K=0;function q(u,m){if(K>0){K--;return}for(var B=x,_e=H;B<=_e;){var Y=D(u.huffmanTableAC),W=Y&15,oe=Y>>4;if(W===0){if(oe<15){K=o(oe)+(1<<oe)-1;break}B+=16;continue}B+=oe;var L=t[B];m[L]=E(W)*(1<<R),B++}}var v=0,_;function fe(u,m){for(var B=x,_e=H,Y=0;B<=_e;){var W=t[B],oe=m[W]<0?-1:1;switch(v){case 0:var L=D(u.huffmanTableAC),ne=L&15,Y=L>>4;if(ne===0)Y<15?(K=o(Y)+(1<<Y),v=4):(Y=16,v=1);else{if(ne!==1)throw new Error("invalid ACn encoding");_=E(ne),v=Y?2:3}continue;case 1:case 2:m[W]?m[W]+=(Z()<<R)*oe:(Y--,Y===0&&(v=v==2?3:0));break;case 3:m[W]?m[W]+=(Z()<<R)*oe:(m[W]=_<<R,v=0);break;case 4:m[W]&&(m[W]+=(Z()<<R)*oe);break}B++}v===4&&(K--,K===0&&(v=0))}function O(u,m,B,_e,Y){var W=B/F|0,oe=B%F,L=W*u.v+_e,ne=oe*u.h+Y;u.blocks[L]===void 0&&V.tolerantDecoding||m(u,u.blocks[L][ne])}function N(u,m,B){var _e=B/u.blocksPerLine|0,Y=B%u.blocksPerLine;u.blocks[_e]===void 0&&V.tolerantDecoding||m(u,u.blocks[_e][Y])}var Ce=f.length,Fe,l,b,I,T,M;X?x===0?M=A===0?le:J:M=A===0?q:fe:M=se;var U=0,te,re;Ce==1?re=f[0].blocksPerLine*f[0].blocksPerColumn:re=F*w.mcusPerColumn,ee||(ee=re);for(var pe,ue;U<re;){for(l=0;l<Ce;l++)f[l].pred=0;if(K=0,Ce==1)for(Fe=f[0],T=0;T<ee;T++)N(Fe,M,U),U++;else for(T=0;T<ee;T++){for(l=0;l<Ce;l++)for(Fe=f[l],pe=Fe.h,ue=Fe.v,b=0;b<ue;b++)for(I=0;I<pe;I++)O(Fe,M,U,b,I);if(U++,U===re)break}if(U===re)do{if(Q[p]===255&&Q[p+1]!==0)break;p+=1}while(p<Q.length-2);if(ie=0,te=Q[p]<<8|Q[p+1],te<65280)throw new Error("marker was not found");if(te>=65488&&te<=65495)p+=2;else break}return p-j}function $(Q,p){var w=[],f=p.blocksPerLine,ee=p.blocksPerColumn,x=f<<3,H=new Int32Array(64),A=new Uint8Array(64);function R(j,ge,ie){var Z=p.quantizationTable,D,o,E,se,le,J,K,q,v,_=ie,fe;for(fe=0;fe<64;fe++)_[fe]=j[fe]*Z[fe];for(fe=0;fe<8;++fe){var O=8*fe;if(_[1+O]==0&&_[2+O]==0&&_[3+O]==0&&_[4+O]==0&&_[5+O]==0&&_[6+O]==0&&_[7+O]==0){v=c*_[0+O]+512>>10,_[0+O]=v,_[1+O]=v,_[2+O]=v,_[3+O]=v,_[4+O]=v,_[5+O]=v,_[6+O]=v,_[7+O]=v;continue}D=c*_[0+O]+128>>8,o=c*_[4+O]+128>>8,E=_[2+O],se=_[6+O],le=d*(_[1+O]-_[7+O])+128>>8,q=d*(_[1+O]+_[7+O])+128>>8,J=_[3+O]<<4,K=_[5+O]<<4,v=D-o+1>>1,D=D+o+1>>1,o=v,v=E*h+se*s+128>>8,E=E*s-se*h+128>>8,se=v,v=le-K+1>>1,le=le+K+1>>1,K=v,v=q+J+1>>1,J=q-J+1>>1,q=v,v=D-se+1>>1,D=D+se+1>>1,se=v,v=o-E+1>>1,o=o+E+1>>1,E=v,v=le*n+q*a+2048>>12,le=le*a-q*n+2048>>12,q=v,v=J*i+K*r+2048>>12,J=J*r-K*i+2048>>12,K=v,_[0+O]=D+q,_[7+O]=D-q,_[1+O]=o+K,_[6+O]=o-K,_[2+O]=E+J,_[5+O]=E-J,_[3+O]=se+le,_[4+O]=se-le}for(fe=0;fe<8;++fe){var N=fe;if(_[8+N]==0&&_[16+N]==0&&_[24+N]==0&&_[32+N]==0&&_[40+N]==0&&_[48+N]==0&&_[56+N]==0){v=c*ie[fe+0]+8192>>14,_[0+N]=v,_[8+N]=v,_[16+N]=v,_[24+N]=v,_[32+N]=v,_[40+N]=v,_[48+N]=v,_[56+N]=v;continue}D=c*_[0+N]+2048>>12,o=c*_[32+N]+2048>>12,E=_[16+N],se=_[48+N],le=d*(_[8+N]-_[56+N])+2048>>12,q=d*(_[8+N]+_[56+N])+2048>>12,J=_[24+N],K=_[40+N],v=D-o+1>>1,D=D+o+1>>1,o=v,v=E*h+se*s+2048>>12,E=E*s-se*h+2048>>12,se=v,v=le-K+1>>1,le=le+K+1>>1,K=v,v=q+J+1>>1,J=q-J+1>>1,q=v,v=D-se+1>>1,D=D+se+1>>1,se=v,v=o-E+1>>1,o=o+E+1>>1,E=v,v=le*n+q*a+2048>>12,le=le*a-q*n+2048>>12,q=v,v=J*i+K*r+2048>>12,J=J*r-K*i+2048>>12,K=v,_[0+N]=D+q,_[56+N]=D-q,_[8+N]=o+K,_[48+N]=o-K,_[16+N]=E+J,_[40+N]=E-J,_[24+N]=se+le,_[32+N]=se-le}for(fe=0;fe<64;++fe){var Ce=128+(_[fe]+8>>4);ge[fe]=Ce<0?0:Ce>255?255:Ce}}G(x*ee*8);for(var V,ae,k=0;k<ee;k++){var ve=k<<3;for(V=0;V<8;V++)w.push(new Uint8Array(x));for(var F=0;F<f;F++){R(p.blocks[k][F],A,H);var X=0,xe=F<<3;for(ae=0;ae<8;ae++){var he=w[ve+ae];for(V=0;V<8;V++)he[xe+V]=A[X++]}}}return w}function S(Q){return Q<0?0:Q>255?255:Q}g.prototype={load:function(p){var w=new XMLHttpRequest;w.open("GET",p,!0),w.responseType="arraybuffer",w.onload=(function(){var f=new Uint8Array(w.response||w.mozResponseArrayBuffer);this.parse(f),this.onload&&this.onload()}).bind(this),w.send(null)},parse:function(p){var w=this.opts.maxResolutionInMP*1e3*1e3,f=0,ee=p.length;function x(){var L=p[f]<<8|p[f+1];return f+=2,L}function H(){var L=x(),ne=p.subarray(f,f+L-2);return f+=ne.length,ne}function A(L){var ne=1,be=1,ce,Ae;for(Ae in L.components)L.components.hasOwnProperty(Ae)&&(ce=L.components[Ae],ne<ce.h&&(ne=ce.h),be<ce.v&&(be=ce.v));var Le=Math.ceil(L.samplesPerLine/8/ne),Re=Math.ceil(L.scanLines/8/be);for(Ae in L.components)if(L.components.hasOwnProperty(Ae)){ce=L.components[Ae];var Se=Math.ceil(Math.ceil(L.samplesPerLine/8)*ce.h/ne),Ue=Math.ceil(Math.ceil(L.scanLines/8)*ce.v/be),qe=Le*ce.h,Ne=Re*ce.v,Ze=Ne*qe,Ge=[];G(Ze*256);for(var Ve=0;Ve<Ne;Ve++){for(var Xe=[],je=0;je<qe;je++)Xe.push(new Int32Array(64));Ge.push(Xe)}ce.blocksPerLine=Se,ce.blocksPerColumn=Ue,ce.blocks=Ge}L.maxH=ne,L.maxV=be,L.mcusPerLine=Le,L.mcusPerColumn=Re}var R=null,V=null,ae=null,k,ve,F=[],X=[],xe=[],he=[],j=x(),ge=-1;if(this.comments=[],j!=65496)throw new Error("SOI not found");for(j=x();j!=65497;){var ie,Z,D;switch(j){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var o=H();if(j===65534){var E=String.fromCharCode.apply(null,o);this.comments.push(E)}j===65504&&o[0]===74&&o[1]===70&&o[2]===73&&o[3]===70&&o[4]===0&&(R={version:{major:o[5],minor:o[6]},densityUnits:o[7],xDensity:o[8]<<8|o[9],yDensity:o[10]<<8|o[11],thumbWidth:o[12],thumbHeight:o[13],thumbData:o.subarray(14,14+3*o[12]*o[13])}),j===65505&&o[0]===69&&o[1]===120&&o[2]===105&&o[3]===102&&o[4]===0&&(this.exifBuffer=o.subarray(5,o.length)),j===65518&&o[0]===65&&o[1]===100&&o[2]===111&&o[3]===98&&o[4]===101&&o[5]===0&&(V={version:o[6],flags0:o[7]<<8|o[8],flags1:o[9]<<8|o[10],transformCode:o[11]});break;case 65499:for(var se=x(),le=se+f-2;f<le;){var J=p[f++];G(256);var K=new Int32Array(64);if(J>>4===0)for(Z=0;Z<64;Z++){var q=t[Z];K[q]=p[f++]}else if(J>>4===1)for(Z=0;Z<64;Z++){var q=t[Z];K[q]=x()}else throw new Error("DQT: invalid table spec");F[J&15]=K}break;case 65472:case 65473:case 65474:x(),k={},k.extended=j===65473,k.progressive=j===65474,k.precision=p[f++],k.scanLines=x(),k.samplesPerLine=x(),k.components={},k.componentsOrder=[];var v=k.scanLines*k.samplesPerLine;if(v>w){var _=Math.ceil((v-w)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${_}MP`)}var fe=p[f++],O,N=0,Ce=0;for(ie=0;ie<fe;ie++){O=p[f];var Fe=p[f+1]>>4,l=p[f+1]&15,b=p[f+2];if(Fe<=0||l<=0)throw new Error("Invalid sampling factor, expected values above 0");k.componentsOrder.push(O),k.components[O]={h:Fe,v:l,quantizationIdx:b},f+=3}A(k),X.push(k);break;case 65476:var I=x();for(ie=2;ie<I;){var T=p[f++],M=new Uint8Array(16),U=0;for(Z=0;Z<16;Z++,f++)U+=M[Z]=p[f];G(16+U);var te=new Uint8Array(U);for(Z=0;Z<U;Z++,f++)te[Z]=p[f];ie+=17+U,(T>>4===0?he:xe)[T&15]=y(M,te)}break;case 65501:x(),ve=x();break;case 65500:x(),x();break;case 65498:var re=x(),pe=p[f++],ue=[],u;for(ie=0;ie<pe;ie++){u=k.components[p[f++]];var m=p[f++];u.huffmanTableDC=he[m>>4],u.huffmanTableAC=xe[m&15],ue.push(u)}var B=p[f++],_e=p[f++],Y=p[f++],W=C(p,f,k,ue,ve,B,_e,Y>>4,Y&15,this.opts);f+=W;break;case 65535:p[f]!==255&&f--;break;default:if(p[f-3]==255&&p[f-2]>=192&&p[f-2]<=254){f-=3;break}else if(j===224||j==225){if(ge!==-1)throw new Error(`first unknown JPEG marker at offset ${ge.toString(16)}, second unknown JPEG marker ${j.toString(16)} at offset ${(f-1).toString(16)}`);ge=f-1;let L=x();if(p[f+L-2]===255){f+=L-2;break}}throw new Error("unknown JPEG marker "+j.toString(16))}j=x()}if(X.length!=1)throw new Error("only single frame JPEGs supported");for(var ie=0;ie<X.length;ie++){var oe=X[ie].components;for(var Z in oe)oe[Z].quantizationTable=F[oe[Z].quantizationIdx],delete oe[Z].quantizationIdx}this.width=k.samplesPerLine,this.height=k.scanLines,this.jfif=R,this.adobe=V,this.components=[];for(var ie=0;ie<k.componentsOrder.length;ie++){var u=k.components[k.componentsOrder[ie]];this.components.push({lines:$(k,u),scaleX:u.h/k.maxH,scaleY:u.v/k.maxV})}},getData:function(p,w){var f=this.width/p,ee=this.height/w,x,H,A,R,V,ae,k,ve,F,X,xe=0,he,j,ge,ie,Z,D,o,E,se,le,J,K=p*w*this.components.length;G(K);var q=new Uint8Array(K);switch(this.components.length){case 1:for(x=this.components[0],X=0;X<w;X++)for(V=x.lines[0|X*x.scaleY*ee],F=0;F<p;F++)he=V[0|F*x.scaleX*f],q[xe++]=he;break;case 2:for(x=this.components[0],H=this.components[1],X=0;X<w;X++)for(V=x.lines[0|X*x.scaleY*ee],ae=H.lines[0|X*H.scaleY*ee],F=0;F<p;F++)he=V[0|F*x.scaleX*f],q[xe++]=he,he=ae[0|F*H.scaleX*f],q[xe++]=he;break;case 3:for(J=!0,this.adobe&&this.adobe.transformCode?J=!0:typeof this.opts.colorTransform<"u"&&(J=!!this.opts.colorTransform),x=this.components[0],H=this.components[1],A=this.components[2],X=0;X<w;X++)for(V=x.lines[0|X*x.scaleY*ee],ae=H.lines[0|X*H.scaleY*ee],k=A.lines[0|X*A.scaleY*ee],F=0;F<p;F++)J?(he=V[0|F*x.scaleX*f],j=ae[0|F*H.scaleX*f],ge=k[0|F*A.scaleX*f],E=S(he+1.402*(ge-128)),se=S(he-.3441363*(j-128)-.71413636*(ge-128)),le=S(he+1.772*(j-128))):(E=V[0|F*x.scaleX*f],se=ae[0|F*H.scaleX*f],le=k[0|F*A.scaleX*f]),q[xe++]=E,q[xe++]=se,q[xe++]=le;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(J=!1,this.adobe&&this.adobe.transformCode?J=!0:typeof this.opts.colorTransform<"u"&&(J=!!this.opts.colorTransform),x=this.components[0],H=this.components[1],A=this.components[2],R=this.components[3],X=0;X<w;X++)for(V=x.lines[0|X*x.scaleY*ee],ae=H.lines[0|X*H.scaleY*ee],k=A.lines[0|X*A.scaleY*ee],ve=R.lines[0|X*R.scaleY*ee],F=0;F<p;F++)J?(he=V[0|F*x.scaleX*f],j=ae[0|F*H.scaleX*f],ge=k[0|F*A.scaleX*f],ie=ve[0|F*R.scaleX*f],Z=255-S(he+1.402*(ge-128)),D=255-S(he-.3441363*(j-128)-.71413636*(ge-128)),o=255-S(he+1.772*(j-128))):(Z=V[0|F*x.scaleX*f],D=ae[0|F*H.scaleX*f],o=k[0|F*A.scaleX*f],ie=ve[0|F*R.scaleX*f]),q[xe++]=255-Z,q[xe++]=255-D,q[xe++]=255-o,q[xe++]=255-ie;break;default:throw new Error("Unsupported color mode")}return q},copyToImageData:function(p,w){var f=p.width,ee=p.height,x=p.data,H=this.getData(f,ee),A=0,R=0,V,ae,k,ve,F,X,xe,he,j;switch(this.components.length){case 1:for(ae=0;ae<ee;ae++)for(V=0;V<f;V++)k=H[A++],x[R++]=k,x[R++]=k,x[R++]=k,w&&(x[R++]=255);break;case 3:for(ae=0;ae<ee;ae++)for(V=0;V<f;V++)xe=H[A++],he=H[A++],j=H[A++],x[R++]=xe,x[R++]=he,x[R++]=j,w&&(x[R++]=255);break;case 4:for(ae=0;ae<ee;ae++)for(V=0;V<f;V++)F=H[A++],X=H[A++],k=H[A++],ve=H[A++],xe=255-S(F*(1-ve/255)+ve),he=255-S(X*(1-ve/255)+ve),j=255-S(k*(1-ve/255)+ve),x[R++]=xe,x[R++]=he,x[R++]=j,w&&(x[R++]=255);break;default:throw new Error("Unsupported color mode")}}};var z=0,P=0;function G(Q=0){var p=z+Q;if(p>P){var w=Math.ceil((p-P)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${w}MB`)}z=p}return g.resetMaxMemoryUsage=function(Q){z=0,P=Q},g.getBytesAllocated=function(){return z},g.requestMemoryAllocation=G,g})();typeof gt<"u"?gt.exports=Or:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].decode=Or);function Or(e,t={}){var r={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512},i={...r,...t},a=new Uint8Array(e),n=new vt;n.opts=i,vt.resetMaxMemoryUsage(i.maxMemoryUsageInMB*1024*1024),n.parse(a);var s=i.formatAsRGBA?4:3,h=n.width*n.height*s;try{vt.requestMemoryAllocation(h);var c={width:n.width,height:n.height,exifBuffer:n.exifBuffer,data:i.useTArray?new Uint8Array(h):Buffer.alloc(h)};n.comments.length>0&&(c.comments=n.comments)}catch(d){throw d instanceof RangeError?new Error("Could not allocate enough memory for the image. Required: "+h):d instanceof ReferenceError&&d.message==="Buffer is not defined"?new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true"):d}return n.copyToImageData(c,i.formatAsRGBA),c}});var Rr=de((vn,Br)=>{"use strict";var Gi=Lr(),Vi=Pr();Br.exports={encode:Gi,decode:Vi}});var Mr=Pt(kr(),1),Sr=Pt(Rr(),1);function gn(e){return e.length>=24&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?e.toString("latin1",12,16)!=="IHDR"?{format:"png"}:{format:"png",width:e.readUInt32BE(16),height:e.readUInt32BE(20)}:e.length>=4&&e[0]===255&&e[1]===216&&e[2]===255?{format:"jpeg",...Xi(e)}:e.length>=16&&e.toString("latin1",0,4)==="RIFF"&&e.toString("latin1",8,12)==="WEBP"?{format:"webp",...ji(e)}:e.length>=4&&e.toString("latin1",0,4).startsWith("GIF8")?{format:"gif"}:e.length>=2&&e[0]===66&&e[1]===77?{format:"bmp"}:e.length>=4&&(e[0]===73&&e[1]===73&&e[2]===42&&e[3]===0||e[0]===77&&e[1]===77&&e[2]===0&&e[3]===42)?{format:"tiff"}:e.length>=44&&e.readUInt32LE(0)===1&&e.toString("latin1",40,44)===" EMF"?{format:"emf"}:e.length>=4&&(e[0]===215&&e[1]===205&&e[2]===198&&e[3]===154||e[0]===1&&e[1]===0&&e[2]===9&&e[3]===0)?{format:"wmf"}:{format:"unknown"}}function Xi(e){let t=2;for(;t+9<e.length;){if(e[t]!==255)return{};let r=e[t+1];if(r===216||r>=208&&r<=215){t+=2;continue}let i=e.readUInt16BE(t+2);if(r>=192&&r<=207&&r!==196&&r!==200&&r!==204)return{height:e.readUInt16BE(t+5),width:e.readUInt16BE(t+7)};if(i<2)return{};t+=2+i}return{}}function ji(e){let t=e.toString("latin1",12,16);if(t==="VP8X"&&e.length>=30)return{width:1+e.readUIntLE(24,3),height:1+e.readUIntLE(27,3)};if(t==="VP8 "&&e.length>=30)return e[23]!==157||e[24]!==1||e[25]!==42?{}:{width:e.readUInt16LE(26)&16383,height:e.readUInt16LE(28)&16383};if(t==="VP8L"&&e.length>=25){if(e[20]!==47)return{};let r=e.readUInt32LE(21);return{width:(r&16383)+1,height:(r>>>14&16383)+1}}return{}}function mn(e,t){try{if(t==="png"){let r=Mr.PNG.sync.read(e);return{data:Buffer.from(r.data),width:r.width,height:r.height,channels:4}}if(t==="jpeg"){let r=Sr.decode(e,{useTArray:!0,maxMemoryUsageInMB:512});return{data:Buffer.from(r.data),width:r.width,height:r.height,channels:4}}return null}catch{return null}}export{gn as a,mn as b};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{execSync as c}from"child_process";import{readFileSync as o}from"fs";import{createHash as a}from"crypto";import{hostname as u,platform as f,arch as m}from"os";var t=null;function g(){return t||(t=s(),t)}function s(){let r=f();if(r==="darwin")try{let n=c("ioreg -rd1 -c IOPlatformExpertDevice",{encoding:"utf-8",timeout:5e3}).match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);if(n?.[1])return n[1]}catch{}if(r==="linux")try{let e=o("/etc/machine-id","utf-8").trim();if(e)return e}catch{}let i=`${u()}:${r}:${m()}`;return a("sha256").update(i).digest("hex").slice(0,32)}export{g as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-73C4PRYU.js";import{y as u}from"./chunk-C4G7RVJ6.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
2
+ import{a as k}from"./chunk-FEJXWJ3L.js";import{y as u}from"./chunk-27U4PLPX.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
3
3
  `),e}var c=p(f(),1),S=t=>t!==void 0&&/[A-Za-z0-9]/.test(t);function x(t){let e=[],o="",i=()=>{o&&(e.push({text:o}),o="")},d=(a,l,r)=>(a===0||!S(t[a-1]))&&(l+r>=t.length||!S(t[l+r])),n=0;for(;n<t.length;){let a=t.slice(n,n+2),l=t[n];if(a==="**"||a==="__"){let r=t.indexOf(a,n+2);if(r!==-1&&r>n+2&&(a==="**"||d(n,r,2))){i(),e.push({text:t.slice(n+2,r),bold:!0}),n=r+2;continue}}if(l==="`"){let r=t.indexOf("`",n+1);if(r!==-1&&r>n+1){i(),e.push({text:t.slice(n+1,r),code:!0}),n=r+1;continue}}if(l==="*"||l==="_"){let r=t.indexOf(l,n+1);if(r!==-1&&r>n+1&&(l==="*"||d(n,r,1))){i(),e.push({text:t.slice(n+1,r),italic:!0}),n=r+1;continue}}o+=l,n+=1}return i(),e.length===0&&e.push({text:""}),e}function h(t){return t.map((e,o)=>(0,c.jsx)(s,{bold:e.bold,italic:e.italic,color:e.code?u.dim:void 0,children:e.text},o))}function T(t){return t.split(`
4
4
  `).map(e=>{if(e.trim()==="")return{kind:"blank"};let o=e.match(/^\s*[-*+]\s+(.*)$/);if(o)return{kind:"bullet",segs:x(o[1])};let i=e.match(/^\s*(\d+)\.\s+(.*)$/);if(i)return{kind:"numbered",n:i[1],segs:x(i[2])};let d=e.match(/^#{1,6}\s+(.*)$/);return d?{kind:"heading",segs:x(d[1])}:{kind:"para",segs:x(e)}})}function R(t,e,o=""){switch(t.kind){case"blank":return(0,c.jsx)(s,{children:o||" "},e);case"heading":return(0,c.jsxs)(s,{bold:!0,children:[o,h(t.segs)]},e);case"bullet":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,"\u2022 ",h(t.segs)]})},e);case"numbered":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,`${t.n}. `,h(t.segs)]})},e);default:return(0,c.jsxs)(s,{children:[o,h(t.segs)]},e)}}function $({text:t,accent:e=u.generateAccent}){let o=T(B(t)),{stdout:i}=b(),d=i?.columns??80;return(0,c.jsxs)(m,{marginBottom:1,children:[(0,c.jsx)(m,{width:2,flexShrink:0,children:(0,c.jsx)(s,{color:e,children:"\u2503"})}),(0,c.jsx)(m,{flexDirection:"column",width:d-2,children:o.map((n,a)=>R(n,a))})]})}var g=p(f(),1),I=5;function C({thinking:t,expanded:e,thinkingDone:o,maxLines:i=I}){if(!e)return(0,g.jsxs)(m,{paddingX:1,children:[(0,g.jsx)(s,{color:u.dim,children:o?"\u2237 thinking complete ":"\u2237 thinking\u2026 "}),(0,g.jsx)(s,{color:u.muted,children:o?"(ctrl+t to view)":"(ctrl+t to show)"})]});let d=t.split(`
5
5
  `),n=Math.max(0,d.length-i),a=n>0?d.slice(-i).join(`
@@ -0,0 +1,11 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as Ve}from"./chunk-T5Y6MOLM.js";import{a as Ye}from"./chunk-OTTGS2TE.js";import{a as We}from"./chunk-YCCUBQY4.js";import{a as qe}from"./chunk-VE3SUJMA.js";import{a as be}from"./chunk-TFPPEOAK.js";import{a as Ge}from"./chunk-766WGMBU.js";import{a as He}from"./chunk-G7VQCS4J.js";import{c as Le,y as u}from"./chunk-27U4PLPX.js";import{a as ne}from"./chunk-HCBYKLMW.js";import{a as h,b as f,h as Fe,i as Se,k as Ne}from"./chunk-C44QQJR4.js";import{a as we}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var je=$(we(),1);import{readFileSync as ct,writeFileSync as ut,mkdirSync as ft}from"fs";import{dirname as dt,join as ze}from"path";var mt=ze(Le,"command-history.json"),Dt=ze(Le,"generate-history.json"),ht=200,De=class{entries;filePath;max;constructor(t=mt,e=ht){this.filePath=t,this.max=e,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let e=t.toLowerCase(),o=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(e)&&o.push(this.entries[s]);return o}_load(){if(this.filePath===null)return[];try{let t=ct(this.filePath,"utf-8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}_save(){if(this.filePath!==null)try{ft(dt(this.filePath),{recursive:!0}),ut(this.filePath,JSON.stringify(this.entries)+`
3
+ `)}catch{}}};function kt(n){let t=(0,je.useRef)(null);return t.current||(t.current=new De(n)),t.current}var D=$(we(),1);var ke=$(we(),1);var Q=$(ne(),1);function Xe({history:n,onSelect:t,onClose:e}){let[o,s]=(0,ke.useState)(""),[l,m]=(0,ke.useState)(0),v=o?n.search(o).slice(0,8):[];return Se((b,d)=>{if(d.escape){e();return}if(d.return){v.length>0&&v[l]?t(v[l]):e();return}if(d.upArrow){m(S=>Math.max(0,S-1));return}if(d.downArrow){m(S=>Math.min(v.length-1,S+1));return}if(d.backspace||d.delete){s(S=>S.slice(0,-1)),m(0);return}b&&!d.ctrl&&!d.meta&&(s(S=>S+b),m(0))}),(0,Q.jsxs)(h,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,Q.jsx)(f,{color:u.muted,bold:!0,children:"reverse search"}),(0,Q.jsxs)(h,{gap:1,children:[(0,Q.jsx)(f,{color:u.dim,children:"search:"}),(0,Q.jsx)(f,{children:o}),(0,Q.jsx)(f,{color:u.orange,children:"\u2588"})]}),v.length>0&&(0,Q.jsx)(f,{children:" "}),v.map((b,d)=>(0,Q.jsx)(h,{marginLeft:2,children:(0,Q.jsxs)(f,{color:d===l?u.orange:u.dim,bold:d===l,children:[d===l?"\u25B8 ":" ",b]})},`${d}-${b}`))]})}var de=$(ne(),1);function Je({commands:n,selectedIndex:t}){return n.length===0?null:(0,de.jsx)(h,{flexDirection:"column",marginBottom:0,children:n.map((e,o)=>{let s=o===t;return(0,de.jsxs)(h,{children:[(0,de.jsx)(f,{color:s?u.orange:u.dim,children:s?"\u276F ":" "}),(0,de.jsxs)(f,{color:s?u.orange:void 0,bold:s,children:["/",e.name]}),e.args&&(0,de.jsxs)(f,{color:u.dim,children:[" ",e.args]}),(0,de.jsxs)(f,{color:u.dim,children:[" ",e.description]})]},e.name)})})}var Ze=$(we(),1);var q=$(ne(),1),et={scenario:"Scenarios",case:"Test Cases",file:"Files",artifact:"Artifact candidates",installed:"Installed on device"};function Qe(n){let t={scenario:0,case:0,file:0,artifact:0,installed:0};for(let e of n)t[e.kind]++;return["scenario","case","file","artifact","installed"].filter(e=>t[e]>0).map(e=>`${t[e]} ${et[e]}`).join(" \xB7 ")}var Pe=7;function tt({items:n,selectedIndex:t,accent:e=u.orange}){let o=n.length;if(o===0)return null;let s=Math.floor(Pe/2),l=o<=Pe?0:Math.max(0,Math.min(t-s,o-Pe)),m=Math.min(o,l+Pe),v=l,b=o-m;return(0,q.jsxs)(h,{flexDirection:"column",marginBottom:0,children:[v>0&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:` \u22EF ${v} above \u2014 ${Qe(n.slice(0,l))}`})}),n.slice(l,m).map((d,S)=>{let U=l+S,F=d.selectable!==!1,E=U===t&&F,C=S===0||n[U-1].kind!==d.kind;return(0,q.jsxs)(Ze.default.Fragment,{children:[C&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:et[d.kind]})}),(0,q.jsxs)(h,{children:[(0,q.jsx)(f,{color:E?e:u.dim,children:E?"\u276F ":" "}),(0,q.jsxs)(f,{color:E?e:F?void 0:u.dim,bold:E,children:[d.label,d.reason?` \u2014 ${d.reason}`:""]})]})]},`${d.kind}:${d.value}:${U}`)}),b>0&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:` \u22EF ${b} more \u2014 ${Qe(n.slice(m))}`})})]})}var Be=$(we(),1);var gt=27,pt=127,xt=11;function bt(n){return n>=64&&n<=126}function Tt(n,t){n===xt&&t({killToEnd:!0,ctrl:!0,raw:String.fromCharCode(n)})}function vt(n,t){n===pt&&t({backspace:!0,meta:!0,raw:"\x1B\x7F"})}function wt(n,t){let e=n.map(s=>String.fromCharCode(s)).join(""),o=/^\[1;([0-9]+)([A-D])$/.exec(e);if(o){let s=parseInt(o[1],10),l=o[2],m={raw:"\x1B"+e};if(s===2)m.shift=!0;else if(s===3)m.meta=!0;else if(s===5)m.ctrl=!0;else return;l==="A"?m.arrowUp=!0:l==="B"?m.arrowDown=!0:l==="C"?m.arrowRight=!0:l==="D"&&(m.arrowLeft=!0),t(m);return}if(e==="[H"||e==="[1~"||e==="[7~"){t({home:!0,raw:"\x1B"+e});return}if(e==="[F"||e==="[4~"||e==="[8~"){t({end:!0,raw:"\x1B"+e});return}if(e==="[3;5~"){t({delete:!0,ctrl:!0,raw:"\x1B"+e});return}if(e==="[3;3~"){t({delete:!0,meta:!0,raw:"\x1B"+e});return}}function St(n,t){n===72?t({home:!0,raw:"\x1BO"+String.fromCharCode(n)}):n===70&&t({end:!0,raw:"\x1BO"+String.fromCharCode(n)})}function Et(){let n="IDLE",t=[];function e(){n="IDLE",t=[]}return{feed(o,s){for(let l of o)n==="IDLE"?l===gt?(n="ESC",t=[]):Tt(l,s):n==="ESC"?l===91?(n="CSI",t=[]):l===79?(n="SS3",t=[]):(vt(l,s),e()):n==="CSI"?(t.push(l),bt(l)&&(wt([91,...t],s),e())):n==="SS3"&&(St(l,s),e())},flushIdle(o){n==="ESC"&&t.length===0&&o({raw:"\x1B"}),e()}}}function nt(n,t={}){let e=(0,Be.useRef)(n);e.current=n;let{stdin:o}=Fe();(0,Be.useEffect)(()=>{if(t.isActive===!1||!o)return;let s=Et(),l=null,m=v=>{l&&(clearTimeout(l),l=null);let b=Buffer.isBuffer(v)?v:Buffer.from(v,"binary");s.feed(b,d=>e.current(d)),l=setTimeout(()=>{s.flushIdle(d=>e.current(d)),l=null},50)};return o.on("data",m),()=>{o.removeListener("data",m),l&&clearTimeout(l)}},[t.isActive,o])}var w=$(ne(),1);function yt(n,t){let e=t-1;for(;e>=0&&n[e]!=="@"&&n[e]!==" "&&n[e]!==`
4
+ `;)e--;return e<0||n[e]!=="@"||e>0&&n[e-1]!==" "&&n[e-1]!==`
5
+ `?null:{at:e,query:n.slice(e+1,t).join("")}}function rt(n,t,e){for(let o=t+e;o>=0&&o<n.length;o+=e)if(n[o]?.selectable!==!1)return o;return t}function At(n){let t=n.findIndex(e=>e.selectable!==!1);return t===-1?0:t}var Oe=10;function Ct(n){return n.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`
6
+ `).replace(/\r/g,`
7
+ `).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,"")}function Rt(n,t){let e=[],o=0;for(;o<=n.length;){let s=o;for(;s<n.length&&n[s]!==`
8
+ `;)s++;if(o===s)e.push({start:o,end:o});else{let l=o;for(;l<s;){let m=Math.min(l+t,s);e.push({start:l,end:m}),l=m}}if(s>=n.length)break;o=s+1}return e}function It(n,t,e){if(n.length===0)return 0;if(t>=e.length)return n.length-1;if(e[t]===`
9
+ `){for(let o=n.length-1;o>=0;o--)if(n[o].end===t)return o;return n.length-1}for(let o=0;o<n.length;o++){let s=n[o];if(s.start<=t&&t<s.end)return o}return n.length-1}function it(n,t,e,o){let s=Rt(n,e);if(s.length===0)return null;let l=It(s,t,n),m=l+o;if(m<0||m>=s.length)return null;let v=t-s[l].start,b=s[m],d=b.end-b.start;return b.start+Math.min(v,d)}function rn({onSubmit:n,onEscape:t,history:e,placeholder:o="Type an objective or /command...",commands:s,clearSeq:l,submitVerb:m,footerBindings:v,inert:b=!1,clearOnSubmit:d=!0,noHistory:S=!1,accent:U=u.orange,scenarios:F,mentionFiles:E,loadMentionItems:C,onMentionSelect:Ee,mentionHint:G,submitEmpty:V=!1}){let[c,A]=(0,D.useState)([]),[x,g]=(0,D.useState)(0),[N,Z]=(0,D.useState)("none"),[re,M]=(0,D.useState)(-1),ie=(0,D.useRef)(""),[Y,oe]=(0,D.useState)(!0),{stdout:Ie}=Ne(),se=Ie?.columns??80,[me,ee]=(0,D.useState)(0),[ce,le]=(0,D.useState)(0),[P,R]=(0,D.useState)([]),[_,B]=(0,D.useState)([]),[j,ye]=(0,D.useState)(null),$e=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(l!==void 0){if(!$e.current){$e.current=!0;return}A([]),g(0),M(-1),ie.current="",oe(!0),Z("none"),ee(0)}},[l]);let L=c.join(""),Ae=(()=>{if(N!=="none"||c.length===0)return"";if(L.startsWith("/")&&s&&L.length>=2){let r=L.slice(1).toLowerCase(),i=s.find(T=>T.name.startsWith(r)&&T.name!==r);return i?`/${i.name}`.slice(L.length):""}if(L.startsWith("/")||S)return"";let a=e.getAll();for(let r=a.length-1;r>=0;r--)if(a[r].startsWith(L)&&a[r]!==L)return a[r].slice(L.length);return""})(),he=(()=>{if(!s||!L.startsWith("/"))return[];let a=L.length>=2?L.slice(1).toLowerCase():"";return a&&s.some(r=>r.name===a)?[]:s.filter(r=>!a||r.name.startsWith(a))})(),ge=he.length>0&&L.startsWith("/"),O=!!C||!!E||!!(F&&F.length)?yt(c,x):null,Ce=O?O.query:null,z=(()=>{if(!O)return[];if(C)return _;let a=O.query.toLowerCase(),r=[];(F??[]).forEach((i,T)=>{let y=`s${T+1}`;(!a||y.includes(a)||(i.title??"").toLowerCase().includes(a))&&r.push({kind:"scenario",value:y,label:`@${y} ${i.title??i.sid??""}`.trim()})}),(F??[]).forEach((i,T)=>{let I=T+1;(i.test_cases??[]).forEach((y,W)=>{let X=`s${I}.c${W+1}`;(!a||X.includes(a)||(y.title??"").toLowerCase().includes(a))&&r.push({kind:"case",value:X,label:`@${X} ${y.title??""}`.trim()})})});for(let i of P)r.push({kind:"file",value:i,label:i});return r})(),Te=O!==null&&O.at!==j&&!ge&&N==="none"&&z.length>0,st=O!==null&&O.at!==j&&!ge&&N==="none"&&!!G;(0,D.useEffect)(()=>{if(C&&Ce!==null){let r=!1;return C(Ce).then(i=>{r||B(i)}).catch(()=>{r||B([])}),()=>{r=!0}}if(!E||Ce===null){R([]),B([]);return}let a=!1;return E(Ce).then(r=>{a||R(r)}).catch(()=>{a||R([])}),()=>{a=!0}},[Ce,E,C]),(0,D.useEffect)(()=>{ce>=z.length&&le(0)},[z.length]);let Re=z[ce]?.selectable===!1?At(z):ce,Ke=a=>{if(!O||a.selectable===!1)return;if(Ee){let T=[...c.slice(0,O.at),...c.slice(x)];A(T),g(O.at),le(0),ye(O.at),oe(T.length===0),Ee(a);return}let r=/\s/.test(a.value)?`@"${a.value}"`:`@${a.value}`,i=[...c.slice(0,O.at),...r,...c.slice(x)];A(i),g(O.at+r.length),le(0),ye(O.at),oe(!1)};if(Se((a,r)=>{if(Y&&a&&oe(!1),r.return){if(Te&&z[Re]){Ke(z[Re]);return}if(ge&&he[me]){let i=`/${he[me].name}`;S||e.push(i),n(i),A([]),g(0),Z("none"),M(-1),ie.current="",oe(!0),ee(0);return}L.trim()?(S||e.push(L.trim()),n(L.trim()),d&&(A([]),g(0),Z("none"),M(-1),ie.current="",oe(!0),ee(0))):V&&n("");return}if(r.escape){if(Te){ye(O.at);return}N!=="none"?Z("none"):c.length>0?(A([]),g(0),M(-1),ie.current=""):t?.();return}if(r.tab&&!r.shift){if(Te&&z[Re]){Ke(z[Re]);return}if(ge&&he[me]){let i=`/${he[me].name}`;A([...i]),g(i.length),ee(0);return}if(Ae){let i=L+Ae;A([...i]),g(i.length);return}return}if(r.ctrl&&a==="r"){if(S)return;Z("search");return}if(r.ctrl&&a==="a"){g(0);return}if(r.ctrl&&a==="e"){g(c.length);return}if(r.ctrl&&a==="w"){if(x===0)return;let i=x-1;for(;i>0&&c[i]===" ";)i--;for(;i>0&&c[i-1]!==" ";)i--;let T=[...c.slice(0,i),...c.slice(x)];A(T),g(i);return}if(r.ctrl&&a==="u"){A([]),g(0),M(-1),Z("none");return}if(r.meta&&a==="b"){let i=x-1;for(;i>0&&c[i]===" ";)i--;for(;i>0&&c[i-1]!==" ";)i--;g(Math.max(0,i));return}if(r.meta&&a==="f"){let i=x;for(;i<c.length&&c[i]!==" ";)i++;for(;i<c.length&&c[i]===" ";)i++;g(i);return}if(r.leftArrow){if(r.ctrl||r.shift)return;g(i=>Math.max(0,i-1));return}if(r.rightArrow){if(r.ctrl||r.shift)return;if(x>=c.length&&Ae){let i=L+Ae;A([...i]),g(i.length)}else g(i=>Math.min(c.length,i+1));return}if(r.upArrow){if(r.shift)return;if(Te){le(i=>rt(z,i,-1));return}if(ge){ee(i=>Math.max(0,i-1));return}if(N==="none"){let i=Math.max(1,se-2),T=it(c,x,i,-1);if(T!==null){g(T);return}if(S)return;let I=e.getAll();if(I.length===0)return;if(re===-1){ie.current=L,M(I.length-1);let y=I[I.length-1];A([...y]),g(y.length)}else if(re>0){let y=re-1;M(y);let W=I[y];A([...W]),g(W.length)}}return}if(r.downArrow){if(r.shift)return;if(Te){le(i=>rt(z,i,1));return}if(ge){ee(i=>Math.min(he.length-1,i+1));return}if(N==="none"){let i=Math.max(1,se-2),T=it(c,x,i,1);if(T!==null){g(T);return}if(S)return;let I=e.getAll();if(re===-1)return;if(re<I.length-1){let y=re+1;M(y);let W=I[y];A([...W]),g(W.length)}else{M(-1);let y=ie.current;A([...y]),g(y.length)}}return}if(r.backspace||r.delete){if(r.meta||r.ctrl)return;if(x>0){let i=[...c.slice(0,x-1),...c.slice(x)];A(i),g(x-1),M(-1),ee(0),ye(null),le(0)}return}if(a&&!r.ctrl&&!r.meta){let i=Ct(a);if(!i)return;let T=[...c.slice(0,x),...i,...c.slice(x)];A(T),g(x+i.length),M(-1),ee(0),ye(null),le(0)}},{isActive:!b&&N!=="search"}),nt(a=>{if(a.home){g(0);return}if(a.end){g(c.length);return}if(a.killToEnd){A(c.slice(0,x));return}if(a.arrowLeft&&(a.ctrl||a.meta)){let r=x-1;for(;r>0&&c[r]===" ";)r--;for(;r>0&&c[r-1]!==" ";)r--;g(Math.max(0,r));return}if(a.arrowRight&&(a.ctrl||a.meta)){let r=x;for(;r<c.length&&c[r]!==" ";)r++;for(;r<c.length&&c[r]===" ";)r++;g(r);return}if(a.backspace&&a.meta){if(x===0)return;let r=x-1;for(;r>0&&c[r]===" ";)r--;for(;r>0&&c[r-1]!==" ";)r--;let i=[...c.slice(0,r),...c.slice(x)];A(i),g(r);return}if(a.delete&&(a.ctrl||a.meta)){let r=x;for(;r<c.length&&c[r]===" ";)r++;for(;r<c.length&&c[r]!==" ";)r++;A([...c.slice(0,x),...c.slice(r)]);return}},{isActive:!b&&N!=="search"}),b)return(0,w.jsxs)(h,{flexDirection:"column",children:[(0,w.jsx)(f,{color:u.muted,children:"\u2500".repeat(se)}),(0,w.jsxs)(h,{children:[(0,w.jsx)(f,{color:u.muted,children:"\u276F "}),(0,w.jsx)(f,{color:u.dim,children:o})]}),(0,w.jsx)(be,{bindings:v??[{keys:"ctrl+c",label:"cancel"},{keys:"/cancel",label:"stop turn"},{keys:"ctrl+t",label:"thinking"}],suppressEscBack:!0})]});let lt=a=>{A([...a]),g(a.length),Z("none")},at=()=>{Z("none")},_e=(()=>{if(Y&&c.length===0)return null;let a=x>=c.length,r=c.slice(0,x).join(""),i,T;a?(i=" ",T=""):c[x]===`
10
+ `?(i=" ",T=c.slice(x).join("")):(i=c[x],T=c.slice(x+1).join(""));let I=r+i+T+Ae,y=r.length,W=y+1,X=W+T.length,Me=Math.max(1,se-2),k=[],ae=0;for(;ae<=I.length;){let H=I.indexOf(`
11
+ `,ae);if(H===-1&&(H=I.length),ae===H)k.push({type:"content",start:ae,end:ae});else{let J=ae;for(;J<H;){let ue=Math.min(J+Me,H);k.push({type:"content",start:J,end:ue}),J=ue}}if(H>=I.length)break;ae=H+1}let te=Math.max(0,k.findIndex(H=>H.start<=y&&y<=H.end)),xe;if(k.length<=Oe)xe=k;else{let J=Oe-1-4;if(te<4||te>=k.length-J)xe=[...k.slice(0,4),{type:"ellipsis",hidden:k.length-4-J},...k.slice(k.length-J)];else{let ue=Oe-2,Ue=Math.floor(ue/2),fe=te-Ue,ve=te+(ue-Ue)-1;fe<1&&(ve+=1-fe,fe=1),ve>k.length-2&&(fe-=ve-(k.length-2),ve=k.length-2),fe=Math.max(1,fe),xe=[{type:"ellipsis",hidden:fe},...k.slice(fe,ve+1),{type:"ellipsis",hidden:k.length-ve-1}]}}return{full:I,b:y,c:W,a:X,rows:xe}})();return(0,w.jsxs)(h,{flexDirection:"column",children:[N==="search"&&(0,w.jsx)(Xe,{history:e,onSelect:lt,onClose:at}),ge&&(0,w.jsx)(Je,{commands:he,selectedIndex:me}),Te&&(0,w.jsx)(tt,{items:z,selectedIndex:Re,accent:U}),st&&(0,w.jsx)(h,{children:(0,w.jsx)(f,{color:u.dim,children:G})}),(0,w.jsx)(f,{color:u.muted,children:"\u2500".repeat(se)}),_e===null?(0,w.jsxs)(h,{children:[(0,w.jsx)(f,{color:U,children:"\u276F "}),(0,w.jsx)(f,{inverse:!0,children:" "}),(0,w.jsx)(f,{color:u.dim,children:o})]}):(()=>{let a=_e.rows.findIndex(r=>r.type==="content");return(0,w.jsx)(h,{flexDirection:"column",children:_e.rows.map((r,i)=>{if(r.type==="ellipsis")return(0,w.jsx)(h,{children:(0,w.jsxs)(f,{color:u.dim,children:[" \u22EF ","(",r.hidden," more line",r.hidden===1?"":"s",")"]})},i);let{full:T,b:I,c:y,a:W}=_e,X=r.start,pe=r.end,Me=i===a,k=Me?"\u276F ":" ",ae=Me?U:u.muted,te=[(0,w.jsx)(f,{color:ae,children:k},"p")];X<Math.min(I,pe)&&te.push((0,w.jsx)(f,{children:T.slice(X,Math.min(I,pe))},"b"));let xe=Math.max(I,X),H=Math.min(y,pe);xe<H&&te.push((0,w.jsx)(f,{color:U,inverse:!0,children:T.slice(xe,H)},"c"));let J=Math.max(y,X),ue=Math.min(W,pe);return J<ue&&te.push((0,w.jsx)(f,{children:T.slice(J,ue)},"a")),pe>W&&te.push((0,w.jsx)(f,{color:u.dim,children:T.slice(Math.max(W,X),pe)},"g")),(0,w.jsx)(h,{children:te},i)})})})(),(0,w.jsx)(be,{bindings:v??[{keys:"\u2191\u2193",label:"history"},{keys:"\u21B5",label:m??"submit"},{keys:"tab",label:"complete"},{keys:"ctrl+r",label:"search"}],escBackLabel:"clear"})]})}var K=$(we(),1);var p=$(ne(),1);function _t(n){let t=[{id:"method",label:"Auth method",options:[{label:"Basic Auth",value:"basic"},{label:"OAuth (browser)",value:"oauth"}]}];return n&&t.push({id:"env",label:"Environment",options:[{label:"prod",value:"prod"},{label:"stage",value:"stage"}]}),t.push({id:"profile",label:"Profile"}),t.push({id:"credentials",label:"Credentials"}),t}function fn({devMode:n,profiles:t,onBasicLogin:e,onOAuthLogin:o,onComplete:s,onCancel:l}){let m=_t(n),[v,b]=(0,K.useState)(0),[d,S]=(0,K.useState)(0),[U,F]=(0,K.useState)({}),[E,C]=(0,K.useState)("select"),[Ee,G]=(0,K.useState)(""),[V,c]=(0,K.useState)("username"),[A,x]=(0,K.useState)(""),[g,N]=(0,K.useState)(null),[Z,re]=(0,K.useState)(null),M=m[v],ie=U.method??"basic",Y=U.env??"prod",oe=(0,K.useCallback)(()=>{let R=t.filter(_=>_.env===Y).map(_=>({label:`${_.profile} [${_.env}]`,value:_.profile}));return R.push({label:"+ Create new",value:"__new__"}),R},[t,Y]),Ie=(0,K.useCallback)(()=>{v===0?l():(b(P=>P-1),S(0),C("select"),G(""),N(null))},[v,l]),se=(0,K.useCallback)(P=>{ie==="basic"?(C("text-input"),c("username"),G("")):(C("waiting"),o(P,Y).then(()=>{re(`Logged in via OAuth as ${P} [${Y}]`),C("done")}).catch(R=>{N(R.message),C("error")}))},[ie,Y,o]),me=(0,K.useCallback)(P=>{let R=P.trim();if(R){if(V==="profileName"){let _=R;F(B=>({...B,profile:_})),se(_);return}if(V==="username"){x(R),G(""),c("accessKey"),C("text-input-masked");return}if(V==="accessKey"){let _=U.profile??"default";C("waiting"),(async()=>{try{await e(_,Y,A,R),re(`Logged in as ${_} [${Y}] via basic auth`),C("done")}catch{N("Credentials not valid. Please use valid credentials."),x(""),G(""),c("username"),C("text-input")}})()}}},[V,U.profile,Y,e,A,se]),ee=(0,K.useCallback)(P=>{G(P),g&&N(null)},[g]);Se((P,R)=>{if(E==="done"){let B=U.profile??"default";s(B,Y);return}if(E==="error"){l();return}if(E==="waiting"){R.escape&&l();return}if(E==="text-input"||E==="text-input-masked")return;if(R.escape){Ie();return}let _=M?.id==="profile"?oe():M?.options??[];if(R.upArrow){S(B=>Math.max(0,B-1));return}if(R.downArrow){S(B=>Math.min(_.length-1,B+1));return}if(R.return&&_[d]){let B=_[d];if(M.id==="profile"){if(B.value==="__new__"){C("text-input"),c("profileName"),G("");return}F(j=>({...j,profile:B.value})),b(j=>j+1),S(0),se(B.value);return}F(j=>({...j,[M.id]:B.value})),b(j=>j+1),S(0)}});let ce="Login";if(E==="done")return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.green,paddingX:2,paddingY:1,children:[(0,p.jsxs)(f,{color:u.green,bold:!0,children:["\u2713 ",Z]}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.dim,children:"press any key"})})]});if(E==="error")return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(f,{color:u.red,bold:!0,children:"Login failed"}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.red,children:g})}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.dim,children:"press any key"})})]});if(E==="waiting")return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[(0,p.jsxs)(f,{color:u.orange,bold:!0,children:[ce," \u203A OAuth"]}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.secondary,children:"Opening browser for login..."})}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.orange,children:"Waiting for callback \u27F3"})}),(0,p.jsx)(be,{bindings:[],escBackLabel:"cancel"})]});if(E==="text-input"||E==="text-input-masked"){let P=V==="username"?"Username":V==="accessKey"?"Access Key":"Profile name",R=V==="username"||V==="accessKey"?`${ce} \u203A Basic Auth`:`${ce} \u203A New Profile`;return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[g&&(V==="username"||V==="accessKey")&&(0,p.jsx)(h,{marginBottom:1,children:(0,p.jsxs)(f,{color:u.red,children:["\u2717 ",g]})}),(0,p.jsx)(f,{color:u.orange,bold:!0,children:R}),V==="accessKey"&&(0,p.jsxs)(h,{marginTop:1,children:[(0,p.jsx)(f,{color:u.secondary,children:"Username: "}),(0,p.jsx)(f,{children:A})]}),(0,p.jsxs)(h,{marginTop:1,children:[(0,p.jsxs)(f,{color:u.secondary,children:[P,": "]}),(0,p.jsx)(We,{value:Ee,onChange:ee,onSubmit:me,onCancel:Ie,masked:E==="text-input-masked"})]}),(0,p.jsx)(be,{bindings:[{keys:"\u21B5",label:"confirm"}],escBackLabel:"back"})]})}let le=M?.id==="profile"?oe():M?.options??[];return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[(0,p.jsx)(f,{color:u.orange,bold:!0,children:ce}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsxs)(f,{color:u.secondary,children:[M?.label,":"]})}),(0,p.jsx)(h,{flexDirection:"column",marginTop:1,children:le.map((P,R)=>{let _=R===d,B=_?"\u276F ":" ",j=P.value==="__new__"?u.green:_?u.orange:void 0;return(0,p.jsxs)(f,{color:j,children:[B,P.label]},P.value)})}),(0,p.jsx)(be,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}async function ot(n,t,e,o){let s=n.loadBasicAuth(t,e),l=n.loadCredentials(t,e);if(!s&&!l)return o("info","STARTUP_GATE_NO_CREDS","Profile has no credentials",{profile:t,env:e}),{status:"needs_login",profile:t,env:e};let m=He(e),v=async()=>n.loadCredentials(t,e)?.access_token??null,b=new Ye(m.controllerBaseUrl,v,s,o);o("info","STARTUP_GATE_VALIDATE","Validating credentials with controller",{profile:t,env:e,method:s?"basic":"oauth"});let d=await b.resolve(!0);if(d)return o("info","STARTUP_GATE_VALID","Credentials validated",{profile:t,env:e,username:d.username,org_id:d.org_id}),{status:"authenticated",result:{profile:t,env:e,credentials:l,basicAuth:s,tmsCreds:d,resolver:b}};if(!s&&l){let S=l.refresh_token,F=n.loadClient(t,e)?.client_id;if(S&&F){o("info","STARTUP_GATE_REFRESH","Attempting token refresh",{profile:t,env:e});try{let C=await new Ge(e).refreshToken(S,F);if(C.access_token){n.saveCredentials(t,e,{...l,...C,expires_at:Date.now()/1e3+(C.expires_in??3600)});let G=await b.resolve(!0);if(G)return o("info","STARTUP_GATE_REFRESH_OK","Token refreshed and validated",{profile:t,env:e,username:G.username}),{status:"authenticated",result:{profile:t,env:e,credentials:{...l,...C},basicAuth:null,tmsCreds:G,resolver:b}}}o("warn","STARTUP_GATE_REFRESH_INVALID","Refreshed token still invalid",{profile:t,env:e})}catch(E){o("warn","STARTUP_GATE_REFRESH_FAILED","Token refresh failed",{profile:t,env:e,error:E instanceof Error?E.message:String(E)})}}else o("info","STARTUP_GATE_NO_REFRESH","No refresh_token or client_id \u2014 login required",{profile:t,env:e})}return o("info","STARTUP_GATE_INVALID","Credentials invalid \u2014 login required",{profile:t,env:e}),{status:"needs_login",profile:t,env:e}}async function bn(n,t,e=new Ve){let o=n.listProfiles();if(t("info","STARTUP_GATE_START","Auth startup gate",{profile_count:o.length}),o.length===0)return t("info","STARTUP_GATE_NONE","No profiles found \u2014 login required"),{status:"needs_login"};if(o.length>1){let m=n.getActiveProfile(),v=n.getDefaultEnv();if(m&&o.some(d=>d.profile===m&&d.env===v)){t("info","STARTUP_GATE_TRY_ACTIVE","Multiple profiles \u2014 trying active first",{activeProfile:m,activeEnv:v});let d=await ot(n,m,v,t);if(d.status==="authenticated")return d;t("info","STARTUP_GATE_ACTIVE_FAILED","Active profile invalid \u2014 showing picker",{activeProfile:m,activeEnv:v})}return t("info","STARTUP_GATE_MULTI","Multiple profiles \u2014 picker required",{profiles:o.map(b=>`${b.profile}/${b.env}`)}),{status:"needs_pick",profiles:o}}let{profile:s,env:l}=o[0];return n.setActiveProfile(s),n.setDefaultEnv(l),qe(n,e,s,l),ot(n,s,l,t)}export{Dt as a,kt as b,rn as c,fn as d,ot as e,bn as f};
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as B,b as U,c as Y}from"./chunk-AFPHLUQ5.js";import{b as K}from"./chunk-RLRNLIRS.js";import{a as j}from"./chunk-DNNZ353O.js";import{d as F}from"./chunk-XWKUZJCP.js";import{A as k,a as L,b as V,k as G,o as N}from"./chunk-TH47OOBV.js";import{d as I}from"./chunk-DUAXZYAD.js";import{d as v,e as x,g as H}from"./chunk-WXHQYYD5.js";function ee(t,e,n,i,s){let f=n.rows.filter(u=>{let d=i.get(u.temp_ref);return d!==void 0&&d!=="reject"});if(f.length===0)return{record:null,errors:null};let o={version:1,read_basis:e.latestHash,source:{source_id:n.source_id,source_cid:e.heads.get(n.source_id)??""},use_cases:f.map(u=>u.uc)},p=new Map;for(let u of f){let d=i.get(u.temp_ref);typeof d=="object"?p.set(u.temp_ref,{resolution:"edited",edit:d.edited}):p.set(u.temp_ref,{resolution:u.uc.matches_existing&&u.uc.changed?"edited":"approved"})}let g=Y(o,e,n.staged_source_cid);if(g.errors!==null)return{record:null,errors:g.errors};let r=g.proposal,l=o.source.source_cid?D(t,e,o.source.source_cid):null;if(l!==null){r=U(r,l);let u=G(r,B(l),e);if(u.length>0)return{record:null,errors:[{code:"HELD_CITES_STALE",detail:"the source moved after this plan staged \u2014 its quotes no longer verify against the current head; re-run kane-cli maintain reconcile to re-stage"},...u]}}let m=`held-${(e.latestHash??"root").slice(-12)}-${f.length}`;return N({contextDir:t,graph:e,proposal:r,proposalId:m,verdicts:p,by:s,autoName:!0})}function W(t,e,n=[]){let i=K(t,e),s=new Set,f=[],o=l=>{!l||s.has(l)||(s.add(l),f.push(y(t,l)))};for(let l of i.pairs)o(l.scenario),o(l.test);for(let[l,m]of i.verifies){o(l);for(let u of m)o(u)}if(n.length===0)return{stale_refs:f};let p=l=>`${String(l.props.source_id)}\0${String(l.props.anchor)}`,g=new Set;for(let{cid:l}of t.byLabel(v.USECASE))if(t.tipOf(l)===e)for(let m of t.edgesInto(l)){if(m.type!==x.DERIVES)continue;let u=m.props.claim;typeof u=="string"&&n.includes(u)&&g.add(p(m))}if(g.size===0)return{stale_refs:f};let r=new Set;for(let[l,m]of i.verifies)if(t.edgesInto(l).some(d=>d.type===x.DERIVES&&g.has(p(d)))){r.add(y(t,l));for(let d of m)r.add(y(t,d))}return{stale_refs:f,...r.size>0?{direct_refs:[...r]}:{}}}var q="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",te="suite untouched; graph updated";function M(t,e){return!t.superseded.has(e)&&t.trust.get(e)!=="archived"}function y(t,e,n=new Set){let i=t.nameOf.get(e);if(i!==void 0)return i;if(n.has(e))return e;n.add(e);for(let[s,f]of t.superseded){if(f!==e)continue;let o=y(t,s,n);if(o!==s)return o}return e}function C(t){return String(t).slice(0,19)}function A(t,e,n){let i=t.edgesFrom(e).find(s=>s.type===n);return i?t.tipOf(i.dst):null}function X(t,e){let n=t.nodeLabel.get(e);if(n===v.USECASE)return e;if(n===v.SCENARIO)return A(t,e,x.BELONGS_TO);if(n===v.AC){let i=A(t,e,x.SCOPED_TO);return i?t.nodeLabel.get(i)===v.USECASE?i:A(t,i,x.BELONGS_TO):null}if(n===v.TEST){let i=A(t,e,x.AUTOMATES);return i?A(t,i,x.BELONGS_TO):null}return null}function z(t,e){let n=[],i=new Map;for(let s of t.derivesInto(e))i.set(String(s.props.source_id),s);for(let[s,f]of i){let o=t.heads.get(s);if(o==null){n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source retired`);continue}if(o!==f.props.source_cid){let p=t.convChains.get(s)?.chain;if(p&&p.includes(String(f.props.source_cid)))continue;n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source head moved to ${C(o)}`)}}for(let s of t.edgesFrom(e))H(s.type)?.pin?.comparesTo==="dst_tip"&&t.superseded.has(s.dst)&&n.push(`${s.type} pin \u2192 ${y(t,s.dst)} \u2014 target superseded`);return n.join("; ")||"structural pin broken"}var ne=new Set([v.USECASE,v.SCENARIO,v.AC,v.TEST]);function $(t,e){return t.ref<e.ref?-1:t.ref>e.ref?1:0}function D(t,e,n){let i=j(t,e,n);return i===null?null:i.toString("utf8")}function se(t,e,n,i,s){let f=n.props.quote;if(typeof f=="string"&&f.length>0)return i.includes(f);let o=String(n.props.source_cid);s.has(o)||s.set(o,D(t,e,o));let p=s.get(o);if(p===null)return!1;let g=V(p,String(n.props.anchor));return g===null?!1:g.split(`
3
+ `).some(r=>r.trim().length>0&&i.includes(r.trim()))}function oe(t,e,n){let i=L(String(e.props.anchor));if(i?.kind!=="img-part")return!1;let f=(t.mediaOf(String(e.props.source_cid)).images??[]).find(r=>r.ref===i.ref),o=f?.blob;if(o===void 0)return!1;let p=t.mediaOf(n).images??[];if(p.some(r=>r.blob===o))return!0;let g=f?.appearance;return g!==void 0&&p.filter(r=>r.appearance===g).length===1}var J=128*1024,Q=64*1024;function re(t,e){let n=t.split(`
4
+ `),i=e.split(`
5
+ `),s=0;for(;s<n.length&&s<i.length&&n[s]===i[s];)s++;let f=n.length,o=i.length;for(;f>s&&o>s&&n[f-1]===i[o-1];)f--,o--;if(f===s&&o===s)return"";let p=n.slice(s,f),g=i.slice(s,o),l=ie(p,g,2e3),m=[];if(l===null)m.push(`@@ old L${s+1}-L${f} \u2192 new L${s+1}-L${o} @@`,...p.map(u=>`- ${u}`),...g.map(u=>`+ ${u}`));else{let u=l.map((a,h)=>a.op==="="?-1:h).filter(a=>a>=0),d=0;for(;d<u.length;){let a=d;for(;a+1<u.length&&u[a+1]-u[a]<=3;)a++;let h=Math.max(u[d]-1,0),R=Math.min(u[a]+1,l.length-1),b=l.slice(h,R+1),S=s+(b[0].ai??0)+1,_=s+(b[0].bi??0)+1,c=b.filter(E=>E.op!=="+").length,w=b.filter(E=>E.op!=="-").length;m.push(`@@ old L${S}-L${S+Math.max(c-1,0)} \u2192 new L${_}-L${_+Math.max(w-1,0)} @@`);for(let E of b)m.push(E.op==="="?` ${E.line}`:`${E.op} ${E.line}`);d=a+1}}return m.join(`
6
+ `)}function ie(t,e,n){let i=t.length,s=e.length,f=Math.min(i+s,n),o=new Map([[1,0]]),p=[],g=!1;for(let u=0;u<=f&&!g;u++){p.push(new Map(o));for(let d=-u;d<=u;d+=2){let a=d===-u||d!==u&&(o.get(d-1)??0)<(o.get(d+1)??0)?o.get(d+1)??0:(o.get(d-1)??0)+1,h=a-d;for(;a<i&&h<s&&t[a]===e[h];)a++,h++;if(o.set(d,a),a>=i&&h>=s){g=!0;break}}}if(!g)return null;let r=i,l=s,m=[];for(let u=p.length-1;u>0;u--){let d=p[u],a=r-l,h=a===-u||a!==u&&(d.get(a-1)??0)<(d.get(a+1)??0)?a+1:a-1,R=d.get(h)??0,b=R-h;for(;r>R&&l>b;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;u>0&&(r===R?(m.push({op:"+",line:e[l-1],ai:r,bi:l-1}),l--):(m.push({op:"-",line:t[r-1],ai:r-1,bi:l}),r--))}for(;r>0&&l>0;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;for(;r>0;)m.push({op:"-",line:t[r-1],ai:r-1,bi:0}),r--;for(;l>0;)m.push({op:"+",line:e[l-1],ai:0,bi:l-1}),l--;return m.reverse()}function ce(t){let e=Buffer.byteLength(t,"utf8");if(e<=J+Q)return{diff:t,truncated:!1};let n=Buffer.from(t,"utf8"),i=J;for(;i>0&&(n[i]&192)===128;)i--;let s=e-Q;for(;s<e&&(n[s]&192)===128;)s++;let f=n.subarray(0,i).toString("utf8"),o=n.subarray(s).toString("utf8");return{diff:`${f}
7
+ \u2026 [diff truncated: ${e-i-(e-s)} bytes omitted] \u2026
8
+ ${o}`,truncated:!0}}function ae(t,e){let n=k(t),i=n.heads.get(e);if(typeof i!="string")return null;let s=[];for(let d of I(t).records){let a=d.source_head_moves?.[e];a!==void 0&&a!==s[s.length-1]&&s.push(a)}let f=s.lastIndexOf(i),o=f>0?s[f-1]:null;if(typeof o!="string"||o===i)return null;let p=D(t,n,o),g=D(t,n,i);if(p===null||g===null)return null;let{diff:r,truncated:l}=ce(re(p,g)),m=new Set,u=[];for(let d of n.edgesFrom(o))d.type!==x.DERIVES||n.nodeLabel.get(d.dst)!==v.USECASE||m.has(d.dst)||(m.add(d.dst),u.push({id:d.dst,title:String(n.getNode(d.dst)?.content.title??"")}));return{source_id:e,old_head:o,new_head:i,diff:r,...l?{truncated:!0}:{},prior_ucs:u}}function de(t,e,n){let i=t.getNode(e)?.content??{},s=t.getNode(n)?.content??{},o=[...new Set([...Object.keys(i),...Object.keys(s)])].sort().filter(p=>JSON.stringify(i[p])!==JSON.stringify(s[p]));return o.length>0?`updated: ${o.join(", ")}`:"updated"}function le(t,e,n,i,s,f,o){let p=new Set((o?.rows??[]).map(a=>a.matched_cid).filter(a=>!!a)),g=[];for(let[a,h]of n.superseded)h===null||a===h||e.superseded.has(a)||n.nodeLabel.get(a)===v.USECASE&&g.push({kind:"MODIFY",ref:y(n,a),old_cid:a,new_cid:h,summary:de(n,a,h)});let r=f.map(a=>({kind:"ADD",ref:y(n,a),cid:a}));for(let a of o?.rows??[])a.kind==="MODIFY"&&a.matched_cid?g.push({kind:"MODIFY",ref:y(n,a.matched_cid),old_cid:a.matched_cid,new_cid:null,summary:`${a.why} (staged)`}):a.kind==="ADD"&&r.push({kind:"ADD",ref:a.title,cid:null});let l=[],m=D(t,n,s),u=new Map;for(let{cid:a}of n.byLabel(v.USECASE)){if(!M(n,a)||p.has(a))continue;let h=n.derivesInto(a),R=h.filter(_=>String(_.props.source_id)===i);R.length===0||R.some(_=>_.props.source_cid===s)||R.some(_=>{let c=String(_.props.anchor),w=L(c);return w?.kind==="img-whole"?!1:w?.kind==="img-part"?oe(n,_,s):m!==null&&se(t,n,_,m,u)})||h.some(_=>{let c=String(_.props.source_id);if(c===i)return!1;let w=n.heads.get(c);return w!=null})||l.push({kind:"ARCHIVE",ref:y(n,a),cid:a,why:`evidence decayed: no quote from ${i} relocates into @${C(s)}, no other live source, no fresh evidence this run`,impact:W(n,n.tipOf(a))})}let d=(a,h)=>a.ref<h.ref?-1:a.ref>h.ref?1:0;return[...g.sort(d),...r.sort(d),...l.sort(d)]}function Ee(t,e,n,i,s){let f=e.rows.find(d=>d.temp_ref===n);if(!f)return{ok:!1,message:`held item ${n} missing from the plan artifact`};let o=f,p=k(t);if(o.matched_cid){let d=p.tipOf(o.matched_cid);if(p.superseded.get(d)===null)return{ok:!1,message:`use-case for "${o.title}" was retired meanwhile \u2014 nothing to update`};d!==o.matched_cid&&(o={...o,matched_cid:d,uc:{...o.uc,matches_existing:{cid:d}}})}let g=s?{edited:s}:"approve",r=ee(t,p,{source_id:e.source_id,...e.staged_source_cid!==void 0?{staged_source_cid:e.staged_source_cid}:{},rows:[o]},new Map([[o.temp_ref,g]]),i);if(r.errors)return{ok:!1,message:r.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")};let l=k(t),m=o.matched_cid?l.tipOf(o.matched_cid):r.record?.nodes.find(d=>d.label==="usecase")?.cid??r.record?.review[0]?.id;return{ok:!0,ref:m?y(l,m):o.title,kind:o.kind}}async function Re(t,e,n,i={}){let s=k(t),f=s.heads.get(e)??null,o=new Set(s.staleList().filter(c=>c.state==="stale").map(c=>c.cid)),p=await n.reingest(e);if(p.status==="unchanged"&&!i.resumeHeld)return{source_id:e,changed:!1,head:{status:p.status,before:f,after:p.cid},note:`nothing to reconcile \u2014 ${e} is unchanged`,skipped_arms:q,changeset:[],rows:[]};let g=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await n.reextract(e),r=k(t),l=g.minted.map(c=>{let w=y(r,c);return{kind:"ADD",origin:"content-change",ref:w,reason:`new use-case extracted from ${e}`,provenance:`extraction commit \u2014 DERIVES ${e} @ ${C(p.cid)}`,action:`kane-cli design tests --use-case ${w}`}}),m=r.staleList().filter(c=>c.state==="stale"&&!o.has(c.cid)&&M(r,c.cid)).map(c=>c.cid),u=m.map(c=>{let w=y(r,c),E=ne.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:z(r,c),action:E?`kane-cli maintain evolve ${w}`:`kane-cli design explain ${w}`}}),d=[],a=[];for(let c of g.held?.rows??[])if(c.kind==="ADD")d.push({kind:"ADD",origin:"content-change",ref:c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit + design"});else{let w=c.matched_cid?r.tipOf(c.matched_cid):null,E=w?r.getNode(w)?.content.criteria??[]:[],T=(c.uc.updated?.criteria??[]).map(O=>typeof O=="string"?O:O.text),Z=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?W(r,w,Z):void 0;a.push({kind:"MODIFY",origin:"content-change",ref:c.matched_cid?y(r,c.matched_cid):c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...P?{impact:P}:{}})}let h=new Set;for(let c of[...g.minted,...g.matched])h.add(r.tipOf(c));for(let c of g.held?.rows??[])c.matched_cid&&h.add(r.tipOf(c.matched_cid));for(let c of m){let w=X(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await F(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=X(r,w.tip);!E||!h.has(r.tipOf(E))||R.push({kind:"ADD",origin:"content-change",ref:c.ref,reason:c.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${y(r,E)}`,action:c.ready_command})}let b=[];for(let{cid:c}of r.byLabel(v.USECASE))M(r,c)&&r.stale(c)==="orphaned"&&b.push({kind:"REMOVE",ref:y(r,c),reason:"orphaned \u2014 no live source evidences this use-case",provenance:z(r,c),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,_=[...l.sort($),...d.sort($),...R.sort($),...a.sort($),...u.sort($),...b.sort($)].filter(c=>{let w=`${c.kind}\0${c.ref}`;return S.has(w)?!1:(S.add(w),!0)});return{source_id:e,changed:!0,head:{status:p.status,before:f,after:p.cid},note:te,skipped_arms:q,changeset:le(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function ye(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-EX72IEQT.js"),{convertPdf:s}=await import("./pdf-convert-OZIRUADA.js"),{convertDocx:f}=await import("./docx-convert-JMUMT5C4.js"),o=await i({contextDir:t,filePath:e,asId:n,converters:{pdf:s,docx:f}});return{status:o.status,cid:o.cid}}}function be(t,e,n,i){return async()=>{let f=(i??(await import("./dispatch-SE5GY3Z2.js")).findProvider)(e);if(!f)throw new Error(`the remote re-ingest failed \u2014 no provider matches '${e}'`);let o=await f.ingest(e,void 0,{out:n.out,err:n.err,confirm:async()=>!0,isTTY:!1},t,void 0);if(o.code!==0||!o.result)throw new Error("the remote re-ingest failed \u2014 fix the reported problem and re-run");return{status:o.result.status,cid:o.result.source_cid}}}function xe(t,e={}){return async n=>{let i=[],[{runExtract:s},{resolveAgentAuthEnv:f},{runAgent:o},{preflightTurn:p}]=await Promise.all([import("./run-URPGHOQM.js"),import("./spawner-J67QR4QP.js"),import("./bridge-5Z3BIB77.js"),import("./turn-preflight-JGYT7LXP.js")]),g=await f(),r=new Set(k(t).byLabel(v.USECASE).map(S=>S.cid)),l=ae(t,n)??void 0,m=0,u=await s({mode:"override",source:n,...l?{changeContext:l}:{}},{contextDir:t,agent:o,preflightTurn:()=>p(g),ask:async()=>[],review:async S=>{if(!e.stage)return new Map(S.map(c=>[c.temp_ref,{resolution:c.matches_existing&&c.changed?"edited":"skipped"}]));let _=new Map;for(let c of S){if(c.matches_existing&&!c.changed){_.set(c.temp_ref,{resolution:"skipped"});continue}i.push({kind:c.matches_existing?"MODIFY":"ADD",temp_ref:c.temp_ref,title:c.title,why:c.matches_existing?`updated: ${Object.keys(c.updated??{}).join(", ")||"content"}`:`newly extracted from ${n}`,...c.matches_existing?{matched_cid:c.matches_existing.cid,updated:c.updated}:{},uc:c}),_.set(c.temp_ref,{resolution:"rejected"})}return _},confirmStale:async()=>!1,out:S=>e.hostOut?.(S),progress:S=>e.hostProgress?.(S),emit:S=>{S.type==="commit"&&typeof S.assumed=="number"&&(m+=S.assumed),e.hostEmit?.(S)},isTTY:!1,auth:g});if(u!==0)throw new Error(`reconcile: re-extract of ${n} failed (exit ${u})`);let d=k(t),a=d.heads.get(n),h=[],R=[];if(typeof a=="string"){let S=new Set;for(let _ of d.edgesFrom(a))_.type!==x.DERIVES||d.nodeLabel.get(_.dst)!==v.USECASE||S.has(_.dst)||(S.add(_.dst),!(e.stage&&d.trust.get(_.dst)==="archived")&&(r.has(_.dst)?R:h).push(_.dst))}let b=k(t).heads.get(n);return{minted:h,matched:R,defaultsTaken:m,...e.stage?{held:{source_id:n,...b!=null?{staged_source_cid:b}:{},rows:i}}:{}}}}export{ee as a,W as b,q as c,te as d,M as e,X as f,ne as g,re as h,ce as i,ae as j,Ee as k,Re as l,ye as m,be as n,xe as o};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as _e}from"./chunk-AM5S4KG4.js";import{a as le,b as pe,d as me,e as he}from"./chunk-BB2W35TW.js";import{a as ge}from"./chunk-DNNZ353O.js";import{c as de,e as ae,l as fe,w as ue}from"./chunk-3STZLM5J.js";import{a as oe,b as Y}from"./chunk-L4JIMNKW.js";import{f as re,i as ce}from"./chunk-M7WQM4UA.js";import{d as g,e as p,f as ne,g as se,h as ie}from"./chunk-5YPBPZUR.js";var x=i=>({record:null,errors:i,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function D(i){return i.toLowerCase().trim().replace(/\s+/g," ")}function $e(i,I){let t=i.resolve(I);if(!t||i.nodeLabel.get(t.cid)!==g.USECASE||t.superseded)return[];let m=new Set;for(let{cid:f}of i.byLabel(g.SCENARIO))if(!i.superseded.has(f)&&i.edgesFrom(f).some(k=>k.type===p.BELONGS_TO&&i.tipOf(k.dst)===t.cid)){m.add(f);for(let k of i.edgesInto(f))k.type!==p.AUTOMATES||i.superseded.has(k.src)||m.add(k.src)}return[...m]}function De(i){let{contextDir:I,graph:t,sections:m,by:f}=i,k=i.engine??"design@1",K=re(I);if(t.latestHash!==K)return x([{code:"STALE_BASIS",detail:`graph opened at ${String(t.latestHash)} but chain head is ${String(K)} \u2014 re-open and retry`}]);let L=t.resolve(i.ucRef);if(!L||t.nodeLabel.get(L.cid)!==g.USECASE||L.superseded)return x([{code:"UNKNOWN_UC",detail:`${i.ucRef} is not a live use-case`}]);let E=L.cid,_=[],J=/^design@(\d+)$/.exec(i.templateVersion??""),be=J!==null&&Number.parseInt(J[1],10)>=3,W=new Map,Ee=(e,s)=>{let n=W.get(e.source_cid);if(n===void 0){let o=ge(i.contextDir,t,e.source_cid);n=o?_e(o.toString("utf8")):null,W.set(e.source_cid,n)}if(n===null)return _.push({code:"CITE_UNVERIFIED",detail:`${s}: source ${e.source_id} (${e.source_cid.slice(0,19)}) has no citable text to verify against`}),!1;let c=de(t.mediaOf(e.source_cid),e,n);if(c.length>0){for(let o of c)_.push({code:"CITE_UNVERIFIED",detail:`${s}: ${o.code}: ${o.detail}`});return!1}return!0},T=[],F=[],C=[],j=[],q=[],S={},N={},G={},R=[],P=[],Q=new Set,X=[],B=new Set,A=new Set,M=[];{let e=i.forceScope??(i.force?$e(t,i.ucRef):[]),s=new Set;i.sections.scenarios?.length&&s.add(g.SCENARIO),i.sections.tests?.length&&s.add(g.TEST);for(let n of e)t.superseded.has(n)||(s.has(t.nodeLabel.get(n)??"")?A.add(n):M.push(n))}let w=new Set,V=e=>!t.superseded.has(e)&&(!A.has(e)||w.has(e)),v=(e,s,n)=>{if(S[e])return S[e];let c=t.resolve(e),o=c?V(c.cid)?c.cid:t.tipOf(c.cid):null;return!c||!o||!V(o)?(_.push({code:"UNKNOWN_REF",detail:`${s}: '${e}' is neither in this payload nor a live committed node`}),null):n&&t.nodeLabel.get(o)!==n?(_.push({code:"ILLEGAL_EDGE",detail:`${s}: '${e}' is a ${t.nodeLabel.get(o)}, expected ${n}`}),null):o},Se=(e,s,n,c)=>{if(t.nameOf.has(s)){N[c]=t.nameOf.get(s);return}let o=ue(e,h=>Q.has(h),t.names.keys());o!==null&&(Q.add(o),j.push({cid:s,slug:o,by:f}),N[c]=o)},U=(e,s,n,c)=>{for(let h of ne(e,n))_.push({code:h.code,detail:`${s}: ${h.detail}`});let o=oe(e,n);return t.hasNode(o)&&!t.superseded.has(o)?(A.has(o)&&w.add(o),S[s]=o,o):(T.push({cid:o,label:e,content:n}),S[s]=o,Se(e,o,c,s),o)},$=(e,s,n,c,o)=>{let h=Y(e,s,n,c);if(t.edgesFrom(s).some(r=>r.ecid===h&&!t.superseded.has(r.ecid))){e===p.AUTOMATES&&B.add(n);return}let O=t.nodeLabel.get(s)??T.find(r=>r.cid===s)?.label??"(unknown)",u=t.nodeLabel.get(n)??T.find(r=>r.cid===n)?.label??"(unknown)";for(let r of ie(e,O,u,c))_.push({code:r.code,detail:`${o}: ${r.detail}`});let l=ae(t,e,s,n,X);if(l){_.push({code:l.code,detail:`${o}: ${l.detail}`});return}if(e===p.AUTOMATES){if(B.has(n)){_.push({code:"CARDINALITY_VIOLATION",detail:`${o}: two automates onto ${n} in one record (strict 1:1)`});return}if(B.add(n),!A.has(n)||w.has(n)){let r=b=>A.has(b)&&!w.has(b);if(t.edgesFrom(s).some(b=>b.type===p.AUTOMATES&&b.dst!==n&&!t.superseded.has(b.dst)&&!r(b.dst))&&t.hasNode(s)){_.push({code:"CARDINALITY_VIOLATION",detail:`${o}: automates from ${s} already has a live edge \u2014 supersede it first`});return}if(t.edgesInto(n).some(b=>b.type===p.AUTOMATES&&b.src!==s&&!t.superseded.has(b.src)&&!r(b.src))){_.push({code:"CARDINALITY_VIOLATION",detail:`${o}: automates onto ${n} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}F.push({ecid:Y(e,s,n,c),type:e,src:s,dst:n,props:c}),X.push({src:s,dst:n,type:e})},z=new Set;for(let e of m.gaps??[]){let s=e.temp_ref??e.ref??"gap",n=e.question;if(!n||typeof n!="object"||!n.header||!Array.isArray(n.options)||n.options.length===0||!Number.isInteger(n.recommended_index)){_.push({code:"GAP_QUESTION_INCOMPLETE",detail:`${s}: design gaps carry a full ranked question object (header/options/recommended_index)`});continue}e.kind==="budget-evicted"&&e.ref&&z.add(e.ref);let c={kind:e.kind,question:n,derived:!0,uc:E,...e.risk?{risk:e.risk}:{},...e.risk_rationale?{risk_rationale:e.risk_rationale}:{},...e.text?{text:e.text}:{},...e.ref?{ref:e.ref}:{}};U(g.GAP,s,c,String(n.header))}let Z=new Map;for(let{cid:e,content:s}of t.byLabel(g.SCENARIO))V(e)&&t.edgesFrom(e).some(n=>n.type===p.BELONGS_TO&&t.tipOf(n.dst)===E)&&Z.set(D(String(s.title??"")),e);for(let e of m.scenarios??[]){let s=Z.get(D(e.title));if(s){_.push({code:"DUPLICATE_SCENARIO",detail:`${e.temp_ref}: '${e.title}' duplicates live scenario ${t.nameOf.get(s)??s} \u2014 exercise/link it instead (reuse before minting)`});continue}let n={title:e.title,intent:e.intent,case_type:e.case_type,derived:!0,...e.technique_notes?{technique_notes:e.technique_notes}:{},...e.description?{description:e.description}:{},...e.parameters?{parameters:e.parameters}:{},...e.tags?{tags:e.tags}:{}};U(g.SCENARIO,e.temp_ref,n,e.title)}for(let e of m.scenarios??[]){let s=S[e.temp_ref];if(s){$(p.BELONGS_TO,s,E,{},e.temp_ref);for(let n of e.depends_on??[]){let c=v(n,`${e.temp_ref}.depends_on`,g.SCENARIO);c&&$(p.DEPENDS_ON,s,c,{},`${e.temp_ref}.depends_on`)}}}for(let e of m.acs??[]){let s={text:e.text,kind:e.kind,risk:e.risk,derived:!0,...e.expected_answer?{expected_answer:e.expected_answer}:{},...e.measurable!==void 0?{measurable:e.measurable}:{}},n=U(g.AC,e.temp_ref,s,e.text);if(!n)continue;let c=e.scope?.type==="scenario"&&e.scope.ref?v(e.scope.ref,`${e.temp_ref}.scope`,g.SCENARIO):E;c&&!t.edgesFrom(n).some(o=>o.type===p.SCOPED_TO&&!t.superseded.has(o.ecid))&&$(p.SCOPED_TO,n,c,{},`${e.temp_ref}.scope`);for(let o of e.cites??[]){if(be&&!Ee(o,`${e.temp_ref}.cite`))continue;let h={source_id:o.source_id,source_cid:o.source_cid,anchor:o.anchor,...o.quote?{quote:o.quote}:{}};$(p.DERIVES,o.source_cid,n,h,`${e.temp_ref}.cite`)}}for(let e of m.exercises??[]){let s=v(e.scenario,"exercises.scenario",g.SCENARIO),n=v(e.ac,"exercises.ac",g.AC);s&&n&&$(p.EXERCISES,s,n,{},`exercises ${e.scenario}\u2192${e.ac}`)}for(let e of m.scoped_to_repoints??[]){let s=v(e.ac,"scoped_to_repoints.ac",g.AC),n=v(e.to,"scoped_to_repoints.to");if(!s||!n)continue;let c=t.edgesFrom(s).find(o=>o.type===p.SCOPED_TO&&!t.superseded.has(o.ecid));c&&C.push({kind:"edge",ecid:c.ecid,reason:`re-scoped to ${e.to} by ${f.id}`,by:f}),$(p.SCOPED_TO,s,n,{},`scoped_to_repoints ${e.ac}`)}let ee=new Map;if(i.finalizeTestBody)for(let[e,s]of t.nameOf)ee.set(t.tipOf(e),s);let te=e=>t.nameOf.get(e)??ee.get(t.tipOf(e))??null,ye=e=>{let s=S[e];if(s)return N[e]??te(s);if(t.names.has(e))return t.resolve(e)?e:null;let n=t.resolve(e);return n?te(t.tipOf(n.cid)):null};for(let e of m.tests??[]){for(let u of e.reuses??[])z.has(u)&&_.push({code:"REUSES_EVICTED",detail:`${e.temp_ref}: reuses '${u}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import`});let s=e.test_md_blob,n=e.definitionId,c=e.objectives_blob;if(i.finalizeTestBody){let u;try{u=i.finalizeTestBody({temp_ref:e.temp_ref,test_md_blob:e.test_md_blob,verifies:e.verifies,reuses:e.reuses??[]},ye)}catch(l){return x([{code:"FINALIZE_BODY",detail:`${e.temp_ref}: ${l instanceof Error?l.message:String(l)}`}])}u&&(s=u.test_md_blob,n=u.definitionId,c=u.objectives_blob??c,G[e.temp_ref]=n)}let o={title:e.title,check:e.check,definitionId:n,derived:!0,...e.config?{config:e.config}:{},...s?{test_md_blob:s}:{},...c?{objectives_blob:c}:{},...e.surface_required!==void 0?{surface_required:e.surface_required}:{}},h=U(g.TEST,e.temp_ref,o,e.title);if(!h)continue;let O=v(e.automates,`${e.temp_ref}.automates`,g.SCENARIO);O&&$(p.AUTOMATES,h,O,{},`${e.temp_ref}.automates`);for(let u of e.verifies){let l=v(u,`${e.temp_ref}.verifies`,g.AC);l&&$(p.VERIFIES,h,l,{},`${e.temp_ref}.verifies`)}for(let u of e.reuses??[]){if(z.has(u))continue;let l=v(u,`${e.temp_ref}.reuses`,g.TEST);l&&$(p.REUSES,h,l,{},`${e.temp_ref}.reuses`)}for(let u of e.verifies){let l=S[u]??t.resolve(u)?.cid;l&&(t.trust.get(l)??"derived")==="derived"&&!T.some(r=>r.cid===l)?R.push(`${e.temp_ref}: verifies ${u} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`):l&&S[u]===l&&(m.acs??[]).some(r=>r.temp_ref===u)&&R.push(`${e.temp_ref}: verifies ${u} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`)}if(e.verifies.length>1){let u=e.check?.verified_against;R.push(`${e.temp_ref}: verifies ${e.verifies.length} ACs but machine-asserts only 1 (check.verified_against=${u!=null?String(u):"?"}) \u2014 the rest ride prose only`)}}let H=[];{let e=(r,d)=>`${r??""}\0${D(String(d??""))}`,s=(r,d)=>i.reason?`${i.reason} \u2014 evolve by ${f.id}${d?` (${d})`:""}`:r,n=new Map;for(let r of T){if(r.label!==g.SCENARIO&&r.label!==g.TEST)continue;let d=e(r.label,r.content.title);n.set(d,[...n.get(d)??[],r.cid])}let c=new Map;for(let r of A){if(w.has(r))continue;let d=e(t.nodeLabel.get(r),t.getNode(r)?.content.title);c.set(d,[...c.get(d)??[],r])}for(let[r,d]of c){let a=n.get(r)??[],b=d.length===1&&a.length===1;for(let y of d)b?(C.push({kind:"node",old:y,new:a[0],reason:s(`--force redesign of ${i.ucRef} by ${f.id} (title-matched successor)`,"title-matched successor"),by:f}),H.push({old:y,next:a[0]})):C.push({kind:"node",old:y,new:null,reason:s(`--force redesign of ${i.ucRef} by ${f.id}`),by:f}),P.push(y)}let o=r=>t.edgesFrom(r).some(d=>d.type!==p.SCOPED_TO?!1:d.dst===E||t.tipOf(d.dst)===E?!0:t.nodeLabel.get(d.dst)===g.SCENARIO&&t.edgesFrom(d.dst).some(a=>a.type===p.BELONGS_TO&&t.tipOf(a.dst)===E)),h=new Map;for(let{cid:r,content:d}of t.byLabel(g.AC)){if(t.superseded.has(r)||!o(r))continue;let a=D(String(d.text??""));h.set(a,[...h.get(a)??[],r])}let O=new Map;for(let r of T){if(r.label!==g.AC)continue;let d=D(String(r.content.text??""));O.set(d,[...O.get(d)??[],r.cid])}for(let[r,d]of h){let a=O.get(r)??[];d.length!==1||a.length!==1||(C.push({kind:"node",old:d[0],new:a[0],reason:s(`AC re-emitted with changed content by ${f.id} (text-matched successor)`,"AC text-matched successor"),by:f}),H.push({old:d[0],next:a[0]}),P.push(d[0]))}let u=new Set(P),l=new Set;for(let r of C)r.kind==="edge"&&l.add(r.ecid);for(let{old:r,next:d}of H)for(let a of t.edgesInto(r))se(a.type)?.pin?.comparesTo!=="dst_tip"||t.superseded.has(a.src)||u.has(a.src)||l.has(a.ecid)||(C.push({kind:"edge",ecid:a.ecid,reason:`re-blessed onto ${d} (redirect successor of ${r}) by ${f.id}`,by:f}),l.add(a.ecid),F.some(y=>y.type===a.type&&y.src===a.src&&y.dst===d)||t.edgesFrom(a.src).some(y=>y.type===a.type&&y.dst===d))||a.type===p.AUTOMATES&&B.has(d)||$(a.type,a.src,d,a.props,`rebless ${a.type} from ${t.nameOf.get(a.src)??a.src}`)}if(_.length>0)return x(_);if(T.length===0&&F.length===0&&C.length===0&&q.length===0)return Object.keys(S).length>0?(R.push("everything in this phase is already current \u2014 nothing re-committed"),{record:null,errors:null,minted:S,logicalIds:N,superseded:[],warnings:R,finalizedTests:G,...i.force||i.forceScope?{forceScopeRemaining:M}:{}}):x([{code:"EMPTY_DESIGN",detail:"finalize_design produced nothing to commit"}]);if(i.generationTicket){let e=me(t,i.generationTicket);if(e!==null)return x([e])}return{record:ce(I,{ts:new Date().toISOString(),proposal_id:null,nodes:T,edges:F,review:[],supersessions:C,source_head_moves:{},...j.length>0?{names:j}:{},...(()=>{for(let e of m.judgements??[]){let s=e.target?S[e.target]??t.resolve(e.target)?.cid??E:E;q.push({about:s,rationale:`[${e.kind}] ${e.rationale}`,by:f})}return q.length>0?{judgements:q}:{}})(),design_of:{uc_cid:E,engine:k},...i.generationTicket?{design_generation:he(i.generationTicket,E,f)}:{},...i.eventIds&&i.eventIds.length>0?{event_ids:i.eventIds}:i.sid?{event_ids:fe(t,i.sid,"design",1)}:{},...i.sid?{sid:i.sid}:{},...i.phase?{design_phase:{uc_root:le(t,E),generation:i.generationTicket?.next_gen??pe(t,i.ucRef)?.gen??1,phase:i.phase,completeness:i.phaseCompleteness??"complete"}}:{}},{expectPrev:t.latestHash}).record,errors:null,minted:S,logicalIds:N,superseded:P,warnings:R,finalizedTests:G,...i.force||i.forceScope?{forceScopeRemaining:M}:{}}}function Le(i,I){let t=[];for(let m of i){let f=m.design_phase;!f||typeof f!="object"||f.uc_root===I&&(typeof f.phase!="string"||typeof f.generation!="number"||t.push({phase:f.phase,generation:f.generation,seq:m.seq,completeness:f.completeness==="partial"?"partial":"complete"}))}return t.sort((m,f)=>m.seq-f.seq)}export{$e as a,De as b,Le as c};
2
+ import{a as _e}from"./chunk-AFPHLUQ5.js";import{a as le,b as pe,d as me,e as he}from"./chunk-BB2W35TW.js";import{a as ge}from"./chunk-DNNZ353O.js";import{c as de,f as ae,m as fe,z as ue}from"./chunk-TH47OOBV.js";import{a as oe,b as Y}from"./chunk-CUM23TLF.js";import{f as re,i as ce}from"./chunk-DUAXZYAD.js";import{d as g,e as p,f as ne,g as se,h as ie}from"./chunk-WXHQYYD5.js";var x=i=>({record:null,errors:i,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function D(i){return i.toLowerCase().trim().replace(/\s+/g," ")}function $e(i,I){let t=i.resolve(I);if(!t||i.nodeLabel.get(t.cid)!==g.USECASE||t.superseded)return[];let m=new Set;for(let{cid:f}of i.byLabel(g.SCENARIO))if(!i.superseded.has(f)&&i.edgesFrom(f).some(k=>k.type===p.BELONGS_TO&&i.tipOf(k.dst)===t.cid)){m.add(f);for(let k of i.edgesInto(f))k.type!==p.AUTOMATES||i.superseded.has(k.src)||m.add(k.src)}return[...m]}function De(i){let{contextDir:I,graph:t,sections:m,by:f}=i,k=i.engine??"design@1",K=re(I);if(t.latestHash!==K)return x([{code:"STALE_BASIS",detail:`graph opened at ${String(t.latestHash)} but chain head is ${String(K)} \u2014 re-open and retry`}]);let L=t.resolve(i.ucRef);if(!L||t.nodeLabel.get(L.cid)!==g.USECASE||L.superseded)return x([{code:"UNKNOWN_UC",detail:`${i.ucRef} is not a live use-case`}]);let E=L.cid,_=[],J=/^design@(\d+)$/.exec(i.templateVersion??""),be=J!==null&&Number.parseInt(J[1],10)>=3,W=new Map,Ee=(e,s)=>{let n=W.get(e.source_cid);if(n===void 0){let o=ge(i.contextDir,t,e.source_cid);n=o?_e(o.toString("utf8")):null,W.set(e.source_cid,n)}if(n===null)return _.push({code:"CITE_UNVERIFIED",detail:`${s}: source ${e.source_id} (${e.source_cid.slice(0,19)}) has no citable text to verify against`}),!1;let c=de(t.mediaOf(e.source_cid),e,n);if(c.length>0){for(let o of c)_.push({code:"CITE_UNVERIFIED",detail:`${s}: ${o.code}: ${o.detail}`});return!1}return!0},T=[],F=[],C=[],j=[],q=[],S={},N={},G={},R=[],P=[],Q=new Set,X=[],B=new Set,A=new Set,M=[];{let e=i.forceScope??(i.force?$e(t,i.ucRef):[]),s=new Set;i.sections.scenarios?.length&&s.add(g.SCENARIO),i.sections.tests?.length&&s.add(g.TEST);for(let n of e)t.superseded.has(n)||(s.has(t.nodeLabel.get(n)??"")?A.add(n):M.push(n))}let w=new Set,V=e=>!t.superseded.has(e)&&(!A.has(e)||w.has(e)),v=(e,s,n)=>{if(S[e])return S[e];let c=t.resolve(e),o=c?V(c.cid)?c.cid:t.tipOf(c.cid):null;return!c||!o||!V(o)?(_.push({code:"UNKNOWN_REF",detail:`${s}: '${e}' is neither in this payload nor a live committed node`}),null):n&&t.nodeLabel.get(o)!==n?(_.push({code:"ILLEGAL_EDGE",detail:`${s}: '${e}' is a ${t.nodeLabel.get(o)}, expected ${n}`}),null):o},Se=(e,s,n,c)=>{if(t.nameOf.has(s)){N[c]=t.nameOf.get(s);return}let o=ue(e,h=>Q.has(h),t.names.keys());o!==null&&(Q.add(o),j.push({cid:s,slug:o,by:f}),N[c]=o)},U=(e,s,n,c)=>{for(let h of ne(e,n))_.push({code:h.code,detail:`${s}: ${h.detail}`});let o=oe(e,n);return t.hasNode(o)&&!t.superseded.has(o)?(A.has(o)&&w.add(o),S[s]=o,o):(T.push({cid:o,label:e,content:n}),S[s]=o,Se(e,o,c,s),o)},$=(e,s,n,c,o)=>{let h=Y(e,s,n,c);if(t.edgesFrom(s).some(r=>r.ecid===h&&!t.superseded.has(r.ecid))){e===p.AUTOMATES&&B.add(n);return}let O=t.nodeLabel.get(s)??T.find(r=>r.cid===s)?.label??"(unknown)",u=t.nodeLabel.get(n)??T.find(r=>r.cid===n)?.label??"(unknown)";for(let r of ie(e,O,u,c))_.push({code:r.code,detail:`${o}: ${r.detail}`});let l=ae(t,e,s,n,X);if(l){_.push({code:l.code,detail:`${o}: ${l.detail}`});return}if(e===p.AUTOMATES){if(B.has(n)){_.push({code:"CARDINALITY_VIOLATION",detail:`${o}: two automates onto ${n} in one record (strict 1:1)`});return}if(B.add(n),!A.has(n)||w.has(n)){let r=b=>A.has(b)&&!w.has(b);if(t.edgesFrom(s).some(b=>b.type===p.AUTOMATES&&b.dst!==n&&!t.superseded.has(b.dst)&&!r(b.dst))&&t.hasNode(s)){_.push({code:"CARDINALITY_VIOLATION",detail:`${o}: automates from ${s} already has a live edge \u2014 supersede it first`});return}if(t.edgesInto(n).some(b=>b.type===p.AUTOMATES&&b.src!==s&&!t.superseded.has(b.src)&&!r(b.src))){_.push({code:"CARDINALITY_VIOLATION",detail:`${o}: automates onto ${n} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}F.push({ecid:Y(e,s,n,c),type:e,src:s,dst:n,props:c}),X.push({src:s,dst:n,type:e})},z=new Set;for(let e of m.gaps??[]){let s=e.temp_ref??e.ref??"gap",n=e.question;if(!n||typeof n!="object"||!n.header||!Array.isArray(n.options)||n.options.length===0||!Number.isInteger(n.recommended_index)){_.push({code:"GAP_QUESTION_INCOMPLETE",detail:`${s}: design gaps carry a full ranked question object (header/options/recommended_index)`});continue}e.kind==="budget-evicted"&&e.ref&&z.add(e.ref);let c={kind:e.kind,question:n,derived:!0,uc:E,...e.risk?{risk:e.risk}:{},...e.risk_rationale?{risk_rationale:e.risk_rationale}:{},...e.text?{text:e.text}:{},...e.ref?{ref:e.ref}:{}};U(g.GAP,s,c,String(n.header))}let Z=new Map;for(let{cid:e,content:s}of t.byLabel(g.SCENARIO))V(e)&&t.edgesFrom(e).some(n=>n.type===p.BELONGS_TO&&t.tipOf(n.dst)===E)&&Z.set(D(String(s.title??"")),e);for(let e of m.scenarios??[]){let s=Z.get(D(e.title));if(s){_.push({code:"DUPLICATE_SCENARIO",detail:`${e.temp_ref}: '${e.title}' duplicates live scenario ${t.nameOf.get(s)??s} \u2014 exercise/link it instead (reuse before minting)`});continue}let n={title:e.title,intent:e.intent,case_type:e.case_type,derived:!0,...e.technique_notes?{technique_notes:e.technique_notes}:{},...e.description?{description:e.description}:{},...e.parameters?{parameters:e.parameters}:{},...e.tags?{tags:e.tags}:{}};U(g.SCENARIO,e.temp_ref,n,e.title)}for(let e of m.scenarios??[]){let s=S[e.temp_ref];if(s){$(p.BELONGS_TO,s,E,{},e.temp_ref);for(let n of e.depends_on??[]){let c=v(n,`${e.temp_ref}.depends_on`,g.SCENARIO);c&&$(p.DEPENDS_ON,s,c,{},`${e.temp_ref}.depends_on`)}}}for(let e of m.acs??[]){let s={text:e.text,kind:e.kind,risk:e.risk,derived:!0,...e.expected_answer?{expected_answer:e.expected_answer}:{},...e.measurable!==void 0?{measurable:e.measurable}:{}},n=U(g.AC,e.temp_ref,s,e.text);if(!n)continue;let c=e.scope?.type==="scenario"&&e.scope.ref?v(e.scope.ref,`${e.temp_ref}.scope`,g.SCENARIO):E;c&&!t.edgesFrom(n).some(o=>o.type===p.SCOPED_TO&&!t.superseded.has(o.ecid))&&$(p.SCOPED_TO,n,c,{},`${e.temp_ref}.scope`);for(let o of e.cites??[]){if(be&&!Ee(o,`${e.temp_ref}.cite`))continue;let h={source_id:o.source_id,source_cid:o.source_cid,anchor:o.anchor,...o.quote?{quote:o.quote}:{}};$(p.DERIVES,o.source_cid,n,h,`${e.temp_ref}.cite`)}}for(let e of m.exercises??[]){let s=v(e.scenario,"exercises.scenario",g.SCENARIO),n=v(e.ac,"exercises.ac",g.AC);s&&n&&$(p.EXERCISES,s,n,{},`exercises ${e.scenario}\u2192${e.ac}`)}for(let e of m.scoped_to_repoints??[]){let s=v(e.ac,"scoped_to_repoints.ac",g.AC),n=v(e.to,"scoped_to_repoints.to");if(!s||!n)continue;let c=t.edgesFrom(s).find(o=>o.type===p.SCOPED_TO&&!t.superseded.has(o.ecid));c&&C.push({kind:"edge",ecid:c.ecid,reason:`re-scoped to ${e.to} by ${f.id}`,by:f}),$(p.SCOPED_TO,s,n,{},`scoped_to_repoints ${e.ac}`)}let ee=new Map;if(i.finalizeTestBody)for(let[e,s]of t.nameOf)ee.set(t.tipOf(e),s);let te=e=>t.nameOf.get(e)??ee.get(t.tipOf(e))??null,ye=e=>{let s=S[e];if(s)return N[e]??te(s);if(t.names.has(e))return t.resolve(e)?e:null;let n=t.resolve(e);return n?te(t.tipOf(n.cid)):null};for(let e of m.tests??[]){for(let u of e.reuses??[])z.has(u)&&_.push({code:"REUSES_EVICTED",detail:`${e.temp_ref}: reuses '${u}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import`});let s=e.test_md_blob,n=e.definitionId,c=e.objectives_blob;if(i.finalizeTestBody){let u;try{u=i.finalizeTestBody({temp_ref:e.temp_ref,test_md_blob:e.test_md_blob,verifies:e.verifies,reuses:e.reuses??[]},ye)}catch(l){return x([{code:"FINALIZE_BODY",detail:`${e.temp_ref}: ${l instanceof Error?l.message:String(l)}`}])}u&&(s=u.test_md_blob,n=u.definitionId,c=u.objectives_blob??c,G[e.temp_ref]=n)}let o={title:e.title,check:e.check,definitionId:n,derived:!0,...e.config?{config:e.config}:{},...s?{test_md_blob:s}:{},...c?{objectives_blob:c}:{},...e.surface_required!==void 0?{surface_required:e.surface_required}:{}},h=U(g.TEST,e.temp_ref,o,e.title);if(!h)continue;let O=v(e.automates,`${e.temp_ref}.automates`,g.SCENARIO);O&&$(p.AUTOMATES,h,O,{},`${e.temp_ref}.automates`);for(let u of e.verifies){let l=v(u,`${e.temp_ref}.verifies`,g.AC);l&&$(p.VERIFIES,h,l,{},`${e.temp_ref}.verifies`)}for(let u of e.reuses??[]){if(z.has(u))continue;let l=v(u,`${e.temp_ref}.reuses`,g.TEST);l&&$(p.REUSES,h,l,{},`${e.temp_ref}.reuses`)}for(let u of e.verifies){let l=S[u]??t.resolve(u)?.cid;l&&(t.trust.get(l)??"derived")==="derived"&&!T.some(r=>r.cid===l)?R.push(`${e.temp_ref}: verifies ${u} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`):l&&S[u]===l&&(m.acs??[]).some(r=>r.temp_ref===u)&&R.push(`${e.temp_ref}: verifies ${u} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`)}if(e.verifies.length>1){let u=e.check?.verified_against;R.push(`${e.temp_ref}: verifies ${e.verifies.length} ACs but machine-asserts only 1 (check.verified_against=${u!=null?String(u):"?"}) \u2014 the rest ride prose only`)}}let H=[];{let e=(r,d)=>`${r??""}\0${D(String(d??""))}`,s=(r,d)=>i.reason?`${i.reason} \u2014 evolve by ${f.id}${d?` (${d})`:""}`:r,n=new Map;for(let r of T){if(r.label!==g.SCENARIO&&r.label!==g.TEST)continue;let d=e(r.label,r.content.title);n.set(d,[...n.get(d)??[],r.cid])}let c=new Map;for(let r of A){if(w.has(r))continue;let d=e(t.nodeLabel.get(r),t.getNode(r)?.content.title);c.set(d,[...c.get(d)??[],r])}for(let[r,d]of c){let a=n.get(r)??[],b=d.length===1&&a.length===1;for(let y of d)b?(C.push({kind:"node",old:y,new:a[0],reason:s(`--force redesign of ${i.ucRef} by ${f.id} (title-matched successor)`,"title-matched successor"),by:f}),H.push({old:y,next:a[0]})):C.push({kind:"node",old:y,new:null,reason:s(`--force redesign of ${i.ucRef} by ${f.id}`),by:f}),P.push(y)}let o=r=>t.edgesFrom(r).some(d=>d.type!==p.SCOPED_TO?!1:d.dst===E||t.tipOf(d.dst)===E?!0:t.nodeLabel.get(d.dst)===g.SCENARIO&&t.edgesFrom(d.dst).some(a=>a.type===p.BELONGS_TO&&t.tipOf(a.dst)===E)),h=new Map;for(let{cid:r,content:d}of t.byLabel(g.AC)){if(t.superseded.has(r)||!o(r))continue;let a=D(String(d.text??""));h.set(a,[...h.get(a)??[],r])}let O=new Map;for(let r of T){if(r.label!==g.AC)continue;let d=D(String(r.content.text??""));O.set(d,[...O.get(d)??[],r.cid])}for(let[r,d]of h){let a=O.get(r)??[];d.length!==1||a.length!==1||(C.push({kind:"node",old:d[0],new:a[0],reason:s(`AC re-emitted with changed content by ${f.id} (text-matched successor)`,"AC text-matched successor"),by:f}),H.push({old:d[0],next:a[0]}),P.push(d[0]))}let u=new Set(P),l=new Set;for(let r of C)r.kind==="edge"&&l.add(r.ecid);for(let{old:r,next:d}of H)for(let a of t.edgesInto(r))se(a.type)?.pin?.comparesTo!=="dst_tip"||t.superseded.has(a.src)||u.has(a.src)||l.has(a.ecid)||(C.push({kind:"edge",ecid:a.ecid,reason:`re-blessed onto ${d} (redirect successor of ${r}) by ${f.id}`,by:f}),l.add(a.ecid),F.some(y=>y.type===a.type&&y.src===a.src&&y.dst===d)||t.edgesFrom(a.src).some(y=>y.type===a.type&&y.dst===d))||a.type===p.AUTOMATES&&B.has(d)||$(a.type,a.src,d,a.props,`rebless ${a.type} from ${t.nameOf.get(a.src)??a.src}`)}if(_.length>0)return x(_);if(T.length===0&&F.length===0&&C.length===0&&q.length===0)return Object.keys(S).length>0?(R.push("everything in this phase is already current \u2014 nothing re-committed"),{record:null,errors:null,minted:S,logicalIds:N,superseded:[],warnings:R,finalizedTests:G,...i.force||i.forceScope?{forceScopeRemaining:M}:{}}):x([{code:"EMPTY_DESIGN",detail:"finalize_design produced nothing to commit"}]);if(i.generationTicket){let e=me(t,i.generationTicket);if(e!==null)return x([e])}return{record:ce(I,{ts:new Date().toISOString(),proposal_id:null,nodes:T,edges:F,review:[],supersessions:C,source_head_moves:{},...j.length>0?{names:j}:{},...(()=>{for(let e of m.judgements??[]){let s=e.target?S[e.target]??t.resolve(e.target)?.cid??E:E;q.push({about:s,rationale:`[${e.kind}] ${e.rationale}`,by:f})}return q.length>0?{judgements:q}:{}})(),design_of:{uc_cid:E,engine:k},...i.generationTicket?{design_generation:he(i.generationTicket,E,f)}:{},...i.eventIds&&i.eventIds.length>0?{event_ids:i.eventIds}:i.sid?{event_ids:fe(t,i.sid,"design",1)}:{},...i.sid?{sid:i.sid}:{},...i.phase?{design_phase:{uc_root:le(t,E),generation:i.generationTicket?.next_gen??pe(t,i.ucRef)?.gen??1,phase:i.phase,completeness:i.phaseCompleteness??"complete"}}:{}},{expectPrev:t.latestHash}).record,errors:null,minted:S,logicalIds:N,superseded:P,warnings:R,finalizedTests:G,...i.force||i.forceScope?{forceScopeRemaining:M}:{}}}function Le(i,I){let t=[];for(let m of i){let f=m.design_phase;!f||typeof f!="object"||f.uc_root===I&&(typeof f.phase!="string"||typeof f.generation!="number"||t.push({phase:f.phase,generation:f.generation,seq:m.seq,completeness:f.completeness==="partial"?"partial":"complete"}))}return t.sort((m,f)=>m.seq-f.seq)}export{$e as a,De as b,Le as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{execFile as x}from"child_process";var f=15e3,l=124,g=127,p=8*1024*1024,w=(s,c,e={})=>new Promise(d=>{let E=x(s,c,{timeout:e.timeoutMs??f,maxBuffer:p,windowsHide:!0,...e.env?{env:e.env}:{},...e.cwd?{cwd:e.cwd}:{}},(t,n,u)=>{let m=typeof n=="string"?n:String(n??""),o=typeof u=="string"?u:String(u??"");if(!t){d({stdout:m,stderr:o,code:0});return}let r=t,i;typeof r.code=="number"?i=r.code:r.killed?i=l:i=g,o.trim()===""&&(o=r.message??""),d({stdout:m,stderr:o,code:i})});if(e.onOutput){let t=n=>e.onOutput(String(n));E.stdout?.on("data",t),E.stderr?.on("data",t)}});function O(s){return new Promise(c=>setTimeout(c,s))}export{f as a,l as b,g as c,w as d,O as e};
@@ -0,0 +1,19 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{c as g}from"./chunk-5EOX4MEY.js";var y={ASR_CMD_START:"info",ASR_CMD_END:"info",ASR_AGENT_SPAWN:"info",ASR_WORK_ITEM_START:"info",ASR_WORK_ITEM_END:"info",ASR_PROPOSAL:"info",ASR_VALIDATE_FAILED:"warn",ASR_COMMIT:"info",ASR_SESSION_PAUSED:"info",ASR_SESSION_RESUMED:"info",ASR_SESSION_COMPLETE:"info",ASR_AGENT_EXIT:"warn",ASR_RECONCILE_PLAN:"info",ASR_RECONCILE_ROW_END:"info",ASR_HIGH_RISK_CI:"warn",ASR_INGEST:"info",ASR_EMBED_DEGRADED:"warn",ASR_CONTEXT_CLONED:"warn",ASR_ERROR:"error",ASR_CRASH:"error",ASR_FSCK_REPORT:"warn"},O={ASR_CMD_START:["source_count","resumed","applied_plan"],ASR_CMD_END:["exit_code","duration_ms","credits_total","work_items_total","work_items_failed"],ASR_AGENT_SPAWN:["tier","duration_ms"],ASR_WORK_ITEM_START:["work_item_index","work_item_count","source_kind"],ASR_WORK_ITEM_END:["work_item_index","work_item_count","outcome","duration_ms","error_domain","error_code"],ASR_PROPOSAL:["item_count","turn_index"],ASR_VALIDATE_FAILED:["error_code","count","turn_index"],ASR_COMMIT:["trusted","derived","archived","items","items_dropped","record_seq"],ASR_SESSION_PAUSED:["pending_questions","pending_proposals"],ASR_SESSION_RESUMED:["resume_count","expired_session_id"],ASR_SESSION_COMPLETE:["duration_ms","credits_total"],ASR_AGENT_EXIT:["exit_code","signal"],ASR_RECONCILE_PLAN:["row_count","add_count","modify_count","archive_count"],ASR_RECONCILE_ROW_END:["row_index","kind","outcome","duration_ms"],ASR_HIGH_RISK_CI:["count"],ASR_INGEST:["work_item_index","work_item_count","format","bytes","media_facts"],ASR_EMBED_DEGRADED:["held"],ASR_CONTEXT_CLONED:[],ASR_ERROR:["error_domain","error_code","exit_code","turn_index"],ASR_CRASH:["error_domain","error_code","error_name"],ASR_FSCK_REPORT:["issue_count","records","pending","codes","issues","issues_truncated"]},b=[[/^(auth_expired|401|preflight_auth|AUTH)/i,"auth"],[/^(credit_denied|402|CREDIT)/i,"credit"],[/^(stream_drop|read_timeout|connect_failed|dns|E(CONN|AI_AGAIN|TIMEDOUT)|network)/i,"network"],[/^(frame_parse|post_terminal_data|eof_without_terminal|turn_id_mismatch|binding_mismatch|schema_invalid|frame_too_large|protocol)/i,"protocol"],[/^(provider_error|http_5\d\d|turn_exhausted|adapter_integrity)/i,"provider"],[/^(STALE_BASIS|R\d+|validation|criteria)/i,"validation"],[/^(CHAIN_ERROR|DERIVED_(MISSING|DRIFT)|NODE_FILE_(MISSING|MISMATCH|CORRUPT)|CARDINALITY_VIOLATION|SUPERSEDE_(UNKNOWN_(OLD|NEW|ECID)|CYCLE)|DOUBLE_SUPERSEDE|NAME_UNKNOWN_TARGET|EDGE_CYCLE|UNKNOWN_(LABEL|FIELD|EDGE_TYPE|EDGE_PROP)|BAD_(CHECK|ENUM)|MISSING_(FIELD|SALIENT)|ILLEGAL_EDGE)$/,"graph"],[/^(BLOB_MISSING|SOURCE_UNKNOWN|SESSION_(LOCKED|EXPIRED|MISSING|LOCK_LOST)|NO_STORE|fsck|store)/i,"store"],[/^(usage|EX2|SOURCE_WITH_RESUME|HIGH_RISK_CI|bad_flag|no_tty)/i,"usage"],[/^exit_\d+_unattributed$/,"unattributed"],[/^agent_(crash|exit)/i,"agent_crash"]];function h(e){let t=(e||"unknown").slice(0,64);for(let[n,r]of b)if(n.test(t))return{error_domain:r,error_code:t};return{error_domain:"cli_crash",error_code:t}}import{randomBytes as C}from"crypto";var v=/^(uc|sc|ac|t|gap|sty)-\d+$/,k="0123456789abcdefghijklmnopqrstuvwxyz";function $(e){let t="",n=C(e);for(let r=0;r<e;r++)t+=k[n[r]%36];return t}function J(e=new Date){let t=(r,o)=>String(r).padStart(o,"0");return`as-${`${e.getUTCFullYear()}${t(e.getUTCMonth()+1,2)}${t(e.getUTCDate(),2)}T${t(e.getUTCHours(),2)}${t(e.getUTCMinutes(),2)}`}-${$(8)}`}var L=-1,f=0;function Z(e=new Date){let t=e.getTime(),n=C(10);t===L?f=f+1&4095:(L=t,f=(n[0]<<8|n[1])&4095);let r=Buffer.alloc(16);r.writeUIntBE(t,0,6),r[6]=112|f>>8,r[7]=f&255,r[8]=128|n[2]&63,n.copy(r,9,3,10);let o=r.toString("hex");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var G=64,P=128,U=/^[A-Za-z0-9._:@\/-]+$/,F={codes:512},K={ASR_FSCK_REPORT:["issues"]},W=20480,H=0;function B(e,t){if(typeof t=="number"&&Number.isFinite(t)||typeof t=="boolean")return t;if(typeof t!="string")return;let n=e.endsWith("_id")||e==="signal"?P:F[e]??G;if(!(t.length===0||t.length>n)&&U.test(t))return t}function M(e,t,n={}){let r=O[t],o={};for(let i of r){let s=n[i];if(s==null)continue;if(K[t]?.includes(i)){if(typeof s!="string"||s.length===0)continue;let d=s.replace(/[\u0000-\u001F\u007F]/g,"");if(Buffer.byteLength(d,"utf8")>W)continue;o[i]=d;continue}if(i==="items"){let d=Array.isArray(s)?s.filter(N=>typeof N=="string"):[],u=d.filter(N=>v.test(N));u.length>0&&(o.items=u.slice(0,50).join(","));let S=d.length-u.length;S>0&&(o.items_dropped=S);continue}let a=B(i,s);a!==void 0&&(o[i]=a)}if(typeof n.error_code=="string"&&r.includes("error_code")){let{error_domain:i,error_code:s}=h(n.error_code);o.error_code=s,r.includes("error_domain")&&(o.error_domain=i)}return{level:y[t],event:t,message:t,session_id:e.session_id,operation_id:e.operation_id,...e.parent_operation_id?{parent_operation_id:e.parent_operation_id}:{},...e.agent_session_id?{agent_session_id:e.agent_session_id}:{},context_lineage_id:e.context_lineage_id??null,context_instance_id:e.context_instance_id??null,verb:e.verb,mode:e.mode,component:"kane-cli",seq:H++,event_time:new Date().toISOString(),context:o}}import _ from"fs";import X from"path";var V=500,j=7;function w(e){if(e.length!==0)try{let t=g();_.mkdirSync(X.dirname(t),{recursive:!0});let n=e.map(r=>JSON.stringify(r)).join(`
3
+ `)+`
4
+ `;_.appendFileSync(t,n,{flag:"a",mode:384}),q()}catch{}}async function se(e){let t=g(),n=`${t}.claim-${process.pid}`,r;try{_.renameSync(t,n),r=_.readFileSync(n,"utf8")}catch{return}let o=[];for(let i of r.split(`
5
+ `))if(i.trim())try{o.push(JSON.parse(i))}catch{}try{(o.length===0?!0:await e(o))?_.unlinkSync(n):(_.appendFileSync(t,r,{flag:"a",mode:384}),_.unlinkSync(n))}catch{try{_.appendFileSync(t,r,{flag:"a",mode:384}),_.unlinkSync(n)}catch{}}}function q(e=V,t=j){try{let n=g(),o=_.readFileSync(n,"utf8").split(`
6
+ `).filter(d=>d.trim()),i=Date.now()-t*24*3600*1e3,a=o.filter(d=>{try{let u=JSON.parse(d),S=Date.parse(u.event_time??u.timestamp??"");return Number.isNaN(S)||S>=i}catch{return!1}}).slice(-e);a.length!==o.length&&_.writeFileSync(n,a.length?a.join(`
7
+ `)+`
8
+ `:"",{mode:384})}catch{}}var E=null;function de(e){E=e}function le(){return E}var T=()=>!!process.env.KANE_DEV_MODE,c=[],A=!1,D=null,R=null,I=null,l=null,p=[];function Ee(e){if(l=e,e&&p.length>0){let t=p;p=[];for(let n of t)try{e.log(n.level,n.event,n.message,n.context)}catch{}}}function ue(e,t,n,r){if(l){try{l.log(e,t,n,r)}catch{}return}p.push({level:e,event:t,message:n,context:r})}function Se(){return l}function fe(){return A}function pe(e,t){c=c.filter(n=>n.name!==e),c.push({name:e,fn:t})}function Re(e){c=c.filter(t=>t.name!==e)}function ge(e,t){let n=c.find(o=>o.name===e);if(!n)return;c=c.filter(o=>o.name!==e);let r=!0;try{n.fn()}catch(o){r=!1,process.stderr.write(`[exit-manager] cleanup(${e}) failed: ${o instanceof Error?o.message:String(o)}
9
+ `)}t&&r&&T()&&process.stderr.write(`[exit-manager] cleanup(${e}): ${t}
10
+ `)}function m(e,t,n=!1,r){if(A){process.exit(D??e);return}if(A=!0,D=e,n&&l)try{l.log("error","CRASH",t),l.shutdownSync()}catch{}if(n&&E&&e!==130&&e!==143)try{let s=/Uncaught exception:\s*([A-Za-z0-9_$]+)/.exec(t)?.[1]??"crash";w([M(E,"ASR_CRASH",{error_code:"cli_crash",error_name:s})])}catch{}let o=[...c].reverse(),i=[];for(let s of o)try{s.fn(),i.push(s.name)}catch(a){process.stderr.write(`[exit-manager] cleanup(${s.name}) failed: ${a instanceof Error?a.message:String(a)}
11
+ `)}if(c=[],T()&&(process.stderr.write(`[exit-manager] shutdown(${e}): ${t}
12
+ `),i.length>0&&process.stderr.write(`[exit-manager] cleaned up: ${i.join(", ")}
13
+ `)),n){if(I)try{I()}catch{}e===130||e===143||(process.stderr.write(`
14
+ kane-cli crashed: ${t}
15
+ `+(i.length>0?`Resources cleaned up (${i.join(", ")}).
16
+ `:"")),E&&process.stderr.write(`session: ${E.session_id} \u2014 share this id with support
17
+ `),r&&T()?process.stderr.write(`${r}
18
+ `):process.stderr.write(`(re-run with KANE_DEV_MODE=1 for the full stack)
19
+ `)),process.exit(e);return}if(R&&!n){R();return}process.exit(e)}function me(e){R=e}function Ae(){R=null}function Ie(e){I=e}var x=!1;function Ne(){x||(x=!0,process.on("SIGINT",()=>{m(130,"Received SIGINT",!0)}),process.on("SIGTERM",()=>{m(143,"Received SIGTERM",!0)}),process.on("uncaughtException",e=>{m(1,`Uncaught exception: ${e.name}: ${e.message}`,!0,e.stack)}),process.on("unhandledRejection",e=>{m(1,`Unhandled rejection: ${String(e)}`,!0,e instanceof Error?e.stack:void 0)}))}function Te(){c=[],A=!1,D=null,R=null,I=null,l=null,p=[],x=!1,E=null}export{y as a,J as b,Z as c,M as d,w as e,se as f,de as g,le as h,Ee as i,ue as j,Se as k,fe as l,pe as m,Re as n,ge as o,m as p,me as q,Ae as r,Ie as s,Ne as t,Te as u};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as O,b as B,c as P}from"./chunk-QM4S2APK.js";import{d as w,e as h}from"./chunk-5YPBPZUR.js";var z={window:10,latest_only:!1,stale_at_run_weight:.5,counted_verdicts:["passed","failed"],accepted_oracle_modes:["authored","inferred","runtime-derived"],verified_threshold:.5,min_passes:1,risk_weights:{high:3}},Y={window:10,latest_only:!0,stale_at_run_weight:0,counted_verdicts:["passed","failed"],accepted_oracle_modes:["authored","inferred"],verified_threshold:1,min_passes:1,risk_weights:{high:3}},K={lenient:z,strict:Y};function Q(e,t){let s=e.slice(-t.window),i=new Map;for(let c of s)i.set(c.execution_id,c);let d=[...i.values()].sort((c,u)=>c.ts<u.ts?-1:c.ts>u.ts?1:c.execution_id<u.execution_id?-1:1).filter(c=>t.counted_verdicts.includes(c.verdict)&&t.accepted_oracle_modes.includes(c.oracle_mode));return t.latest_only&&d.length>1?[d[d.length-1]]:d}function Z(e,t){let s=Q(e,t),i=0,d=0,c=0;for(let l of s){let b=l.stale_at_run?t.stale_at_run_weight:1;i+=b,l.verdict==="passed"&&(d+=b,c++)}let u=i>0?Math.round(d/i*100)/100:0;return{score:u,verified:u>=t.verified_threshold&&c>=t.min_passes,passes:c,counted:s.length}}function U(e,t){let s=0,i=0;for(let d of e){let c=t[d.risk]??1;s+=c,d.verified&&(i+=c)}return s>0?Math.round(i/s*100):0}function ee(e,t){let s={},i={},d=[],c=0;for(let u of e.usecases){let l=[];for(let o of u.acceptance_criteria){let _=Z(o.executions??[],t);s[o.id]=_;let m={risk:o.risk,verified:_.verified};l.push(m),d.push(m)}let b=l.filter(o=>o.verified).length,n=l.length>0&&b===l.length?"covered":b>0?"partial":"uncovered";n==="covered"&&c++,i[u.id]={status:n,pct:U(l,t.risk_weights)}}return{config:t,acs:s,usecases:i,summary:{coverage_pct:U(d,t.risk_weights),acs_verified:`${d.filter(u=>u.verified).length}/${d.length}`,usecases_covered:`${c}/${e.usecases.length}`,uncovered:Object.values(i).filter(u=>u.status==="uncovered").length}}}function pe(e,t=K){return{rollup_version:1,stale_sources:new Set(e.usecases.flatMap(s=>s.stale_sources??[])).size,high_risk_gaps:(e.gaps??[]).filter(s=>s.risk==="high").length,aspects:Object.fromEntries(Object.entries(t).map(([s,i])=>[s,ee(e,i)]))}}var W={high:3};function fe(e){let t=e.byLabel(w.USECASE).filter(({cid:n})=>O(e,n)),s=new Map(t.map(({cid:n})=>[n,[]]));for(let{cid:n,content:o}of e.byLabel(w.AC)){if(!O(e,n))continue;let _=P(e,n),m=_?s.get(_):void 0;m&&m.push({risk:String(o.risk??""),designed:B(e,n),stale:e.stale(n)!=="fresh"})}let i={},d=[],c=0,u=0,l=0,b=0;for(let{cid:n}of t){let o=s.get(n),_=o.map(v=>({risk:v.risk,verified:v.designed}));d.push(..._),u+=o.length;let m=o.filter(v=>v.designed).length;c+=m;let x=o.filter(v=>v.stale).length,A=e.edgesInto(n).some(v=>v.type===h.BELONGS_TO&&O(e,v.src));A||b++;let k=o.length===0||m===0?"undesigned":m===o.length&&x===0&&A?"complete":"partial";k==="complete"&&l++,i[e.displayNameOf(n)??n]={pct:U(_,W),status:k,staleAcs:x}}return{pct:U(d,W),acs_designed:`${c}/${u}`,usecases_complete:`${l}/${t.length}`,ucs_needing_scenarios:b,perUc:i,config:{criterion:"live_verifies_edge",risk_weights:{high:3},freshness:"not_discounted"}}}var y=(e,t)=>e.nameOf.get(t)??t,R=(e,t)=>!e.superseded.has(t);function te(e,t){return e.byLabel(w.SCENARIO).filter(({cid:s})=>R(e,s)).filter(({cid:s})=>e.edgesFrom(s).some(i=>i.type===h.BELONGS_TO&&e.tipOf(i.dst)===t)).map(({cid:s})=>s)}function se(e,t,s){let i=[];for(let{cid:d}of e.byLabel(w.AC)){if(!R(e,d))continue;let c=e.edgesFrom(d).find(l=>l.type===h.SCOPED_TO);if(!c)continue;let u=e.tipOf(c.dst);u===t?i.push({cid:d,scope:{type:"usecase",ref:y(e,t)}}):s.has(u)&&i.push({cid:d,scope:{type:"scenario",ref:y(e,u)}})}return i}function ne(e){let t=e.filter(s=>s!==void 0).map(s=>s.execution);return t.includes("failed")?"failed":t.includes("blocked")?"blocked":t.includes("passed")?"passed":"not-run"}var oe={passed:"passed",failed:"failed",broken:"blocked",skipped:"not-run"};function re(e,t){let s=t.flatMap(i=>i?.acs??[]).filter(i=>i.ref===e).map(i=>oe[i.verdict]??"not-run");return s.length===0?ne(t):s.includes("failed")?"failed":s.includes("blocked")?"blocked":s.includes("passed")?"passed":"not-run"}function Se(e){return ie(e,new Map)}function ie(e,t,s){let i=s?.scope==="run",d=[],c=new Set,u=new Map;for(let[n,o]of e.nameOf)u.set(e.tipOf(n)??n,o);let l=n=>u.get(n)??y(e,n);for(let{cid:n,content:o}of e.byLabel(w.USECASE)){if(!R(e,n)||e.trust.get(n)==="archived")continue;let _=e.tipOf(n),m=e.derivesInto(_).filter(r=>!e.superseded.has(r.ecid)),x=[...new Set(m.map(r=>String(r.props?.source_id??"")).filter(Boolean))].sort(),A=x.map(r=>{let f=e.heads.get(r);if(typeof f!="string")return{id:r};let p=e.getNode(f)?.content.blob;return{id:r,media_type:e.mediaOf(f).media_type,...typeof p=="string"?{cid:p}:{}}}),k=m[0],v=new Map;for(let r of m)r.props?.source_id&&r.props?.source_cid&&v.set(String(r.props.source_id),String(r.props.source_cid));let T=x.filter(r=>{let f=e.heads.get(r),p=v.get(r);return f!=null&&p!==void 0&&f!==p}).sort(),L=e.edgesFrom(n).filter(r=>r.type===h.DEPENDS_ON&&!e.superseded.has(r.ecid)).map(r=>de(e,r.dst)).filter(r=>r!==null).sort(),D=te(e,_),q=new Set(D),H=D.map(r=>{let f=e.getNode(r)?.content??{},p=e.edgesFrom(r).filter(S=>S.type===h.EXERCISES&&!e.superseded.has(S.ecid)&&R(e,e.tipOf(S.dst))).map(S=>y(e,e.tipOf(S.dst))).sort();return{id:y(e,r),case_type:String(f.case_type??""),intent:String(f.intent??""),exercises:p}}).sort((r,f)=>r.id<f.id?-1:1),$=!1,E=new Set([_]);for(let r of D)E.add(r);let J=se(e,_,q).map(({cid:r,scope:f})=>{let p=e.getNode(r)?.content??{},S=[...new Set(e.edgesInto(r).filter(a=>a.type===h.VERIFIES&&!e.superseded.has(a.ecid)).map(a=>e.tipOf(a.src)).filter(a=>!!a&&R(e,a)))].sort((a,g)=>l(a)<l(g)?-1:1),G=S.length>0,N=S.map(a=>t.get(`id:${l(a)}`)??t.get(`def:${String(e.getNode(a)?.content.definitionId??"")}`)),j=N.some(a=>a!==void 0);j&&($=!0),E.add(r);for(let a of S)E.add(a);let X=G&&!j?"unknown":e.stale(r)==="fresh"?"fresh":"stale",C=p.expected_answer??{},I=y(e,r),F=S.flatMap(a=>(e.execHistory?.(l(a))??[]).map(g=>({execution_id:String(g.execution_id),ts:String(g.started_at),verdict:String(g.per_ac?.find(M=>M.ac_ref===I)?.verdict??g.verdict),stale_at_run:!!g.stale_at_run,oracle_mode:String(g.oracle_mode),...g.via_parent?{via_parent:String(g.via_parent)}:{}}))).sort((a,g)=>a.ts<g.ts?-1:1).slice(-10);return{id:I,text:String(p.text??""),risk:String(p.risk??""),scope:f,covered_by:S.map(a=>l(a)),...G?{link_type:"verifies"}:{},execution:re(I,N),fresh:X,derived:!!p.derived,...p.kind||p.expected_answer?{expected_answer:{...p.kind?{kind:String(p.kind)}:{},statement:String(p.text??""),...C.operator!==void 0?{operator:C.operator}:{},...C.operand!==void 0?{operand:C.operand}:{}}}:{},...G?{satisfied_by:S.map((a,g)=>{let M=e.getNode(a)?.content.check??{},V=N[g]?.steps?.checkStepId??M.verified_against;return{test:l(a),...V?{step:V}:{}}})}:{},...F.length?{executions:F}:{}}}).sort((r,f)=>r.id<f.id?-1:1);if(!(i&&!$)){for(let r of E)c.add(r);d.push({id:y(e,n),title:String(o.title??""),...o.description||o.summary?{description:String(o.description??o.summary)}:{},...Array.isArray(o.actors)&&o.actors.length?{actors:o.actors.map(String)}:{},...o.value?{value:String(o.value)}:{},risk:String(o.risk??""),status:e.trust.get(n)==="trusted"?"approved":"draft",sources:A,...T.length?{stale_sources:T}:{},...L.length?{depends_on:L}:{},...k?{provenance:{derived_from:`${String(k.props?.source_id??"")}#${String(k.props?.anchor??"")}`}}:{},scenarios:H,acceptance_criteria:J})}}d.sort((n,o)=>n.id<o.id?-1:1);let b=e.byLabel(w.GAP).filter(({cid:n})=>R(e,n)&&e.trust.get(n)!=="archived").filter(({content:n})=>{if(!i||typeof n.uc=="string"&&c.has(e.tipOf(n.uc)))return!0;let o=typeof n.ref=="string"?e.resolve(n.ref):null;return o!==null&&c.has(e.tipOf(o.cid))}).map(({cid:n,content:o})=>({ref:y(e,n),kind:String(o.kind??""),...o.risk?{risk:String(o.risk)}:{},...o.question?{question:ce(o.question)}:{}})).sort((n,o)=>n.ref<o.ref?-1:1);return{usecases:d,...b.length?{gaps:b}:{},...i?{scope:"run"}:{}}}function ce(e){if(typeof e=="string")return e;let t=e?.header;return typeof t=="string"?t:""}function de(e,t){let s=e.tipOf(t);return e.nodeLabel.get(s)!==w.USECASE||!R(e,s)?null:y(e,s)}export{K as a,Q as b,Z as c,pe as d,fe as e,Se as f,ie as g};
2
+ import{a as O,b as B,c as P}from"./chunk-XWKUZJCP.js";import{d as w,e as h}from"./chunk-WXHQYYD5.js";var z={window:10,latest_only:!1,stale_at_run_weight:.5,counted_verdicts:["passed","failed"],accepted_oracle_modes:["authored","inferred","runtime-derived"],verified_threshold:.5,min_passes:1,risk_weights:{high:3}},Y={window:10,latest_only:!0,stale_at_run_weight:0,counted_verdicts:["passed","failed"],accepted_oracle_modes:["authored","inferred"],verified_threshold:1,min_passes:1,risk_weights:{high:3}},K={lenient:z,strict:Y};function Q(e,t){let s=e.slice(-t.window),i=new Map;for(let c of s)i.set(c.execution_id,c);let d=[...i.values()].sort((c,u)=>c.ts<u.ts?-1:c.ts>u.ts?1:c.execution_id<u.execution_id?-1:1).filter(c=>t.counted_verdicts.includes(c.verdict)&&t.accepted_oracle_modes.includes(c.oracle_mode));return t.latest_only&&d.length>1?[d[d.length-1]]:d}function Z(e,t){let s=Q(e,t),i=0,d=0,c=0;for(let l of s){let b=l.stale_at_run?t.stale_at_run_weight:1;i+=b,l.verdict==="passed"&&(d+=b,c++)}let u=i>0?Math.round(d/i*100)/100:0;return{score:u,verified:u>=t.verified_threshold&&c>=t.min_passes,passes:c,counted:s.length}}function U(e,t){let s=0,i=0;for(let d of e){let c=t[d.risk]??1;s+=c,d.verified&&(i+=c)}return s>0?Math.round(i/s*100):0}function ee(e,t){let s={},i={},d=[],c=0;for(let u of e.usecases){let l=[];for(let o of u.acceptance_criteria){let _=Z(o.executions??[],t);s[o.id]=_;let m={risk:o.risk,verified:_.verified};l.push(m),d.push(m)}let b=l.filter(o=>o.verified).length,n=l.length>0&&b===l.length?"covered":b>0?"partial":"uncovered";n==="covered"&&c++,i[u.id]={status:n,pct:U(l,t.risk_weights)}}return{config:t,acs:s,usecases:i,summary:{coverage_pct:U(d,t.risk_weights),acs_verified:`${d.filter(u=>u.verified).length}/${d.length}`,usecases_covered:`${c}/${e.usecases.length}`,uncovered:Object.values(i).filter(u=>u.status==="uncovered").length}}}function pe(e,t=K){return{rollup_version:1,stale_sources:new Set(e.usecases.flatMap(s=>s.stale_sources??[])).size,high_risk_gaps:(e.gaps??[]).filter(s=>s.risk==="high").length,aspects:Object.fromEntries(Object.entries(t).map(([s,i])=>[s,ee(e,i)]))}}var W={high:3};function fe(e){let t=e.byLabel(w.USECASE).filter(({cid:n})=>O(e,n)),s=new Map(t.map(({cid:n})=>[n,[]]));for(let{cid:n,content:o}of e.byLabel(w.AC)){if(!O(e,n))continue;let _=P(e,n),m=_?s.get(_):void 0;m&&m.push({risk:String(o.risk??""),designed:B(e,n),stale:e.stale(n)!=="fresh"})}let i={},d=[],c=0,u=0,l=0,b=0;for(let{cid:n}of t){let o=s.get(n),_=o.map(v=>({risk:v.risk,verified:v.designed}));d.push(..._),u+=o.length;let m=o.filter(v=>v.designed).length;c+=m;let x=o.filter(v=>v.stale).length,A=e.edgesInto(n).some(v=>v.type===h.BELONGS_TO&&O(e,v.src));A||b++;let k=o.length===0||m===0?"undesigned":m===o.length&&x===0&&A?"complete":"partial";k==="complete"&&l++,i[e.displayNameOf(n)??n]={pct:U(_,W),status:k,staleAcs:x}}return{pct:U(d,W),acs_designed:`${c}/${u}`,usecases_complete:`${l}/${t.length}`,ucs_needing_scenarios:b,perUc:i,config:{criterion:"live_verifies_edge",risk_weights:{high:3},freshness:"not_discounted"}}}var y=(e,t)=>e.nameOf.get(t)??t,R=(e,t)=>!e.superseded.has(t);function te(e,t){return e.byLabel(w.SCENARIO).filter(({cid:s})=>R(e,s)).filter(({cid:s})=>e.edgesFrom(s).some(i=>i.type===h.BELONGS_TO&&e.tipOf(i.dst)===t)).map(({cid:s})=>s)}function se(e,t,s){let i=[];for(let{cid:d}of e.byLabel(w.AC)){if(!R(e,d))continue;let c=e.edgesFrom(d).find(l=>l.type===h.SCOPED_TO);if(!c)continue;let u=e.tipOf(c.dst);u===t?i.push({cid:d,scope:{type:"usecase",ref:y(e,t)}}):s.has(u)&&i.push({cid:d,scope:{type:"scenario",ref:y(e,u)}})}return i}function ne(e){let t=e.filter(s=>s!==void 0).map(s=>s.execution);return t.includes("failed")?"failed":t.includes("blocked")?"blocked":t.includes("passed")?"passed":"not-run"}var oe={passed:"passed",failed:"failed",broken:"blocked",skipped:"not-run"};function re(e,t){let s=t.flatMap(i=>i?.acs??[]).filter(i=>i.ref===e).map(i=>oe[i.verdict]??"not-run");return s.length===0?ne(t):s.includes("failed")?"failed":s.includes("blocked")?"blocked":s.includes("passed")?"passed":"not-run"}function Se(e){return ie(e,new Map)}function ie(e,t,s){let i=s?.scope==="run",d=[],c=new Set,u=new Map;for(let[n,o]of e.nameOf)u.set(e.tipOf(n)??n,o);let l=n=>u.get(n)??y(e,n);for(let{cid:n,content:o}of e.byLabel(w.USECASE)){if(!R(e,n)||e.trust.get(n)==="archived")continue;let _=e.tipOf(n),m=e.derivesInto(_).filter(r=>!e.superseded.has(r.ecid)),x=[...new Set(m.map(r=>String(r.props?.source_id??"")).filter(Boolean))].sort(),A=x.map(r=>{let f=e.heads.get(r);if(typeof f!="string")return{id:r};let p=e.getNode(f)?.content.blob;return{id:r,media_type:e.mediaOf(f).media_type,...typeof p=="string"?{cid:p}:{}}}),k=m[0],v=new Map;for(let r of m)r.props?.source_id&&r.props?.source_cid&&v.set(String(r.props.source_id),String(r.props.source_cid));let T=x.filter(r=>{let f=e.heads.get(r),p=v.get(r);return f!=null&&p!==void 0&&f!==p}).sort(),L=e.edgesFrom(n).filter(r=>r.type===h.DEPENDS_ON&&!e.superseded.has(r.ecid)).map(r=>de(e,r.dst)).filter(r=>r!==null).sort(),D=te(e,_),q=new Set(D),H=D.map(r=>{let f=e.getNode(r)?.content??{},p=e.edgesFrom(r).filter(S=>S.type===h.EXERCISES&&!e.superseded.has(S.ecid)&&R(e,e.tipOf(S.dst))).map(S=>y(e,e.tipOf(S.dst))).sort();return{id:y(e,r),case_type:String(f.case_type??""),intent:String(f.intent??""),exercises:p}}).sort((r,f)=>r.id<f.id?-1:1),$=!1,E=new Set([_]);for(let r of D)E.add(r);let J=se(e,_,q).map(({cid:r,scope:f})=>{let p=e.getNode(r)?.content??{},S=[...new Set(e.edgesInto(r).filter(a=>a.type===h.VERIFIES&&!e.superseded.has(a.ecid)).map(a=>e.tipOf(a.src)).filter(a=>!!a&&R(e,a)))].sort((a,g)=>l(a)<l(g)?-1:1),G=S.length>0,N=S.map(a=>t.get(`id:${l(a)}`)??t.get(`def:${String(e.getNode(a)?.content.definitionId??"")}`)),j=N.some(a=>a!==void 0);j&&($=!0),E.add(r);for(let a of S)E.add(a);let X=G&&!j?"unknown":e.stale(r)==="fresh"?"fresh":"stale",C=p.expected_answer??{},I=y(e,r),F=S.flatMap(a=>(e.execHistory?.(l(a))??[]).map(g=>({execution_id:String(g.execution_id),ts:String(g.started_at),verdict:String(g.per_ac?.find(M=>M.ac_ref===I)?.verdict??g.verdict),stale_at_run:!!g.stale_at_run,oracle_mode:String(g.oracle_mode),...g.via_parent?{via_parent:String(g.via_parent)}:{}}))).sort((a,g)=>a.ts<g.ts?-1:1).slice(-10);return{id:I,text:String(p.text??""),risk:String(p.risk??""),scope:f,covered_by:S.map(a=>l(a)),...G?{link_type:"verifies"}:{},execution:re(I,N),fresh:X,derived:!!p.derived,...p.kind||p.expected_answer?{expected_answer:{...p.kind?{kind:String(p.kind)}:{},statement:String(p.text??""),...C.operator!==void 0?{operator:C.operator}:{},...C.operand!==void 0?{operand:C.operand}:{}}}:{},...G?{satisfied_by:S.map((a,g)=>{let M=e.getNode(a)?.content.check??{},V=N[g]?.steps?.checkStepId??M.verified_against;return{test:l(a),...V?{step:V}:{}}})}:{},...F.length?{executions:F}:{}}}).sort((r,f)=>r.id<f.id?-1:1);if(!(i&&!$)){for(let r of E)c.add(r);d.push({id:y(e,n),title:String(o.title??""),...o.description||o.summary?{description:String(o.description??o.summary)}:{},...Array.isArray(o.actors)&&o.actors.length?{actors:o.actors.map(String)}:{},...o.value?{value:String(o.value)}:{},risk:String(o.risk??""),status:e.trust.get(n)==="trusted"?"approved":"draft",sources:A,...T.length?{stale_sources:T}:{},...L.length?{depends_on:L}:{},...k?{provenance:{derived_from:`${String(k.props?.source_id??"")}#${String(k.props?.anchor??"")}`}}:{},scenarios:H,acceptance_criteria:J})}}d.sort((n,o)=>n.id<o.id?-1:1);let b=e.byLabel(w.GAP).filter(({cid:n})=>R(e,n)&&e.trust.get(n)!=="archived").filter(({content:n})=>{if(!i||typeof n.uc=="string"&&c.has(e.tipOf(n.uc)))return!0;let o=typeof n.ref=="string"?e.resolve(n.ref):null;return o!==null&&c.has(e.tipOf(o.cid))}).map(({cid:n,content:o})=>({ref:y(e,n),kind:String(o.kind??""),...o.risk?{risk:String(o.risk)}:{},...o.question?{question:ce(o.question)}:{}})).sort((n,o)=>n.ref<o.ref?-1:1);return{usecases:d,...b.length?{gaps:b}:{},...i?{scope:"run"}:{}}}function ce(e){if(typeof e=="string")return e;let t=e?.header;return typeof t=="string"?t:""}function de(e,t){let s=e.tipOf(t);return e.nodeLabel.get(s)!==w.USECASE||!R(e,s)?null:y(e,s)}export{K as a,Q as b,Z as c,pe as d,fe as e,Se as f,ie as g};
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var p=1;function f(e){return e==="agent"?"ndjson":"human"}function c(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}var a=/^(∷ |· |→ |✓ |✗ |… )/;function d(e){return e===0?"complete":e===2?"refused":e===3?"paused":e===130?"interrupted":"error"}function l(e,r,s={stdout:t=>process.stdout.write(t),stderr:t=>process.stderr.write(t)}){let t=!1,u=n=>{if(e!=="ndjson"||t)return;n.type==="done"&&(t=!0);let{type:i,...o}=n;s.stdout(JSON.stringify({type:i,v:1,verb:r,...o})+`
3
+ `)};return{encoding:e,out:e==="ndjson"?()=>{}:n=>s.stdout(n+`
4
+ `),progress:e==="ndjson"?()=>{}:n=>s.stderr(n.replace(a,"").replace(/…$/,"")+`
5
+ `),event:u,done:(n,i,o)=>(u({type:"done",status:i??d(n),exit_code:n,...o!==void 0&&o.length>0?{next:o}:{}}),n)}}var g=8*1024;function m(e,r){return e.message==null?null:e.message.trim()?e.resume?Buffer.byteLength(e.message,"utf8")>g?`${r==="extract"?"extract":"design"}: --message is over 8KB \u2014 the agent would silently drop it; shorten the statement`:null:`${r==="extract"?"extract":"design"}: --message only rides a resume \u2014 pair it with --resume <sid> (a fresh run takes its direction from the sources)`:`${r==="extract"?"extract":"design"}: --message is empty \u2014 say what you want the agent to know`}function x(e,r,s){return e.event({type:"error",message:r,...s?{code:s}:{}}),e.done(2,"refused")}function E(e,r,s){return{out:t=>{r()&&s.test(t)||e.out(t)},emit:t=>{r()&&t.type==="error"&&s.test(String(t.message??""))||e.event(t)}}}export{p as a,f as b,c,l as d,g as e,m as f,x as g,E as h};
@@ -0,0 +1,7 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as C,b as k,c as R,d as D}from"./chunk-7BZSCUPP.js";import{g as T,h as $,i as b}from"./chunk-W4B5LOEX.js";import{g as E}from"./chunk-R7QAS6LZ.js";import{i as S}from"./chunk-KRKGZ2ZW.js";import{c as y}from"./chunk-5DT7PIGB.js";import{a as O}from"./chunk-CH273NAE.js";import{A as _}from"./chunk-TH47OOBV.js";import{existsSync as H}from"fs";import{basename as q}from"path";import{appendFileSync as L,mkdirSync as U}from"fs";import{homedir as F}from"os";import{dirname as G,join as j}from"path";function P(c,s){let n=/^(DOCX_[A-Z_]+):/.exec(s)?.[1];if(n)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??j(F(),".testmuai","kaneai","context-refusals.log");U(G(u),{recursive:!0}),L(u,`${new Date().toISOString()} ${n} ${c}
3
+ `)}catch{}}async function w(c,s,n,u=process.cwd(),p){let l=O(u),g=[];if(s.as!==void 0&&c.length>1)return(n.err??n.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${c.length})`,"AS_SINGLE_SOURCE"),{code:2,results:g};for(let o of c){if(R(o)){let a=D(o);if(a===null)return(n.err??n.out)(`error: ${o}: unsupported remote URL \u2014 supported: ${k.map(d=>d.hint).join("; ")}`,"UNSUPPORTED_URL"),{code:1,results:g};let r=await a.ingest(o,s.as,n,l,p);if(r.code!==0)return{code:r.code,results:g};r.result&&g.push({status:r.result.status==="versioned"?"versioned":r.result.status==="unchanged"?"unchanged":"created",source_id:r.result.source_id,source_cid:r.result.source_cid});continue}let f=s.as,v;if(f===void 0&&H(l)){let a=T(o),r=$(a);if(r){let d=_(l);d.heads.get(r)!=null&&d.heads.get(a)==null&&(v=r,n.isTTY&&await n.confirm(`${a} looks like a new version of existing source '${r}' \u2014 ingest as '${r}' (replaces the current version; items built on it go stale)?`)&&(f=r))}}let e;try{e=await b({contextDir:l,filePath:o,asId:f,confirmSameSource:n.isTTY?a=>n.confirm(`identical bytes already ingested as ${a} \u2014 treat as the same source?`):void 0,converters:{pdf:E,docx:S}})}catch(a){let r=a instanceof Error?a.message:String(a);return P(o,r),(n.err??n.out)(`error: ${o}: ${r}`,"INGEST_FAILED"),{code:1,results:g}}n.out(C(n.isTTY,e,q(o)));for(let a of e.warnings??[])n.out(`warning: ${a}`);if(e.composite&&(e.composite.delivered>0||e.composite.omitted>0)){let a=e.composite.pages!==void 0?` ${e.composite.pages} pages,`:"";n.out(`${e.source_id}: ${e.composite.kind},${a} ${e.composite.delivered} images delivered (${e.composite.omitted} omitted)`)}let m;if(!n.isTTY&&e.status==="created"){let a=_(l);for(let[r,d]of a.heads.entries())if(!(r===e.source_id||d==null)&&a.getNode(d)?.content.blob===e.blob){m=r,n.out(`hint: identical bytes already ingested as ${r} \u2014 merged later via review`);break}}g.push({status:e.status,source_id:e.source_id,source_cid:e.cid,...e.warnings?.length?{warnings:e.warnings}:{},...e.composite?{media:{kind:e.composite.kind,...e.composite.pages!==void 0?{pages:e.composite.pages}:{},delivered:e.composite.delivered,omitted:e.composite.omitted}}:{},...m?{duplicate_of:m}:{},...v&&f===void 0?{lineage_candidate:v}:{}})}return{code:0,results:g}}async function se(c,s,n,u=process.cwd(),p){return(await w(c,s,n,u,p)).code}async function ie(c,s){if(s.mode!=null&&!["interactive","agent","ci","override"].includes(s.mode)){let{makeHeadlessIO:t,agentRefusal:i}=await import("./headless-io-66RG5NN5.js");return i(t("ndjson","extract"),`ingest: --mode must be interactive | agent | ci | override, got '${s.mode}'`,"MODE_USAGE")}let n=y();if(s.mode==="interactive"&&!n)return process.stderr.write(`ingest: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
4
+ `),2;let u=s.mode??(n?"interactive":void 0),p=u==="interactive"||u==="agent"||u==="override";if(!p&&(s.plan||s.force||s.trust!==void 0))return process.stderr.write(`ingest: --plan/--force/--trust steer the extraction \u2014 not available when only landing (use --mode agent to extract headless)
5
+ `),2;let{createInterface:l}=await import("readline/promises"),g=u==="agent",o=g?(await import("./headless-io-66RG5NN5.js")).makeHeadlessIO("ndjson","extract"):null,f=[],v=()=>{for(let t of f.splice(0))o.event({type:"error",message:t.message,...t.code?{code:t.code}:{}})},e=t=>{for(let i of t)o.event({type:"ingested",source_id:i.source_id,status:i.status,cid:i.source_cid,...i.warnings?.length?{warnings:i.warnings}:{},...i.media?{media:i.media}:{},...i.duplicate_of?{duplicate_of:i.duplicate_of}:{},...i.lineage_candidate?{lineage_candidate:i.lineage_candidate}:{}})},m=o?{out:()=>{},err:(t,i)=>f.push({message:t.replace(/^error: /,""),...i?{code:i}:{}}),isTTY:!1,confirm:async()=>!1}:{out:t=>process.stdout.write(t+`
6
+ `),err:t=>process.stderr.write(t+`
7
+ `),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-CQCWLVOC.js");return t("ingest",async()=>{let{code:i,results:h}=await w(c,{as:s.as},m,void 0,void 0);if(i!==0)return i;let I=h.filter(Y=>Y.status!=="unchanged").length;return I>0&&(m.err??m.out)(`landed ${I} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let a;try{a=o?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:o.event},()=>w(c,{as:s.as},m,void 0,void 0)):await w(c,{as:s.as},m,void 0,void 0)}catch(t){if(o)return v(),o.event({type:"error",message:t instanceof Error?t.message:String(t),code:"INGEST_FAILED"}),o.done(1,"error");throw t}let{code:r,results:d}=a;if(r!==0)return o?(e(d),v(),o.done(r,r===2?"refused":"error")):r;if(d.length===0)return o?o.done(0):0;let{extractCommand:A}=await import("./extract-cmd-UZMEZMGP.js"),N=[...new Set(d.map(t=>t.source_id))],x=await A({...s.mode!==void 0?{mode:s.mode}:{},...s.plan?{plan:!0}:{},...s.force?{force:!0}:{},...s.trust!==void 0?{trust:s.trust}:{},sources:N,landed:d});if(x===2&&!g){let t=d.filter(i=>i.status!=="unchanged").length;t>0&&(m.err??m.out)(`note: the ${t} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return x}export{w as a,se as b,ie as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var c={darwin:"macOS",linux:"Linux",win32:"Windows"};function _(n){return c[n]??n}function r(n){return typeof n!="string"?void 0:n.trim()||void 0}function u(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:void 0}function s(n){return n==="emulator"||n==="simulator"?n:void 0}function f(n){if(!n||typeof n!="object")return;let i=n,t=i.device&&typeof i.device=="object"?i.device:void 0,e=t?{...r(t.model)?{model:r(t.model)}:{},...r(t.manufacturer)?{manufacturer:r(t.manufacturer)}:{},...r(t.os_version)?{os_version:r(t.os_version)}:{},...u(t.pixel_ratio)!==void 0?{pixel_ratio:u(t.pixel_ratio)}:{},...r(t.automation)?{automation:r(t.automation)}:{},...r(t.device_instance_id)?{device_instance_id:r(t.device_instance_id)}:{},...s(t.target_kind)?{target_kind:s(t.target_kind)}:{}}:void 0,d=r(i.resolution),o=r(i.native_platform),a=e&&Object.keys(e).length>0;if(!(!d&&!o&&!a))return{...d?{resolution:d}:{},...o?{native_platform:o}:{},...a?{device:e}:{}}}function v(n,i){if(!n)return i;if(!i)return n;let t={...n.device??{},...i.device??{}};return{...n,...i,...Object.keys(t).length?{device:t}:{}}}function m(n){if(n.startsWith("android"))return"Android";if(n.startsWith("ios"))return"iOS"}function l(n,i){let t=f(i);if(!t)return n;let e={...n};if(t.resolution&&(t.native_platform||!e.resolution)&&(e.resolution=t.resolution),!t.native_platform)return e;e.native_platform=t.native_platform,delete e.browser,delete e.browser_version;let d=m(t.native_platform);d&&(e.os=d);let o=t.device;return o?.model&&(e.device=o.model),o?.manufacturer&&(e.manufacturer=o.manufacturer),o?.os_version&&(e.os_version=o.os_version),o?.pixel_ratio!==void 0&&(e.pixel_ratio=o.pixel_ratio),o?.automation&&(e.automation=o.automation),o?.device_instance_id&&(e.device_instance_id=o.device_instance_id),o?.target_kind&&(e.target_kind=o.target_kind),e}function p(n,i,t){let d=!!f(i)?.native_platform;return{model:n,platform:d?"Mobile":"Desktop",platform_type:d?"app":"web",...t?{run_kind:t}:{}}}function g(n,i){let t={},e=(d,o)=>{o!==void 0&&o!==""&&(t[d]=o)};return e("model",i.model),e("os",n.os),e("browser",n.browser),e("browser_version",n.browser_version),e("resolution",n.resolution),e("platform",i.platform),e("platform_type",i.platform_type),e("run_kind",i.run_kind),e("os_version",n.os_version),e("native_platform",n.native_platform),e("manufacturer",n.manufacturer),e("pixel_ratio",n.pixel_ratio),e("automation",n.automation),e("device_instance_id",n.device_instance_id),e("target_kind",n.target_kind),n.device!==void 0&&n.device!==""?t.device=n.device:i.platform_type&&i.platform_type!=="web"&&(t.device=null),t}export{_ as a,f as b,v as c,l as d,p as e,g as f};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as b,d as _}from"./chunk-NVGBE2DR.js";import{a as g,c as h}from"./chunk-L4JIMNKW.js";import{i as S}from"./chunk-M7WQM4UA.js";import{d as f,f as v}from"./chunk-5YPBPZUR.js";var V=n=>`conv#turn=${n}`;function E(n,o){for(let t of n.split(`
2
+ import{c as b,d as _}from"./chunk-NVGBE2DR.js";import{a as g,c as h}from"./chunk-CUM23TLF.js";import{i as S}from"./chunk-DUAXZYAD.js";import{d as f,f as v}from"./chunk-WXHQYYD5.js";var V=n=>`conv#turn=${n}`;function E(n,o){for(let t of n.split(`
3
3
  `))if(t.trim())try{let r=JSON.parse(t);if(r.turn===o)return r.text}catch{}return null}var y={format:"conversation",media_type:"text/x-conversation",anchors_supported:["#turn="]};function $(n){let{contextDir:o,graph:t,sessionStamp:r}=n,e=`su-conv-${r}`,u=t.heads.get(e);if(typeof u=="string")return{record:null,errors:[{code:"CONV_SOURCE_EXISTS",detail:`${e} already exists \u2014 resume it`}],sourceId:e,cid:u};let i=b(o,Buffer.from("","utf8")),c=h(e,i),a=v("source",c);if(a.length>0)return{record:null,errors:a.map(s=>({code:s.code,detail:s.detail})),sourceId:e,cid:""};let d=g("source",c);return{record:S(o,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:d,label:f.SOURCE,content:c}],edges:[],review:[],supersessions:[],source_head_moves:{[e]:d},media:{[e]:y},conv:{source_id:e,turn:0,append_of:null}},{expectPrev:t.latestHash}).record,errors:null,sourceId:e,cid:d}}function G(n){let{contextDir:o,graph:t,sourceId:r,text:e,force:u}=n,i=t.heads.get(r),c=t.convChains.get(r);if(typeof i!="string"||!c)return{record:null,errors:[{code:"CONV_SOURCE_MISSING",detail:`${r} is not a live conversation source`}]};let d=t.getNode(i)?.content?.blob;if(typeof d!="string")return{record:null,errors:[{code:"CONV_SOURCE_MISSING",detail:`${r} head node unreadable`}]};let l=_(o,d)?.toString("utf8")??"",s=c.turns;if(!u&&s>0&&E(l,s)===e)return{record:null,errors:null,turn:s,cid:i,idempotent:!0};let p=s+1,C=`${l}${JSON.stringify({turn:p,text:e})}
4
4
  `,O=b(o,Buffer.from(C,"utf8")),x=h(r,O),m=g("source",x);return{record:S(o,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:m,label:f.SOURCE,content:x}],edges:[],review:[],supersessions:[],source_head_moves:{[r]:m},media:{[r]:y},conv:{source_id:r,turn:p,append_of:i}},{expectPrev:t.latestHash}).record,errors:null,turn:p,cid:m,idempotent:!1}}export{V as a,E as b,$ as c,G as d};