@rho-workspace/rho 0.5.5 → 0.5.6

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 (106) hide show
  1. package/dist/agent-connect.d.ts +8 -0
  2. package/dist/agent-connect.js +15 -0
  3. package/dist/browser-access.js +1 -1
  4. package/dist/cli.js +38 -8
  5. package/dist/contract.generated.d.ts +148 -5
  6. package/dist/contract.generated.js +1 -1
  7. package/dist/contracts/owners.generated.js +107 -12
  8. package/dist/conversations.d.ts +157 -4
  9. package/dist/conversations.js +69 -6
  10. package/dist/discovery.js +1 -1
  11. package/dist/protocol.d.ts +1 -0
  12. package/dist/protocol.js +12 -5
  13. package/dist/server.d.ts +2 -10
  14. package/dist/server.js +71 -8
  15. package/dist/web/.vite/manifest.json +61 -61
  16. package/dist/web/assets/{choices-b0XhrGQV.js → choices-D-YfnFP6.js} +1 -1
  17. package/dist/web/assets/{console-BSjLGe0T.js → console-Trqc0swD.js} +1 -1
  18. package/dist/web/assets/{dist-Buk0lwzI.js → dist-DZmszrjG.js} +1 -1
  19. package/dist/web/assets/{dist-Cw8hRIlT.js → dist-DpIHRk3B.js} +1 -1
  20. package/dist/web/assets/{dist-foH9IKc6.js → dist-eMx6b8N1.js} +1 -1
  21. package/dist/web/assets/{dist-Tzoe_zm-.js → dist-pF902jHA.js} +1 -1
  22. package/dist/web/assets/{explore-in-BVUy3ZW_.js → explore-in-BCHqjJ7B.js} +1 -1
  23. package/dist/web/assets/{graph-1OdIJ9l7.js → graph-lENgfQNH.js} +1 -1
  24. package/dist/web/assets/index-B3_OVy91.css +1 -0
  25. package/dist/web/assets/{index-CxmItXqa.js → index-BpL_Kl_s.js} +84 -83
  26. package/dist/web/assets/{notes-meaning-pVbbQUGP.js → notes-meaning-DcVGUBBY.js} +1 -1
  27. package/dist/web/assets/{overview-B9UtVJ32.js → overview-CDnVKlOt.js} +3 -3
  28. package/dist/web/assets/{preview-CksD_5KS.js → preview-BEC1E9MK.js} +1 -1
  29. package/dist/web/assets/{review-CMxQlQ-C.js → review-DYP0aCXb.js} +1 -1
  30. package/dist/web/assets/{skills-BFNSyrnD.js → skills-1ec0Z-jx.js} +1 -1
  31. package/dist/web/assets/{skills-work-BGPSnF_I.js → skills-work-DNexV4OJ.js} +1 -1
  32. package/dist/web/assets/{studio-process-CsRoTHOh.js → studio-process-EYQgikxq.js} +1 -1
  33. package/dist/web/assets/{timeline-events-BbuuFWHV.js → timeline-events-Chj2Gbx7.js} +1 -1
  34. package/dist/web/assets/{work-turns-BvJlIMmA.js → work-turns-CT9RVcWY.js} +1 -1
  35. package/dist/web/assets/{workspace-CWlkjLNx.js → workspace-COmCbGV3.js} +1 -1
  36. package/dist/web/composition.json +58 -58
  37. package/dist/web/index.html +2 -2
  38. package/dist/web/renderer.json +1 -1
  39. package/docs/FRONTEND.md +26 -18
  40. package/docs/HEADLESS.md +37 -27
  41. package/node_modules/@rho-workspace/plugin-agent/README.md +29 -0
  42. package/node_modules/@rho-workspace/plugin-agent/dist/acp-command.d.ts +1 -0
  43. package/node_modules/@rho-workspace/plugin-agent/dist/acp-command.js +9 -1
  44. package/node_modules/@rho-workspace/plugin-agent/dist/acp-conversation.d.ts +1 -0
  45. package/node_modules/@rho-workspace/plugin-agent/dist/acp-conversation.js +10 -0
  46. package/node_modules/@rho-workspace/plugin-agent/dist/external-session-contract.js +10 -5
  47. package/node_modules/@rho-workspace/plugin-agent/dist/external-session.d.ts +12 -1
  48. package/node_modules/@rho-workspace/plugin-agent/dist/native-sessions.d.ts +70 -0
  49. package/node_modules/@rho-workspace/plugin-agent/dist/native-sessions.js +538 -0
  50. package/node_modules/@rho-workspace/plugin-agent/package.json +2 -1
  51. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
  52. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
  53. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
  54. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
  55. package/node_modules/hono/dist/cjs/client/fetch-result-please.js +1 -1
  56. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +2 -1
  57. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +5 -3
  58. package/node_modules/hono/dist/cjs/jsx/base.js +49 -30
  59. package/node_modules/hono/dist/cjs/jsx/components.js +2 -2
  60. package/node_modules/hono/dist/cjs/jsx/constants.js +2 -0
  61. package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +13 -17
  62. package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -1
  63. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +1 -0
  64. package/node_modules/hono/dist/cjs/middleware/timing/timing.js +4 -3
  65. package/node_modules/hono/dist/cjs/utils/cookie.js +2 -2
  66. package/node_modules/hono/dist/cjs/utils/mime.js +1 -1
  67. package/node_modules/hono/dist/cjs/utils/url.js +1 -1
  68. package/node_modules/hono/dist/client/fetch-result-please.js +1 -1
  69. package/node_modules/hono/dist/helper/accepts/accepts.js +2 -1
  70. package/node_modules/hono/dist/helper/ssg/ssg.js +5 -3
  71. package/node_modules/hono/dist/jsx/base.js +49 -32
  72. package/node_modules/hono/dist/jsx/components.js +2 -2
  73. package/node_modules/hono/dist/jsx/constants.js +2 -1
  74. package/node_modules/hono/dist/jsx/jsx-runtime.js +15 -19
  75. package/node_modules/hono/dist/middleware/etag/index.js +3 -1
  76. package/node_modules/hono/dist/middleware/language/language.js +1 -1
  77. package/node_modules/hono/dist/middleware/pretty-json/index.js +1 -0
  78. package/node_modules/hono/dist/middleware/timing/timing.js +4 -3
  79. package/node_modules/hono/dist/utils/cookie.js +2 -2
  80. package/node_modules/hono/dist/utils/mime.js +1 -1
  81. package/node_modules/hono/dist/utils/url.js +1 -1
  82. package/node_modules/hono/package.json +1 -1
  83. package/package.json +2 -2
  84. package/protocol/index.json +39 -33
  85. package/protocol/operations/agent.sessions.list.json +49 -3
  86. package/protocol/operations/agent.sessions.read.json +53 -4
  87. package/protocol/operations/conversation.configure.json +29 -0
  88. package/protocol/operations/conversation.decide.json +29 -0
  89. package/protocol/operations/conversation.list.json +29 -0
  90. package/protocol/operations/conversation.permission.json +29 -0
  91. package/protocol/operations/conversation.read.json +29 -0
  92. package/protocol/operations/conversation.restore.json +29 -0
  93. package/protocol/operations/conversation.send.json +29 -0
  94. package/protocol/operations/conversation.settings.check.json +92 -0
  95. package/protocol/operations/conversation.settings.read.json +92 -0
  96. package/protocol/operations/conversation.settings.update.json +92 -0
  97. package/protocol/operations/conversation.start.json +46 -1
  98. package/protocol/operations/conversation.stop.json +29 -0
  99. package/protocol/operations/conversation.trash.json +29 -0
  100. package/protocol/operations/observation.snapshot.json +29 -0
  101. package/protocol/operations/session.instructions.json +43 -0
  102. package/vendor/composition.json +74 -74
  103. package/vendor/rho-workspace-plugin-agent-0.4.30.tgz +0 -0
  104. package/web/theme.css +12 -0
  105. package/dist/web/assets/index-CsC3sTRq.css +0 -1
  106. package/vendor/rho-workspace-plugin-agent-0.4.29.tgz +0 -0
@@ -253,7 +253,7 @@
253
253
  ]
254
254
  },
255
255
  "../node_modules/@codemirror/lang-markdown/dist/index.js": {
256
- "file": "assets/dist-Buk0lwzI.js",
256
+ "file": "assets/dist-DZmszrjG.js",
257
257
  "name": "dist",
258
258
  "src": "../node_modules/@codemirror/lang-markdown/dist/index.js",
259
259
  "isDynamicEntry": true,
@@ -261,22 +261,22 @@
261
261
  "index.html",
262
262
  "_dist-DCtcCJPs.js",
263
263
  "../node_modules/@codemirror/language/dist/index.js",
264
- "_dist-Cw8hRIlT.js"
264
+ "_dist-DpIHRk3B.js"
265
265
  ]
266
266
  },
267
267
  "../node_modules/@codemirror/lang-python/dist/index.js": {
268
- "file": "assets/dist-foH9IKc6.js",
268
+ "file": "assets/dist-eMx6b8N1.js",
269
269
  "name": "dist",
270
270
  "src": "../node_modules/@codemirror/lang-python/dist/index.js",
271
271
  "isDynamicEntry": true,
272
272
  "imports": [
273
273
  "_dist-DCtcCJPs.js",
274
274
  "../node_modules/@codemirror/language/dist/index.js",
275
- "_dist-Cw8hRIlT.js"
275
+ "_dist-DpIHRk3B.js"
276
276
  ]
277
277
  },
278
278
  "../node_modules/@codemirror/language/dist/index.js": {
279
- "file": "assets/dist-Tzoe_zm-.js",
279
+ "file": "assets/dist-pF902jHA.js",
280
280
  "name": "dist",
281
281
  "src": "../node_modules/@codemirror/language/dist/index.js",
282
282
  "isDynamicEntry": true,
@@ -304,12 +304,8 @@
304
304
  "_home-CCbP6kS-.js"
305
305
  ]
306
306
  },
307
- "_choices-DLah50GC.css": {
308
- "file": "assets/choices-DLah50GC.css",
309
- "src": "_choices-DLah50GC.css"
310
- },
311
- "_choices-b0XhrGQV.js": {
312
- "file": "assets/choices-b0XhrGQV.js",
307
+ "_choices-D-YfnFP6.js": {
308
+ "file": "assets/choices-D-YfnFP6.js",
313
309
  "name": "choices",
314
310
  "imports": [
315
311
  "_rolldown-runtime-XKyaHtl9.js",
@@ -317,14 +313,22 @@
317
313
  "_markdown-0ngRuTpW.js",
318
314
  "_canvas-D8rDdfDz.js",
319
315
  "index.html",
320
- "_notes-meaning-pVbbQUGP.js"
316
+ "_notes-meaning-DcVGUBBY.js"
321
317
  ],
322
318
  "css": [
323
319
  "assets/choices-DLah50GC.css"
324
320
  ]
325
321
  },
326
- "_console-BSjLGe0T.js": {
327
- "file": "assets/console-BSjLGe0T.js",
322
+ "_choices-DLah50GC.css": {
323
+ "file": "assets/choices-DLah50GC.css",
324
+ "src": "_choices-DLah50GC.css"
325
+ },
326
+ "_console-By4Mvn1y.css": {
327
+ "file": "assets/console-By4Mvn1y.css",
328
+ "src": "_console-By4Mvn1y.css"
329
+ },
330
+ "_console-Trqc0swD.js": {
331
+ "file": "assets/console-Trqc0swD.js",
328
332
  "name": "console",
329
333
  "imports": [
330
334
  "_rolldown-runtime-XKyaHtl9.js",
@@ -334,34 +338,30 @@
334
338
  "_canvas-D8rDdfDz.js",
335
339
  "index.html",
336
340
  "_facts-BMO6V3-3.js",
337
- "_work-turns-BvJlIMmA.js"
341
+ "_work-turns-CT9RVcWY.js"
338
342
  ],
339
343
  "css": [
340
344
  "assets/console-By4Mvn1y.css"
341
345
  ]
342
346
  },
343
- "_console-By4Mvn1y.css": {
344
- "file": "assets/console-By4Mvn1y.css",
345
- "src": "_console-By4Mvn1y.css"
346
- },
347
- "_dist-Cw8hRIlT.js": {
348
- "file": "assets/dist-Cw8hRIlT.js",
347
+ "_dist-DCtcCJPs.js": {
348
+ "file": "assets/dist-DCtcCJPs.js",
349
349
  "name": "dist",
350
350
  "imports": [
351
- "index.html",
352
- "_dist-DCtcCJPs.js",
353
- "../node_modules/@codemirror/language/dist/index.js"
351
+ "_rolldown-runtime-XKyaHtl9.js"
354
352
  ]
355
353
  },
356
- "_dist-DCtcCJPs.js": {
357
- "file": "assets/dist-DCtcCJPs.js",
354
+ "_dist-DpIHRk3B.js": {
355
+ "file": "assets/dist-DpIHRk3B.js",
358
356
  "name": "dist",
359
357
  "imports": [
360
- "_rolldown-runtime-XKyaHtl9.js"
358
+ "index.html",
359
+ "_dist-DCtcCJPs.js",
360
+ "../node_modules/@codemirror/language/dist/index.js"
361
361
  ]
362
362
  },
363
- "_explore-in-BVUy3ZW_.js": {
364
- "file": "assets/explore-in-BVUy3ZW_.js",
363
+ "_explore-in-BCHqjJ7B.js": {
364
+ "file": "assets/explore-in-BCHqjJ7B.js",
365
365
  "name": "explore-in",
366
366
  "imports": [
367
367
  "_react-Dss-ouuy.js",
@@ -402,8 +402,8 @@
402
402
  "_react-Dss-ouuy.js"
403
403
  ]
404
404
  },
405
- "_notes-meaning-pVbbQUGP.js": {
406
- "file": "assets/notes-meaning-pVbbQUGP.js",
405
+ "_notes-meaning-DcVGUBBY.js": {
406
+ "file": "assets/notes-meaning-DcVGUBBY.js",
407
407
  "name": "notes-meaning",
408
408
  "imports": [
409
409
  "index.html"
@@ -420,8 +420,8 @@
420
420
  "file": "assets/rolldown-runtime-XKyaHtl9.js",
421
421
  "name": "rolldown-runtime"
422
422
  },
423
- "_skills-work-BGPSnF_I.js": {
424
- "file": "assets/skills-work-BGPSnF_I.js",
423
+ "_skills-work-DNexV4OJ.js": {
424
+ "file": "assets/skills-work-DNexV4OJ.js",
425
425
  "name": "skills-work",
426
426
  "imports": [
427
427
  "_rolldown-runtime-XKyaHtl9.js",
@@ -439,8 +439,8 @@
439
439
  "_react-Dss-ouuy.js"
440
440
  ]
441
441
  },
442
- "_timeline-events-BbuuFWHV.js": {
443
- "file": "assets/timeline-events-BbuuFWHV.js",
442
+ "_timeline-events-Chj2Gbx7.js": {
443
+ "file": "assets/timeline-events-Chj2Gbx7.js",
444
444
  "name": "timeline-events",
445
445
  "imports": [
446
446
  "_rolldown-runtime-XKyaHtl9.js",
@@ -448,8 +448,8 @@
448
448
  "index.html"
449
449
  ]
450
450
  },
451
- "_work-turns-BvJlIMmA.js": {
452
- "file": "assets/work-turns-BvJlIMmA.js",
451
+ "_work-turns-CT9RVcWY.js": {
452
+ "file": "assets/work-turns-CT9RVcWY.js",
453
453
  "name": "work-turns",
454
454
  "imports": [
455
455
  "_rolldown-runtime-XKyaHtl9.js",
@@ -458,7 +458,7 @@
458
458
  ]
459
459
  },
460
460
  "graph.tsx": {
461
- "file": "assets/graph-1OdIJ9l7.js",
461
+ "file": "assets/graph-lENgfQNH.js",
462
462
  "name": "graph",
463
463
  "src": "graph.tsx",
464
464
  "isDynamicEntry": true,
@@ -468,17 +468,17 @@
468
468
  "_markdown-0ngRuTpW.js",
469
469
  "_canvas-D8rDdfDz.js",
470
470
  "index.html",
471
- "_work-turns-BvJlIMmA.js",
471
+ "_work-turns-CT9RVcWY.js",
472
472
  "_snapshot-CAxBYPvV.js",
473
- "_timeline-events-BbuuFWHV.js",
474
- "_choices-b0XhrGQV.js"
473
+ "_timeline-events-Chj2Gbx7.js",
474
+ "_choices-D-YfnFP6.js"
475
475
  ],
476
476
  "css": [
477
477
  "assets/graph-BYKN84J3.css"
478
478
  ]
479
479
  },
480
480
  "index.html": {
481
- "file": "assets/index-CxmItXqa.js",
481
+ "file": "assets/index-BpL_Kl_s.js",
482
482
  "name": "index",
483
483
  "src": "index.html",
484
484
  "isEntry": true,
@@ -501,17 +501,17 @@
501
501
  "overview.tsx",
502
502
  "preview.tsx",
503
503
  "graph.tsx",
504
- "_console-BSjLGe0T.js",
504
+ "_console-Trqc0swD.js",
505
505
  "index.html",
506
506
  "skills.tsx",
507
507
  "studio-process.tsx"
508
508
  ],
509
509
  "css": [
510
- "assets/index-CsC3sTRq.css"
510
+ "assets/index-B3_OVy91.css"
511
511
  ]
512
512
  },
513
513
  "overview.tsx": {
514
- "file": "assets/overview-B9UtVJ32.js",
514
+ "file": "assets/overview-CDnVKlOt.js",
515
515
  "name": "overview",
516
516
  "src": "overview.tsx",
517
517
  "isDynamicEntry": true,
@@ -523,10 +523,10 @@
523
523
  "_canvas-D8rDdfDz.js",
524
524
  "index.html",
525
525
  "_facts-BMO6V3-3.js",
526
- "_work-turns-BvJlIMmA.js",
527
- "_choices-b0XhrGQV.js",
528
- "_skills-work-BGPSnF_I.js",
529
- "_explore-in-BVUy3ZW_.js",
526
+ "_work-turns-CT9RVcWY.js",
527
+ "_choices-D-YfnFP6.js",
528
+ "_skills-work-DNexV4OJ.js",
529
+ "_explore-in-BCHqjJ7B.js",
530
530
  "_answer-board-CBkGbSLD.js"
531
531
  ],
532
532
  "dynamicImports": [
@@ -537,7 +537,7 @@
537
537
  ]
538
538
  },
539
539
  "preview.tsx": {
540
- "file": "assets/preview-CksD_5KS.js",
540
+ "file": "assets/preview-BEC1E9MK.js",
541
541
  "name": "preview",
542
542
  "src": "preview.tsx",
543
543
  "isDynamicEntry": true,
@@ -547,11 +547,11 @@
547
547
  "_markdown-0ngRuTpW.js",
548
548
  "_canvas-D8rDdfDz.js",
549
549
  "index.html",
550
- "_explore-in-BVUy3ZW_.js"
550
+ "_explore-in-BCHqjJ7B.js"
551
551
  ]
552
552
  },
553
553
  "review.tsx": {
554
- "file": "assets/review-CMxQlQ-C.js",
554
+ "file": "assets/review-DYP0aCXb.js",
555
555
  "name": "review",
556
556
  "src": "review.tsx",
557
557
  "isDynamicEntry": true,
@@ -564,7 +564,7 @@
564
564
  ]
565
565
  },
566
566
  "shell/workspace.tsx": {
567
- "file": "assets/workspace-CWlkjLNx.js",
567
+ "file": "assets/workspace-COmCbGV3.js",
568
568
  "name": "workspace",
569
569
  "src": "shell/workspace.tsx",
570
570
  "isDynamicEntry": true,
@@ -574,14 +574,14 @@
574
574
  "_markdown-0ngRuTpW.js",
575
575
  "_canvas-D8rDdfDz.js",
576
576
  "index.html",
577
- "_console-BSjLGe0T.js",
577
+ "_console-Trqc0swD.js",
578
578
  "_facts-BMO6V3-3.js",
579
579
  "_snapshot-CAxBYPvV.js",
580
- "_explore-in-BVUy3ZW_.js"
580
+ "_explore-in-BCHqjJ7B.js"
581
581
  ]
582
582
  },
583
583
  "skills.tsx": {
584
- "file": "assets/skills-BFNSyrnD.js",
584
+ "file": "assets/skills-1ec0Z-jx.js",
585
585
  "name": "skills",
586
586
  "src": "skills.tsx",
587
587
  "isDynamicEntry": true,
@@ -591,14 +591,14 @@
591
591
  "_home-CCbP6kS-.js",
592
592
  "_markdown-0ngRuTpW.js",
593
593
  "index.html",
594
- "_skills-work-BGPSnF_I.js"
594
+ "_skills-work-DNexV4OJ.js"
595
595
  ],
596
596
  "css": [
597
597
  "assets/skills-WkE0KCzn.css"
598
598
  ]
599
599
  },
600
600
  "studio-process.tsx": {
601
- "file": "assets/studio-process-CsRoTHOh.js",
601
+ "file": "assets/studio-process-EYQgikxq.js",
602
602
  "name": "studio-process",
603
603
  "src": "studio-process.tsx",
604
604
  "isDynamicEntry": true,
@@ -608,9 +608,9 @@
608
608
  "_markdown-0ngRuTpW.js",
609
609
  "_canvas-D8rDdfDz.js",
610
610
  "index.html",
611
- "_console-BSjLGe0T.js",
612
- "_timeline-events-BbuuFWHV.js",
613
- "_notes-meaning-pVbbQUGP.js",
611
+ "_console-Trqc0swD.js",
612
+ "_timeline-events-Chj2Gbx7.js",
613
+ "_notes-meaning-DcVGUBBY.js",
614
614
  "_answer-board-CBkGbSLD.js",
615
615
  "shell/workspace.tsx"
616
616
  ],
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{r}from"./markdown-0ngRuTpW.js";import{N as i}from"./canvas-D8rDdfDz.js";import{J as a,K as o,_t as s,mt as c,pt as l}from"./index-CxmItXqa.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./notes-meaning-pVbbQUGP.js";var g=e(n(),1),_=(e,t)=>e.length>t?e.slice(0,t-1).trimEnd()+`…`:e;function v(e){let{process:t,meanings:n,traces:r}=e,i=new Map(e.files.map(e=>[e.path,e])),o=f(n),s=e.described??new Map,l=new Map,u=new Map,d=new Map,p=[],m=(e,t,n,r,i,a,o)=>{let s=t+`>`+n+`:`+r;e.has(s)||e.set(s,{id:s,from:t,to:n,label:r,basis:i,at:a,turn:o})},h=e=>t.nodes.filter(t=>t.kind===`file`&&t.path===e).flatMap(e=>e.versions??(e.resource?[{resource:e.resource,capturedAt:e.capturedAt??e.at}]:[])).sort((e,t)=>e.capturedAt-t.capturedAt),g=(e,n)=>t.nodes.find(t=>t.kind===`file`&&t.path===e&&(!n||t.resource?.version===n||t.versions?.some(e=>e.resource.version===n))),v=(t,n,a,u)=>{let d=`m:f:`+t,f=l.get(d);if(!f){let p=i.get(t),m=u?.files.find(e=>e.path===t)?.kept??null,g=h(t).at(-1),_=m??(g?{resource:g.resource,at:g.capturedAt}:null),v=c(t,o,s),y=o.get(t);f={id:d,kind:`file`,title:t.split(`/`).at(-1)??t,path:t,at:a,category:p?.category??e.kindOf(t),exists:!!p,bytes:p?.bytes,modifiedAt:p?.modifiedAt,..._?{resource:_.resource,capturedAt:_.at}:{gap:`No version of this file was kept in the Agent's record.`},events:[{key:d,at:a,node:d,turn:n,action:`write`,label:`Named in the notes`}],meaning:{session:``,conversationId:null,...v?{description:{...v,...v.source===`notes`&&y?{trace:r.get(y.statement)}:{}}}:{}}},l.set(d,f)}return f};n.forEach(n=>{let a=n.statements;if(!a.length)return;let o=`m:`+(n.conversationId??`notes-`+n.line),s=t.turns.find(e=>e.conversationId===n.conversationId),c=a.map(e=>r.get(e)?.written?.at).filter(e=>e!==void 0),f=c.length?Math.min(...c):s?.start??0;p.push({id:o,conversationId:n.conversationId??``,title:n.title,agent:s?.agent??`Notes`,start:f,end:Math.max(f,...c),running:!1});let h=e=>r.get(e)?.written?.at??f,g=e=>({session:n.title,conversationId:n.conversationId,...e?{statement:e,trace:r.get(e)}:{}}),y=a.filter(e=>e.kind===`todo`),b=a.find(e=>e.kind===`question`),C={id:`q:`+o,kind:`question`,title:_(b?.text||n.title,160),text:b?.text||n.title,at:b?h(b):f,turn:o,conversationId:n.conversationId??void 0,agent:s?.agent,events:[],meaning:{...g(b),...y.length?{todos:{done:y.filter(e=>e.done).length,total:y.length}}:{}}};l.set(C.id,C);let w=new Map;a.forEach((e,i)=>{if(e.kind!==`finding`&&e.kind!==`choice`)return;let a={id:`m:s:`+o+`:`+e.line,kind:e.kind,title:_(e.text,220),text:e.text,at:h(e),turn:o,conversationId:n.conversationId??void 0,events:[{key:`m:s:`+o+`:`+e.line,at:h(e),node:`m:s:`+o+`:`+e.line,turn:o,action:`write`,label:`Written in the notes`}],meaning:g(e)};l.set(a.id,a),w.set(i,a),m(u,C.id,a.id,e.kind===`finding`?`found`:`chose`,`declared`,h(e),o);for(let t of e.links)m(u,a.id,v(t,o,h(e),r.get(e)).id,e.kind===`finding`?`rests on`:`gives`,`declared`,h(e),o);for(let t of e.alternatives??[])for(let n of t.links)m(u,a.id,v(n,o,h(e),r.get(e)).id,`instead gives`,`declared`,h(e),o);let s=r.get(e)?.written;s&&t.nodes.some(e=>e.id===`q:`+s.turn)&&m(d,a.id,`q:`+s.turn,`written in`,`observed`,s.at,o)}),a.forEach(e=>{if(e.kind!==`figure`)return;let t=e.of===void 0?void 0:w.get(e.of);for(let n of e.links)m(u,(t??C).id,v(n,o,h(e),r.get(e)).id,t?`shown in`:`shows`,`declared`,h(e),o)});let T=()=>new Set([...u.values()].map(e=>e.to));for(let e of a)if(e.kind===`file`)for(let t of e.links){let n=v(t,o,h(e),r.get(e));!T().has(n.id)&&n.category!==`code`&&n.category!==`data`&&m(u,C.id,n.id,`made`,`declared`,h(e),o)}let E=a.filter(e=>e.kind===`method`||e.kind===`file`);for(let t of E){let n=t.links.filter(t=>(i.get(t)?.category??e.kindOf(t))===`code`),a=t.links.filter(t=>(i.get(t)?.category??e.kindOf(t))===`data`);for(let e of n)for(let n of a)m(u,v(e,o,h(t),r.get(t)).id,v(n,o,h(t),r.get(t)).id,`reads`,`declared`,h(t),o)}n.conversationId&&x(o,C,n.conversationId),S(o,n.conversationId);for(let e of E)for(let t of e.links){let n=v(t,o,h(e),r.get(e));T().has(n.id)||m(u,C.id,n.id,n.category===`data`?`uses data`:`uses`,`declared`,h(e),o)}});let y=new Set(n.map(e=>e.conversationId));for(let e of new Set([...s.values()].map(e=>e.conversationId))){if(y.has(e)||!b(e).length)continue;let n=`m:`+e,r=t.turns.find(t=>t.conversationId===e),i=t.nodes.find(t=>t.kind===`question`&&t.conversationId===e),a=b(e).map(e=>Date.parse(e.observedAt)),o=r?.start??Math.min(...a);p.push({id:n,conversationId:e,title:r?.title??`Conversation`,agent:r?.agent??`Agent`,start:o,end:Math.max(o,...a),running:!1});let s={id:`q:`+n,kind:`question`,title:_(i?.text??r?.title??`Conversation`,160),text:i?.text??r?.title??``,at:o,turn:n,conversationId:e,agent:r?.agent,events:[],meaning:{session:r?.title??`Conversation`,conversationId:e,...i?{message:{id:i.id,at:i.at}}:{}}};l.set(s.id,s),x(n,s,e),S(n,e)}function b(t){return[...s.values()].filter(n=>n.conversationId===t&&[`results`,`figures`].includes(i.get(n.path)?.category??e.kindOf(n.path)??``))}function x(e,t,n){for(let r of b(n)){if(l.has(`m:f:`+r.path))continue;let n=Date.parse(r.observedAt),i=v(r.path,e,n);m(u,t.id,i.id,`made`,`observed`,n,e)}}function S(e,n){let r=e=>!n||e.turn.startsWith(n+`/`),i=new Map(t.nodes.map(e=>[e.id,e])),a=!0;for(;a;){a=!1;for(let n of[...l.values()])if(n.kind===`file`&&n.path&&n.events[0]?.turn===e){for(let o of t.edges.filter(e=>r(e)&&i.get(e.to)?.path===n.path)){let r=i.get(o.from);if(r?.kind===`run`)for(let s of t.edges.filter(e=>e.to===r.id&&(e.label===`runs`||e.label===`named`))){let t=i.get(s.from);if(!t?.path||t.path===n.path)continue;let r=l.size,c=v(t.path,e,s.at);m(u,n.id,c.id,s.label===`runs`?`made by`:`named with`,o.basis,o.at,e),l.size>r&&(a=!0)}}if(n.category===`code`)for(let o of t.edges.filter(e=>r(e)&&e.label===`runs`&&i.get(e.from)?.path===n.path))for(let r of t.edges.filter(e=>e.to===o.to&&e.label===`named`)){let t=i.get(r.from);if(!t?.path||t.path===n.path)continue;let o=l.size;m(u,n.id,v(t.path,e,r.at).id,`reads`,`named`,r.at,e),l.size>o&&(a=!0)}}}}for(let e of l.values()){if(e.kind!==`file`||!e.path)continue;let t=g(e.path,e.resource?.version)??g(e.path);t&&m(d,e.id,t.id,`kept as`,`observed`,e.capturedAt??e.at,e.events[0].turn)}let C=`m:f:`+a,w=e=>e.from!==C&&e.to!==C;return{nodes:[...l.values()].filter(e=>e.id!==C),edges:[...u.values()].filter(w),turns:p,traces:[...d.values()].filter(w)}}function y(e,t,n){return n===`process`||!t||!t.nodes.length?e:n===`meaning`?{...e,nodes:t.nodes,edges:t.edges,turns:t.turns,events:[],live:null,omittedNodes:0}:{...e,nodes:[...t.nodes,...e.nodes],edges:[...t.edges,...t.traces,...e.edges],turns:[...t.turns,...e.turns]}}var b={versions:24},x=new Map;function S(e,t,n,r,a,d=[]){let p=t.project.id,h=(0,g.useMemo)(()=>n.nodes.filter(e=>e.kind===`file`&&e.path===`project-notes.md`).flatMap(e=>(e.versions??(e.resource?[{resource:e.resource,capturedAt:e.capturedAt??e.at}]:[])).map(t=>({...t,turn:e.events.find(e=>e.action===`capture`&&e.key.endsWith(`:`+t.resource.id))?.turn??e.events[0]?.turn??``}))).sort((e,t)=>e.capturedAt-t.capturedAt).slice(-b.versions),[n]),_=h.map(e=>e.resource.version).join(`,`),[y,S]=(0,g.useState)([]);return(0,g.useEffect)(()=>{let t=!0;return Promise.all(h.map(t=>{let n=p+`:`+t.resource.id+`@`+t.resource.version;return x.has(n)||x.set(n,s(e,p,t.resource,o.maxTitleBytes).then(e=>new TextDecoder().decode(e)).catch(()=>(x.delete(n),``))),x.get(n).then(e=>({text:e,at:t.capturedAt,turn:t.turn,conversationId:t.turn.split(`/`)[0]??``,resource:t.resource}))})).then(e=>{t&&S(e.filter(e=>e.text))}),()=>{t=!1}},[e,p,_]),(0,g.useMemo)(()=>{let e=m(a.length>o.maxTitleBytes?``:a),t=e=>n.nodes.filter(t=>t.kind===`file`&&t.path===e).flatMap(e=>e.versions??(e.resource?[{resource:e.resource,capturedAt:e.capturedAt??e.at}]:[])).map(e=>({at:e.capturedAt,resource:e.resource})),s=e=>{let t=r.find(t=>t.path===e);return t?.modifiedAt?Date.parse(t.modifiedAt):null},p=new Map;for(let n of e)for(let e of n.statements)p.set(e,u(e,y,t,s));let g=l(d),_=f(e);return{meanings:e,traces:p,layer:v({process:n,meanings:e,traces:p,files:r,kindOf:e=>i(e),described:g}),descriptions:_,versions:{read:y.length,kept:h.length},holds:e=>c(e,_,g)}},[a,y,n,r,d])}var C=t();function w({statement:e,trace:t,conversationId:n,client:i,projectId:a,onPath:o,onSent:s}){let[c,l]=(0,g.useState)(null),u=e=>t?.files.find(t=>t.path===e)?.later,f=e=>e.map(e=>(0,C.jsxs)(`button`,{className:`work-file`,title:e+(u(e)===`kept`?` · a newer version was kept since this was written`:u(e)===`written`?` · written again since this was written`:``),onClick:()=>o(e),children:[(0,C.jsx)(r,{name:/\.(png|jpe?g|svg)$/i.test(e)?`image`:/\.(csv|tsv)$/i.test(e)?`table`:`file`,size:13}),(0,C.jsx)(`span`,{children:e.split(`/`).at(-1)}),u(e)&&(0,C.jsx)(`small`,{children:`changed since`})]},e)),{topic:m,rest:_}=d(p(e.text,e.links)),v=e.alternatives??[];return(0,C.jsx)(`div`,{className:`choice`+(m?``:` untitled`),children:(0,C.jsxs)(`div`,{className:`choice-grid`,children:[m&&(0,C.jsx)(`p`,{className:`choice-topic`,children:m}),(0,C.jsxs)(`div`,{className:`choice-body`,children:[(0,C.jsx)(`p`,{className:`choice-taken`,children:_}),e.links.length>0&&(0,C.jsx)(`div`,{className:`choice-foot`,children:f(e.links)}),v.map((t,r)=>(0,C.jsxs)(`div`,{className:`choice-other`,children:[(0,C.jsxs)(`p`,{children:[(0,C.jsx)(`span`,{className:`choice-other-label`,children:`Other option`}),h(p(t.text,t.links))]}),t.links.length>0&&(0,C.jsx)(`div`,{className:`choice-foot`,children:f(t.links)}),n&&c!==r&&(0,C.jsx)(`button`,{className:`text-button choice-instead`,onClick:()=>l(r),children:`Use this instead…`}),n&&c===r&&(0,C.jsx)(T,{conversationId:n,client:i,projectId:a,taken:e.text,option:t.text,onCancel:()=>l(null),onSent:e=>{l(null),s?.(e)}})]},r))]})]})})}function T({conversationId:e,client:t,projectId:n,taken:r,option:i,onCancel:a,onSent:o}){let[s,c]=(0,g.useState)(`Use this option instead: “${i}” (in place of “${r}”). Redo what depends on it and update the notes.`),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),p=(0,g.useRef)(null);async function m(){if(s.trim()&&!l){p.current?.text!==s&&(p.current={text:s,changeId:`choice-`+crypto.randomUUID()}),u(!0),f(``);try{await t.call(`conversation.send`,{projectId:n,conversationId:e,changeId:p.current.changeId,text:s}),p.current=null,o(e)}catch(e){f(e instanceof Error?e.message:`The message could not be sent.`)}finally{u(!1)}}}return(0,C.jsxs)(`form`,{className:`choice-send`,onSubmit:e=>{e.preventDefault(),m()},onKeyDown:e=>{e.key===`Escape`&&a()},children:[(0,C.jsx)(`textarea`,{rows:3,value:s,"aria-label":`Message to the Agent`,onChange:e=>c(e.target.value),autoFocus:!0}),d&&(0,C.jsx)(`p`,{className:`inline-error`,role:`alert`,children:d}),(0,C.jsxs)(`div`,{className:`choice-send-actions`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`}),(0,C.jsx)(`button`,{type:`submit`,className:`primary`,disabled:l||!s.trim(),children:l?`Sending…`:`Send to the Agent`})]})]})}export{S as n,y as r,w as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{r}from"./markdown-0ngRuTpW.js";import{N as i}from"./canvas-D8rDdfDz.js";import{J as a,K as o,_t as s,mt as c,pt as l}from"./index-BpL_Kl_s.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./notes-meaning-DcVGUBBY.js";var g=e(n(),1),_=(e,t)=>e.length>t?e.slice(0,t-1).trimEnd()+`…`:e;function v(e){let{process:t,meanings:n,traces:r}=e,i=new Map(e.files.map(e=>[e.path,e])),o=f(n),s=e.described??new Map,l=new Map,u=new Map,d=new Map,p=[],m=(e,t,n,r,i,a,o)=>{let s=t+`>`+n+`:`+r;e.has(s)||e.set(s,{id:s,from:t,to:n,label:r,basis:i,at:a,turn:o})},h=e=>t.nodes.filter(t=>t.kind===`file`&&t.path===e).flatMap(e=>e.versions??(e.resource?[{resource:e.resource,capturedAt:e.capturedAt??e.at}]:[])).sort((e,t)=>e.capturedAt-t.capturedAt),g=(e,n)=>t.nodes.find(t=>t.kind===`file`&&t.path===e&&(!n||t.resource?.version===n||t.versions?.some(e=>e.resource.version===n))),v=(t,n,a,u)=>{let d=`m:f:`+t,f=l.get(d);if(!f){let p=i.get(t),m=u?.files.find(e=>e.path===t)?.kept??null,g=h(t).at(-1),_=m??(g?{resource:g.resource,at:g.capturedAt}:null),v=c(t,o,s),y=o.get(t);f={id:d,kind:`file`,title:t.split(`/`).at(-1)??t,path:t,at:a,category:p?.category??e.kindOf(t),exists:!!p,bytes:p?.bytes,modifiedAt:p?.modifiedAt,..._?{resource:_.resource,capturedAt:_.at}:{gap:`No version of this file was kept in the Agent's record.`},events:[{key:d,at:a,node:d,turn:n,action:`write`,label:`Named in the notes`}],meaning:{session:``,conversationId:null,...v?{description:{...v,...v.source===`notes`&&y?{trace:r.get(y.statement)}:{}}}:{}}},l.set(d,f)}return f};n.forEach(n=>{let a=n.statements;if(!a.length)return;let o=`m:`+(n.conversationId??`notes-`+n.line),s=t.turns.find(e=>e.conversationId===n.conversationId),c=a.map(e=>r.get(e)?.written?.at).filter(e=>e!==void 0),f=c.length?Math.min(...c):s?.start??0;p.push({id:o,conversationId:n.conversationId??``,title:n.title,agent:s?.agent??`Notes`,start:f,end:Math.max(f,...c),running:!1});let h=e=>r.get(e)?.written?.at??f,g=e=>({session:n.title,conversationId:n.conversationId,...e?{statement:e,trace:r.get(e)}:{}}),y=a.filter(e=>e.kind===`todo`),b=a.find(e=>e.kind===`question`),C={id:`q:`+o,kind:`question`,title:_(b?.text||n.title,160),text:b?.text||n.title,at:b?h(b):f,turn:o,conversationId:n.conversationId??void 0,agent:s?.agent,events:[],meaning:{...g(b),...y.length?{todos:{done:y.filter(e=>e.done).length,total:y.length}}:{}}};l.set(C.id,C);let w=new Map;a.forEach((e,i)=>{if(e.kind!==`finding`&&e.kind!==`choice`)return;let a={id:`m:s:`+o+`:`+e.line,kind:e.kind,title:_(e.text,220),text:e.text,at:h(e),turn:o,conversationId:n.conversationId??void 0,events:[{key:`m:s:`+o+`:`+e.line,at:h(e),node:`m:s:`+o+`:`+e.line,turn:o,action:`write`,label:`Written in the notes`}],meaning:g(e)};l.set(a.id,a),w.set(i,a),m(u,C.id,a.id,e.kind===`finding`?`found`:`chose`,`declared`,h(e),o);for(let t of e.links)m(u,a.id,v(t,o,h(e),r.get(e)).id,e.kind===`finding`?`rests on`:`gives`,`declared`,h(e),o);for(let t of e.alternatives??[])for(let n of t.links)m(u,a.id,v(n,o,h(e),r.get(e)).id,`instead gives`,`declared`,h(e),o);let s=r.get(e)?.written;s&&t.nodes.some(e=>e.id===`q:`+s.turn)&&m(d,a.id,`q:`+s.turn,`written in`,`observed`,s.at,o)}),a.forEach(e=>{if(e.kind!==`figure`)return;let t=e.of===void 0?void 0:w.get(e.of);for(let n of e.links)m(u,(t??C).id,v(n,o,h(e),r.get(e)).id,t?`shown in`:`shows`,`declared`,h(e),o)});let T=()=>new Set([...u.values()].map(e=>e.to));for(let e of a)if(e.kind===`file`)for(let t of e.links){let n=v(t,o,h(e),r.get(e));!T().has(n.id)&&n.category!==`code`&&n.category!==`data`&&m(u,C.id,n.id,`made`,`declared`,h(e),o)}let E=a.filter(e=>e.kind===`method`||e.kind===`file`);for(let t of E){let n=t.links.filter(t=>(i.get(t)?.category??e.kindOf(t))===`code`),a=t.links.filter(t=>(i.get(t)?.category??e.kindOf(t))===`data`);for(let e of n)for(let n of a)m(u,v(e,o,h(t),r.get(t)).id,v(n,o,h(t),r.get(t)).id,`reads`,`declared`,h(t),o)}n.conversationId&&x(o,C,n.conversationId),S(o,n.conversationId);for(let e of E)for(let t of e.links){let n=v(t,o,h(e),r.get(e));T().has(n.id)||m(u,C.id,n.id,n.category===`data`?`uses data`:`uses`,`declared`,h(e),o)}});let y=new Set(n.map(e=>e.conversationId));for(let e of new Set([...s.values()].map(e=>e.conversationId))){if(y.has(e)||!b(e).length)continue;let n=`m:`+e,r=t.turns.find(t=>t.conversationId===e),i=t.nodes.find(t=>t.kind===`question`&&t.conversationId===e),a=b(e).map(e=>Date.parse(e.observedAt)),o=r?.start??Math.min(...a);p.push({id:n,conversationId:e,title:r?.title??`Conversation`,agent:r?.agent??`Agent`,start:o,end:Math.max(o,...a),running:!1});let s={id:`q:`+n,kind:`question`,title:_(i?.text??r?.title??`Conversation`,160),text:i?.text??r?.title??``,at:o,turn:n,conversationId:e,agent:r?.agent,events:[],meaning:{session:r?.title??`Conversation`,conversationId:e,...i?{message:{id:i.id,at:i.at}}:{}}};l.set(s.id,s),x(n,s,e),S(n,e)}function b(t){return[...s.values()].filter(n=>n.conversationId===t&&[`results`,`figures`].includes(i.get(n.path)?.category??e.kindOf(n.path)??``))}function x(e,t,n){for(let r of b(n)){if(l.has(`m:f:`+r.path))continue;let n=Date.parse(r.observedAt),i=v(r.path,e,n);m(u,t.id,i.id,`made`,`observed`,n,e)}}function S(e,n){let r=e=>!n||e.turn.startsWith(n+`/`),i=new Map(t.nodes.map(e=>[e.id,e])),a=!0;for(;a;){a=!1;for(let n of[...l.values()])if(n.kind===`file`&&n.path&&n.events[0]?.turn===e){for(let o of t.edges.filter(e=>r(e)&&i.get(e.to)?.path===n.path)){let r=i.get(o.from);if(r?.kind===`run`)for(let s of t.edges.filter(e=>e.to===r.id&&(e.label===`runs`||e.label===`named`))){let t=i.get(s.from);if(!t?.path||t.path===n.path)continue;let r=l.size,c=v(t.path,e,s.at);m(u,n.id,c.id,s.label===`runs`?`made by`:`named with`,o.basis,o.at,e),l.size>r&&(a=!0)}}if(n.category===`code`)for(let o of t.edges.filter(e=>r(e)&&e.label===`runs`&&i.get(e.from)?.path===n.path))for(let r of t.edges.filter(e=>e.to===o.to&&e.label===`named`)){let t=i.get(r.from);if(!t?.path||t.path===n.path)continue;let o=l.size;m(u,n.id,v(t.path,e,r.at).id,`reads`,`named`,r.at,e),l.size>o&&(a=!0)}}}}for(let e of l.values()){if(e.kind!==`file`||!e.path)continue;let t=g(e.path,e.resource?.version)??g(e.path);t&&m(d,e.id,t.id,`kept as`,`observed`,e.capturedAt??e.at,e.events[0].turn)}let C=`m:f:`+a,w=e=>e.from!==C&&e.to!==C;return{nodes:[...l.values()].filter(e=>e.id!==C),edges:[...u.values()].filter(w),turns:p,traces:[...d.values()].filter(w)}}function y(e,t,n){return n===`process`||!t||!t.nodes.length?e:n===`meaning`?{...e,nodes:t.nodes,edges:t.edges,turns:t.turns,events:[],live:null,omittedNodes:0}:{...e,nodes:[...t.nodes,...e.nodes],edges:[...t.edges,...t.traces,...e.edges],turns:[...t.turns,...e.turns]}}var b={versions:24},x=new Map;function S(e,t,n,r,a,d=[]){let p=t.project.id,h=(0,g.useMemo)(()=>n.nodes.filter(e=>e.kind===`file`&&e.path===`project-notes.md`).flatMap(e=>(e.versions??(e.resource?[{resource:e.resource,capturedAt:e.capturedAt??e.at}]:[])).map(t=>({...t,turn:e.events.find(e=>e.action===`capture`&&e.key.endsWith(`:`+t.resource.id))?.turn??e.events[0]?.turn??``}))).sort((e,t)=>e.capturedAt-t.capturedAt).slice(-b.versions),[n]),_=h.map(e=>e.resource.version).join(`,`),[y,S]=(0,g.useState)([]);return(0,g.useEffect)(()=>{let t=!0;return Promise.all(h.map(t=>{let n=p+`:`+t.resource.id+`@`+t.resource.version;return x.has(n)||x.set(n,s(e,p,t.resource,o.maxTitleBytes).then(e=>new TextDecoder().decode(e)).catch(()=>(x.delete(n),``))),x.get(n).then(e=>({text:e,at:t.capturedAt,turn:t.turn,conversationId:t.turn.split(`/`)[0]??``,resource:t.resource}))})).then(e=>{t&&S(e.filter(e=>e.text))}),()=>{t=!1}},[e,p,_]),(0,g.useMemo)(()=>{let e=m(a.length>o.maxTitleBytes?``:a),t=e=>n.nodes.filter(t=>t.kind===`file`&&t.path===e).flatMap(e=>e.versions??(e.resource?[{resource:e.resource,capturedAt:e.capturedAt??e.at}]:[])).map(e=>({at:e.capturedAt,resource:e.resource})),s=e=>{let t=r.find(t=>t.path===e);return t?.modifiedAt?Date.parse(t.modifiedAt):null},p=new Map;for(let n of e)for(let e of n.statements)p.set(e,u(e,y,t,s));let g=l(d),_=f(e);return{meanings:e,traces:p,layer:v({process:n,meanings:e,traces:p,files:r,kindOf:e=>i(e),described:g}),descriptions:_,versions:{read:y.length,kept:h.length},holds:e=>c(e,_,g)}},[a,y,n,r,d])}var C=t();function w({statement:e,trace:t,conversationId:n,client:i,projectId:a,onPath:o,onSent:s}){let[c,l]=(0,g.useState)(null),u=e=>t?.files.find(t=>t.path===e)?.later,f=e=>e.map(e=>(0,C.jsxs)(`button`,{className:`work-file`,title:e+(u(e)===`kept`?` · a newer version was kept since this was written`:u(e)===`written`?` · written again since this was written`:``),onClick:()=>o(e),children:[(0,C.jsx)(r,{name:/\.(png|jpe?g|svg)$/i.test(e)?`image`:/\.(csv|tsv)$/i.test(e)?`table`:`file`,size:13}),(0,C.jsx)(`span`,{children:e.split(`/`).at(-1)}),u(e)&&(0,C.jsx)(`small`,{children:`changed since`})]},e)),{topic:m,rest:_}=d(p(e.text,e.links)),v=e.alternatives??[];return(0,C.jsx)(`div`,{className:`choice`+(m?``:` untitled`),children:(0,C.jsxs)(`div`,{className:`choice-grid`,children:[m&&(0,C.jsx)(`p`,{className:`choice-topic`,children:m}),(0,C.jsxs)(`div`,{className:`choice-body`,children:[(0,C.jsx)(`p`,{className:`choice-taken`,children:_}),e.links.length>0&&(0,C.jsx)(`div`,{className:`choice-foot`,children:f(e.links)}),v.map((t,r)=>(0,C.jsxs)(`div`,{className:`choice-other`,children:[(0,C.jsxs)(`p`,{children:[(0,C.jsx)(`span`,{className:`choice-other-label`,children:`Other option`}),h(p(t.text,t.links))]}),t.links.length>0&&(0,C.jsx)(`div`,{className:`choice-foot`,children:f(t.links)}),n&&c!==r&&(0,C.jsx)(`button`,{className:`text-button choice-instead`,onClick:()=>l(r),children:`Use this instead…`}),n&&c===r&&(0,C.jsx)(T,{conversationId:n,client:i,projectId:a,taken:e.text,option:t.text,onCancel:()=>l(null),onSent:e=>{l(null),s?.(e)}})]},r))]})]})})}function T({conversationId:e,client:t,projectId:n,taken:r,option:i,onCancel:a,onSent:o}){let[s,c]=(0,g.useState)(`Use this option instead: “${i}” (in place of “${r}”). Redo what depends on it and update the notes.`),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),p=(0,g.useRef)(null);async function m(){if(s.trim()&&!l){p.current?.text!==s&&(p.current={text:s,changeId:`choice-`+crypto.randomUUID()}),u(!0),f(``);try{await t.call(`conversation.send`,{projectId:n,conversationId:e,changeId:p.current.changeId,text:s}),p.current=null,o(e)}catch(e){f(e instanceof Error?e.message:`The message could not be sent.`)}finally{u(!1)}}}return(0,C.jsxs)(`form`,{className:`choice-send`,onSubmit:e=>{e.preventDefault(),m()},onKeyDown:e=>{e.key===`Escape`&&a()},children:[(0,C.jsx)(`textarea`,{rows:3,value:s,"aria-label":`Message to the Agent`,onChange:e=>c(e.target.value),autoFocus:!0}),d&&(0,C.jsx)(`p`,{className:`inline-error`,role:`alert`,children:d}),(0,C.jsxs)(`div`,{className:`choice-send-actions`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`}),(0,C.jsx)(`button`,{type:`submit`,className:`primary`,disabled:l||!s.trim(),children:l?`Sending…`:`Send to the Agent`})]})]})}export{S as n,y as r,w as t};
@@ -1,4 +1,4 @@
1
- import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{n,t as r}from"./react-Dss-ouuy.js";import{a as i}from"./home-CCbP6kS-.js";import{r as a}from"./markdown-0ngRuTpW.js";import{N as o,i as s}from"./canvas-D8rDdfDz.js";import{At as c,Gt as l,Ht as u,Nt as d,Ut as f,Wt as p,kt as m}from"./index-CxmItXqa.js";import{c as h,l as g,t as _}from"./facts-BMO6V3-3.js";import{t as v}from"./work-turns-BvJlIMmA.js";var y=n(),b=t(r(),1),x={shownBytes:262144,pollMs:700,listed:50},S=e=>e instanceof Error?e.message:`The Console could not be reached.`,C=e=>[`unavailable`,`unauthorized`].includes(e?.error?.kind??``),w=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function T(e){if(e<1e4)return(Math.max(e,100)/1e3).toFixed(1)+` s`;if(e<6e4)return Math.round(e/1e3)+` s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return t+` min`+(n?` `+n+` s`:``)}function E(e,t,n){N();let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)({off:!1,problem:``}),s=(0,b.useCallback)(()=>e.call(`console.list`,{projectId:t,limit:x.listed}).then(e=>{i(e.commands),o({off:!1,problem:``})},e=>o({off:C(e),problem:S(e)})),[e,t]);return(0,b.useEffect)(()=>{s()},[s,n]),{commands:r,...a,read:s}}function D(e,t,{onRan:n,center:r=!1}={}){let[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(``),f=(0,b.useRef)(null),p=(0,b.useRef)(null);async function m(r){if(r.trim()&&!c){f.current?.command!==r&&(f.current={command:r,changeId:`console-`+crypto.randomUUID()}),l(!0),d(``);try{await e.call(`console.run`,{projectId:t,command:r,changeId:f.current.changeId}),f.current=null,a(``),s(``),n?.()}catch(e){d(S(e))}finally{l(!1)}}}async function h(r){try{await e.call(`console.stop`,{projectId:t,commandId:r.commandId,changeId:`stop-`+r.commandId}),n?.()}catch(e){d(S(e))}}function g(e,t){a(e),s(`From `+t+`. Check it, then press Run.`),d(``),r&&p.current?.scrollIntoView({block:`center`}),p.current?.focus()}return{draft:i,setDraft:e=>{a(e),e||s(``)},note:o,busy:c,problem:u,input:p,start:m,stop:h,prepare:g}}function O({folder:e,line:t,problem:n}){N();let{draft:r,setDraft:i,note:a,busy:o,input:s}=t,c=Math.min(8,r.split(`
1
+ import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{n,t as r}from"./react-Dss-ouuy.js";import{a as i}from"./home-CCbP6kS-.js";import{r as a}from"./markdown-0ngRuTpW.js";import{N as o,i as s}from"./canvas-D8rDdfDz.js";import{At as c,Gt as l,Ht as u,Nt as d,Ut as f,Wt as p,kt as m}from"./index-BpL_Kl_s.js";import{c as h,l as g,t as _}from"./facts-BMO6V3-3.js";import{t as v}from"./work-turns-CT9RVcWY.js";var y=n(),b=t(r(),1),x={shownBytes:262144,pollMs:700,listed:50},S=e=>e instanceof Error?e.message:`The Console could not be reached.`,C=e=>[`unavailable`,`unauthorized`].includes(e?.error?.kind??``),w=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function T(e){if(e<1e4)return(Math.max(e,100)/1e3).toFixed(1)+` s`;if(e<6e4)return Math.round(e/1e3)+` s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return t+` min`+(n?` `+n+` s`:``)}function E(e,t,n){N();let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)({off:!1,problem:``}),s=(0,b.useCallback)(()=>e.call(`console.list`,{projectId:t,limit:x.listed}).then(e=>{i(e.commands),o({off:!1,problem:``})},e=>o({off:C(e),problem:S(e)})),[e,t]);return(0,b.useEffect)(()=>{s()},[s,n]),{commands:r,...a,read:s}}function D(e,t,{onRan:n,center:r=!1}={}){let[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(``),f=(0,b.useRef)(null),p=(0,b.useRef)(null);async function m(r){if(r.trim()&&!c){f.current?.command!==r&&(f.current={command:r,changeId:`console-`+crypto.randomUUID()}),l(!0),d(``);try{await e.call(`console.run`,{projectId:t,command:r,changeId:f.current.changeId}),f.current=null,a(``),s(``),n?.()}catch(e){d(S(e))}finally{l(!1)}}}async function h(r){try{await e.call(`console.stop`,{projectId:t,commandId:r.commandId,changeId:`stop-`+r.commandId}),n?.()}catch(e){d(S(e))}}function g(e,t){a(e),s(`From `+t+`. Check it, then press Run.`),d(``),r&&p.current?.scrollIntoView({block:`center`}),p.current?.focus()}return{draft:i,setDraft:e=>{a(e),e||s(``)},note:o,busy:c,problem:u,input:p,start:m,stop:h,prepare:g}}function O({folder:e,line:t,problem:n}){N();let{draft:r,setDraft:i,note:a,busy:o,input:s}=t,c=Math.min(8,r.split(`
2
2
  `).length),l=(0,b.useId)(),u=t.problem||n;return(0,y.jsxs)(`form`,{className:`console-prompt`,onSubmit:e=>{e.preventDefault(),t.start(r)},children:[(0,y.jsxs)(`label`,{htmlFor:l,className:`console-prompt-label`,children:[`Run a command in `,(0,y.jsx)(`strong`,{children:e})]}),(0,y.jsxs)(`div`,{className:`console-line`,children:[(0,y.jsx)(`span`,{"aria-hidden":`true`,children:`$`}),(0,y.jsx)(`textarea`,{id:l,ref:s,rows:c,value:r,spellCheck:!1,autoComplete:`off`,autoCapitalize:`off`,placeholder:`python3 analysis.py`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),t.start(r))}}),(0,y.jsx)(`button`,{type:`submit`,className:`primary`,disabled:o||!r.trim(),children:o?`Starting…`:`Run`})]}),a&&(0,y.jsx)(`p`,{className:`console-note`,children:a}),u&&(0,y.jsx)(`p`,{className:`inline-error`,role:`alert`,children:u})]})}function k(e,t,n,r){let[i,a]=(0,b.useState)({text:``,more:!1,problem:``}),o=(0,b.useRef)(0);return(0,b.useEffect)(()=>{if(!r)return;let i=!0,s,c=async()=>{try{for(;;){if(o.current>=x.shownBytes){a(e=>({...e,more:!0}));return}let r=await e.call(`console.output`,{projectId:t,commandId:n.commandId,offset:o.current,maxBytes:65536});if(!i)return;if(o.current=r.nextOffset,a(e=>({text:e.text+r.text,more:!1,problem:``})),!r.more)break}}catch(e){i&&a(t=>({...t,problem:S(e)}))}i&&n.state===`running`&&(s=setTimeout(c,x.pollMs))};return c(),()=>{i=!1,clearTimeout(s)}},[e,t,n.commandId,n.state,r]),i}var A=e=>e.state===`running`?`Running`:e.state===`stopped`?`Stopped`:e.state===`continuing`?`Still running outside Rho`:e.state===`unknown`?`Outcome unknown`:e.state===`not-started`?`Did not start`:e.exit?.signal?`Ended by `+e.exit.signal:`Exit `+(e.exit?.code??`?`);function j({record:e,client:t,projectId:n,made:r,after:i,onRunAgain:a,onStop:o}){N();let[s,c]=(0,b.useState)(e.state===`running`),[l,u]=(0,b.useState)(Date.now()),d=k(t,n,e,s),f=e.state===`running`;(0,b.useEffect)(()=>{if(!f)return;let e=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(e)},[f]);let p=(e.endedAt?Date.parse(e.endedAt):l)-Date.parse(e.startedAt),m=e.state===`exited`&&e.exit?.code===0,h=[m?``:A(e),p>=1e3?T(p):``].filter(Boolean).join(` · `);return(0,y.jsxs)(`li`,{className:`console-command mine`+(r||f?` made`:``)+(!m&&!f?` problem`:``),children:[(0,y.jsxs)(`details`,{open:s,onToggle:e=>c(e.currentTarget.open),children:[(0,y.jsxs)(`summary`,{children:[(0,y.jsx)(`span`,{className:`console-time`,children:w(Date.parse(e.startedAt))}),(0,y.jsx)(`span`,{className:`console-what`,title:e.command,children:(0,y.jsx)(`code`,{className:`alone`,children:e.command})}),(0,y.jsx)(`span`,{className:`console-end`+(f?` running`:m?``:` problem`),children:h})]}),(0,y.jsxs)(`div`,{className:`console-detail`,children:[e.cwd&&(0,y.jsxs)(`p`,{className:`console-note`,children:[`In `,e.cwd,`/`]}),d.text?(0,y.jsx)(`pre`,{className:`console-output`,ref:e=>{e&&f&&(e.scrollTop=e.scrollHeight)},children:d.text}):(0,y.jsx)(`p`,{className:`console-note`,children:f?`Waiting for output…`:d.problem?``:`It printed nothing.`}),d.more&&(0,y.jsxs)(`p`,{className:`console-note`,children:[`Showing the first `,(x.shownBytes/1024).toFixed(0),` KiB of `,e.kept.toLocaleString(`en-US`),` kept bytes.`]}),e.cut&&!f&&(0,y.jsxs)(`p`,{className:`console-note`,children:[`It printed `,e.bytes.toLocaleString(`en-US`),` bytes; the middle was not kept.`]}),e.problem&&(0,y.jsx)(`p`,{className:`console-note`,children:e.problem}),d.problem&&(0,y.jsx)(`p`,{className:`inline-error`,role:`alert`,children:d.problem}),!f&&e.state!==`continuing`&&(0,y.jsx)(`div`,{className:`console-actions`,children:(0,y.jsx)(`button`,{className:`text-button console-again`,onClick:()=>a(e),children:`Run again`})})]})]}),i,f&&(0,y.jsx)(`div`,{className:`console-actions`,children:(0,y.jsx)(`button`,{className:`text-button console-again`,disabled:!!e.stop,onClick:()=>o(e),children:e.stop?`Stopping…`:`Stop`})})]})}var M=`.console-command { border-top: 1px solid var(--color-divider); }
3
3
  .console-command summary { display: grid; grid-template-columns: 4.6em minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 8px 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer; list-style: none; }
4
4
  .console-command summary:hover { background: var(--color-hover); }
@@ -1,4 +1,4 @@
1
- import{C as e,G as t,I as n,M as r,N as i,O as a}from"./index-CxmItXqa.js";import{c as o,d as s,f as c,g as l,i as u,l as d,m as f,o as p,p as m,t as h,u as g}from"./dist-DCtcCJPs.js";import{LRLanguage as ee,Language as te,LanguageDescription as ne,LanguageSupport as _,ParseContext as re,bracketMatchingHandle as ie,continuedIndent as v,defineLanguageFacet as ae,delimitedIndent as oe,flatIndent as se,foldInside as ce,foldNodeProp as y,foldService as le,indentNodeProp as b,indentUnit as ue,languageDataProp as de,sublanguageProp as fe,syntaxTree as x}from"./dist-Tzoe_zm-.js";import{a as pe,c as S,i as me,n as C,o as he,r as ge,s as _e,t as ve}from"./dist-Cw8hRIlT.js";var ye=class e{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new e(t,n,r,o,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[d.contextHash,r]]}addChild(e,t){e.prop(d.contextHash)!=this.hash&&(e=new f(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new f(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new f(s.none,e,t,n,this.hashProp)})}},w;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(w||={});var be=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},xe=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return E(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Se(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==w.OrderedList?Ae:ke)(n,t,!1);return r>0&&(e.type!=w.BulletList||De(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Ce={[w.Blockquote](e,t,n){return n.next==62&&(n.markers.push(N(w.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(T(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[w.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[w.OrderedList]:Se,[w.BulletList]:Se,[w.Document](){return!0}};function T(e){return e==32||e==9||e==10||e==13}function E(e,t=0){for(;t<e.length&&T(e.charCodeAt(t));)t++;return t}function we(e,t,n){for(;t>n&&T(e.charCodeAt(t-1));)t--;return t}function Te(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Ee(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function De(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!T(n))return-1}return n&&e.next==45&&Me(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(He.SetextHeading)>-1||r<3?-1:1}function Oe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function ke(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||T(e.text.charCodeAt(e.pos+1)))&&(!n||Oe(t,w.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Ae(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!T(e.text.charCodeAt(r+1))||n&&!Oe(t,w.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function je(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Me(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&T(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var Ne=/^[ \t]*$/,Pe=/-->/,Fe=/\?>/,Ie=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Pe],[/^\s*<\?/,Fe],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Ne],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Ne]];function Le(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=Ie.length-+!!n;e<t;e++)if(Ie[e][0].test(r))return e;return-1}function Re(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.skipSpace(t),i=e.countIndent(r,t,n);return i>=n+5||r==e.text.length?n+1:i}function D(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==w.CodeText?e[r].to=n:e.push(N(w.CodeText,t,n))}var O={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(D(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){D(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==w.CodeText?D(o,e.from,e.to):o.push(e);s=[]}D(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&D(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=w.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(w.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Te(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=we(t.text,t.text.length,o),c=[N(w.CodeMark,r,r+a)];o<s&&c.push(N(w.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&D(c,e.lineStart-1,e.lineStart),c.push(N(w.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}{o=!0,n||(D(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(D(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(w.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Ee(t);return n<0?!1:(e.startContext(w.Blockquote,t.pos),e.addNode(w.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(De(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(w.HorizontalRule,n),!0},BulletList(e,t){let n=ke(t,e,!1);if(n<0)return!1;e.block.type!=w.BulletList&&e.startContext(w.BulletList,t.basePos,t.next);let r=Re(t,t.pos+1);return e.startContext(w.ListItem,t.basePos,r-t.baseIndent),e.addNode(w.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Ae(t,e,!1);if(n<0)return!1;e.block.type!=w.OrderedList&&e.startContext(w.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=Re(t,t.pos+n);return e.startContext(w.ListItem,t.basePos,r-t.baseIndent),e.addNode(w.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=je(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=we(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!T(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(w.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(w.HeaderMark,o-r,a-r);let c=s.finish(w.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=Le(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=Ie[n][1],a=[],o=i!=Ne;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==Pe?w.CommentBlock:i==Fe?w.ProcessingInstructionBlock:w.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},ze=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
1
+ import{C as e,G as t,I as n,M as r,N as i,O as a}from"./index-BpL_Kl_s.js";import{c as o,d as s,f as c,g as l,i as u,l as d,m as f,o as p,p as m,t as h,u as g}from"./dist-DCtcCJPs.js";import{LRLanguage as ee,Language as te,LanguageDescription as ne,LanguageSupport as _,ParseContext as re,bracketMatchingHandle as ie,continuedIndent as v,defineLanguageFacet as ae,delimitedIndent as oe,flatIndent as se,foldInside as ce,foldNodeProp as y,foldService as le,indentNodeProp as b,indentUnit as ue,languageDataProp as de,sublanguageProp as fe,syntaxTree as x}from"./dist-pF902jHA.js";import{a as pe,c as S,i as me,n as C,o as he,r as ge,s as _e,t as ve}from"./dist-DpIHRk3B.js";var ye=class e{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new e(t,n,r,o,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[d.contextHash,r]]}addChild(e,t){e.prop(d.contextHash)!=this.hash&&(e=new f(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new f(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new f(s.none,e,t,n,this.hashProp)})}},w;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(w||={});var be=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},xe=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return E(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Se(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==w.OrderedList?Ae:ke)(n,t,!1);return r>0&&(e.type!=w.BulletList||De(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Ce={[w.Blockquote](e,t,n){return n.next==62&&(n.markers.push(N(w.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(T(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[w.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[w.OrderedList]:Se,[w.BulletList]:Se,[w.Document](){return!0}};function T(e){return e==32||e==9||e==10||e==13}function E(e,t=0){for(;t<e.length&&T(e.charCodeAt(t));)t++;return t}function we(e,t,n){for(;t>n&&T(e.charCodeAt(t-1));)t--;return t}function Te(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Ee(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function De(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!T(n))return-1}return n&&e.next==45&&Me(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(He.SetextHeading)>-1||r<3?-1:1}function Oe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function ke(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||T(e.text.charCodeAt(e.pos+1)))&&(!n||Oe(t,w.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Ae(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!T(e.text.charCodeAt(r+1))||n&&!Oe(t,w.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function je(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Me(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&T(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var Ne=/^[ \t]*$/,Pe=/-->/,Fe=/\?>/,Ie=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Pe],[/^\s*<\?/,Fe],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Ne],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Ne]];function Le(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=Ie.length-+!!n;e<t;e++)if(Ie[e][0].test(r))return e;return-1}function Re(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.skipSpace(t),i=e.countIndent(r,t,n);return i>=n+5||r==e.text.length?n+1:i}function D(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==w.CodeText?e[r].to=n:e.push(N(w.CodeText,t,n))}var O={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(D(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){D(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==w.CodeText?D(o,e.from,e.to):o.push(e);s=[]}D(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&D(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=w.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(w.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Te(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=we(t.text,t.text.length,o),c=[N(w.CodeMark,r,r+a)];o<s&&c.push(N(w.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&D(c,e.lineStart-1,e.lineStart),c.push(N(w.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}{o=!0,n||(D(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(D(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(w.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Ee(t);return n<0?!1:(e.startContext(w.Blockquote,t.pos),e.addNode(w.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(De(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(w.HorizontalRule,n),!0},BulletList(e,t){let n=ke(t,e,!1);if(n<0)return!1;e.block.type!=w.BulletList&&e.startContext(w.BulletList,t.basePos,t.next);let r=Re(t,t.pos+1);return e.startContext(w.ListItem,t.basePos,r-t.baseIndent),e.addNode(w.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Ae(t,e,!1);if(n<0)return!1;e.block.type!=w.OrderedList&&e.startContext(w.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=Re(t,t.pos+n);return e.startContext(w.ListItem,t.basePos,r-t.baseIndent),e.addNode(w.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=je(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=we(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!T(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(w.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(w.HeaderMark,o-r,a-r);let c=s.finish(w.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=Le(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=Ie[n][1],a=[],o=i!=Ne;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==Pe?w.CommentBlock:i==Fe?w.ProcessingInstructionBlock:w.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},ze=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
2
2
  `+t.scrub(),i=this.advance(r);return i>-1&&i<r.length&&this.complete(e,n,i)}finish(e,t){return(this.stage==2||this.stage==3)&&E(t.content,this.pos)==t.content.length&&this.complete(e,t,t.content.length)}complete(e,t,n){return e.addLeafElement(t,N(w.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;)if(this.stage==-1)return-1;else if(this.stage==0){if(!this.nextStage(at(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(N(w.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(rt(e,E(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=E(e,this.pos),n=0;if(t>this.pos){let r=it(e,t,this.start);if(r){let t=Be(e,r.to-this.start);t>0&&(this.nextStage(r),n=t)}}return n||=Be(e,this.pos),n>0&&n<e.length?n:-1}else return Be(e,this.pos)}};function Be(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!T(n))return-1}return t}var Ve=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:Me(t),i=t.next;if(r<0)return!1;let a=N(w.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,N(i==61?w.SetextHeading1:w.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),a])),!0}finish(){return!1}},He={LinkReference(e,t){return t.content.charCodeAt(0)==91?new ze(t):null},SetextHeading(){return new Ve}},Ue=[(e,t)=>je(t)>=0,(e,t)=>Te(t)>=0,(e,t)=>Ee(t)>=0,(e,t)=>ke(t,e,!0)>=0,(e,t)=>Ae(t,e,!0)>=0,(e,t)=>De(t,e,!0)>=0,(e,t)=>Le(t,e,!0)>=0],We={text:``,end:0},Ge=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new xe,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=ye.create(w.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new ct(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!n||e.markers[t].from<n.end);){let n=e.markers[t++];this.addNode(n.type,n.from,n.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;start:for(;;){for(let t of this.parser.blockParsers)if(t){let n=t(this,e);if(n!=0){if(n==1)return null;e.forward();continue start}}break}if(e.pos==e.text.length)return this.nextLine()?null:this.finish();let t=new be(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let n=e(this,t);n&&t.parsers.push(n)}lines:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break lines}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
3
3
  `+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=lt(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=We;if(t.end=e,e>=this.to)t.text=``;else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<t.end;){n++;let r=this.ranges[n].from,i=this.lineChunkAt(r);t.end=r+i.length,t.text=t.text.slice(0,this.ranges[n-1].to-e)+i,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],n=this.parser.skipContextMarkup[t.type];if(!n)throw Error(`Unhandled block context `+w[t.type]);let r=this.line.markers.length;if(!n(t,this,e)){this.line.markers.length>r&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
4
4
  `?``:t;else{let e=t.indexOf(`