dorkos 0.126.3 → 0.126.4

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 (314) hide show
  1. package/dist/bin/cli.js +138 -93
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-ycWTfXI8.js → AboutPage-CAt15a-r.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-DBecAo4-.js → ActivityErrorState-s4xAcJQR.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-CGuIeDGm.js → ActivityPage-BpSggjZV.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-BRiUvjHA.js → ActivityRow-5PJBHIt2.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-z6z9LKwd.js → AdapterIcon-d8mZODCX.js} +1 -1
  9. package/dist/client/assets/AdapterSetupWizard-R-KxNMiM.js +2 -0
  10. package/dist/client/assets/{AgentOptionRow-BLuSwpNh.js → AgentOptionRow-hemBruhh.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-DazquIgR.js → AgentPicker-DOba9a77.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-BoRmxLKy.js → AgentRequestCard-RFQOrk-W.js} +1 -1
  13. package/dist/client/assets/{AppearancePage-BMiVpe48.js → AppearancePage-1m4bJ-Rg.js} +1 -1
  14. package/dist/client/assets/{ApplyToOverridesDialog-BHIrnfPf.js → ApplyToOverridesDialog-BxeMLhGv.js} +1 -1
  15. package/dist/client/assets/{AttentionSignalRow-CjN8lCWI.js → AttentionSignalRow-BoTonsR5.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-BMBnO0fv.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-Bz6XyZ6v.js} +3 -3
  17. package/dist/client/assets/BindingDialog-CILm91iU.js +1 -0
  18. package/dist/client/assets/{BlintzCanvas-Dd3bC9vw.js → BlintzCanvas-BFJXKo1L.js} +3 -3
  19. package/dist/client/assets/{CanvasCsvContent-B2S75f6B.js → CanvasCsvContent-DzkaHpEo.js} +3 -3
  20. package/dist/client/assets/{CanvasFileContent-CVSfg4MO.js → CanvasFileContent-DZf9SjJn.js} +2 -2
  21. package/dist/client/assets/{CanvasModel3dContent-CNmJsBTS.js → CanvasModel3dContent-Cd8hf6Ba.js} +2 -2
  22. package/dist/client/assets/{ChannelComposer-7KpffyFv.js → ChannelComposer-YXkkFcyY.js} +10 -10
  23. package/dist/client/assets/{ChatAppsOff-D7anOG3n.js → ChatAppsOff-X5Y8OHAz.js} +2 -2
  24. package/dist/client/assets/{CodeMirrorDiff-CfOmRCky.js → CodeMirrorDiff-BsQKbrls.js} +1 -1
  25. package/dist/client/assets/{CodeMirrorEditor-Cyz227_1.js → CodeMirrorEditor-DnkumDd3.js} +1 -1
  26. package/dist/client/assets/{CommitmentList-DKo1Fb1A.js → CommitmentList-BjI2jvMX.js} +1 -1
  27. package/dist/client/assets/{CommitmentsPage-DIcEZ2ka.js → CommitmentsPage-7g68FcGR.js} +1 -1
  28. package/dist/client/assets/{ComputerResourceView-Ck7rJ-SP.js → ComputerResourceView-Dcd0e_Oj.js} +1 -1
  29. package/dist/client/assets/{ComputerViewer-Dw_VpNjD.js → ComputerViewer-Dq3aQyZD.js} +1 -1
  30. package/dist/client/assets/{ConnectionAccessLists-CETLVH7o.js → ConnectionAccessLists-CXPn8ICQ.js} +1 -1
  31. package/dist/client/assets/{ConnectionsPage-ZVWDffcl.js → ConnectionsPage-DEc4JsR5.js} +2 -2
  32. package/dist/client/assets/{ConventionPage-DkJ91wrN.js → ConventionPage-B7cm4O1D.js} +1 -1
  33. package/dist/client/assets/{ExtensionPageRoute-FbJo1Qc0.js → ExtensionPageRoute-ba2uGsYs.js} +2 -2
  34. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-DCLR3iKw.js → FloatingTanStackRouterDevtools-CqogiFob-Dxk_rLHR.js} +1 -1
  35. package/dist/client/assets/{ForwardConsentHost-Buy5XlH7.js → ForwardConsentHost-CNuTTR3q.js} +1 -1
  36. package/dist/client/assets/HandlePage-WIwOCyJg.js +1 -0
  37. package/dist/client/assets/{HeartbeatPage-GXBEcZoJ.js → HeartbeatPage-CEb8SaAx.js} +1 -1
  38. package/dist/client/assets/{KeyEntry-g2VQ33KW.js → KeyEntry-CHJpgP6H.js} +1 -1
  39. package/dist/client/assets/{LexicalField-CLd77PuB.js → LexicalField-B0tWaDy5.js} +1 -1
  40. package/dist/client/assets/{ManagesPage-qCwzJ4Cx.js → ManagesPage-rcz--gCT.js} +1 -1
  41. package/dist/client/assets/{Marketplace-DdkdIVPQ.js → Marketplace-wjAUiULQ.js} +4 -4
  42. package/dist/client/assets/{MarketplaceSourcesView-D44G21ff.js → MarketplaceSourcesView-BMGnEy8T.js} +1 -1
  43. package/dist/client/assets/{McpAppFrame-DVNWJHrn.js → McpAppFrame-CmwiQHxf.js} +2 -2
  44. package/dist/client/assets/{McpSigninBody-BO0OkvOw.js → McpSigninBody-D99PCc0n.js} +1 -1
  45. package/dist/client/assets/{Model3dViewer-Cvcyx2yv.js → Model3dViewer-qUwwZnb2.js} +1 -1
  46. package/dist/client/assets/NamePage-B7VSrPmK.js +1 -0
  47. package/dist/client/assets/{NewDirectMessageMenu-C_hXtliM.js → NewDirectMessageMenu-DyMfEU7i.js} +1 -1
  48. package/dist/client/assets/{NotificationsPage-DP4HAVMA.js → NotificationsPage-BsOaV6Ei.js} +1 -1
  49. package/dist/client/assets/{OpenMeshSwitch-0Mkl8abo.js → OpenMeshSwitch-CjCPWZn0.js} +2 -2
  50. package/dist/client/assets/{OperatorIdentityForm-BRftJqRq.js → OperatorIdentityForm-Cd6B2hxb.js} +1 -1
  51. package/dist/client/assets/{PermissionHistory-Czl5PWN3.js → PermissionHistory-xp6vPQ20.js} +1 -1
  52. package/dist/client/assets/{PermissionsPage-DAsbrl6Q.js → PermissionsPage-DaAJew99.js} +1 -1
  53. package/dist/client/assets/{PersonalityPopover-liTJ0Lns.js → PersonalityPopover-BZaif5Fn.js} +1 -1
  54. package/dist/client/assets/PhotoPage-43WNaavk.js +1 -0
  55. package/dist/client/assets/{PreviewRefusedNotice-DcD1EY2c.js → PreviewRefusedNotice-CCpHgrea.js} +1 -1
  56. package/dist/client/assets/{ProfileFields-Bi_AfHOE.js → ProfileFields-DyVqmcPr.js} +1 -1
  57. package/dist/client/assets/{ProfilePanelContainer-BIbOulLu.js → ProfilePanelContainer-CMRG6AmB.js} +1 -1
  58. package/dist/client/assets/{ProfileRolePicker-BadkFi4V.js → ProfileRolePicker-Q_hY6ybO.js} +1 -1
  59. package/dist/client/assets/{PromptSuggestionChips-C653MlaU.js → PromptSuggestionChips-B5afjbD0.js} +1 -1
  60. package/dist/client/assets/{ReportsToPopover-dIbt6aes.js → ReportsToPopover-CVF7Rtzh.js} +1 -1
  61. package/dist/client/assets/{RoomSurface-CssMcozl.js → RoomSurface-Bz1DfoQD.js} +1 -1
  62. package/dist/client/assets/{RoomsPage-CxwTRRNu.js → RoomsPage-4u74yonc.js} +1 -1
  63. package/dist/client/assets/{RunsOnPopover-lp8n4lgI.js → RunsOnPopover-CnUm4LP2.js} +1 -1
  64. package/dist/client/assets/{RuntimeConnectFlow-BAqkzthF.js → RuntimeConnectFlow-B0TIITVq.js} +1 -1
  65. package/dist/client/assets/{RuntimeSetupDialog-E6f7Rd2W.js → RuntimeSetupDialog-CEUC7GrY.js} +1 -1
  66. package/dist/client/assets/{SeenDevices-xdR3YQNr.js → SeenDevices-CxhuIRp3.js} +2 -2
  67. package/dist/client/assets/{SessionsPage-BNZTufty.js → SessionsPage-l6_Qc7hz.js} +1 -1
  68. package/dist/client/assets/{SettingsDialog-d7SQTDNy.js → SettingsDialog-GEK8nhI8.js} +4 -4
  69. package/dist/client/assets/{SkillsPage-DiqUOZup.js → SkillsPage-PlVj6VdA.js} +1 -1
  70. package/dist/client/assets/{TaskDialogWrapper-5gb-f-Uo.js → TaskDialogWrapper-TspfYk9J.js} +1 -1
  71. package/dist/client/assets/{TasksEmptyState-g-CavcMv.js → TasksEmptyState-DsHh0blU.js} +2 -2
  72. package/dist/client/assets/{TasksPage-BexV_pxB.js → TasksPage-Va0dvkif.js} +1 -1
  73. package/dist/client/assets/{TeamComputerEntry-BFYqGL-G.js → TeamComputerEntry-C6juiObF.js} +1 -1
  74. package/dist/client/assets/{ToolsPage-Dxt6qOdF.js → ToolsPage-C0ESG42C.js} +2 -2
  75. package/dist/client/assets/{TopologyGraph-Cx_6gdbV.js → TopologyGraph-M24Edx-I.js} +3 -3
  76. package/dist/client/assets/TourHost-CcN4uCDR.js +1 -0
  77. package/dist/client/assets/{UnlinkDialog-fgubvOUd.js → UnlinkDialog-DlD1cmRZ.js} +1 -1
  78. package/dist/client/assets/{UnreadDivider-BoLcTO_Z.js → UnreadDivider-DPD9MQ8-.js} +1 -1
  79. package/dist/client/assets/{WidgetErrorCard-CgRMeAEO.js → WidgetErrorCard-Bte2obmw.js} +3 -3
  80. package/dist/client/assets/{WithheldExtensionsNotice-CFHBDyIh.js → WithheldExtensionsNotice-CZibLuKA.js} +1 -1
  81. package/dist/client/assets/{WorkView-5jzcnod5.js → WorkView-PsLjURld.js} +15 -15
  82. package/dist/client/assets/{_shell-DFfXd1ys.js → _shell-Ce_cSF7V.js} +2 -2
  83. package/dist/client/assets/{_shell._home-D2GJeGbi.js → _shell._home-DcZcTXu8.js} +1 -1
  84. package/dist/client/assets/{_shell._home.activity-DRXBBtAq.js → _shell._home.activity-BXw8iSC4.js} +1 -1
  85. package/dist/client/assets/_shell._home.index-BleaCq_y.js +3 -0
  86. package/dist/client/assets/{_shell._home.tasks-Cr4gak8T.js → _shell._home.tasks-gdbnkq3-.js} +1 -1
  87. package/dist/client/assets/{_shell._home.workspaces-DbWciI1g.js → _shell._home.workspaces-BCwJX783.js} +1 -1
  88. package/dist/client/assets/{_shell.channels-C31Txlqh.js → _shell.channels-D-lMqbSA.js} +1 -1
  89. package/dist/client/assets/_shell.connections-BFmTpceq.js +1 -0
  90. package/dist/client/assets/{_shell.feedback-requests-CQc7aVrV.js → _shell.feedback-requests-NKpm6Uhu.js} +1 -1
  91. package/dist/client/assets/_shell.marketplace-DB7NSxDU.js +1 -0
  92. package/dist/client/assets/_shell.marketplace_.sources-WU9ILkRM.js +1 -0
  93. package/dist/client/assets/_shell.session-CchZWYRA.js +1 -0
  94. package/dist/client/assets/{_shell.team-BlLU5BMC.js → _shell.team-DcCRbdAb.js} +4 -4
  95. package/dist/client/assets/{_shell.threads-YmF9dQnZ.js → _shell.threads-BLy6Cgqk.js} +1 -1
  96. package/dist/client/assets/_shell.x._extensionId-CVW0g7Rb.js +1 -0
  97. package/dist/client/assets/_shell.x._extensionId_._-CVW0g7Rb.js +1 -0
  98. package/dist/client/assets/{abnfDiagram-WEYOIA3C-DLiXaMmC.js → abnfDiagram-WEYOIA3C-DpkXbw1_.js} +1 -1
  99. package/dist/client/assets/{access-copy-xWnaUps1.js → access-copy-Y2_F9uAx.js} +1 -1
  100. package/dist/client/assets/{arc-AndXXvZc.js → arc-B3bZAGvi.js} +1 -1
  101. package/dist/client/assets/{architectureDiagram-ZHVYKT53-CM4tGveM.js → architectureDiagram-ZHVYKT53-BKR1sFvp.js} +1 -1
  102. package/dist/client/assets/{banner-BH1gXPTc.js → banner-CqhUGJmy.js} +2 -2
  103. package/dist/client/assets/{blockDiagram-RJAE7QA3-DenkdFXV.js → blockDiagram-RJAE7QA3-C2I50BMQ.js} +1 -1
  104. package/dist/client/assets/{c4Diagram-XDPPPE54-DMAlFuoX.js → c4Diagram-XDPPPE54-dhHi_wUH.js} +1 -1
  105. package/dist/client/assets/{card-TbpEl6EH.js → card-CM7-_8nD.js} +1 -1
  106. package/dist/client/assets/channel-NlrM9BR7.js +1 -0
  107. package/dist/client/assets/{chunk-2E7WHVMD-u0q5vCEc.js → chunk-2E7WHVMD-B0B27SHJ.js} +1 -1
  108. package/dist/client/assets/{chunk-2Q5K7J3B-DBTggfjR.js → chunk-2Q5K7J3B-dsUDjsr2.js} +1 -1
  109. package/dist/client/assets/{chunk-4EMNKR2T-zu55wq-c.js → chunk-4EMNKR2T-C3IdUlS9.js} +1 -1
  110. package/dist/client/assets/{chunk-55XCU76K-XLIA3Qss.js → chunk-55XCU76K-D6qgX8rY.js} +1 -1
  111. package/dist/client/assets/{chunk-5VM5RSS4-DmGjbtZg.js → chunk-5VM5RSS4-CWhRZZS1.js} +1 -1
  112. package/dist/client/assets/{chunk-JWPE2WC7-ikMrk6md.js → chunk-JWPE2WC7-Bd3RyNB2.js} +1 -1
  113. package/dist/client/assets/{chunk-VQ5W62QI-cfwin8SC.js → chunk-VQ5W62QI-HqUjzAO7.js} +1 -1
  114. package/dist/client/assets/{chunk-XXDRQBXY-Cn3e0QEQ.js → chunk-XXDRQBXY-CfeGRauy.js} +1 -1
  115. package/dist/client/assets/{chunk-ZCHMQSOR-7RkBP94K.js → chunk-ZCHMQSOR-D30UE34C.js} +2 -2
  116. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-CqVol7t8.js → classDiagram-v2-4MYWR3UA-ClIZEeNx.js} +1 -1
  117. package/dist/client/assets/{command-2pl_Cn7b.js → command-DuhX52Bi.js} +1 -1
  118. package/dist/client/assets/{cose-bilkent-JH36ORCC-m0tmlDnx.js → cose-bilkent-JH36ORCC-C_MZbmxw.js} +1 -1
  119. package/dist/client/assets/{cpu-CdCfSlSR.js → cpu-BMUMZCWW.js} +1 -1
  120. package/dist/client/assets/{cynefin-EF2NZ3EQ-Cf7ajLou.js → cynefin-EF2NZ3EQ-DjzC1gsw.js} +1 -1
  121. package/dist/client/assets/{cynefinDiagram-WF24UDRP-Dl8GJr0l.js → cynefinDiagram-WF24UDRP-Dnu1pf_9.js} +1 -1
  122. package/dist/client/assets/{dagre-NK4GIZVX-2yAF6nW_.js → dagre-NK4GIZVX-Bruwoqfg.js} +1 -1
  123. package/dist/client/assets/{diagram-CBK3MWTC-DaBb9JFm.js → diagram-CBK3MWTC-Co7nk3xQ.js} +1 -1
  124. package/dist/client/assets/{diagram-I5XIIV2D-BMeCfhD1.js → diagram-I5XIIV2D-CDJY0Snc.js} +1 -1
  125. package/dist/client/assets/{diagram-ODIL2UCW-ClVKCieB.js → diagram-ODIL2UCW-CF0utpvI.js} +1 -1
  126. package/dist/client/assets/{diagram-PFBEJUXE-DFIKk-tB.js → diagram-PFBEJUXE-BrLRX5Ip.js} +1 -1
  127. package/dist/client/assets/{diagram-RJA3I4VV-DzC_xtYu.js → diagram-RJA3I4VV-BOo6-thr.js} +1 -1
  128. package/dist/client/assets/{diagram-TYUNFSNR-BroMVHm2.js → diagram-TYUNFSNR-B-206XZy.js} +1 -1
  129. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-GMsyIh86.js → ebnfDiagram-V4P3TTPT-C6SZjvSQ.js} +1 -1
  130. package/dist/client/assets/{elk-QONTBCTQ-DIpw6SW5.js → elk-QONTBCTQ-B_QHOQ8G.js} +1 -1
  131. package/dist/client/assets/{empty-state-B7ufhAFk.js → empty-state-BzWMBBQZ.js} +1 -1
  132. package/dist/client/assets/{erDiagram-KYQIGQAA-CsezeWpx.js → erDiagram-KYQIGQAA-BTKJgVOK.js} +1 -1
  133. package/dist/client/assets/{execution-config-DRqIsff0.js → execution-config-D_PgYyCI.js} +1 -1
  134. package/dist/client/assets/{file-DHPgnMgj.js → file-DiYwTQdD.js} +1 -1
  135. package/dist/client/assets/{file-exclamation-point-DtjBa2XX.js → file-exclamation-point-CnQYdJiV.js} +1 -1
  136. package/dist/client/assets/{file-text-wmrSy3Io.js → file-text-DLPhIP0f.js} +1 -1
  137. package/dist/client/assets/{find-latest-widget-fence-Bv9D10ve.js → find-latest-widget-fence-BYtG5PzD.js} +3 -3
  138. package/dist/client/assets/{flowDiagram-IUGLLWBU-BGwNqglr.js → flowDiagram-IUGLLWBU-o2In4cGl.js} +1 -1
  139. package/dist/client/assets/{form-CA_eiUg-.js → form-DUFlQ-yL.js} +1 -1
  140. package/dist/client/assets/{format-cron-YPhIy57w.js → format-cron-D5dtMPdH.js} +1 -1
  141. package/dist/client/assets/{ganttDiagram-R7GPNTJY-4IlzTCzA.js → ganttDiagram-R7GPNTJY-WwrWLB2J.js} +1 -1
  142. package/dist/client/assets/{git-branch-BLIYLcM4.js → git-branch-uZFa3Tmr.js} +1 -1
  143. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-HeaC8vlP.js → gitGraphDiagram-PDYL7XHY-C1yG6xrf.js} +1 -1
  144. package/dist/client/assets/{graph-Ch9lnHSS.js → graph-C10tj8MW.js} +1 -1
  145. package/dist/client/assets/{heart-D4fTvM5q.js → heart--8btr31M.js} +1 -1
  146. package/dist/client/assets/{highlighted-body-KPVGNVTW-KPma22SA.js → highlighted-body-KPVGNVTW-DGp-Vg6c.js} +1 -1
  147. package/dist/client/assets/{image-lightbox-DI18fB2Q.js → image-lightbox-BfwZy_vF.js} +1 -1
  148. package/dist/client/assets/{image-off-DRgXXpgv.js → image-off-Bmtj2Xtq.js} +1 -1
  149. package/dist/client/assets/{index--2mMmier.js → index-8hXtJ0Xw.js} +1 -1
  150. package/dist/client/assets/{index-2J89pJxF.js → index-B5i5B8F0.js} +1 -1
  151. package/dist/client/assets/{index-mRMaqxu5.js → index-BBaFVr5z.js} +1 -1
  152. package/dist/client/assets/{index-B_56Srtt.js → index-BCZa5De0.js} +1 -1
  153. package/dist/client/assets/{index-COoO8dzi.js → index-BE8yM241.js} +1 -1
  154. package/dist/client/assets/{index-C3IsCAxA.js → index-BHXG7bNX.js} +1 -1
  155. package/dist/client/assets/{index-DHZS9Lod.js → index-BJ_fl1Gy.js} +1 -1
  156. package/dist/client/assets/{index-rPJ8b_DO.js → index-BbIFaQ9_.js} +1 -1
  157. package/dist/client/assets/{index-B-4XmK5Q.js → index-BlHuuCes.js} +1 -1
  158. package/dist/client/assets/{index-DpvGUFpV.js → index-BtrV6g02.js} +1 -1
  159. package/dist/client/assets/{index-3UGWygRZ.js → index-C-tNYOVV.js} +1 -1
  160. package/dist/client/assets/{index-C-X6jaVm.js → index-C3LZBxuM.js} +1 -1
  161. package/dist/client/assets/{index-D9w0FBQG.js → index-CO9QUYdl.js} +1 -1
  162. package/dist/client/assets/{index-CRCfkwyN.js → index-CP47qL8N.js} +1 -1
  163. package/dist/client/assets/{index-CTTaeOCw.js → index-CYM65t4i.js} +1 -1
  164. package/dist/client/assets/{index-bzM-k5lI.js → index-CaZ9yNIm.js} +1 -1
  165. package/dist/client/assets/index-CaxFHvSK.js +1 -0
  166. package/dist/client/assets/index-CdHuEKYh.js +1 -0
  167. package/dist/client/assets/{index-QSo53dH-.js → index-CoL3MmPh.js} +1 -1
  168. package/dist/client/assets/{index-BAd8jUzo.js → index-CtN6_QCQ.js} +2 -2
  169. package/dist/client/assets/{index-Dbujw1c2.js → index-CvIKejlx.js} +1 -1
  170. package/dist/client/assets/{index-Ix2nCAz0.js → index-CypEgDik.js} +1 -1
  171. package/dist/client/assets/index-Cz9N1NHd.js +1 -0
  172. package/dist/client/assets/{index-CucieFDK.js → index-D-ZRSiaH.js} +1 -1
  173. package/dist/client/assets/{index-D0cIffaH.js → index-D8ZcqMea.js} +1 -1
  174. package/dist/client/assets/{index-DuvW22xi.js → index-D97clHqL.js} +1 -1
  175. package/dist/client/assets/index-DAaYbj1s.js +1 -0
  176. package/dist/client/assets/{index-BY0SKYuc.js → index-DI9IsN-O.js} +1 -1
  177. package/dist/client/assets/{index-uy36h8lC.js → index-DLPkp7I9.js} +1 -1
  178. package/dist/client/assets/{index-DTRAR0KK.js → index-DMTfnznD.js} +1 -1
  179. package/dist/client/assets/{index-JoxvTUfo.js → index-DZQUx5pX.js} +3 -3
  180. package/dist/client/assets/{index-EDXuyCOT.js → index-DamNtsio.js} +1 -1
  181. package/dist/client/assets/{index-jk2K24il.js → index-DenTxAiI.js} +1 -1
  182. package/dist/client/assets/{index-uG06zgQo.js → index-DmG7yphM.js} +1 -1
  183. package/dist/client/assets/{index-zvAbU6ah.js → index-Dqouol3i.js} +1 -1
  184. package/dist/client/assets/{index-DSIdPh8G.js → index-Dsj1fDYU.js} +1 -1
  185. package/dist/client/assets/{index-BtRM2yox.js → index-E5KPj_ZX.js} +1 -1
  186. package/dist/client/assets/{index-ClbMjgcZ.js → index-LGTvsZzp.js} +1 -1
  187. package/dist/client/assets/{index-BmlBYrxT.js → index-Nr39AP-T.js} +1 -1
  188. package/dist/client/assets/{index-qEI7Rsr1.js → index-YrSNUw95.js} +1 -1
  189. package/dist/client/assets/index-fge85Gub.js +1053 -0
  190. package/dist/client/assets/{index-Dy9bWvna.js → index-mweR5xOP.js} +1 -1
  191. package/dist/client/assets/{index-DbV3-jog.js → index-ocZzSFoR.js} +1 -1
  192. package/dist/client/assets/{index.esm-CxXuMuQv.js → index.esm-BEGwgVfU.js} +1 -1
  193. package/dist/client/assets/{infoDiagram-MVDRKAX5-g9EeD2xH.js → infoDiagram-MVDRKAX5-oeBcoEBA.js} +1 -1
  194. package/dist/client/assets/{inline-code-14c1Gacs.js → inline-code-7dwi7wWG.js} +1 -1
  195. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-Zv5DrRnv.js → ishikawaDiagram-HPEHV2GE-CLIGz304.js} +1 -1
  196. package/dist/client/assets/{journeyDiagram-BOSHW7O7-COiWWTez.js → journeyDiagram-BOSHW7O7-Cg0HlPT5.js} +1 -1
  197. package/dist/client/assets/{kanban-definition-FNSA4HC5-DnQa8qXB.js → kanban-definition-FNSA4HC5-DXaqYXhm.js} +1 -1
  198. package/dist/client/assets/{layers-D_NEJsnH.js → layers-BhECZJWp.js} +1 -1
  199. package/dist/client/assets/{lightbulb-EadQi_Lr.js → lightbulb-DjMxuZnu.js} +1 -1
  200. package/dist/client/assets/{link-2-DugR2HHU.js → link-2-BY2WyWzK.js} +1 -1
  201. package/dist/client/assets/{list-runtime-types-iJaKcim4.js → list-runtime-types-hMouIGtG.js} +1 -1
  202. package/dist/client/assets/{markdown-content-BFHUHPgi.js → markdown-content-DV3AiG76.js} +1 -1
  203. package/dist/client/assets/{mention-pill-DXBno6EY.js → mention-pill-Db0XBC6Z.js} +1 -1
  204. package/dist/client/assets/{mermaid.core-C6ckWvkG.js → mermaid.core-_ZqWvaFB.js} +4 -4
  205. package/dist/client/assets/{message-square-off-BH8wbm2a.js → message-square-off-w0__0O5g.js} +1 -1
  206. package/dist/client/assets/{mindmap-definition-6OY57UG3-DV4PNLc-.js → mindmap-definition-6OY57UG3-BRVkHL68.js} +1 -1
  207. package/dist/client/assets/{more-details-DhdX4DGU.js → more-details-BUolHzrY.js} +1 -1
  208. package/dist/client/assets/{owner-notice-FMj3k7-f.js → owner-notice-Cn5EUxgh.js} +1 -1
  209. package/dist/client/assets/{package-0mI7-RiJ.js → package-BafFSryH.js} +1 -1
  210. package/dist/client/assets/{page-container-DRyYoDkA.js → page-container-BCdJ_DsH.js} +1 -1
  211. package/dist/client/assets/{pane-resize-handle-OBc3uYxQ.js → pane-resize-handle-Bar-FdkY.js} +1 -1
  212. package/dist/client/assets/{paperclip-BsTJpkyE.js → paperclip-DY4e-IlK.js} +1 -1
  213. package/dist/client/assets/{path-input-CFm1b1pk.js → path-input-SZl4NGTs.js} +1 -1
  214. package/dist/client/assets/{pegDiagram-ECIUJNBX-Cboo0f6B.js → pegDiagram-ECIUJNBX-D9J7XmXK.js} +1 -1
  215. package/dist/client/assets/{pieDiagram-GNMPY74T-CiihSor1.js → pieDiagram-GNMPY74T-myMGqtsR.js} +1 -1
  216. package/dist/client/assets/{plug-BdnJAo1j.js → plug-BdWCGVJg.js} +1 -1
  217. package/dist/client/assets/primer-trigger-r8N0YY5e.js +3 -0
  218. package/dist/client/assets/{profile-errors-B08zStmk.js → profile-errors-DymWFWiP.js} +1 -1
  219. package/dist/client/assets/{progress-CpiQE0rv.js → progress-es667_cM.js} +1 -1
  220. package/dist/client/assets/{quadrantDiagram-D57K4MC3-dF0oKeMn.js → quadrantDiagram-D57K4MC3-D5_2lcqK.js} +1 -1
  221. package/dist/client/assets/{query-error-state-B0RUeb10.js → query-error-state-BNPduDBN.js} +1 -1
  222. package/dist/client/assets/{radio-CAGXbJK_.js → radio-DpWUX1KL.js} +1 -1
  223. package/dist/client/assets/{railroadDiagram-Y72NRBL7-ClkFJVq1.js → railroadDiagram-Y72NRBL7-D15ELhSC.js} +1 -1
  224. package/dist/client/assets/{registry-Cog_2xvt.js → registry-5Qudcjd5.js} +4 -4
  225. package/dist/client/assets/registry-DvKu39S1.js +1 -0
  226. package/dist/client/assets/relay-trace-schemas-DURazPP9.js +6 -0
  227. package/dist/client/assets/{repeat-Dag80z5v.js → repeat-HOHWZc6L.js} +1 -1
  228. package/dist/client/assets/{requirementDiagram-EQYSW5RA-Cey6FmFd.js → requirementDiagram-EQYSW5RA-CHcEVlsR.js} +1 -1
  229. package/dist/client/assets/{room-files-source-BKUFMU_b.js → room-files-source-BO3E2ed0.js} +1 -1
  230. package/dist/client/assets/{rotate-ccw-clock-egrvXlKX.js → rotate-ccw-clock-Dniulnw5.js} +1 -1
  231. package/dist/client/assets/{rotate-cw-Po-L3HFe.js → rotate-cw-um9OzAM7.js} +1 -1
  232. package/dist/client/assets/{sankeyDiagram-SY24JHO5-BsIuHjbJ.js → sankeyDiagram-SY24JHO5-_R5087R3.js} +1 -1
  233. package/dist/client/assets/{scroll-area-C7vKp2H4.js → scroll-area-MdXbnM77.js} +1 -1
  234. package/dist/client/assets/search-x-CHNgYj0F.js +6 -0
  235. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-BJZXJxwu.js → sequenceDiagram-BLEHNHQU-BzHmSHMF.js} +1 -1
  236. package/dist/client/assets/{shield-x-hHpT8rAA.js → shield-x-CDXAW9YF.js} +1 -1
  237. package/dist/client/assets/{signed-in-BhArfIJC.js → signed-in-JAMHtSjx.js} +1 -1
  238. package/dist/client/assets/{sizeCapture-INFHLROL-DYCQyn7S.js → sizeCapture-INFHLROL-CqA3cZcy.js} +1 -1
  239. package/dist/client/assets/{soul-file-Doekkv7n.js → soul-file-BcaDvIdL.js} +1 -1
  240. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-C6bUDAO7.js → stateDiagram-v2-A6IESKWZ-RAA8YyBW.js} +1 -1
  241. package/dist/client/assets/{swimlanes-B3ENRKFQ-DGyTrJBT.js → swimlanes-B3ENRKFQ-BQvgJIcj.js} +1 -1
  242. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-iDgTYazX.js +8 -0
  243. package/dist/client/assets/{table-9KRGRv_s.js → table-BcJvj9rx.js} +1 -1
  244. package/dist/client/assets/{timeline-definition-JXYKGLGB-CHAJwSq6.js → timeline-definition-JXYKGLGB-DXi0saeN.js} +1 -1
  245. package/dist/client/assets/{trust-posture-BQE9NSf_.js → trust-posture-vH4plBRD.js} +1 -1
  246. package/dist/client/assets/{unplug-CklGWwz7.js → unplug-CK2bPGpg.js} +1 -1
  247. package/dist/client/assets/{unverified-catalog-notice-9mykZSlO.js → unverified-catalog-notice-WMkPDdUp.js} +1 -1
  248. package/dist/client/assets/{use-bindings-CPbqKyo6.js → use-bindings-h_mG9d64.js} +1 -1
  249. package/dist/client/assets/{use-composer-prefs-C7v03Xx_.js → use-composer-prefs-DhCnTsrF.js} +1 -1
  250. package/dist/client/assets/{use-connector-management-COqWo76Y.js → use-connector-management-CXVz2xe3.js} +1 -1
  251. package/dist/client/assets/{use-deep-link-scroll-BuYR3PaO.js → use-deep-link-scroll-DYOZ5k0G.js} +1 -1
  252. package/dist/client/assets/{use-delete-binding-Dfz8BlLn.js → use-delete-binding-CHAeTC_Q.js} +1 -1
  253. package/dist/client/assets/{use-dev-links-Cu2JmM-_.js → use-dev-links-CM2NIeqy.js} +1 -1
  254. package/dist/client/assets/{use-direct-message-panel-DobIp_O4.js → use-direct-message-panel-DXTH05Ym.js} +1 -1
  255. package/dist/client/assets/use-external-adapter-catalog-DKlBkkvF.js +1 -0
  256. package/dist/client/assets/use-full-activity-feed-QZAZ5vBJ.js +1 -0
  257. package/dist/client/assets/use-is-below-desktop-DS51QTwj.js +1 -0
  258. package/dist/client/assets/{use-local-browser-DPdkgs06.js → use-local-browser-43FpcgCM.js} +1 -1
  259. package/dist/client/assets/{use-mesh-topology-Ci7r-pAi.js → use-mesh-topology-Bw7MmKA9.js} +1 -1
  260. package/dist/client/assets/{use-mounted-ref-CWXhSyZ8.js → use-mounted-ref-Cuui7-gf.js} +1 -1
  261. package/dist/client/assets/{use-notification-prefs-GJ2coibL.js → use-notification-prefs-CJnF55Rv.js} +1 -1
  262. package/dist/client/assets/use-pending-read-DB25CO5E.js +1 -0
  263. package/dist/client/assets/{use-personality-commit-Da2BJ_58.js → use-personality-commit-p6Of1UxX.js} +1 -1
  264. package/dist/client/assets/{use-promo-activation-D4PAd7pd.js → use-promo-activation-CxG-kZJQ.js} +3 -3
  265. package/dist/client/assets/{use-promo-dismissals-BCBu0s3k.js → use-promo-dismissals-DeNbRWOh.js} +1 -1
  266. package/dist/client/assets/{use-pulse-freshness-CHLSUL-h.js → use-pulse-freshness-CdRkKThf.js} +1 -1
  267. package/dist/client/assets/{use-room-follow-claim-BSijPV3c.js → use-room-follow-claim-_B7HonZx.js} +1 -1
  268. package/dist/client/assets/{use-room-sessions-CNqHgLVa.js → use-room-sessions-CrFskgCJ.js} +1 -1
  269. package/dist/client/assets/{use-roving-tab-list-EsqX22Ik.js → use-roving-tab-list-DSjW4_wm.js} +1 -1
  270. package/dist/client/assets/{use-session-canvas-DAGOz8a6.js → use-session-canvas-KguPfnsc.js} +8 -8
  271. package/dist/client/assets/{use-status-budget-CHln-8aP.js → use-status-budget-CTereFSr.js} +3 -3
  272. package/dist/client/assets/{use-transform-BmyqpcvO.js → use-transform-YUDqOhoc.js} +1 -1
  273. package/dist/client/assets/{use-unclaimed-chats-9Clj_rwl.js → use-unclaimed-chats-B9ChucvA.js} +1 -1
  274. package/dist/client/assets/use-update-config-BH0agtZh.js +1 -0
  275. package/dist/client/assets/{useMutationState-B61VoWtY.js → useMutationState-TJGtJT5R.js} +1 -1
  276. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-BUqj8rIH.js → usecaseDiagram-WPOLBNNX-Cjs1EpVL.js} +1 -1
  277. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-B09oli-Z.js → vennDiagram-Q3Y3IDCW-BtgH-ZyN.js} +1 -1
  278. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-BE7gzLdw.js → wardleyDiagram-IVAIDKWA-BCWHQ18G.js} +1 -1
  279. package/dist/client/assets/{xychartDiagram-4URNHDU4-CbGKfmuW.js → xychartDiagram-4URNHDU4-CUBPWq_V.js} +1 -1
  280. package/dist/client/index.html +1 -1
  281. package/dist/server/index.js +4872 -3645
  282. package/dist/server/index.js.map +2 -2
  283. package/package.json +6 -6
  284. package/dist/client/assets/AdapterSetupWizard-Cp56Zx24.js +0 -2
  285. package/dist/client/assets/BindingDialog-Bw55sMTh.js +0 -1
  286. package/dist/client/assets/HandlePage-CByGC3B8.js +0 -1
  287. package/dist/client/assets/NamePage-5VUtswMH.js +0 -1
  288. package/dist/client/assets/PhotoPage-DDcbiGjb.js +0 -1
  289. package/dist/client/assets/TourHost-DvAjpsug.js +0 -1
  290. package/dist/client/assets/_shell._home.index-CA_GnaUK.js +0 -3
  291. package/dist/client/assets/_shell.connections-gfevZyC-.js +0 -1
  292. package/dist/client/assets/_shell.marketplace-BepG1fJe.js +0 -1
  293. package/dist/client/assets/_shell.marketplace_.sources-BBQESbqU.js +0 -1
  294. package/dist/client/assets/_shell.session-DzeI9YIK.js +0 -1
  295. package/dist/client/assets/_shell.x._extensionId-ByRocZjS.js +0 -1
  296. package/dist/client/assets/_shell.x._extensionId_._-ByRocZjS.js +0 -1
  297. package/dist/client/assets/channel-5-dQamNX.js +0 -1
  298. package/dist/client/assets/index-B9X2-pzp.js +0 -1
  299. package/dist/client/assets/index-BMYGo6Ki.js +0 -1
  300. package/dist/client/assets/index-ButY6gKr.js +0 -1
  301. package/dist/client/assets/index-CgpRBcA4.js +0 -1
  302. package/dist/client/assets/index-p3WivF1M.js +0 -1053
  303. package/dist/client/assets/primer-trigger-BV4xZfFz.js +0 -3
  304. package/dist/client/assets/registry-DLWJMbtY.js +0 -1
  305. package/dist/client/assets/relay-trace-schemas-CNDSmhcJ.js +0 -6
  306. package/dist/client/assets/search-x-C_BEqIuX.js +0 -6
  307. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-DrZ99xGr.js +0 -8
  308. package/dist/client/assets/use-adapter-catalog-CDxy08u_.js +0 -1
  309. package/dist/client/assets/use-external-adapter-catalog-OLn4l20Q.js +0 -1
  310. package/dist/client/assets/use-full-activity-feed-DNrhQueu.js +0 -1
  311. package/dist/client/assets/use-is-below-desktop-7gY1n-47.js +0 -1
  312. package/dist/client/assets/use-pending-read-DcVJ8fZb.js +0 -1
  313. package/dist/client/assets/use-relay-config-C6rPlEud.js +0 -1
  314. package/dist/client/assets/use-update-config-T78vOnRy.js +0 -1
@@ -1,15 +1,15 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlintzCanvas-Dd3bC9vw.js","assets/index-p3WivF1M.js","assets/index-CujX3mpY.css","assets/index-DSIdPh8G.js","assets/index-JoxvTUfo.js","assets/BlintzCanvas-DCXOV_yN.css","assets/CanvasFileContent-CVSfg4MO.js","assets/rotate-cw-Po-L3HFe.js","assets/query-keys-DeYqUDia.js","assets/index.esm-CxXuMuQv.js","assets/WidgetErrorCard-CgRMeAEO.js","assets/index-BY0SKYuc.js","assets/card-TbpEl6EH.js","assets/progress-CpiQE0rv.js","assets/markdown-content-BFHUHPgi.js","assets/table-9KRGRv_s.js","assets/package-0mI7-RiJ.js","assets/heart-D4fTvM5q.js","assets/git-branch-BLIYLcM4.js","assets/file-text-wmrSy3Io.js","assets/file-DHPgnMgj.js","assets/McpAppFrame-DVNWJHrn.js","assets/more-details-DhdX4DGU.js","assets/CanvasModel3dContent-CNmJsBTS.js","assets/CanvasCsvContent-B2S75f6B.js","assets/index-Dbujw1c2.js"])))=>i.map(i=>d[i]);
2
- var tn=Object.defineProperty;var Qt=e=>{throw TypeError(e)};var rn=(e,t,r)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var re=(e,t,r)=>rn(e,typeof t!="symbol"?t+"":t,r),gt=(e,t,r)=>t.has(e)||Qt("Cannot "+r);var Me=(e,t,r)=>(gt(e,t,"read from private field"),r?r.call(e):t.get(e)),Le=(e,t,r)=>t.has(e)?Qt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),ve=(e,t,r,n)=>(gt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),be=(e,t,r)=>(gt(e,t,"access private method"),r);import{O as ft,a1 as oe,a2 as nn,a3 as sn,r as p,l8 as ht,fI as X,fT as K,fM as jt,fP as Be,fJ as ce,nK as on,nL as an,nM as cn,aZ as Oe,cm as Mt,dW as un,aY as V,j as h,nN as ln,kb as dn,i6 as fn,i7 as hn,es as pn,G as Lt,I as mn,fB as gn,fL as it,ct as vn,nO as bn,js as wn,jw as xn,a7 as yn,nP as kn,nQ as yr,fH as Kt,nR as Ct,nS as ot,nT as kr,nU as jn,nV as Cn,nW as Rn,h9 as J,nX as On,nY as En,B as rt,J as jr,gh as Cr,C as _n,aN as Sn,nZ as Dn,n_ as In,n$ as er}from"./index-p3WivF1M.js";import{R as Nn}from"./rotate-cw-Po-L3HFe.js";import{d as Rt}from"./query-keys-DeYqUDia.js";import{T as Tn,a as An,u as zn}from"./index.esm-CxXuMuQv.js";import{v as Fn,a as Mn,W as Ln}from"./WidgetErrorCard-CgRMeAEO.js";import{M as qn}from"./McpAppFrame-DVNWJHrn.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlintzCanvas-BFJXKo1L.js","assets/index-fge85Gub.js","assets/index-CujX3mpY.css","assets/index-Dsj1fDYU.js","assets/index-DZQUx5pX.js","assets/BlintzCanvas-DCXOV_yN.css","assets/CanvasFileContent-DZf9SjJn.js","assets/rotate-cw-um9OzAM7.js","assets/query-keys-DeYqUDia.js","assets/index.esm-BEGwgVfU.js","assets/WidgetErrorCard-Bte2obmw.js","assets/index-DI9IsN-O.js","assets/card-CM7-_8nD.js","assets/progress-es667_cM.js","assets/markdown-content-DV3AiG76.js","assets/table-BcJvj9rx.js","assets/package-BafFSryH.js","assets/heart--8btr31M.js","assets/git-branch-uZFa3Tmr.js","assets/file-text-DLPhIP0f.js","assets/file-DiYwTQdD.js","assets/McpAppFrame-CmwiQHxf.js","assets/more-details-BUolHzrY.js","assets/CanvasModel3dContent-Cd8hf6Ba.js","assets/CanvasCsvContent-DzkaHpEo.js","assets/index-CvIKejlx.js"])))=>i.map(i=>d[i]);
2
+ var tn=Object.defineProperty;var Qt=e=>{throw TypeError(e)};var rn=(e,t,r)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var re=(e,t,r)=>rn(e,typeof t!="symbol"?t+"":t,r),gt=(e,t,r)=>t.has(e)||Qt("Cannot "+r);var Me=(e,t,r)=>(gt(e,t,"read from private field"),r?r.call(e):t.get(e)),Le=(e,t,r)=>t.has(e)?Qt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),ve=(e,t,r,n)=>(gt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),be=(e,t,r)=>(gt(e,t,"access private method"),r);import{O as ft,a1 as oe,a2 as nn,a3 as sn,r as p,lb as ht,fH as Z,fS as K,fL as jt,fO as Be,fI as ce,nW as on,nX as an,nY as cn,aX as Re,ck as Mt,dV as un,aW as V,j as h,nZ as ln,ke as dn,i9 as fn,ia as hn,er as pn,G as Lt,I as mn,fA as gn,fK as it,cr as vn,n_ as bn,jv as wn,jz as xn,dD as yn,n$ as kn,o0 as yr,fG as Kt,o1 as Ct,o2 as ot,o3 as kr,o4 as jn,o5 as Cn,o6 as On,h9 as J,o7 as Rn,o8 as En,B as rt,J as jr,gh as Cr,C as _n,aL as Sn,o9 as Dn,oa as In,ob as er}from"./index-fge85Gub.js";import{R as Nn}from"./rotate-cw-um9OzAM7.js";import{d as Ot}from"./query-keys-DeYqUDia.js";import{T as Tn,a as An,u as zn}from"./index.esm-BEGwgVfU.js";import{v as Fn,a as Mn,W as Ln}from"./WidgetErrorCard-Bte2obmw.js";import{M as qn}from"./McpAppFrame-CmwiQHxf.js";/**
3
3
  * @license lucide-react v1.48.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
6
6
  * See the LICENSE file in the root directory of this source tree.
7
- */const Rr={name:"file-code",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]};Rr.node;const Fo=ft(Rr);/**
7
+ */const Or={name:"file-code",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]};Or.node;const Fo=ft(Or);/**
8
8
  * @license lucide-react v1.48.0 - ISC
9
9
  *
10
10
  * This source code is licensed under the ISC license.
11
11
  * See the LICENSE file in the root directory of this source tree.
12
- */const Or={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]};Or.node;const Pn=ft(Or);/**
12
+ */const Rr={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]};Rr.node;const Pn=ft(Rr);/**
13
13
  * @license lucide-react v1.48.0 - ISC
14
14
  *
15
15
  * This source code is licensed under the ISC license.
@@ -19,9 +19,9 @@ var tn=Object.defineProperty;var Qt=e=>{throw TypeError(e)};var rn=(e,t,r)=>t in
19
19
  *
20
20
  * This source code is licensed under the ISC license.
21
21
  * See the LICENSE file in the root directory of this source tree.
22
- */const _r={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};_r.node;const Un=ft(_r);function Wn(e,t){const r=oe();return nn({queryKey:Rt.index(e??""),queryFn:()=>r.getDocIndex(e),enabled:t&&e!==null,refetchOnWindowFocus:!0})}function $n(){const e=sn();return p.useCallback(t=>{e.invalidateQueries({queryKey:t?Rt.index(t):Rt.all})},[e])}const _e={pending:64,queueBytes:1048576,batchMs:300,frames:62,imageChars:9e5,imageEdge:1568,resourceErrors:1e4},at=ce().min(1).max(128),Te={bridgeGeneration:at},Gn=X({...Te,__dorkosDevtools:K("capture-result"),requestId:at,dataUrl:ce().max(9e5).optional(),error:ce().max(2048).optional()}),Hn=on.omit({hostOutcome:!0}).extend({...Te,__dorkosDevtools:K("act-result"),dataUrl:ce().max(9e5).optional()}),Vn=an.extend({status:Be().int().min(0).max(599),durationMs:Be().min(0),responseSize:Be().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),timestamp:Be().min(0)}),Jn=cn.refine(e=>e.timestamp>=0),Zn=ht("__dorkosDevtools",[X({__dorkosDevtools:K("hello"),pageInstanceId:at,bridgeVersion:K(2)}),X({...Te,__dorkosDevtools:K("ready"),pageInstanceId:at}),X({...Te,__dorkosDevtools:K("navigated")}),X({...Te,__dorkosDevtools:K("resource-error")}),X({...Te,__dorkosDevtools:K("batch"),seq:Be().int().min(0).max(Number.MAX_SAFE_INTEGER),console:jt(Jn).max(500),network:jt(Vn).max(200)}),Gn,Hn]);function Xn(e){const t=new Set;let r=0,n=0;const s=a=>(n+=a)<=16384;function o(a){if(!s(2))return!1;for(let i=0;i<a.length;i++){const d=a.charCodeAt(i);if(d>=55296&&d<=56319&&i+1<a.length&&a.charCodeAt(i+1)>=56320&&a.charCodeAt(i+1)<=57343){if(!s(2))return!1;i++;continue}const u=d===34||d===92||[8,9,10,12,13].includes(d)?2:d<32||d>=55296&&d<=57343?6:1;if(!s(u))return!1}return!0}function c(a,i){if(++r>2048||i>8)return!1;if(a===null)return s(4);if(typeof a=="boolean")return s(a?4:5);if(typeof a=="string")return o(a);if(typeof a=="number")return Number.isFinite(a)&&s(String(a).length);if(typeof a!="object"||t.has(a))return!1;const d=Object.getPrototypeOf(a);if(d!==Object.prototype&&d!==null&&d!==Array.prototype)return!1;const u=Array.isArray(a);if(u&&a.length>2048||Object.getOwnPropertySymbols(a).length||!s(2))return!1;t.add(a);let f=0;for(const l in a){if(!Object.prototype.hasOwnProperty.call(a,l))continue;if(++f>2048||u&&(!/^\d+$/.test(l)||Number(l)>=a.length))return!1;const m=Object.getOwnPropertyDescriptor(a,l);if(["__proto__","constructor","prototype"].includes(l)||!("value"in m)||!m.enumerable||f>1&&!s(1)||!u&&(!o(l)||!s(1))||!c(m.value,i+1))return!1}return t.delete(a),!u||f===a.length}try{return c(e,0)}catch{return!1}}function Yn(e){try{if(!e||typeof e!="object")return null;const t=e;if(t.__dorkosDevtools==="capture-result"&&t.dataUrl===void 0&&t.error===void 0)return null;if(t.__dorkosDevtools==="batch"){if(!Array.isArray(t.console)||t.console.length>500||!Array.isArray(t.network)||t.network.length>200)return null;for(const s of t.console){if(!s||typeof s!="object")return null;const o=s.args;if(o!==void 0&&(!Array.isArray(o)||o.length>50||!Xn(o)))return null}}const r=Zn.safeParse(e);if(!r.success)return null;const n=r.data;return"dataUrl"in n&&n.dataUrl!==void 0&&!Sr(n.dataUrl)?null:n}catch{return null}}function Sr(e){if(e.length>9e5||!/^data:image\/png;base64,[A-Za-z0-9+/]+={0,2}$/.test(e))return null;try{const t=atob(e.slice(e.indexOf(",")+1));if(t.length<24||t.slice(0,8)!==`‰PNG\r
22
+ */const _r={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};_r.node;const Un=ft(_r);function Wn(e,t){const r=oe();return nn({queryKey:Ot.index(e??""),queryFn:()=>r.getDocIndex(e),enabled:t&&e!==null,refetchOnWindowFocus:!0})}function $n(){const e=sn();return p.useCallback(t=>{e.invalidateQueries({queryKey:t?Ot.index(t):Ot.all})},[e])}const _e={pending:64,queueBytes:1048576,batchMs:300,frames:62,imageChars:9e5,imageEdge:1568,resourceErrors:1e4},at=ce().min(1).max(128),Te={bridgeGeneration:at},Gn=Z({...Te,__dorkosDevtools:K("capture-result"),requestId:at,dataUrl:ce().max(9e5).optional(),error:ce().max(2048).optional()}),Hn=on.omit({hostOutcome:!0}).extend({...Te,__dorkosDevtools:K("act-result"),dataUrl:ce().max(9e5).optional()}),Vn=an.extend({status:Be().int().min(0).max(599),durationMs:Be().min(0),responseSize:Be().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),timestamp:Be().min(0)}),Jn=cn.refine(e=>e.timestamp>=0),Xn=ht("__dorkosDevtools",[Z({__dorkosDevtools:K("hello"),pageInstanceId:at,bridgeVersion:K(2)}),Z({...Te,__dorkosDevtools:K("ready"),pageInstanceId:at}),Z({...Te,__dorkosDevtools:K("navigated")}),Z({...Te,__dorkosDevtools:K("resource-error")}),Z({...Te,__dorkosDevtools:K("batch"),seq:Be().int().min(0).max(Number.MAX_SAFE_INTEGER),console:jt(Jn).max(500),network:jt(Vn).max(200)}),Gn,Hn]);function Zn(e){const t=new Set;let r=0,n=0;const s=a=>(n+=a)<=16384;function o(a){if(!s(2))return!1;for(let i=0;i<a.length;i++){const d=a.charCodeAt(i);if(d>=55296&&d<=56319&&i+1<a.length&&a.charCodeAt(i+1)>=56320&&a.charCodeAt(i+1)<=57343){if(!s(2))return!1;i++;continue}const u=d===34||d===92||[8,9,10,12,13].includes(d)?2:d<32||d>=55296&&d<=57343?6:1;if(!s(u))return!1}return!0}function c(a,i){if(++r>2048||i>8)return!1;if(a===null)return s(4);if(typeof a=="boolean")return s(a?4:5);if(typeof a=="string")return o(a);if(typeof a=="number")return Number.isFinite(a)&&s(String(a).length);if(typeof a!="object"||t.has(a))return!1;const d=Object.getPrototypeOf(a);if(d!==Object.prototype&&d!==null&&d!==Array.prototype)return!1;const u=Array.isArray(a);if(u&&a.length>2048||Object.getOwnPropertySymbols(a).length||!s(2))return!1;t.add(a);let f=0;for(const l in a){if(!Object.prototype.hasOwnProperty.call(a,l))continue;if(++f>2048||u&&(!/^\d+$/.test(l)||Number(l)>=a.length))return!1;const m=Object.getOwnPropertyDescriptor(a,l);if(["__proto__","constructor","prototype"].includes(l)||!("value"in m)||!m.enumerable||f>1&&!s(1)||!u&&(!o(l)||!s(1))||!c(m.value,i+1))return!1}return t.delete(a),!u||f===a.length}try{return c(e,0)}catch{return!1}}function Yn(e){try{if(!e||typeof e!="object")return null;const t=e;if(t.__dorkosDevtools==="capture-result"&&t.dataUrl===void 0&&t.error===void 0)return null;if(t.__dorkosDevtools==="batch"){if(!Array.isArray(t.console)||t.console.length>500||!Array.isArray(t.network)||t.network.length>200)return null;for(const s of t.console){if(!s||typeof s!="object")return null;const o=s.args;if(o!==void 0&&(!Array.isArray(o)||o.length>50||!Zn(o)))return null}}const r=Xn.safeParse(e);if(!r.success)return null;const n=r.data;return"dataUrl"in n&&n.dataUrl!==void 0&&!Sr(n.dataUrl)?null:n}catch{return null}}function Sr(e){if(e.length>9e5||!/^data:image\/png;base64,[A-Za-z0-9+/]+={0,2}$/.test(e))return null;try{const t=atob(e.slice(e.indexOf(",")+1));if(t.length<24||t.slice(0,8)!==`‰PNG\r
23
23
  
24
- `||t.slice(12,16)!=="IHDR")return null;const r=o=>t.charCodeAt(o)*2**24+(t.charCodeAt(o+1)<<16)+(t.charCodeAt(o+2)<<8)+t.charCodeAt(o+3),n=r(16),s=r(20);return n>0&&s>0&&n<=1568&&s<=1568?{width:n,height:s}:null}catch{return null}}let vt=null;async function tr(){return vt===null&&(vt=(await Oe(()=>import("./html-to-image-cl8bZGTj.js"),[])).default),vt}let bt=null;async function Qn(){if(bt===null){const e=await Oe(()=>import("./gifenc.esm-sOOlYEo8.js"),[]);bt={GIFEncoder:e.GIFEncoder,quantize:e.quantize,applyPalette:e.applyPalette}}return bt}async function rr(e,t,r=()=>{}){if(e.length===0)return{ok:!1,error:"The recording has no frames in it."};r();const{GIFEncoder:n,quantize:s,applyPalette:o}=await Qn();r();const c=e[0],a=e[e.length-1],i=new Uint8ClampedArray(c.data.length+a.data.length);i.set(c.data,0),i.set(a.data,c.data.length);const d=s(i,256),u=n();for(let l=0;l<e.length;l++){r();const m=e[l];if(u.writeFrame(o(m.data,d),m.width,m.height,{...l===0?{palette:d,repeat:0}:{},delay:t.frameMs}),u.bytesView().byteLength>t.maxBytes)return{ok:!1,error:`The recording came out bigger than ${Math.round(t.maxBytes/1024/1024)} MB, so it was not saved.`}}u.finish();const f=u.bytes();return f.byteLength>t.maxBytes?{ok:!1,error:`The recording came out bigger than ${Math.round(t.maxBytes/1024/1024)} MB, so it was not saved.`}:{ok:!0,bytes:f}}async function Kn(e,t,r=()=>{}){const n=[],s=document.createElement("canvas");let o=0,c=0;try{for(let a=0;a<Math.min(e.length,62);a++){r();const i=e[a];if(!Sr(i)){e[a]="";continue}const d=await ts(i);e[a]="";try{if(r(),!d)continue;if(!o){const l=Math.min(1,Math.min(800,t)/Math.max(d.width,d.height,1));o=Math.max(1,Math.round(d.width*l)),c=Math.max(1,Math.round(d.height*l)),s.width=o,s.height=c}const u=s.getContext("2d",{willReadFrequently:!0});if(!u)return[];u.fillStyle="#ffffff",u.fillRect(0,0,o,c);const f=Math.min(o/d.width,c/d.height);u.drawImage(d,0,0,Math.round(d.width*f),Math.round(d.height*f)),r(),n.push({data:u.getImageData(0,0,o,c).data,width:o,height:c})}finally{d&&(d.src="")}}return n}catch(a){throw n.length=0,a}finally{e.length=0,s.width=0,s.height=0}}function es(e,t=()=>{}){const r=document.createElement("canvas"),n=document.createElement("canvas");try{for(let s=0;s<e.length;s++){t();const o=e[s];n.width=o.width,n.height=o.height,r.width=Math.max(1,Math.round(o.width/2)),r.height=Math.max(1,Math.round(o.height/2));const c=n.getContext("2d"),a=r.getContext("2d",{willReadFrequently:!0});if(!c||!a)throw new Error("Canvas pixels are unavailable");c.putImageData(new ImageData(new Uint8ClampedArray(o.data),o.width,o.height),0,0),a.drawImage(n,0,0,r.width,r.height),e[s]={data:a.getImageData(0,0,r.width,r.height).data,width:r.width,height:r.height}}}finally{n.width=n.height=r.width=r.height=0}}function ts(e){return new Promise(t=>{const r=new Image;r.onload=()=>{r.onload=r.onerror=null,t(r)},r.onerror=()=>{r.onload=r.onerror=null,r.src="",t(null)},r.src=e})}function nr(e,t,r){const n=r.slice().buffer;return{name:e,type:t,size:r.byteLength,arrayBuffer:async()=>n}}function rs(e){const t=atob(e.slice(e.indexOf(",")+1));return Uint8Array.from(t,r=>r.charCodeAt(0))}const ns=8e3;function ss(e){const t=oe(),r=p.useRef(t);p.useLayoutEffect(()=>{r.current=t});const[n]=Mt(),[s,o]=p.useState(0),c=p.useRef(null),a=p.useRef(new Map),i=p.useRef(null),d=p.useRef({console:[],network:[],entryBytes:0,overheadBytes:0}),u=p.useRef(null),f=p.useRef(-1),l=p.useRef(null),m=p.useRef(null),w=p.useRef(!1),g=p.useRef(-1/0),v=p.useRef(!1),D=p.useRef(null),N=p.useRef(0),C=p.useRef(null),z=p.useRef(null),F=p.useRef(!1),G=p.useRef(null),L=p.useRef({...e,sessionId:n}),q=p.useRef(Promise.resolve()),U=p.useRef(()=>{}),Y=p.useRef({initialize:x,retire:S,consume:ue,register:P,eligiblePending:te,refuseRequest:y,live:k,captureFrame:mt,valid:Ke,reportRecordingStart:Ae,cancelReservation:Wt,finish:$t});p.useLayoutEffect(()=>{Y.current={initialize:x,retire:S,consume:ue,register:P,eligiblePending:te,refuseRequest:y,live:k,captureFrame:mt,valid:Ke,reportRecordingStart:Ae,cancelReservation:Wt,finish:$t}});const he=O=>G.current===O||V.getState().openDocuments.some(b=>b.id===O&&b.openedHere);function j(O,{active:b,activation:E=!1,keepalive:R=!1,reset:T=!1}){if(!O.sessionId)return;const Q={documentId:O.documentId,logicalUrl:O.logicalUrl,bridgeGeneration:O.generation,seq:Math.max(0,f.current),console:[],network:[],active:b,activation:E,instrumented:O.ready&&!O.retired,...T?{reset:!0}:{}};q.current=q.current.then(()=>r.current.ingestDevtoolsCapture(O.sessionId,Q,R?{keepalive:!0}:void 0)).catch(()=>{})}function S(){var E;const O=c.current;O&&(O.retired=!0),c.current=null,u.current!==null&&clearTimeout(u.current),u.current=null,i.current=null,d.current={console:[],network:[],entryBytes:0,overheadBytes:0},f.current=-1,g.current=-1/0,v.current=!1;for(const[R,T]of a.current)T.life.sessionId&&T.deadline>Date.now()&&T.kind!=="frame"&&y(R,T.kind,T.life,"The frame changed while this request was pending."),clearTimeout(T.timer),(E=T.resolve)==null||E.call(T,null);a.current.clear(),O&&j(O,{active:!1});const b=D.current;b&&(clearTimeout(b.reservationTimer),b.cancelled=!0,b.abort.abort(),b.frames.length=0,b.finishing||(b.drawn.length=0,D.current=null)),C.current!==null&&cancelAnimationFrame(C.current),C.current=null,N.current=0,o(0)}function x({loadActivation:O,reset:b=!1}={}){var $,se;const E=L.current,R=($=E.iframeRef.current)==null?void 0:$.contentWindow;if(w.current||!R||!E.bridgeEligibility||!E.resolvedSource)return;const T={generation:crypto.randomUUID(),frame:R,sessionId:E.sessionId,documentId:E.documentId,logicalUrl:E.logicalUrl,source:E.resolvedSource,origin:E.bridgeEligibility==="served-document"?"null":E.previewOrigin,ready:!1,activation:!1,retired:!1};c.current=T;const Q=O??(F.current||z.current!==T.documentId&&he(T.documentId));T.activation=Q,F.current=!1,z.current=T.documentId,j(T,{active:!0,activation:Q,reset:b}),((se=l.current)==null?void 0:se.frame)===R&&l.current.source===E.resolvedSource&&l.current.reload===E.reloadNonce&&l.current.documentId===E.documentId&&l.current.logicalUrl===E.logicalUrl&&R.postMessage({__dorkosDevtools:"init",bridgeGeneration:T.generation},"*")}p.useLayoutEffect(()=>{var R;L.current={...e,sessionId:n};const O={frame:(R=e.iframeRef.current)==null?void 0:R.contentWindow,sessionId:n,documentId:e.documentId,logicalUrl:e.logicalUrl,source:e.resolvedSource,eligibility:e.bridgeEligibility,origin:e.previewOrigin,reload:e.reloadNonce},b=m.current;if(!b||Object.keys(O).some(T=>O[T]!==b[T])){const T=!b||b.frame!==O.frame||b.documentId!==O.documentId||b.logicalUrl!==O.logicalUrl||b.source!==O.source||b.reload!==O.reload;m.current=O,w.current=!1,S(),x({reset:T})}});const A=p.useCallback(()=>{var Q,$,se;const{initialize:O,retire:b}=Y.current,E=L.current,R=(Q=E.iframeRef.current)==null?void 0:Q.contentWindow,T=($=c.current)!=null&&$.ready?!1:(se=c.current)==null?void 0:se.activation;R&&E.resolvedSource&&(l.current={frame:R,source:E.resolvedSource,reload:E.reloadNonce,documentId:E.documentId,logicalUrl:E.logicalUrl}),w.current=!1,b(),O({loadActivation:T,reset:!0})},[]),I=p.useCallback(()=>{const O=c.current;F.current=!0,G.current=L.current.documentId,O&&U.current({active:!0,activation:!0})},[]);p.useLayoutEffect(()=>{U.current=O=>{c.current&&j(c.current,O)}});function k(O){return c.current===O&&!O.retired}function y(O,b,E,R){if(!E.sessionId)return;const T={requestId:O,bridgeGeneration:E.generation,documentId:E.documentId,hostOutcome:"host",error:R};b==="action"?r.current.postDevtoolsAction(E.sessionId,{...T,ok:!1}).catch(()=>{}):r.current.ingestDevtoolsCapture(E.sessionId,{...T,logicalUrl:E.logicalUrl,seq:Math.max(0,f.current),console:[],network:[],screenshot:{requestId:O,error:R}}).catch(()=>{})}function P(O,b,E,{capture:R=!1,resolve:T,timeoutMs:Q=8e3}={}){if(a.current.size>=_e.pending||a.current.has(O))return null;const $=setTimeout(()=>W(O,se),Q),se={kind:b,life:E,capture:R,deadline:Date.now()+Q,timer:$,resolve:T};return a.current.set(O,se),se}function W(O,b){var E;a.current.get(O)===b&&(a.current.delete(O),clearTimeout(b.timer),(E=b.resolve)==null||E.call(b,null))}function te(O,b,E){return a.current.get(O)!==b||b.life!==E||!k(E)?!1:Date.now()>=b.deadline?(W(O,b),!1):!0}function ue(O,b,E){const R=a.current.get(O);return!R||R.life!==E||R.kind!==b&&!(b==="capture"&&R.kind==="frame")||!te(O,R,E)?null:(a.current.delete(O),clearTimeout(R.timer),R)}p.useEffect(()=>{const{initialize:O,retire:b,consume:E}=Y.current;function R(){u.current=null;const de=i.current;i.current=null,d.current={console:[],network:[],entryBytes:0,overheadBytes:0};const _=c.current;de&&_&&!_.retired&&_.sessionId&&de.bridgeGeneration===_.generation&&r.current.ingestDevtoolsCapture(_.sessionId,de)}function T(de){var Ht,Vt,Jt,Zt;const _=c.current;if(!_||_.retired||de.source!==_.frame||de.origin!==_.origin||((Ht=l.current)==null?void 0:Ht.frame)!==_.frame||l.current.source!==_.source||l.current.reload!==L.current.reloadNonce||l.current.documentId!==_.documentId||l.current.logicalUrl!==_.logicalUrl)return;const M=de.data;if(!M||typeof M!="object"||typeof M.__dorkosDevtools!="string"||!["hello","ready","navigated","resource-error","batch","capture-result","act-result"].includes(M.__dorkosDevtools)||M.__dorkosDevtools!=="hello"&&M.bridgeGeneration!==_.generation)return;const ie=M.__dorkosDevtools==="batch";if(ie){if(!_.ready||!_.sessionId||M.bridgeGeneration!==_.generation||!Number.isSafeInteger(M.seq)||M.seq<0||M.seq<=f.current)return;const H=Date.now();if(H-g.current<_e.batchMs){i.current?i.current.dropped=!0:v.current=!0;return}g.current=H}const B=Yn(M);if(!B){ie&&(v.current=!0);return}if(B.__dorkosDevtools==="hello"){_.frame.postMessage({__dorkosDevtools:"init",bridgeGeneration:_.generation},"*");return}if(B.bridgeGeneration!==_.generation)return;if(B.__dorkosDevtools==="ready"){_.ready||(_.ready=!0,_.activation=!1,j(_,{active:!0}));return}if(!_.ready)return;if(B.__dorkosDevtools==="navigated"){w.current=!0,b();return}if(B.__dorkosDevtools==="resource-error"){N.current=Math.min(_e.resourceErrors,N.current+1),C.current===null&&(C.current=requestAnimationFrame(()=>{C.current=null,k(_)&&o(N.current)}));return}if(!_.sessionId)return;if(B.__dorkosDevtools==="batch"){if(B.seq<=f.current)return;f.current=B.seq;const H=i.current??{documentId:_.documentId,logicalUrl:_.logicalUrl,bridgeGeneration:_.generation,seq:B.seq,console:[],network:[]};H.seq=B.seq,v.current&&(H.dropped=!0),v.current=!1;const je=d.current,Xt=new TextEncoder;if(i.current||(je.overheadBytes=Xt.encode(JSON.stringify({...H,seq:Number.MAX_SAFE_INTEGER,dropped:!0,console:[],network:[]})).length),je.overheadBytes>_e.queueBytes){i.current=null,d.current={console:[],network:[],entryBytes:0,overheadBytes:0},v.current=!0;return}for(const[Fe,Kr]of[["console",B.console],["network",B.network]])for(const en of Kr){const Yt=Xt.encode(JSON.stringify(en)).length;je[Fe].push(Yt),je.entryBytes+=Yt}H.console.push(...B.console),H.network.push(...B.network);const Qr=()=>je.overheadBytes+je.entryBytes+Math.max(0,H.console.length-1)+Math.max(0,H.network.length-1);for(;H.console.length>500||H.network.length>200||Qr()>_e.queueBytes;){H.dropped=!0;const Fe=(((Vt=H.console[0])==null?void 0:Vt.timestamp)??1/0)<=(((Jt=H.network[0])==null?void 0:Jt.timestamp)??1/0)?"console":"network";if(!H[Fe].length)break;H[Fe].shift(),je.entryBytes-=je[Fe].shift()}i.current=H,u.current===null&&(u.current=setTimeout(R,_e.batchMs));return}if(B.__dorkosDevtools==="capture-result"){const H=E(B.requestId,"capture",_);if(!H)return;if(H.kind==="frame"){(Zt=H.resolve)==null||Zt.call(H,B.dataUrl??null);return}r.current.ingestDevtoolsCapture(_.sessionId,{bridgeGeneration:_.generation,documentId:_.documentId,logicalUrl:_.logicalUrl,seq:Math.max(0,f.current),console:[],network:[],hostOutcome:"page-reported",screenshot:{requestId:B.requestId,dataUrl:B.dataUrl,error:B.error}});return}const ze=E(B.requestId,"action",_);if(!ze)return;const Ee=D.current,Gt=ze.capture&&B.dataUrl!==void 0&&Ee!==null&&Ee.life===_&&Ee.activated&&!Ee.finishing&&!Ee.cancelled&&Ee.frames.length<61;Gt&&Ee.frames.push(B.dataUrl);const{__dorkosDevtools:Eo,dataUrl:_o,...Yr}=B;r.current.postDevtoolsAction(_.sessionId,{...Yr,hostOutcome:"page-reported",documentId:_.documentId,captured:Gt||void 0})}window.addEventListener("message",T);const Q=setInterval(()=>U.current({active:!0}),15e3),$=()=>{c.current||O(),U.current({active:!0,activation:!0})},se=()=>{U.current({active:!1,keepalive:!0}),b()},ae=()=>{document.visibilityState==="visible"&&$()};return window.addEventListener("focus",$),window.addEventListener("pagehide",se),window.addEventListener("pageshow",$),document.addEventListener("visibilitychange",ae),()=>{window.removeEventListener("message",T),clearInterval(Q),window.removeEventListener("focus",$),window.removeEventListener("pagehide",se),window.removeEventListener("pageshow",$),document.removeEventListener("visibilitychange",ae),b()}},[]),p.useEffect(()=>un.subscribeSessionEvent((O,b)=>{if(b.type!=="devtools_capture_request"&&b.type!=="devtools_action_request"&&b.type!=="devtools_recording_request")return;const{register:E,eligiblePending:R,refuseRequest:T,captureFrame:Q,valid:$,finish:se,reportRecordingStart:ae,cancelReservation:de}=Y.current,_=c.current;if(!(!(_!=null&&_.ready)||!_.sessionId||_.retired||b.targetClientId!==r.current.clientId||b.documentId!==_.documentId||b.bridgeGeneration!==_.generation)){if(b.type==="devtools_capture_request"||b.type==="devtools_action_request"){const M=b.type==="devtools_action_request",ie=E(b.requestId,M?"action":"capture",_,{capture:M&&!!b.capture,timeoutMs:M&&b.command.action==="wait_for"?Math.min(1e4,b.command.timeoutMs)+2e3:8e3});if(!ie){a.current.has(b.requestId)||T(b.requestId,M?"action":"capture",_,"Too many browser requests are waiting. Try again when one finishes.");return}const B=ze=>{R(b.requestId,ie,_)&&_.frame.postMessage(M?{__dorkosDevtools:"act-request",bridgeGeneration:_.generation,requestId:b.requestId,documentId:_.documentId,command:b.command,...b.capture?{capture:!0,lib:ze}:{}}:{__dorkosDevtools:"capture-request",bridgeGeneration:_.generation,requestId:b.requestId,lib:ze},"*")};!M||b.capture?tr().then(B,()=>B()):B()}if(b.type==="devtools_recording_request"){if(b.action==="cancel-start"){de(b.recordingId,b.requestId,_);return}if(b.action==="confirm-start"){const M=D.current;if(!M||M.id!==b.recordingId||M.startRequestId!==b.requestId||M.life!==_||M.finishing||!$(M))return;if(!M.activated){if(performance.now()>=M.reservationDeadline){de(M.id,M.startRequestId,_),ae(b,_,{phase:"started",ok:!1,error:"This recording reservation expired before capture could start."});return}clearTimeout(M.reservationTimer),M.activated=!0,M.startedAt=Date.now(),Q(_).then(ie=>{ie&&$(M)&&M.frames.push(ie)})}ae(b,_,{phase:"started",ok:!0});return}if(b.action==="start"){const M=b.reservationTimeoutMs;if(!Number.isSafeInteger(M)||!M||M<1||M>ns){ae(b,_,{phase:"reserved",ok:!1,error:"This recording request has no valid reservation timeout."});return}if(D.current){ae(b,_,{phase:"reserved",ok:!1,error:"Another recording in this window is still running or being saved. Wait for it to finish, then start again."});return}const ie={id:b.recordingId,startRequestId:b.requestId,activated:!1,reservationDeadline:performance.now()+M,life:_,startedAt:Date.now(),frames:[],drawn:[],finishing:!1,cancelled:!1,abort:new AbortController};D.current=ie,ie.reservationTimer=setTimeout(()=>{D.current===ie&&!ie.activated&&de(ie.id,ie.startRequestId,_)},M),ae(b,_,{phase:"reserved",ok:!0})}else se(b.requestId,b.recordingId,_)}}}),[]);function Ae(O,b,E){!k(b)||!b.sessionId||r.current.ingestDevtoolsCapture(b.sessionId,{hostOutcome:"host",documentId:b.documentId,bridgeGeneration:b.generation,seq:0,console:[],network:[],recordingStart:{...E,requestId:O.requestId,recordingId:O.recordingId}}).catch(()=>{})}function Wt(O,b,E){var T;const R=D.current;if(!(!R||R.id!==O||R.startRequestId!==b||R.life!==E||R.finishing)){clearTimeout(R.reservationTimer),R.cancelled=!0,R.abort.abort(),R.frames.length=0,R.drawn.length=0;for(const[Q,$]of a.current)$.life===E&&$.kind==="frame"&&(clearTimeout($.timer),(T=$.resolve)==null||T.call($,null),a.current.delete(Q));D.current=null}}function Ke(O){return D.current===O&&!O.cancelled&&k(O.life)}function mt(O){const b=`frame-${crypto.randomUUID()}`;return new Promise(E=>{const R=P(b,"frame",O,{resolve:E});if(!R){E(null);return}tr().then(T=>{te(b,R,O)&&O.frame.postMessage({__dorkosDevtools:"capture-request",bridgeGeneration:O.generation,requestId:b,lib:T},"*")},()=>{W(b,R)})})}async function $t(O,b,E){const R=D.current;if(!R||!R.activated||R.id!==b||R.life!==E){k(E)&&await r.current.uploadDevtoolsRecording(E.sessionId,{requestId:O,bridgeGeneration:E.generation,documentId:E.documentId,hostOutcome:"host",error:"The window showing that page stopped recording before it could be saved."}).catch(()=>{});return}if(R.finishing)return;R.finishing=!0;const T=()=>{if(!Ke(R))throw new Error("retired")},Q={requestId:O,bridgeGeneration:E.generation,documentId:E.documentId};try{const $=await mt(E);T(),$&&R.frames.length<_e.frames&&R.frames.push($);const se=R.frames.length?rs(R.frames[R.frames.length-1]):new Uint8Array;R.drawn=await Kn(R.frames,800,T),T();let ae=await rr(R.drawn,{frameMs:500,maxBytes:8*1024*1024},T);if(T(),!ae.ok&&R.drawn.length&&(es(R.drawn,T),ae=await rr(R.drawn,{frameMs:500,maxBytes:8*1024*1024},T),T()),!ae.ok){await r.current.uploadDevtoolsRecording(E.sessionId,{...Q,hostOutcome:"host",error:ae.error},{signal:R.abort.signal}),T();return}T(),await r.current.uploadDevtoolsRecording(E.sessionId,{...Q,frames:R.drawn.length,durationMs:Date.now()-R.startedAt,recording:nr(`${b}.gif`,"image/gif",ae.bytes),keyframe:nr(`${b}.png`,"image/png",se)},{signal:R.abort.signal}),T()}catch{Ke(R)&&await r.current.uploadDevtoolsRecording(E.sessionId,{...Q,hostOutcome:"host",error:"This window could not turn that recording into a file."},{signal:R.abort.signal}).catch(()=>{})}finally{R.frames.length=0,R.drawn.length=0,D.current===R&&(D.current=null)}}return{resourceErrorCount:s,notePersonNavigated:I,noteFrameLoaded:A}}function is(e,t,r){return r!=null&&r.bridgeEligibility?e.mode==="serve"?t===null?null:{kind:"serve",cwd:t,path:e.path}:e.mode==="proxy"?{kind:"proxy",port:e.port,path:e.path}:null:null}function os({iframeRef:e,target:t,cwd:r,resolved:n,reloadNonce:s}){const o=oe(),c=p.useRef(o);p.useEffect(()=>{c.current=o});const a=is(t,r,n),i=a?JSON.stringify(a):null,d=i?`${i}
24
+ `||t.slice(12,16)!=="IHDR")return null;const r=o=>t.charCodeAt(o)*2**24+(t.charCodeAt(o+1)<<16)+(t.charCodeAt(o+2)<<8)+t.charCodeAt(o+3),n=r(16),s=r(20);return n>0&&s>0&&n<=1568&&s<=1568?{width:n,height:s}:null}catch{return null}}let vt=null;async function tr(){return vt===null&&(vt=(await Re(()=>import("./html-to-image-cl8bZGTj.js"),[])).default),vt}let bt=null;async function Qn(){if(bt===null){const e=await Re(()=>import("./gifenc.esm-sOOlYEo8.js"),[]);bt={GIFEncoder:e.GIFEncoder,quantize:e.quantize,applyPalette:e.applyPalette}}return bt}async function rr(e,t,r=()=>{}){if(e.length===0)return{ok:!1,error:"The recording has no frames in it."};r();const{GIFEncoder:n,quantize:s,applyPalette:o}=await Qn();r();const c=e[0],a=e[e.length-1],i=new Uint8ClampedArray(c.data.length+a.data.length);i.set(c.data,0),i.set(a.data,c.data.length);const d=s(i,256),u=n();for(let l=0;l<e.length;l++){r();const m=e[l];if(u.writeFrame(o(m.data,d),m.width,m.height,{...l===0?{palette:d,repeat:0}:{},delay:t.frameMs}),u.bytesView().byteLength>t.maxBytes)return{ok:!1,error:`The recording came out bigger than ${Math.round(t.maxBytes/1024/1024)} MB, so it was not saved.`}}u.finish();const f=u.bytes();return f.byteLength>t.maxBytes?{ok:!1,error:`The recording came out bigger than ${Math.round(t.maxBytes/1024/1024)} MB, so it was not saved.`}:{ok:!0,bytes:f}}async function Kn(e,t,r=()=>{}){const n=[],s=document.createElement("canvas");let o=0,c=0;try{for(let a=0;a<Math.min(e.length,62);a++){r();const i=e[a];if(!Sr(i)){e[a]="";continue}const d=await ts(i);e[a]="";try{if(r(),!d)continue;if(!o){const l=Math.min(1,Math.min(800,t)/Math.max(d.width,d.height,1));o=Math.max(1,Math.round(d.width*l)),c=Math.max(1,Math.round(d.height*l)),s.width=o,s.height=c}const u=s.getContext("2d",{willReadFrequently:!0});if(!u)return[];u.fillStyle="#ffffff",u.fillRect(0,0,o,c);const f=Math.min(o/d.width,c/d.height);u.drawImage(d,0,0,Math.round(d.width*f),Math.round(d.height*f)),r(),n.push({data:u.getImageData(0,0,o,c).data,width:o,height:c})}finally{d&&(d.src="")}}return n}catch(a){throw n.length=0,a}finally{e.length=0,s.width=0,s.height=0}}function es(e,t=()=>{}){const r=document.createElement("canvas"),n=document.createElement("canvas");try{for(let s=0;s<e.length;s++){t();const o=e[s];n.width=o.width,n.height=o.height,r.width=Math.max(1,Math.round(o.width/2)),r.height=Math.max(1,Math.round(o.height/2));const c=n.getContext("2d"),a=r.getContext("2d",{willReadFrequently:!0});if(!c||!a)throw new Error("Canvas pixels are unavailable");c.putImageData(new ImageData(new Uint8ClampedArray(o.data),o.width,o.height),0,0),a.drawImage(n,0,0,r.width,r.height),e[s]={data:a.getImageData(0,0,r.width,r.height).data,width:r.width,height:r.height}}}finally{n.width=n.height=r.width=r.height=0}}function ts(e){return new Promise(t=>{const r=new Image;r.onload=()=>{r.onload=r.onerror=null,t(r)},r.onerror=()=>{r.onload=r.onerror=null,r.src="",t(null)},r.src=e})}function nr(e,t,r){const n=r.slice().buffer;return{name:e,type:t,size:r.byteLength,arrayBuffer:async()=>n}}function rs(e){const t=atob(e.slice(e.indexOf(",")+1));return Uint8Array.from(t,r=>r.charCodeAt(0))}const ns=8e3;function ss(e){const t=oe(),r=p.useRef(t);p.useLayoutEffect(()=>{r.current=t});const[n]=Mt(),[s,o]=p.useState(0),c=p.useRef(null),a=p.useRef(new Map),i=p.useRef(null),d=p.useRef({console:[],network:[],entryBytes:0,overheadBytes:0}),u=p.useRef(null),f=p.useRef(-1),l=p.useRef(null),m=p.useRef(null),w=p.useRef(!1),g=p.useRef(-1/0),v=p.useRef(!1),D=p.useRef(null),N=p.useRef(0),C=p.useRef(null),z=p.useRef(null),F=p.useRef(!1),G=p.useRef(null),L=p.useRef({...e,sessionId:n}),q=p.useRef(Promise.resolve()),U=p.useRef(()=>{}),Y=p.useRef({initialize:x,retire:S,consume:ue,register:P,eligiblePending:te,refuseRequest:y,live:k,captureFrame:mt,valid:Ke,reportRecordingStart:Ae,cancelReservation:Wt,finish:$t});p.useLayoutEffect(()=>{Y.current={initialize:x,retire:S,consume:ue,register:P,eligiblePending:te,refuseRequest:y,live:k,captureFrame:mt,valid:Ke,reportRecordingStart:Ae,cancelReservation:Wt,finish:$t}});const he=R=>G.current===R||V.getState().openDocuments.some(b=>b.id===R&&b.openedHere);function j(R,{active:b,activation:E=!1,keepalive:O=!1,reset:T=!1}){if(!R.sessionId)return;const Q={documentId:R.documentId,logicalUrl:R.logicalUrl,bridgeGeneration:R.generation,seq:Math.max(0,f.current),console:[],network:[],active:b,activation:E,instrumented:R.ready&&!R.retired,...T?{reset:!0}:{}};q.current=q.current.then(()=>r.current.ingestDevtoolsCapture(R.sessionId,Q,O?{keepalive:!0}:void 0)).catch(()=>{})}function S(){var E;const R=c.current;R&&(R.retired=!0),c.current=null,u.current!==null&&clearTimeout(u.current),u.current=null,i.current=null,d.current={console:[],network:[],entryBytes:0,overheadBytes:0},f.current=-1,g.current=-1/0,v.current=!1;for(const[O,T]of a.current)T.life.sessionId&&T.deadline>Date.now()&&T.kind!=="frame"&&y(O,T.kind,T.life,"The frame changed while this request was pending."),clearTimeout(T.timer),(E=T.resolve)==null||E.call(T,null);a.current.clear(),R&&j(R,{active:!1});const b=D.current;b&&(clearTimeout(b.reservationTimer),b.cancelled=!0,b.abort.abort(),b.frames.length=0,b.finishing||(b.drawn.length=0,D.current=null)),C.current!==null&&cancelAnimationFrame(C.current),C.current=null,N.current=0,o(0)}function x({loadActivation:R,reset:b=!1}={}){var $,se;const E=L.current,O=($=E.iframeRef.current)==null?void 0:$.contentWindow;if(w.current||!O||!E.bridgeEligibility||!E.resolvedSource)return;const T={generation:crypto.randomUUID(),frame:O,sessionId:E.sessionId,documentId:E.documentId,logicalUrl:E.logicalUrl,source:E.resolvedSource,origin:E.bridgeEligibility==="served-document"?"null":E.previewOrigin,ready:!1,activation:!1,retired:!1};c.current=T;const Q=R??(F.current||z.current!==T.documentId&&he(T.documentId));T.activation=Q,F.current=!1,z.current=T.documentId,j(T,{active:!0,activation:Q,reset:b}),((se=l.current)==null?void 0:se.frame)===O&&l.current.source===E.resolvedSource&&l.current.reload===E.reloadNonce&&l.current.documentId===E.documentId&&l.current.logicalUrl===E.logicalUrl&&O.postMessage({__dorkosDevtools:"init",bridgeGeneration:T.generation},"*")}p.useLayoutEffect(()=>{var O;L.current={...e,sessionId:n};const R={frame:(O=e.iframeRef.current)==null?void 0:O.contentWindow,sessionId:n,documentId:e.documentId,logicalUrl:e.logicalUrl,source:e.resolvedSource,eligibility:e.bridgeEligibility,origin:e.previewOrigin,reload:e.reloadNonce},b=m.current;if(!b||Object.keys(R).some(T=>R[T]!==b[T])){const T=!b||b.frame!==R.frame||b.documentId!==R.documentId||b.logicalUrl!==R.logicalUrl||b.source!==R.source||b.reload!==R.reload;m.current=R,w.current=!1,S(),x({reset:T})}});const A=p.useCallback(()=>{var Q,$,se;const{initialize:R,retire:b}=Y.current,E=L.current,O=(Q=E.iframeRef.current)==null?void 0:Q.contentWindow,T=($=c.current)!=null&&$.ready?!1:(se=c.current)==null?void 0:se.activation;O&&E.resolvedSource&&(l.current={frame:O,source:E.resolvedSource,reload:E.reloadNonce,documentId:E.documentId,logicalUrl:E.logicalUrl}),w.current=!1,b(),R({loadActivation:T,reset:!0})},[]),I=p.useCallback(()=>{const R=c.current;F.current=!0,G.current=L.current.documentId,R&&U.current({active:!0,activation:!0})},[]);p.useLayoutEffect(()=>{U.current=R=>{c.current&&j(c.current,R)}});function k(R){return c.current===R&&!R.retired}function y(R,b,E,O){if(!E.sessionId)return;const T={requestId:R,bridgeGeneration:E.generation,documentId:E.documentId,hostOutcome:"host",error:O};b==="action"?r.current.postDevtoolsAction(E.sessionId,{...T,ok:!1}).catch(()=>{}):r.current.ingestDevtoolsCapture(E.sessionId,{...T,logicalUrl:E.logicalUrl,seq:Math.max(0,f.current),console:[],network:[],screenshot:{requestId:R,error:O}}).catch(()=>{})}function P(R,b,E,{capture:O=!1,resolve:T,timeoutMs:Q=8e3}={}){if(a.current.size>=_e.pending||a.current.has(R))return null;const $=setTimeout(()=>W(R,se),Q),se={kind:b,life:E,capture:O,deadline:Date.now()+Q,timer:$,resolve:T};return a.current.set(R,se),se}function W(R,b){var E;a.current.get(R)===b&&(a.current.delete(R),clearTimeout(b.timer),(E=b.resolve)==null||E.call(b,null))}function te(R,b,E){return a.current.get(R)!==b||b.life!==E||!k(E)?!1:Date.now()>=b.deadline?(W(R,b),!1):!0}function ue(R,b,E){const O=a.current.get(R);return!O||O.life!==E||O.kind!==b&&!(b==="capture"&&O.kind==="frame")||!te(R,O,E)?null:(a.current.delete(R),clearTimeout(O.timer),O)}p.useEffect(()=>{const{initialize:R,retire:b,consume:E}=Y.current;function O(){u.current=null;const de=i.current;i.current=null,d.current={console:[],network:[],entryBytes:0,overheadBytes:0};const _=c.current;de&&_&&!_.retired&&_.sessionId&&de.bridgeGeneration===_.generation&&r.current.ingestDevtoolsCapture(_.sessionId,de)}function T(de){var Ht,Vt,Jt,Xt;const _=c.current;if(!_||_.retired||de.source!==_.frame||de.origin!==_.origin||((Ht=l.current)==null?void 0:Ht.frame)!==_.frame||l.current.source!==_.source||l.current.reload!==L.current.reloadNonce||l.current.documentId!==_.documentId||l.current.logicalUrl!==_.logicalUrl)return;const M=de.data;if(!M||typeof M!="object"||typeof M.__dorkosDevtools!="string"||!["hello","ready","navigated","resource-error","batch","capture-result","act-result"].includes(M.__dorkosDevtools)||M.__dorkosDevtools!=="hello"&&M.bridgeGeneration!==_.generation)return;const ie=M.__dorkosDevtools==="batch";if(ie){if(!_.ready||!_.sessionId||M.bridgeGeneration!==_.generation||!Number.isSafeInteger(M.seq)||M.seq<0||M.seq<=f.current)return;const H=Date.now();if(H-g.current<_e.batchMs){i.current?i.current.dropped=!0:v.current=!0;return}g.current=H}const B=Yn(M);if(!B){ie&&(v.current=!0);return}if(B.__dorkosDevtools==="hello"){_.frame.postMessage({__dorkosDevtools:"init",bridgeGeneration:_.generation},"*");return}if(B.bridgeGeneration!==_.generation)return;if(B.__dorkosDevtools==="ready"){_.ready||(_.ready=!0,_.activation=!1,j(_,{active:!0}));return}if(!_.ready)return;if(B.__dorkosDevtools==="navigated"){w.current=!0,b();return}if(B.__dorkosDevtools==="resource-error"){N.current=Math.min(_e.resourceErrors,N.current+1),C.current===null&&(C.current=requestAnimationFrame(()=>{C.current=null,k(_)&&o(N.current)}));return}if(!_.sessionId)return;if(B.__dorkosDevtools==="batch"){if(B.seq<=f.current)return;f.current=B.seq;const H=i.current??{documentId:_.documentId,logicalUrl:_.logicalUrl,bridgeGeneration:_.generation,seq:B.seq,console:[],network:[]};H.seq=B.seq,v.current&&(H.dropped=!0),v.current=!1;const je=d.current,Zt=new TextEncoder;if(i.current||(je.overheadBytes=Zt.encode(JSON.stringify({...H,seq:Number.MAX_SAFE_INTEGER,dropped:!0,console:[],network:[]})).length),je.overheadBytes>_e.queueBytes){i.current=null,d.current={console:[],network:[],entryBytes:0,overheadBytes:0},v.current=!0;return}for(const[Fe,Kr]of[["console",B.console],["network",B.network]])for(const en of Kr){const Yt=Zt.encode(JSON.stringify(en)).length;je[Fe].push(Yt),je.entryBytes+=Yt}H.console.push(...B.console),H.network.push(...B.network);const Qr=()=>je.overheadBytes+je.entryBytes+Math.max(0,H.console.length-1)+Math.max(0,H.network.length-1);for(;H.console.length>500||H.network.length>200||Qr()>_e.queueBytes;){H.dropped=!0;const Fe=(((Vt=H.console[0])==null?void 0:Vt.timestamp)??1/0)<=(((Jt=H.network[0])==null?void 0:Jt.timestamp)??1/0)?"console":"network";if(!H[Fe].length)break;H[Fe].shift(),je.entryBytes-=je[Fe].shift()}i.current=H,u.current===null&&(u.current=setTimeout(O,_e.batchMs));return}if(B.__dorkosDevtools==="capture-result"){const H=E(B.requestId,"capture",_);if(!H)return;if(H.kind==="frame"){(Xt=H.resolve)==null||Xt.call(H,B.dataUrl??null);return}r.current.ingestDevtoolsCapture(_.sessionId,{bridgeGeneration:_.generation,documentId:_.documentId,logicalUrl:_.logicalUrl,seq:Math.max(0,f.current),console:[],network:[],hostOutcome:"page-reported",screenshot:{requestId:B.requestId,dataUrl:B.dataUrl,error:B.error}});return}const ze=E(B.requestId,"action",_);if(!ze)return;const Ee=D.current,Gt=ze.capture&&B.dataUrl!==void 0&&Ee!==null&&Ee.life===_&&Ee.activated&&!Ee.finishing&&!Ee.cancelled&&Ee.frames.length<61;Gt&&Ee.frames.push(B.dataUrl);const{__dorkosDevtools:Eo,dataUrl:_o,...Yr}=B;r.current.postDevtoolsAction(_.sessionId,{...Yr,hostOutcome:"page-reported",documentId:_.documentId,captured:Gt||void 0})}window.addEventListener("message",T);const Q=setInterval(()=>U.current({active:!0}),15e3),$=()=>{c.current||R(),U.current({active:!0,activation:!0})},se=()=>{U.current({active:!1,keepalive:!0}),b()},ae=()=>{document.visibilityState==="visible"&&$()};return window.addEventListener("focus",$),window.addEventListener("pagehide",se),window.addEventListener("pageshow",$),document.addEventListener("visibilitychange",ae),()=>{window.removeEventListener("message",T),clearInterval(Q),window.removeEventListener("focus",$),window.removeEventListener("pagehide",se),window.removeEventListener("pageshow",$),document.removeEventListener("visibilitychange",ae),b()}},[]),p.useEffect(()=>un.subscribeSessionEvent((R,b)=>{if(b.type!=="devtools_capture_request"&&b.type!=="devtools_action_request"&&b.type!=="devtools_recording_request")return;const{register:E,eligiblePending:O,refuseRequest:T,captureFrame:Q,valid:$,finish:se,reportRecordingStart:ae,cancelReservation:de}=Y.current,_=c.current;if(!(!(_!=null&&_.ready)||!_.sessionId||_.retired||b.targetClientId!==r.current.clientId||b.documentId!==_.documentId||b.bridgeGeneration!==_.generation)){if(b.type==="devtools_capture_request"||b.type==="devtools_action_request"){const M=b.type==="devtools_action_request",ie=E(b.requestId,M?"action":"capture",_,{capture:M&&!!b.capture,timeoutMs:M&&b.command.action==="wait_for"?Math.min(1e4,b.command.timeoutMs)+2e3:8e3});if(!ie){a.current.has(b.requestId)||T(b.requestId,M?"action":"capture",_,"Too many browser requests are waiting. Try again when one finishes.");return}const B=ze=>{O(b.requestId,ie,_)&&_.frame.postMessage(M?{__dorkosDevtools:"act-request",bridgeGeneration:_.generation,requestId:b.requestId,documentId:_.documentId,command:b.command,...b.capture?{capture:!0,lib:ze}:{}}:{__dorkosDevtools:"capture-request",bridgeGeneration:_.generation,requestId:b.requestId,lib:ze},"*")};!M||b.capture?tr().then(B,()=>B()):B()}if(b.type==="devtools_recording_request"){if(b.action==="cancel-start"){de(b.recordingId,b.requestId,_);return}if(b.action==="confirm-start"){const M=D.current;if(!M||M.id!==b.recordingId||M.startRequestId!==b.requestId||M.life!==_||M.finishing||!$(M))return;if(!M.activated){if(performance.now()>=M.reservationDeadline){de(M.id,M.startRequestId,_),ae(b,_,{phase:"started",ok:!1,error:"This recording reservation expired before capture could start."});return}clearTimeout(M.reservationTimer),M.activated=!0,M.startedAt=Date.now(),Q(_).then(ie=>{ie&&$(M)&&M.frames.push(ie)})}ae(b,_,{phase:"started",ok:!0});return}if(b.action==="start"){const M=b.reservationTimeoutMs;if(!Number.isSafeInteger(M)||!M||M<1||M>ns){ae(b,_,{phase:"reserved",ok:!1,error:"This recording request has no valid reservation timeout."});return}if(D.current){ae(b,_,{phase:"reserved",ok:!1,error:"Another recording in this window is still running or being saved. Wait for it to finish, then start again."});return}const ie={id:b.recordingId,startRequestId:b.requestId,activated:!1,reservationDeadline:performance.now()+M,life:_,startedAt:Date.now(),frames:[],drawn:[],finishing:!1,cancelled:!1,abort:new AbortController};D.current=ie,ie.reservationTimer=setTimeout(()=>{D.current===ie&&!ie.activated&&de(ie.id,ie.startRequestId,_)},M),ae(b,_,{phase:"reserved",ok:!0})}else se(b.requestId,b.recordingId,_)}}}),[]);function Ae(R,b,E){!k(b)||!b.sessionId||r.current.ingestDevtoolsCapture(b.sessionId,{hostOutcome:"host",documentId:b.documentId,bridgeGeneration:b.generation,seq:0,console:[],network:[],recordingStart:{...E,requestId:R.requestId,recordingId:R.recordingId}}).catch(()=>{})}function Wt(R,b,E){var T;const O=D.current;if(!(!O||O.id!==R||O.startRequestId!==b||O.life!==E||O.finishing)){clearTimeout(O.reservationTimer),O.cancelled=!0,O.abort.abort(),O.frames.length=0,O.drawn.length=0;for(const[Q,$]of a.current)$.life===E&&$.kind==="frame"&&(clearTimeout($.timer),(T=$.resolve)==null||T.call($,null),a.current.delete(Q));D.current=null}}function Ke(R){return D.current===R&&!R.cancelled&&k(R.life)}function mt(R){const b=`frame-${crypto.randomUUID()}`;return new Promise(E=>{const O=P(b,"frame",R,{resolve:E});if(!O){E(null);return}tr().then(T=>{te(b,O,R)&&R.frame.postMessage({__dorkosDevtools:"capture-request",bridgeGeneration:R.generation,requestId:b,lib:T},"*")},()=>{W(b,O)})})}async function $t(R,b,E){const O=D.current;if(!O||!O.activated||O.id!==b||O.life!==E){k(E)&&await r.current.uploadDevtoolsRecording(E.sessionId,{requestId:R,bridgeGeneration:E.generation,documentId:E.documentId,hostOutcome:"host",error:"The window showing that page stopped recording before it could be saved."}).catch(()=>{});return}if(O.finishing)return;O.finishing=!0;const T=()=>{if(!Ke(O))throw new Error("retired")},Q={requestId:R,bridgeGeneration:E.generation,documentId:E.documentId};try{const $=await mt(E);T(),$&&O.frames.length<_e.frames&&O.frames.push($);const se=O.frames.length?rs(O.frames[O.frames.length-1]):new Uint8Array;O.drawn=await Kn(O.frames,800,T),T();let ae=await rr(O.drawn,{frameMs:500,maxBytes:8*1024*1024},T);if(T(),!ae.ok&&O.drawn.length&&(es(O.drawn,T),ae=await rr(O.drawn,{frameMs:500,maxBytes:8*1024*1024},T),T()),!ae.ok){await r.current.uploadDevtoolsRecording(E.sessionId,{...Q,hostOutcome:"host",error:ae.error},{signal:O.abort.signal}),T();return}T(),await r.current.uploadDevtoolsRecording(E.sessionId,{...Q,frames:O.drawn.length,durationMs:Date.now()-O.startedAt,recording:nr(`${b}.gif`,"image/gif",ae.bytes),keyframe:nr(`${b}.png`,"image/png",se)},{signal:O.abort.signal}),T()}catch{Ke(O)&&await r.current.uploadDevtoolsRecording(E.sessionId,{...Q,hostOutcome:"host",error:"This window could not turn that recording into a file."},{signal:O.abort.signal}).catch(()=>{})}finally{O.frames.length=0,O.drawn.length=0,D.current===O&&(D.current=null)}}return{resourceErrorCount:s,notePersonNavigated:I,noteFrameLoaded:A}}function is(e,t,r){return r!=null&&r.bridgeEligibility?e.mode==="serve"?t===null?null:{kind:"serve",cwd:t,path:e.path}:e.mode==="proxy"?{kind:"proxy",port:e.port,path:e.path}:null:null}function os({iframeRef:e,target:t,cwd:r,resolved:n,reloadNonce:s}){const o=oe(),c=p.useRef(o);p.useEffect(()=>{c.current=o});const a=is(t,r,n),i=a?JSON.stringify(a):null,d=i?`${i}
25
25
  ${n==null?void 0:n.src}
26
- ${s}`:null,[u,f]=p.useState(null);return p.useLayoutEffect(()=>{if(d===null||i===null)return;const l=JSON.parse(i);let m=!0,w=0;const g=new WeakSet,v=D=>{const N=D.target;if(N===null||N!==e.current)return;const C=++w;if(g.has(N)){f(null);return}g.add(N),c.current.getFrameBridgeStatus(l).then(z=>{!m||C!==w||f(z.bridge==="refused"&&z.reason?{pageKey:d,reason:z.reason}:null)},()=>{})};return document.addEventListener("load",v,!0),()=>{m=!1,document.removeEventListener("load",v,!0)}},[d,i,e]),u!==null&&u.pageKey===d?u.reason:null}const as=15e3;function cs(e){const t=e instanceof Error?e.message.trim():"";return t.length>0?t:"Couldn’t reach DorkOS. Check your network and try again."}function us(e){const t=oe();return{open:p.useCallback(async r=>{await t.openRoomCanvasDocument(e,r)},[t,e]),update:p.useCallback(async(r,n)=>{await t.updateRoomCanvasDocument(e,r,{content:n})},[t,e]),pin:p.useCallback(async(r,n)=>{await t.updateRoomCanvasDocument(e,r,{pinned:n})},[t,e]),close:p.useCallback(async r=>{await t.closeRoomCanvasDocument(e,r)},[t,e])}}function ls(e,t){const r=oe(),n=V(s=>s.setRoomCanvasEditing);p.useEffect(()=>{if(n(e,t),t===null)return;const s=c=>{r.setRoomCanvasEditing(e,t,c).catch(a=>{console.warn("[room-canvas] edit lock failed",{roomId:e,documentId:t,err:a})})};s(!0);const o=setInterval(()=>s(!0),as);return()=>{clearInterval(o),s(!1),n(e,null)}},[r,e,t,n])}const ds=400;function Mo(e,t){const r=oe(),n=V(s=>s.roomCanvasPresenceEpoch[e]??0);p.useEffect(()=>{const s=a=>{r.setRoomCanvasViewing(e,a).catch(i=>{console.warn("[room-canvas] could not say where we are looking",{roomId:e,err:i})})};let o=!1;const c=setTimeout(()=>{o=!0,s(t)},ds);return()=>{clearTimeout(c),o&&s(null)}},[r,e,t,n])}const fs="allow-scripts allow-forms allow-popups allow-modals",wt="allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-downloads",hs=new Set(["javascript:","data:","blob:"]),ps=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","::1"]);function qt(e){return ps.has(e)||e.endsWith(".localhost")}function ms(e){return qt(e)?"direct":"server"}function gs(e,t){let r;try{r=new URL(e)}catch{return null}const n=r.searchParams.get(sr),s=new URL(r.origin),o=t.indexOf("?");return s.pathname=(o===-1?t:t.slice(0,o))||"/",s.search=o===-1?"":t.slice(o),n!==null&&s.searchParams.set(sr,n),s.toString()}const sr="__dorkos_preview",vs="/__dorkos_preview/health";function bs(e){return e==="https:"?443:80}function Dr(e){let t;try{t=new URL(e)}catch{return{mode:"serve",path:e}}if(hs.has(t.protocol))return{mode:"blocked"};if(t.protocol==="file:")return{mode:"serve",path:decodeURIComponent(t.pathname)};if(t.protocol==="http:"||t.protocol==="https:"){if(qt(t.hostname)){const r=t.port?Number(t.port):bs(t.protocol);return{mode:"proxy",hostname:t.hostname,port:r,path:`${t.pathname}${t.search}`}}return{mode:"external",url:e}}return{mode:"blocked"}}function ws(e){const t=e.trim();if(t===""||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const r=t.split("/")[0];if(t.includes("/")&&!r.includes(".")&&!r.includes(":"))return t;const s=r.split(":")[0];return`${qt(s)?"http":"https"}://${t}`}function xs(e){const t=Dr(e);if(t.mode==="serve")return{kind:"local",path:t.path};if(t.mode==="blocked")return{kind:"raw",text:e};try{const r=new URL(e),n=r.host.replace(/^www\./,""),s=r.pathname==="/"&&r.search===""&&r.hash===""?"":`${r.pathname}${r.search}${r.hash}`;return{kind:"url",host:n,rest:s}}catch{return{kind:"raw",text:e}}}const ys=2e3;async function ir(e,t=globalThis.fetch,r=ys){const n=new AbortController,s=setTimeout(()=>n.abort(),r);try{return await t(e,{mode:"no-cors",cache:"no-store",signal:n.signal}),!0}catch{return n.signal.aborted}finally{clearTimeout(s)}}function ks({target:e,currentUrl:t,strategy:r,cwd:n,reloadNonce:s}){const o=JSON.stringify([t,r,n,s]),[c,a]=p.useState(null),[i,d]=p.useState(null),[u,f]=p.useState(null),l=oe(),m=p.useRef(l);return p.useEffect(()=>{m.current=l}),p.useEffect(()=>{const w=m.current;let g=!1;const v=z=>{a(o),d(z)};async function D(z){if(n===null){f({kind:"no-session"});return}try{const F=await w.createServeUrl(n,z);if(g)return;F===null?f({kind:"unsupported"}):v({src:F,sandbox:fs,previewOrigin:null,bridgeEligibility:"served-document"})}catch{g||f({kind:"failed"})}}async function N(z,F){let G;try{const q=await w.probeLoopbackPort(z);G=q===null?"unknown":q.listening}catch{G="unknown"}if(g)return;let L=null;if(G!==!1){let q=null;try{q=await w.createProxyUrl(z)}catch{if(g)return;L={kind:"failed"}}if(g)return;if((q==null?void 0:q.unavailable)==="tunnel"){f({kind:"tunnel"});return}if((q==null?void 0:q.unavailable)==="no-port"&&(L={kind:"no-port"}),q!=null&&q.url){const U=new URL(q.url);if(await ir(`${U.origin}${vs}`)){if(g)return;const Y=gs(q.url,F);if(Y!==null){v({src:Y,sandbox:wt,previewOrigin:U.origin,bridgeEligibility:"preview-listener"});return}}if(g)return;L={kind:"origin-unreachable",host:U.hostname,listenPort:U.port}}}if(r==="direct"&&await ir(t)){if(g)return;v({src:t,sandbox:wt,previewOrigin:null,bridgeEligibility:null});return}g||f(L??{kind:"no-upstream"})}async function C(){if(f(null),d(null),e.mode!=="blocked"){if(e.mode==="external"){v({src:e.url,sandbox:wt,previewOrigin:null,bridgeEligibility:null});return}return e.mode==="serve"?D(e.path):N(e.port,e.path)}}return C(),()=>{g=!0}},[e,t,r,n,s,o]),{resolved:c===o?i:null,resolveError:u}}const js=ln/(1024*1024),Cs={csp:"This page’s security policy blocks added scripts, so it can’t talk to its agent.",encoding:"This page isn’t saved as UTF-8, so it can’t talk to its agent.",oversize:`This page is over ${js} MB, so it can’t talk to its agent.`,"no-head":"This page has no <head> tag, so it can’t talk to its agent.",markup:"DorkOS can’t safely read this page’s <head>, so it can’t talk to its agent.","fixed-source":"DorkOS couldn’t connect this page to its agent."};function Rs({reason:e}){return h.jsx("p",{role:"status","data-bridge-refusal":e,className:"text-muted-foreground border-border/60 border-b px-2 py-1 text-xs",children:Cs[e]})}const Os=1e4;function Es(e,t){if(e&&e.contentUrl===t&&e.stack.length>0){const r=Math.min(Math.max(e.cursor,0),e.stack.length-1);return{stack:e.stack,cursor:r}}return{stack:[t],cursor:0}}function _s({documentId:e,content:t}){const r=V(I=>I.selectedCwd),n=V(I=>I.writeBrowserHistory),[s]=p.useState(()=>Es(V.getState().browserHistories[e],t.url)),[o,c]=p.useState(s.stack),[a,i]=p.useState(s.cursor),[d,u]=p.useState(0);p.useEffect(()=>{n(e,{contentUrl:t.url,stack:o,cursor:a})},[e,t.url,o,a,n]);const f=o[a],l=p.useMemo(()=>Dr(f),[f]),m=p.useMemo(()=>l.mode==="proxy"?ms(window.location.hostname):null,[l]),w=p.useRef(null),{resolved:g,resolveError:v}=ks({target:l,currentUrl:f,strategy:m,cwd:r,reloadNonce:d}),{resourceErrorCount:D,notePersonNavigated:N,noteFrameLoaded:C}=ss({iframeRef:w,documentId:e,logicalUrl:f,reloadNonce:d,previewOrigin:(g==null?void 0:g.previewOrigin)??null,bridgeEligibility:(g==null?void 0:g.bridgeEligibility)??null,resolvedSource:(g==null?void 0:g.src)??null}),z=os({iframeRef:w,target:l,cwd:r,resolved:g,reloadNonce:d}),F=V(I=>I.roomCanvasLiveRoomId),{open:G}=us(F??""),[L,q]=p.useState(null),U=p.useCallback(I=>{c(k=>[...k.slice(0,a+1),I]),i(k=>k+1)},[a]),Y=dn(F),he=V(I=>F?I.roomCanvasEditing[F]??null:null);p.useEffect(()=>{if(Y===null||he!==null||Y.documentId!==e)return;const I=Y.url;I===void 0||I===f||U(I)},[Y,he,e,f,U]);const j=a>0,S=a<o.length-1,x=p.useCallback(I=>{const k=ws(I);if(!k||k===f){N(),u(y=>y+1);return}if(F){q(null),G({type:"browser",url:k}).catch(y=>{q({url:k,message:cs(y)})});return}N(),U(k)},[f,U,F,G,N]),A=()=>gn(f);return h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsxs("div",{className:"border-border/60 flex shrink-0 flex-wrap items-center gap-1 border-b px-2 py-1 lg:h-9 lg:flex-nowrap lg:py-0",children:[h.jsx(et,{label:"Back",disabled:!j,onClick:()=>i(I=>I-1),children:h.jsx(fn,{className:"size-4"})}),h.jsx(et,{label:"Forward",disabled:!S,onClick:()=>i(I=>I+1),children:h.jsx(hn,{className:"size-4"})}),h.jsx(et,{label:"Reload",onClick:()=>u(I=>I+1),children:h.jsx(Nn,{className:"size-4"})}),h.jsx("div",{className:"order-first flex w-full min-w-0 lg:order-none lg:w-auto lg:flex-1",children:h.jsx(Ss,{url:(L==null?void 0:L.url)??f,startEditing:L!==null,onSubmit:x},L===null?"address":`retry:${L.url}`)}),h.jsx(et,{label:"Open in system browser",onClick:A,children:h.jsx(pn,{className:"size-4"})})]}),L!==null&&h.jsx("p",{role:"status",className:"text-destructive border-border/60 border-b px-2 py-1 text-xs",children:L.message}),z!==null&&h.jsx(Rs,{reason:z}),h.jsx(Ts,{target:l,resolved:g,resolveError:v,reloadNonce:d,resourceErrorCount:D,title:t.title??"Embedded browser",onOpenExternally:A,onReload:()=>{N(),u(I=>I+1)},iframeRef:w,onFrameLoad:C})]})}function Ss({url:e,startEditing:t=!1,onSubmit:r}){const[n,s]=p.useState(t),[o,c]=p.useState(e);if(!n)return h.jsx(Is,{url:e,onActivate:()=>{c(e),s(!0)}});const a=i=>{i.preventDefault(),s(!1),r(o)};return h.jsx("form",{onSubmit:a,className:"min-w-0 flex-1",children:h.jsx(mn,{"aria-label":"Address",autoFocus:!0,value:o,onChange:i=>c(i.target.value),onFocus:i=>i.currentTarget.select(),onBlur:()=>s(!1),onKeyDown:i=>{i.key==="Escape"&&(i.preventDefault(),s(!1))},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:"h-11 w-full text-base lg:h-7 lg:text-sm"})})}function Ds(e){return e.kind==="local"?e.path:e.kind==="url"?`${e.host}${e.rest}`:e.text}function Is({url:e,onActivate:t}){const r=p.useMemo(()=>xs(e),[e]);return h.jsxs("button",{type:"button","aria-label":`Address: ${Ds(r)}`,onClick:t,className:"text-muted-foreground hover:bg-muted focus-ring flex h-11 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 text-left text-sm transition-colors lg:h-7",children:[r.kind==="local"&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"bg-muted-foreground/15 text-3xs rounded px-1 py-0.5 font-medium tracking-wide uppercase",children:"local"}),h.jsx("span",{className:"text-foreground truncate",children:r.path})]}),r.kind==="url"&&h.jsxs("span",{className:"truncate",children:[h.jsx("span",{className:"text-foreground",children:r.host}),h.jsx("span",{className:"text-muted-foreground",children:r.rest})]}),r.kind==="raw"&&h.jsx("span",{className:"truncate",children:r.text})]})}function Ns(e,t){switch(e.kind){case"no-session":return"Open a chat to preview local files.";case"unsupported":return"Local previews aren’t available in this environment.";case"failed":return"Couldn’t load this preview. Reload, or open the app in your browser.";case"tunnel":return"Dev server previews don’t work remotely. Open DorkOS on the computer running it.";case"no-port":return"All preview ports are in use. Close a preview, then reload.";case"origin-unreachable":return`This view can’t reach port ${e.listenPort} on ${e.host}. Open DorkOS on the computer running it.`;case"no-upstream":return`Nothing is listening on ${t.mode==="proxy"?`${t.hostname}:${t.port}`:"that address"}. Start the dev server, then reload.`}}function Ts({target:e,resolved:t,resolveError:r,reloadNonce:n,resourceErrorCount:s,title:o,onOpenExternally:c,onReload:a,iframeRef:i,onFrameLoad:d}){if(e.mode==="blocked")return h.jsx(xt,{children:"This address is blocked for safety."});if(r!==null)return h.jsxs(xt,{children:[h.jsx("p",{children:Ns(r,e)}),r.kind!=="no-session"&&r.kind!=="unsupported"&&h.jsx("button",{type:"button",onClick:a,className:"text-foreground mt-3 hover:underline",children:"Reload"})]});if(t===null)return h.jsx(xt,{children:"Loading…"});const u=e.mode==="external";return h.jsx(As,{src:t.src,sandbox:t.sandbox,title:o,iframeRef:i,onFrameLoad:d,watchLoadDeadline:!u,resourceErrorCount:s,showEmbedFallback:u,onOpenExternally:c,onReload:a},`${t.src}:${n}`)}function As({src:e,sandbox:t,title:r,iframeRef:n,onFrameLoad:s,watchLoadDeadline:o,resourceErrorCount:c,showEmbedFallback:a,onOpenExternally:i,onReload:d}){const[u,f]=p.useState(!1),[l,m]=p.useState(!1);return p.useEffect(()=>{if(!o)return;const w=setTimeout(()=>m(!0),Os);return()=>clearTimeout(w)},[o]),h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[l&&!u&&h.jsx(or,{onOpenExternally:i,onReload:d,children:"This preview is slow to load."}),c>0&&h.jsxs(or,{onOpenExternally:i,children:["This page hit ",c===1e4?"at least 10,000":c," ",c===1?"error":"errors"," while loading."]}),h.jsx("iframe",{ref:n,src:e,sandbox:t,onLoad:()=>{f(!0),s()},className:"min-h-0 w-full flex-1 border-0",title:r}),a&&h.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-t px-3 py-1.5 text-xs",children:[h.jsx("span",{children:"This site can’t always be embedded here."}),h.jsx("button",{type:"button",onClick:i,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function or({children:e,onOpenExternally:t,onReload:r}){return h.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-b px-3 py-1.5 text-xs",children:[h.jsx("span",{children:e}),h.jsxs("span",{className:"flex shrink-0 items-center gap-3",children:[r&&h.jsx("button",{type:"button",onClick:r,className:"text-foreground hover:underline",children:"Reload"}),h.jsx("button",{type:"button",onClick:t,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function et({label:e,disabled:t,onClick:r,children:n}){return h.jsx("button",{type:"button","aria-label":e,disabled:t,onClick:r,className:Lt("text-muted-foreground hover:text-foreground hover:bg-muted focus-ring flex size-11 shrink-0 items-center justify-center rounded-md transition-colors lg:size-7",t&&"pointer-events-none opacity-40"),children:n})}function xt({children:e}){return h.jsx("div",{className:"text-muted-foreground flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center",children:e})}const zs=4096;function Fs(e){return e.toLowerCase().endsWith(".md")?e.slice(0,-3):e}function Ms(e){const t=e.trim(),r=/^(["'])(.*)\1$/.exec(t);return r?r[2].trim():/^[|>][+-]?\d*$/.test(t)?"":t.replace(/\s+#.*$/,"").trim()}function Ls(e,t){var o;const r=e.replace(/^\uFEFF/,"").split(/\r?\n/);let n=0;if(r[0]==="---"){for(n=1;n<r.length;n+=1){const c=r[n];if(c==="---"||c==="...")break;const a=/^title:(.*)$/.exec(c);if(a){const i=Ms(a[1]);if(i!=="")return i}}n+=1}let s=null;for(;n<r.length;n+=1){const c=r[n],a=(o=/^ {0,3}(`{3,}|~{3,})/.exec(c))==null?void 0:o[1];if(a){s===null?s=a[0]:a[0]===s&&(s=null);continue}if(s!==null)continue;const i=/^ {0,3}#[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/.exec(c);if(i&&i[1].trim()!=="")return i[1].trim()}return Fs(t)}function qs(e,t,r=zs){let n=new TextDecoder().decode(e.subarray(0,r));return e.length>=r&&(n=n.slice(0,Math.max(0,n.lastIndexOf(`
27
- `)))),Ls(n,t)}function Ps(e,t){return qs(new TextEncoder().encode(e),t)}const Ir=X({path:ce().min(1),title:ce(),slug:ce()});X({root:ce(),docs:jt(Ir),truncated:it()});X({cwd:ce().min(1)});X({cwd:ce().min(1),target:ce().min(1).max(1e3),from:ce().min(1).optional()});X({doc:Ir.nullable(),complete:it()});const Ot=".md";function we(e){return e.normalize("NFC").trim().toLowerCase()}function Nr(e){return we(e).replace(/\s+/g,"-")}function qe(e){return e.toLowerCase().endsWith(Ot)?e.slice(0,-Ot.length):e}function ar(e){return e.slice(e.lastIndexOf("/")+1)}function nt(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function ct(e){return e===""?[]:e.split("/")}function Bs(e,t){const r=ct(e);for(const n of t.split("/"))if(!(n===""||n==="."))if(n===".."){if(r.length===0)return null;r.pop()}else r.push(n);return r.length===0?null:r.join("/")}function cr(e,t){const r=ct(e),n=ct(t);let s=0;for(;s<r.length&&s<n.length&&r[s]===n[s];)s+=1;return r.length-s+(n.length-s)}function Us(e){return Nr(e).replace(/[^\p{L}\p{N}_-]/gu,"")}function Ws(e,t,r=null){const n=r&&r.trim()!==""?`#${Us(r)}`:"",s=e===null?null:e.normalize("NFC"),o=t.normalize("NFC");if(s===o&&n)return n;const c=ct(s===null?"":nt(s)),a=o.split("/");let i=0;for(;i<c.length&&i<a.length-1&&c[i]===a[i];)i+=1;return[...Array.from({length:c.length-i},()=>".."),...a.slice(i)].map(encodeURIComponent).join("/")+n}const $s=/[[\]|#\n\r]/,Gs=20;function Hs(e){const t=e.map(a=>({doc:a,folder:nt(a.path),path:we(a.path),title:we(a.title),base:we(qe(ar(a.path)))})),r=new Map(t.map(a=>[a.path,a])),n=a=>(i,d)=>cr(a,i.folder)-cr(a,d.folder)||i.doc.path.length-d.doc.path.length||(i.doc.path<d.doc.path?-1:i.doc.path>d.doc.path?1:0);function s(a,i){const d=qe(a),u=a.startsWith("/")?[""]:[i,""];for(const f of u){const l=Bs(f,d);if(l===null)continue;const m=r.get(we(l+Ot));if(m)return m}}function o(a,i){const d=a.normalize("NFC").trim();if(d==="")return null;const u=i===null?"":nt(i);if(d.includes("/")){const g=s(d,u);if(g)return g}const f=we(d),l=we(qe(d)),m=Nr(l),w=t.filter(g=>g.title===f||g.base===l||g.doc.slug===m);return w.length===0?null:w.sort(n(u))[0]??null}function c(a,i){const d=[a.doc.title.trim(),qe(ar(a.doc.path)),`/${qe(a.doc.path)}`];for(const u of d)if(!(u===""||$s.test(u))&&o(u,i)===a)return u;return null}return{docs:e,resolve:(a,i)=>{var d;return((d=o(a,i))==null?void 0:d.doc)??null},search(a,i,d=Gs){const u=we(a),f=i===null?"":nt(i),l=i===null?null:we(i),m=[];for(const v of t){if(v.path===l)continue;const D=u===""||v.title.startsWith(u)?0:v.title.split(/[\s\-_/]+/).some(N=>N.startsWith(u))?1:v.title.includes(u)?2:v.path.includes(u)?3:-1;D>=0&&m.push({entry:v,score:D})}const w=n(f);m.sort((v,D)=>v.score-D.score||w(v.entry,D.entry));const g=[];for(const{entry:v}of m){if(g.length>=d)break;const D=c(v,i);D!==null&&g.push({target:D,title:v.doc.title,description:v.doc.path})}return g}}}function ur(e,t){const r=t.normalize("NFC").replaceAll("\\","/"),n=r.startsWith("/")||/^[A-Za-z]:\//.test(r);let s=r;if(n){const c=e.normalize("NFC").replaceAll("\\","/").replace(/\/+$/,"");if(!r.startsWith(`${c}/`))return null;s=r.slice(c.length+1)}const o=[];for(const c of s.split("/"))if(!(c===""||c==="."))if(c===".."){if(o.length===0)return null;o.pop()}else o.push(c);return o.length===0?null:o.join("/")}const lr="Links within this doc don’t open.",dr="This folder is too big to check this link.",fr="Couldn’t check this link.";function hr(e,t,r){return{exists:!0,href:Ws(e,t.path,r),title:t.title}}function Vs(e){const{index:t,truncated:r,docPath:n,lookup:s,open:o,refuse:c}=e,a=new Map,i=f=>{const l=f.normalize("NFC").trim().toLowerCase();let m=a.get(l);return m||(m=s(f.trim()).catch(()=>null),a.set(l,m)),m};return{resolve:f=>{if(f.target.trim()==="")return{exists:!1,title:lr};const l=t.resolve(f.target,n);return l?hr(n,l,f.heading):r?i(f.target).then(m=>m===null?{exists:!0,title:fr}:m.doc?hr(n,m.doc,f.heading):m.complete?{exists:!1}:{exists:!0,title:dr}):{exists:!1}},search:f=>t.search(f,n),onOpen:f=>{const l=f.target.trim();if(l===""){c(lr);return}const m=`No doc called “${l}” yet.`,w=t.resolve(l,n);if(w){o(w.path);return}if(!r){c(m);return}i(l).then(g=>{g!=null&&g.doc?o(g.doc.path):c(g===null?fr:g.complete?m:dr)})}}}function Js({cwd:e,sourcePath:t,content:r="",saved:n=!1}){const{enabled:s}=vn(bn),o=s&&!!e&&!!t,{data:c}=Wn(e,o),a=$n(),i=oe(),{setTheme:d}=wn(),u=o&&c&&e&&t?ur(e,t)??ur(c.root,t):null,f=p.useMemo(()=>c?Hs(c.docs):null,[c]),l=p.useRef({index:f,docPath:u,content:r,cwd:e});p.useEffect(()=>{l.current={index:f,docPath:u,content:r,cwd:e}}),p.useEffect(()=>{const{index:w,docPath:g,content:v,cwd:D}=l.current;if(!n||!w||g===null)return;const N=w.docs.find(z=>z.path.normalize("NFC").toLowerCase()===g.toLowerCase()),C=g.slice(g.lastIndexOf("/")+1);(!N||N.title!==Ps(v,C))&&a(D)},[n,a]);const m=p.useCallback(w=>{xn({getStore:V.getState,setTheme:d,supportsTerminal:i.supportsTerminal},{action:"open_file",sourcePath:w},"user")},[d,i]);return p.useMemo(()=>{if(!(!f||!c||u===null||!e))return Vs({index:f,truncated:c.truncated,docPath:u,lookup:w=>i.resolveDocLink(e,w,u),open:m,refuse:w=>yn.info(w)})},[f,c,u,e,i,m])}const Je=ce().min(1).max(128),pe={protocol:K("dorkos-doc"),v:K(1),nonce:Je,requestToken:Je,loadToken:Ct,generation:yr.shape.generation};ht("kind",[X({...pe,kind:K("challenge")}).strict(),X({...pe,kind:K("ack")}).strict(),X({...pe,kind:K("connect")}).strict()]);ht("kind",[X({...pe,kind:K("emit"),requestId:Je,event:ot}).strict(),X({...pe,kind:K("retire")}).strict()]);ht("kind",[X({...pe,kind:K("receipt"),requestId:Je,receipt:kr}).strict(),X({...pe,kind:K("refused"),requestId:Je,outcome:Kt(["cancelled","unconfirmed","refused"])}).strict(),X({...pe,kind:K("state"),state:jn,stateRev:Ct,docSeq:Ct,reset:it()}).strict(),X({...pe,kind:K("event"),frame:Cn}).strict(),X({...pe,kind:K("status"),status:Kt(["connecting","ready","offline","revoked"]),unconfirmed:it()}).strict()]);function Zs(e,t){try{if(kn(t,1048576)!==void 0)return null;const r=e.safeParse(t);return r.success?r.data:null}catch{return null}}function Xs(e){return typeof e=="object"&&e!==null&&e.status===404}function Ys({owner:e,getOwner:t,readTail:r,writeTail:n,transport:s,cwd:o,sourcePath:c,documentId:a,pending:i}){const d=()=>{var g,v;return((g=t())==null?void 0:g.recoveryGate)==="unsupported"||((v=t())==null?void 0:v.recoveryGate)==="observed_clear"},u=g=>{var N;const v=Rn.parse(g),D=(N=t())==null?void 0:N.recoveryBinding;if(!D||v.documentId!==a||!J(v.incarnation,D.incarnation))throw new Error("Original save scope changed");return v},f=s.originalFileSaveRecovery,l=()=>{var g;try{const v=t();return(v==null?void 0:v.identity)===e&&v.active&&!!((g=v.recoveryBinding)!=null&&g.current())}catch{return!1}},m=(g,v,D=!1,N=!1)=>{if(!f||!l())return Promise.resolve({status:"idle"});const C=t(),z={},F=()=>t()===C&&l()&&(!v||C.recoveryBinding===v)&&(!D||C.recoveryWork===z),G=C.discovery;let L=!1;C.recoveryWork=z,C.recoveryGate="pending",C.recoveryBusy=!0;const q=r().catch(()=>{}).then(async()=>{try{if(!F())return{status:"idle"};const U=await g();return F()?(D&&(C.recoveryGate="observed_clear"),L=!0,{status:"observed",value:U}):{status:"idle"}}catch(U){return F()?(C.recoveryGate="unavailable",{status:N&&Xs(U)?"refused":"unavailable"}):{status:"idle"}}finally{!L&&C.discovery===G&&(C.discovery=void 0),C.recoveryWork===z&&(C.recoveryBusy=!1,C.recoveryWork=void 0)}});return D||n(q.then(()=>{})),q};return{identity:e,supported:!!f,current:l,discover:(g=!1)=>{if(!f||!l())return Promise.resolve({status:"idle"});const v=t(),D=v.recoveryBinding;if(v.discoveryBinding===D&&v.discovery&&(v.pendingDiscovery===v.discovery||!g&&v.recoveryGate==="observed_clear"))return v.discovery;const N=m(async()=>{const C=u(await f.discover(a));return t()===v&&v.recoveryBinding===D&&l()&&(v.recoveryGate=C.admission==="blocked"?"blocked":"observed_clear"),C},D,!1,!0);return v.discoveryBinding=D,v.discovery=N,v.pendingDiscovery=N,N.then(C=>{v.pendingDiscovery===N&&(v.pendingDiscovery=void 0),C.status==="idle"&&v.discovery===N&&(v.discovery=void 0)}),N},recover(g){if(i())return Promise.resolve({status:"local_uncertain"});const v=t();return m(async()=>{if(!v||i())throw new Error("Mounted original still uncertain");const D=v.recoveryBinding,N=On.parse(await f.recover(a,g,D.incarnation));if(t()!==v||!l()||N.documentId!==a||N.entry.eventId!==g||!J(N.incarnation,D.incarnation))throw new Error("Original recovery scope changed");const C=u(await f.discover(a));return t()===v&&l()&&(v.recoveryGate=C.admission==="blocked"?"blocked":"observed_clear"),{result:N,discovery:C}})},inspectCurrent(){const g=t();return!g||!l()||i()||!d()?Promise.resolve({status:"local_uncertain"}):m(async()=>{const v=await s.readFileContent(o,c);if(!v||typeof v.content!="string"||typeof v.hash!="string"||!/^[a-f0-9]{64}$/u.test(v.hash))throw new Error("Current file evidence missing");return{content:v.content,hash:v.hash}},g.recoveryBinding,!0)}}}class Se extends Error{constructor(){super("The original save is not confirmed. Retry it before saving another draft.")}}class Ge extends Error{}function Qs(){const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Ks(e){const t=e;return(t==null?void 0:t.status)===412&&t.code==="DOC_SAVE_FAILED"}var fe,Ie,Ye,Et;class ei{constructor(){Le(this,Ye);Le(this,fe);Le(this,Ie)}get pending(){return Me(this,fe)!==void 0}get receipt(){return Me(this,Ie)}async write(t,r,n,s,o,c,a=!1){if(Me(this,fe))throw new Se;if(ve(this,Ie,void 0),!c)return t.writeFile(r,n,s,o);if(!a&&!c.current())throw new Ge;const i=Object.freeze({cwd:r,path:n,content:s,options:Object.freeze({...o,documentSave:Object.freeze({documentId:c.incarnation.documentId,eventId:Qs(),incarnation:Object.freeze({...c.incarnation})})})});return ve(this,fe,i),be(this,Ye,Et).call(this,t,i)}async retry(t,r){const n=Me(this,fe);if(!(n!=null&&n.options.documentSave)||!r.current()||!J(n.options.documentSave.incarnation,r.incarnation))throw new Ge;return{result:await be(this,Ye,Et).call(this,t,n),content:n.content}}}fe=new WeakMap,Ie=new WeakMap,Ye=new WeakSet,Et=async function(t,r){try{const n=await t.writeFile(r.cwd,r.path,r.content,r.options);if(!n||typeof n!="object"||typeof n.ok!="boolean")throw new Se;if(!n.ok){if(!n.conflict||typeof n.conflict.currentHash!="string"||!n.conflict.currentHash||typeof n.conflict.currentContent!="string")throw new Se;return ve(this,fe,void 0),n}if(typeof n.hash!="string"||!n.hash||n.effect!=="changed"&&n.effect!=="no_op")throw new Se;const s="documentReceipt"in n?En.parse(n.documentReceipt):void 0,o=r.options.documentSave;if(!s&&n.effect!=="no_op")throw new Se;if(s&&(s.documentId!==o.documentId||s.eventId!==o.eventId||!J(s.incarnation,o.incarnation)||s.fileHash!==n.hash||(s.status==="accepted"?n.effect!=="changed":n.effect!=="no_op")))throw new Se;if((s==null?void 0:s.status)==="duplicate"){const c=await t.readFileContent(r.cwd,r.path);if(!c||typeof c!="object"||Array.isArray(c)||typeof c.hash!="string"||!c.hash||typeof c.content!="string")throw new Se;if(c.hash!==s.fileHash||c.content!==r.content)return ve(this,Ie,s),ve(this,fe,void 0),{ok:!1,conflict:{currentHash:c.hash,currentContent:c.content}}}return ve(this,Ie,s),ve(this,fe,void 0),n}catch(n){throw Ks(n)&&ve(this,fe,void 0),n}};function ti({sourcePath:e,cwd:t,loadedContent:r,documentId:n,documentSaveBinding:s,documentRecoveryBinding:o}){const c=oe(),a=(s==null?void 0:s.incarnation)??(o==null?void 0:o.incarnation),i=a?JSON.stringify([a.documentId,a.physicalOpenedAt,a.channelCreatedAt,a.generation]):void 0,d=p.useRef(new ei),u=p.useMemo(()=>({sourcePath:e,cwd:t,documentId:n,transport:c,birthKey:i}),[e,t,n,c,i]),f=p.useRef(null),l=p.useRef(null),m=p.useRef(Promise.resolve()),w=p.useCallback(()=>{var k;return((k=l.current)==null?void 0:k.identity)===u&&l.current.active},[u]);p.useLayoutEffect(()=>{var k;return((k=l.current)==null?void 0:k.identity)!==u?l.current={identity:u,baseHash:null,baseContent:r,active:!0,recoveryBinding:o,recoveryGate:o&&c.originalFileSaveRecovery?"pending":"unsupported"}:(l.current.active=!0,l.current.recoveryBinding=o),()=>{var y;((y=l.current)==null?void 0:y.identity)===u&&(l.current.active=!1)}},[u,r,o,c]);const[g,v]=p.useState({owner:u,status:"idle",conflict:null}),D=g.owner===u?g.status:"idle",N=g.owner===u?g.conflict:null,C=p.useCallback((k,y,P)=>{w()&&v(W=>({owner:u,status:k,documentReceipt:y,confirmedContent:P,conflict:W.owner===u?W.conflict:null}))},[u,w]),z=p.useCallback(k=>{w()&&v(y=>({owner:u,conflict:k,status:y.owner===u?y.status:"idle"}))},[u,w]),F=p.useCallback(()=>{var k,y;return((k=l.current)==null?void 0:k.recoveryGate)==="unsupported"||((y=l.current)==null?void 0:y.recoveryGate)==="observed_clear"},[]),G=p.useMemo(()=>{const k=()=>Ys({owner:u,getOwner:()=>l.current,readTail:()=>m.current,writeTail:y=>{m.current=y},transport:c,cwd:t,sourcePath:e,documentId:n,pending:()=>d.current.pending});return{identity:u,supported:!!c.originalFileSaveRecovery,current:()=>k().current(),discover:y=>k().discover(y),recover:y=>k().recover(y),inspectCurrent:()=>k().inspectCurrent()}},[u,c,t,e,n]),L=!!(e&&t),q=p.useCallback((k,y,P,W=!1)=>{const te=()=>w()&&l.current===k&&(!s||s.current());if(y.ok){if(typeof y.hash!="string"||!y.hash||y.effect!=="changed"&&y.effect!=="no_op")throw new Error("Invalid file save acknowledgement");return k.baseHash=y.hash,k.baseContent=P,!W&&!te()?{status:"idle"}:(W||(z(null),C("saved",d.current.receipt,P)),{status:y.effect,confirmed:{hash:y.hash,content:P}})}return!W&&!te()?{status:"idle"}:(W||(z(y.conflict),C("conflict")),{status:"conflict"})},[w,s,z,C]),U=p.useCallback(async(k,y)=>{if(!w())return{status:"idle"};const P=l.current;s&&!d.current.pending&&(f.current=u);const W=await d.current.write(c,t,e,k,y,s);return q(P,W,k)},[w,c,t,e,s,q,u]),Y=p.useCallback(k=>{var W;if(!L||!w())return Promise.resolve({status:"idle"});const y=((W=l.current.finalToken)==null?void 0:W.content)===k?l.current.finalToken:void 0,P=m.current.catch(()=>{}).then(async()=>{if(!w()||s&&!s.current())return{status:"idle"};if(d.current.pending)return C("uncertain"),{status:"uncertain"};if(!F())return C("error"),{status:"error"};l.current.finalToken===y&&(l.current.finalToken=void 0),C("saving");try{const te=l.current.baseHash!==null?{expectedHash:l.current.baseHash}:{expectedContent:l.current.baseContent};return await U(k,te)}catch(te){if(te instanceof Ge)return{status:"idle"};if(!w()||s&&!s.current())return{status:"idle"};const ue=d.current.pending?"uncertain":"error";return C(ue),{status:ue}}});return m.current=P.then(()=>{}),P},[L,U,w,C,s,F]),he=p.useCallback(k=>{if(!L||!w()||s&&!s.current())return null;const y=l.current,P={content:k,id:Symbol("buffered canvas draft")};return y.finalToken=P,{cancel(){y.finalToken===P&&(y.finalToken=void 0)},flush(){if(y.finalToken!==P||l.current!==y||y.active)return Promise.resolve({status:"idle"});y.finalToken=void 0;const W=m.current.catch(()=>{}).then(async()=>{if(l.current!==y||y.active)return{status:"idle"};try{if(y.recoveryGate!=="unsupported"&&y.recoveryGate!=="observed_clear")return{status:"error"};const te=y.baseHash!==null?{expectedHash:y.baseHash}:{expectedContent:y.baseContent};s&&!d.current.pending&&(f.current=u);const ue=await d.current.write(c,t,e,k,te,s,!0);return q(y,ue,k,!0)}catch{return{status:"error"}}});return m.current=W.then(()=>{}),W}}},[L,w,c,t,e,s,q,u]),j=p.useCallback(async k=>{const y=l.current;return!y||y.identity!==u?!1:(await m.current.catch(()=>{}),l.current===y&&!d.current.pending&&y.baseContent===k)},[u]),S=p.useCallback(()=>{if(!w()||!s||f.current!==u)return Promise.resolve({status:"idle"});const k=l.current,y=m.current.catch(()=>{}).then(async()=>{if(!w()||l.current!==k||f.current!==u)return{status:"idle"};try{C("saving");const P=await d.current.retry(c,s);return q(k,P.result,P.content)}catch(P){if(P instanceof Ge||!w()||l.current!==k)return{status:"idle"};const W=d.current.pending?"uncertain":"error";return C(W),{status:W}}});return m.current=y.then(()=>{}),y},[w,s,c,q,C,u]),x=p.useCallback(k=>{var te;if(!L||!N||!w())return Promise.resolve({status:"idle"});const y=N.currentHash,P=((te=l.current.finalToken)==null?void 0:te.content)===k?l.current.finalToken:void 0,W=m.current.catch(()=>{}).then(async()=>{if(!w()||s&&!s.current())return{status:"idle"};if(d.current.pending)return C("uncertain"),{status:"uncertain"};if(!F())return C("error"),{status:"error"};l.current.finalToken===P&&(l.current.finalToken=void 0),C("saving");try{return await U(k,{expectedHash:y})}catch(ue){if(ue instanceof Ge)return{status:"idle"};if(!w()||s&&!s.current())return{status:"idle"};const Ae=d.current.pending?"uncertain":"error";return C(Ae),{status:Ae}}});return m.current=W.then(()=>{}),W},[L,N,U,w,C,s,F]),A=p.useCallback(()=>{var k;return((k=l.current)==null?void 0:k.identity)===u?{hash:l.current.baseHash,content:l.current.baseContent}:{hash:null,content:r}},[u,r]),I=p.useCallback(()=>{if(!N||!w()||s&&!s.current())return null;l.current.finalToken=void 0;const k=N.currentContent;return l.current.baseHash=N.currentHash,l.current.baseContent=k,z(null),C("idle"),k},[N,w,z,C,s]);return{recovery:G,status:D,conflict:N,canSave:L,save:Y,overwrite:x,adoptDisk:I,getConfirmedBase:A,prepareFinalSave:he,retryUnconfirmed:S,waitForCloseDrain:j,documentReceipt:g.owner===u?g.documentReceipt:void 0,confirmedContent:g.owner===u?g.confirmedContent:void 0}}const ri=p.lazy(()=>Oe(()=>import("./BlintzCanvas-Dd3bC9vw.js").then(e=>e.B),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.BlintzCanvas}))),ni=500;function si(e){switch(e){case"saving":return"Saving…";case"saved":return"Saved";case"error":return"Couldn’t save";default:return null}}function ii({content:e,documentId:t,onContentChange:r}){const[n,s]=p.useState(!1),[o,c]=p.useState(e.content),a=V(x=>x.canvasSessionId),i=V(x=>x.setDocumentEditing),d=V(x=>{var A;return((A=x.openDocuments.find(I=>I.id===t))==null?void 0:A.editing)??!1}),u=V(x=>x.selectedCwd),f=n&&d,l=ti({documentId:t,sourcePath:e.sourcePath,cwd:u,loadedContent:e.content}),m=l.canSave,w=Js({cwd:u,sourcePath:m?e.sourcePath:null,content:o,saved:l.status==="saved"}),g=p.useRef(null),v=p.useRef(null),D=p.useRef(o),N=p.useRef(e),C=p.useRef(r),z=p.useRef(l.save),F=p.useRef(l.prepareFinalSave),G=p.useRef(null);p.useEffect(()=>{D.current=o,N.current=e,C.current=r,z.current=l.save,F.current=l.prepareFinalSave});const L=p.useCallback(x=>{V.getState().canvasSessionId===g.current&&(C.current({...N.current,content:x}),z.current(x))},[]),q=p.useCallback(x=>{var A;c(x),D.current=x,(A=G.current)==null||A.cancel(),G.current=F.current(x),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=null,L(x)},ni)},[L]),U=()=>{g.current=V.getState().canvasSessionId,c(e.content),s(!0),i(t,!0)},Y=()=>{v.current&&(clearTimeout(v.current),v.current=null,L(D.current)),s(!1),i(t,!1)};p.useEffect(()=>{var x;f&&a!==g.current&&(v.current&&(clearTimeout(v.current),v.current=null),(x=G.current)==null||x.cancel(),G.current=null,s(!1),i(t,!1))},[a,f,t,i]),p.useEffect(()=>{var x;!n||f||(v.current&&clearTimeout(v.current),v.current=null,(x=G.current)==null||x.cancel(),G.current=null)},[f,n]),p.useEffect(()=>()=>{var x,A;v.current&&(clearTimeout(v.current),v.current=null,V.getState().canvasSessionId===g.current&&C.current({...N.current,content:D.current})),V.getState().canvasSessionId===g.current?(x=G.current)==null||x.flush():(A=G.current)==null||A.cancel(),G.current=null,i(t,!1)},[L,t,i]);const he=()=>{const x=l.adoptDisk();x!=null&&(r({...e,content:x}),c(x))},j=()=>{l.overwrite(D.current)},S=si(l.status);return h.jsxs("div",{className:"relative flex h-full flex-col",children:[h.jsxs("div",{className:"sticky top-0 z-10 flex h-0 items-start justify-end gap-2 pr-2",children:[m&&S&&h.jsx("span",{className:"text-muted-foreground mt-3 text-xs","aria-live":"polite",children:S}),m&&h.jsx(rt,{type:"button",variant:"ghost",size:"icon-md",className:"text-muted-foreground hover:text-foreground mt-2",onClick:f?Y:U,"aria-label":f?"Finish editing":"Edit document",children:f?h.jsx(jr,{className:"size-4"}):h.jsx(Cr,{className:"size-4"})})]}),l.status==="conflict"&&h.jsxs("div",{className:"bg-destructive/10 text-destructive mx-2 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md px-3 py-2 text-sm",children:[h.jsx("span",{className:"flex-1",children:"This file changed on disk since you opened it."}),h.jsx(rt,{type:"button",variant:"ghost",size:"sm",className:"h-7",onClick:he,children:"Reload"}),h.jsx(rt,{type:"button",variant:"destructive",size:"sm",className:"h-7",onClick:j,children:"Overwrite"})]}),h.jsx("div",{className:"flex-1 px-2 pb-6",children:h.jsx(p.Suspense,{fallback:h.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading editor…"}),children:h.jsx(ri,{value:f?o:e.content,editable:f,onChange:f?q:void 0,wikiLinks:w})})})]})}function oi({content:e}){return h.jsx("div",{className:"p-4 font-mono text-sm",children:h.jsx(Tr,{value:e.data,depth:0})})}const ai=20;function Tr({value:e,depth:t,keyName:r}){const[n,s]=p.useState(t>2),o=p.useCallback(()=>s(u=>!u),[]);if(t>=ai)return h.jsx(Pe,{keyName:r,value:"[max depth]",className:"text-muted-foreground"});if(e===null)return h.jsx(Pe,{keyName:r,value:"null",className:"text-muted-foreground"});if(typeof e=="boolean")return h.jsx(Pe,{keyName:r,value:String(e),className:"text-blue-500"});if(typeof e=="number")return h.jsx(Pe,{keyName:r,value:String(e),className:"text-green-500"});if(typeof e=="string")return h.jsx(Pe,{keyName:r,value:`"${e}"`,className:"text-amber-500"});const c=Array.isArray(e),a=c?e.map((u,f)=>[String(f),u]):Object.entries(e),i=c?"[":"{",d=c?"]":"}";return h.jsxs("div",{style:{paddingLeft:t>0?16:0},children:[h.jsxs("button",{type:"button",className:"hover:bg-muted -ml-0.5 inline-flex items-center gap-0.5 rounded px-0.5 transition-colors duration-150",onClick:o,children:[h.jsx(_n,{className:Lt("size-3 transition-transform",!n&&"rotate-90")}),r!=null&&h.jsxs("span",{className:"text-foreground",children:[r,": "]}),h.jsxs("span",{className:"text-muted-foreground",children:[i,n&&` … ${a.length} items `,n&&d]})]}),!n&&h.jsxs(h.Fragment,{children:[a.map(([u,f])=>h.jsx(Tr,{keyName:c?void 0:u,value:f,depth:t+1},u)),h.jsx("div",{className:"text-muted-foreground",children:d})]})]})}function Pe({keyName:e,value:t,className:r}){return h.jsxs("div",{style:{paddingLeft:16},children:[e!=null&&h.jsxs("span",{className:"text-foreground",children:[e,": "]}),h.jsx("span",{className:r,children:t})]})}const ci=/^\/api\/rooms\/([A-Za-z0-9][A-Za-z0-9._-]*)\/canvas\/media\/([0-9a-f]{16}-[0-9a-f]{64}(?:\.[a-z0-9]{1,10})?)$/;function Ar(e,t){const r=ci.exec(e.trim());return r?t===void 0||r[1]===t:!1}const ui=new Set(["http:","https:"]);function li(e){const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||t[1].length===1?null:`${t[1].toLowerCase()}:`}const di={image:"data:image/",pdf:"data:application/pdf"};function zr(e,t,r){const n=e.trim();if(n.startsWith("data:"))return n.toLowerCase().startsWith(di[t])?{url:n,error:null}:{url:null,error:"unsupported-data"};if(Ar(n))return{url:n,error:null};const s=li(n);if(s!==null)return ui.has(s)?{url:n,error:null}:{url:null,error:"blocked"};const o=r(n);return o?{url:o,error:null}:{url:null,error:"local-unavailable"}}function Fr(e,t){switch(e){case"blocked":return`This ${t} source is blocked for safety.`;case"unsupported-data":return`This data URI isn’t a valid ${t} source.`;case"local-unavailable":return`Local ${t} files can’t be displayed here.`}}function fi({content:e}){const t=oe(),r=V(u=>u.selectedCwd),n=p.useMemo(()=>zr(e.src,"image",u=>t.mediaUrl(r??"",u)),[e.src,t,r]),[s,o]=p.useState("loading"),[c,a]=p.useState(e.src);c!==e.src&&(a(e.src),o("loading"));const i=e.alt??e.title??"Canvas image";if(n.url===null){const u=n.error?Fr(n.error,"image"):"";return h.jsx(pr,{children:u})}const d=n.url;return h.jsxs("div",{className:"bg-muted/40 relative flex h-full items-center justify-center",children:[s==="loading"&&h.jsx("p",{className:"text-muted-foreground absolute text-sm","aria-live":"polite",children:"Loading image…"}),s==="error"?h.jsx(pr,{children:"This image couldn’t be loaded."}):h.jsxs(Tn,{centerOnInit:!0,doubleClick:{mode:"toggle"},wheel:{step:.15},children:[h.jsx(hi,{}),h.jsx(An,{wrapperClass:"!h-full !w-full",contentClass:"!h-full !w-full flex items-center justify-center",children:h.jsx("img",{src:d,alt:i,onLoad:()=>o("loaded"),onError:()=>o("error"),className:Lt("max-h-full max-w-full object-contain transition-opacity",s==="loaded"?"opacity-100":"opacity-0")})})]})]})}function hi(){const{zoomIn:e,zoomOut:t,resetTransform:r}=zn();return h.jsxs("div",{className:"absolute top-2 right-2 z-10 flex gap-1",children:[h.jsx(yt,{label:"Zoom in",onClick:()=>e(),children:h.jsx(Bn,{className:"size-4"})}),h.jsx(yt,{label:"Zoom out",onClick:()=>t(),children:h.jsx(Un,{className:"size-4"})}),h.jsx(yt,{label:"Reset zoom",onClick:()=>r(),children:h.jsx(Pn,{className:"size-4"})})]})}function yt({label:e,onClick:t,children:r}){return h.jsx("button",{type:"button",onClick:t,"aria-label":e,className:"bg-background/80 text-muted-foreground hover:text-foreground focus-ring rounded-md border p-1.5 backdrop-blur transition-colors",children:r})}function pr({children:e}){return h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:e})})}function pi({content:e}){const t=oe(),r=Sn().data,n=V(i=>i.selectedCwd),s=p.useMemo(()=>zr(e.src,"pdf",i=>t.mediaUrl(n??"",i)),[e.src,t,n]);if(s.url===null){const i=s.error?Fr(s.error,"pdf"):"";return h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:i})})}const o=s.url,c=e.title??"PDF document",a=new URL(o,window.location.href).origin===window.location.origin;return a&&!r?null:a&&(r==null?void 0:r.serverRole)==="hub"?h.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[h.jsx("p",{children:"PDFs download here instead of opening."}),h.jsxs("a",{href:o,download:!0,className:"text-foreground focus-ring rounded-md underline underline-offset-4",children:["Download ",c]})]}):h.jsx("object",{data:o,type:"application/pdf",title:c,className:"h-full w-full",children:h.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[h.jsx("p",{children:"This PDF can’t be shown here."}),h.jsxs("a",{href:o,target:"_blank",rel:"noreferrer",className:"text-foreground focus-ring rounded-md underline underline-offset-4",children:["Open ",c," in a new tab"]})]})})}function mi(e){const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||t[1].length===1?null:`${t[1].toLowerCase()}:`}const gi=new Set(["http:","https:","data:"]);function Mr(e,t,r){const n=e.trim();if(Ar(n))return{url:n};const s=mi(n);return s!==null?gi.has(s)?s==="data:"&&r!==void 0?n.toLowerCase().startsWith(r)?{url:n}:{url:null}:{url:n}:{url:null}:{url:t(n)}}function vi({content:e}){const t=oe(),r=V(o=>o.selectedCwd),n=p.useMemo(()=>Mr(e.src,o=>t.mediaUrl(r??"",o),"data:audio/"),[e.src,t,r]),s=e.title??"Canvas audio";return n.url===null?h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:"This audio can’t be played here."})}):h.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center p-8",children:h.jsx("audio",{controls:!0,src:n.url,"aria-label":s,className:"w-full max-w-2xl",children:h.jsxs("p",{className:"text-muted-foreground text-sm",children:["Your browser can’t play this audio."," ",h.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",s]}),"."]})})})}function bi({content:e}){const t=oe(),r=V(o=>o.selectedCwd),n=p.useMemo(()=>Mr(e.src,o=>t.mediaUrl(r??"",o),"data:video/"),[e.src,t,r]),s=e.title??"Canvas video";return n.url===null?h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:"This video can’t be played here."})}):h.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center",children:h.jsx("video",{controls:!0,src:n.url,"aria-label":s,className:"max-h-full w-full max-w-full object-contain",children:h.jsxs("p",{className:"text-muted-foreground p-8 text-sm",children:["Your browser can’t play this video."," ",h.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",s]}),"."]})})})}function Lr({content:e,documentId:t,channel:r}){const[n]=Mt(),s=Fn(e.definition),o=p.useMemo(()=>JSON.stringify(e.definition),[e.definition]);return h.jsx("div",{className:"p-4",children:s.ok?h.jsx(Mn,{channel:r,document:s.document,sessionId:n??void 0},r?t??r.documentId:o):h.jsx(Ln,{error:s.error,raw:s.raw})})}class wi{constructor(){re(this,"contiguous",0);re(this,"through",0);re(this,"pending",new Map)}get highest(){return this.contiguous}get catchUpThrough(){return this.through}get pendingCount(){return this.pending.size}reset(){this.contiguous=0,this.through=0,this.pending.clear()}resetHighest(){this.contiguous=0}advance(t){this.contiguous=Math.max(this.contiguous,t)}markThrough(t){this.through=Math.max(this.through,t)}recordGap(t){return this.markThrough(t.docSeq),this.pending.set(t.docSeq,t),this.pending.size<=200?!1:(this.pending.clear(),!0)}takeNextContiguous(){for(const n of this.pending.keys())n<=this.contiguous&&this.pending.delete(n);const t=this.contiguous+1,r=this.pending.get(t);return r&&this.pending.delete(t),r}clearReachedTarget(){return this.contiguous<this.through?!1:(this.through=0,!0)}}const _t=new WeakMap,Qe=new WeakMap,ye=new WeakMap,He=new WeakMap;function Re(e){Ne(e);const t=_t.get(e);if(!t)throw new Error("Replay owner lifetime is absent.");return t}function xi(e,t){const r=Qe.get(t);if(!r||r.owner!==e)throw new Error("Replay run is foreign.");return r}function qr(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){for(const t of Object.values(e))qr(t);Object.freeze(e)}return e}function yi(e){if(Ne(e),_t.has(e))throw new Error("Replay owner lifetime is already initialized.");_t.set(e,new wi)}function Pt(e){const t=Re(e);return Object.freeze({highest:t.highest,through:t.catchUpThrough,pending:t.pendingCount})}function mr(e){Re(e).reset()}function gr(e,t){const r=Qe.get(t);if(!(!r||r.owner!==e))return Object.freeze({subject:r.subject,epoch:r.epoch,revision:r.revision,observation:r.observation,ended:r.ended})}function ki(e,t,r){const n=ye.get(r),s=Qe.get(t);if(!(!s||s.owner!==e||!n||n.owner!==e||n.run!==t||n.phase!=="consuming"||n.admissionRead||!ne(e,t)))return n.admissionRead=!0,Object.freeze({response:n.response,since:n.since,revision:n.revision,observation:n.observation,targetBirth:s.targetBirth})}function ji(e,t,r){const n=xi(e,t),s=ye.get(r),o=$r(e,t,r);if(!o||!s||s.owner!==e||s.run!==t||s.phase!=="consuming"||!s.admissionRead||n.ended||n.epoch!==o.epoch||n.subject!==o.previous)throw new Error("Replay own issuance is foreign or stale.");n.subject=o.subject}function Pr(e,t,r,n){if(!ne(e,t))return;if(n){const o=He.get(r);return o&&o.owner===e&&o.run===t&&o.phase==="dispatching"&&!o.advanced?o.frame:void 0}const s=ye.get(r);return s&&s.owner===e&&s.run===t&&s.phase==="frames"&&s.dispatching!==void 0&&!s.advanced?s.frames[s.dispatching]:void 0}function Ci(e,t,r,n){const s=Yi(e,t,r,n);if(!s||!ne(e,t))throw new Error("Replay cursor advance has no genuine core witness.");const o=n?He.get(r):ye.get(r);if(!o||o.advanced)throw new Error("Replay frame advance was consumed.");o.advanced=!0,Re(e).advance(s.docSeq)}function Ri(e,t){const r=Qe.get(t),n=(r==null?void 0:r.lastPage)&&ye.get(r.lastPage);if(!r||r.owner!==e||!ne(e,t)||r.target===void 0||!n||n.phase!=="finished"||n.next!==n.frames.length||n.response.events.length>=200&&Re(e).highest<r.target)return;const s=Re(e);return Object.freeze({highest:s.highest,through:s.catchUpThrough,target:r.target})}function Oi(e,t){const r=Xe(e,t);if(!r)throw new Error("Replay notice is foreign or stale.");const n=Re(e),s=r.notification;if(r.mode==="quarantine")n.markThrough(s.type==="canvas_channel_snapshot"?s.snapshot.highWatermark:s.docSeq),s.type!=="canvas_channel_snapshot"&&n.recordGap(s);else{if(r.mode==="gap"&&s.type!=="canvas_channel_snapshot")return n.recordGap(s);r.mode==="event"&&lo(e,t)}return!1}function Ei(e,t){const r=Xe(e,t);if(!r||r.mode!=="event"||r.notification.type==="canvas_channel_snapshot")throw new Error("Notice cursor advance is foreign.");Re(e).advance(r.notification.docSeq)}function _i(e){const t=le(e),r=Re(e),n=Object.freeze({}),s={owner:e,subject:t.subject,epoch:t.epoch,revision:t.revision,observation:t.observation,ended:!1,starting:r.highest,succeeded:!1};Qe.set(n,s),to(e,n);const o=()=>ne(e,n),c=()=>le(e).live?o()?void 0:"restart":"stop";return Object.freeze({async readPage(){if(!o())return null;const a=le(e),i=r.highest,d=pt(e),u=d.getCanvasChannel;if(!o())return null;const f=await u.call(d,t.documentId,{since:i,limit:200});if(!o())return null;const l=qr(Dn.parse(f));if(!o())return null;const m=Object.freeze({});return ye.set(m,{owner:e,run:n,response:l,since:i,revision:a.revision,observation:a.observation,phase:"read",admissionRead:!1,frames:[],next:0,advanced:!1}),m},consumePage(a){const i=ye.get(a);return!o()||!i||i.owner!==e||i.run!==n||i.phase!=="read"?{kind:"done"}:(i.phase="consuming",ro(e,n,a)!=="accepted"||!o()?(i.phase="finished",{kind:"done"}):(s.target??(s.target=i.response.highWatermark),s.targetBirth=i.response.incarnation,i.frames=Object.freeze(i.response.events.filter(u=>u.docSeq<=s.target)),i.phase="frames",s.lastPage=a,i.response.resetRequired&&r.advance(i.response.retentionFloor-1),{kind:"frames",count:i.frames.length}))},advancePageFrame(a,i){const d=ye.get(a);if(!o()||!d||d.owner!==e||d.run!==n||d.phase!=="frames"||i!==d.next||!d.frames[i])return!1;d.next=i+1,d.dispatching=i,d.advanced=!1;try{return br(e,n,a,!1)&&o()}finally{d.dispatching=void 0}},finishPage(a){const i=ye.get(a);if(!o()||!i||i.owner!==e||i.run!==n||i.phase!=="frames"||i.next!==i.frames.length||s.target===void 0)return"done";if(i.phase="finished",i.response.events.length<200||r.highest>=s.target)return r.advance(s.target),!o()||(wr(e,n),!o())||(s.succeeded=!0),"done";if(r.highest<=i.since)throw new Error("Document replay made no progress.");return"again"},failed(){o()&&no(e,n)},beginFinalization(){return c()??(s.succeeded?"drain":"stop")},takePending(){if(!o())return null;const a=r.takeNextContiguous();if(!a||!o())return null;const i=Object.freeze({});return He.set(i,{owner:e,run:n,frame:a,phase:"taken",advanced:!1}),i},advancePending(a){const i=He.get(a);if(!o()||!i||i.owner!==e||i.run!==n||i.phase!=="taken")return!1;i.phase="dispatching";try{return br(e,n,a,!0)&&o()}finally{i.phase="finished",He.delete(a)}},finishFinalization(){const a=c();if(a)return a;if(r.clearReachedTarget()){const i=c();if(i)return i;wr(e,n);const d=c();if(d)return d}if(r.pendingCount||r.catchUpThrough>r.highest){const i=le(e);if(r.highest>s.starting||i.revision>s.revision||i.observation>s.observation)return"restart";so(e,n)}return c()??"stop"},current:o,end:()=>{s.ended=!0}})}var ge,Dt,Ue;class St{constructor(){Le(this,ge);re(this,"current",null);re(this,"token",0);re(this,"retiring",!1);re(this,"subscribers",new Set);re(this,"resources",new Map);re(this,"doc",null);re(this,"docClaims",new WeakMap);re(this,"retiringDoc",!1);re(this,"docResources",new Map);re(this,"bindings",new WeakSet)}getCurrent(){return this.current}observeHostContext(t){if(this.retiring)return null;if(!t.transportOwner||typeof t.transportOwner!="object"||!Number.isSafeInteger(t.publisherEpoch)||t.publisherEpoch<0)throw new Error("Explicit transport owner and epoch required.");const r=["frame","documentId","resolvedSource","logicalUrl","reloadKey","sessionId","eligibility","exactOrigin","transportOwner","publisherEpoch"];if(r.some(s=>!Object.hasOwn(t,s))||typeof t.documentId!="string"||!t.documentId||typeof t.logicalUrl!="string"||typeof t.reloadKey!="string")throw new Error("Complete host context required.");const n=this.current;return n&&r.every(s=>Object.is(n[s],t[s]))?n:(this.retire(),this.current=Object.freeze({...t,token:this.token,loaded:!1}),this.current)}observeLoaded(t){return this.retiring||this.current!==t||!t.frame?null:(this.retire(),this.current=Object.freeze({...t,token:this.token,loaded:!0}),this.current)}retire(){if(this.retiring)return;const t=this.current;this.current=null;const r=this.doc;this.doc=null,this.token++,this.retiring=!0;const n=[...t?this.resources.get(t)??[]:[],...r?this.docResources.get(r)??[]:[],...this.subscribers];r&&this.docResources.delete(r),t&&this.resources.delete(t);try{for(const s of n)try{const o=s();o&&typeof o.then=="function"&&Promise.resolve(o).catch(()=>{})}catch{}}finally{this.retiring=!1}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}own(t,r){if(this.retiring||this.current!==t)throw new Error("Frame observation retired.");const n=this.resources.get(t)??new Set;return n.add(r),this.resources.set(t,n),()=>{n.delete(r)}}bindDoc(t,r,n){return be(this,ge,Dt).call(this,t,r,n)}acquireDoc(t,r,n){const s=be(this,ge,Dt).call(this,t,r,n),o=Object.freeze({});this.docClaims.set(s,o);let c=!1;return Object.freeze({binding:s,release:()=>{c||(c=!0,this.docClaims.get(s)===o&&(this.docClaims.delete(s),this.doc===s&&this.bindings.has(s)&&be(this,ge,Ue).call(this)))}})}disableDoc(){be(this,ge,Ue).call(this)}retireDoc(t){this.doc===t&&this.bindings.has(t)&&be(this,ge,Ue).call(this)}ownDoc(t,r){if(!this.isCurrent(t))throw new Error("Doc binding retired.");const n=this.docResources.get(t)??new Set;return n.add(r),this.docResources.set(t,n),()=>{n.delete(r)}}isCurrent(t){return!this.retiring&&!this.retiringDoc&&this.doc===t&&this.bindings.has(t)&&this.current===t.observation}}ge=new WeakSet,Dt=function(t,r,n){const s=this.doc,o=this.token,c=Zs(yr,r);if(!c)throw this.disableDoc(),new Error("Established server Doc birth required.");const a=c,i=t.exactOrigin,d=t.eligibility==="served-document"?i==="null":t.eligibility==="preview-listener"&&i!==null&&new URL(i).origin===i;if(!t.loaded||!t.frame||typeof t.frame.postMessage!="function"||!t.resolvedSource||!d||t.documentId!==a.documentId||!n||n.length>200)throw new Error("Loaded eligible frame and established Doc birth required.");if(this.retiring||this.retiringDoc||this.current!==t||this.doc!==s||this.token!==o)throw new Error("Frame observation retired during Doc admission.");if(this.doc){if(this.doc.observation!==t)throw new Error("Doc binding belongs to another host load.");if(J(this.doc.incarnation,a)&&this.doc.scope===n)return this.doc;throw this.retire(),new Error("Doc birth changed; a fresh host load is required.")}const u=Object.freeze({observation:t,incarnation:Object.freeze(a),scope:n});try{return this.doc=u,this.bindings.add(u),u}catch(f){throw this.doc===u&&be(this,ge,Ue).call(this),f}},Ue=function(){if(this.retiringDoc)return;const t=this.doc;this.doc=null,this.retiringDoc=!0;const r=[...t?this.docResources.get(t)??[]:[]];t&&this.docResources.delete(t);try{for(const n of r)try{const s=n();s&&typeof s.then=="function"&&Promise.resolve(s).catch(()=>{})}catch{}}finally{this.retiringDoc=!1}};function Si(e,t,r){if(!r||typeof r.captureOriginal!="function"||typeof r.submit!="function"||typeof r.inspect!="function"||typeof r.isCurrentOwner!="function"||r.owner!==t.observation.transportOwner||r.publisherEpoch!==t.observation.publisherEpoch)throw new Error("Explicit current transport submit and inspect ports required.");const{owner:n,publisherEpoch:s,isCurrentOwner:o,submit:c,inspect:a,captureOriginal:i}=r,d=Object.freeze({expectedGeneration:t.incarnation.generation}),u=()=>{try{return e.isCurrent(t)?o(n,s)===!0&&e.isCurrent(t):!1}catch{return!1}};if(!u())throw new Error("Doc binding unavailable.");const f=()=>{if(!u())throw new Error("Doc binding retired.")};return Object.freeze({binding:t,current:u,captureOriginal:l=>{f();const m=l.id;f();const w=l.bytes;f();const g=Reflect.apply(i,r,[Object.freeze({id:m,bytes:w})]);if(f(),!g)return null;const v=g.id;f();const D=g.bytes;f();const N=g.submit;f();const C=g.inspect;return f(),v!==m||D!==w||typeof N!="function"||typeof C!="function"?null:Object.freeze({id:m,bytes:w,submit:async z=>{f(),z.throwIfAborted();const F=await Reflect.apply(N,g,[z]);return f(),z.throwIfAborted(),F},inspect:async z=>{f(),z.throwIfAborted();const F=await Reflect.apply(C,g,[z]);return f(),z.throwIfAborted(),F}})},retireObservation:()=>{u()&&e.retire()},onRetire:l=>e.ownDoc(t,l),submit:(l,m)=>(f(),m.throwIfAborted(),c(l,d,m)),inspect:(l,m)=>(f(),m.throwIfAborted(),a(l,d,m))})}class Di{constructor(){re(this,"revision",0);re(this,"draining",!1);re(this,"cleanup");re(this,"subscribers",new Set);re(this,"retirements",new WeakMap)}captureRetirement(){const t=Object.freeze({}),r=++this.revision,n=this.cleanup;return this.cleanup=void 0,this.retirements.set(t,{revision:r,cleanup:n,callbacks:this.draining?[]:[...this.subscribers]}),t}drainRetirement(t){const r=this.retirements.get(t);if(!r)throw new Error("Frame resource retirement is foreign or consumed.");this.retirements.delete(t);const n=this.draining;this.draining=!0;try{this.drain(r.cleanup);for(const s of r.callbacks)this.drain(s)}finally{this.draining=n}}begin(){const t=this.captureRetirement(),r=this.revision;return this.drainRetirement(t),r}once(t,r,n){let s=!1;return()=>{if(s||(s=!0,!this.current(t)||!r()||!this.current(t)))return null;const o=n();return!this.current(t)||!r()||!this.current(t)?null:o}}drain(t){try{Promise.resolve(t==null?void 0:t()).catch(()=>{})}catch{}}current(t){return this.revision===t}install(t,r){return this.current(t)?(this.cleanup=r,!0):!1}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}}function Ii(e,t,r){const n=()=>e.current(t)&&r.current()===!0&&e.current(t),s=e.once(t,n,r.complete);return Object.freeze({completeLoad:()=>{const o=s();return!o||!n()||r.accept(o)!==!0||!n()?null:o}})}function Ni(e,t,r){const n=()=>e.current(t)&&r.current()===!0&&e.current(t);if(!n())return null;const s=r.acquire();if(!s)return null;let o=!1,c=null,a;try{const i=s.binding;if(n()&&r.bindingCurrent(i)===!0&&n()){const d=r.createPort(i);n()&&r.portCurrent(d)===!0&&n()&&e.install(t,s.release)&&(o=!0,c=d)}}catch(i){a={cause:i}}if(!o)try{s.release()}catch(i){a??(a={cause:i})}if(a)throw a.cause;return c}function Ti(e){const t=()=>Object.assign(new Error("Document actions are unavailable."),{status:409}),r=(s,o)=>{if(o.aborted||!e.current(s)||o.aborted)throw t()},n=(s,o)=>{const c=kr.parse(o);if(c.receipt.id!==s)throw new Error("Document receipt does not match this action.");return c};return Object.freeze({current:e.current,submit:async(s,o)=>{const c=ot.parse(JSON.parse(JSON.stringify(s))),a=c.id;r("submit",o);const i=await e.submit(c,o);r("read",o);const d=n(a,i);return r("read",o),d},inspect:async(s,o)=>{r("read",o);const c=await e.inspect(s,o);r("read",o);const a=n(s,c);return r("read",o),a},captureOriginal:s=>{const o=ot.parse(JSON.parse(JSON.stringify(s))),c=o.id,a=JSON.stringify(o);if(!e.current("submit"))return null;const i=e.capture(o,a);if(!i||!e.current("submit")||!i.current("submit"))return null;let d=!1;const u=f=>i.current(f)===!0;return Object.freeze({id:c,bytes:a,current:u,submit:async f=>{if(d||f.aborted||!u("submit"))throw t();d=!0;const l=await i.submit(JSON.parse(a),f);if(f.aborted||!u("read"))throw t();const m=n(c,l);if(f.aborted||!u("read"))throw t();return m},inspect:async f=>{if(f.aborted||!u("read"))throw t();const l=await i.inspect(c,f);if(f.aborted||!u("read"))throw t();const m=n(c,l);if(f.aborted||!u("read"))throw t();return m}})}})}function Ai(e){return Object.freeze({id:e.id,bytes:e.bytes,submit:async t=>{try{return{kind:"accepted",receipt:await e.submit(t)}}catch{return{kind:"uncertain"}}},inspect:async t=>{try{return{kind:"accepted",receipt:await e.inspect(t)}}catch{return{kind:"unknown"}}}})}function zi(e,t,r){const n=ot.parse(JSON.parse(e.bytes));if(n.id!==e.id||JSON.stringify(n)!==e.bytes||!r())return null;const s=t(n);return!r()||!s?null:Ai(s)}const Fi=St.prototype.acquireDoc,ut=new WeakMap,It=new WeakMap;function Mi(e,t){const r=pt(e),n=new WeakMap,s=(c,a)=>t.current(a)&&Ce(e,c,!0);return Object.freeze({prepareFrameLoad:(c,a)=>{var l;if(!(c instanceof St)||a.loaded)return null;const i=vr(e),d=i?(l=De(e,i))==null?void 0:l.httpBaseline:void 0,u=t.begin();if(!i||!d||!t.current(u)||!Ce(e,i,!0)||c.getCurrent()!==a||a.transportOwner!==r||!s(i,u))return null;let f=null;return Ii(t,u,{current:()=>{var m;return Ce(e,i,!0)&&((m=De(e,i))==null?void 0:m.httpBaseline)===d&&c.getCurrent()===(f??a)&&t.current(u)&&Ce(e,i,!0)},complete:()=>(f=c.observeLoaded(a),f),accept:m=>{var w,g;return!t.current(u)||!Ce(e,i,!0)||((w=De(e,i))==null?void 0:w.httpBaseline)!==d||c.getCurrent()!==m||!t.current(u)||!Ce(e,i,!0)||((g=De(e,i))==null?void 0:g.httpBaseline)!==d?!1:(n.set(m,{record:i,birth:d.birth}),!0)}})},subscribeInvalidation:c=>t.subscribe(c),attachFrame:(c,a)=>{if(!(c instanceof St))return null;const i=vr(e),d=t.begin();if(!i||!t.current(d)||!Ce(e,i,!0)||c.getCurrent()!==a||a.transportOwner!==r||!s(i,d))return null;const u=n.get(a);return!u||u.record!==i||!J(u.birth,De(e,i).birth)?null:Ni(t,d,{current:()=>s(i,d),acquire:()=>{const f=Fi.call(c,a,De(e,i).birth,De(e,i).birth.documentId);let l=!1,m=null,w;try{s(i,d)&&c.getCurrent()===a&&s(i,d)&&(m=Object.freeze({binding:f.binding,release:f.release}),l=!0)}catch(g){w={cause:g}}if(!l)try{f.release()}catch(g){w??(w={cause:g})}if(w)throw w.cause;return m},bindingCurrent:f=>c.isCurrent(f)&&s(i,d),createPort:f=>Si(c,f,{owner:r,publisherEpoch:a.publisherEpoch,isCurrentOwner:(l,m)=>l===r&&m===a.publisherEpoch&&t.current(d)&&Ce(e,i),captureOriginal:l=>zi(l,m=>{var w;return((w=eo(e,i))==null?void 0:w.captureOriginal(m))??null},()=>s(i,d)),submit:async()=>({kind:"terminal"}),inspect:async()=>({kind:"unknown"})}),portCurrent:f=>f.current()&&s(i,d)})}})}function Li(e){if(Ne(e),ut.has(e))throw new Error("Frame owner is already initialized.");const t=new Di,r=Mi(e,t);return ut.set(e,{frames:t,facade:r}),r}function qi(e){var t;return Ne(e),(t=ut.get(e))==null?void 0:t.facade}function We(e){Ne(e);const t=ut.get(e);if(!t)return;const r=Object.freeze({});return It.set(r,{owner:e,frames:t.frames,ticket:t.frames.captureRetirement()}),r}function $e(e,t){if(!t)return;const r=It.get(t);if(!r||r.owner!==e)throw new Error("Frame retirement is foreign or consumed.");It.delete(t),r.frames.drainRetirement(r.ticket)}function Br(e,t){const r=xe(e,t),n=Xi(e,t);if(!(!r||!n))return{owner:t,verified:r.verified,...Ti(n)}}function me(e,t){return{documentId:e,transport:t,events:[],available:!1}}function Pi(e,t,r,n,s,o){var i,d;const c=e.documentId===r&&e.transport===n?e:me(r,n);if(c.snapshot&&(t.highWatermark<c.snapshot.highWatermark||t.stateRev<c.snapshot.stateRev))return c;const a=new Map((((i=c.snapshot)==null?void 0:i.receipts)??[]).filter(u=>u.receipt.docSeq>=t.receiptRetentionFloor).map(u=>[u.receipt.id,u]));for(const u of t.receipts)a.set(u.receipt.id,u);return{...c,available:o,snapshot:{...t,...s?{}:{routing:(d=c.snapshot)==null?void 0:d.routing},receipts:[...a.values()].sort((u,f)=>f.receipt.docSeq-u.receipt.docSeq).slice(0,400)},events:t.resetRequired?c.events.filter(u=>u.docSeq>=t.retentionFloor):c.events}}function Bi(e){var r,n,s,o,c,a,i,d,u,f,l,m;const t=async()=>{throw Object.assign(new Error("Document actions are unavailable."),{status:409})};return{documentId:e.documentId,enabled:e.available&&((r=e.binding)==null?void 0:r.verified)===!0&&((s=(n=e.snapshot)==null?void 0:n.routing)==null?void 0:s.enabled)===!0,submissionOwner:(o=e.binding)==null?void 0:o.owner,current:((c=e.binding)==null?void 0:c.current)??(()=>!1),approvedEventTypes:e.available?((i=(a=e.snapshot)==null?void 0:a.routing)==null?void 0:i.approvedEventTypes)??[]:[],destinationLabel:e.available?((u=(d=e.snapshot)==null?void 0:d.routing)==null?void 0:u.destinationLabel)??"Actions unavailable":"Actions unavailable",...e.snapshot?{snapshot:e.snapshot}:{},submit:((f=e.binding)==null?void 0:f.submit)??t,inspect:((l=e.binding)==null?void 0:l.inspect)??t,captureOriginal:(m=e.binding)==null?void 0:m.captureOriginal}}function Ui(e,t,r){return!!(e&&t&&r.incarnation&&J(t,r.incarnation)&&(r.highWatermark<e.highWatermark||r.stateRev<e.stateRev))}function Ur(e,t,r,n){const s=e.documentId===r&&e.transport===n?e:me(r,n);return{...s,events:[...s.events,t].slice(-200)}}function Wi(e,t){if(e.incarnation&&(e.incarnation.documentId!==t||e.events.some(r=>r.documentId!==t||!r.incarnation||!J(e.incarnation,r.incarnation))))throw new Error("Document replay identity changed.")}const Nt=new WeakMap;function $i(e,t,r){const n=ki(e,t,r);if(n)return Nt.set(r,{owner:e,run:t,witness:n}),n}const Wr=new WeakMap,Ze=new WeakMap,Tt=new WeakMap,At=new WeakMap;function ke(e,t){Ne(e);const r=t??Ze.get(e),n=r&&Wr.get(r);return n&&n.owner===e&&Ze.get(e)===r&&n.active?n:void 0}function Z(e){return Ne(e),Ze.get(e)}function xe(e,t){const r=ke(e,t);return r?Object.freeze({birth:r.birth,httpBaseline:r.httpBaseline,snapshot:r.snapshot,verified:r.verified}):void 0}function Ve(e,t,r=!1){var o,c;const n=ke(e,t),s=le(e);return!!n&&s.live&&n.verified&&n.transport===pt(e)&&(!r||((c=(o=n.snapshot)==null?void 0:o.routing)==null?void 0:c.enabled)===!0)}function Gi(e){const t=ke(e);Ze.delete(e),t&&(t.active=!1,t.verified=!1)}function kt(e,t){const r=ke(e,t);r&&(r.verified=!1)}function Hi(e,t,r){const n=ke(e,r);return!n||!ne(e,t)?!1:(n.verified=!0,ne(e,t))}function Vi(e,t,r){const n=Nt.get(r);Nt.delete(r);const s=(n==null?void 0:n.owner)===e&&n.run===t?n.witness:void 0;if(!s||!ne(e,t))return!1;const o=s.response.incarnation;let c=ke(e);if(!c&&!o)return ne(e,t);if(!c&&o){const a=le(e),i=()=>{const w=le(e);return ne(e,t)&&w.epoch===a.epoch&&w.observation===a.observation&&Z(e)===a.subject},d=pt(e),u=d.ingestCanvasEvent;if(!i())return!1;const f=Function.prototype.bind.call(u,d),l=d.getCanvasEventReceipt;if(!i())return!1;const m=Function.prototype.bind.call(l,d);if(!i())return!1;c={owner:e,token:Object.freeze({}),birth:Object.freeze({...o}),active:!0,verified:!1,submit:f,inspect:m,transport:d},Wr.set(c.token,c),Ze.set(e,c.token),c.httpBaseline=Object.freeze({birth:c.birth,floor:s.response.receiptRetentionFloor}),Tt.set(r,Object.freeze({owner:e,run:t,epoch:a.epoch,previous:a.subject,subject:c.token}));try{ji(e,t,r)}catch(w){throw ke(e)===c&&ao(e,t,r),w}finally{Tt.delete(r)}if(!ne(e,t))return!1}else if(c){if(!o||!J(c.birth,o))return!1;c.httpBaseline=Object.freeze({birth:c.birth,floor:s.response.receiptRetentionFloor})}return ne(e,t)?(c&&(c.verified=co(e)||c.verified),!0):!1}function Bt(e,t,r){const n=Ut(e),s=n.subject,o=()=>Vr(e,n,r);if(!s||!Ve(e,s)){const i=We(e);$e(e,i)}if(!o())return;const c=s&&Br(e,s),a=qi(e);n.dispatch(i=>{var f;if(!o())return i;const d=((f=i.binding)==null?void 0:f.owner)===s?i:me(n.documentId,n.transport),u=typeof t=="function"?t(d):t;return o()?{...u,...u.snapshot?{snapshot:Object.freeze({...u.snapshot})}:{},binding:c,frameAdmission:a}:i})}function Ji(e,t,r,n,s){const o=Ut(e),c=ke(e);Vr(e,o,s)&&(c&&(c.snapshot=t),Bt(e,a=>Pi(a,t,o.documentId,o.transport,r,n),s))}function Zi(e,t,r,n){const s=Pr(e,t,r,n);if(!ne(e,t)||!s)return!1;if(s.docSeq<=Pt(e).highest)return ne(e,t);At.set(r,{owner:e,run:t,pending:n,frame:s});try{Ci(e,t,r,n)}finally{At.delete(r)}if(!ne(e,t))return!1;const o=Ut(e);return Bt(e,c=>Ur(c,s,o.documentId,o.transport),t),ne(e,t)}function Xi(e,t){const r=ke(e,t);if(!r)return;const n=le(e).documentId;return{current:s=>Ve(e,t,s==="submit"),submit:(s,o)=>r.submit(n,s,{expectedGeneration:r.birth.generation},o),inspect:(s,o)=>r.inspect(n,s,{expectedGeneration:r.birth.generation},o),capture:()=>{const s=r.httpBaseline;return!s||!Ve(e,t,!0)||!J(s.birth,r.birth)?null:Object.freeze({current:o=>Ve(e,t,o==="submit")&&(o==="read"||r.httpBaseline===s),submit:(o,c)=>r.submit(n,o,{expectedGeneration:s.birth.generation},c),inspect:(o,c)=>r.inspect(n,o,{expectedGeneration:s.birth.generation},c)})}}}function $r(e,t,r){const n=Tt.get(r),s=le(e);return n&&n.owner===e&&n.run===t&&s.epoch===n.epoch&&s.subject===n.subject&&s.live?n:void 0}function Yi(e,t,r,n){const s=At.get(r);return s&&s.owner===e&&s.run===t&&s.pending===n&&ne(e,t)?s.frame:void 0}const Gr=new WeakMap,lt=new WeakMap;function Qi(e){const t=lt.get(e);if(!t)throw new Error("Document construction ticket is foreign or consumed.");return lt.delete(e),t}function Ki(e,t,r){const n=Object.freeze({});lt.set(n,Object.freeze({documentId:e,transport:t,dispatch:r}));try{const s=uo(n);return Gr.set(n,s),n}finally{lt.delete(n)}}function ee(e){const t=Gr.get(e);if(!t)throw new Error("Document owner is foreign.");return t}function Ne(e){ee(e)}function le(e){return ee(e).facts()}function pt(e){return ee(e).transport()}function vr(e){return ee(e).subject()}function De(e,t){return ee(e).subjectFacts(t)}function Ce(e,t,r=!1){return ee(e).subjectCurrent(t,r)}function eo(e,t){return ee(e).binding(t)}function to(e,t){ee(e).reserve(t)}function ne(e,t){return ee(e).current(t)}function ro(e,t,r){return ee(e).admit(t,r)}function br(e,t,r,n){return ee(e).frame(t,r,n)}function wr(e,t){return ee(e).qualify(t)}function no(e,t){ee(e).failed(t)}function so(e,t){ee(e).unavailable(t)}function io(e,t){ee(e).start(t)}function oo(e){ee(e).dispose()}const Hr=new WeakMap;function Ut(e){const t=Object.freeze(ee(e).projection());return Hr.set(t,Object.freeze({custodyKey:e,capture:t})),t}function Vr(e,t,r){const n=Hr.get(t);return(n==null?void 0:n.custodyKey)===e&&n.capture===t&&ee(e).projectionCurrent(t.epoch,t.subject,r)}function ao(e,t,r){ee(e).abortAdmission(t,r)}function co(e){return ee(e).qualified()}const zt=new WeakMap;function uo(e){const{documentId:t,transport:r,dispatch:n}=Qi(e);let s,o=!1,c;const a={live:!0};let i=0,d,u,f=!1,l,m,w=0;const g=()=>a.live,v=()=>Gi(e);let D=0;const N=()=>Pt(e),C=j=>{const S=gr(e,j);return!!S&&!S.ended&&g()&&s===j&&S.epoch===i&&S.subject===Z(e)},z=(j=!1)=>{const S=We(e);v(),i++,s=void 0,j&&mr(e),$e(e,S)},F=(j,S)=>Bt(e,j,S),G=j=>{const S=Ri(e,j),x=Z(e),A=x&&xe(e,x);return!C(j)||!S||S.through>S.highest||!l||!A||!J(l,A.birth)||!Hi(e,j,x)?!1:(l=void 0,F(I=>({...I,available:!0}),j),C(j))},L=(j,S,x)=>{const A=Z(e),I=A&&xe(e,A),k=i,y=()=>g()&&k===i&&Z(e)===A&&(!x||C(x));if(!y()||Ui(I==null?void 0:I.snapshot,I==null?void 0:I.birth,j))return;const P=S?j.routing:u;j={...j,routing:P&&Object.freeze({enabled:P.enabled,destinationLabel:P.destinationLabel,approvedEventTypes:Object.freeze([...P.approvedEventTypes])})},S&&(u=j.routing),!A&&!j.incarnation&&(f=!0),y()&&Ji(e,j,S,l===void 0,x)},q=(j,S)=>{var ue;const x=$i(e,j,S);if(!C(j)||!x)return"discard";const A=x.response;Wi(A,t);const I=A.incarnation;if((Z(e)||l||m)&&!I)throw new Error("Document replay identity is unavailable.");if(m&&I&&!J(m,I))return z(!0),F(me(t,r)),"restart";const k=Z(e),y=(k&&((ue=xe(e,k))==null?void 0:ue.birth))??l;if(I&&(y&&!J(y,I)||!y&&f||x.targetBirth&&!J(x.targetBirth,I)))return l=I,f=!1,u=void 0,d=void 0,z(!0),F(me(t,r)),"restart";const{events:P,...W}=A,te=Z(e);return!te&&I&&(l=m??I),!Vi(e,j,S)||!C(j)?"discard":(!te&&I&&(m=void 0),L(W,x.revision===D,j),C(j)?"accepted":"discard")},U=(j,S,x)=>{var y;const A=Pr(e,j,S,x),I=Z(e),k=(I&&((y=xe(e,I))==null?void 0:y.birth))??l;return!C(j)||!A||A.documentId!==t||k&&(!A.incarnation||!J(k,A.incarnation))?!1:Zi(e,j,S,x)},Y=(j,S)=>{const x=Object.freeze({});zt.set(x,Object.freeze({owner:e,revision:D,observation:w,epoch:i,notification:j,mode:S}));try{return Oi(e,x)}finally{zt.delete(x)}},he=j=>{if(o||!g()||(o=!0,F(me(t,r)),!g()))return;const S=In(void 0,x=>{if(!g()||x.documentId!==t)return;const A=x.type==="canvas_channel_snapshot"?x.snapshot.incarnation:x.incarnation,I=Z(e);if(!I){if(l&&!m&&(!A||!J(l,A))||!A||A.documentId!==t)return;if(!m||!J(m,A)){const k=!!m||!!l;if(m=Object.freeze({...A}),w++,u=void 0,d=void 0,f=!1,k&&(z(!0),F(me(t,r))),!g()||!m||!J(m,A))return}Y(x,"quarantine"),g()&&j();return}if(l&&(!A||!J(l,A))){A&&j();return}if(A&&!J(xe(e,I).birth,A)){l=A,f=!1,u=void 0,d=void 0,z(!0),F(me(t,r)),g()&&j();return}if(A){if(d!==void 0&&d!==x.scope){const k=We(e);if(d=x.scope,kt(e,I),i++,s=void 0,D++,$e(e,k),Z(e)!==I||!g())return;F(y=>({...y,available:!1})),Z(e)===I&&g()&&j();return}d=x.scope,D++,x.type==="canvas_channel_snapshot"?L(x.snapshot,!0):x.docSeq>N().highest+1?(Y(x,"gap")&&g()&&F(y=>({...y,available:!1})),g()&&j()):Y(x,"event")}},r,()=>{if(!g())return;const x=We(e),A=Z(e);A&&kt(e,A),i++,s=void 0,D++,$e(e,x),F(I=>({...I,available:!1})),g()&&j()});g()?c=S:S(),g()&&j()};return Jr.set(e,j=>{const S=Xe(e,j);if(!S||S.notification.type==="canvas_channel_snapshot")return;const x=Z(e),A=i;!x||!S.notification.incarnation||!J(xe(e,x).birth,S.notification.incarnation)||(F(I=>Ur(I,S.notification,t,r)),!g()||A!==i||Z(e))}),{facts:()=>Object.freeze({documentId:t,live:g(),epoch:i,revision:D,observation:w,subject:Z(e)}),transport:()=>r,subject:()=>Z(e),subjectFacts:j=>xe(e,j),subjectCurrent:(j,S)=>Ve(e,j,S),binding:j=>Br(e,j),qualified:()=>l===void 0,projection:()=>({documentId:t,transport:r,dispatch:n,epoch:i,run:s,subject:Z(e)}),projectionCurrent:(j,S,x)=>g()&&j===i&&S===Z(e)&&(!x||s===x),abortAdmission:(j,S)=>{$r(e,j,S)&&z(!0)},reserve:j=>{const S=gr(e,j);if(!S||S.ended||!g()||S.epoch!==i||S.subject!==Z(e))throw new Error("Replay run is foreign or stale.");s=j},current:C,admit:q,frame:U,qualify:G,failed:j=>{if(!C(j))return;const S=Z(e);S&&kt(e,S),F(x=>({...x,available:!1}),j)},unavailable:j=>{C(j)&&F(S=>({...S,available:!1}),j)},start:he,dispose:()=>{if(!g())return;const j=We(e);a.live=!1,s=void 0;const S=c;c=void 0,v(),i++,mr(e);try{$e(e,j)}finally{S==null||S()}}}}function Xe(e,t){const r=zt.get(t),n=le(e);if(!(!r||r.owner!==e||!n.live||n.epoch!==r.epoch||n.revision!==r.revision||n.observation!==r.observation))return r}function lo(e,t){var a;const r=Xe(e,t);if(!r||r.notification.type==="canvas_channel_snapshot")return;const n=r.notification,o=le(e).subject,c=o&&xe(e,o);!c||!n.incarnation||!J(c.birth,n.incarnation)||n.docSeq<=Pt(e).highest||(Ei(e,t),!(!Xe(e,t)||le(e).subject!==o)&&((a=Jr.get(e))==null||a(t)))}const Jr=new WeakMap;function fo(e,t,r){const n=Ki(e,t,r);yi(n);const s=Li(n);return Object.freeze({beginRun:()=>_i(n),frameAdmission:s,start:o=>io(n,o),dispose:()=>oo(n)})}function ho(e,t){let r,n=0;const s=f=>{try{t==null||t(f)}catch{}},o=f=>{r===f&&(r=void 0)},c=(f,l)=>{f.settled||(f.settled=!0,r||s(!1),l?f.reject(l.cause):f.resolve())},a=()=>{u().catch(()=>{})},i=(f,l)=>{const m=()=>n===f.revision;if(!m())return;const w=l.beginFinalization();if(m()){if(w==="restart"){a();return}if(w==="drain")for(;m();){const g=l.drainOne();if(!m())return;if(g!=="again"){if(g==="restart")a();else if(g==="tail"){const v=l.finishFinalization();m()&&v==="restart"&&a()}return}}}},d=async f=>{let l,m;try{l=e();try{for(;await l.page()==="again";);}catch(w){l.failed(w)}}catch(w){m={cause:w}}finally{o(f);try{l&&i(f,l)}catch(w){m={cause:w}}finally{c(f,m)}}},u=()=>{if(r)return r.promise;let f,l;const m=new Promise((g,v)=>{f=g,l=v}),w={revision:++n,promise:m,resolve:f,reject:l,settled:!1};return r=w,s(!0),d(w),m};return Object.freeze({request:u})}function po(e,t,r,n){const s=fo(e,t,r);let o=!1;const c=ho(()=>{const a=s.beginRun();return{async page(){const i=await a.readPage();if(!i)return"done";const d=a.consumePage(i);if(d.kind!=="frames")return d.kind;for(let u=0;u<d.count;u++)if(!a.advancePageFrame(i,u))return"done";return a.finishPage(i)},failed:()=>a.failed(),beginFinalization:()=>{const i=a.beginFinalization();return i!=="drain"&&a.end(),i},drainOne(){if(!a.current())return a.end(),"stop";const i=a.takePending();return i?a.advancePending(i)?"again":(a.end(),"stop"):"tail"},finishFinalization:()=>{try{return a.finishFinalization()}finally{a.end()}}}},a=>{o||n==null||n(a)});return s.start(()=>{c.request().catch(()=>{})}),Object.freeze({dispose(){o=!0,s.dispose()}})}function mo(e){var d,u,f;const t=oe(),[r,n]=p.useState(()=>me(e,t)),[s,o]=p.useState({documentId:e,transport:t,pending:!0});p.useLayoutEffect(()=>{const l=po(e,t,n,m=>{o({documentId:e,transport:t,pending:m})});return()=>l.dispose()},[e,t]);const c=r.documentId===e&&r.transport===t?r:me(e,t),a=p.useMemo(()=>Bi(c),[c]),i=p.useMemo(()=>{var w;const l=(w=c.snapshot)==null?void 0:w.incarnation,m=c.binding;return l&&m?Object.freeze({incarnation:Object.freeze({...l}),current:()=>m.current("read")}):void 0},[(d=c.snapshot)==null?void 0:d.incarnation,c.binding]);return{channel:a,events:c.events,frameAdmission:c.frameAdmission,fileSaveBinding:i,fileSaveObservation:s.documentId!==e||s.transport!==t||s.pending?"pending":c.available&&((u=c.binding)!=null&&u.verified)&&((f=c.snapshot)!=null&&f.incarnation)?"ready":"unavailable"}}function go({content:e}){const[t]=Mt();return t?h.jsx("div",{className:"h-full w-full",children:h.jsx(qn,{sessionId:t,serverName:e.serverName,uri:e.uri,title:e.title})}):null}const vo=p.lazy(()=>Oe(()=>import("./CanvasFileContent-CVSfg4MO.js"),__vite__mapDeps([6,1,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])).then(e=>({default:e.CanvasFileContent}))),bo=p.lazy(()=>Oe(()=>import("./CanvasModel3dContent-CNmJsBTS.js"),__vite__mapDeps([23,1,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])).then(e=>({default:e.CanvasModel3dContent}))),wo=p.lazy(()=>Oe(()=>import("./CanvasCsvContent-B2S75f6B.js"),__vite__mapDeps([24,1,2,25,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])).then(e=>({default:e.CanvasCsvContent}))),xo=p.lazy(()=>Oe(()=>import("./index-p3WivF1M.js").then(e=>e.vo),__vite__mapDeps([1,2])).then(e=>({default:e.CanvasDiffContent})));function Lo({documentId:e,widgetChannel:t,content:r,onContentChange:n}){switch(r.type){case"url":case"browser":return h.jsx(_s,{documentId:e,content:r},`${e}:${r.url}`);case"markdown":return h.jsx(ii,{documentId:e,content:r,onContentChange:n},r.sourcePath??"generated");case"json":return h.jsx(oi,{content:r});case"image":return h.jsx(fi,{content:r});case"pdf":return h.jsx(pi,{content:r});case"audio":return h.jsx(vi,{content:r});case"video":return h.jsx(bi,{content:r});case"widget":return t?h.jsx(Lr,{content:r,documentId:e,channel:t}):h.jsx(yo,{documentId:e,content:r});case"mcp_app":return h.jsx(go,{content:r});case"file":return h.jsx(p.Suspense,{fallback:h.jsx(tt,{}),children:h.jsx(vo,{documentId:e,content:r})});case"model3d":return h.jsx(p.Suspense,{fallback:h.jsx(tt,{}),children:h.jsx(bo,{content:r})});case"csv":return h.jsx(p.Suspense,{fallback:h.jsx(tt,{}),children:h.jsx(wo,{content:r})});case"diff":return h.jsx(p.Suspense,{fallback:h.jsx(tt,{}),children:h.jsx(xo,{documentId:e,content:r},r.sourcePath)})}}function tt(){return h.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"})}function yo({documentId:e,content:t}){const{channel:r}=mo(e);return h.jsx(Lr,{documentId:e,content:t,channel:r})}const ko=p.lazy(()=>Oe(()=>import("./BlintzCanvas-Dd3bC9vw.js").then(e=>e.B),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.BlintzCanvas})));function qo({roomId:e,document:t,content:r,onSave:n}){const[s,o]=p.useState(null),[c,a]=p.useState(!1),[i,d]=p.useState(null),u=s!==null,f=r.sourcePath===void 0;ls(e,u?t.id:null);const l=async()=>{if(s===null)return;if(s===r.content){o(null),d(null);return}a(!0),d(null);const m=await n(t.id,{...r,content:s});a(!1),m?o(null):d("Couldn’t save. Your words are still here. Try again.")};return h.jsxs("div",{className:"flex h-full flex-col",children:[f&&h.jsxs("div",{className:"flex items-center justify-end gap-2 border-b px-2 py-1",children:[u&&h.jsx("span",{className:"text-muted-foreground text-xs",children:c?"Saving…":"Everyone sees your save."}),h.jsx(rt,{type:"button",size:"xs",variant:"ghost",disabled:c,"aria-label":u?"Save for the room":"Edit this document",onClick:()=>u?void l():o(r.content),children:u?h.jsx(jr,{className:"size-3.5"}):h.jsx(Cr,{className:"size-3.5"})})]}),i!==null&&h.jsx("p",{role:"status",className:"text-destructive border-b px-2 py-1 text-xs",children:i}),h.jsx("div",{className:"flex-1 px-2 pb-6",children:h.jsx(p.Suspense,{fallback:h.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"}),children:h.jsx(ko,{value:s??r.content,editable:u,onChange:o},u?"editing":`rev-${t.rev}`)})})]})}const Ft="dorkos-canvas-sessions",jo=1440*60*60*1e3;function Zr(){try{const e=localStorage.getItem(Ft);if(!e)return null;const t=JSON.parse(e);return t===null||typeof t!="object"?null:t}catch{return null}}function Xr(e){try{Object.keys(e).length===0?localStorage.removeItem(Ft):localStorage.setItem(Ft,JSON.stringify(e))}catch{}}function Co(e){return Array.isArray(e.documents)?[...e.documents].sort((t,r)=>(t.openedAt??0)-(r.openedAt??0)).map(t=>t.content).filter(t=>!!t):e.content?[e.content]:[]}function dt(e){return e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?`[${e.map(dt).join(",")}]`:`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${JSON.stringify(r)}:${dt(n)}`).join(",")}}`}function Ro(e,t){const r=new Set,n=new Map;for(const o of e){const c=er(o.content);if(c!==null){r.add(c);continue}const a=dt(o.content);n.set(a,(n.get(a)??0)+1)}const s=[];for(const o of t){const c=er(o);if(c!==null){r.has(c)||s.push(o);continue}const a=dt(o),i=n.get(a)??0;i>0?n.set(a,i-1):s.push(o)}return s}const st=new Set;function Po(){st.clear()}function Bo(e,t={}){const r=oe(),n=t.canonical??!0;p.useEffect(()=>{e&&V.getState().loadCanvasForSession(e)},[e]),p.useEffect(()=>{if(!e||!n||st.has(e))return;const s=Zr();if(!s)return;const o=s[e];if(!o){Oo(s);return}st.add(e),(async()=>{try{const c=Co(o),a=Ro(await r.listSessionCanvas(e),c);if(a.length===0){xr(e);return}for(const i of a)await r.openSessionCanvasDocument(e,i);xr(e),V.getState().hydrateCanvasFromSnapshot(e,await r.listSessionCanvas(e))}catch{st.delete(e)}})()},[e,n,r])}function xr(e){const t=Zr();if(!t)return;const{[e]:r,...n}=t;Xr(n)}function Oo(e){const t=Date.now()-jo,r=Object.entries(e).filter(([,n])=>n.accessedAt===void 0||n.accessedAt>=t);r.length!==Object.keys(e).length&&Xr(Object.fromEntries(r))}export{Lo as C,Fo as F,qo as R,Js as a,mo as b,us as c,cs as d,Mo as e,Lr as f,Po as g,ss as h,Ar as i,Bo as j,Mr as r,ti as u};
26
+ ${s}`:null,[u,f]=p.useState(null);return p.useLayoutEffect(()=>{if(d===null||i===null)return;const l=JSON.parse(i);let m=!0,w=0;const g=new WeakSet,v=D=>{const N=D.target;if(N===null||N!==e.current)return;const C=++w;if(g.has(N)){f(null);return}g.add(N),c.current.getFrameBridgeStatus(l).then(z=>{!m||C!==w||f(z.bridge==="refused"&&z.reason?{pageKey:d,reason:z.reason}:null)},()=>{})};return document.addEventListener("load",v,!0),()=>{m=!1,document.removeEventListener("load",v,!0)}},[d,i,e]),u!==null&&u.pageKey===d?u.reason:null}const as=15e3;function cs(e){const t=e instanceof Error?e.message.trim():"";return t.length>0?t:"Couldn’t reach DorkOS. Check your network and try again."}function us(e){const t=oe();return{open:p.useCallback(async r=>{await t.openRoomCanvasDocument(e,r)},[t,e]),update:p.useCallback(async(r,n)=>{await t.updateRoomCanvasDocument(e,r,{content:n})},[t,e]),pin:p.useCallback(async(r,n)=>{await t.updateRoomCanvasDocument(e,r,{pinned:n})},[t,e]),close:p.useCallback(async r=>{await t.closeRoomCanvasDocument(e,r)},[t,e])}}function ls(e,t){const r=oe(),n=V(s=>s.setRoomCanvasEditing);p.useEffect(()=>{if(n(e,t),t===null)return;const s=c=>{r.setRoomCanvasEditing(e,t,c).catch(a=>{console.warn("[room-canvas] edit lock failed",{roomId:e,documentId:t,err:a})})};s(!0);const o=setInterval(()=>s(!0),as);return()=>{clearInterval(o),s(!1),n(e,null)}},[r,e,t,n])}const ds=400;function Mo(e,t){const r=oe(),n=V(s=>s.roomCanvasPresenceEpoch[e]??0);p.useEffect(()=>{const s=a=>{r.setRoomCanvasViewing(e,a).catch(i=>{console.warn("[room-canvas] could not say where we are looking",{roomId:e,err:i})})};let o=!1;const c=setTimeout(()=>{o=!0,s(t)},ds);return()=>{clearTimeout(c),o&&s(null)}},[r,e,t,n])}const fs="allow-scripts allow-forms allow-popups allow-modals",wt="allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-downloads",hs=new Set(["javascript:","data:","blob:"]),ps=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","::1"]);function qt(e){return ps.has(e)||e.endsWith(".localhost")}function ms(e){return qt(e)?"direct":"server"}function gs(e,t){let r;try{r=new URL(e)}catch{return null}const n=r.searchParams.get(sr),s=new URL(r.origin),o=t.indexOf("?");return s.pathname=(o===-1?t:t.slice(0,o))||"/",s.search=o===-1?"":t.slice(o),n!==null&&s.searchParams.set(sr,n),s.toString()}const sr="__dorkos_preview",vs="/__dorkos_preview/health";function bs(e){return e==="https:"?443:80}function Dr(e){let t;try{t=new URL(e)}catch{return{mode:"serve",path:e}}if(hs.has(t.protocol))return{mode:"blocked"};if(t.protocol==="file:")return{mode:"serve",path:decodeURIComponent(t.pathname)};if(t.protocol==="http:"||t.protocol==="https:"){if(qt(t.hostname)){const r=t.port?Number(t.port):bs(t.protocol);return{mode:"proxy",hostname:t.hostname,port:r,path:`${t.pathname}${t.search}`}}return{mode:"external",url:e}}return{mode:"blocked"}}function ws(e){const t=e.trim();if(t===""||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const r=t.split("/")[0];if(t.includes("/")&&!r.includes(".")&&!r.includes(":"))return t;const s=r.split(":")[0];return`${qt(s)?"http":"https"}://${t}`}function xs(e){const t=Dr(e);if(t.mode==="serve")return{kind:"local",path:t.path};if(t.mode==="blocked")return{kind:"raw",text:e};try{const r=new URL(e),n=r.host.replace(/^www\./,""),s=r.pathname==="/"&&r.search===""&&r.hash===""?"":`${r.pathname}${r.search}${r.hash}`;return{kind:"url",host:n,rest:s}}catch{return{kind:"raw",text:e}}}const ys=2e3;async function ir(e,t=globalThis.fetch,r=ys){const n=new AbortController,s=setTimeout(()=>n.abort(),r);try{return await t(e,{mode:"no-cors",cache:"no-store",signal:n.signal}),!0}catch{return n.signal.aborted}finally{clearTimeout(s)}}function ks({target:e,currentUrl:t,strategy:r,cwd:n,reloadNonce:s}){const o=JSON.stringify([t,r,n,s]),[c,a]=p.useState(null),[i,d]=p.useState(null),[u,f]=p.useState(null),l=oe(),m=p.useRef(l);return p.useEffect(()=>{m.current=l}),p.useEffect(()=>{const w=m.current;let g=!1;const v=z=>{a(o),d(z)};async function D(z){if(n===null){f({kind:"no-session"});return}try{const F=await w.createServeUrl(n,z);if(g)return;F===null?f({kind:"unsupported"}):v({src:F,sandbox:fs,previewOrigin:null,bridgeEligibility:"served-document"})}catch{g||f({kind:"failed"})}}async function N(z,F){let G;try{const q=await w.probeLoopbackPort(z);G=q===null?"unknown":q.listening}catch{G="unknown"}if(g)return;let L=null;if(G!==!1){let q=null;try{q=await w.createProxyUrl(z)}catch{if(g)return;L={kind:"failed"}}if(g)return;if((q==null?void 0:q.unavailable)==="tunnel"){f({kind:"tunnel"});return}if((q==null?void 0:q.unavailable)==="no-port"&&(L={kind:"no-port"}),q!=null&&q.url){const U=new URL(q.url);if(await ir(`${U.origin}${vs}`)){if(g)return;const Y=gs(q.url,F);if(Y!==null){v({src:Y,sandbox:wt,previewOrigin:U.origin,bridgeEligibility:"preview-listener"});return}}if(g)return;L={kind:"origin-unreachable",host:U.hostname,listenPort:U.port}}}if(r==="direct"&&await ir(t)){if(g)return;v({src:t,sandbox:wt,previewOrigin:null,bridgeEligibility:null});return}g||f(L??{kind:"no-upstream"})}async function C(){if(f(null),d(null),e.mode!=="blocked"){if(e.mode==="external"){v({src:e.url,sandbox:wt,previewOrigin:null,bridgeEligibility:null});return}return e.mode==="serve"?D(e.path):N(e.port,e.path)}}return C(),()=>{g=!0}},[e,t,r,n,s,o]),{resolved:c===o?i:null,resolveError:u}}const js=ln/(1024*1024),Cs={csp:"This page’s security policy blocks added scripts, so it can’t talk to its agent.",encoding:"This page isn’t saved as UTF-8, so it can’t talk to its agent.",oversize:`This page is over ${js} MB, so it can’t talk to its agent.`,"no-head":"This page has no <head> tag, so it can’t talk to its agent.",markup:"DorkOS can’t safely read this page’s <head>, so it can’t talk to its agent.","fixed-source":"DorkOS couldn’t connect this page to its agent."};function Os({reason:e}){return h.jsx("p",{role:"status","data-bridge-refusal":e,className:"text-muted-foreground border-border/60 border-b px-2 py-1 text-xs",children:Cs[e]})}const Rs=1e4;function Es(e,t){if(e&&e.contentUrl===t&&e.stack.length>0){const r=Math.min(Math.max(e.cursor,0),e.stack.length-1);return{stack:e.stack,cursor:r}}return{stack:[t],cursor:0}}function _s({documentId:e,content:t}){const r=V(I=>I.selectedCwd),n=V(I=>I.writeBrowserHistory),[s]=p.useState(()=>Es(V.getState().browserHistories[e],t.url)),[o,c]=p.useState(s.stack),[a,i]=p.useState(s.cursor),[d,u]=p.useState(0);p.useEffect(()=>{n(e,{contentUrl:t.url,stack:o,cursor:a})},[e,t.url,o,a,n]);const f=o[a],l=p.useMemo(()=>Dr(f),[f]),m=p.useMemo(()=>l.mode==="proxy"?ms(window.location.hostname):null,[l]),w=p.useRef(null),{resolved:g,resolveError:v}=ks({target:l,currentUrl:f,strategy:m,cwd:r,reloadNonce:d}),{resourceErrorCount:D,notePersonNavigated:N,noteFrameLoaded:C}=ss({iframeRef:w,documentId:e,logicalUrl:f,reloadNonce:d,previewOrigin:(g==null?void 0:g.previewOrigin)??null,bridgeEligibility:(g==null?void 0:g.bridgeEligibility)??null,resolvedSource:(g==null?void 0:g.src)??null}),z=os({iframeRef:w,target:l,cwd:r,resolved:g,reloadNonce:d}),F=V(I=>I.roomCanvasLiveRoomId),{open:G}=us(F??""),[L,q]=p.useState(null),U=p.useCallback(I=>{c(k=>[...k.slice(0,a+1),I]),i(k=>k+1)},[a]),Y=dn(F),he=V(I=>F?I.roomCanvasEditing[F]??null:null);p.useEffect(()=>{if(Y===null||he!==null||Y.documentId!==e)return;const I=Y.url;I===void 0||I===f||U(I)},[Y,he,e,f,U]);const j=a>0,S=a<o.length-1,x=p.useCallback(I=>{const k=ws(I);if(!k||k===f){N(),u(y=>y+1);return}if(F){q(null),G({type:"browser",url:k}).catch(y=>{q({url:k,message:cs(y)})});return}N(),U(k)},[f,U,F,G,N]),A=()=>gn(f);return h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsxs("div",{className:"border-border/60 flex shrink-0 flex-wrap items-center gap-1 border-b px-2 py-1 lg:h-9 lg:flex-nowrap lg:py-0",children:[h.jsx(et,{label:"Back",disabled:!j,onClick:()=>i(I=>I-1),children:h.jsx(fn,{className:"size-4"})}),h.jsx(et,{label:"Forward",disabled:!S,onClick:()=>i(I=>I+1),children:h.jsx(hn,{className:"size-4"})}),h.jsx(et,{label:"Reload",onClick:()=>u(I=>I+1),children:h.jsx(Nn,{className:"size-4"})}),h.jsx("div",{className:"order-first flex w-full min-w-0 lg:order-none lg:w-auto lg:flex-1",children:h.jsx(Ss,{url:(L==null?void 0:L.url)??f,startEditing:L!==null,onSubmit:x},L===null?"address":`retry:${L.url}`)}),h.jsx(et,{label:"Open in system browser",onClick:A,children:h.jsx(pn,{className:"size-4"})})]}),L!==null&&h.jsx("p",{role:"status",className:"text-destructive border-border/60 border-b px-2 py-1 text-xs",children:L.message}),z!==null&&h.jsx(Os,{reason:z}),h.jsx(Ts,{target:l,resolved:g,resolveError:v,reloadNonce:d,resourceErrorCount:D,title:t.title??"Embedded browser",onOpenExternally:A,onReload:()=>{N(),u(I=>I+1)},iframeRef:w,onFrameLoad:C})]})}function Ss({url:e,startEditing:t=!1,onSubmit:r}){const[n,s]=p.useState(t),[o,c]=p.useState(e);if(!n)return h.jsx(Is,{url:e,onActivate:()=>{c(e),s(!0)}});const a=i=>{i.preventDefault(),s(!1),r(o)};return h.jsx("form",{onSubmit:a,className:"min-w-0 flex-1",children:h.jsx(mn,{"aria-label":"Address",autoFocus:!0,value:o,onChange:i=>c(i.target.value),onFocus:i=>i.currentTarget.select(),onBlur:()=>s(!1),onKeyDown:i=>{i.key==="Escape"&&(i.preventDefault(),s(!1))},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:"h-11 w-full text-base lg:h-7 lg:text-sm"})})}function Ds(e){return e.kind==="local"?e.path:e.kind==="url"?`${e.host}${e.rest}`:e.text}function Is({url:e,onActivate:t}){const r=p.useMemo(()=>xs(e),[e]);return h.jsxs("button",{type:"button","aria-label":`Address: ${Ds(r)}`,onClick:t,className:"text-muted-foreground hover:bg-muted focus-ring flex h-11 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 text-left text-sm transition-colors lg:h-7",children:[r.kind==="local"&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"bg-muted-foreground/15 text-3xs rounded px-1 py-0.5 font-medium tracking-wide uppercase",children:"local"}),h.jsx("span",{className:"text-foreground truncate",children:r.path})]}),r.kind==="url"&&h.jsxs("span",{className:"truncate",children:[h.jsx("span",{className:"text-foreground",children:r.host}),h.jsx("span",{className:"text-muted-foreground",children:r.rest})]}),r.kind==="raw"&&h.jsx("span",{className:"truncate",children:r.text})]})}function Ns(e,t){switch(e.kind){case"no-session":return"Open a chat to preview local files.";case"unsupported":return"Local previews aren’t available in this environment.";case"failed":return"Couldn’t load this preview. Reload, or open the app in your browser.";case"tunnel":return"Dev server previews don’t work remotely. Open DorkOS on the computer running it.";case"no-port":return"All preview ports are in use. Close a preview, then reload.";case"origin-unreachable":return`This view can’t reach port ${e.listenPort} on ${e.host}. Open DorkOS on the computer running it.`;case"no-upstream":return`Nothing is listening on ${t.mode==="proxy"?`${t.hostname}:${t.port}`:"that address"}. Start the dev server, then reload.`}}function Ts({target:e,resolved:t,resolveError:r,reloadNonce:n,resourceErrorCount:s,title:o,onOpenExternally:c,onReload:a,iframeRef:i,onFrameLoad:d}){if(e.mode==="blocked")return h.jsx(xt,{children:"This address is blocked for safety."});if(r!==null)return h.jsxs(xt,{children:[h.jsx("p",{children:Ns(r,e)}),r.kind!=="no-session"&&r.kind!=="unsupported"&&h.jsx("button",{type:"button",onClick:a,className:"text-foreground mt-3 hover:underline",children:"Reload"})]});if(t===null)return h.jsx(xt,{children:"Loading…"});const u=e.mode==="external";return h.jsx(As,{src:t.src,sandbox:t.sandbox,title:o,iframeRef:i,onFrameLoad:d,watchLoadDeadline:!u,resourceErrorCount:s,showEmbedFallback:u,onOpenExternally:c,onReload:a},`${t.src}:${n}`)}function As({src:e,sandbox:t,title:r,iframeRef:n,onFrameLoad:s,watchLoadDeadline:o,resourceErrorCount:c,showEmbedFallback:a,onOpenExternally:i,onReload:d}){const[u,f]=p.useState(!1),[l,m]=p.useState(!1);return p.useEffect(()=>{if(!o)return;const w=setTimeout(()=>m(!0),Rs);return()=>clearTimeout(w)},[o]),h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[l&&!u&&h.jsx(or,{onOpenExternally:i,onReload:d,children:"This preview is slow to load."}),c>0&&h.jsxs(or,{onOpenExternally:i,children:["This page hit ",c===1e4?"at least 10,000":c," ",c===1?"error":"errors"," while loading."]}),h.jsx("iframe",{ref:n,src:e,sandbox:t,onLoad:()=>{f(!0),s()},className:"min-h-0 w-full flex-1 border-0",title:r}),a&&h.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-t px-3 py-1.5 text-xs",children:[h.jsx("span",{children:"This site can’t always be embedded here."}),h.jsx("button",{type:"button",onClick:i,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function or({children:e,onOpenExternally:t,onReload:r}){return h.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-b px-3 py-1.5 text-xs",children:[h.jsx("span",{children:e}),h.jsxs("span",{className:"flex shrink-0 items-center gap-3",children:[r&&h.jsx("button",{type:"button",onClick:r,className:"text-foreground hover:underline",children:"Reload"}),h.jsx("button",{type:"button",onClick:t,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function et({label:e,disabled:t,onClick:r,children:n}){return h.jsx("button",{type:"button","aria-label":e,disabled:t,onClick:r,className:Lt("text-muted-foreground hover:text-foreground hover:bg-muted focus-ring flex size-11 shrink-0 items-center justify-center rounded-md transition-colors lg:size-7",t&&"pointer-events-none opacity-40"),children:n})}function xt({children:e}){return h.jsx("div",{className:"text-muted-foreground flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center",children:e})}const zs=4096;function Fs(e){return e.toLowerCase().endsWith(".md")?e.slice(0,-3):e}function Ms(e){const t=e.trim(),r=/^(["'])(.*)\1$/.exec(t);return r?r[2].trim():/^[|>][+-]?\d*$/.test(t)?"":t.replace(/\s+#.*$/,"").trim()}function Ls(e,t){var o;const r=e.replace(/^\uFEFF/,"").split(/\r?\n/);let n=0;if(r[0]==="---"){for(n=1;n<r.length;n+=1){const c=r[n];if(c==="---"||c==="...")break;const a=/^title:(.*)$/.exec(c);if(a){const i=Ms(a[1]);if(i!=="")return i}}n+=1}let s=null;for(;n<r.length;n+=1){const c=r[n],a=(o=/^ {0,3}(`{3,}|~{3,})/.exec(c))==null?void 0:o[1];if(a){s===null?s=a[0]:a[0]===s&&(s=null);continue}if(s!==null)continue;const i=/^ {0,3}#[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/.exec(c);if(i&&i[1].trim()!=="")return i[1].trim()}return Fs(t)}function qs(e,t,r=zs){let n=new TextDecoder().decode(e.subarray(0,r));return e.length>=r&&(n=n.slice(0,Math.max(0,n.lastIndexOf(`
27
+ `)))),Ls(n,t)}function Ps(e,t){return qs(new TextEncoder().encode(e),t)}const Ir=Z({path:ce().min(1),title:ce(),slug:ce()});Z({root:ce(),docs:jt(Ir),truncated:it()});Z({cwd:ce().min(1)});Z({cwd:ce().min(1),target:ce().min(1).max(1e3),from:ce().min(1).optional()});Z({doc:Ir.nullable(),complete:it()});const Rt=".md";function we(e){return e.normalize("NFC").trim().toLowerCase()}function Nr(e){return we(e).replace(/\s+/g,"-")}function qe(e){return e.toLowerCase().endsWith(Rt)?e.slice(0,-Rt.length):e}function ar(e){return e.slice(e.lastIndexOf("/")+1)}function nt(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function ct(e){return e===""?[]:e.split("/")}function Bs(e,t){const r=ct(e);for(const n of t.split("/"))if(!(n===""||n==="."))if(n===".."){if(r.length===0)return null;r.pop()}else r.push(n);return r.length===0?null:r.join("/")}function cr(e,t){const r=ct(e),n=ct(t);let s=0;for(;s<r.length&&s<n.length&&r[s]===n[s];)s+=1;return r.length-s+(n.length-s)}function Us(e){return Nr(e).replace(/[^\p{L}\p{N}_-]/gu,"")}function Ws(e,t,r=null){const n=r&&r.trim()!==""?`#${Us(r)}`:"",s=e===null?null:e.normalize("NFC"),o=t.normalize("NFC");if(s===o&&n)return n;const c=ct(s===null?"":nt(s)),a=o.split("/");let i=0;for(;i<c.length&&i<a.length-1&&c[i]===a[i];)i+=1;return[...Array.from({length:c.length-i},()=>".."),...a.slice(i)].map(encodeURIComponent).join("/")+n}const $s=/[[\]|#\n\r]/,Gs=20;function Hs(e){const t=e.map(a=>({doc:a,folder:nt(a.path),path:we(a.path),title:we(a.title),base:we(qe(ar(a.path)))})),r=new Map(t.map(a=>[a.path,a])),n=a=>(i,d)=>cr(a,i.folder)-cr(a,d.folder)||i.doc.path.length-d.doc.path.length||(i.doc.path<d.doc.path?-1:i.doc.path>d.doc.path?1:0);function s(a,i){const d=qe(a),u=a.startsWith("/")?[""]:[i,""];for(const f of u){const l=Bs(f,d);if(l===null)continue;const m=r.get(we(l+Rt));if(m)return m}}function o(a,i){const d=a.normalize("NFC").trim();if(d==="")return null;const u=i===null?"":nt(i);if(d.includes("/")){const g=s(d,u);if(g)return g}const f=we(d),l=we(qe(d)),m=Nr(l),w=t.filter(g=>g.title===f||g.base===l||g.doc.slug===m);return w.length===0?null:w.sort(n(u))[0]??null}function c(a,i){const d=[a.doc.title.trim(),qe(ar(a.doc.path)),`/${qe(a.doc.path)}`];for(const u of d)if(!(u===""||$s.test(u))&&o(u,i)===a)return u;return null}return{docs:e,resolve:(a,i)=>{var d;return((d=o(a,i))==null?void 0:d.doc)??null},search(a,i,d=Gs){const u=we(a),f=i===null?"":nt(i),l=i===null?null:we(i),m=[];for(const v of t){if(v.path===l)continue;const D=u===""||v.title.startsWith(u)?0:v.title.split(/[\s\-_/]+/).some(N=>N.startsWith(u))?1:v.title.includes(u)?2:v.path.includes(u)?3:-1;D>=0&&m.push({entry:v,score:D})}const w=n(f);m.sort((v,D)=>v.score-D.score||w(v.entry,D.entry));const g=[];for(const{entry:v}of m){if(g.length>=d)break;const D=c(v,i);D!==null&&g.push({target:D,title:v.doc.title,description:v.doc.path})}return g}}}function ur(e,t){const r=t.normalize("NFC").replaceAll("\\","/"),n=r.startsWith("/")||/^[A-Za-z]:\//.test(r);let s=r;if(n){const c=e.normalize("NFC").replaceAll("\\","/").replace(/\/+$/,"");if(!r.startsWith(`${c}/`))return null;s=r.slice(c.length+1)}const o=[];for(const c of s.split("/"))if(!(c===""||c==="."))if(c===".."){if(o.length===0)return null;o.pop()}else o.push(c);return o.length===0?null:o.join("/")}const lr="Links within this doc don’t open.",dr="This folder is too big to check this link.",fr="Couldn’t check this link.";function hr(e,t,r){return{exists:!0,href:Ws(e,t.path,r),title:t.title}}function Vs(e){const{index:t,truncated:r,docPath:n,lookup:s,open:o,refuse:c}=e,a=new Map,i=f=>{const l=f.normalize("NFC").trim().toLowerCase();let m=a.get(l);return m||(m=s(f.trim()).catch(()=>null),a.set(l,m)),m};return{resolve:f=>{if(f.target.trim()==="")return{exists:!1,title:lr};const l=t.resolve(f.target,n);return l?hr(n,l,f.heading):r?i(f.target).then(m=>m===null?{exists:!0,title:fr}:m.doc?hr(n,m.doc,f.heading):m.complete?{exists:!1}:{exists:!0,title:dr}):{exists:!1}},search:f=>t.search(f,n),onOpen:f=>{const l=f.target.trim();if(l===""){c(lr);return}const m=`No doc called “${l}” yet.`,w=t.resolve(l,n);if(w){o(w.path);return}if(!r){c(m);return}i(l).then(g=>{g!=null&&g.doc?o(g.doc.path):c(g===null?fr:g.complete?m:dr)})}}}function Js({cwd:e,sourcePath:t,content:r="",saved:n=!1}){const{enabled:s}=vn(bn),o=s&&!!e&&!!t,{data:c}=Wn(e,o),a=$n(),i=oe(),{setTheme:d}=wn(),u=o&&c&&e&&t?ur(e,t)??ur(c.root,t):null,f=p.useMemo(()=>c?Hs(c.docs):null,[c]),l=p.useRef({index:f,docPath:u,content:r,cwd:e});p.useEffect(()=>{l.current={index:f,docPath:u,content:r,cwd:e}}),p.useEffect(()=>{const{index:w,docPath:g,content:v,cwd:D}=l.current;if(!n||!w||g===null)return;const N=w.docs.find(z=>z.path.normalize("NFC").toLowerCase()===g.toLowerCase()),C=g.slice(g.lastIndexOf("/")+1);(!N||N.title!==Ps(v,C))&&a(D)},[n,a]);const m=p.useCallback(w=>{xn({getStore:V.getState,setTheme:d,supportsTerminal:i.supportsTerminal},{action:"open_file",sourcePath:w},"user")},[d,i]);return p.useMemo(()=>{if(!(!f||!c||u===null||!e))return Vs({index:f,truncated:c.truncated,docPath:u,lookup:w=>i.resolveDocLink(e,w,u),open:m,refuse:w=>yn.info(w)})},[f,c,u,e,i,m])}const Je=ce().min(1).max(128),pe={protocol:K("dorkos-doc"),v:K(1),nonce:Je,requestToken:Je,loadToken:Ct,generation:yr.shape.generation};ht("kind",[Z({...pe,kind:K("challenge")}).strict(),Z({...pe,kind:K("ack")}).strict(),Z({...pe,kind:K("connect")}).strict()]);ht("kind",[Z({...pe,kind:K("emit"),requestId:Je,event:ot}).strict(),Z({...pe,kind:K("retire")}).strict()]);ht("kind",[Z({...pe,kind:K("receipt"),requestId:Je,receipt:kr}).strict(),Z({...pe,kind:K("refused"),requestId:Je,outcome:Kt(["cancelled","unconfirmed","refused"])}).strict(),Z({...pe,kind:K("state"),state:jn,stateRev:Ct,docSeq:Ct,reset:it()}).strict(),Z({...pe,kind:K("event"),frame:Cn}).strict(),Z({...pe,kind:K("status"),status:Kt(["connecting","ready","offline","revoked"]),unconfirmed:it()}).strict()]);function Xs(e,t){try{if(kn(t,1048576)!==void 0)return null;const r=e.safeParse(t);return r.success?r.data:null}catch{return null}}function Zs(e){return typeof e=="object"&&e!==null&&e.status===404}function Ys({owner:e,getOwner:t,readTail:r,writeTail:n,transport:s,cwd:o,sourcePath:c,documentId:a,pending:i}){const d=()=>{var g,v;return((g=t())==null?void 0:g.recoveryGate)==="unsupported"||((v=t())==null?void 0:v.recoveryGate)==="observed_clear"},u=g=>{var N;const v=On.parse(g),D=(N=t())==null?void 0:N.recoveryBinding;if(!D||v.documentId!==a||!J(v.incarnation,D.incarnation))throw new Error("Original save scope changed");return v},f=s.originalFileSaveRecovery,l=()=>{var g;try{const v=t();return(v==null?void 0:v.identity)===e&&v.active&&!!((g=v.recoveryBinding)!=null&&g.current())}catch{return!1}},m=(g,v,D=!1,N=!1)=>{if(!f||!l())return Promise.resolve({status:"idle"});const C=t(),z={},F=()=>t()===C&&l()&&(!v||C.recoveryBinding===v)&&(!D||C.recoveryWork===z),G=C.discovery;let L=!1;C.recoveryWork=z,C.recoveryGate="pending",C.recoveryBusy=!0;const q=r().catch(()=>{}).then(async()=>{try{if(!F())return{status:"idle"};const U=await g();return F()?(D&&(C.recoveryGate="observed_clear"),L=!0,{status:"observed",value:U}):{status:"idle"}}catch(U){return F()?(C.recoveryGate="unavailable",{status:N&&Zs(U)?"refused":"unavailable"}):{status:"idle"}}finally{!L&&C.discovery===G&&(C.discovery=void 0),C.recoveryWork===z&&(C.recoveryBusy=!1,C.recoveryWork=void 0)}});return D||n(q.then(()=>{})),q};return{identity:e,supported:!!f,current:l,discover:(g=!1)=>{if(!f||!l())return Promise.resolve({status:"idle"});const v=t(),D=v.recoveryBinding;if(v.discoveryBinding===D&&v.discovery&&(v.pendingDiscovery===v.discovery||!g&&v.recoveryGate==="observed_clear"))return v.discovery;const N=m(async()=>{const C=u(await f.discover(a));return t()===v&&v.recoveryBinding===D&&l()&&(v.recoveryGate=C.admission==="blocked"?"blocked":"observed_clear"),C},D,!1,!0);return v.discoveryBinding=D,v.discovery=N,v.pendingDiscovery=N,N.then(C=>{v.pendingDiscovery===N&&(v.pendingDiscovery=void 0),C.status==="idle"&&v.discovery===N&&(v.discovery=void 0)}),N},recover(g){if(i())return Promise.resolve({status:"local_uncertain"});const v=t();return m(async()=>{if(!v||i())throw new Error("Mounted original still uncertain");const D=v.recoveryBinding,N=Rn.parse(await f.recover(a,g,D.incarnation));if(t()!==v||!l()||N.documentId!==a||N.entry.eventId!==g||!J(N.incarnation,D.incarnation))throw new Error("Original recovery scope changed");const C=u(await f.discover(a));return t()===v&&l()&&(v.recoveryGate=C.admission==="blocked"?"blocked":"observed_clear"),{result:N,discovery:C}})},inspectCurrent(){const g=t();return!g||!l()||i()||!d()?Promise.resolve({status:"local_uncertain"}):m(async()=>{const v=await s.readFileContent(o,c);if(!v||typeof v.content!="string"||typeof v.hash!="string"||!/^[a-f0-9]{64}$/u.test(v.hash))throw new Error("Current file evidence missing");return{content:v.content,hash:v.hash}},g.recoveryBinding,!0)}}}class Se extends Error{constructor(){super("The original save is not confirmed. Retry it before saving another draft.")}}class Ge extends Error{}function Qs(){const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Ks(e){const t=e;return(t==null?void 0:t.status)===412&&t.code==="DOC_SAVE_FAILED"}var fe,Ie,Ye,Et;class ei{constructor(){Le(this,Ye);Le(this,fe);Le(this,Ie)}get pending(){return Me(this,fe)!==void 0}get receipt(){return Me(this,Ie)}async write(t,r,n,s,o,c,a=!1){if(Me(this,fe))throw new Se;if(ve(this,Ie,void 0),!c)return t.writeFile(r,n,s,o);if(!a&&!c.current())throw new Ge;const i=Object.freeze({cwd:r,path:n,content:s,options:Object.freeze({...o,documentSave:Object.freeze({documentId:c.incarnation.documentId,eventId:Qs(),incarnation:Object.freeze({...c.incarnation})})})});return ve(this,fe,i),be(this,Ye,Et).call(this,t,i)}async retry(t,r){const n=Me(this,fe);if(!(n!=null&&n.options.documentSave)||!r.current()||!J(n.options.documentSave.incarnation,r.incarnation))throw new Ge;return{result:await be(this,Ye,Et).call(this,t,n),content:n.content}}}fe=new WeakMap,Ie=new WeakMap,Ye=new WeakSet,Et=async function(t,r){try{const n=await t.writeFile(r.cwd,r.path,r.content,r.options);if(!n||typeof n!="object"||typeof n.ok!="boolean")throw new Se;if(!n.ok){if(!n.conflict||typeof n.conflict.currentHash!="string"||!n.conflict.currentHash||typeof n.conflict.currentContent!="string")throw new Se;return ve(this,fe,void 0),n}if(typeof n.hash!="string"||!n.hash||n.effect!=="changed"&&n.effect!=="no_op")throw new Se;const s="documentReceipt"in n?En.parse(n.documentReceipt):void 0,o=r.options.documentSave;if(!s&&n.effect!=="no_op")throw new Se;if(s&&(s.documentId!==o.documentId||s.eventId!==o.eventId||!J(s.incarnation,o.incarnation)||s.fileHash!==n.hash||(s.status==="accepted"?n.effect!=="changed":n.effect!=="no_op")))throw new Se;if((s==null?void 0:s.status)==="duplicate"){const c=await t.readFileContent(r.cwd,r.path);if(!c||typeof c!="object"||Array.isArray(c)||typeof c.hash!="string"||!c.hash||typeof c.content!="string")throw new Se;if(c.hash!==s.fileHash||c.content!==r.content)return ve(this,Ie,s),ve(this,fe,void 0),{ok:!1,conflict:{currentHash:c.hash,currentContent:c.content}}}return ve(this,Ie,s),ve(this,fe,void 0),n}catch(n){throw Ks(n)&&ve(this,fe,void 0),n}};function ti({sourcePath:e,cwd:t,loadedContent:r,documentId:n,documentSaveBinding:s,documentRecoveryBinding:o}){const c=oe(),a=(s==null?void 0:s.incarnation)??(o==null?void 0:o.incarnation),i=a?JSON.stringify([a.documentId,a.physicalOpenedAt,a.channelCreatedAt,a.generation]):void 0,d=p.useRef(new ei),u=p.useMemo(()=>({sourcePath:e,cwd:t,documentId:n,transport:c,birthKey:i}),[e,t,n,c,i]),f=p.useRef(null),l=p.useRef(null),m=p.useRef(Promise.resolve()),w=p.useCallback(()=>{var k;return((k=l.current)==null?void 0:k.identity)===u&&l.current.active},[u]);p.useLayoutEffect(()=>{var k;return((k=l.current)==null?void 0:k.identity)!==u?l.current={identity:u,baseHash:null,baseContent:r,active:!0,recoveryBinding:o,recoveryGate:o&&c.originalFileSaveRecovery?"pending":"unsupported"}:(l.current.active=!0,l.current.recoveryBinding=o),()=>{var y;((y=l.current)==null?void 0:y.identity)===u&&(l.current.active=!1)}},[u,r,o,c]);const[g,v]=p.useState({owner:u,status:"idle",conflict:null}),D=g.owner===u?g.status:"idle",N=g.owner===u?g.conflict:null,C=p.useCallback((k,y,P)=>{w()&&v(W=>({owner:u,status:k,documentReceipt:y,confirmedContent:P,conflict:W.owner===u?W.conflict:null}))},[u,w]),z=p.useCallback(k=>{w()&&v(y=>({owner:u,conflict:k,status:y.owner===u?y.status:"idle"}))},[u,w]),F=p.useCallback(()=>{var k,y;return((k=l.current)==null?void 0:k.recoveryGate)==="unsupported"||((y=l.current)==null?void 0:y.recoveryGate)==="observed_clear"},[]),G=p.useMemo(()=>{const k=()=>Ys({owner:u,getOwner:()=>l.current,readTail:()=>m.current,writeTail:y=>{m.current=y},transport:c,cwd:t,sourcePath:e,documentId:n,pending:()=>d.current.pending});return{identity:u,supported:!!c.originalFileSaveRecovery,current:()=>k().current(),discover:y=>k().discover(y),recover:y=>k().recover(y),inspectCurrent:()=>k().inspectCurrent()}},[u,c,t,e,n]),L=!!(e&&t),q=p.useCallback((k,y,P,W=!1)=>{const te=()=>w()&&l.current===k&&(!s||s.current());if(y.ok){if(typeof y.hash!="string"||!y.hash||y.effect!=="changed"&&y.effect!=="no_op")throw new Error("Invalid file save acknowledgement");return k.baseHash=y.hash,k.baseContent=P,!W&&!te()?{status:"idle"}:(W||(z(null),C("saved",d.current.receipt,P)),{status:y.effect,confirmed:{hash:y.hash,content:P}})}return!W&&!te()?{status:"idle"}:(W||(z(y.conflict),C("conflict")),{status:"conflict"})},[w,s,z,C]),U=p.useCallback(async(k,y)=>{if(!w())return{status:"idle"};const P=l.current;s&&!d.current.pending&&(f.current=u);const W=await d.current.write(c,t,e,k,y,s);return q(P,W,k)},[w,c,t,e,s,q,u]),Y=p.useCallback(k=>{var W;if(!L||!w())return Promise.resolve({status:"idle"});const y=((W=l.current.finalToken)==null?void 0:W.content)===k?l.current.finalToken:void 0,P=m.current.catch(()=>{}).then(async()=>{if(!w()||s&&!s.current())return{status:"idle"};if(d.current.pending)return C("uncertain"),{status:"uncertain"};if(!F())return C("error"),{status:"error"};l.current.finalToken===y&&(l.current.finalToken=void 0),C("saving");try{const te=l.current.baseHash!==null?{expectedHash:l.current.baseHash}:{expectedContent:l.current.baseContent};return await U(k,te)}catch(te){if(te instanceof Ge)return{status:"idle"};if(!w()||s&&!s.current())return{status:"idle"};const ue=d.current.pending?"uncertain":"error";return C(ue),{status:ue}}});return m.current=P.then(()=>{}),P},[L,U,w,C,s,F]),he=p.useCallback(k=>{if(!L||!w()||s&&!s.current())return null;const y=l.current,P={content:k,id:Symbol("buffered canvas draft")};return y.finalToken=P,{cancel(){y.finalToken===P&&(y.finalToken=void 0)},flush(){if(y.finalToken!==P||l.current!==y||y.active)return Promise.resolve({status:"idle"});y.finalToken=void 0;const W=m.current.catch(()=>{}).then(async()=>{if(l.current!==y||y.active)return{status:"idle"};try{if(y.recoveryGate!=="unsupported"&&y.recoveryGate!=="observed_clear")return{status:"error"};const te=y.baseHash!==null?{expectedHash:y.baseHash}:{expectedContent:y.baseContent};s&&!d.current.pending&&(f.current=u);const ue=await d.current.write(c,t,e,k,te,s,!0);return q(y,ue,k,!0)}catch{return{status:"error"}}});return m.current=W.then(()=>{}),W}}},[L,w,c,t,e,s,q,u]),j=p.useCallback(async k=>{const y=l.current;return!y||y.identity!==u?!1:(await m.current.catch(()=>{}),l.current===y&&!d.current.pending&&y.baseContent===k)},[u]),S=p.useCallback(()=>{if(!w()||!s||f.current!==u)return Promise.resolve({status:"idle"});const k=l.current,y=m.current.catch(()=>{}).then(async()=>{if(!w()||l.current!==k||f.current!==u)return{status:"idle"};try{C("saving");const P=await d.current.retry(c,s);return q(k,P.result,P.content)}catch(P){if(P instanceof Ge||!w()||l.current!==k)return{status:"idle"};const W=d.current.pending?"uncertain":"error";return C(W),{status:W}}});return m.current=y.then(()=>{}),y},[w,s,c,q,C,u]),x=p.useCallback(k=>{var te;if(!L||!N||!w())return Promise.resolve({status:"idle"});const y=N.currentHash,P=((te=l.current.finalToken)==null?void 0:te.content)===k?l.current.finalToken:void 0,W=m.current.catch(()=>{}).then(async()=>{if(!w()||s&&!s.current())return{status:"idle"};if(d.current.pending)return C("uncertain"),{status:"uncertain"};if(!F())return C("error"),{status:"error"};l.current.finalToken===P&&(l.current.finalToken=void 0),C("saving");try{return await U(k,{expectedHash:y})}catch(ue){if(ue instanceof Ge)return{status:"idle"};if(!w()||s&&!s.current())return{status:"idle"};const Ae=d.current.pending?"uncertain":"error";return C(Ae),{status:Ae}}});return m.current=W.then(()=>{}),W},[L,N,U,w,C,s,F]),A=p.useCallback(()=>{var k;return((k=l.current)==null?void 0:k.identity)===u?{hash:l.current.baseHash,content:l.current.baseContent}:{hash:null,content:r}},[u,r]),I=p.useCallback(()=>{if(!N||!w()||s&&!s.current())return null;l.current.finalToken=void 0;const k=N.currentContent;return l.current.baseHash=N.currentHash,l.current.baseContent=k,z(null),C("idle"),k},[N,w,z,C,s]);return{recovery:G,status:D,conflict:N,canSave:L,save:Y,overwrite:x,adoptDisk:I,getConfirmedBase:A,prepareFinalSave:he,retryUnconfirmed:S,waitForCloseDrain:j,documentReceipt:g.owner===u?g.documentReceipt:void 0,confirmedContent:g.owner===u?g.confirmedContent:void 0}}const ri=p.lazy(()=>Re(()=>import("./BlintzCanvas-BFJXKo1L.js").then(e=>e.B),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.BlintzCanvas}))),ni=500;function si(e){switch(e){case"saving":return"Saving…";case"saved":return"Saved";case"error":return"Couldn’t save";default:return null}}function ii({content:e,documentId:t,onContentChange:r}){const[n,s]=p.useState(!1),[o,c]=p.useState(e.content),a=V(x=>x.canvasSessionId),i=V(x=>x.setDocumentEditing),d=V(x=>{var A;return((A=x.openDocuments.find(I=>I.id===t))==null?void 0:A.editing)??!1}),u=V(x=>x.selectedCwd),f=n&&d,l=ti({documentId:t,sourcePath:e.sourcePath,cwd:u,loadedContent:e.content}),m=l.canSave,w=Js({cwd:u,sourcePath:m?e.sourcePath:null,content:o,saved:l.status==="saved"}),g=p.useRef(null),v=p.useRef(null),D=p.useRef(o),N=p.useRef(e),C=p.useRef(r),z=p.useRef(l.save),F=p.useRef(l.prepareFinalSave),G=p.useRef(null);p.useEffect(()=>{D.current=o,N.current=e,C.current=r,z.current=l.save,F.current=l.prepareFinalSave});const L=p.useCallback(x=>{V.getState().canvasSessionId===g.current&&(C.current({...N.current,content:x}),z.current(x))},[]),q=p.useCallback(x=>{var A;c(x),D.current=x,(A=G.current)==null||A.cancel(),G.current=F.current(x),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=null,L(x)},ni)},[L]),U=()=>{g.current=V.getState().canvasSessionId,c(e.content),s(!0),i(t,!0)},Y=()=>{v.current&&(clearTimeout(v.current),v.current=null,L(D.current)),s(!1),i(t,!1)};p.useEffect(()=>{var x;f&&a!==g.current&&(v.current&&(clearTimeout(v.current),v.current=null),(x=G.current)==null||x.cancel(),G.current=null,s(!1),i(t,!1))},[a,f,t,i]),p.useEffect(()=>{var x;!n||f||(v.current&&clearTimeout(v.current),v.current=null,(x=G.current)==null||x.cancel(),G.current=null)},[f,n]),p.useEffect(()=>()=>{var x,A;v.current&&(clearTimeout(v.current),v.current=null,V.getState().canvasSessionId===g.current&&C.current({...N.current,content:D.current})),V.getState().canvasSessionId===g.current?(x=G.current)==null||x.flush():(A=G.current)==null||A.cancel(),G.current=null,i(t,!1)},[L,t,i]);const he=()=>{const x=l.adoptDisk();x!=null&&(r({...e,content:x}),c(x))},j=()=>{l.overwrite(D.current)},S=si(l.status);return h.jsxs("div",{className:"relative flex h-full flex-col",children:[h.jsxs("div",{className:"sticky top-0 z-10 flex h-0 items-start justify-end gap-2 pr-2",children:[m&&S&&h.jsx("span",{className:"text-muted-foreground mt-3 text-xs","aria-live":"polite",children:S}),m&&h.jsx(rt,{type:"button",variant:"ghost",size:"icon-md",className:"text-muted-foreground hover:text-foreground mt-2",onClick:f?Y:U,"aria-label":f?"Finish editing":"Edit document",children:f?h.jsx(jr,{className:"size-4"}):h.jsx(Cr,{className:"size-4"})})]}),l.status==="conflict"&&h.jsxs("div",{className:"bg-destructive/10 text-destructive mx-2 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md px-3 py-2 text-sm",children:[h.jsx("span",{className:"flex-1",children:"This file changed on disk since you opened it."}),h.jsx(rt,{type:"button",variant:"ghost",size:"sm",className:"h-7",onClick:he,children:"Reload"}),h.jsx(rt,{type:"button",variant:"destructive",size:"sm",className:"h-7",onClick:j,children:"Overwrite"})]}),h.jsx("div",{className:"flex-1 px-2 pb-6",children:h.jsx(p.Suspense,{fallback:h.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading editor…"}),children:h.jsx(ri,{value:f?o:e.content,editable:f,onChange:f?q:void 0,wikiLinks:w})})})]})}function oi({content:e}){return h.jsx("div",{className:"p-4 font-mono text-sm",children:h.jsx(Tr,{value:e.data,depth:0})})}const ai=20;function Tr({value:e,depth:t,keyName:r}){const[n,s]=p.useState(t>2),o=p.useCallback(()=>s(u=>!u),[]);if(t>=ai)return h.jsx(Pe,{keyName:r,value:"[max depth]",className:"text-muted-foreground"});if(e===null)return h.jsx(Pe,{keyName:r,value:"null",className:"text-muted-foreground"});if(typeof e=="boolean")return h.jsx(Pe,{keyName:r,value:String(e),className:"text-blue-500"});if(typeof e=="number")return h.jsx(Pe,{keyName:r,value:String(e),className:"text-green-500"});if(typeof e=="string")return h.jsx(Pe,{keyName:r,value:`"${e}"`,className:"text-amber-500"});const c=Array.isArray(e),a=c?e.map((u,f)=>[String(f),u]):Object.entries(e),i=c?"[":"{",d=c?"]":"}";return h.jsxs("div",{style:{paddingLeft:t>0?16:0},children:[h.jsxs("button",{type:"button",className:"hover:bg-muted -ml-0.5 inline-flex items-center gap-0.5 rounded px-0.5 transition-colors duration-150",onClick:o,children:[h.jsx(_n,{className:Lt("size-3 transition-transform",!n&&"rotate-90")}),r!=null&&h.jsxs("span",{className:"text-foreground",children:[r,": "]}),h.jsxs("span",{className:"text-muted-foreground",children:[i,n&&` … ${a.length} items `,n&&d]})]}),!n&&h.jsxs(h.Fragment,{children:[a.map(([u,f])=>h.jsx(Tr,{keyName:c?void 0:u,value:f,depth:t+1},u)),h.jsx("div",{className:"text-muted-foreground",children:d})]})]})}function Pe({keyName:e,value:t,className:r}){return h.jsxs("div",{style:{paddingLeft:16},children:[e!=null&&h.jsxs("span",{className:"text-foreground",children:[e,": "]}),h.jsx("span",{className:r,children:t})]})}const ci=/^\/api\/rooms\/([A-Za-z0-9][A-Za-z0-9._-]*)\/canvas\/media\/([0-9a-f]{16}-[0-9a-f]{64}(?:\.[a-z0-9]{1,10})?)$/;function Ar(e,t){const r=ci.exec(e.trim());return r?t===void 0||r[1]===t:!1}const ui=new Set(["http:","https:"]);function li(e){const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||t[1].length===1?null:`${t[1].toLowerCase()}:`}const di={image:"data:image/",pdf:"data:application/pdf"};function zr(e,t,r){const n=e.trim();if(n.startsWith("data:"))return n.toLowerCase().startsWith(di[t])?{url:n,error:null}:{url:null,error:"unsupported-data"};if(Ar(n))return{url:n,error:null};const s=li(n);if(s!==null)return ui.has(s)?{url:n,error:null}:{url:null,error:"blocked"};const o=r(n);return o?{url:o,error:null}:{url:null,error:"local-unavailable"}}function Fr(e,t){switch(e){case"blocked":return`This ${t} source is blocked for safety.`;case"unsupported-data":return`This data URI isn’t a valid ${t} source.`;case"local-unavailable":return`Local ${t} files can’t be displayed here.`}}function fi({content:e}){const t=oe(),r=V(u=>u.selectedCwd),n=p.useMemo(()=>zr(e.src,"image",u=>t.mediaUrl(r??"",u)),[e.src,t,r]),[s,o]=p.useState("loading"),[c,a]=p.useState(e.src);c!==e.src&&(a(e.src),o("loading"));const i=e.alt??e.title??"Canvas image";if(n.url===null){const u=n.error?Fr(n.error,"image"):"";return h.jsx(pr,{children:u})}const d=n.url;return h.jsxs("div",{className:"bg-muted/40 relative flex h-full items-center justify-center",children:[s==="loading"&&h.jsx("p",{className:"text-muted-foreground absolute text-sm","aria-live":"polite",children:"Loading image…"}),s==="error"?h.jsx(pr,{children:"This image couldn’t be loaded."}):h.jsxs(Tn,{centerOnInit:!0,doubleClick:{mode:"toggle"},wheel:{step:.15},children:[h.jsx(hi,{}),h.jsx(An,{wrapperClass:"!h-full !w-full",contentClass:"!h-full !w-full flex items-center justify-center",children:h.jsx("img",{src:d,alt:i,onLoad:()=>o("loaded"),onError:()=>o("error"),className:Lt("max-h-full max-w-full object-contain transition-opacity",s==="loaded"?"opacity-100":"opacity-0")})})]})]})}function hi(){const{zoomIn:e,zoomOut:t,resetTransform:r}=zn();return h.jsxs("div",{className:"absolute top-2 right-2 z-10 flex gap-1",children:[h.jsx(yt,{label:"Zoom in",onClick:()=>e(),children:h.jsx(Bn,{className:"size-4"})}),h.jsx(yt,{label:"Zoom out",onClick:()=>t(),children:h.jsx(Un,{className:"size-4"})}),h.jsx(yt,{label:"Reset zoom",onClick:()=>r(),children:h.jsx(Pn,{className:"size-4"})})]})}function yt({label:e,onClick:t,children:r}){return h.jsx("button",{type:"button",onClick:t,"aria-label":e,className:"bg-background/80 text-muted-foreground hover:text-foreground focus-ring rounded-md border p-1.5 backdrop-blur transition-colors",children:r})}function pr({children:e}){return h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:e})})}function pi({content:e}){const t=oe(),r=Sn().data,n=V(i=>i.selectedCwd),s=p.useMemo(()=>zr(e.src,"pdf",i=>t.mediaUrl(n??"",i)),[e.src,t,n]);if(s.url===null){const i=s.error?Fr(s.error,"pdf"):"";return h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:i})})}const o=s.url,c=e.title??"PDF document",a=new URL(o,window.location.href).origin===window.location.origin;return a&&!r?null:a&&(r==null?void 0:r.serverRole)==="hub"?h.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[h.jsx("p",{children:"PDFs download here instead of opening."}),h.jsxs("a",{href:o,download:!0,className:"text-foreground focus-ring rounded-md underline underline-offset-4",children:["Download ",c]})]}):h.jsx("object",{data:o,type:"application/pdf",title:c,className:"h-full w-full",children:h.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[h.jsx("p",{children:"This PDF can’t be shown here."}),h.jsxs("a",{href:o,target:"_blank",rel:"noreferrer",className:"text-foreground focus-ring rounded-md underline underline-offset-4",children:["Open ",c," in a new tab"]})]})})}function mi(e){const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||t[1].length===1?null:`${t[1].toLowerCase()}:`}const gi=new Set(["http:","https:","data:"]);function Mr(e,t,r){const n=e.trim();if(Ar(n))return{url:n};const s=mi(n);return s!==null?gi.has(s)?s==="data:"&&r!==void 0?n.toLowerCase().startsWith(r)?{url:n}:{url:null}:{url:n}:{url:null}:{url:t(n)}}function vi({content:e}){const t=oe(),r=V(o=>o.selectedCwd),n=p.useMemo(()=>Mr(e.src,o=>t.mediaUrl(r??"",o),"data:audio/"),[e.src,t,r]),s=e.title??"Canvas audio";return n.url===null?h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:"This audio can’t be played here."})}):h.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center p-8",children:h.jsx("audio",{controls:!0,src:n.url,"aria-label":s,className:"w-full max-w-2xl",children:h.jsxs("p",{className:"text-muted-foreground text-sm",children:["Your browser can’t play this audio."," ",h.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",s]}),"."]})})})}function bi({content:e}){const t=oe(),r=V(o=>o.selectedCwd),n=p.useMemo(()=>Mr(e.src,o=>t.mediaUrl(r??"",o),"data:video/"),[e.src,t,r]),s=e.title??"Canvas video";return n.url===null?h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:"This video can’t be played here."})}):h.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center",children:h.jsx("video",{controls:!0,src:n.url,"aria-label":s,className:"max-h-full w-full max-w-full object-contain",children:h.jsxs("p",{className:"text-muted-foreground p-8 text-sm",children:["Your browser can’t play this video."," ",h.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",s]}),"."]})})})}function Lr({content:e,documentId:t,channel:r}){const[n]=Mt(),s=Fn(e.definition),o=p.useMemo(()=>JSON.stringify(e.definition),[e.definition]);return h.jsx("div",{className:"p-4",children:s.ok?h.jsx(Mn,{channel:r,document:s.document,sessionId:n??void 0},r?t??r.documentId:o):h.jsx(Ln,{error:s.error,raw:s.raw})})}class wi{constructor(){re(this,"contiguous",0);re(this,"through",0);re(this,"pending",new Map)}get highest(){return this.contiguous}get catchUpThrough(){return this.through}get pendingCount(){return this.pending.size}reset(){this.contiguous=0,this.through=0,this.pending.clear()}resetHighest(){this.contiguous=0}advance(t){this.contiguous=Math.max(this.contiguous,t)}markThrough(t){this.through=Math.max(this.through,t)}recordGap(t){return this.markThrough(t.docSeq),this.pending.set(t.docSeq,t),this.pending.size<=200?!1:(this.pending.clear(),!0)}takeNextContiguous(){for(const n of this.pending.keys())n<=this.contiguous&&this.pending.delete(n);const t=this.contiguous+1,r=this.pending.get(t);return r&&this.pending.delete(t),r}clearReachedTarget(){return this.contiguous<this.through?!1:(this.through=0,!0)}}const _t=new WeakMap,Qe=new WeakMap,ye=new WeakMap,He=new WeakMap;function Oe(e){Ne(e);const t=_t.get(e);if(!t)throw new Error("Replay owner lifetime is absent.");return t}function xi(e,t){const r=Qe.get(t);if(!r||r.owner!==e)throw new Error("Replay run is foreign.");return r}function qr(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){for(const t of Object.values(e))qr(t);Object.freeze(e)}return e}function yi(e){if(Ne(e),_t.has(e))throw new Error("Replay owner lifetime is already initialized.");_t.set(e,new wi)}function Pt(e){const t=Oe(e);return Object.freeze({highest:t.highest,through:t.catchUpThrough,pending:t.pendingCount})}function mr(e){Oe(e).reset()}function gr(e,t){const r=Qe.get(t);if(!(!r||r.owner!==e))return Object.freeze({subject:r.subject,epoch:r.epoch,revision:r.revision,observation:r.observation,ended:r.ended})}function ki(e,t,r){const n=ye.get(r),s=Qe.get(t);if(!(!s||s.owner!==e||!n||n.owner!==e||n.run!==t||n.phase!=="consuming"||n.admissionRead||!ne(e,t)))return n.admissionRead=!0,Object.freeze({response:n.response,since:n.since,revision:n.revision,observation:n.observation,targetBirth:s.targetBirth})}function ji(e,t,r){const n=xi(e,t),s=ye.get(r),o=$r(e,t,r);if(!o||!s||s.owner!==e||s.run!==t||s.phase!=="consuming"||!s.admissionRead||n.ended||n.epoch!==o.epoch||n.subject!==o.previous)throw new Error("Replay own issuance is foreign or stale.");n.subject=o.subject}function Pr(e,t,r,n){if(!ne(e,t))return;if(n){const o=He.get(r);return o&&o.owner===e&&o.run===t&&o.phase==="dispatching"&&!o.advanced?o.frame:void 0}const s=ye.get(r);return s&&s.owner===e&&s.run===t&&s.phase==="frames"&&s.dispatching!==void 0&&!s.advanced?s.frames[s.dispatching]:void 0}function Ci(e,t,r,n){const s=Yi(e,t,r,n);if(!s||!ne(e,t))throw new Error("Replay cursor advance has no genuine core witness.");const o=n?He.get(r):ye.get(r);if(!o||o.advanced)throw new Error("Replay frame advance was consumed.");o.advanced=!0,Oe(e).advance(s.docSeq)}function Oi(e,t){const r=Qe.get(t),n=(r==null?void 0:r.lastPage)&&ye.get(r.lastPage);if(!r||r.owner!==e||!ne(e,t)||r.target===void 0||!n||n.phase!=="finished"||n.next!==n.frames.length||n.response.events.length>=200&&Oe(e).highest<r.target)return;const s=Oe(e);return Object.freeze({highest:s.highest,through:s.catchUpThrough,target:r.target})}function Ri(e,t){const r=Ze(e,t);if(!r)throw new Error("Replay notice is foreign or stale.");const n=Oe(e),s=r.notification;if(r.mode==="quarantine")n.markThrough(s.type==="canvas_channel_snapshot"?s.snapshot.highWatermark:s.docSeq),s.type!=="canvas_channel_snapshot"&&n.recordGap(s);else{if(r.mode==="gap"&&s.type!=="canvas_channel_snapshot")return n.recordGap(s);r.mode==="event"&&lo(e,t)}return!1}function Ei(e,t){const r=Ze(e,t);if(!r||r.mode!=="event"||r.notification.type==="canvas_channel_snapshot")throw new Error("Notice cursor advance is foreign.");Oe(e).advance(r.notification.docSeq)}function _i(e){const t=le(e),r=Oe(e),n=Object.freeze({}),s={owner:e,subject:t.subject,epoch:t.epoch,revision:t.revision,observation:t.observation,ended:!1,starting:r.highest,succeeded:!1};Qe.set(n,s),to(e,n);const o=()=>ne(e,n),c=()=>le(e).live?o()?void 0:"restart":"stop";return Object.freeze({async readPage(){if(!o())return null;const a=le(e),i=r.highest,d=pt(e),u=d.getCanvasChannel;if(!o())return null;const f=await u.call(d,t.documentId,{since:i,limit:200});if(!o())return null;const l=qr(Dn.parse(f));if(!o())return null;const m=Object.freeze({});return ye.set(m,{owner:e,run:n,response:l,since:i,revision:a.revision,observation:a.observation,phase:"read",admissionRead:!1,frames:[],next:0,advanced:!1}),m},consumePage(a){const i=ye.get(a);return!o()||!i||i.owner!==e||i.run!==n||i.phase!=="read"?{kind:"done"}:(i.phase="consuming",ro(e,n,a)!=="accepted"||!o()?(i.phase="finished",{kind:"done"}):(s.target??(s.target=i.response.highWatermark),s.targetBirth=i.response.incarnation,i.frames=Object.freeze(i.response.events.filter(u=>u.docSeq<=s.target)),i.phase="frames",s.lastPage=a,i.response.resetRequired&&r.advance(i.response.retentionFloor-1),{kind:"frames",count:i.frames.length}))},advancePageFrame(a,i){const d=ye.get(a);if(!o()||!d||d.owner!==e||d.run!==n||d.phase!=="frames"||i!==d.next||!d.frames[i])return!1;d.next=i+1,d.dispatching=i,d.advanced=!1;try{return br(e,n,a,!1)&&o()}finally{d.dispatching=void 0}},finishPage(a){const i=ye.get(a);if(!o()||!i||i.owner!==e||i.run!==n||i.phase!=="frames"||i.next!==i.frames.length||s.target===void 0)return"done";if(i.phase="finished",i.response.events.length<200||r.highest>=s.target)return r.advance(s.target),!o()||(wr(e,n),!o())||(s.succeeded=!0),"done";if(r.highest<=i.since)throw new Error("Document replay made no progress.");return"again"},failed(){o()&&no(e,n)},beginFinalization(){return c()??(s.succeeded?"drain":"stop")},takePending(){if(!o())return null;const a=r.takeNextContiguous();if(!a||!o())return null;const i=Object.freeze({});return He.set(i,{owner:e,run:n,frame:a,phase:"taken",advanced:!1}),i},advancePending(a){const i=He.get(a);if(!o()||!i||i.owner!==e||i.run!==n||i.phase!=="taken")return!1;i.phase="dispatching";try{return br(e,n,a,!0)&&o()}finally{i.phase="finished",He.delete(a)}},finishFinalization(){const a=c();if(a)return a;if(r.clearReachedTarget()){const i=c();if(i)return i;wr(e,n);const d=c();if(d)return d}if(r.pendingCount||r.catchUpThrough>r.highest){const i=le(e);if(r.highest>s.starting||i.revision>s.revision||i.observation>s.observation)return"restart";so(e,n)}return c()??"stop"},current:o,end:()=>{s.ended=!0}})}var ge,Dt,Ue;class St{constructor(){Le(this,ge);re(this,"current",null);re(this,"token",0);re(this,"retiring",!1);re(this,"subscribers",new Set);re(this,"resources",new Map);re(this,"doc",null);re(this,"docClaims",new WeakMap);re(this,"retiringDoc",!1);re(this,"docResources",new Map);re(this,"bindings",new WeakSet)}getCurrent(){return this.current}observeHostContext(t){if(this.retiring)return null;if(!t.transportOwner||typeof t.transportOwner!="object"||!Number.isSafeInteger(t.publisherEpoch)||t.publisherEpoch<0)throw new Error("Explicit transport owner and epoch required.");const r=["frame","documentId","resolvedSource","logicalUrl","reloadKey","sessionId","eligibility","exactOrigin","transportOwner","publisherEpoch"];if(r.some(s=>!Object.hasOwn(t,s))||typeof t.documentId!="string"||!t.documentId||typeof t.logicalUrl!="string"||typeof t.reloadKey!="string")throw new Error("Complete host context required.");const n=this.current;return n&&r.every(s=>Object.is(n[s],t[s]))?n:(this.retire(),this.current=Object.freeze({...t,token:this.token,loaded:!1}),this.current)}observeLoaded(t){return this.retiring||this.current!==t||!t.frame?null:(this.retire(),this.current=Object.freeze({...t,token:this.token,loaded:!0}),this.current)}retire(){if(this.retiring)return;const t=this.current;this.current=null;const r=this.doc;this.doc=null,this.token++,this.retiring=!0;const n=[...t?this.resources.get(t)??[]:[],...r?this.docResources.get(r)??[]:[],...this.subscribers];r&&this.docResources.delete(r),t&&this.resources.delete(t);try{for(const s of n)try{const o=s();o&&typeof o.then=="function"&&Promise.resolve(o).catch(()=>{})}catch{}}finally{this.retiring=!1}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}own(t,r){if(this.retiring||this.current!==t)throw new Error("Frame observation retired.");const n=this.resources.get(t)??new Set;return n.add(r),this.resources.set(t,n),()=>{n.delete(r)}}bindDoc(t,r,n){return be(this,ge,Dt).call(this,t,r,n)}acquireDoc(t,r,n){const s=be(this,ge,Dt).call(this,t,r,n),o=Object.freeze({});this.docClaims.set(s,o);let c=!1;return Object.freeze({binding:s,release:()=>{c||(c=!0,this.docClaims.get(s)===o&&(this.docClaims.delete(s),this.doc===s&&this.bindings.has(s)&&be(this,ge,Ue).call(this)))}})}disableDoc(){be(this,ge,Ue).call(this)}retireDoc(t){this.doc===t&&this.bindings.has(t)&&be(this,ge,Ue).call(this)}ownDoc(t,r){if(!this.isCurrent(t))throw new Error("Doc binding retired.");const n=this.docResources.get(t)??new Set;return n.add(r),this.docResources.set(t,n),()=>{n.delete(r)}}isCurrent(t){return!this.retiring&&!this.retiringDoc&&this.doc===t&&this.bindings.has(t)&&this.current===t.observation}}ge=new WeakSet,Dt=function(t,r,n){const s=this.doc,o=this.token,c=Xs(yr,r);if(!c)throw this.disableDoc(),new Error("Established server Doc birth required.");const a=c,i=t.exactOrigin,d=t.eligibility==="served-document"?i==="null":t.eligibility==="preview-listener"&&i!==null&&new URL(i).origin===i;if(!t.loaded||!t.frame||typeof t.frame.postMessage!="function"||!t.resolvedSource||!d||t.documentId!==a.documentId||!n||n.length>200)throw new Error("Loaded eligible frame and established Doc birth required.");if(this.retiring||this.retiringDoc||this.current!==t||this.doc!==s||this.token!==o)throw new Error("Frame observation retired during Doc admission.");if(this.doc){if(this.doc.observation!==t)throw new Error("Doc binding belongs to another host load.");if(J(this.doc.incarnation,a)&&this.doc.scope===n)return this.doc;throw this.retire(),new Error("Doc birth changed; a fresh host load is required.")}const u=Object.freeze({observation:t,incarnation:Object.freeze(a),scope:n});try{return this.doc=u,this.bindings.add(u),u}catch(f){throw this.doc===u&&be(this,ge,Ue).call(this),f}},Ue=function(){if(this.retiringDoc)return;const t=this.doc;this.doc=null,this.retiringDoc=!0;const r=[...t?this.docResources.get(t)??[]:[]];t&&this.docResources.delete(t);try{for(const n of r)try{const s=n();s&&typeof s.then=="function"&&Promise.resolve(s).catch(()=>{})}catch{}}finally{this.retiringDoc=!1}};function Si(e,t,r){if(!r||typeof r.captureOriginal!="function"||typeof r.submit!="function"||typeof r.inspect!="function"||typeof r.isCurrentOwner!="function"||r.owner!==t.observation.transportOwner||r.publisherEpoch!==t.observation.publisherEpoch)throw new Error("Explicit current transport submit and inspect ports required.");const{owner:n,publisherEpoch:s,isCurrentOwner:o,submit:c,inspect:a,captureOriginal:i}=r,d=Object.freeze({expectedGeneration:t.incarnation.generation}),u=()=>{try{return e.isCurrent(t)?o(n,s)===!0&&e.isCurrent(t):!1}catch{return!1}};if(!u())throw new Error("Doc binding unavailable.");const f=()=>{if(!u())throw new Error("Doc binding retired.")};return Object.freeze({binding:t,current:u,captureOriginal:l=>{f();const m=l.id;f();const w=l.bytes;f();const g=Reflect.apply(i,r,[Object.freeze({id:m,bytes:w})]);if(f(),!g)return null;const v=g.id;f();const D=g.bytes;f();const N=g.submit;f();const C=g.inspect;return f(),v!==m||D!==w||typeof N!="function"||typeof C!="function"?null:Object.freeze({id:m,bytes:w,submit:async z=>{f(),z.throwIfAborted();const F=await Reflect.apply(N,g,[z]);return f(),z.throwIfAborted(),F},inspect:async z=>{f(),z.throwIfAborted();const F=await Reflect.apply(C,g,[z]);return f(),z.throwIfAborted(),F}})},retireObservation:()=>{u()&&e.retire()},onRetire:l=>e.ownDoc(t,l),submit:(l,m)=>(f(),m.throwIfAborted(),c(l,d,m)),inspect:(l,m)=>(f(),m.throwIfAborted(),a(l,d,m))})}class Di{constructor(){re(this,"revision",0);re(this,"draining",!1);re(this,"cleanup");re(this,"subscribers",new Set);re(this,"retirements",new WeakMap)}captureRetirement(){const t=Object.freeze({}),r=++this.revision,n=this.cleanup;return this.cleanup=void 0,this.retirements.set(t,{revision:r,cleanup:n,callbacks:this.draining?[]:[...this.subscribers]}),t}drainRetirement(t){const r=this.retirements.get(t);if(!r)throw new Error("Frame resource retirement is foreign or consumed.");this.retirements.delete(t);const n=this.draining;this.draining=!0;try{this.drain(r.cleanup);for(const s of r.callbacks)this.drain(s)}finally{this.draining=n}}begin(){const t=this.captureRetirement(),r=this.revision;return this.drainRetirement(t),r}once(t,r,n){let s=!1;return()=>{if(s||(s=!0,!this.current(t)||!r()||!this.current(t)))return null;const o=n();return!this.current(t)||!r()||!this.current(t)?null:o}}drain(t){try{Promise.resolve(t==null?void 0:t()).catch(()=>{})}catch{}}current(t){return this.revision===t}install(t,r){return this.current(t)?(this.cleanup=r,!0):!1}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}}function Ii(e,t,r){const n=()=>e.current(t)&&r.current()===!0&&e.current(t),s=e.once(t,n,r.complete);return Object.freeze({completeLoad:()=>{const o=s();return!o||!n()||r.accept(o)!==!0||!n()?null:o}})}function Ni(e,t,r){const n=()=>e.current(t)&&r.current()===!0&&e.current(t);if(!n())return null;const s=r.acquire();if(!s)return null;let o=!1,c=null,a;try{const i=s.binding;if(n()&&r.bindingCurrent(i)===!0&&n()){const d=r.createPort(i);n()&&r.portCurrent(d)===!0&&n()&&e.install(t,s.release)&&(o=!0,c=d)}}catch(i){a={cause:i}}if(!o)try{s.release()}catch(i){a??(a={cause:i})}if(a)throw a.cause;return c}function Ti(e){const t=()=>Object.assign(new Error("Document actions are unavailable."),{status:409}),r=(s,o)=>{if(o.aborted||!e.current(s)||o.aborted)throw t()},n=(s,o)=>{const c=kr.parse(o);if(c.receipt.id!==s)throw new Error("Document receipt does not match this action.");return c};return Object.freeze({current:e.current,submit:async(s,o)=>{const c=ot.parse(JSON.parse(JSON.stringify(s))),a=c.id;r("submit",o);const i=await e.submit(c,o);r("read",o);const d=n(a,i);return r("read",o),d},inspect:async(s,o)=>{r("read",o);const c=await e.inspect(s,o);r("read",o);const a=n(s,c);return r("read",o),a},captureOriginal:s=>{const o=ot.parse(JSON.parse(JSON.stringify(s))),c=o.id,a=JSON.stringify(o);if(!e.current("submit"))return null;const i=e.capture(o,a);if(!i||!e.current("submit")||!i.current("submit"))return null;let d=!1;const u=f=>i.current(f)===!0;return Object.freeze({id:c,bytes:a,current:u,submit:async f=>{if(d||f.aborted||!u("submit"))throw t();d=!0;const l=await i.submit(JSON.parse(a),f);if(f.aborted||!u("read"))throw t();const m=n(c,l);if(f.aborted||!u("read"))throw t();return m},inspect:async f=>{if(f.aborted||!u("read"))throw t();const l=await i.inspect(c,f);if(f.aborted||!u("read"))throw t();const m=n(c,l);if(f.aborted||!u("read"))throw t();return m}})}})}function Ai(e){return Object.freeze({id:e.id,bytes:e.bytes,submit:async t=>{try{return{kind:"accepted",receipt:await e.submit(t)}}catch{return{kind:"uncertain"}}},inspect:async t=>{try{return{kind:"accepted",receipt:await e.inspect(t)}}catch{return{kind:"unknown"}}}})}function zi(e,t,r){const n=ot.parse(JSON.parse(e.bytes));if(n.id!==e.id||JSON.stringify(n)!==e.bytes||!r())return null;const s=t(n);return!r()||!s?null:Ai(s)}const Fi=St.prototype.acquireDoc,ut=new WeakMap,It=new WeakMap;function Mi(e,t){const r=pt(e),n=new WeakMap,s=(c,a)=>t.current(a)&&Ce(e,c,!0);return Object.freeze({prepareFrameLoad:(c,a)=>{var l;if(!(c instanceof St)||a.loaded)return null;const i=vr(e),d=i?(l=De(e,i))==null?void 0:l.httpBaseline:void 0,u=t.begin();if(!i||!d||!t.current(u)||!Ce(e,i,!0)||c.getCurrent()!==a||a.transportOwner!==r||!s(i,u))return null;let f=null;return Ii(t,u,{current:()=>{var m;return Ce(e,i,!0)&&((m=De(e,i))==null?void 0:m.httpBaseline)===d&&c.getCurrent()===(f??a)&&t.current(u)&&Ce(e,i,!0)},complete:()=>(f=c.observeLoaded(a),f),accept:m=>{var w,g;return!t.current(u)||!Ce(e,i,!0)||((w=De(e,i))==null?void 0:w.httpBaseline)!==d||c.getCurrent()!==m||!t.current(u)||!Ce(e,i,!0)||((g=De(e,i))==null?void 0:g.httpBaseline)!==d?!1:(n.set(m,{record:i,birth:d.birth}),!0)}})},subscribeInvalidation:c=>t.subscribe(c),attachFrame:(c,a)=>{if(!(c instanceof St))return null;const i=vr(e),d=t.begin();if(!i||!t.current(d)||!Ce(e,i,!0)||c.getCurrent()!==a||a.transportOwner!==r||!s(i,d))return null;const u=n.get(a);return!u||u.record!==i||!J(u.birth,De(e,i).birth)?null:Ni(t,d,{current:()=>s(i,d),acquire:()=>{const f=Fi.call(c,a,De(e,i).birth,De(e,i).birth.documentId);let l=!1,m=null,w;try{s(i,d)&&c.getCurrent()===a&&s(i,d)&&(m=Object.freeze({binding:f.binding,release:f.release}),l=!0)}catch(g){w={cause:g}}if(!l)try{f.release()}catch(g){w??(w={cause:g})}if(w)throw w.cause;return m},bindingCurrent:f=>c.isCurrent(f)&&s(i,d),createPort:f=>Si(c,f,{owner:r,publisherEpoch:a.publisherEpoch,isCurrentOwner:(l,m)=>l===r&&m===a.publisherEpoch&&t.current(d)&&Ce(e,i),captureOriginal:l=>zi(l,m=>{var w;return((w=eo(e,i))==null?void 0:w.captureOriginal(m))??null},()=>s(i,d)),submit:async()=>({kind:"terminal"}),inspect:async()=>({kind:"unknown"})}),portCurrent:f=>f.current()&&s(i,d)})}})}function Li(e){if(Ne(e),ut.has(e))throw new Error("Frame owner is already initialized.");const t=new Di,r=Mi(e,t);return ut.set(e,{frames:t,facade:r}),r}function qi(e){var t;return Ne(e),(t=ut.get(e))==null?void 0:t.facade}function We(e){Ne(e);const t=ut.get(e);if(!t)return;const r=Object.freeze({});return It.set(r,{owner:e,frames:t.frames,ticket:t.frames.captureRetirement()}),r}function $e(e,t){if(!t)return;const r=It.get(t);if(!r||r.owner!==e)throw new Error("Frame retirement is foreign or consumed.");It.delete(t),r.frames.drainRetirement(r.ticket)}function Br(e,t){const r=xe(e,t),n=Zi(e,t);if(!(!r||!n))return{owner:t,verified:r.verified,...Ti(n)}}function me(e,t){return{documentId:e,transport:t,events:[],available:!1}}function Pi(e,t,r,n,s,o){var i,d;const c=e.documentId===r&&e.transport===n?e:me(r,n);if(c.snapshot&&(t.highWatermark<c.snapshot.highWatermark||t.stateRev<c.snapshot.stateRev))return c;const a=new Map((((i=c.snapshot)==null?void 0:i.receipts)??[]).filter(u=>u.receipt.docSeq>=t.receiptRetentionFloor).map(u=>[u.receipt.id,u]));for(const u of t.receipts)a.set(u.receipt.id,u);return{...c,available:o,snapshot:{...t,...s?{}:{routing:(d=c.snapshot)==null?void 0:d.routing},receipts:[...a.values()].sort((u,f)=>f.receipt.docSeq-u.receipt.docSeq).slice(0,400)},events:t.resetRequired?c.events.filter(u=>u.docSeq>=t.retentionFloor):c.events}}function Bi(e){var r,n,s,o,c,a,i,d,u,f,l,m;const t=async()=>{throw Object.assign(new Error("Document actions are unavailable."),{status:409})};return{documentId:e.documentId,enabled:e.available&&((r=e.binding)==null?void 0:r.verified)===!0&&((s=(n=e.snapshot)==null?void 0:n.routing)==null?void 0:s.enabled)===!0,submissionOwner:(o=e.binding)==null?void 0:o.owner,current:((c=e.binding)==null?void 0:c.current)??(()=>!1),approvedEventTypes:e.available?((i=(a=e.snapshot)==null?void 0:a.routing)==null?void 0:i.approvedEventTypes)??[]:[],destinationLabel:e.available?((u=(d=e.snapshot)==null?void 0:d.routing)==null?void 0:u.destinationLabel)??"Actions unavailable":"Actions unavailable",...e.snapshot?{snapshot:e.snapshot}:{},submit:((f=e.binding)==null?void 0:f.submit)??t,inspect:((l=e.binding)==null?void 0:l.inspect)??t,captureOriginal:(m=e.binding)==null?void 0:m.captureOriginal}}function Ui(e,t,r){return!!(e&&t&&r.incarnation&&J(t,r.incarnation)&&(r.highWatermark<e.highWatermark||r.stateRev<e.stateRev))}function Ur(e,t,r,n){const s=e.documentId===r&&e.transport===n?e:me(r,n);return{...s,events:[...s.events,t].slice(-200)}}function Wi(e,t){if(e.incarnation&&(e.incarnation.documentId!==t||e.events.some(r=>r.documentId!==t||!r.incarnation||!J(e.incarnation,r.incarnation))))throw new Error("Document replay identity changed.")}const Nt=new WeakMap;function $i(e,t,r){const n=ki(e,t,r);if(n)return Nt.set(r,{owner:e,run:t,witness:n}),n}const Wr=new WeakMap,Xe=new WeakMap,Tt=new WeakMap,At=new WeakMap;function ke(e,t){Ne(e);const r=t??Xe.get(e),n=r&&Wr.get(r);return n&&n.owner===e&&Xe.get(e)===r&&n.active?n:void 0}function X(e){return Ne(e),Xe.get(e)}function xe(e,t){const r=ke(e,t);return r?Object.freeze({birth:r.birth,httpBaseline:r.httpBaseline,snapshot:r.snapshot,verified:r.verified}):void 0}function Ve(e,t,r=!1){var o,c;const n=ke(e,t),s=le(e);return!!n&&s.live&&n.verified&&n.transport===pt(e)&&(!r||((c=(o=n.snapshot)==null?void 0:o.routing)==null?void 0:c.enabled)===!0)}function Gi(e){const t=ke(e);Xe.delete(e),t&&(t.active=!1,t.verified=!1)}function kt(e,t){const r=ke(e,t);r&&(r.verified=!1)}function Hi(e,t,r){const n=ke(e,r);return!n||!ne(e,t)?!1:(n.verified=!0,ne(e,t))}function Vi(e,t,r){const n=Nt.get(r);Nt.delete(r);const s=(n==null?void 0:n.owner)===e&&n.run===t?n.witness:void 0;if(!s||!ne(e,t))return!1;const o=s.response.incarnation;let c=ke(e);if(!c&&!o)return ne(e,t);if(!c&&o){const a=le(e),i=()=>{const w=le(e);return ne(e,t)&&w.epoch===a.epoch&&w.observation===a.observation&&X(e)===a.subject},d=pt(e),u=d.ingestCanvasEvent;if(!i())return!1;const f=Function.prototype.bind.call(u,d),l=d.getCanvasEventReceipt;if(!i())return!1;const m=Function.prototype.bind.call(l,d);if(!i())return!1;c={owner:e,token:Object.freeze({}),birth:Object.freeze({...o}),active:!0,verified:!1,submit:f,inspect:m,transport:d},Wr.set(c.token,c),Xe.set(e,c.token),c.httpBaseline=Object.freeze({birth:c.birth,floor:s.response.receiptRetentionFloor}),Tt.set(r,Object.freeze({owner:e,run:t,epoch:a.epoch,previous:a.subject,subject:c.token}));try{ji(e,t,r)}catch(w){throw ke(e)===c&&ao(e,t,r),w}finally{Tt.delete(r)}if(!ne(e,t))return!1}else if(c){if(!o||!J(c.birth,o))return!1;c.httpBaseline=Object.freeze({birth:c.birth,floor:s.response.receiptRetentionFloor})}return ne(e,t)?(c&&(c.verified=co(e)||c.verified),!0):!1}function Bt(e,t,r){const n=Ut(e),s=n.subject,o=()=>Vr(e,n,r);if(!s||!Ve(e,s)){const i=We(e);$e(e,i)}if(!o())return;const c=s&&Br(e,s),a=qi(e);n.dispatch(i=>{var f;if(!o())return i;const d=((f=i.binding)==null?void 0:f.owner)===s?i:me(n.documentId,n.transport),u=typeof t=="function"?t(d):t;return o()?{...u,...u.snapshot?{snapshot:Object.freeze({...u.snapshot})}:{},binding:c,frameAdmission:a}:i})}function Ji(e,t,r,n,s){const o=Ut(e),c=ke(e);Vr(e,o,s)&&(c&&(c.snapshot=t),Bt(e,a=>Pi(a,t,o.documentId,o.transport,r,n),s))}function Xi(e,t,r,n){const s=Pr(e,t,r,n);if(!ne(e,t)||!s)return!1;if(s.docSeq<=Pt(e).highest)return ne(e,t);At.set(r,{owner:e,run:t,pending:n,frame:s});try{Ci(e,t,r,n)}finally{At.delete(r)}if(!ne(e,t))return!1;const o=Ut(e);return Bt(e,c=>Ur(c,s,o.documentId,o.transport),t),ne(e,t)}function Zi(e,t){const r=ke(e,t);if(!r)return;const n=le(e).documentId;return{current:s=>Ve(e,t,s==="submit"),submit:(s,o)=>r.submit(n,s,{expectedGeneration:r.birth.generation},o),inspect:(s,o)=>r.inspect(n,s,{expectedGeneration:r.birth.generation},o),capture:()=>{const s=r.httpBaseline;return!s||!Ve(e,t,!0)||!J(s.birth,r.birth)?null:Object.freeze({current:o=>Ve(e,t,o==="submit")&&(o==="read"||r.httpBaseline===s),submit:(o,c)=>r.submit(n,o,{expectedGeneration:s.birth.generation},c),inspect:(o,c)=>r.inspect(n,o,{expectedGeneration:s.birth.generation},c)})}}}function $r(e,t,r){const n=Tt.get(r),s=le(e);return n&&n.owner===e&&n.run===t&&s.epoch===n.epoch&&s.subject===n.subject&&s.live?n:void 0}function Yi(e,t,r,n){const s=At.get(r);return s&&s.owner===e&&s.run===t&&s.pending===n&&ne(e,t)?s.frame:void 0}const Gr=new WeakMap,lt=new WeakMap;function Qi(e){const t=lt.get(e);if(!t)throw new Error("Document construction ticket is foreign or consumed.");return lt.delete(e),t}function Ki(e,t,r){const n=Object.freeze({});lt.set(n,Object.freeze({documentId:e,transport:t,dispatch:r}));try{const s=uo(n);return Gr.set(n,s),n}finally{lt.delete(n)}}function ee(e){const t=Gr.get(e);if(!t)throw new Error("Document owner is foreign.");return t}function Ne(e){ee(e)}function le(e){return ee(e).facts()}function pt(e){return ee(e).transport()}function vr(e){return ee(e).subject()}function De(e,t){return ee(e).subjectFacts(t)}function Ce(e,t,r=!1){return ee(e).subjectCurrent(t,r)}function eo(e,t){return ee(e).binding(t)}function to(e,t){ee(e).reserve(t)}function ne(e,t){return ee(e).current(t)}function ro(e,t,r){return ee(e).admit(t,r)}function br(e,t,r,n){return ee(e).frame(t,r,n)}function wr(e,t){return ee(e).qualify(t)}function no(e,t){ee(e).failed(t)}function so(e,t){ee(e).unavailable(t)}function io(e,t){ee(e).start(t)}function oo(e){ee(e).dispose()}const Hr=new WeakMap;function Ut(e){const t=Object.freeze(ee(e).projection());return Hr.set(t,Object.freeze({custodyKey:e,capture:t})),t}function Vr(e,t,r){const n=Hr.get(t);return(n==null?void 0:n.custodyKey)===e&&n.capture===t&&ee(e).projectionCurrent(t.epoch,t.subject,r)}function ao(e,t,r){ee(e).abortAdmission(t,r)}function co(e){return ee(e).qualified()}const zt=new WeakMap;function uo(e){const{documentId:t,transport:r,dispatch:n}=Qi(e);let s,o=!1,c;const a={live:!0};let i=0,d,u,f=!1,l,m,w=0;const g=()=>a.live,v=()=>Gi(e);let D=0;const N=()=>Pt(e),C=j=>{const S=gr(e,j);return!!S&&!S.ended&&g()&&s===j&&S.epoch===i&&S.subject===X(e)},z=(j=!1)=>{const S=We(e);v(),i++,s=void 0,j&&mr(e),$e(e,S)},F=(j,S)=>Bt(e,j,S),G=j=>{const S=Oi(e,j),x=X(e),A=x&&xe(e,x);return!C(j)||!S||S.through>S.highest||!l||!A||!J(l,A.birth)||!Hi(e,j,x)?!1:(l=void 0,F(I=>({...I,available:!0}),j),C(j))},L=(j,S,x)=>{const A=X(e),I=A&&xe(e,A),k=i,y=()=>g()&&k===i&&X(e)===A&&(!x||C(x));if(!y()||Ui(I==null?void 0:I.snapshot,I==null?void 0:I.birth,j))return;const P=S?j.routing:u;j={...j,routing:P&&Object.freeze({enabled:P.enabled,destinationLabel:P.destinationLabel,approvedEventTypes:Object.freeze([...P.approvedEventTypes])})},S&&(u=j.routing),!A&&!j.incarnation&&(f=!0),y()&&Ji(e,j,S,l===void 0,x)},q=(j,S)=>{var ue;const x=$i(e,j,S);if(!C(j)||!x)return"discard";const A=x.response;Wi(A,t);const I=A.incarnation;if((X(e)||l||m)&&!I)throw new Error("Document replay identity is unavailable.");if(m&&I&&!J(m,I))return z(!0),F(me(t,r)),"restart";const k=X(e),y=(k&&((ue=xe(e,k))==null?void 0:ue.birth))??l;if(I&&(y&&!J(y,I)||!y&&f||x.targetBirth&&!J(x.targetBirth,I)))return l=I,f=!1,u=void 0,d=void 0,z(!0),F(me(t,r)),"restart";const{events:P,...W}=A,te=X(e);return!te&&I&&(l=m??I),!Vi(e,j,S)||!C(j)?"discard":(!te&&I&&(m=void 0),L(W,x.revision===D,j),C(j)?"accepted":"discard")},U=(j,S,x)=>{var y;const A=Pr(e,j,S,x),I=X(e),k=(I&&((y=xe(e,I))==null?void 0:y.birth))??l;return!C(j)||!A||A.documentId!==t||k&&(!A.incarnation||!J(k,A.incarnation))?!1:Xi(e,j,S,x)},Y=(j,S)=>{const x=Object.freeze({});zt.set(x,Object.freeze({owner:e,revision:D,observation:w,epoch:i,notification:j,mode:S}));try{return Ri(e,x)}finally{zt.delete(x)}},he=j=>{if(o||!g()||(o=!0,F(me(t,r)),!g()))return;const S=In(void 0,x=>{if(!g()||x.documentId!==t)return;const A=x.type==="canvas_channel_snapshot"?x.snapshot.incarnation:x.incarnation,I=X(e);if(!I){if(l&&!m&&(!A||!J(l,A))||!A||A.documentId!==t)return;if(!m||!J(m,A)){const k=!!m||!!l;if(m=Object.freeze({...A}),w++,u=void 0,d=void 0,f=!1,k&&(z(!0),F(me(t,r))),!g()||!m||!J(m,A))return}Y(x,"quarantine"),g()&&j();return}if(l&&(!A||!J(l,A))){A&&j();return}if(A&&!J(xe(e,I).birth,A)){l=A,f=!1,u=void 0,d=void 0,z(!0),F(me(t,r)),g()&&j();return}if(A){if(d!==void 0&&d!==x.scope){const k=We(e);if(d=x.scope,kt(e,I),i++,s=void 0,D++,$e(e,k),X(e)!==I||!g())return;F(y=>({...y,available:!1})),X(e)===I&&g()&&j();return}d=x.scope,D++,x.type==="canvas_channel_snapshot"?L(x.snapshot,!0):x.docSeq>N().highest+1?(Y(x,"gap")&&g()&&F(y=>({...y,available:!1})),g()&&j()):Y(x,"event")}},r,()=>{if(!g())return;const x=We(e),A=X(e);A&&kt(e,A),i++,s=void 0,D++,$e(e,x),F(I=>({...I,available:!1})),g()&&j()});g()?c=S:S(),g()&&j()};return Jr.set(e,j=>{const S=Ze(e,j);if(!S||S.notification.type==="canvas_channel_snapshot")return;const x=X(e),A=i;!x||!S.notification.incarnation||!J(xe(e,x).birth,S.notification.incarnation)||(F(I=>Ur(I,S.notification,t,r)),!g()||A!==i||X(e))}),{facts:()=>Object.freeze({documentId:t,live:g(),epoch:i,revision:D,observation:w,subject:X(e)}),transport:()=>r,subject:()=>X(e),subjectFacts:j=>xe(e,j),subjectCurrent:(j,S)=>Ve(e,j,S),binding:j=>Br(e,j),qualified:()=>l===void 0,projection:()=>({documentId:t,transport:r,dispatch:n,epoch:i,run:s,subject:X(e)}),projectionCurrent:(j,S,x)=>g()&&j===i&&S===X(e)&&(!x||s===x),abortAdmission:(j,S)=>{$r(e,j,S)&&z(!0)},reserve:j=>{const S=gr(e,j);if(!S||S.ended||!g()||S.epoch!==i||S.subject!==X(e))throw new Error("Replay run is foreign or stale.");s=j},current:C,admit:q,frame:U,qualify:G,failed:j=>{if(!C(j))return;const S=X(e);S&&kt(e,S),F(x=>({...x,available:!1}),j)},unavailable:j=>{C(j)&&F(S=>({...S,available:!1}),j)},start:he,dispose:()=>{if(!g())return;const j=We(e);a.live=!1,s=void 0;const S=c;c=void 0,v(),i++,mr(e);try{$e(e,j)}finally{S==null||S()}}}}function Ze(e,t){const r=zt.get(t),n=le(e);if(!(!r||r.owner!==e||!n.live||n.epoch!==r.epoch||n.revision!==r.revision||n.observation!==r.observation))return r}function lo(e,t){var a;const r=Ze(e,t);if(!r||r.notification.type==="canvas_channel_snapshot")return;const n=r.notification,o=le(e).subject,c=o&&xe(e,o);!c||!n.incarnation||!J(c.birth,n.incarnation)||n.docSeq<=Pt(e).highest||(Ei(e,t),!(!Ze(e,t)||le(e).subject!==o)&&((a=Jr.get(e))==null||a(t)))}const Jr=new WeakMap;function fo(e,t,r){const n=Ki(e,t,r);yi(n);const s=Li(n);return Object.freeze({beginRun:()=>_i(n),frameAdmission:s,start:o=>io(n,o),dispose:()=>oo(n)})}function ho(e,t){let r,n=0;const s=f=>{try{t==null||t(f)}catch{}},o=f=>{r===f&&(r=void 0)},c=(f,l)=>{f.settled||(f.settled=!0,r||s(!1),l?f.reject(l.cause):f.resolve())},a=()=>{u().catch(()=>{})},i=(f,l)=>{const m=()=>n===f.revision;if(!m())return;const w=l.beginFinalization();if(m()){if(w==="restart"){a();return}if(w==="drain")for(;m();){const g=l.drainOne();if(!m())return;if(g!=="again"){if(g==="restart")a();else if(g==="tail"){const v=l.finishFinalization();m()&&v==="restart"&&a()}return}}}},d=async f=>{let l,m;try{l=e();try{for(;await l.page()==="again";);}catch(w){l.failed(w)}}catch(w){m={cause:w}}finally{o(f);try{l&&i(f,l)}catch(w){m={cause:w}}finally{c(f,m)}}},u=()=>{if(r)return r.promise;let f,l;const m=new Promise((g,v)=>{f=g,l=v}),w={revision:++n,promise:m,resolve:f,reject:l,settled:!1};return r=w,s(!0),d(w),m};return Object.freeze({request:u})}function po(e,t,r,n){const s=fo(e,t,r);let o=!1;const c=ho(()=>{const a=s.beginRun();return{async page(){const i=await a.readPage();if(!i)return"done";const d=a.consumePage(i);if(d.kind!=="frames")return d.kind;for(let u=0;u<d.count;u++)if(!a.advancePageFrame(i,u))return"done";return a.finishPage(i)},failed:()=>a.failed(),beginFinalization:()=>{const i=a.beginFinalization();return i!=="drain"&&a.end(),i},drainOne(){if(!a.current())return a.end(),"stop";const i=a.takePending();return i?a.advancePending(i)?"again":(a.end(),"stop"):"tail"},finishFinalization:()=>{try{return a.finishFinalization()}finally{a.end()}}}},a=>{o||n==null||n(a)});return s.start(()=>{c.request().catch(()=>{})}),Object.freeze({dispose(){o=!0,s.dispose()}})}function mo(e){var d,u,f;const t=oe(),[r,n]=p.useState(()=>me(e,t)),[s,o]=p.useState({documentId:e,transport:t,pending:!0});p.useLayoutEffect(()=>{const l=po(e,t,n,m=>{o({documentId:e,transport:t,pending:m})});return()=>l.dispose()},[e,t]);const c=r.documentId===e&&r.transport===t?r:me(e,t),a=p.useMemo(()=>Bi(c),[c]),i=p.useMemo(()=>{var w;const l=(w=c.snapshot)==null?void 0:w.incarnation,m=c.binding;return l&&m?Object.freeze({incarnation:Object.freeze({...l}),current:()=>m.current("read")}):void 0},[(d=c.snapshot)==null?void 0:d.incarnation,c.binding]);return{channel:a,events:c.events,frameAdmission:c.frameAdmission,fileSaveBinding:i,fileSaveObservation:s.documentId!==e||s.transport!==t||s.pending?"pending":c.available&&((u=c.binding)!=null&&u.verified)&&((f=c.snapshot)!=null&&f.incarnation)?"ready":"unavailable"}}function go({content:e}){const[t]=Mt();return t?h.jsx("div",{className:"h-full w-full",children:h.jsx(qn,{sessionId:t,serverName:e.serverName,uri:e.uri,title:e.title})}):null}const vo=p.lazy(()=>Re(()=>import("./CanvasFileContent-DZf9SjJn.js"),__vite__mapDeps([6,1,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])).then(e=>({default:e.CanvasFileContent}))),bo=p.lazy(()=>Re(()=>import("./CanvasModel3dContent-Cd8hf6Ba.js"),__vite__mapDeps([23,1,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])).then(e=>({default:e.CanvasModel3dContent}))),wo=p.lazy(()=>Re(()=>import("./CanvasCsvContent-DzkaHpEo.js"),__vite__mapDeps([24,1,2,25,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])).then(e=>({default:e.CanvasCsvContent}))),xo=p.lazy(()=>Re(()=>import("./index-fge85Gub.js").then(e=>e.vA),__vite__mapDeps([1,2])).then(e=>({default:e.CanvasDiffContent})));function Lo({documentId:e,widgetChannel:t,content:r,onContentChange:n}){switch(r.type){case"url":case"browser":return h.jsx(_s,{documentId:e,content:r},`${e}:${r.url}`);case"markdown":return h.jsx(ii,{documentId:e,content:r,onContentChange:n},r.sourcePath??"generated");case"json":return h.jsx(oi,{content:r});case"image":return h.jsx(fi,{content:r});case"pdf":return h.jsx(pi,{content:r});case"audio":return h.jsx(vi,{content:r});case"video":return h.jsx(bi,{content:r});case"widget":return t?h.jsx(Lr,{content:r,documentId:e,channel:t}):h.jsx(yo,{documentId:e,content:r});case"mcp_app":return h.jsx(go,{content:r});case"file":return h.jsx(p.Suspense,{fallback:h.jsx(tt,{}),children:h.jsx(vo,{documentId:e,content:r})});case"model3d":return h.jsx(p.Suspense,{fallback:h.jsx(tt,{}),children:h.jsx(bo,{content:r})});case"csv":return h.jsx(p.Suspense,{fallback:h.jsx(tt,{}),children:h.jsx(wo,{content:r})});case"diff":return h.jsx(p.Suspense,{fallback:h.jsx(tt,{}),children:h.jsx(xo,{documentId:e,content:r},r.sourcePath)})}}function tt(){return h.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"})}function yo({documentId:e,content:t}){const{channel:r}=mo(e);return h.jsx(Lr,{documentId:e,content:t,channel:r})}const ko=p.lazy(()=>Re(()=>import("./BlintzCanvas-BFJXKo1L.js").then(e=>e.B),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.BlintzCanvas})));function qo({roomId:e,document:t,content:r,onSave:n}){const[s,o]=p.useState(null),[c,a]=p.useState(!1),[i,d]=p.useState(null),u=s!==null,f=r.sourcePath===void 0;ls(e,u?t.id:null);const l=async()=>{if(s===null)return;if(s===r.content){o(null),d(null);return}a(!0),d(null);const m=await n(t.id,{...r,content:s});a(!1),m?o(null):d("Couldn’t save. Your words are still here. Try again.")};return h.jsxs("div",{className:"flex h-full flex-col",children:[f&&h.jsxs("div",{className:"flex items-center justify-end gap-2 border-b px-2 py-1",children:[u&&h.jsx("span",{className:"text-muted-foreground text-xs",children:c?"Saving…":"Everyone sees your save."}),h.jsx(rt,{type:"button",size:"xs",variant:"ghost",disabled:c,"aria-label":u?"Save for the room":"Edit this document",onClick:()=>u?void l():o(r.content),children:u?h.jsx(jr,{className:"size-3.5"}):h.jsx(Cr,{className:"size-3.5"})})]}),i!==null&&h.jsx("p",{role:"status",className:"text-destructive border-b px-2 py-1 text-xs",children:i}),h.jsx("div",{className:"flex-1 px-2 pb-6",children:h.jsx(p.Suspense,{fallback:h.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"}),children:h.jsx(ko,{value:s??r.content,editable:u,onChange:o},u?"editing":`rev-${t.rev}`)})})]})}const Ft="dorkos-canvas-sessions",jo=1440*60*60*1e3;function Xr(){try{const e=localStorage.getItem(Ft);if(!e)return null;const t=JSON.parse(e);return t===null||typeof t!="object"?null:t}catch{return null}}function Zr(e){try{Object.keys(e).length===0?localStorage.removeItem(Ft):localStorage.setItem(Ft,JSON.stringify(e))}catch{}}function Co(e){return Array.isArray(e.documents)?[...e.documents].sort((t,r)=>(t.openedAt??0)-(r.openedAt??0)).map(t=>t.content).filter(t=>!!t):e.content?[e.content]:[]}function dt(e){return e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?`[${e.map(dt).join(",")}]`:`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${JSON.stringify(r)}:${dt(n)}`).join(",")}}`}function Oo(e,t){const r=new Set,n=new Map;for(const o of e){const c=er(o.content);if(c!==null){r.add(c);continue}const a=dt(o.content);n.set(a,(n.get(a)??0)+1)}const s=[];for(const o of t){const c=er(o);if(c!==null){r.has(c)||s.push(o);continue}const a=dt(o),i=n.get(a)??0;i>0?n.set(a,i-1):s.push(o)}return s}const st=new Set;function Po(){st.clear()}function Bo(e,t={}){const r=oe(),n=t.canonical??!0;p.useEffect(()=>{e&&V.getState().loadCanvasForSession(e)},[e]),p.useEffect(()=>{if(!e||!n||st.has(e))return;const s=Xr();if(!s)return;const o=s[e];if(!o){Ro(s);return}st.add(e),(async()=>{try{const c=Co(o),a=Oo(await r.listSessionCanvas(e),c);if(a.length===0){xr(e);return}for(const i of a)await r.openSessionCanvasDocument(e,i);xr(e),V.getState().hydrateCanvasFromSnapshot(e,await r.listSessionCanvas(e))}catch{st.delete(e)}})()},[e,n,r])}function xr(e){const t=Xr();if(!t)return;const{[e]:r,...n}=t;Zr(n)}function Ro(e){const t=Date.now()-jo,r=Object.entries(e).filter(([,n])=>n.accessedAt===void 0||n.accessedAt>=t);r.length!==Object.keys(e).length&&Zr(Object.fromEntries(r))}export{Lo as C,Fo as F,qo as R,Js as a,mo as b,us as c,cs as d,Mo as e,Lr as f,Po as g,ss as h,Ar as i,Bo as j,Mr as r,ti as u};