dorkos 0.121.0 → 0.123.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +532 -373
- package/dist/browser/native/package-manifest.json +1 -1
- package/dist/browser/source-manifest.json +1 -1
- package/dist/client/assets/{AboutPage-CtI8gbER.js → AboutPage-BmtoPqP9.js} +1 -1
- package/dist/client/assets/{ActivityErrorState-CHTXfBS7.js → ActivityErrorState-CEzdFJiR.js} +1 -1
- package/dist/client/assets/{ActivityPage-B8p4yYJL.js → ActivityPage-mFYgTr3e.js} +1 -1
- package/dist/client/assets/{ActivityRow-CSuSz-92.js → ActivityRow-Bkc0kkim.js} +1 -1
- package/dist/client/assets/{AdapterIcon-Qnxn0cE5.js → AdapterIcon-DVgTrgnM.js} +1 -1
- package/dist/client/assets/{AdapterSetupWizard-BG8H-Lld.js → AdapterSetupWizard-I03EluU5.js} +1 -1
- package/dist/client/assets/{AgentOptionRow-BWFQFynn.js → AgentOptionRow-DI1TzLaR.js} +1 -1
- package/dist/client/assets/{AgentPicker-CL93SET3.js → AgentPicker-CBYeBzjf.js} +1 -1
- package/dist/client/assets/{AgentRequestCard-CamX7Tvr.js → AgentRequestCard-DQ6GYoeE.js} +3 -3
- package/dist/client/assets/{AppearancePage-rN70_7ih.js → AppearancePage-62xIPNPn.js} +1 -1
- package/dist/client/assets/{ApplyToOverridesDialog-DeWaXbgm.js → ApplyToOverridesDialog-CrqkeHQb.js} +1 -1
- package/dist/client/assets/{AttentionSignalRow-CKcSWExi.js → AttentionSignalRow-Coe5pYX6.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-BwYaLf2P.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-D07cg75s.js} +1 -1
- package/dist/client/assets/{BindingDialog-DqPDLYbF.js → BindingDialog-DVyxVXZM.js} +1 -1
- package/dist/client/assets/{BlintzCanvas-DoAZs5bz.js → BlintzCanvas-BmfkiUQJ.js} +3 -3
- package/dist/client/assets/{BlintzCanvas-xZ3u3nk7.css → BlintzCanvas-DCXOV_yN.css} +1 -1
- package/dist/client/assets/{CanvasCsvContent-ViqRJuhW.js → CanvasCsvContent-CRTr-AI7.js} +2 -2
- package/dist/client/assets/CanvasFileContent-rOmY1s3T.js +2 -0
- package/dist/client/assets/CanvasModel3dContent-D7oRT6ey.js +2 -0
- package/dist/client/assets/{ChatAppsOff-D0PbHYqF.js → ChatAppsOff-BmuOTq83.js} +1 -1
- package/dist/client/assets/{CodeMirrorDiff-DFNSXeuV.js → CodeMirrorDiff-DidSWwYJ.js} +1 -1
- package/dist/client/assets/{CodeMirrorEditor-AgkgsSqN.js → CodeMirrorEditor-BUAWGbRo.js} +1 -1
- package/dist/client/assets/{CommitmentList-0V6QivXH.js → CommitmentList-uK4CKaz0.js} +1 -1
- package/dist/client/assets/{CommitmentsPage-i3XoHwBj.js → CommitmentsPage-BWITH1r2.js} +1 -1
- package/dist/client/assets/{ComputerResourceView-RPoBc-km.js → ComputerResourceView-adgF_EZU.js} +1 -1
- package/dist/client/assets/{ComputerViewer-2ugaCd0H.js → ComputerViewer-D87LhxwL.js} +1 -1
- package/dist/client/assets/{ConnectionAccessLists-DaPP4U96.js → ConnectionAccessLists-BFEFqcSZ.js} +1 -1
- package/dist/client/assets/{ConnectionsPage-BVqYvfk5.js → ConnectionsPage-Cd_cLoSY.js} +1 -1
- package/dist/client/assets/{ConventionPage-BoqncrFd.js → ConventionPage-BSztD-gU.js} +1 -1
- package/dist/client/assets/{ExtensionPageRoute-BrOEeNX3.js → ExtensionPageRoute-BSge6XRv.js} +1 -1
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-DLwix3K7.js → FloatingTanStackRouterDevtools-CqogiFob-TO2CUPG0.js} +1 -1
- package/dist/client/assets/HandlePage-BKiqymRF.js +1 -0
- package/dist/client/assets/{HeartbeatPage-DgXhbaBJ.js → HeartbeatPage-DIJzdOhj.js} +1 -1
- package/dist/client/assets/{KeyEntry-CRr32Ae5.js → KeyEntry-DJnzW3Mu.js} +1 -1
- package/dist/client/assets/{LexicalField-DeAoA6yr.js → LexicalField-BxzNvIjJ.js} +1 -1
- package/dist/client/assets/{ManagesPage-ZBWYLTZx.js → ManagesPage-BQj8KbYA.js} +1 -1
- package/dist/client/assets/{Marketplace-iL5p8Omt.js → Marketplace-CIG5_a_H.js} +4 -4
- package/dist/client/assets/{MarketplaceSourcesView-CsNLVOdP.js → MarketplaceSourcesView-16HKvFK-.js} +1 -1
- package/dist/client/assets/{McpAppFrame-B1WPswgk.js → McpAppFrame-5xlga1jD.js} +1 -1
- package/dist/client/assets/{McpSigninBody-CJ28yu0o.js → McpSigninBody-COIHpHq_.js} +1 -1
- package/dist/client/assets/{Model3dViewer-BIZWdK8g.js → Model3dViewer-CQ0sA_kr.js} +1 -1
- package/dist/client/assets/NamePage-D7W6VMYd.js +1 -0
- package/dist/client/assets/{NewDirectMessageMenu-DRx9e9kM.js → NewDirectMessageMenu-D092y0K9.js} +1 -1
- package/dist/client/assets/{NotificationsPage-cfqgSuVy.js → NotificationsPage-CskOPdhh.js} +1 -1
- package/dist/client/assets/{OpenMeshSwitch-BIIuKDku.js → OpenMeshSwitch-BHRm328L.js} +1 -1
- package/dist/client/assets/{OperatorIdentityForm-BKUSGrs6.js → OperatorIdentityForm-C3op6BIC.js} +1 -1
- package/dist/client/assets/{PermissionHistory-Ctdqhib6.js → PermissionHistory-CKebTVkq.js} +1 -1
- package/dist/client/assets/{PermissionsPage-CYA_zdrV.js → PermissionsPage-XuPOSYll.js} +1 -1
- package/dist/client/assets/{PersonalityPopover-BR4Cpr2C.js → PersonalityPopover-BrZjxakx.js} +1 -1
- package/dist/client/assets/PhotoPage-Ch1at4A6.js +1 -0
- package/dist/client/assets/{PreviewRefusedNotice-D1Tl265t.js → PreviewRefusedNotice-BANdpT9O.js} +1 -1
- package/dist/client/assets/{ProfileFields-T3vVbHRC.js → ProfileFields-Dp68ebW9.js} +1 -1
- package/dist/client/assets/{ProfilePanelContainer-CParzTPA.js → ProfilePanelContainer-BKwGdI90.js} +1 -1
- package/dist/client/assets/{ProfileRolePicker-BU4eiMKn.js → ProfileRolePicker-ClOdfLda.js} +1 -1
- package/dist/client/assets/{PromptSuggestionChips-CGNQc2Tf.js → PromptSuggestionChips-zcW4UJ_O.js} +1 -1
- package/dist/client/assets/{ReportsToPopover-Dj5U_Ppi.js → ReportsToPopover-BwDVGqFg.js} +1 -1
- package/dist/client/assets/RoomSurface-CSKIvyHH.js +44 -0
- package/dist/client/assets/{RoomsPage-Cvs3h6f0.js → RoomsPage-CAvrRbPk.js} +1 -1
- package/dist/client/assets/{RunsOnPopover-BUlYwRW4.js → RunsOnPopover-CQ4t9EZ-.js} +1 -1
- package/dist/client/assets/{RuntimeConnectFlow-ChrvjC84.js → RuntimeConnectFlow--fVpIf0B.js} +1 -1
- package/dist/client/assets/{RuntimeSetupDialog-BK9yo7YF.js → RuntimeSetupDialog-COpyPrqL.js} +1 -1
- package/dist/client/assets/SeenDevices-BPw3UgjX.js +19 -0
- package/dist/client/assets/{SessionsPage-CWUwU3US.js → SessionsPage-FDyYzuXs.js} +1 -1
- package/dist/client/assets/{SettingsDialog-BApzy0J8.js → SettingsDialog-Bdws5dbS.js} +4 -4
- package/dist/client/assets/{SkillsPage-z3XnApNX.js → SkillsPage-PLXEY0LB.js} +1 -1
- package/dist/client/assets/{TaskDialogWrapper-BEWUpAlk.js → TaskDialogWrapper-CTcW70s8.js} +1 -1
- package/dist/client/assets/{TasksEmptyState-CLwpLnIO.js → TasksEmptyState-8RZxhRh6.js} +1 -1
- package/dist/client/assets/{TasksPage-CyHjr9OZ.js → TasksPage-C-EtQXKb.js} +1 -1
- package/dist/client/assets/{TeamComputerEntry-BHHIofx3.js → TeamComputerEntry-qx_19Htj.js} +1 -1
- package/dist/client/assets/{ToolsPage-CckCco8x.js → ToolsPage-D5-fx1EA.js} +1 -1
- package/dist/client/assets/{TopologyGraph-Dox7aWP3.js → TopologyGraph-1wtG1BE9.js} +1 -1
- package/dist/client/assets/{TourHost-CTBewD-a.js → TourHost-C664E8OY.js} +1 -1
- package/dist/client/assets/{UnlinkDialog-CFRgExId.js → UnlinkDialog-Di1oBFA_.js} +1 -1
- package/dist/client/assets/{WidgetErrorCard-Dx5oPMlF.js → WidgetErrorCard-BfgGzyqg.js} +1 -1
- package/dist/client/assets/_shell-BLTSXXDw.js +80 -0
- package/dist/client/assets/{_shell._home-DnBkgWs4.js → _shell._home-Hz78BY6-.js} +1 -1
- package/dist/client/assets/{_shell._home.activity-CVCC-EEI.js → _shell._home.activity-BxvI0gkw.js} +1 -1
- package/dist/client/assets/{_shell._home.index-Ck6jxwIx.js → _shell._home.index-Cqq81f3P.js} +1 -1
- package/dist/client/assets/{_shell._home.tasks-B7QQAZnA.js → _shell._home.tasks-Cth56CwC.js} +1 -1
- package/dist/client/assets/{_shell._home.workspaces-DlrRd9tv.js → _shell._home.workspaces-DkoOJSWz.js} +1 -1
- package/dist/client/assets/{_shell.channels-CiWehoyl.js → _shell.channels-D_GQU4RB.js} +4 -4
- package/dist/client/assets/{_shell.connections-CGP5hZHq.js → _shell.connections-DZrlxs4G.js} +1 -1
- package/dist/client/assets/{_shell.feedback-requests-BxxNvw6j.js → _shell.feedback-requests-BTxHdsfb.js} +1 -1
- package/dist/client/assets/_shell.marketplace-CZxkAmFz.js +1 -0
- package/dist/client/assets/_shell.marketplace_.sources-Q0BTQIuE.js +1 -0
- package/dist/client/assets/_shell.session-DvGL0DoX.js +63 -0
- package/dist/client/assets/{_shell.team-CsXH3NkS.js → _shell.team-ZxGwa39m.js} +3 -3
- package/dist/client/assets/_shell.x._extensionId-B6Tm5KuT.js +1 -0
- package/dist/client/assets/_shell.x._extensionId_._-B6Tm5KuT.js +1 -0
- package/dist/client/assets/{abnfDiagram-WEYOIA3C-CMdkyiQ3.js → abnfDiagram-WEYOIA3C-CzqPVMdw.js} +1 -1
- package/dist/client/assets/{access-copy-CW-z1oMH.js → access-copy-Dj09Xk4b.js} +1 -1
- package/dist/client/assets/{arc-Bw7tftQk.js → arc-Bgy7ExYl.js} +1 -1
- package/dist/client/assets/{architectureDiagram-ZHVYKT53-BhpXALtX.js → architectureDiagram-ZHVYKT53-DYfb2p9r.js} +1 -1
- package/dist/client/assets/{banner-EomQNDOH.js → banner-dlsHTWSf.js} +1 -1
- package/dist/client/assets/{blockDiagram-RJAE7QA3-Bxk_BuZv.js → blockDiagram-RJAE7QA3-BkOzLL8s.js} +1 -1
- package/dist/client/assets/{c4Diagram-XDPPPE54-CYN0FwR8.js → c4Diagram-XDPPPE54-CsZm4qpD.js} +1 -1
- package/dist/client/assets/{card-ww4ebz8h.js → card-Dj6ZfRgu.js} +1 -1
- package/dist/client/assets/channel-CGffcDRq.js +1 -0
- package/dist/client/assets/{chunk-2E7WHVMD-IPDvYcPa.js → chunk-2E7WHVMD-GA96Jfps.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-DZ5bU5Ax.js → chunk-2Q5K7J3B-CW2i0IkT.js} +1 -1
- package/dist/client/assets/{chunk-4EMNKR2T-DrsWxa6Y.js → chunk-4EMNKR2T-BwFvnPZg.js} +1 -1
- package/dist/client/assets/{chunk-55XCU76K-CiBbKG0b.js → chunk-55XCU76K-MOezzAAB.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-B3K3MUav.js → chunk-5VM5RSS4-woru6zOC.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-CjV5RcIh.js → chunk-JWPE2WC7-CUrKlP2M.js} +1 -1
- package/dist/client/assets/{chunk-VQ5W62QI-CWoRr0H2.js → chunk-VQ5W62QI-CqZ2cdEu.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-E0nvzXiG.js → chunk-XXDRQBXY-ByAcvWaE.js} +1 -1
- package/dist/client/assets/{chunk-ZCHMQSOR-DFop6Lvt.js → chunk-ZCHMQSOR-3nkba9kj.js} +2 -2
- package/dist/client/assets/{classDiagram-v2-4MYWR3UA-B7JJfc9z.js → classDiagram-v2-4MYWR3UA-B-zZKAmI.js} +1 -1
- package/dist/client/assets/{command-D4fLpJxA.js → command-BAOEURY7.js} +1 -1
- package/dist/client/assets/{cose-bilkent-JH36ORCC-BjNppl29.js → cose-bilkent-JH36ORCC-sCKxRv1H.js} +1 -1
- package/dist/client/assets/{cpu-DCe0Yyml.js → cpu-TtYQqONc.js} +1 -1
- package/dist/client/assets/{cynefin-EF2NZ3EQ-PmRntJwW.js → cynefin-EF2NZ3EQ-CXzvL5Cg.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-WF24UDRP-Ctdbp_Vg.js → cynefinDiagram-WF24UDRP-C0wjhu9X.js} +1 -1
- package/dist/client/assets/{dagre-NK4GIZVX-5tvLY2ZW.js → dagre-NK4GIZVX-Doi2IPkY.js} +1 -1
- package/dist/client/assets/{diagram-CBK3MWTC-DZO-XBOO.js → diagram-CBK3MWTC-11TVuPel.js} +1 -1
- package/dist/client/assets/{diagram-I5XIIV2D-CWBbA1Pv.js → diagram-I5XIIV2D-CJq7fHFM.js} +1 -1
- package/dist/client/assets/{diagram-ODIL2UCW-hP5A1tGl.js → diagram-ODIL2UCW-2Ae6unuU.js} +1 -1
- package/dist/client/assets/{diagram-PFBEJUXE-EI_-RoN7.js → diagram-PFBEJUXE-BXza6_iz.js} +1 -1
- package/dist/client/assets/{diagram-RJA3I4VV-TrYq9A4Z.js → diagram-RJA3I4VV-Z0i3uBW9.js} +1 -1
- package/dist/client/assets/{diagram-TYUNFSNR-BAQq2OM5.js → diagram-TYUNFSNR-Dq_-g1oP.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-V4P3TTPT-cKbeW9dQ.js → ebnfDiagram-V4P3TTPT-vxzIvg-W.js} +1 -1
- package/dist/client/assets/{elk-QONTBCTQ-wpfNPp0q.js → elk-QONTBCTQ-BBIXXtg_.js} +1 -1
- package/dist/client/assets/{empty-state-DXWQsHMf.js → empty-state-kISAAp0z.js} +1 -1
- package/dist/client/assets/{erDiagram-KYQIGQAA-Dk0OrvjE.js → erDiagram-KYQIGQAA-Bk2MeLBx.js} +1 -1
- package/dist/client/assets/{execution-config-CAyT2Qoo.js → execution-config-DYFe-VNC.js} +1 -1
- package/dist/client/assets/{file-Bf7D_47y.js → file-DEt4KgZG.js} +1 -1
- package/dist/client/assets/{file-exclamation-point-DZXE9_8o.js → file-exclamation-point-QqXJhXD9.js} +1 -1
- package/dist/client/assets/{file-text-C1ougnBY.js → file-text-CRw31ZWd.js} +1 -1
- package/dist/client/assets/{find-latest-widget-fence-B1_-pC-Z.js → find-latest-widget-fence-B3aaiBNI.js} +1 -1
- package/dist/client/assets/{flowDiagram-IUGLLWBU-CdlOoRZV.js → flowDiagram-IUGLLWBU-B53m4r8u.js} +1 -1
- package/dist/client/assets/{form-D7kF-U0d.js → form-Bjhk9zOn.js} +1 -1
- package/dist/client/assets/{format-cron-ZtliseYi.js → format-cron-9tmNIcgl.js} +1 -1
- package/dist/client/assets/{ganttDiagram-R7GPNTJY-x0MJLv5d.js → ganttDiagram-R7GPNTJY-CS6TN3R1.js} +1 -1
- package/dist/client/assets/{git-branch-B2k77X3Q.js → git-branch-DWerghmw.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-CruCvk7w.js → gitGraphDiagram-PDYL7XHY-D096ZtqE.js} +1 -1
- package/dist/client/assets/{graph-5PBe05F8.js → graph-DQpTuPmX.js} +1 -1
- package/dist/client/assets/{heart-CmqGJPDc.js → heart-CRkjVW7-.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-Bqu2cQDj.js → highlighted-body-KPVGNVTW-DoVCXOMU.js} +1 -1
- package/dist/client/assets/{image-lightbox-BBbz-ThL.js → image-lightbox-BXzbN27o.js} +1 -1
- package/dist/client/assets/{image-off-BCtWIY4q.js → image-off-VyMBVwgK.js} +1 -1
- package/dist/client/assets/{index-8IAr9b71.js → index-1qv8ldHx.js} +1 -1
- package/dist/client/assets/{index-ClBIPuLA.js → index-2EaVZrJe.js} +1 -1
- package/dist/client/assets/{index-DcZPWi_I.js → index-8-iQ6PnT.js} +252 -247
- package/dist/client/assets/{index-CJ5v2_Cz.js → index-B2rBVMNl.js} +1 -1
- package/dist/client/assets/{index-BpmmNapD.js → index-BBcAekWE.js} +1 -1
- package/dist/client/assets/index-BFitbVs4.js +1 -0
- package/dist/client/assets/{index-xmk9Ohv9.js → index-BLkXoquZ.js} +1 -1
- package/dist/client/assets/{index-xaMF1mrN.js → index-BcFMs7lK.js} +1 -1
- package/dist/client/assets/{index-EdJm7ZN-.js → index-BiFJIg4n.js} +1 -1
- package/dist/client/assets/{index-BuGQxHrf.js → index-BpjEclkM.js} +1 -1
- package/dist/client/assets/{index-CtycM8wY.js → index-C24HfJir.js} +1 -1
- package/dist/client/assets/{index-DAdo_yIq.js → index-C3sW6rkN.js} +1 -1
- package/dist/client/assets/{index-JxeBJIuE.js → index-C6Fo2htT.js} +1 -1
- package/dist/client/assets/{index-B5rRtvWx.js → index-C6udJCgz.js} +1 -1
- package/dist/client/assets/{index-ChwNEkM8.js → index-CDuYKaGY.js} +1 -1
- package/dist/client/assets/{index-Cml5572f.js → index-CEVwhauU.js} +1 -1
- package/dist/client/assets/index-CI84yP-g.js +1 -0
- package/dist/client/assets/{index-BzPgsdPn.js → index-COMRALJO.js} +1 -1
- package/dist/client/assets/index-CiVeycsn.js +17 -0
- package/dist/client/assets/{index-BXZlDqvy.js → index-Cs3WB8yn.js} +1 -1
- package/dist/client/assets/{index-BrQGZ6iF.js → index-Csr_C1sk.js} +1 -1
- package/dist/client/assets/{index-CMNc_OrC.js → index-Ctqe81qr.js} +1 -1
- package/dist/client/assets/{index-Dmn03xST.js → index-CvhR1oZB.js} +1 -1
- package/dist/client/assets/{index-B6dEbNhI.js → index-CyGRWyhV.js} +1 -1
- package/dist/client/assets/{index-mFOJXyAE.js → index-Czm6C7FZ.js} +3 -3
- package/dist/client/assets/{index-1ShgR_xt.js → index-D5zUdnZM.js} +1 -1
- package/dist/client/assets/{index-Cv0GsC4n.js → index-DBo2XfNv.js} +1 -1
- package/dist/client/assets/{index-DIxzqCwG.js → index-DKWpwwxo.js} +1 -1
- package/dist/client/assets/{index-BXMxoWrk.js → index-DN2sTT2U.js} +1 -1
- package/dist/client/assets/index-DNzk9m1D.js +23 -0
- package/dist/client/assets/{index-CrflCTqO.css → index-DUZrTFYD.css} +1 -1
- package/dist/client/assets/{index-t4Ud6YTX.js → index-DX_2Mxwv.js} +1 -1
- package/dist/client/assets/{index-C11Ssk2u.js → index-Dgrk2udV.js} +2 -2
- package/dist/client/assets/{index-BCk4wW-T.js → index-DgyhdQnI.js} +1 -1
- package/dist/client/assets/{index-CQ0VLZf-.js → index-DmFNztTX.js} +1 -1
- package/dist/client/assets/{index-rWZWP3Wh.js → index-TnoaFCrj.js} +1 -1
- package/dist/client/assets/{index-DbDI5BAA.js → index-_emDKzsu.js} +1 -1
- package/dist/client/assets/{index-BIIH5CXj.js → index-b9p_y2Ql.js} +1 -1
- package/dist/client/assets/{index-yI1r4pSP.js → index-gIQ7FrL9.js} +1 -1
- package/dist/client/assets/{index-DsJWzmWw.js → index-igLqtuoO.js} +1 -1
- package/dist/client/assets/{index-Do6eeFps.js → index-n3-zWcH-.js} +2 -2
- package/dist/client/assets/{index-8TfzCkKR.js → index-rCvQat0D.js} +1 -1
- package/dist/client/assets/{index-BfRW2WTx.js → index-setKr4xl.js} +1 -1
- package/dist/client/assets/{index-DrA03bMq.js → index-t3eRSGcT.js} +1 -1
- package/dist/client/assets/{index.esm-CZZtbPRj.js → index.esm-bLeQzVWT.js} +1 -1
- package/dist/client/assets/{infoDiagram-MVDRKAX5-Bj9DD77n.js → infoDiagram-MVDRKAX5-nN_N76Fn.js} +1 -1
- package/dist/client/assets/{inline-code-g9PVHZI2.js → inline-code-D9bLKHjY.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-DckI6dhS.js → ishikawaDiagram-HPEHV2GE-CiLFbWXd.js} +1 -1
- package/dist/client/assets/{journeyDiagram-BOSHW7O7-Ce1GAVa0.js → journeyDiagram-BOSHW7O7-Dn3yOv96.js} +1 -1
- package/dist/client/assets/{kanban-definition-FNSA4HC5-Kq5O9rZa.js → kanban-definition-FNSA4HC5-JxiBdBQC.js} +1 -1
- package/dist/client/assets/{layers-D3lEdRF0.js → layers-DTnLoRvE.js} +1 -1
- package/dist/client/assets/{lightbulb-BFE-KkFU.js → lightbulb-CRKLr5q3.js} +1 -1
- package/dist/client/assets/{link-2-Dvb6g-2Q.js → link-2-hgHg-lyw.js} +1 -1
- package/dist/client/assets/{list-runtime-types-8YGEK3Al.js → list-runtime-types-Bb33QiMC.js} +1 -1
- package/dist/client/assets/{markdown-content-Cqq_QMXA.js → markdown-content-D0FpU2cz.js} +1 -1
- package/dist/client/assets/{mention-pill-Bnzt4u2l.js → mention-pill-uuaUvwSW.js} +1 -1
- package/dist/client/assets/{mermaid.core-dpp59v7L.js → mermaid.core-x3Hh6iut.js} +4 -4
- package/dist/client/assets/{message-square-off-BX2XnEDx.js → message-square-off-B8N6YF9R.js} +1 -1
- package/dist/client/assets/{mindmap-definition-6OY57UG3-CFdfJO6g.js → mindmap-definition-6OY57UG3-D0SEv5Re.js} +1 -1
- package/dist/client/assets/{more-details-B4lBMpKi.js → more-details-CadxnGyH.js} +1 -1
- package/dist/client/assets/{owner-notice-ByjrIRmX.js → owner-notice-CJHyha58.js} +1 -1
- package/dist/client/assets/{package-6Rbxg35g.js → package-B8G7jQm-.js} +1 -1
- package/dist/client/assets/{page-container-DoZzad36.js → page-container-Bb-_N7lw.js} +1 -1
- package/dist/client/assets/{paperclip-B-jDXtxw.js → paperclip-BDeYGKqh.js} +1 -1
- package/dist/client/assets/{path-input-DpqUD8hN.js → path-input-BIfexEKz.js} +1 -1
- package/dist/client/assets/{pegDiagram-ECIUJNBX-eVnSw2Ma.js → pegDiagram-ECIUJNBX-7ivMd0-b.js} +1 -1
- package/dist/client/assets/{pieDiagram-GNMPY74T-BYG7LY5Q.js → pieDiagram-GNMPY74T-DGDkbFvu.js} +1 -1
- package/dist/client/assets/{plug-DnaAhcy4.js → plug-wP1d6OUX.js} +1 -1
- package/dist/client/assets/{primer-trigger-Da5ECjY8.js → primer-trigger-CEli_z4n.js} +1 -1
- package/dist/client/assets/{profile-errors-GbTNc2-M.js → profile-errors-C1qSJkiG.js} +1 -1
- package/dist/client/assets/{progress-DlIRjXIA.js → progress-DmUieXLn.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-D57K4MC3-CRgNKuHR.js → quadrantDiagram-D57K4MC3-AFQRVSsK.js} +1 -1
- package/dist/client/assets/{query-error-state-DB-Jby7_.js → query-error-state--8AnWSSn.js} +1 -1
- package/dist/client/assets/query-keys-DeYqUDia.js +1 -0
- package/dist/client/assets/{radio-CaaE60ws.js → radio-mkA-Sqe0.js} +1 -1
- package/dist/client/assets/{railroadDiagram-Y72NRBL7-DGL-Hqz9.js → railroadDiagram-Y72NRBL7-3QBa2d3j.js} +1 -1
- package/dist/client/assets/registry-Bnd-HFt3.js +1 -0
- package/dist/client/assets/{relay-trace-schemas-CcCqyOrA.js → relay-trace-schemas-fScydQ3A.js} +1 -1
- package/dist/client/assets/{requirementDiagram-EQYSW5RA-DKsFpU3l.js → requirementDiagram-EQYSW5RA-BVBqcASy.js} +1 -1
- package/dist/client/assets/{room-files-source-CbbVpvSW.js → room-files-source-BhkPUTiP.js} +1 -1
- package/dist/client/assets/{rotate-ccw-clock-CeY00nlZ.js → rotate-ccw-clock-DiuTseKz.js} +1 -1
- package/dist/client/assets/{rotate-cw-Djl5J_x9.js → rotate-cw-DvoxWwSx.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-SY24JHO5-BFRkDxic.js → sankeyDiagram-SY24JHO5-DFjfOD38.js} +1 -1
- package/dist/client/assets/{scroll-area-BOqrziJf.js → scroll-area-DYyyRqW_.js} +1 -1
- package/dist/client/assets/{search-x-B_mHjnlo.js → search-x-CA-FzEqZ.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-BLEHNHQU-fHea3KOI.js → sequenceDiagram-BLEHNHQU-Cr9LzoSF.js} +1 -1
- package/dist/client/assets/{shield-check-Csnr5rFy.js → shield-check-CpUB_Ju1.js} +1 -1
- package/dist/client/assets/{shield-x-Dhl4YvvW.js → shield-x-B0W_7qwR.js} +1 -1
- package/dist/client/assets/{signed-in-BMqAss8c.js → signed-in-X2utDqQS.js} +1 -1
- package/dist/client/assets/{sizeCapture-INFHLROL-CztsD3qF.js → sizeCapture-INFHLROL-Do_jfNyT.js} +1 -1
- package/dist/client/assets/{soul-file-DOfamgB5.js → soul-file-DgfhKQIK.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-CWyOqZ9S.js → stateDiagram-v2-A6IESKWZ-BCi9yk_0.js} +1 -1
- package/dist/client/assets/{swimlanes-B3ENRKFQ-0EfOxSAX.js → swimlanes-B3ENRKFQ-3SSAw2av.js} +1 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-jpZCGfva.js +8 -0
- package/dist/client/assets/{table-L7FvN6Or.js → table-DvU_oS4E.js} +1 -1
- package/dist/client/assets/{terminal-C9M5a_PS.js → terminal-Dw2QZ7Dh.js} +1 -1
- package/dist/client/assets/{timeline-definition-JXYKGLGB-sFyYvZ20.js → timeline-definition-JXYKGLGB-DTLPXTMA.js} +1 -1
- package/dist/client/assets/{trust-posture-dl6qwDtI.js → trust-posture-2MR0ap9o.js} +1 -1
- package/dist/client/assets/{unplug-CFUEVRbc.js → unplug-CAVOLB2R.js} +1 -1
- package/dist/client/assets/{unverified-catalog-notice-CdYU3WEJ.js → unverified-catalog-notice-u4ikVg8J.js} +1 -1
- package/dist/client/assets/{use-adapter-catalog-YTofdqDJ.js → use-adapter-catalog-BQKfRxXC.js} +1 -1
- package/dist/client/assets/{use-bindings-CpyT6kNu.js → use-bindings-BV6HA0MD.js} +1 -1
- package/dist/client/assets/{use-composer-prefs-CK_EK_QJ.js → use-composer-prefs-DCSzOnEO.js} +1 -1
- package/dist/client/assets/{use-connector-management-DwoK8kon.js → use-connector-management-fr1tx-GZ.js} +1 -1
- package/dist/client/assets/{use-deep-link-scroll-CgRjt48R.js → use-deep-link-scroll-v02TbidQ.js} +1 -1
- package/dist/client/assets/{use-delete-binding-CfsnMXrL.js → use-delete-binding-CnziYpXo.js} +1 -1
- package/dist/client/assets/{use-dev-links-B3I-ZK34.js → use-dev-links-k4YWFO1v.js} +1 -1
- package/dist/client/assets/{use-external-adapter-catalog-aGlZNRrp.js → use-external-adapter-catalog-DoGUfa2F.js} +1 -1
- package/dist/client/assets/{use-full-activity-feed-B61Olhdw.js → use-full-activity-feed-CQNxgxnw.js} +1 -1
- package/dist/client/assets/use-is-below-desktop-DR8FEbRW.js +1 -0
- package/dist/client/assets/use-is-hub-BmpgFnFp.js +1 -0
- package/dist/client/assets/{use-jump-back-in-C39GOTHa.js → use-jump-back-in-BuO6A0P7.js} +1 -1
- package/dist/client/assets/{use-local-browser-DCwzB4D8.js → use-local-browser-BNzN5O1P.js} +1 -1
- package/dist/client/assets/{use-mesh-topology-LRYxFuZp.js → use-mesh-topology-CpIDE8lD.js} +1 -1
- package/dist/client/assets/{use-mounted-ref-CZaegwTr.js → use-mounted-ref-BAO3qunF.js} +1 -1
- package/dist/client/assets/{use-notification-prefs-FtOiUS5H.js → use-notification-prefs-CtqeH5Pk.js} +1 -1
- package/dist/client/assets/{use-panel-tab-placements-Dv2OPvKh.js → use-panel-tab-placements-DFobGBRm.js} +1 -1
- package/dist/client/assets/use-pending-read-Do0_vZ2I.js +1 -0
- package/dist/client/assets/{use-personality-commit-BB5aeh6p.js → use-personality-commit-BvqCwzAC.js} +1 -1
- package/dist/client/assets/{use-promo-activation-BW0u7n7m.js → use-promo-activation-Dz5cYm-X.js} +1 -1
- package/dist/client/assets/{use-promo-dismissals-BOXzW4kD.js → use-promo-dismissals-CuOsnqnZ.js} +1 -1
- package/dist/client/assets/{use-pulse-freshness-ClW-MLMo.js → use-pulse-freshness-qcTH6PM7.js} +1 -1
- package/dist/client/assets/{use-relay-config-hItHtkSr.js → use-relay-config-1mAMDNbc.js} +1 -1
- package/dist/client/assets/{use-room-follow-claim-wotzxUWc.js → use-room-follow-claim-CCGhsyH3.js} +1 -1
- package/dist/client/assets/{use-roving-tab-list-DkbO6xSs.js → use-roving-tab-list-Bsg2dfUx.js} +1 -1
- package/dist/client/assets/use-session-canvas-awPngMKg.js +25 -0
- package/dist/client/assets/{use-session-diagnostics-DmxvD-wy.js → use-session-diagnostics-D5g8Mc52.js} +2 -2
- package/dist/client/assets/{use-unclaimed-chats-DKpexDm3.js → use-unclaimed-chats-Db_wuzt0.js} +1 -1
- package/dist/client/assets/use-update-config-DwtH_H9Z.js +1 -0
- package/dist/client/assets/{useMutationState-Btf2Hp1a.js → useMutationState-BvwBDXKc.js} +1 -1
- package/dist/client/assets/{usecaseDiagram-WPOLBNNX-DRngjDUq.js → usecaseDiagram-WPOLBNNX-1zKygEKR.js} +1 -1
- package/dist/client/assets/{vennDiagram-Q3Y3IDCW-iK-dlS1-.js → vennDiagram-Q3Y3IDCW-BR2EbgGY.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-IVAIDKWA-sOS67Cks.js → wardleyDiagram-IVAIDKWA-D0OwouJc.js} +1 -1
- package/dist/client/assets/{xychartDiagram-4URNHDU4-EgnLiIao.js → xychartDiagram-4URNHDU4-BM-7_FQQ.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/drizzle/20261018123612_session_route.sql +1 -0
- package/dist/drizzle/meta/20261018123612_snapshot.json +14027 -0
- package/dist/drizzle/meta/_journal.json +7 -0
- package/dist/server/index.js +31594 -28878
- package/dist/server/index.js.map +2 -2
- package/package.json +6 -6
- package/dist/client/assets/CanvasFileContent-ClcHZ_l-.js +0 -2
- package/dist/client/assets/CanvasModel3dContent-Cm3msNdQ.js +0 -2
- package/dist/client/assets/HandlePage-B_5GLHsp.js +0 -1
- package/dist/client/assets/NamePage-0nr288eM.js +0 -1
- package/dist/client/assets/PhotoPage-C3Ir3wlA.js +0 -1
- package/dist/client/assets/PresetPicker-zGvDOqTf.js +0 -19
- package/dist/client/assets/RoomSurface-BIyjtxKD.js +0 -44
- package/dist/client/assets/_shell-BHUZq_8C.js +0 -80
- package/dist/client/assets/_shell.marketplace-BoAmyvPt.js +0 -1
- package/dist/client/assets/_shell.marketplace_.sources-BpqWjkGL.js +0 -1
- package/dist/client/assets/_shell.session-KyPj3OxK.js +0 -61
- package/dist/client/assets/_shell.x._extensionId-CfiAgtoq.js +0 -1
- package/dist/client/assets/_shell.x._extensionId_._-CfiAgtoq.js +0 -1
- package/dist/client/assets/channel-DZpRF3QJ.js +0 -1
- package/dist/client/assets/index-Cl8trmnL.js +0 -1
- package/dist/client/assets/index-Cp3yShS8.js +0 -23
- package/dist/client/assets/index-DKDK-3KH.js +0 -17
- package/dist/client/assets/index-DPNBHwcQ.js +0 -1
- package/dist/client/assets/registry-DS1Ghdft.js +0 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-C7fkUKrq.js +0 -8
- package/dist/client/assets/use-is-below-desktop-Qwyg-mFb.js +0 -1
- package/dist/client/assets/use-is-hub-CSz6NDaP.js +0 -1
- package/dist/client/assets/use-pending-read-DBOl1ee_.js +0 -1
- package/dist/client/assets/use-session-canvas-C_fuAgW_.js +0 -24
- package/dist/client/assets/use-update-config-CSYwg557.js +0 -1
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{W as Se,aR as Me,a1 as ne,r as s,iL as Ie,iM as Q,iN as G,iO as H,go as ie,iP as Ce,a7 as J,iQ as ee,as as it,iR as lt,a3 as oe,iS as ct,iT as dt,iH as ut,iU as ft,aW as Te,iV as ht,j as e,x as Fe,T as pt,C as Ke,aq as mt,dZ as be,ig as xt,G as Pe,iW as gt,iX as yt,iY as vt,iZ as X,i_ as ue,g9 as fe,ga as he,gb as pe,gc as me,gd as xe,ge,gf as ye,gg as ve,B as Y,b6 as Ct,e3 as _e,il as bt,i$ as jt,a2 as ce,j0 as He,dz as kt,j1 as wt,j2 as Et,j3 as Dt,j4 as Nt,bk as De,j5 as Ue,a4 as Rt,gm as St,a0 as Tt,gl as Ft,dJ as Pt,iq as Ot,j6 as Mt,cw as _t,cx as At,cz as Lt,cA as zt,cB as $t,dw as It,I as Kt,dc as Ht}from"./index-DcZPWi_I.js";import{t as ae,g as Ut,C as qt,n as qe,r as Qe,a as Qt,p as Bt,F as Wt,w as Yt,c as Be,b as Gt}from"./room-files-source-CbbVpvSW.js";import{N as ss,R as as}from"./room-files-source-CbbVpvSW.js";import{r as Vt,c as Zt}from"./composer-insert-BpyATrmR.js";import{u as Xt}from"./index-yI1r4pSP.js";import{r as We,h as Ye,F as Jt}from"./file-drag-GDx2qhdk.js";import{R as Ge}from"./rotate-cw-Djl5J_x9.js";import{L as en}from"./link-2-Dvb6g-2Q.js";import{F as Ve}from"./file-Bf7D_47y.js";import{G as Ze}from"./git-branch-B2k77X3Q.js";import{M as tn}from"./more-details-B4lBMpKi.js";import"./markdown-content-Cqq_QMXA.js";import"./file-exclamation-point-DZXE9_8o.js";/**
|
|
2
|
-
* @license lucide-react v1.48.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Xe={name:"corner-left-up",size:24,node:[["path",{d:"M14 9 9 4 4 9",key:"1af5af"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]]};Xe.node;const nn=Se(Xe);/**
|
|
7
|
-
* @license lucide-react v1.48.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Je={name:"file-plus",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:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]};Je.node;const et=Se(Je);/**
|
|
12
|
-
* @license lucide-react v1.48.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const tt={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};tt.node;const sn=Se(tt);function le(t,n,a){return["file-explorer","tree",t.scopeKey,n,t.filtersHidden?a:null]}function ke(t,n,a,x){return{queryKey:le(t,n,a),queryFn:()=>t.list(n,{showHidden:a}),staleTime:Me.FILE_TREE_STALE_TIME_MS,gcTime:Me.FILE_TREE_GC_TIME_MS,refetchOnWindowFocus:!0,placeholderData:p=>p??x.getQueryData(le(t,n,!a))}}const an=[".git",".dork",".claude",".agents","node_modules"];function rn(t){return t.startsWith(".")||an.includes(t)}const Ne=["ROOM.md","README.md"];function Re(t){return Ne.some(n=>n.toLowerCase()===t.toLowerCase())}function nt(t){return t.filter(n=>!rn(n.name))}function on(t){if(t.reduce((p,c)=>c.type==="file"&&Re(c.name)?p+1:p,0)===0)return t;const a=[],x=[];for(const p of t)p.type==="file"&&Re(p.name)?a.push(p):x.push(p);return a.sort((p,c)=>Ne.findIndex(o=>o.toLowerCase()===p.name.toLowerCase())-Ne.findIndex(o=>o.toLowerCase()===c.name.toLowerCase())),[...a,...x]}const ln=/ copy(?: \d+)?$/;function Oe({name:t,isDir:n,taken:a}){const x=new Set(a);if(!x.has(t))return t;const p=n?-1:t.lastIndexOf("."),c=p>0,o=c?t.slice(p):"",m=(c?t.slice(0,p):t).replace(ln,"");for(let r=1;;r+=1){const i=r===1?`${m} copy${o}`:`${m} copy ${r}${o}`;if(!x.has(i))return i}}function Ae(t,n,a){return{name:n,path:t,type:a,size:0,mtime:Date.now(),isSymlink:!1}}function cn(t){const n=ne(),{source:a,showHidden:x,queryClient:p,inFlightRef:c}=t,o=a.cwd??"",[m,r]=s.useState(null),i=s.useCallback(async h=>{c.current+=1;try{return await h()}finally{c.current-=1}},[c]),u=s.useMemo(()=>{const h=g=>le(a,g,x);return{getChildren:g=>{var w;return((w=p.getQueryData(h(g)))==null?void 0:w.entries)??[]},isLoaded:g=>p.getQueryData(h(g))!==void 0,takenNames:async g=>(await n.readFileTree(o,{path:g===Q?void 0:g,showHidden:!0})).entries.map(b=>b.name),snapshot:g=>p.getQueryData(h(g)),setChildren:(g,w)=>{p.setQueryData(h(g),b=>({entries:Ie(w((b==null?void 0:b.entries)??[]))}))},restore:(g,w)=>{p.setQueryData(h(g),w)},invalidate:g=>{p.invalidateQueries({queryKey:h(g),exact:!0})}}},[p,n,o,a,x]),N=s.useCallback((h,g,w)=>i(async()=>{const b=ee(h,g),S=!u.getChildren(h).some(A=>A.path===b),K=u.snapshot(h);S&&u.setChildren(h,A=>[...A,Ae(b,g,w)]);try{return await n.createEntry(o,b,w),!0}catch(A){return S&&u.restore(h,K),ae(A,`Couldn’t create ${w==="dir"?"folder":"file"}`),!1}finally{u.invalidate(h)}}),[n,o,u,i]),F=s.useCallback((h,g)=>i(async()=>{if(g===h.name||g.length===0)return!0;const w=G(h.path),b=ee(w,g),S=u.getChildren(w).some(_=>_.path===b),K=u.snapshot(w),A={...h,name:g,path:b};S||u.setChildren(w,_=>_.map($=>$.path===h.path?A:$));try{return await n.renameEntry(o,h.path,b),H.getState().remapExpandedPaths(h.path,b),!0}catch(_){return S||u.restore(w,K),ae(_,"Couldn’t rename"),!1}finally{u.invalidate(w)}}),[n,o,u,i]),D=s.useCallback(h=>i(async()=>{const g=G(h.path),w=u.snapshot(g);u.setChildren(g,b=>b.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path,{recursive:!0}),H.getState().dropExpandedPaths(h.path)}catch(b){u.restore(g,w),ae(b,"Couldn’t delete")}finally{u.invalidate(g)}}),[n,o,u,i]),L=s.useCallback(h=>i(async()=>{const g=G(h.path);if(h.type==="file"){const w=u.snapshot(g);u.setChildren(g,b=>b.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path),H.getState().dropExpandedPaths(h.path)}catch(b){u.restore(g,w),ae(b,"Couldn’t delete")}finally{u.invalidate(g)}return}try{await n.deleteEntry(o,h.path),u.setChildren(g,w=>w.filter(b=>b.path!==h.path)),H.getState().dropExpandedPaths(h.path),u.invalidate(g)}catch(w){if(Ut(w)==="DIR_NOT_EMPTY"){r(h);return}ae(w,"Couldn’t delete")}}),[n,o,u,i]),C=s.useCallback(async()=>{const h=m;r(null),h&&await D(h)},[m,D]),U=s.useCallback(()=>r(null),[]),I=s.useCallback((h,g)=>i(async()=>{const w=G(h),b=ie(h),S=ee(g,b);if(g===w||S===h||Ce(g,h))return;const K=u.getChildren(w).find(v=>v.path===h);if(!K)return;const A=u.isLoaded(g),_=A&&u.getChildren(g).some(v=>v.path===S),$={...K,name:b,path:S},W=u.snapshot(w),P=A?u.snapshot(g):void 0;u.setChildren(w,v=>v.filter(z=>z.path!==h)),A&&!_&&u.setChildren(g,v=>[...v,$]);try{await n.renameEntry(o,h,S),H.getState().remapExpandedPaths(h,S)}catch(v){u.restore(w,W),A&&!_&&u.restore(g,P),ae(v,"Couldn’t move")}finally{u.invalidate(w),A&&u.invalidate(g)}}),[n,o,u,i]),k=s.useCallback((h,g)=>i(async()=>{if(h.isDir&&Ce(g,h.path)){J.error(qt);return}let w;try{w=await u.takenNames(g)}catch(_){ae(_,"Couldn’t copy");return}const b=Oe({name:ie(h.path),isDir:h.isDir,taken:w}),S=ee(g,b),K=u.isLoaded(g),A=K?u.snapshot(g):void 0;if(K){const _=u.getChildren(G(h.path)).find(W=>W.path===h.path),$=_?{..._,name:b,path:S}:Ae(S,b,h.isDir?"dir":"file");u.setChildren(g,W=>[...W,$])}try{await n.copyEntry(o,h.path,S)}catch(_){K&&u.restore(g,A),ae(_,"Couldn’t copy")}finally{u.invalidate(g)}}),[n,o,u,i]);return{createEntry:N,renameEntry:F,removeEntry:L,moveEntry:I,copyEntry:k,pendingRecursiveDelete:m,confirmRecursiveDelete:C,cancelRecursiveDelete:U}}function dn(t){return t!=null&&t.startsWith("darwin")?"Reveal in Finder":t!=null&&t.startsWith("win32")?"Reveal in File Explorer":"Show in file manager"}function un(t,n){const a=t.includes("\\")&&!t.includes("/"),x=t.replace(/[\\/]+$/,""),p=a?n.split("/").join("\\"):n;return`${x}${a?"\\":"/"}${p}`}function fn(t){const n=ne(),{data:a}=it(),x=s.useMemo(()=>n.supportsReveal?dn(a==null?void 0:a.platform):null,[n.supportsReveal,a==null?void 0:a.platform]),p=s.useCallback(async i=>{if(t)try{await n.revealEntry(t,i.path)}catch(u){ae(u,"Couldn’t open the file manager")}},[n,t]),{copy:c}=lt(),o=s.useCallback(async(i,u)=>{const N=u==="absolute"&&t?un(t,i.path):i.path;await c(N)||J.error("Couldn’t copy to the clipboard")},[t,c]),m=s.useCallback(i=>{Vt(Zt(i.path))||J.error("Open a chat to add this file")},[]),r=s.useCallback(i=>{H.getState().setClipboard({path:i.path,isDir:i.type==="dir"});try{navigator.clipboard.writeText(i.path).catch(()=>{})}catch{}},[]);return{revealLabel:x,reveal:p,copyPath:o,addToChat:m,copyToClipboard:r}}const hn=1e3;function pn(t){const{source:n,showHidden:a,queryClient:x,inFlightRef:p}=t,c=n.changes,[o,m]=s.useState(null),[r,i]=s.useState(null),[u,N]=s.useState(null),[F,D]=s.useState(0),L=s.useCallback(async d=>{p.current+=1,D(f=>f+1);try{return await d()}finally{p.current-=1,D(f=>f-1)}},[p]),C=s.useMemo(()=>{const d=f=>le(n,f,a);return{listing:f=>x.getQueryData(d(f)),isLoaded:f=>x.getQueryData(d(f))!==void 0,entries:f=>{var T;return((T=x.getQueryData(d(f)))==null?void 0:T.entries)??[]},setEntries:(f,T)=>x.setQueryData(d(f),y=>({...y,entries:Ie(T((y==null?void 0:y.entries)??[]))})),restore:(f,T)=>x.setQueryData(d(f),T),fetch:f=>n.list(f,{showHidden:!0}),refreshAll:()=>{x.invalidateQueries({queryKey:["file-explorer","tree",n.scopeKey]}),x.invalidateQueries({queryKey:["file-explorer","preview",n.scopeKey]})}}},[x,n,a]),U=s.useCallback(async d=>{const f=C.listing(d);return(f==null?void 0:f.commit)!==void 0?f.commit:(await C.fetch(d)).commit??null},[C]),I=s.useCallback((d,f,T,y)=>{switch(d.status){case"changed":return!0;case"conflict":return N({kind:f,path:d.path,lastCommit:d.lastCommit,retry:()=>T(d.commit)}),!1;case"exists":return J.error(y===void 0?d.reason:qe(y)),!1;case"refused":return J.error(d.reason),!1}},[]),k=s.useCallback((d,f)=>{J.error(Qe(d)??f)},[]),h=s.useCallback((d,f,T)=>{const y=O=>L(async()=>{if(c===void 0)return!1;const E=G(d.path),R=G(f),j=ie(f),q=C.isLoaded(R),te=q&&C.entries(R).some(Z=>Z.path===f),V=C.listing(E),de=R===E?void 0:C.listing(R),l={...d,name:j,path:f};te||(R===E?C.setEntries(E,Z=>Z.map(se=>se.path===d.path?l:se)):(C.setEntries(E,Z=>Z.filter(se=>se.path!==d.path)),q&&C.setEntries(R,Z=>[...Z,l])));const M=()=>{C.restore(E,V),R!==E&&q&&C.restore(R,de)};try{const Z=O??await U(E);if(Z===null)return M(),J.error("This room has no files to change yet."),!1;const se=await c.move({from:d.path,to:f,baseCommit:Z}),we=I(se,T,async re=>{await y(re)},j);return we?H.getState().remapExpandedPaths(d.path,f):M(),we}catch(Z){return M(),k(Z,T==="rename"?"Couldn’t rename":"Couldn’t move"),!1}finally{C.refreshAll()}});return y(null)},[c,C,L,U,I,k]),g=s.useCallback(async(d,f)=>f===d.name||f.length===0?!0:h(d,ee(G(d.path),f),"rename"),[h]),w=s.useCallback(async(d,f)=>{const T=G(d),y=ee(f,ie(d));if(f===T||y===d||Ce(f,d))return;const O=C.entries(T).find(E=>E.path===d);O&&await h(O,y,"move")},[C,h]),b=s.useCallback(async d=>{let f=0;const T=[d];for(;T.length>0;){const y=T.shift(),O=await C.fetch(y);for(const E of O.entries)if(E.type==="dir"?T.push(E.path):f+=1,f>=hn)return{count:f,moreThan:!0}}return{count:f,moreThan:!1}},[C]),S=s.useCallback(d=>{if(d.type!=="dir"){m({entry:d,fileCount:1,moreThan:!1});return}m({entry:d,fileCount:null,moreThan:!1}),b(d.path).then(({count:f,moreThan:T})=>m(y=>(y==null?void 0:y.entry.path)===d.path?{entry:d,fileCount:f,moreThan:T}:y),()=>{})},[b]),K=s.useCallback(d=>{const f=T=>L(async()=>{if(c===void 0)return;const y=G(d.path),O=C.listing(y);C.setEntries(y,E=>E.filter(R=>R.path!==d.path));try{const E=T??await U(y);if(E===null){C.restore(y,O);return}const R=await c.remove({path:d.path,baseCommit:E});I(R,"delete",q=>f(q))?H.getState().dropExpandedPaths(d.path):C.restore(y,O)}catch(E){C.restore(y,O),k(E,"Couldn’t delete")}finally{C.refreshAll()}});return f(null)},[c,C,L,U,I,k]),A=s.useCallback(async()=>{const d=o;m(null),d&&await K(d.entry)},[o,K]),_=s.useCallback(()=>m(null),[]),$=s.useCallback((d,f,T,y)=>{const O=E=>L(async()=>{if(c===void 0)return;const R=C.isLoaded(d),j=R?C.listing(d):void 0;if(R){const q=new Set(C.entries(d).map(V=>V.name)),te=f.filter(V=>!q.has(V.name)).map(V=>({name:V.name,path:ee(d,V.name),type:"file",size:V.size}));te.length>0&&C.setEntries(d,V=>[...V,...te])}try{const q=await c.upload({dir:d,baseCommit:E,replace:T,files:f});!I(q,"upload",V=>O(V))&&R&&C.restore(d,j)}catch(q){R&&C.restore(d,j),k(q,"Couldn’t upload")}finally{C.refreshAll()}});return O(y)},[c,C,L,I,k]),W=s.useCallback(async(d,f)=>{if(c===void 0||f.length===0)return;if(f.length>c.maxUploadFiles){J.error(`Nothing was uploaded. One upload takes up to ${c.maxUploadFiles} files.`);return}let T;try{T=await C.fetch(d)}catch(j){k(j,"Couldn’t upload");return}const y=T.entries.map(j=>j.name),O=new Set(y),E=f.map(j=>j.name).filter(j=>O.has(j)),R=T.commit??null;if(E.length===0){await $(d,f,[],R);return}i({dir:d,files:f,names:E,taken:y,baseCommit:R})},[c,C,k,$]),P=s.useCallback(async d=>{const f=r;if(i(null),f===null)return;if(d==="replace"){await $(f.dir,f.files,f.names,f.baseCommit);return}const T=new Set([...f.taken,...f.files.map(E=>E.name)]),y=new Set(f.names),O=f.files.map(E=>{if(!y.has(E.name))return E;const R=Oe({name:E.name,isDir:!1,taken:T});return T.add(R),new File([E],R,{type:E.type,lastModified:E.lastModified})});await $(f.dir,O,[],f.baseCommit)},[r,$]),v=s.useCallback(()=>i(null),[]),z=s.useCallback(()=>N(null),[]),B=s.useMemo(()=>r===null?null:{dir:r.dir,names:r.names},[r]);return{renameEntry:g,moveEntry:w,requestDelete:S,pendingDelete:o,confirmDelete:A,cancelDelete:_,upload:W,pendingClash:B,resolveClash:P,cancelClash:v,conflict:u,dismissConflict:z,busy:F>0}}const Le={scopeKey:"",cwd:null,writable:!1,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list:()=>Promise.resolve({entries:[]})};function mn(t){var d,f,T;const n=ne(),a=oe(),{setTheme:x}=ct(),p=H(y=>y.showHidden),c=H(y=>y.expanded),o=H(y=>y.loadExplorerForCwd),m=H(y=>y.pruneMissing),r=(t==null?void 0:t.scopeKey)??null,i=(t==null?void 0:t.cwd)??null;s.useEffect(()=>{o(r)},[r,o]);const u=s.useMemo(()=>[Q,...dt(c)],[c]),N=ut({queries:t?u.map(y=>ke(t,y,p,a)):[]}),F=(t==null?void 0:t.filtersHidden)??!0,D=s.useMemo(()=>{const y={};return u.forEach((O,E)=>{var q;const R=N[E];let j=((q=R==null?void 0:R.data)==null?void 0:q.entries)??[];!p&&!F&&(j=nt(j)),O===Q&&(j=on(j)),y[O]={entries:j,loading:(R==null?void 0:R.isLoading)??!1,error:(R==null?void 0:R.isError)??!1}}),y},[u,N,p,F]),L=s.useRef(0),C=s.useRef({});s.useEffect(()=>{L.current>0||u.forEach((y,O)=>{var R,j,q;const E=(j=(R=N[O])==null?void 0:R.data)==null?void 0:j.entries;!E||(q=N[O])!=null&&q.isError||C.current[y]!==E&&(C.current[y]=E,m(y,E.map(te=>te.name)))})},[u,N,m]);const U=s.useMemo(()=>ft(c,D),[c,D]),I=!!t&&!!((d=D[Q])!=null&&d.loading),k=!!t&&!!((f=D[Q])!=null&&f.error),h=(T=N[0])==null?void 0:T.error,g=k&&h?Qt(h):void 0,w=(g==null?void 0:g.message)??null,b=(g==null?void 0:g.command)??null,S=s.useMemo(()=>{var O;const y=new Set;for(const E of u)E!==Q&&((O=D[E])!=null&&O.error)&&y.add(E);return y},[u,D]),K=s.useCallback(y=>{if(y.type!=="dir")return;const O=H.getState();O.setDirExpanded(y.path,!O.expanded[y.path])},[]),A=s.useCallback(y=>{if(y===Q)return;const O=H.getState();O.expanded[y]||O.setDirExpanded(y,!0)},[]),_=(t==null?void 0:t.preview)==="canvas",$=s.useCallback(y=>{if(y.type!=="file"||!_)return;const O={getStore:Te.getState,setTheme:x,supportsTerminal:n.supportsTerminal};ht(O,{action:"open_file",sourcePath:y.path},"user")},[_,x,n]),W=s.useCallback(()=>{r!==null&&a.invalidateQueries({queryKey:["file-explorer","tree",r]})},[a,r]),P=s.useCallback(y=>{t!==null&&a.invalidateQueries({queryKey:le(t,y,p),exact:!0})},[a,t,p]);s.useEffect(()=>{if(t!=null&&t.events)return t.events(W)},[t,W]);const v=cn({source:t??Le,showHidden:p,queryClient:a,inFlightRef:L}),z=pn({source:t??Le,showHidden:p,queryClient:a,inFlightRef:L}),B=fn(i);return{rows:U,rootLoading:I,rootError:k,rootErrorMessage:w,rootErrorCommand:b,errorPaths:S,toggleExpand:K,ensureExpanded:A,openFile:$,reload:W,retryDir:P,changes:t!=null&&t.changes?z:null,...v,...B}}function xn(t){const{transport:n,cwd:a}=t;return{scopeKey:a,cwd:a,writable:!0,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list(x,p){return n.readFileTree(a,{path:x===""?void 0:x,showHidden:p.showHidden})}}}function je(t){return Array.from(t).includes("Files")}function st(t){const n=Array.from(t.items??[]);if(!(n.length>0&&n.every(c=>"webkitGetAsEntry"in c)))return{files:Array.from(t.files??[]),folders:0};const x=[];let p=0;for(const c of n){if(c.kind!=="file")continue;const o=c.webkitGetAsEntry();if(o!=null&&o.isDirectory){p+=1;continue}const m=c.getAsFile();m&&x.push(m)}return{files:x,folders:p}}const gn=12;function yn({row:t,selected:n,renaming:a,error:x,onSelect:p,onActivate:c,onRetry:o,onSubmitRename:m,onCancelRename:r,onNewFile:i,onNewFolder:u,onStartRename:N,onDelete:F,onMove:D,onCopyInto:L,onCopy:C,onPaste:U,onDuplicate:I,canPasteInto:k,revealLabel:h,onReveal:g,onAddToChat:w,onCopyPath:b,readOnly:S=!1,provenance:K=!1,copyable:A=!0,onDisk:_=!0,onUpload:$,onPickUpload:W}){const{entry:P,depth:v,expanded:z,loading:B}=t,d=P.type==="dir",f=d?P.path:G(P.path),[T,y]=s.useState(!1),O=!d&&v===0&&Re(P.name),E=Bt(P.lastCommit),R=e.jsxs("div",{role:"treeitem","aria-label":P.name,"aria-expanded":d?z:void 0,"aria-selected":n,tabIndex:-1,onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),p(P),c(P))},draggable:!a&&!S,onDragStart:j=>{S||(j.dataTransfer.setData("text/plain",P.path),j.dataTransfer.setData(Jt,P.path),j.dataTransfer.effectAllowed="copyMove")},onDragOver:j=>{if(j.stopPropagation(),!S&&$&&je(j.dataTransfer.types)){j.preventDefault(),j.dataTransfer.dropEffect="copy",y(!0);return}S||!d||!Ye(j.dataTransfer.types)||(j.preventDefault(),j.dataTransfer.dropEffect=j.altKey&&A?"copy":"move",y(!0))},onDragLeave:()=>y(!1),onDrop:j=>{if(j.stopPropagation(),S)return;if(y(!1),$&&je(j.dataTransfer.types)){j.preventDefault();const{files:te}=st(j.dataTransfer);$(f,te);return}if(!d)return;const q=We(j.dataTransfer);q!==null&&(j.preventDefault(),j.altKey&&A?L(q,P.path):D(q,P.path))},onClick:()=>{p(P),c(P)},className:Pe("flex w-full cursor-pointer items-center gap-1 py-1 pr-2 text-sm transition-colors",n?"bg-accent text-foreground":"hover:bg-accent/50",T&&"ring-ring/60 bg-accent ring-1"),style:{paddingLeft:v*gn+8},children:[e.jsx("span",{className:"flex size-4 flex-shrink-0 items-center justify-center",children:d&&(B?e.jsx(Fe,{size:"xs",className:"text-muted-foreground"}):x?e.jsx("button",{type:"button","aria-label":"Retry loading",title:"Couldn’t load. Retry",onClick:j=>{j.stopPropagation(),o()},className:"flex items-center justify-center",children:e.jsx(Ge,{className:"text-destructive size-3.5"})}):z?e.jsx(pt,{className:"text-muted-foreground size-3.5"}):e.jsx(Ke,{className:"text-muted-foreground size-3.5"}))}),d?z?e.jsx(mt,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):e.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):P.isSymlink===!0?e.jsx(en,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}):e.jsx(Ve,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),a?e.jsx(vn,{initialName:P.name,onSubmit:j=>m(P,j),onCancel:r}):e.jsx("span",{className:"min-w-0 flex-1 truncate",children:P.name}),O&&!a&&e.jsx(xt,{"aria-label":"Pinned to the top",className:"text-muted-foreground/60 size-3 flex-shrink-0"}),K&&!a&&e.jsx("span",{className:"text-muted-foreground/70 text-2xs max-w-[45%] flex-shrink-0 truncate tabular-nums",title:E.title??void 0,children:E.label})]});return S?R:e.jsxs(gt,{children:[e.jsx(yt,{asChild:!0,children:R}),e.jsxs(vt,{className:"w-52",children:[e.jsx(X,{movesFocus:!0,onClick:()=>i(f),children:"New file"}),e.jsx(X,{movesFocus:!0,onClick:()=>u(f),children:"New folder"}),W&&e.jsx(X,{onClick:()=>W(f),children:"Upload files…"}),_&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{}),h&&e.jsx(X,{onClick:()=>g(P),children:h}),e.jsx(X,{movesFocus:!0,onClick:()=>w(P),children:"Add to chat"})]}),A&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{}),e.jsx(X,{onClick:()=>C(P),children:"Copy"}),e.jsx(X,{disabled:!k(f),onClick:()=>U(f),children:"Paste"}),e.jsx(X,{onClick:()=>I(P),children:"Duplicate"})]}),e.jsx(ue,{}),_?e.jsxs(e.Fragment,{children:[e.jsx(X,{onClick:()=>b(P,"absolute"),children:"Copy path"}),e.jsx(X,{onClick:()=>b(P,"relative"),children:"Copy relative path"})]}):e.jsx(X,{onClick:()=>b(P,"relative"),children:"Copy path"}),e.jsx(ue,{}),e.jsx(X,{movesFocus:!0,onClick:()=>N(P),children:"Rename"}),e.jsx(X,{variant:"destructive",onClick:()=>F(P),children:"Delete"})]})]})}function vn({initialName:t,onSubmit:n,onCancel:a}){const x=s.useRef(null),[p,c]=s.useState(t);s.useEffect(()=>{const m=x.current;if(!m)return;m.focus();const r=t.lastIndexOf(".");m.setSelectionRange(0,r>0?r:t.length)},[t]);const o=()=>{const m=p.trim();m&&m!==t?n(m):a()};return e.jsx("input",{ref:x,type:"text",value:p,"aria-label":"New name",onChange:m=>c(m.target.value),onClick:m=>m.stopPropagation(),onBlur:o,onKeyDown:m=>{m.stopPropagation(),m.key==="Enter"?o():m.key==="Escape"&&a()},className:"border-border bg-background focus-ring min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})}const Cn=100,bn=28,jn=250;function kn(t){const{rows:n,selectedPath:a,renamingPath:x,errorPaths:p,onSelectPath:c,onRetryDir:o}=t,m=s.useRef(null),r=H(v=>v.setScrollTop),i=H(v=>v.scopeKey),u=s.useCallback(v=>v.type==="dir"?t.onToggle(v):t.onOpen(v),[t]),N=En(t,u),F=n.length>Cn,D=Xt({count:n.length,getScrollElement:()=>m.current,estimateSize:()=>bn,overscan:12,enabled:F}),L=s.useRef({scope:void 0,done:!1}),C=s.useRef(null);s.useLayoutEffect(()=>{const v=L.current;if(v.scope!==i&&(v.scope=i,v.done=!1),v.done||n.length===0)return;const z=m.current;if(!z)return;const B=H.getState().scrollTop;if(B<=0){v.done=!0;return}F?D.scrollToOffset(B):z.scrollTop=B,C.current=z.scrollTop,z.scrollTop>=B&&(v.done=!0)},[n.length,i,F,D]);const U=s.useRef(null),I=s.useRef(null),k=s.useCallback(()=>{const v=m.current;v&&v.scrollTop!==C.current&&(L.current.done=!0,U.current=v.scrollTop,I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{I.current=null,U.current!==null&&r(U.current)},jn))},[r]);s.useEffect(()=>()=>{I.current&&clearTimeout(I.current),U.current!==null&&r(U.current)},[r]);const h=s.useRef(void 0);s.useEffect(()=>{var d,f;const v=h.current;if(h.current=a,v===void 0||a===v||a===null)return;const z=n.findIndex(T=>T.entry.path===a);if(z<0)return;const B=m.current;B&&(F?D.scrollToIndex(z,{align:"auto"}):(f=(d=B.querySelector(`[data-row-index="${z}"]`))==null?void 0:d.scrollIntoView)==null||f.call(d,{block:"nearest"}),C.current=B.scrollTop)},[a,n,F,D]);const[g,w]=s.useState(!1),{onCopyInto:b,onMove:S}=t,K=t.readOnly===!0,A=t.copyable!==!1,_=s.useCallback(v=>{K||!Ye(v.dataTransfer.types)||(v.preventDefault(),v.dataTransfer.dropEffect=v.altKey&&A?"copy":"move",w(!0))},[K,A]),$=s.useCallback((v,z)=>{const B=n.find(d=>d.entry.path===v);B&&b({path:v,isDir:B.entry.type==="dir"},z)},[n,b]),W=s.useCallback(v=>{if(w(!1),K)return;const z=We(v.dataTransfer);z!==null&&(v.preventDefault(),v.altKey&&A?$(z,Q):S(z,Q))},[$,S,K,A]),P=v=>e.jsx(yn,{row:v,selected:v.entry.path===a,renaming:v.entry.path===x,error:v.entry.type==="dir"&&v.expanded&&p.has(v.entry.path),onSelect:z=>c(z.path),onActivate:u,onRetry:()=>o(v.entry.path),onSubmitRename:t.onSubmitRename,onCancelRename:t.onCancelRename,onStartRename:t.onStartRename,onNewFile:t.onNewFile,onNewFolder:t.onNewFolder,onDelete:t.onDelete,onMove:t.onMove,onCopyInto:$,onCopy:t.onCopy,onPaste:t.onPaste,onDuplicate:t.onDuplicate,canPasteInto:t.canPasteInto,revealLabel:t.revealLabel,onReveal:t.onReveal,onAddToChat:t.onAddToChat,onCopyPath:t.onCopyPath,readOnly:t.readOnly,provenance:t.provenance,copyable:t.copyable,onDisk:t.onDisk,onUpload:t.onUpload,onPickUpload:t.onPickUpload});return e.jsx("div",{ref:m,role:"tree","aria-label":"File explorer",tabIndex:0,onKeyDown:N,onScroll:k,onDragOver:_,onDragLeave:()=>w(!1),onDrop:W,className:Pe("focus-visible:ring-ring h-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset",g&&"ring-ring/60 bg-accent/30 ring-1 ring-inset"),children:F?e.jsx("div",{style:{height:D.getTotalSize()},className:"relative w-full",children:D.getVirtualItems().map(v=>e.jsx("div",{"data-row-index":v.index,className:"absolute top-0 left-0 w-full",style:{transform:`translateY(${v.start}px)`},children:P(n[v.index])},n[v.index].entry.path))}):n.map((v,z)=>e.jsx("div",{"data-row-index":z,children:P(v)},v.entry.path))})}function wn(t){return t?t.type==="dir"?t.path:G(t.path):Q}function En(t,n){const{rows:a,selectedPath:x,renamingPath:p,onSelectPath:c}=t;return s.useCallback(o=>{var i,u,N,F;if(p!==null)return;const m=a.findIndex(D=>D.entry.path===x),r=m>=0?a[m]:void 0;if(o.metaKey||o.ctrlKey){if(t.readOnly===!0||t.copyable===!1)return;const D=o.key.toLowerCase();if(D==="c"&&r){o.preventDefault(),t.onCopy(r.entry);return}if(D==="v"){o.preventDefault(),t.onPaste(wn(r==null?void 0:r.entry));return}return}switch(o.key){case"ArrowDown":o.preventDefault(),c(((i=a[Math.min(m+1,a.length-1)])==null?void 0:i.entry.path)??((u=a[0])==null?void 0:u.entry.path));break;case"ArrowUp":o.preventDefault(),c(((N=a[Math.max(m-1,0)])==null?void 0:N.entry.path)??((F=a[0])==null?void 0:F.entry.path));break;case"ArrowRight":(r==null?void 0:r.entry.type)==="dir"&&!r.expanded&&(o.preventDefault(),t.onToggle(r.entry));break;case"ArrowLeft":if(!r)break;if(o.preventDefault(),r.entry.type==="dir"&&r.expanded)t.onToggle(r.entry);else{const D=G(r.entry.path);D&&c(D)}break;case"Enter":r&&(o.preventDefault(),n(r.entry));break;case"F2":r&&t.readOnly!==!0&&(o.preventDefault(),t.onStartRename(r.entry));break;case"Delete":case"Backspace":r&&t.readOnly!==!0&&(o.preventDefault(),t.onDelete(r.entry));break}},[a,x,p,c,t,n])}const Dn={rename:"Rename it anyway",move:"Move it anyway",delete:"Delete it anyway",upload:"Upload mine over it"},Nn={rename:"nothing was renamed",move:"nothing was moved",delete:"nothing was deleted",upload:"nothing was uploaded"};function Rn(t){const{entry:n,fileCount:a,moreThan:x}=t;if(n.type!=="dir")return`“${n.name}” leaves the room’s files.`;const p=a===null?"everything in it":x?`the more than ${a.toLocaleString()} files in it`:a===1?"the 1 file in it":`the ${a.toLocaleString()} files in it`;return`“${n.name}” and ${p} leave the room’s files.`}const Sn="The room’s history keeps a copy. An agent can restore it.";function Tn({changes:t,onOpenTheirs:n,onReturnFocus:a}){var D;const x=L=>{L.preventDefault();const C=document.activeElement;C!==null&&C!==document.body||a()},{pendingDelete:p,pendingClash:c,conflict:o}=t,[m,r]=s.useState(p);p!==null&&p!==m&&r(p);const[i,u]=s.useState(c);c!==null&&c!==i&&u(c);const N=i===null?"":i.dir===Q?"The top folder":`“${i.dir}”`,F=(i==null?void 0:i.names.length)===1;return e.jsxs(e.Fragment,{children:[e.jsx(fe,{open:p!==null,onOpenChange:L=>!L&&t.cancelDelete(),children:e.jsxs(he,{onCloseAutoFocus:x,children:[e.jsxs(pe,{children:[e.jsx(me,{children:m===null?"":`Delete “${m.entry.name}”?`}),e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:m===null?"":Rn(m)}),e.jsx("p",{children:Sn})]})})]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:t.cancelDelete,children:"Cancel"}),e.jsx(ve,{onClick:()=>void t.confirmDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:(m==null?void 0:m.entry.type)==="dir"?"Delete folder":"Delete file"})]})]})}),e.jsx(fe,{open:c!==null,onOpenChange:L=>!L&&t.cancelClash(),children:e.jsxs(he,{onCloseAutoFocus:x,children:[e.jsxs(pe,{children:[e.jsx(me,{children:F?`Replace “${i==null?void 0:i.names[0]}”?`:`Replace ${(i==null?void 0:i.names.length)??0} files?`}),e.jsx(xe,{children:F?`${N} already has a file with this name. Replace it, or keep both.`:`${N} already has files named ${(i==null?void 0:i.names.join(", "))??""}. Replace them, or keep both.`})]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:t.cancelClash,children:"Cancel"}),e.jsx(Y,{variant:"outline",onClick:()=>void t.resolveClash("keep-both"),children:"Keep both"}),e.jsx(ve,{onClick:()=>void t.resolveClash("replace"),children:"Replace"})]})]})}),e.jsx(fe,{open:o!==null,onOpenChange:L=>!L&&t.dismissConflict(),children:e.jsxs(he,{onCloseAutoFocus:x,children:[e.jsxs(pe,{children:[e.jsx(me,{children:"Somebody changed this first"}),e.jsx(xe,{children:o===null?"":`${((D=o.lastCommit)==null?void 0:D.author)??"Somebody"} changed “${o.path}” after you opened it, so ${Nn[o.kind]}.`})]}),(o==null?void 0:o.lastCommit)&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[o.lastCommit.subject," · ",Ct(o.lastCommit.at)]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:t.dismissConflict,children:"Cancel"}),e.jsx(Y,{variant:"outline",onClick:()=>{o!==null&&(t.dismissConflict(),n(o.path))},children:"Open their version"}),e.jsx(ve,{onClick:()=>{o!==null&&(t.dismissConflict(),o.retry())},className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:o===null?"":Dn[o.kind]})]})]})})]})}function ze(t,n){return n.name===t?qe(t):`“${n.name}” is already there. Some computers ignore capital letters in names. Pick another name.`}const Fn="Folders can’t be uploaded. Drop the files inside instead.";function Pn({source:t,className:n,onCommands:a}={}){var de;const x=ne(),p=Te(l=>l.selectedCwd),c=s.useMemo(()=>p?xn({transport:x,cwd:p}):null,[x,p]),o=t===void 0?c:t,m=o!==null&&!o.writable,r=mn(o),i=r.changes,u=oe(),N=H(l=>l.showHidden),{rows:F,rootLoading:D,rootError:L,rootErrorMessage:C,rootErrorCommand:U,errorPaths:I}=r,k=H(l=>l.setCommands),h=H(l=>l.selectedPath),g=H(l=>l.setSelectedPath),w=H(l=>l.clipboard),[b,S]=s.useState(null),[K,A]=s.useState(null),[_,$]=s.useState(null),W=s.useCallback(l=>$(l===null?null:{path:l,isNew:!1}),[]),P=s.useRef(null),v=s.useRef(Q),[z,B]=s.useState(!1),d=s.useCallback((l,M)=>{if(i!==null){if(M.length===0){J.error(Fn);return}r.ensureExpanded(l),i.upload(l,M)}},[i,r]),f=s.useRef(null),T=s.useCallback(()=>{var l,M;(M=(l=f.current)==null?void 0:l.querySelector('[role="tree"]'))==null||M.focus()},[]),y=s.useCallback(l=>{var M;v.current=l,(M=P.current)==null||M.click()},[]),O=s.useCallback(l=>w!==null&&!(w.isDir&&Ce(l,w.path)),[w]),E=s.useCallback((l,M)=>{r.ensureExpanded(l),_e.flushSync(()=>{A(null),S({parent:l,type:M})})},[r]),R=s.useCallback(l=>{_e.flushSync(()=>A(l.path))},[]),j=s.useRef({startCreate:E,reload:r.reload,pickUpload:y});s.useEffect(()=>{j.current={startCreate:E,reload:r.reload,pickUpload:y}});const q=i!==null;s.useEffect(()=>{if(m||a===void 0&&q)return;const l=a??k;return l({newFile:()=>j.current.startCreate(Q,"file"),newFolder:()=>j.current.startCreate(Q,"dir"),refresh:()=>j.current.reload(),...q&&{upload:()=>j.current.pickUpload(Q)}}),()=>l(null)},[k,a,m,q]);const te=s.useCallback(async l=>{var se;if(!b||o===null)return;const M=b;if(S(null),i!==null){const re=(((se=u.getQueryData(le(o,M.parent,N)))==null?void 0:se.entries)??[]).find(ot=>ot.name.toLowerCase()===l.toLowerCase());if(M.type==="dir"){if(re!==void 0&&!(re.type==="dir"&&re.name===l)){J.error(ze(l,re));return}S({parent:ee(M.parent,l),type:"file",firstInFolder:l});return}if(re!==void 0){J.error(ze(l,re));return}const rt=ee(M.parent,l);$({path:rt,isNew:!0});return}await r.createEntry(M.parent,l,M.type)&&g(ee(M.parent,l))},[b,o,i,u,N,r,g]),V=s.useCallback(async(l,M)=>{A(null),(i?await i.renameEntry(l,M):await r.renameEntry(l,M))&&g(ee(G(l.path),M))},[i,r,g]);return o===null?t!==void 0?null:e.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-center text-sm",children:"Pick a folder to see its files."}):e.jsxs("div",{ref:f,className:Pe("flex h-full flex-col",z&&"ring-ring/60 bg-accent/30 ring-1 ring-inset",n),onDragOver:l=>{i===null||!je(l.dataTransfer.types)||(l.preventDefault(),l.dataTransfer.dropEffect="copy",B(!0))},onDragLeave:l=>{l.currentTarget.contains(l.relatedTarget)||B(!1)},onDrop:l=>{B(!1),!(i===null||!je(l.dataTransfer.types))&&(l.preventDefault(),d(Q,st(l.dataTransfer).files))},children:[i!==null&&e.jsx("input",{ref:P,type:"file",multiple:!0,hidden:!0,"aria-hidden":!0,tabIndex:-1,"data-testid":"room-files-upload-input",onChange:l=>{const M=Array.from(l.target.files??[]);l.target.value="",d(v.current,M)}}),e.jsxs("div",{className:"min-h-0 flex-1",children:[b&&e.jsx(On,{type:b.type,firstInFolder:b.firstInFolder,onSubmit:l=>void te(l),onCancel:()=>S(null)},`${b.parent}:${b.type}:${b.firstInFolder??""}`),D&&F.length===0?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx(Fe,{size:"md",className:"text-muted-foreground",label:"Loading files"})}):L&&F.length===0?e.jsxs("div",{className:"text-muted-foreground flex min-h-20 flex-col items-center justify-center gap-2 px-4 py-3 text-center text-xs [overflow-wrap:anywhere]",children:[e.jsx("span",{children:C??"Couldn’t load files."}),U!==null&&e.jsx("code",{"aria-label":"Command that removes the settings",className:"bg-muted text-foreground block w-full rounded px-2 py-1.5 text-left font-mono select-all",children:U}),e.jsxs(Y,{variant:"outline",size:"xs",onClick:r.reload,children:[e.jsx(Ge,{}),"Retry"]})]}):F.length===0&&!b?e.jsx("div",{className:"text-muted-foreground/60 flex h-20 items-center justify-center px-4 text-center text-xs",children:i!==null?"No files yet. Drop files here, or use Upload.":"Empty folder"}):e.jsx(kn,{rows:F,selectedPath:h,renamingPath:K,errorPaths:I,onSelectPath:g,onToggle:r.toggleExpand,onOpen:l=>{o.preview==="inline"?W(l.path):r.openFile(l)},onRetryDir:r.retryDir,onSubmitRename:(l,M)=>void V(l,M),onCancelRename:()=>A(null),onStartRename:R,onNewFile:l=>E(l,"file"),onNewFolder:l=>E(l,"dir"),onDelete:l=>i?i.requestDelete(l):void r.removeEntry(l),onMove:(l,M)=>void(i?i.moveEntry(l,M):r.moveEntry(l,M)),onCopyInto:(l,M)=>void r.copyEntry(l,M),onCopy:r.copyToClipboard,onPaste:l=>{w&&r.copyEntry(w,l)},onDuplicate:l=>void r.copyEntry({path:l.path,isDir:l.type==="dir"},G(l.path)),canPasteInto:O,readOnly:m,provenance:o.provenance,copyable:i===null,onDisk:o.cwd!==null,onUpload:i?d:void 0,onPickUpload:i?y:void 0,revealLabel:r.revealLabel,onReveal:l=>void r.reveal(l),onAddToChat:r.addToChat,onCopyPath:(l,M)=>void r.copyPath(l,M)})]}),o.preview==="inline"&&e.jsx(Wt,{source:o,path:(_==null?void 0:_.path)??null,isNew:(_==null?void 0:_.isNew)??!1,onCreated:()=>{_!==null&&($({path:_.path,isNew:!1}),g(_.path))},onClose:()=>$(null)}),i!==null&&e.jsx(Tn,{changes:i,onOpenTheirs:l=>W(l),onReturnFocus:T}),e.jsx(fe,{open:r.pendingRecursiveDelete!==null,onOpenChange:l=>!l&&r.cancelRecursiveDelete(),children:e.jsxs(he,{children:[e.jsxs(pe,{children:[e.jsxs(me,{children:["Delete “",(de=r.pendingRecursiveDelete)==null?void 0:de.name,"”?"]}),e.jsx(xe,{children:"This folder isn’t empty. Everything inside is deleted. This can’t be undone."})]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:r.cancelRecursiveDelete,children:"Cancel"}),e.jsx(ve,{onClick:()=>void r.confirmRecursiveDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete folder"})]})]})})]})}function On({type:t,firstInFolder:n,onSubmit:a,onCancel:x}){const p=s.useRef(null),[c,o]=s.useState("");s.useEffect(()=>{var i;(i=p.current)==null||i.focus()},[]);const m=()=>{const i=c.trim();i?a(i):x()},r=e.jsxs("div",{className:"flex items-center gap-1",children:[t==="dir"?e.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):e.jsx(Ve,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),e.jsx("input",{ref:p,type:"text",value:c,"aria-label":n!==void 0?`First file in ${n}`:t==="dir"?"New folder name":"New file name",placeholder:t==="dir"?"folder-name":"file-name",onChange:i=>o(i.target.value),onBlur:m,onKeyDown:i=>{i.key==="Enter"?m():i.key==="Escape"&&x()},className:"border-border bg-background focus-ring min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})]});return n===void 0?e.jsx("div",{className:"px-3 py-1",children:r}):e.jsxs("div",{className:"space-y-1 px-3 py-1",children:[e.jsxs("p",{className:"text-muted-foreground flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(be,{className:"size-(--size-icon-xs) flex-shrink-0 text-sky-500"}),e.jsx("span",{className:"truncate",children:n})]}),r,e.jsx("p",{className:"text-muted-foreground text-2xs",children:"Name its first file. The folder appears on save."})]})}function at(){const t=H(x=>x.showHidden),n=H(x=>x.setShowHidden),a=t?"Hide hidden files":"Show hidden files";return e.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":a,title:a,onClick:()=>n(!t),children:t?e.jsx(bt,{className:"text-muted-foreground"}):e.jsx(jt,{className:"text-muted-foreground"})})}function Mn({cwd:t}){const n=ne(),{data:a}=ce({queryKey:["file-explorer","workspace",t],queryFn:()=>n.resolveWorkspace(t),staleTime:6e4});return a!=null&&a.branch?e.jsxs("span",{className:"text-muted-foreground bg-muted/50 text-2xs inline-flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5",title:`Workspace ${a.key} on ${a.branch}`,children:[e.jsx(Ze,{className:"size-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a.branch})]}):null}function Xn(){const t=Te(a=>a.selectedCwd),n=H(a=>a.commands);return t?e.jsxs(e.Fragment,{children:[e.jsx(Mn,{cwd:t}),e.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New file",title:"New file",onClick:()=>n==null?void 0:n.newFile(),children:e.jsx(et,{className:"text-muted-foreground"})}),e.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New folder",title:"New folder",onClick:()=>n==null?void 0:n.newFolder(),children:e.jsx(He,{className:"text-muted-foreground"})}),e.jsx(at,{}),e.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"Refresh",title:"Refresh",onClick:()=>n==null?void 0:n.refresh(),children:e.jsx(kt,{className:"text-muted-foreground"})})]}):null}function _n({roomId:t}){const n=ne(),a=oe(),x=ce(Ue(n,t));s.useEffect(()=>Yt(a,t,()=>{a.invalidateQueries({queryKey:De.repoStatus(t)})}),[a,t]);const p=s.useMemo(()=>{var r;return((r=x.data)==null?void 0:r.kind)==="ok"?wt(x.data.status):[]},[x.data]),c=Et(p),o=Dt(p);if(!o)return null;const m=p.map((r,i)=>`${c[i]}: ${Nt(r)}`);return e.jsxs("span",{"data-slot":"pending-work-badge",title:m.join(`
|
|
17
|
-
`),className:"text-muted-foreground bg-muted/50 text-2xs inline-flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5",children:[e.jsx(Ze,{className:"size-3 flex-shrink-0"}),e.jsxs("span",{className:"sr-only",children:["Not merged into the room yet. ",m.join(". "),"."]}),e.jsx("span",{"aria-hidden":"true",className:"truncate",children:o})]})}const An={added:"added",modified:"changed",deleted:"deleted",untracked:"new"},Ln=new Map([["OPERATOR_ONLY","Only the owner of this DorkOS can keep or discard these."],["ROOM_FILE_NOT_FOUND","One of those changes is gone, so nothing was discarded. The list is refreshed."],["MERGE_IN_FLIGHT","Something else is writing to these files. Nothing changed. Try again in a moment."],["MAIN_CHECKOUT_DIRTY","These files are on another branch. Switch them back to main yourself."],["ROOM_REPO_GIT_UNAVAILABLE","Room files need git, and git isn’t installed on this computer."],["ROOM_HAS_NO_REPO","This room no longer has its own files."],["ROOM_REPOS_DISABLED","Room files are turned off on this install."]]);function zn({roomId:t}){var U,I;const n=ne(),a=oe(),x=ce(Ue(n,t)),[p,c]=s.useState([]),[o,m]=s.useState(!1),[r,i]=s.useState(null),u=Rt({mutationFn:k=>n.repairRoomMain(t,k),onSuccess:()=>{c([]),m(!1),i(null),a.invalidateQueries({queryKey:De.repoStatus(t)})},onError:k=>{m(!1);const h=Ln.get(St(k)??"");i(h??"Couldn’t update the files. Try again in a moment."),a.invalidateQueries({queryKey:De.repoStatus(t)})}});if(((U=x.data)==null?void 0:U.kind)==="unavailable")return e.jsx("p",{role:"alert","data-slot":"room-main-warning",className:"border-border/60 text-muted-foreground rounded-lg border px-3 py-2.5 text-xs",children:"Couldn’t check this room’s files. Saves may not work. Try again soon."});const N=((I=x.data)==null?void 0:I.kind)==="ok"?x.data.status.main:void 0;if(N===void 0||!N.dirty)return null;const F=N.branch!=="main",D=p.filter(k=>N.strays.some(h=>h.path===k)),L=o&&D.length>0,C=k=>c(h=>h.includes(k)?h.filter(g=>g!==k):[...h,k]);return e.jsxs("div",{"data-slot":"room-main-warning",className:"border-border/60 bg-muted/40 space-y-3 rounded-lg border px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Tt,{className:"text-muted-foreground mt-0.5 size-(--size-icon-sm) flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{role:"alert",className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Somebody changed this room’s files outside DorkOS"}),F?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:`This room’s files are on ${N.branch??"no branch"}, not main.`}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Saves and agent merges wait until they’re back on main."})]}):e.jsx("p",{className:"text-muted-foreground text-xs",children:"Saves and agent merges wait until you keep or discard these."})]}),F&&e.jsx(tn,{className:"text-xs",children:e.jsx("p",{children:"DorkOS won’t switch the branch for you. There may be work on it."})})]})]}),!F&&e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"space-y-1.5",children:N.strays.map(k=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Ft,{id:`stray-${t}-${k.path}`,checked:D.includes(k.path),onCheckedChange:()=>C(k.path),disabled:u.isPending}),e.jsx("label",{htmlFor:`stray-${t}-${k.path}`,className:"min-w-0 flex-1 cursor-pointer truncate font-mono text-xs",title:k.path,children:k.path}),e.jsx("span",{className:"text-muted-foreground flex-shrink-0 text-xs",children:An[k.kind]})]},k.path))}),N.strayCount>N.strays.length&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["…and ",N.strayCount-N.strays.length," more not shown. “Keep them all” keeps these too."]}),L?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs",children:D.length===1?"Discard this change? It can’t be undone.":`Discard these ${D.length} changes? They can’t be undone.`}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Y,{type:"button",variant:"ghost",size:"sm",disabled:u.isPending,onClick:()=>m(!1),children:"Cancel"}),e.jsx(Y,{type:"button",variant:"destructive",size:"sm",disabled:u.isPending,onClick:()=>u.mutate({action:"discard",paths:[...D]}),children:D.length===1?"Discard change":`Discard ${D.length} changes`})]})]}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Y,{type:"button",variant:"outline",size:"sm",disabled:u.isPending,onClick:()=>u.mutate({action:"commit"}),children:"Keep them all"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",disabled:u.isPending||D.length===0,onClick:()=>m(!0),children:D.length===0?"Discard…":`Discard ${D.length}`})]})]}),r!==null&&e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:r})]})}const Ee="pointer-coarse:size-11";function Jn({roomId:t,canChange:n}){const a=ne(),x=oe(),p=H(F=>F.showHidden),[c,o]=s.useState(null),m=s.useMemo(()=>Be({transport:a,queryClient:x,roomId:t,canChange:n}),[a,x,t,n]),r=ce(ke(m,Q,p,x)),i=r.isSuccess&&r.data.absent!==!0||r.isError,[u,N]=s.useState(null);return i&&u!==t&&N(t),!i&&u!==t?null:e.jsxs("section",{"aria-label":"Room files",className:"space-y-2",children:[e.jsxs("header",{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),e.jsx("h3",{className:"text-muted-foreground text-xs font-medium tracking-wide uppercase",children:"Files"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(_n,{roomId:t})}),n&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"New file",title:"New file",disabled:c===null,onClick:()=>c==null?void 0:c.newFile(),children:e.jsx(et,{className:"text-muted-foreground"})}),e.jsx(Y,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"New folder",title:"New folder",disabled:c===null,onClick:()=>c==null?void 0:c.newFolder(),children:e.jsx(He,{className:"text-muted-foreground"})}),e.jsx(Y,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"Upload files",title:"Upload files",disabled:(c==null?void 0:c.upload)===void 0,onClick:()=>{var F;return(F=c==null?void 0:c.upload)==null?void 0:F.call(c)},children:e.jsx(sn,{className:"text-muted-foreground"})})]}),e.jsx(at,{})]}),e.jsx(zn,{roomId:t}),e.jsx("div",{"data-slot":"room-files-body",className:"border-border/60 h-72 overflow-hidden rounded-lg border",children:e.jsx(Pn,{source:m,onCommands:o})})]})}function es({roomId:t,attachment:n}){var i;const a=ne(),x=oe(),p=s.useMemo(()=>Be({transport:a,queryClient:x,roomId:t}),[a,x,t]),c=ce(ke(p,Q,!1,x)),[o,m]=s.useState(!1),r=Ot(t);return!c.isSuccess||c.data.absent===!0||((i=r.data)==null?void 0:i.archived)!==!1?null:e.jsxs(e.Fragment,{children:[e.jsx(Y,{type:"button",variant:"ghost",size:"icon-xs","aria-label":`Save ${n.name} to the room’s files`,title:"Save to room files",className:"text-muted-foreground hover:text-foreground mt-0.5 pointer-coarse:size-11",onClick:()=>m(!0),children:e.jsx(Mt,{})}),o&&e.jsx($n,{roomId:t,source:p,attachment:n,onClose:()=>m(!1)})]})}function $n({roomId:t,source:n,attachment:a,onClose:x}){const p=ne(),c=oe(),[o,m]=s.useState(Q),[r,i]=s.useState(a.name),[u,N]=s.useState(null),[F,D]=s.useState(!1),L=s.useId(),C=ce(ke(n,o,!1,c)),U=s.useMemo(()=>{var k;return nt(((k=C.data)==null?void 0:k.entries)??[]).filter(h=>h.type==="dir")},[C.data]),I=async()=>{var h,g;const k=r.trim();if(k!==""){D(!0),N(null);try{await p.saveAttachmentToRoomFiles(t,{attachmentId:a.id,dir:o,name:k,baseCommit:((h=C.data)==null?void 0:h.commit)??null}),c.invalidateQueries({queryKey:["file-explorer","tree",n.scopeKey]}),J.success(`Saved ${k} to the room’s files`),x()}catch(w){let b;try{b=Gt(w,c,t)}catch{b={status:"refused",reason:Qe(w)??"Couldn’t save. Try again in a moment."}}if(b.status==="exists"){const S=(((g=C.data)==null?void 0:g.entries)??[]).map(K=>K.name);N({reason:`This folder already has a file called “${k}”. Pick another name.`,suggestion:Oe({name:k,isDir:!1,taken:[...S,k]})})}else b.status==="conflict"?(N({reason:"This folder changed while you chose, so nothing was saved. Try again."}),C.refetch()):b.status==="refused"&&N({reason:b.reason})}finally{D(!1)}}};return e.jsx(_t,{open:!0,onOpenChange:k=>!k&&x(),children:e.jsxs(At,{className:"sm:max-w-md",children:[e.jsxs(Lt,{children:[e.jsx(zt,{children:"Save to room files"}),e.jsx($t,{children:"Everyone in the room, and their agents, can find it there."})]}),e.jsxs(It,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Folder"}),e.jsxs("div",{role:"group","aria-label":"Folders",className:"border-border/60 max-h-56 overflow-auto rounded-md border",children:[e.jsx("p",{className:"bg-muted/40 truncate px-3 py-1.5 font-mono text-xs",children:o===Q?"Top folder":`${o}/`}),o!==Q&&e.jsx($e,{label:"Up one folder",icon:e.jsx(nn,{className:"text-muted-foreground size-(--size-icon-sm)"}),onClick:()=>m(G(o))}),C.isPending?e.jsx("div",{className:"flex h-12 items-center justify-center",children:e.jsx(Fe,{size:"sm",className:"text-muted-foreground",label:"Loading folders"})}):U.length===0?e.jsx("p",{className:"text-muted-foreground px-3 py-2 text-xs",children:"No folders in here."}):U.map(k=>e.jsx($e,{label:k.name,icon:e.jsx(be,{className:"size-(--size-icon-sm) text-sky-500"}),chevron:!0,onClick:()=>m(ee(o,ie(k.path)))},k.path))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:L,className:"text-muted-foreground text-xs font-medium",children:"Name"}),e.jsx(Kt,{id:L,value:r,onChange:k=>{i(k.target.value),N(null)},spellCheck:!1,autoComplete:"off"})]}),u!==null&&e.jsxs("div",{role:"alert",className:"text-destructive space-y-1 text-xs",children:[e.jsx("p",{children:u.reason}),u.suggestion!==void 0&&e.jsxs(Y,{type:"button",variant:"outline",size:"xs",onClick:()=>{i(u.suggestion),N(null)},children:["Use “",u.suggestion,"”"]})]})]}),e.jsxs(Ht,{className:"gap-2",children:[e.jsx(Y,{type:"button",variant:"ghost",onClick:x,children:"Cancel"}),e.jsx(Y,{type:"button",disabled:F||r.trim()===""||C.isPending,onClick:()=>void I(),children:F?"Saving…":o===Q?"Save to the top folder":`Save to ${ie(o)}`})]})]})})}function $e({label:t,icon:n,chevron:a=!1,onClick:x}){return e.jsxs("button",{type:"button",onClick:x,className:"hover:bg-accent/50 focus-visible:bg-accent flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm outline-none",children:[n,e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),a&&e.jsx(Ke,{className:"text-muted-foreground size-3.5"})]})}export{Pn as FileExplorer,Xn as FileExplorerActions,Wt as FilePreviewDialog,an as HIDDEN_ENTRY_NAMES,at as HiddenEntriesToggle,ss as NO_PROVENANCE,Ne as PINNED_ENTRY_NAMES,as as ROOM_FILES_REFRESH_INTERVAL_MS,Jn as RoomFilesSection,es as SaveToRoomFilesButton,Be as createRoomFilesSource,xn as createSessionCwdSource,le as explorerDirQueryKey,ke as explorerDirQueryOptions,rn as isHiddenEntryName,Re as isPinnedEntryName,on as pinnedFirst,Bt as provenanceLine,Ue as roomRepoStatusQueryOptions,nt as withoutHidden};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as h,M as w}from"./Marketplace-iL5p8Omt.js";import{M as U,P as V,m as b,u as C,a as D}from"./index-DcZPWi_I.js";import{M as q}from"./MarketplaceSourcesView-CsNLVOdP.js";import{U as y}from"./UnlinkDialog-CFRgExId.js";import"./PreviewRefusedNotice-D1Tl265t.js";import"./shield-x-Dhl4YvvW.js";import"./card-ww4ebz8h.js";import"./empty-state-DXWQsHMf.js";import"./markdown-content-Cqq_QMXA.js";import"./use-unclaimed-chats-DKpexDm3.js";import"./use-bindings-CpyT6kNu.js";import"./more-details-B4lBMpKi.js";import"./use-dev-links-B3I-ZK34.js";import"./terminal-C9M5a_PS.js";import"./file-Bf7D_47y.js";import"./AgentPicker-CL93SET3.js";import"./command-D4fLpJxA.js";import"./AgentOptionRow-BWFQFynn.js";import"./useMutationState-Btf2Hp1a.js";import"./file-exclamation-point-DZXE9_8o.js";import"./rotate-ccw-clock-CeY00nlZ.js";import"./path-input-DpqUD8hN.js";import"./use-pending-read-DBOl1ee_.js";export{h as InstalledPackagesView,w as Marketplace,U as MarketplaceSidebar,q as MarketplaceSourcesView,V as PackageCard,y as UnlinkDialog,b as marketplaceSearchSchema,C as useMarketplaceParams,D as useMarketplaceStore};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aN as a,aO as s}from"./index-DcZPWi_I.js";const t={tasks:s,moment:a};export{t as i};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{c as r,s as e}from"./flowDiagram-IUGLLWBU-CdlOoRZV.js";import{_ as o}from"./mermaid.core-dpp59v7L.js";import"./transform-BqqRT-Iy.js";import"./chunk-5VM5RSS4-B3K3MUav.js";import"./chunk-XXDRQBXY-E0nvzXiG.js";import"./chunk-VQ5W62QI-CWoRr0H2.js";import"./chunk-55XCU76K-CiBbKG0b.js";import"./BlintzCanvas-DoAZs5bz.js";import"./index-DcZPWi_I.js";import"./index-B6dEbNhI.js";import"./index-mFOJXyAE.js";import"./channel-DZpRF3QJ.js";var a=o(t=>`${e(t)}
|
|
2
|
-
.swimlane.cluster:not([data-color-id]) rect {
|
|
3
|
-
stroke: ${t.clusterBorder} !important;
|
|
4
|
-
}
|
|
5
|
-
[data-look="neo"].cluster rect {
|
|
6
|
-
filter: none;
|
|
7
|
-
}
|
|
8
|
-
`,"getStyles"),m=a,v=r({styles:m});export{v as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aw as e}from"./index-DcZPWi_I.js";const o=1024;function t(){return e(`(max-width: ${o-1}px)`)}export{t as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{as as r}from"./index-DcZPWi_I.js";function u(){var e;return((e=r().data)==null?void 0:e.serverRole)==="hub"}export{u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ac as n}from"./index-DcZPWi_I.js";function r(s){const e=n();return s||e}export{r as u};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlintzCanvas-DoAZs5bz.js","assets/index-DcZPWi_I.js","assets/index-CrflCTqO.css","assets/index-B6dEbNhI.js","assets/index-mFOJXyAE.js","assets/BlintzCanvas-xZ3u3nk7.css","assets/CanvasFileContent-ClcHZ_l-.js","assets/rotate-cw-Djl5J_x9.js","assets/index.esm-CZZtbPRj.js","assets/WidgetErrorCard-Dx5oPMlF.js","assets/index-1ShgR_xt.js","assets/card-ww4ebz8h.js","assets/progress-DlIRjXIA.js","assets/markdown-content-Cqq_QMXA.js","assets/table-L7FvN6Or.js","assets/terminal-C9M5a_PS.js","assets/package-6Rbxg35g.js","assets/heart-CmqGJPDc.js","assets/git-branch-B2k77X3Q.js","assets/file-text-C1ougnBY.js","assets/file-Bf7D_47y.js","assets/McpAppFrame-B1WPswgk.js","assets/more-details-B4lBMpKi.js","assets/CanvasModel3dContent-Cm3msNdQ.js","assets/CanvasCsvContent-ViqRJuhW.js","assets/index-yI1r4pSP.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Lr=Object.defineProperty;var Gt=e=>{throw TypeError(e)};var Pr=(e,t,r)=>t in e?Lr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ee=(e,t,r)=>Pr(e,typeof t!="symbol"?t+"":t,r),dt=(e,t,r)=>t.has(e)||Gt("Cannot "+r);var Te=(e,t,r)=>(dt(e,t,"read from private field"),r?r.call(e):t.get(e)),Me=(e,t,r)=>t.has(e)?Gt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),ge=(e,t,r,n)=>(dt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),ve=(e,t,r)=>(dt(e,t,"access private method"),r);import{W as at,lM as ct,fE as se,fP as Y,fI as $t,fL as qe,fF as $e,lN as Br,lO as Ur,lP as Wr,aX as Ce,a1 as ue,r as p,c6 as St,lQ as Gr,aW as J,is as $r,j as d,hp as Hr,hq as Vr,e2 as Jr,G as Dt,I as Xr,fp as Zr,lR as Yr,lS as cr,lT as bt,lU as rt,lV as ur,fD as Ht,lW as Qr,fG as Vt,lX as Kr,lY as en,gD as V,lZ as tn,l_ as rn,B as et,J as lr,gp as dr,C as nn,as as sn,l$ as on,m0 as an,m1 as Jt}from"./index-DcZPWi_I.js";import{R as cn}from"./rotate-cw-Djl5J_x9.js";import{T as un,a as ln,u as dn}from"./index.esm-CZZtbPRj.js";import{v as fn,a as hn,W as pn}from"./WidgetErrorCard-Dx5oPMlF.js";import{M as mn}from"./McpAppFrame-B1WPswgk.js";/**
|
|
3
|
-
* @license lucide-react v1.48.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const fr={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"}]]};fr.node;const Bi=at(fr);/**
|
|
8
|
-
* @license lucide-react v1.48.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const hr={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"}]]};hr.node;const gn=at(hr);/**
|
|
13
|
-
* @license lucide-react v1.48.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const pr={name:"zoom-in",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:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};pr.node;const vn=at(pr);/**
|
|
18
|
-
* @license lucide-react v1.48.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const mr={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"}]]};mr.node;const bn=at(mr),Oe={pending:64,queueBytes:1048576,batchMs:300,frames:62,imageChars:9e5,imageEdge:1568,resourceErrors:1e4},nt=$e().min(1).max(128),Ie={bridgeGeneration:nt},wn=se({...Ie,__dorkosDevtools:Y("capture-result"),requestId:nt,dataUrl:$e().max(9e5).optional(),error:$e().max(2048).optional()}),yn=Br.omit({hostOutcome:!0}).extend({...Ie,__dorkosDevtools:Y("act-result"),dataUrl:$e().max(9e5).optional()}),xn=Ur.extend({status:qe().int().min(0).max(599),durationMs:qe().min(0),responseSize:qe().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),timestamp:qe().min(0)}),kn=Wr.refine(e=>e.timestamp>=0),jn=ct("__dorkosDevtools",[se({__dorkosDevtools:Y("hello"),pageInstanceId:nt,bridgeVersion:Y(2)}),se({...Ie,__dorkosDevtools:Y("ready"),pageInstanceId:nt}),se({...Ie,__dorkosDevtools:Y("navigated")}),se({...Ie,__dorkosDevtools:Y("resource-error")}),se({...Ie,__dorkosDevtools:Y("batch"),seq:qe().int().min(0).max(Number.MAX_SAFE_INTEGER),console:$t(kn).max(500),network:$t(xn).max(200)}),wn,yn]);function Cn(e){const t=new Set;let r=0,n=0;const s=c=>(n+=c)<=16384;function i(c){if(!s(2))return!1;for(let o=0;o<c.length;o++){const f=c.charCodeAt(o);if(f>=55296&&f<=56319&&o+1<c.length&&c.charCodeAt(o+1)>=56320&&c.charCodeAt(o+1)<=57343){if(!s(2))return!1;o++;continue}const l=f===34||f===92||[8,9,10,12,13].includes(f)?2:f<32||f>=55296&&f<=57343?6:1;if(!s(l))return!1}return!0}function a(c,o){if(++r>2048||o>8)return!1;if(c===null)return s(4);if(typeof c=="boolean")return s(c?4:5);if(typeof c=="string")return i(c);if(typeof c=="number")return Number.isFinite(c)&&s(String(c).length);if(typeof c!="object"||t.has(c))return!1;const f=Object.getPrototypeOf(c);if(f!==Object.prototype&&f!==null&&f!==Array.prototype)return!1;const l=Array.isArray(c);if(l&&c.length>2048||Object.getOwnPropertySymbols(c).length||!s(2))return!1;t.add(c);let h=0;for(const u in c){if(!Object.prototype.hasOwnProperty.call(c,u))continue;if(++h>2048||l&&(!/^\d+$/.test(u)||Number(u)>=c.length))return!1;const g=Object.getOwnPropertyDescriptor(c,u);if(["__proto__","constructor","prototype"].includes(u)||!("value"in g)||!g.enumerable||h>1&&!s(1)||!l&&(!i(u)||!s(1))||!a(g.value,o+1))return!1}return t.delete(c),!l||h===c.length}try{return a(e,0)}catch{return!1}}function Rn(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 i=s.args;if(i!==void 0&&(!Array.isArray(i)||i.length>50||!Cn(i)))return null}}const r=jn.safeParse(e);if(!r.success)return null;const n=r.data;return"dataUrl"in n&&n.dataUrl!==void 0&&!gr(n.dataUrl)?null:n}catch{return null}}function gr(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
|
-
|
|
24
|
-
`||t.slice(12,16)!=="IHDR")return null;const r=i=>t.charCodeAt(i)*2**24+(t.charCodeAt(i+1)<<16)+(t.charCodeAt(i+2)<<8)+t.charCodeAt(i+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 ft=null;async function Xt(){return ft===null&&(ft=(await Ce(()=>import("./html-to-image-cl8bZGTj.js"),[])).default),ft}let ht=null;async function On(){if(ht===null){const e=await Ce(()=>import("./gifenc.esm-sOOlYEo8.js"),[]);ht={GIFEncoder:e.GIFEncoder,quantize:e.quantize,applyPalette:e.applyPalette}}return ht}async function Zt(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:i}=await On();r();const a=e[0],c=e[e.length-1],o=new Uint8ClampedArray(a.data.length+c.data.length);o.set(a.data,0),o.set(c.data,a.data.length);const f=s(o,256),l=n();for(let u=0;u<e.length;u++){r();const g=e[u];if(l.writeFrame(i(g.data,f),g.width,g.height,{...u===0?{palette:f,repeat:0}:{},delay:t.frameMs}),l.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.`}}l.finish();const h=l.bytes();return h.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:h}}async function En(e,t,r=()=>{}){const n=[],s=document.createElement("canvas");let i=0,a=0;try{for(let c=0;c<Math.min(e.length,62);c++){r();const o=e[c];if(!gr(o)){e[c]="";continue}const f=await Sn(o);e[c]="";try{if(r(),!f)continue;if(!i){const u=Math.min(1,Math.min(800,t)/Math.max(f.width,f.height,1));i=Math.max(1,Math.round(f.width*u)),a=Math.max(1,Math.round(f.height*u)),s.width=i,s.height=a}const l=s.getContext("2d",{willReadFrequently:!0});if(!l)return[];l.fillStyle="#ffffff",l.fillRect(0,0,i,a);const h=Math.min(i/f.width,a/f.height);l.drawImage(f,0,0,Math.round(f.width*h),Math.round(f.height*h)),r(),n.push({data:l.getImageData(0,0,i,a).data,width:i,height:a})}finally{f&&(f.src="")}}return n}catch(c){throw n.length=0,c}finally{e.length=0,s.width=0,s.height=0}}function _n(e,t=()=>{}){const r=document.createElement("canvas"),n=document.createElement("canvas");try{for(let s=0;s<e.length;s++){t();const i=e[s];n.width=i.width,n.height=i.height,r.width=Math.max(1,Math.round(i.width/2)),r.height=Math.max(1,Math.round(i.height/2));const a=n.getContext("2d"),c=r.getContext("2d",{willReadFrequently:!0});if(!a||!c)throw new Error("Canvas pixels are unavailable");a.putImageData(new ImageData(new Uint8ClampedArray(i.data),i.width,i.height),0,0),c.drawImage(n,0,0,r.width,r.height),e[s]={data:c.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 Sn(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 Yt(e,t,r){const n=r.slice().buffer;return{name:e,type:t,size:r.byteLength,arrayBuffer:async()=>n}}function Dn(e){const t=atob(e.slice(e.indexOf(",")+1));return Uint8Array.from(t,r=>r.charCodeAt(0))}const In=8e3;function An(e){const t=ue(),r=p.useRef(t);p.useLayoutEffect(()=>{r.current=t});const[n]=St(),[s,i]=p.useState(0),a=p.useRef(null),c=p.useRef(new Map),o=p.useRef(null),f=p.useRef({console:[],network:[],entryBytes:0,overheadBytes:0}),l=p.useRef(null),h=p.useRef(-1),u=p.useRef(null),g=p.useRef(null),w=p.useRef(!1),m=p.useRef(-1/0),y=p.useRef(!1),N=p.useRef(null),D=p.useRef(0),I=p.useRef(null),M=p.useRef(null),T=p.useRef(!1),U=p.useRef(null),P=p.useRef({...e,sessionId:n}),q=p.useRef(Promise.resolve()),$=p.useRef(()=>{}),te=p.useRef({initialize:S,retire:b,consume:ae,register:L,eligiblePending:K,refuseRequest:k,live:R,captureFrame:lt,valid:Ye,reportRecordingStart:Ae,cancelReservation:Tt,finish:Mt});p.useLayoutEffect(()=>{te.current={initialize:S,retire:b,consume:ae,register:L,eligiblePending:K,refuseRequest:k,live:R,captureFrame:lt,valid:Ye,reportRecordingStart:Ae,cancelReservation:Tt,finish:Mt}});const me=C=>U.current===C||J.getState().openDocuments.some(v=>v.id===C&&v.openedHere);function x(C,{active:v,activation:O=!1,keepalive:j=!1,reset:A=!1}){if(!C.sessionId)return;const Z={documentId:C.documentId,logicalUrl:C.logicalUrl,bridgeGeneration:C.generation,seq:Math.max(0,h.current),console:[],network:[],active:v,activation:O,instrumented:C.ready&&!C.retired,...A?{reset:!0}:{}};q.current=q.current.then(()=>r.current.ingestDevtoolsCapture(C.sessionId,Z,j?{keepalive:!0}:void 0)).catch(()=>{})}function b(){var O;const C=a.current;C&&(C.retired=!0),a.current=null,l.current!==null&&clearTimeout(l.current),l.current=null,o.current=null,f.current={console:[],network:[],entryBytes:0,overheadBytes:0},h.current=-1,m.current=-1/0,y.current=!1;for(const[j,A]of c.current)A.life.sessionId&&A.deadline>Date.now()&&A.kind!=="frame"&&k(j,A.kind,A.life,"The frame changed while this request was pending."),clearTimeout(A.timer),(O=A.resolve)==null||O.call(A,null);c.current.clear(),C&&x(C,{active:!1});const v=N.current;v&&(clearTimeout(v.reservationTimer),v.cancelled=!0,v.abort.abort(),v.frames.length=0,v.finishing||(v.drawn.length=0,N.current=null)),I.current!==null&&cancelAnimationFrame(I.current),I.current=null,D.current=0,i(0)}function S({loadActivation:C,reset:v=!1}={}){var G,ne;const O=P.current,j=(G=O.iframeRef.current)==null?void 0:G.contentWindow;if(w.current||!j||!O.bridgeEligibility||!O.resolvedSource)return;const A={generation:crypto.randomUUID(),frame:j,sessionId:O.sessionId,documentId:O.documentId,logicalUrl:O.logicalUrl,source:O.resolvedSource,origin:O.bridgeEligibility==="served-document"?"null":O.previewOrigin,ready:!1,activation:!1,retired:!1};a.current=A;const Z=C??(T.current||M.current!==A.documentId&&me(A.documentId));A.activation=Z,T.current=!1,M.current=A.documentId,x(A,{active:!0,activation:Z,reset:v}),((ne=u.current)==null?void 0:ne.frame)===j&&u.current.source===O.resolvedSource&&u.current.reload===O.reloadNonce&&u.current.documentId===O.documentId&&u.current.logicalUrl===O.logicalUrl&&j.postMessage({__dorkosDevtools:"init",bridgeGeneration:A.generation},"*")}p.useLayoutEffect(()=>{var j;P.current={...e,sessionId:n};const C={frame:(j=e.iframeRef.current)==null?void 0:j.contentWindow,sessionId:n,documentId:e.documentId,logicalUrl:e.logicalUrl,source:e.resolvedSource,eligibility:e.bridgeEligibility,origin:e.previewOrigin,reload:e.reloadNonce},v=g.current;if(!v||Object.keys(C).some(A=>C[A]!==v[A])){const A=!v||v.frame!==C.frame||v.documentId!==C.documentId||v.logicalUrl!==C.logicalUrl||v.source!==C.source||v.reload!==C.reload;g.current=C,w.current=!1,b(),S({reset:A})}});const _=p.useCallback(()=>{var Z,G,ne;const{initialize:C,retire:v}=te.current,O=P.current,j=(Z=O.iframeRef.current)==null?void 0:Z.contentWindow,A=(G=a.current)!=null&&G.ready?!1:(ne=a.current)==null?void 0:ne.activation;j&&O.resolvedSource&&(u.current={frame:j,source:O.resolvedSource,reload:O.reloadNonce,documentId:O.documentId,logicalUrl:O.logicalUrl}),w.current=!1,v(),C({loadActivation:A,reset:!0})},[]),z=p.useCallback(()=>{const C=a.current;T.current=!0,U.current=P.current.documentId,C&&$.current({active:!0,activation:!0})},[]);p.useLayoutEffect(()=>{$.current=C=>{a.current&&x(a.current,C)}});function R(C){return a.current===C&&!C.retired}function k(C,v,O,j){if(!O.sessionId)return;const A={requestId:C,bridgeGeneration:O.generation,documentId:O.documentId,hostOutcome:"host",error:j};v==="action"?r.current.postDevtoolsAction(O.sessionId,{...A,ok:!1}).catch(()=>{}):r.current.ingestDevtoolsCapture(O.sessionId,{...A,logicalUrl:O.logicalUrl,seq:Math.max(0,h.current),console:[],network:[],screenshot:{requestId:C,error:j}}).catch(()=>{})}function L(C,v,O,{capture:j=!1,resolve:A,timeoutMs:Z=8e3}={}){if(c.current.size>=Oe.pending||c.current.has(C))return null;const G=setTimeout(()=>W(C,ne),Z),ne={kind:v,life:O,capture:j,deadline:Date.now()+Z,timer:G,resolve:A};return c.current.set(C,ne),ne}function W(C,v){var O;c.current.get(C)===v&&(c.current.delete(C),clearTimeout(v.timer),(O=v.resolve)==null||O.call(v,null))}function K(C,v,O){return c.current.get(C)!==v||v.life!==O||!R(O)?!1:Date.now()>=v.deadline?(W(C,v),!1):!0}function ae(C,v,O){const j=c.current.get(C);return!j||j.life!==O||j.kind!==v&&!(v==="capture"&&j.kind==="frame")||!K(C,j,O)?null:(c.current.delete(C),clearTimeout(j.timer),j)}p.useEffect(()=>{const{initialize:C,retire:v,consume:O}=te.current;function j(){l.current=null;const le=o.current;o.current=null,f.current={console:[],network:[],entryBytes:0,overheadBytes:0};const E=a.current;le&&E&&!E.retired&&E.sessionId&&le.bridgeGeneration===E.generation&&r.current.ingestDevtoolsCapture(E.sessionId,le)}function A(le){var qt,Lt,Pt,Bt;const E=a.current;if(!E||E.retired||le.source!==E.frame||le.origin!==E.origin||((qt=u.current)==null?void 0:qt.frame)!==E.frame||u.current.source!==E.source||u.current.reload!==P.current.reloadNonce||u.current.documentId!==E.documentId||u.current.logicalUrl!==E.logicalUrl)return;const F=le.data;if(!F||typeof F!="object"||typeof F.__dorkosDevtools!="string"||!["hello","ready","navigated","resource-error","batch","capture-result","act-result"].includes(F.__dorkosDevtools)||F.__dorkosDevtools!=="hello"&&F.bridgeGeneration!==E.generation)return;const ie=F.__dorkosDevtools==="batch";if(ie){if(!E.ready||!E.sessionId||F.bridgeGeneration!==E.generation||!Number.isSafeInteger(F.seq)||F.seq<0||F.seq<=h.current)return;const H=Date.now();if(H-m.current<Oe.batchMs){o.current?o.current.dropped=!0:y.current=!0;return}m.current=H}const B=Rn(F);if(!B){ie&&(y.current=!0);return}if(B.__dorkosDevtools==="hello"){E.frame.postMessage({__dorkosDevtools:"init",bridgeGeneration:E.generation},"*");return}if(B.bridgeGeneration!==E.generation)return;if(B.__dorkosDevtools==="ready"){E.ready||(E.ready=!0,E.activation=!1,x(E,{active:!0}));return}if(!E.ready)return;if(B.__dorkosDevtools==="navigated"){w.current=!0,v();return}if(B.__dorkosDevtools==="resource-error"){D.current=Math.min(Oe.resourceErrors,D.current+1),I.current===null&&(I.current=requestAnimationFrame(()=>{I.current=null,R(E)&&i(D.current)}));return}if(!E.sessionId)return;if(B.__dorkosDevtools==="batch"){if(B.seq<=h.current)return;h.current=B.seq;const H=o.current??{documentId:E.documentId,logicalUrl:E.logicalUrl,bridgeGeneration:E.generation,seq:B.seq,console:[],network:[]};H.seq=B.seq,y.current&&(H.dropped=!0),y.current=!1;const xe=f.current,Ut=new TextEncoder;if(o.current||(xe.overheadBytes=Ut.encode(JSON.stringify({...H,seq:Number.MAX_SAFE_INTEGER,dropped:!0,console:[],network:[]})).length),xe.overheadBytes>Oe.queueBytes){o.current=null,f.current={console:[],network:[],entryBytes:0,overheadBytes:0},y.current=!0;return}for(const[ze,Fr]of[["console",B.console],["network",B.network]])for(const qr of Fr){const Wt=Ut.encode(JSON.stringify(qr)).length;xe[ze].push(Wt),xe.entryBytes+=Wt}H.console.push(...B.console),H.network.push(...B.network);const Mr=()=>xe.overheadBytes+xe.entryBytes+Math.max(0,H.console.length-1)+Math.max(0,H.network.length-1);for(;H.console.length>500||H.network.length>200||Mr()>Oe.queueBytes;){H.dropped=!0;const ze=(((Lt=H.console[0])==null?void 0:Lt.timestamp)??1/0)<=(((Pt=H.network[0])==null?void 0:Pt.timestamp)??1/0)?"console":"network";if(!H[ze].length)break;H[ze].shift(),xe.entryBytes-=xe[ze].shift()}o.current=H,l.current===null&&(l.current=setTimeout(j,Oe.batchMs));return}if(B.__dorkosDevtools==="capture-result"){const H=O(B.requestId,"capture",E);if(!H)return;if(H.kind==="frame"){(Bt=H.resolve)==null||Bt.call(H,B.dataUrl??null);return}r.current.ingestDevtoolsCapture(E.sessionId,{bridgeGeneration:E.generation,documentId:E.documentId,logicalUrl:E.logicalUrl,seq:Math.max(0,h.current),console:[],network:[],hostOutcome:"page-reported",screenshot:{requestId:B.requestId,dataUrl:B.dataUrl,error:B.error}});return}const Ne=O(B.requestId,"action",E);if(!Ne)return;const Re=N.current,Ft=Ne.capture&&B.dataUrl!==void 0&&Re!==null&&Re.life===E&&Re.activated&&!Re.finishing&&!Re.cancelled&&Re.frames.length<61;Ft&&Re.frames.push(B.dataUrl);const{__dorkosDevtools:Ni,dataUrl:zi,...Tr}=B;r.current.postDevtoolsAction(E.sessionId,{...Tr,hostOutcome:"page-reported",documentId:E.documentId,captured:Ft||void 0})}window.addEventListener("message",A);const Z=setInterval(()=>$.current({active:!0}),15e3),G=()=>{a.current||C(),$.current({active:!0,activation:!0})},ne=()=>{$.current({active:!1,keepalive:!0}),v()},oe=()=>{document.visibilityState==="visible"&&G()};return window.addEventListener("focus",G),window.addEventListener("pagehide",ne),window.addEventListener("pageshow",G),document.addEventListener("visibilitychange",oe),()=>{window.removeEventListener("message",A),clearInterval(Z),window.removeEventListener("focus",G),window.removeEventListener("pagehide",ne),window.removeEventListener("pageshow",G),document.removeEventListener("visibilitychange",oe),v()}},[]),p.useEffect(()=>Gr.subscribeSessionEvent((C,v)=>{if(v.type!=="devtools_capture_request"&&v.type!=="devtools_action_request"&&v.type!=="devtools_recording_request")return;const{register:O,eligiblePending:j,refuseRequest:A,captureFrame:Z,valid:G,finish:ne,reportRecordingStart:oe,cancelReservation:le}=te.current,E=a.current;if(!(!(E!=null&&E.ready)||!E.sessionId||E.retired||v.targetClientId!==r.current.clientId||v.documentId!==E.documentId||v.bridgeGeneration!==E.generation)){if(v.type==="devtools_capture_request"||v.type==="devtools_action_request"){const F=v.type==="devtools_action_request",ie=O(v.requestId,F?"action":"capture",E,{capture:F&&!!v.capture,timeoutMs:F&&v.command.action==="wait_for"?Math.min(1e4,v.command.timeoutMs)+2e3:8e3});if(!ie){c.current.has(v.requestId)||A(v.requestId,F?"action":"capture",E,"Too many browser requests are waiting. Try again when one finishes.");return}const B=Ne=>{j(v.requestId,ie,E)&&E.frame.postMessage(F?{__dorkosDevtools:"act-request",bridgeGeneration:E.generation,requestId:v.requestId,documentId:E.documentId,command:v.command,...v.capture?{capture:!0,lib:Ne}:{}}:{__dorkosDevtools:"capture-request",bridgeGeneration:E.generation,requestId:v.requestId,lib:Ne},"*")};!F||v.capture?Xt().then(B,()=>B()):B()}if(v.type==="devtools_recording_request"){if(v.action==="cancel-start"){le(v.recordingId,v.requestId,E);return}if(v.action==="confirm-start"){const F=N.current;if(!F||F.id!==v.recordingId||F.startRequestId!==v.requestId||F.life!==E||F.finishing||!G(F))return;if(!F.activated){if(performance.now()>=F.reservationDeadline){le(F.id,F.startRequestId,E),oe(v,E,{phase:"started",ok:!1,error:"This recording reservation expired before capture could start."});return}clearTimeout(F.reservationTimer),F.activated=!0,F.startedAt=Date.now(),Z(E).then(ie=>{ie&&G(F)&&F.frames.push(ie)})}oe(v,E,{phase:"started",ok:!0});return}if(v.action==="start"){const F=v.reservationTimeoutMs;if(!Number.isSafeInteger(F)||!F||F<1||F>In){oe(v,E,{phase:"reserved",ok:!1,error:"This recording request has no valid reservation timeout."});return}if(N.current){oe(v,E,{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:v.recordingId,startRequestId:v.requestId,activated:!1,reservationDeadline:performance.now()+F,life:E,startedAt:Date.now(),frames:[],drawn:[],finishing:!1,cancelled:!1,abort:new AbortController};N.current=ie,ie.reservationTimer=setTimeout(()=>{N.current===ie&&!ie.activated&&le(ie.id,ie.startRequestId,E)},F),oe(v,E,{phase:"reserved",ok:!0})}else ne(v.requestId,v.recordingId,E)}}}),[]);function Ae(C,v,O){!R(v)||!v.sessionId||r.current.ingestDevtoolsCapture(v.sessionId,{hostOutcome:"host",documentId:v.documentId,bridgeGeneration:v.generation,seq:0,console:[],network:[],recordingStart:{...O,requestId:C.requestId,recordingId:C.recordingId}}).catch(()=>{})}function Tt(C,v,O){var A;const j=N.current;if(!(!j||j.id!==C||j.startRequestId!==v||j.life!==O||j.finishing)){clearTimeout(j.reservationTimer),j.cancelled=!0,j.abort.abort(),j.frames.length=0,j.drawn.length=0;for(const[Z,G]of c.current)G.life===O&&G.kind==="frame"&&(clearTimeout(G.timer),(A=G.resolve)==null||A.call(G,null),c.current.delete(Z));N.current=null}}function Ye(C){return N.current===C&&!C.cancelled&&R(C.life)}function lt(C){const v=`frame-${crypto.randomUUID()}`;return new Promise(O=>{const j=L(v,"frame",C,{resolve:O});if(!j){O(null);return}Xt().then(A=>{K(v,j,C)&&C.frame.postMessage({__dorkosDevtools:"capture-request",bridgeGeneration:C.generation,requestId:v,lib:A},"*")},()=>{W(v,j)})})}async function Mt(C,v,O){const j=N.current;if(!j||!j.activated||j.id!==v||j.life!==O){R(O)&&await r.current.uploadDevtoolsRecording(O.sessionId,{requestId:C,bridgeGeneration:O.generation,documentId:O.documentId,hostOutcome:"host",error:"The window showing that page stopped recording before it could be saved."}).catch(()=>{});return}if(j.finishing)return;j.finishing=!0;const A=()=>{if(!Ye(j))throw new Error("retired")},Z={requestId:C,bridgeGeneration:O.generation,documentId:O.documentId};try{const G=await lt(O);A(),G&&j.frames.length<Oe.frames&&j.frames.push(G);const ne=j.frames.length?Dn(j.frames[j.frames.length-1]):new Uint8Array;j.drawn=await En(j.frames,800,A),A();let oe=await Zt(j.drawn,{frameMs:500,maxBytes:8*1024*1024},A);if(A(),!oe.ok&&j.drawn.length&&(_n(j.drawn,A),oe=await Zt(j.drawn,{frameMs:500,maxBytes:8*1024*1024},A),A()),!oe.ok){await r.current.uploadDevtoolsRecording(O.sessionId,{...Z,hostOutcome:"host",error:oe.error},{signal:j.abort.signal}),A();return}A(),await r.current.uploadDevtoolsRecording(O.sessionId,{...Z,frames:j.drawn.length,durationMs:Date.now()-j.startedAt,recording:Yt(`${v}.gif`,"image/gif",oe.bytes),keyframe:Yt(`${v}.png`,"image/png",ne)},{signal:j.abort.signal}),A()}catch{Ye(j)&&await r.current.uploadDevtoolsRecording(O.sessionId,{...Z,hostOutcome:"host",error:"This window could not turn that recording into a file."},{signal:j.abort.signal}).catch(()=>{})}finally{j.frames.length=0,j.drawn.length=0,N.current===j&&(N.current=null)}}return{resourceErrorCount:s,notePersonNavigated:z,noteFrameLoaded:_}}const Nn=15e3;function zn(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 Tn(e){const t=ue();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 Mn(e,t){const r=ue(),n=J(s=>s.setRoomCanvasEditing);p.useEffect(()=>{if(n(e,t),t===null)return;const s=a=>{r.setRoomCanvasEditing(e,t,a).catch(c=>{console.warn("[room-canvas] edit lock failed",{roomId:e,documentId:t,err:c})})};s(!0);const i=setInterval(()=>s(!0),Nn);return()=>{clearInterval(i),s(!1),n(e,null)}},[r,e,t,n])}const Fn=400;function Ui(e,t){const r=ue(),n=J(s=>s.roomCanvasPresenceEpoch[e]??0);p.useEffect(()=>{const s=c=>{r.setRoomCanvasViewing(e,c).catch(o=>{console.warn("[room-canvas] could not say where we are looking",{roomId:e,err:o})})};let i=!1;const a=setTimeout(()=>{i=!0,s(t)},Fn);return()=>{clearTimeout(a),i&&s(null)}},[r,e,t,n])}const qn="allow-scripts allow-forms allow-popups allow-modals",pt="allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-downloads",Ln=new Set(["javascript:","data:","blob:"]),Pn=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","::1"]);function It(e){return Pn.has(e)||e.endsWith(".localhost")}function Bn(e){return It(e)?"direct":"server"}function Un(e,t){let r;try{r=new URL(e)}catch{return null}const n=r.searchParams.get(Qt),s=new URL(r.origin),i=t.indexOf("?");return s.pathname=(i===-1?t:t.slice(0,i))||"/",s.search=i===-1?"":t.slice(i),n!==null&&s.searchParams.set(Qt,n),s.toString()}const Qt="__dorkos_preview",Wn="/__dorkos_preview/health";function Gn(e){return e==="https:"?443:80}function vr(e){let t;try{t=new URL(e)}catch{return{mode:"serve",path:e}}if(Ln.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(It(t.hostname)){const r=t.port?Number(t.port):Gn(t.protocol);return{mode:"proxy",hostname:t.hostname,port:r,path:`${t.pathname}${t.search}`}}return{mode:"external",url:e}}return{mode:"blocked"}}function $n(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`${It(s)?"http":"https"}://${t}`}function Hn(e){const t=vr(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 Vn=2e3;async function Kt(e,t=globalThis.fetch,r=Vn){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 Jn({target:e,currentUrl:t,strategy:r,cwd:n,reloadNonce:s}){const i=JSON.stringify([t,r,n,s]),[a,c]=p.useState(null),[o,f]=p.useState(null),[l,h]=p.useState(null),u=ue(),g=p.useRef(u);return p.useEffect(()=>{g.current=u}),p.useEffect(()=>{const w=g.current;let m=!1;const y=M=>{c(i),f(M)};async function N(M){if(n===null){h({kind:"no-session"});return}try{const T=await w.createServeUrl(n,M);if(m)return;T===null?h({kind:"unsupported"}):y({src:T,sandbox:qn,previewOrigin:null,bridgeEligibility:"served-document"})}catch{m||h({kind:"failed"})}}async function D(M,T){let U;try{const q=await w.probeLoopbackPort(M);U=q===null?"unknown":q.listening}catch{U="unknown"}if(m)return;let P=null;if(U!==!1){let q=null;try{q=await w.createProxyUrl(M)}catch{if(m)return;P={kind:"failed"}}if(m)return;if((q==null?void 0:q.unavailable)==="tunnel"){h({kind:"tunnel"});return}if((q==null?void 0:q.unavailable)==="no-port"&&(P={kind:"no-port"}),q!=null&&q.url){const $=new URL(q.url);if(await Kt(`${$.origin}${Wn}`)){if(m)return;const te=Un(q.url,T);if(te!==null){y({src:te,sandbox:pt,previewOrigin:$.origin,bridgeEligibility:"preview-listener"});return}}if(m)return;P={kind:"origin-unreachable",host:$.hostname,listenPort:$.port}}}if(r==="direct"&&await Kt(t)){if(m)return;y({src:t,sandbox:pt,previewOrigin:null,bridgeEligibility:null});return}m||h(P??{kind:"no-upstream"})}async function I(){if(h(null),f(null),e.mode!=="blocked"){if(e.mode==="external"){y({src:e.url,sandbox:pt,previewOrigin:null,bridgeEligibility:null});return}return e.mode==="serve"?N(e.path):D(e.port,e.path)}}return I(),()=>{m=!0}},[e,t,r,n,s,i]),{resolved:a===i?o:null,resolveError:l}}const Xn=1e4;function Zn(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 Yn({documentId:e,content:t}){const r=J(_=>_.selectedCwd),n=J(_=>_.writeBrowserHistory),[s]=p.useState(()=>Zn(J.getState().browserHistories[e],t.url)),[i,a]=p.useState(s.stack),[c,o]=p.useState(s.cursor),[f,l]=p.useState(0);p.useEffect(()=>{n(e,{contentUrl:t.url,stack:i,cursor:c})},[e,t.url,i,c,n]);const h=i[c],u=p.useMemo(()=>vr(h),[h]),g=p.useMemo(()=>u.mode==="proxy"?Bn(window.location.hostname):null,[u]),w=p.useRef(null),{resolved:m,resolveError:y}=Jn({target:u,currentUrl:h,strategy:g,cwd:r,reloadNonce:f}),{resourceErrorCount:N,notePersonNavigated:D,noteFrameLoaded:I}=An({iframeRef:w,documentId:e,logicalUrl:h,reloadNonce:f,previewOrigin:(m==null?void 0:m.previewOrigin)??null,bridgeEligibility:(m==null?void 0:m.bridgeEligibility)??null,resolvedSource:(m==null?void 0:m.src)??null}),M=J(_=>_.roomCanvasLiveRoomId),{open:T}=Tn(M??""),[U,P]=p.useState(null),q=p.useCallback(_=>{a(z=>[...z.slice(0,c+1),_]),o(z=>z+1)},[c]),$=$r(M),te=J(_=>M?_.roomCanvasEditing[M]??null:null);p.useEffect(()=>{if($===null||te!==null||$.documentId!==e)return;const _=$.url;_===void 0||_===h||q(_)},[$,te,e,h,q]);const me=c>0,x=c<i.length-1,b=p.useCallback(_=>{const z=$n(_);if(!z||z===h){D(),l(R=>R+1);return}if(M){P(null),T({type:"browser",url:z}).catch(R=>{P({url:z,message:zn(R)})});return}D(),q(z)},[h,q,M,T,D]),S=()=>Zr(h);return d.jsxs("div",{className:"flex h-full flex-col",children:[d.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:[d.jsx(Qe,{label:"Back",disabled:!me,onClick:()=>o(_=>_-1),children:d.jsx(Hr,{className:"size-4"})}),d.jsx(Qe,{label:"Forward",disabled:!x,onClick:()=>o(_=>_+1),children:d.jsx(Vr,{className:"size-4"})}),d.jsx(Qe,{label:"Reload",onClick:()=>l(_=>_+1),children:d.jsx(cn,{className:"size-4"})}),d.jsx("div",{className:"order-first flex w-full min-w-0 lg:order-none lg:w-auto lg:flex-1",children:d.jsx(Qn,{url:(U==null?void 0:U.url)??h,startEditing:U!==null,onSubmit:b},U===null?"address":`retry:${U.url}`)}),d.jsx(Qe,{label:"Open in system browser",onClick:S,children:d.jsx(Jr,{className:"size-4"})})]}),U!==null&&d.jsx("p",{role:"status",className:"text-destructive border-border/60 border-b px-2 py-1 text-xs",children:U.message}),d.jsx(rs,{target:u,resolved:m,resolveError:y,reloadNonce:f,resourceErrorCount:N,title:t.title??"Embedded browser",onOpenExternally:S,onReload:()=>{D(),l(_=>_+1)},iframeRef:w,onFrameLoad:I})]})}function Qn({url:e,startEditing:t=!1,onSubmit:r}){const[n,s]=p.useState(t),[i,a]=p.useState(e);if(!n)return d.jsx(es,{url:e,onActivate:()=>{a(e),s(!0)}});const c=o=>{o.preventDefault(),s(!1),r(i)};return d.jsx("form",{onSubmit:c,className:"min-w-0 flex-1",children:d.jsx(Xr,{"aria-label":"Address",autoFocus:!0,value:i,onChange:o=>a(o.target.value),onFocus:o=>o.currentTarget.select(),onBlur:()=>s(!1),onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),s(!1))},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:"h-11 w-full text-base lg:h-7 lg:text-sm"})})}function Kn(e){return e.kind==="local"?e.path:e.kind==="url"?`${e.host}${e.rest}`:e.text}function es({url:e,onActivate:t}){const r=p.useMemo(()=>Hn(e),[e]);return d.jsxs("button",{type:"button","aria-label":`Address: ${Kn(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"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"bg-muted-foreground/15 text-3xs rounded px-1 py-0.5 font-medium tracking-wide uppercase",children:"local"}),d.jsx("span",{className:"text-foreground truncate",children:r.path})]}),r.kind==="url"&&d.jsxs("span",{className:"truncate",children:[d.jsx("span",{className:"text-foreground",children:r.host}),d.jsx("span",{className:"text-muted-foreground",children:r.rest})]}),r.kind==="raw"&&d.jsx("span",{className:"truncate",children:r.text})]})}function ts(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 rs({target:e,resolved:t,resolveError:r,reloadNonce:n,resourceErrorCount:s,title:i,onOpenExternally:a,onReload:c,iframeRef:o,onFrameLoad:f}){if(e.mode==="blocked")return d.jsx(mt,{children:"This address is blocked for safety."});if(r!==null)return d.jsxs(mt,{children:[d.jsx("p",{children:ts(r,e)}),r.kind!=="no-session"&&r.kind!=="unsupported"&&d.jsx("button",{type:"button",onClick:c,className:"text-foreground mt-3 hover:underline",children:"Reload"})]});if(t===null)return d.jsx(mt,{children:"Loading…"});const l=e.mode==="external";return d.jsx(ns,{src:t.src,sandbox:t.sandbox,title:i,iframeRef:o,onFrameLoad:f,watchLoadDeadline:!l,resourceErrorCount:s,showEmbedFallback:l,onOpenExternally:a,onReload:c},`${t.src}:${n}`)}function ns({src:e,sandbox:t,title:r,iframeRef:n,onFrameLoad:s,watchLoadDeadline:i,resourceErrorCount:a,showEmbedFallback:c,onOpenExternally:o,onReload:f}){const[l,h]=p.useState(!1),[u,g]=p.useState(!1);return p.useEffect(()=>{if(!i)return;const w=setTimeout(()=>g(!0),Xn);return()=>clearTimeout(w)},[i]),d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[u&&!l&&d.jsx(er,{onOpenExternally:o,onReload:f,children:"This preview is slow to load."}),a>0&&d.jsxs(er,{onOpenExternally:o,children:["This page hit ",a===1e4?"at least 10,000":a," ",a===1?"error":"errors"," while loading."]}),d.jsx("iframe",{ref:n,src:e,sandbox:t,onLoad:()=>{h(!0),s()},className:"min-h-0 w-full flex-1 border-0",title:r}),c&&d.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:[d.jsx("span",{children:"This site can’t always be embedded here."}),d.jsx("button",{type:"button",onClick:o,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function er({children:e,onOpenExternally:t,onReload:r}){return d.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:[d.jsx("span",{children:e}),d.jsxs("span",{className:"flex shrink-0 items-center gap-3",children:[r&&d.jsx("button",{type:"button",onClick:r,className:"text-foreground hover:underline",children:"Reload"}),d.jsx("button",{type:"button",onClick:t,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function Qe({label:e,disabled:t,onClick:r,children:n}){return d.jsx("button",{type:"button","aria-label":e,disabled:t,onClick:r,className:Dt("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 mt({children:e}){return d.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 He=$e().min(1).max(128),fe={protocol:Y("dorkos-doc"),v:Y(1),nonce:He,requestToken:He,loadToken:bt,generation:cr.shape.generation};ct("kind",[se({...fe,kind:Y("challenge")}).strict(),se({...fe,kind:Y("ack")}).strict(),se({...fe,kind:Y("connect")}).strict()]);ct("kind",[se({...fe,kind:Y("emit"),requestId:He,event:rt}).strict(),se({...fe,kind:Y("retire")}).strict()]);ct("kind",[se({...fe,kind:Y("receipt"),requestId:He,receipt:ur}).strict(),se({...fe,kind:Y("refused"),requestId:He,outcome:Ht(["cancelled","unconfirmed","refused"])}).strict(),se({...fe,kind:Y("state"),state:Qr,stateRev:bt,docSeq:bt,reset:Vt()}).strict(),se({...fe,kind:Y("event"),frame:Kr}).strict(),se({...fe,kind:Y("status"),status:Ht(["connecting","ready","offline","revoked"]),unconfirmed:Vt()}).strict()]);function ss(e,t){try{if(Yr(t,1048576)!==void 0)return null;const r=e.safeParse(t);return r.success?r.data:null}catch{return null}}function is({owner:e,getOwner:t,readTail:r,writeTail:n,transport:s,cwd:i,sourcePath:a,documentId:c,pending:o}){const f=()=>{var m,y;return((m=t())==null?void 0:m.recoveryGate)==="unsupported"||((y=t())==null?void 0:y.recoveryGate)==="observed_clear"},l=m=>{var D;const y=en.parse(m),N=(D=t())==null?void 0:D.recoveryBinding;if(!N||y.documentId!==c||!V(y.incarnation,N.incarnation))throw new Error("Original save scope changed");return y},h=s.originalFileSaveRecovery,u=()=>{var m;try{const y=t();return(y==null?void 0:y.identity)===e&&y.active&&!!((m=y.recoveryBinding)!=null&&m.current())}catch{return!1}},g=(m,y,N=!1)=>{if(!h||!u())return Promise.resolve({status:"idle"});const D=t(),I={},M=()=>t()===D&&u()&&(!y||D.recoveryBinding===y)&&(!N||D.recoveryWork===I),T=D.discovery;let U=!1;D.recoveryWork=I,D.recoveryGate="pending",D.recoveryBusy=!0;const P=r().catch(()=>{}).then(async()=>{try{if(!M())return{status:"idle"};const q=await m();return M()?(N&&(D.recoveryGate="observed_clear"),U=!0,{status:"observed",value:q}):{status:"idle"}}catch{return M()?(D.recoveryGate="unavailable",{status:"unavailable"}):{status:"idle"}}finally{!U&&D.discovery===T&&(D.discovery=void 0),D.recoveryWork===I&&(D.recoveryBusy=!1,D.recoveryWork=void 0)}});return N||n(P.then(()=>{})),P};return{identity:e,supported:!!h,current:u,discover:(m=!1)=>{if(!h||!u())return Promise.resolve({status:"idle"});const y=t(),N=y.recoveryBinding;if(y.discoveryBinding===N&&y.discovery&&(y.pendingDiscovery===y.discovery||!m&&y.recoveryGate==="observed_clear"))return y.discovery;const D=g(async()=>{const I=l(await h.discover(c));return t()===y&&y.recoveryBinding===N&&u()&&(y.recoveryGate=I.admission==="blocked"?"blocked":"observed_clear"),I},N);return y.discoveryBinding=N,y.discovery=D,y.pendingDiscovery=D,D.then(I=>{y.pendingDiscovery===D&&(y.pendingDiscovery=void 0),I.status==="idle"&&y.discovery===D&&(y.discovery=void 0)}),D},recover(m){if(o())return Promise.resolve({status:"local_uncertain"});const y=t();return g(async()=>{if(!y||o())throw new Error("Mounted original still uncertain");const N=y.recoveryBinding,D=tn.parse(await h.recover(c,m,N.incarnation));if(t()!==y||!u()||D.documentId!==c||D.entry.eventId!==m||!V(D.incarnation,N.incarnation))throw new Error("Original recovery scope changed");const I=l(await h.discover(c));return t()===y&&u()&&(y.recoveryGate=I.admission==="blocked"?"blocked":"observed_clear"),{result:D,discovery:I}})},inspectCurrent(){const m=t();return!m||!u()||o()||!f()?Promise.resolve({status:"local_uncertain"}):g(async()=>{const y=await s.readFileContent(i,a);if(!y||typeof y.content!="string"||typeof y.hash!="string"||!/^[a-f0-9]{64}$/u.test(y.hash))throw new Error("Current file evidence missing");return{content:y.content,hash:y.hash}},m.recoveryBinding,!0)}}}class Ee extends Error{constructor(){super("The original save is not confirmed. Retry it before saving another draft.")}}class Ue extends Error{}function os(){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 as(e){const t=e;return(t==null?void 0:t.status)===412&&t.code==="DOC_SAVE_FAILED"}var de,Se,Xe,wt;class cs{constructor(){Me(this,Xe);Me(this,de);Me(this,Se)}get pending(){return Te(this,de)!==void 0}get receipt(){return Te(this,Se)}async write(t,r,n,s,i,a,c=!1){if(Te(this,de))throw new Ee;if(ge(this,Se,void 0),!a)return t.writeFile(r,n,s,i);if(!c&&!a.current())throw new Ue;const o=Object.freeze({cwd:r,path:n,content:s,options:Object.freeze({...i,documentSave:Object.freeze({documentId:a.incarnation.documentId,eventId:os(),incarnation:Object.freeze({...a.incarnation})})})});return ge(this,de,o),ve(this,Xe,wt).call(this,t,o)}async retry(t,r){const n=Te(this,de);if(!(n!=null&&n.options.documentSave)||!r.current()||!V(n.options.documentSave.incarnation,r.incarnation))throw new Ue;return{result:await ve(this,Xe,wt).call(this,t,n),content:n.content}}}de=new WeakMap,Se=new WeakMap,Xe=new WeakSet,wt=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 Ee;if(!n.ok){if(!n.conflict||typeof n.conflict.currentHash!="string"||!n.conflict.currentHash||typeof n.conflict.currentContent!="string")throw new Ee;return ge(this,de,void 0),n}if(typeof n.hash!="string"||!n.hash||n.effect!=="changed"&&n.effect!=="no_op")throw new Ee;const s="documentReceipt"in n?rn.parse(n.documentReceipt):void 0,i=r.options.documentSave;if(!s&&n.effect!=="no_op")throw new Ee;if(s&&(s.documentId!==i.documentId||s.eventId!==i.eventId||!V(s.incarnation,i.incarnation)||s.fileHash!==n.hash||(s.status==="accepted"?n.effect!=="changed":n.effect!=="no_op")))throw new Ee;if((s==null?void 0:s.status)==="duplicate"){const a=await t.readFileContent(r.cwd,r.path);if(!a||typeof a!="object"||Array.isArray(a)||typeof a.hash!="string"||!a.hash||typeof a.content!="string")throw new Ee;if(a.hash!==s.fileHash||a.content!==r.content)return ge(this,Se,s),ge(this,de,void 0),{ok:!1,conflict:{currentHash:a.hash,currentContent:a.content}}}return ge(this,Se,s),ge(this,de,void 0),n}catch(n){throw as(n)&&ge(this,de,void 0),n}};function us({sourcePath:e,cwd:t,loadedContent:r,documentId:n,documentSaveBinding:s,documentRecoveryBinding:i}){const a=ue(),c=(s==null?void 0:s.incarnation)??(i==null?void 0:i.incarnation),o=c?JSON.stringify([c.documentId,c.physicalOpenedAt,c.channelCreatedAt,c.generation]):void 0,f=p.useRef(new cs),l=p.useMemo(()=>({sourcePath:e,cwd:t,documentId:n,transport:a,birthKey:o}),[e,t,n,a,o]),h=p.useRef(null),u=p.useRef(null),g=p.useRef(Promise.resolve()),w=p.useCallback(()=>{var R;return((R=u.current)==null?void 0:R.identity)===l&&u.current.active},[l]);p.useLayoutEffect(()=>{var R;return((R=u.current)==null?void 0:R.identity)!==l?u.current={identity:l,baseHash:null,baseContent:r,active:!0,recoveryBinding:i,recoveryGate:i&&a.originalFileSaveRecovery?"pending":"unsupported"}:(u.current.active=!0,u.current.recoveryBinding=i),()=>{var k;((k=u.current)==null?void 0:k.identity)===l&&(u.current.active=!1)}},[l,r,i,a]);const[m,y]=p.useState({owner:l,status:"idle",conflict:null}),N=m.owner===l?m.status:"idle",D=m.owner===l?m.conflict:null,I=p.useCallback((R,k,L)=>{w()&&y(W=>({owner:l,status:R,documentReceipt:k,confirmedContent:L,conflict:W.owner===l?W.conflict:null}))},[l,w]),M=p.useCallback(R=>{w()&&y(k=>({owner:l,conflict:R,status:k.owner===l?k.status:"idle"}))},[l,w]),T=p.useCallback(()=>{var R,k;return((R=u.current)==null?void 0:R.recoveryGate)==="unsupported"||((k=u.current)==null?void 0:k.recoveryGate)==="observed_clear"},[]),U=p.useMemo(()=>{const R=()=>is({owner:l,getOwner:()=>u.current,readTail:()=>g.current,writeTail:k=>{g.current=k},transport:a,cwd:t,sourcePath:e,documentId:n,pending:()=>f.current.pending});return{identity:l,supported:!!a.originalFileSaveRecovery,current:()=>R().current(),discover:k=>R().discover(k),recover:k=>R().recover(k),inspectCurrent:()=>R().inspectCurrent()}},[l,a,t,e,n]),P=!!(e&&t),q=p.useCallback((R,k,L,W=!1)=>{const K=()=>w()&&u.current===R&&(!s||s.current());if(k.ok){if(typeof k.hash!="string"||!k.hash||k.effect!=="changed"&&k.effect!=="no_op")throw new Error("Invalid file save acknowledgement");return R.baseHash=k.hash,R.baseContent=L,!W&&!K()?{status:"idle"}:(W||(M(null),I("saved",f.current.receipt,L)),{status:k.effect,confirmed:{hash:k.hash,content:L}})}return!W&&!K()?{status:"idle"}:(W||(M(k.conflict),I("conflict")),{status:"conflict"})},[w,s,M,I]),$=p.useCallback(async(R,k)=>{if(!w())return{status:"idle"};const L=u.current;s&&!f.current.pending&&(h.current=l);const W=await f.current.write(a,t,e,R,k,s);return q(L,W,R)},[w,a,t,e,s,q,l]),te=p.useCallback(R=>{var W;if(!P||!w())return Promise.resolve({status:"idle"});const k=((W=u.current.finalToken)==null?void 0:W.content)===R?u.current.finalToken:void 0,L=g.current.catch(()=>{}).then(async()=>{if(!w()||s&&!s.current())return{status:"idle"};if(f.current.pending)return I("uncertain"),{status:"uncertain"};if(!T())return I("error"),{status:"error"};u.current.finalToken===k&&(u.current.finalToken=void 0),I("saving");try{const K=u.current.baseHash!==null?{expectedHash:u.current.baseHash}:{expectedContent:u.current.baseContent};return await $(R,K)}catch(K){if(K instanceof Ue)return{status:"idle"};if(!w()||s&&!s.current())return{status:"idle"};const ae=f.current.pending?"uncertain":"error";return I(ae),{status:ae}}});return g.current=L.then(()=>{}),L},[P,$,w,I,s,T]),me=p.useCallback(R=>{if(!P||!w()||s&&!s.current())return null;const k=u.current,L={content:R,id:Symbol("buffered canvas draft")};return k.finalToken=L,{cancel(){k.finalToken===L&&(k.finalToken=void 0)},flush(){if(k.finalToken!==L||u.current!==k||k.active)return Promise.resolve({status:"idle"});k.finalToken=void 0;const W=g.current.catch(()=>{}).then(async()=>{if(u.current!==k||k.active)return{status:"idle"};try{if(k.recoveryGate!=="unsupported"&&k.recoveryGate!=="observed_clear")return{status:"error"};const K=k.baseHash!==null?{expectedHash:k.baseHash}:{expectedContent:k.baseContent};s&&!f.current.pending&&(h.current=l);const ae=await f.current.write(a,t,e,R,K,s,!0);return q(k,ae,R,!0)}catch{return{status:"error"}}});return g.current=W.then(()=>{}),W}}},[P,w,a,t,e,s,q,l]),x=p.useCallback(async R=>{const k=u.current;return!k||k.identity!==l?!1:(await g.current.catch(()=>{}),u.current===k&&!f.current.pending&&k.baseContent===R)},[l]),b=p.useCallback(()=>{if(!w()||!s||h.current!==l)return Promise.resolve({status:"idle"});const R=u.current,k=g.current.catch(()=>{}).then(async()=>{if(!w()||u.current!==R||h.current!==l)return{status:"idle"};try{I("saving");const L=await f.current.retry(a,s);return q(R,L.result,L.content)}catch(L){if(L instanceof Ue||!w()||u.current!==R)return{status:"idle"};const W=f.current.pending?"uncertain":"error";return I(W),{status:W}}});return g.current=k.then(()=>{}),k},[w,s,a,q,I,l]),S=p.useCallback(R=>{var K;if(!P||!D||!w())return Promise.resolve({status:"idle"});const k=D.currentHash,L=((K=u.current.finalToken)==null?void 0:K.content)===R?u.current.finalToken:void 0,W=g.current.catch(()=>{}).then(async()=>{if(!w()||s&&!s.current())return{status:"idle"};if(f.current.pending)return I("uncertain"),{status:"uncertain"};if(!T())return I("error"),{status:"error"};u.current.finalToken===L&&(u.current.finalToken=void 0),I("saving");try{return await $(R,{expectedHash:k})}catch(ae){if(ae instanceof Ue)return{status:"idle"};if(!w()||s&&!s.current())return{status:"idle"};const Ae=f.current.pending?"uncertain":"error";return I(Ae),{status:Ae}}});return g.current=W.then(()=>{}),W},[P,D,$,w,I,s,T]),_=p.useCallback(()=>{var R;return((R=u.current)==null?void 0:R.identity)===l?{hash:u.current.baseHash,content:u.current.baseContent}:{hash:null,content:r}},[l,r]),z=p.useCallback(()=>{if(!D||!w()||s&&!s.current())return null;u.current.finalToken=void 0;const R=D.currentContent;return u.current.baseHash=D.currentHash,u.current.baseContent=R,M(null),I("idle"),R},[D,w,M,I,s]);return{recovery:U,status:N,conflict:D,canSave:P,save:te,overwrite:S,adoptDisk:z,getConfirmedBase:_,prepareFinalSave:me,retryUnconfirmed:b,waitForCloseDrain:x,documentReceipt:m.owner===l?m.documentReceipt:void 0,confirmedContent:m.owner===l?m.confirmedContent:void 0}}const ls=p.lazy(()=>Ce(()=>import("./BlintzCanvas-DoAZs5bz.js").then(e=>e.B),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.BlintzCanvas}))),ds=500;function fs(e){switch(e){case"saving":return"Saving…";case"saved":return"Saved";case"error":return"Couldn’t save";default:return null}}function hs({content:e,documentId:t,onContentChange:r}){const[n,s]=p.useState(!1),[i,a]=p.useState(e.content),c=J(b=>b.canvasSessionId),o=J(b=>b.setDocumentEditing),f=J(b=>{var S;return((S=b.openDocuments.find(_=>_.id===t))==null?void 0:S.editing)??!1}),l=J(b=>b.selectedCwd),h=n&&f,u=us({documentId:t,sourcePath:e.sourcePath,cwd:l,loadedContent:e.content}),g=u.canSave,w=p.useRef(null),m=p.useRef(null),y=p.useRef(i),N=p.useRef(e),D=p.useRef(r),I=p.useRef(u.save),M=p.useRef(u.prepareFinalSave),T=p.useRef(null);p.useEffect(()=>{y.current=i,N.current=e,D.current=r,I.current=u.save,M.current=u.prepareFinalSave});const U=p.useCallback(b=>{J.getState().canvasSessionId===w.current&&(D.current({...N.current,content:b}),I.current(b))},[]),P=p.useCallback(b=>{var S;a(b),y.current=b,(S=T.current)==null||S.cancel(),T.current=M.current(b),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,U(b)},ds)},[U]),q=()=>{w.current=J.getState().canvasSessionId,a(e.content),s(!0),o(t,!0)},$=()=>{m.current&&(clearTimeout(m.current),m.current=null,U(y.current)),s(!1),o(t,!1)};p.useEffect(()=>{var b;h&&c!==w.current&&(m.current&&(clearTimeout(m.current),m.current=null),(b=T.current)==null||b.cancel(),T.current=null,s(!1),o(t,!1))},[c,h,t,o]),p.useEffect(()=>{var b;!n||h||(m.current&&clearTimeout(m.current),m.current=null,(b=T.current)==null||b.cancel(),T.current=null)},[h,n]),p.useEffect(()=>()=>{var b,S;m.current&&(clearTimeout(m.current),m.current=null,J.getState().canvasSessionId===w.current&&D.current({...N.current,content:y.current})),J.getState().canvasSessionId===w.current?(b=T.current)==null||b.flush():(S=T.current)==null||S.cancel(),T.current=null,o(t,!1)},[U,t,o]);const te=()=>{const b=u.adoptDisk();b!=null&&(r({...e,content:b}),a(b))},me=()=>{u.overwrite(y.current)},x=fs(u.status);return d.jsxs("div",{className:"relative flex h-full flex-col",children:[d.jsxs("div",{className:"sticky top-0 z-10 flex h-0 items-start justify-end gap-2 pr-2",children:[g&&x&&d.jsx("span",{className:"text-muted-foreground mt-3 text-xs","aria-live":"polite",children:x}),g&&d.jsx(et,{type:"button",variant:"ghost",size:"icon-md",className:"text-muted-foreground hover:text-foreground mt-2",onClick:h?$:q,"aria-label":h?"Finish editing":"Edit document",children:h?d.jsx(lr,{className:"size-4"}):d.jsx(dr,{className:"size-4"})})]}),u.status==="conflict"&&d.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:[d.jsx("span",{className:"flex-1",children:"This file changed on disk since you opened it."}),d.jsx(et,{type:"button",variant:"ghost",size:"sm",className:"h-7",onClick:te,children:"Reload"}),d.jsx(et,{type:"button",variant:"destructive",size:"sm",className:"h-7",onClick:me,children:"Overwrite"})]}),d.jsx("div",{className:"flex-1 px-2 pb-6",children:d.jsx(p.Suspense,{fallback:d.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading editor…"}),children:d.jsx(ls,{value:h?i:e.content,editable:h,onChange:h?P:void 0})})})]})}function ps({content:e}){return d.jsx("div",{className:"p-4 font-mono text-sm",children:d.jsx(br,{value:e.data,depth:0})})}const ms=20;function br({value:e,depth:t,keyName:r}){const[n,s]=p.useState(t>2),i=p.useCallback(()=>s(l=>!l),[]);if(t>=ms)return d.jsx(Fe,{keyName:r,value:"[max depth]",className:"text-muted-foreground"});if(e===null)return d.jsx(Fe,{keyName:r,value:"null",className:"text-muted-foreground"});if(typeof e=="boolean")return d.jsx(Fe,{keyName:r,value:String(e),className:"text-blue-500"});if(typeof e=="number")return d.jsx(Fe,{keyName:r,value:String(e),className:"text-green-500"});if(typeof e=="string")return d.jsx(Fe,{keyName:r,value:`"${e}"`,className:"text-amber-500"});const a=Array.isArray(e),c=a?e.map((l,h)=>[String(h),l]):Object.entries(e),o=a?"[":"{",f=a?"]":"}";return d.jsxs("div",{style:{paddingLeft:t>0?16:0},children:[d.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:i,children:[d.jsx(nn,{className:Dt("size-3 transition-transform",!n&&"rotate-90")}),r!=null&&d.jsxs("span",{className:"text-foreground",children:[r,": "]}),d.jsxs("span",{className:"text-muted-foreground",children:[o,n&&` … ${c.length} items `,n&&f]})]}),!n&&d.jsxs(d.Fragment,{children:[c.map(([l,h])=>d.jsx(br,{keyName:a?void 0:l,value:h,depth:t+1},l)),d.jsx("div",{className:"text-muted-foreground",children:f})]})]})}function Fe({keyName:e,value:t,className:r}){return d.jsxs("div",{style:{paddingLeft:16},children:[e!=null&&d.jsxs("span",{className:"text-foreground",children:[e,": "]}),d.jsx("span",{className:r,children:t})]})}const gs=new Set(["http:","https:"]);function vs(e){const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||t[1].length===1?null:`${t[1].toLowerCase()}:`}const bs={image:"data:image/",pdf:"data:application/pdf"};function wr(e,t,r){const n=e.trim();if(n.startsWith("data:"))return n.toLowerCase().startsWith(bs[t])?{url:n,error:null}:{url:null,error:"unsupported-data"};const s=vs(n);if(s!==null)return gs.has(s)?{url:n,error:null}:{url:null,error:"blocked"};const i=r(n);return i?{url:i,error:null}:{url:null,error:"local-unavailable"}}function yr(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 ws({content:e}){const t=ue(),r=J(l=>l.selectedCwd),n=p.useMemo(()=>wr(e.src,"image",l=>t.mediaUrl(r??"",l)),[e.src,t,r]),[s,i]=p.useState("loading"),[a,c]=p.useState(e.src);a!==e.src&&(c(e.src),i("loading"));const o=e.alt??e.title??"Canvas image";if(n.url===null){const l=n.error?yr(n.error,"image"):"";return d.jsx(tr,{children:l})}const f=n.url;return d.jsxs("div",{className:"bg-muted/40 relative flex h-full items-center justify-center",children:[s==="loading"&&d.jsx("p",{className:"text-muted-foreground absolute text-sm","aria-live":"polite",children:"Loading image…"}),s==="error"?d.jsx(tr,{children:"This image couldn’t be loaded."}):d.jsxs(un,{centerOnInit:!0,doubleClick:{mode:"toggle"},wheel:{step:.15},children:[d.jsx(ys,{}),d.jsx(ln,{wrapperClass:"!h-full !w-full",contentClass:"!h-full !w-full flex items-center justify-center",children:d.jsx("img",{src:f,alt:o,onLoad:()=>i("loaded"),onError:()=>i("error"),className:Dt("max-h-full max-w-full object-contain transition-opacity",s==="loaded"?"opacity-100":"opacity-0")})})]})]})}function ys(){const{zoomIn:e,zoomOut:t,resetTransform:r}=dn();return d.jsxs("div",{className:"absolute top-2 right-2 z-10 flex gap-1",children:[d.jsx(gt,{label:"Zoom in",onClick:()=>e(),children:d.jsx(vn,{className:"size-4"})}),d.jsx(gt,{label:"Zoom out",onClick:()=>t(),children:d.jsx(bn,{className:"size-4"})}),d.jsx(gt,{label:"Reset zoom",onClick:()=>r(),children:d.jsx(gn,{className:"size-4"})})]})}function gt({label:e,onClick:t,children:r}){return d.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 tr({children:e}){return d.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:d.jsx("p",{children:e})})}function xs({content:e}){const t=ue(),r=sn().data,n=J(o=>o.selectedCwd),s=p.useMemo(()=>wr(e.src,"pdf",o=>t.mediaUrl(n??"",o)),[e.src,t,n]);if(s.url===null){const o=s.error?yr(s.error,"pdf"):"";return d.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:d.jsx("p",{children:o})})}const i=s.url,a=e.title??"PDF document",c=new URL(i,window.location.href).origin===window.location.origin;return c&&!r?null:c&&(r==null?void 0:r.serverRole)==="hub"?d.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[d.jsx("p",{children:"PDFs download here instead of opening."}),d.jsxs("a",{href:i,download:!0,className:"text-foreground focus-ring rounded-md underline underline-offset-4",children:["Download ",a]})]}):d.jsx("object",{data:i,type:"application/pdf",title:a,className:"h-full w-full",children:d.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[d.jsx("p",{children:"This PDF can’t be shown here."}),d.jsxs("a",{href:i,target:"_blank",rel:"noreferrer",className:"text-foreground focus-ring rounded-md underline underline-offset-4",children:["Open ",a," in a new tab"]})]})})}function ks(e){const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||t[1].length===1?null:`${t[1].toLowerCase()}:`}const js=new Set(["http:","https:","data:"]);function xr(e,t,r){const n=e.trim(),s=ks(n);return s!==null?js.has(s)?s==="data:"&&r!==void 0?n.toLowerCase().startsWith(r)?{url:n}:{url:null}:{url:n}:{url:null}:{url:t(n)}}function Cs({content:e}){const t=ue(),r=J(i=>i.selectedCwd),n=p.useMemo(()=>xr(e.src,i=>t.mediaUrl(r??"",i),"data:audio/"),[e.src,t,r]),s=e.title??"Canvas audio";return n.url===null?d.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:d.jsx("p",{children:"This audio can’t be played here."})}):d.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center p-8",children:d.jsx("audio",{controls:!0,src:n.url,"aria-label":s,className:"w-full max-w-2xl",children:d.jsxs("p",{className:"text-muted-foreground text-sm",children:["Your browser can’t play this audio."," ",d.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",s]}),"."]})})})}function Rs({content:e}){const t=ue(),r=J(i=>i.selectedCwd),n=p.useMemo(()=>xr(e.src,i=>t.mediaUrl(r??"",i),"data:video/"),[e.src,t,r]),s=e.title??"Canvas video";return n.url===null?d.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:d.jsx("p",{children:"This video can’t be played here."})}):d.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center",children:d.jsx("video",{controls:!0,src:n.url,"aria-label":s,className:"max-h-full w-full max-w-full object-contain",children:d.jsxs("p",{className:"text-muted-foreground p-8 text-sm",children:["Your browser can’t play this video."," ",d.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",s]}),"."]})})})}function kr({content:e,documentId:t,channel:r}){const[n]=St(),s=fn(e.definition),i=p.useMemo(()=>JSON.stringify(e.definition),[e.definition]);return d.jsx("div",{className:"p-4",children:s.ok?d.jsx(hn,{channel:r,document:s.document,sessionId:n??void 0},r?t??r.documentId:i):d.jsx(pn,{error:s.error,raw:s.raw})})}class Os{constructor(){ee(this,"contiguous",0);ee(this,"through",0);ee(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 yt=new WeakMap,Ze=new WeakMap,we=new WeakMap,We=new WeakMap;function je(e){De(e);const t=yt.get(e);if(!t)throw new Error("Replay owner lifetime is absent.");return t}function Es(e,t){const r=Ze.get(t);if(!r||r.owner!==e)throw new Error("Replay run is foreign.");return r}function jr(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){for(const t of Object.values(e))jr(t);Object.freeze(e)}return e}function _s(e){if(De(e),yt.has(e))throw new Error("Replay owner lifetime is already initialized.");yt.set(e,new Os)}function At(e){const t=je(e);return Object.freeze({highest:t.highest,through:t.catchUpThrough,pending:t.pendingCount})}function rr(e){je(e).reset()}function nr(e,t){const r=Ze.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 Ss(e,t,r){const n=we.get(r),s=Ze.get(t);if(!(!s||s.owner!==e||!n||n.owner!==e||n.run!==t||n.phase!=="consuming"||n.admissionRead||!re(e,t)))return n.admissionRead=!0,Object.freeze({response:n.response,since:n.since,revision:n.revision,observation:n.observation,targetBirth:s.targetBirth})}function Ds(e,t,r){const n=Es(e,t),s=we.get(r),i=_r(e,t,r);if(!i||!s||s.owner!==e||s.run!==t||s.phase!=="consuming"||!s.admissionRead||n.ended||n.epoch!==i.epoch||n.subject!==i.previous)throw new Error("Replay own issuance is foreign or stale.");n.subject=i.subject}function Cr(e,t,r,n){if(!re(e,t))return;if(n){const i=We.get(r);return i&&i.owner===e&&i.run===t&&i.phase==="dispatching"&&!i.advanced?i.frame:void 0}const s=we.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 Is(e,t,r,n){const s=si(e,t,r,n);if(!s||!re(e,t))throw new Error("Replay cursor advance has no genuine core witness.");const i=n?We.get(r):we.get(r);if(!i||i.advanced)throw new Error("Replay frame advance was consumed.");i.advanced=!0,je(e).advance(s.docSeq)}function As(e,t){const r=Ze.get(t),n=(r==null?void 0:r.lastPage)&&we.get(r.lastPage);if(!r||r.owner!==e||!re(e,t)||r.target===void 0||!n||n.phase!=="finished"||n.next!==n.frames.length||n.response.events.length>=200&&je(e).highest<r.target)return;const s=je(e);return Object.freeze({highest:s.highest,through:s.catchUpThrough,target:r.target})}function Ns(e,t){const r=Je(e,t);if(!r)throw new Error("Replay notice is foreign or stale.");const n=je(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"&&vi(e,t)}return!1}function zs(e,t){const r=Je(e,t);if(!r||r.mode!=="event"||r.notification.type==="canvas_channel_snapshot")throw new Error("Notice cursor advance is foreign.");je(e).advance(r.notification.docSeq)}function Ts(e){const t=ce(e),r=je(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};Ze.set(n,s),ci(e,n);const i=()=>re(e,n),a=()=>ce(e).live?i()?void 0:"restart":"stop";return Object.freeze({async readPage(){if(!i())return null;const c=ce(e),o=r.highest,f=ut(e),l=f.getCanvasChannel;if(!i())return null;const h=await l.call(f,t.documentId,{since:o,limit:200});if(!i())return null;const u=jr(on.parse(h));if(!i())return null;const g=Object.freeze({});return we.set(g,{owner:e,run:n,response:u,since:o,revision:c.revision,observation:c.observation,phase:"read",admissionRead:!1,frames:[],next:0,advanced:!1}),g},consumePage(c){const o=we.get(c);return!i()||!o||o.owner!==e||o.run!==n||o.phase!=="read"?{kind:"done"}:(o.phase="consuming",ui(e,n,c)!=="accepted"||!i()?(o.phase="finished",{kind:"done"}):(s.target??(s.target=o.response.highWatermark),s.targetBirth=o.response.incarnation,o.frames=Object.freeze(o.response.events.filter(l=>l.docSeq<=s.target)),o.phase="frames",s.lastPage=c,o.response.resetRequired&&r.advance(o.response.retentionFloor-1),{kind:"frames",count:o.frames.length}))},advancePageFrame(c,o){const f=we.get(c);if(!i()||!f||f.owner!==e||f.run!==n||f.phase!=="frames"||o!==f.next||!f.frames[o])return!1;f.next=o+1,f.dispatching=o,f.advanced=!1;try{return ir(e,n,c,!1)&&i()}finally{f.dispatching=void 0}},finishPage(c){const o=we.get(c);if(!i()||!o||o.owner!==e||o.run!==n||o.phase!=="frames"||o.next!==o.frames.length||s.target===void 0)return"done";if(o.phase="finished",o.response.events.length<200||r.highest>=s.target)return r.advance(s.target),!i()||(or(e,n),!i())||(s.succeeded=!0),"done";if(r.highest<=o.since)throw new Error("Document replay made no progress.");return"again"},failed(){i()&&li(e,n)},beginFinalization(){return a()??(s.succeeded?"drain":"stop")},takePending(){if(!i())return null;const c=r.takeNextContiguous();if(!c||!i())return null;const o=Object.freeze({});return We.set(o,{owner:e,run:n,frame:c,phase:"taken",advanced:!1}),o},advancePending(c){const o=We.get(c);if(!i()||!o||o.owner!==e||o.run!==n||o.phase!=="taken")return!1;o.phase="dispatching";try{return ir(e,n,c,!0)&&i()}finally{o.phase="finished",We.delete(c)}},finishFinalization(){const c=a();if(c)return c;if(r.clearReachedTarget()){const o=a();if(o)return o;or(e,n);const f=a();if(f)return f}if(r.pendingCount||r.catchUpThrough>r.highest){const o=ce(e);if(r.highest>s.starting||o.revision>s.revision||o.observation>s.observation)return"restart";di(e,n)}return a()??"stop"},current:i,end:()=>{s.ended=!0}})}var pe,kt,Le;class xt{constructor(){Me(this,pe);ee(this,"current",null);ee(this,"token",0);ee(this,"retiring",!1);ee(this,"subscribers",new Set);ee(this,"resources",new Map);ee(this,"doc",null);ee(this,"docClaims",new WeakMap);ee(this,"retiringDoc",!1);ee(this,"docResources",new Map);ee(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 i=s();i&&typeof i.then=="function"&&Promise.resolve(i).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 ve(this,pe,kt).call(this,t,r,n)}acquireDoc(t,r,n){const s=ve(this,pe,kt).call(this,t,r,n),i=Object.freeze({});this.docClaims.set(s,i);let a=!1;return Object.freeze({binding:s,release:()=>{a||(a=!0,this.docClaims.get(s)===i&&(this.docClaims.delete(s),this.doc===s&&this.bindings.has(s)&&ve(this,pe,Le).call(this)))}})}disableDoc(){ve(this,pe,Le).call(this)}retireDoc(t){this.doc===t&&this.bindings.has(t)&&ve(this,pe,Le).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}}pe=new WeakSet,kt=function(t,r,n){const s=this.doc,i=this.token,a=ss(cr,r);if(!a)throw this.disableDoc(),new Error("Established server Doc birth required.");const c=a,o=t.exactOrigin,f=t.eligibility==="served-document"?o==="null":t.eligibility==="preview-listener"&&o!==null&&new URL(o).origin===o;if(!t.loaded||!t.frame||typeof t.frame.postMessage!="function"||!t.resolvedSource||!f||t.documentId!==c.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!==i)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(V(this.doc.incarnation,c)&&this.doc.scope===n)return this.doc;throw this.retire(),new Error("Doc birth changed; a fresh host load is required.")}const l=Object.freeze({observation:t,incarnation:Object.freeze(c),scope:n});try{return this.doc=l,this.bindings.add(l),l}catch(h){throw this.doc===l&&ve(this,pe,Le).call(this),h}},Le=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 Ms(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:i,submit:a,inspect:c,captureOriginal:o}=r,f=Object.freeze({expectedGeneration:t.incarnation.generation}),l=()=>{try{return e.isCurrent(t)?i(n,s)===!0&&e.isCurrent(t):!1}catch{return!1}};if(!l())throw new Error("Doc binding unavailable.");const h=()=>{if(!l())throw new Error("Doc binding retired.")};return Object.freeze({binding:t,current:l,captureOriginal:u=>{h();const g=u.id;h();const w=u.bytes;h();const m=Reflect.apply(o,r,[Object.freeze({id:g,bytes:w})]);if(h(),!m)return null;const y=m.id;h();const N=m.bytes;h();const D=m.submit;h();const I=m.inspect;return h(),y!==g||N!==w||typeof D!="function"||typeof I!="function"?null:Object.freeze({id:g,bytes:w,submit:async M=>{h(),M.throwIfAborted();const T=await Reflect.apply(D,m,[M]);return h(),M.throwIfAborted(),T},inspect:async M=>{h(),M.throwIfAborted();const T=await Reflect.apply(I,m,[M]);return h(),M.throwIfAborted(),T}})},retireObservation:()=>{l()&&e.retire()},onRetire:u=>e.ownDoc(t,u),submit:(u,g)=>(h(),g.throwIfAborted(),a(u,f,g)),inspect:(u,g)=>(h(),g.throwIfAborted(),c(u,f,g))})}class Fs{constructor(){ee(this,"revision",0);ee(this,"draining",!1);ee(this,"cleanup");ee(this,"subscribers",new Set);ee(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 i=n();return!this.current(t)||!r()||!this.current(t)?null:i}}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 qs(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 i=s();return!i||!n()||r.accept(i)!==!0||!n()?null:i}})}function Ls(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 i=!1,a=null,c;try{const o=s.binding;if(n()&&r.bindingCurrent(o)===!0&&n()){const f=r.createPort(o);n()&&r.portCurrent(f)===!0&&n()&&e.install(t,s.release)&&(i=!0,a=f)}}catch(o){c={cause:o}}if(!i)try{s.release()}catch(o){c??(c={cause:o})}if(c)throw c.cause;return a}function Ps(e){const t=()=>Object.assign(new Error("Document actions are unavailable."),{status:409}),r=(s,i)=>{if(i.aborted||!e.current(s)||i.aborted)throw t()},n=(s,i)=>{const a=ur.parse(i);if(a.receipt.id!==s)throw new Error("Document receipt does not match this action.");return a};return Object.freeze({current:e.current,submit:async(s,i)=>{const a=rt.parse(JSON.parse(JSON.stringify(s))),c=a.id;r("submit",i);const o=await e.submit(a,i);r("read",i);const f=n(c,o);return r("read",i),f},inspect:async(s,i)=>{r("read",i);const a=await e.inspect(s,i);r("read",i);const c=n(s,a);return r("read",i),c},captureOriginal:s=>{const i=rt.parse(JSON.parse(JSON.stringify(s))),a=i.id,c=JSON.stringify(i);if(!e.current("submit"))return null;const o=e.capture(i,c);if(!o||!e.current("submit")||!o.current("submit"))return null;let f=!1;const l=h=>o.current(h)===!0;return Object.freeze({id:a,bytes:c,current:l,submit:async h=>{if(f||h.aborted||!l("submit"))throw t();f=!0;const u=await o.submit(JSON.parse(c),h);if(h.aborted||!l("read"))throw t();const g=n(a,u);if(h.aborted||!l("read"))throw t();return g},inspect:async h=>{if(h.aborted||!l("read"))throw t();const u=await o.inspect(a,h);if(h.aborted||!l("read"))throw t();const g=n(a,u);if(h.aborted||!l("read"))throw t();return g}})}})}function Bs(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 Us(e,t,r){const n=rt.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:Bs(s)}const Ws=xt.prototype.acquireDoc,st=new WeakMap,jt=new WeakMap;function Gs(e,t){const r=ut(e),n=new WeakMap,s=(a,c)=>t.current(c)&&ke(e,a,!0);return Object.freeze({prepareFrameLoad:(a,c)=>{var u;if(!(a instanceof xt)||c.loaded)return null;const o=sr(e),f=o?(u=_e(e,o))==null?void 0:u.httpBaseline:void 0,l=t.begin();if(!o||!f||!t.current(l)||!ke(e,o,!0)||a.getCurrent()!==c||c.transportOwner!==r||!s(o,l))return null;let h=null;return qs(t,l,{current:()=>{var g;return ke(e,o,!0)&&((g=_e(e,o))==null?void 0:g.httpBaseline)===f&&a.getCurrent()===(h??c)&&t.current(l)&&ke(e,o,!0)},complete:()=>(h=a.observeLoaded(c),h),accept:g=>{var w,m;return!t.current(l)||!ke(e,o,!0)||((w=_e(e,o))==null?void 0:w.httpBaseline)!==f||a.getCurrent()!==g||!t.current(l)||!ke(e,o,!0)||((m=_e(e,o))==null?void 0:m.httpBaseline)!==f?!1:(n.set(g,{record:o,birth:f.birth}),!0)}})},subscribeInvalidation:a=>t.subscribe(a),attachFrame:(a,c)=>{if(!(a instanceof xt))return null;const o=sr(e),f=t.begin();if(!o||!t.current(f)||!ke(e,o,!0)||a.getCurrent()!==c||c.transportOwner!==r||!s(o,f))return null;const l=n.get(c);return!l||l.record!==o||!V(l.birth,_e(e,o).birth)?null:Ls(t,f,{current:()=>s(o,f),acquire:()=>{const h=Ws.call(a,c,_e(e,o).birth,_e(e,o).birth.documentId);let u=!1,g=null,w;try{s(o,f)&&a.getCurrent()===c&&s(o,f)&&(g=Object.freeze({binding:h.binding,release:h.release}),u=!0)}catch(m){w={cause:m}}if(!u)try{h.release()}catch(m){w??(w={cause:m})}if(w)throw w.cause;return g},bindingCurrent:h=>a.isCurrent(h)&&s(o,f),createPort:h=>Ms(a,h,{owner:r,publisherEpoch:c.publisherEpoch,isCurrentOwner:(u,g)=>u===r&&g===c.publisherEpoch&&t.current(f)&&ke(e,o),captureOriginal:u=>Us(u,g=>{var w;return((w=ai(e,o))==null?void 0:w.captureOriginal(g))??null},()=>s(o,f)),submit:async()=>({kind:"terminal"}),inspect:async()=>({kind:"unknown"})}),portCurrent:h=>h.current()&&s(o,f)})}})}function $s(e){if(De(e),st.has(e))throw new Error("Frame owner is already initialized.");const t=new Fs,r=Gs(e,t);return st.set(e,{frames:t,facade:r}),r}function Hs(e){var t;return De(e),(t=st.get(e))==null?void 0:t.facade}function Pe(e){De(e);const t=st.get(e);if(!t)return;const r=Object.freeze({});return jt.set(r,{owner:e,frames:t.frames,ticket:t.frames.captureRetirement()}),r}function Be(e,t){if(!t)return;const r=jt.get(t);if(!r||r.owner!==e)throw new Error("Frame retirement is foreign or consumed.");jt.delete(t),r.frames.drainRetirement(r.ticket)}function Rr(e,t){const r=be(e,t),n=ni(e,t);if(!(!r||!n))return{owner:t,verified:r.verified,...Ps(n)}}function he(e,t){return{documentId:e,transport:t,events:[],available:!1}}function Vs(e,t,r,n,s,i){var o,f;const a=e.documentId===r&&e.transport===n?e:he(r,n);if(a.snapshot&&(t.highWatermark<a.snapshot.highWatermark||t.stateRev<a.snapshot.stateRev))return a;const c=new Map((((o=a.snapshot)==null?void 0:o.receipts)??[]).filter(l=>l.receipt.docSeq>=t.receiptRetentionFloor).map(l=>[l.receipt.id,l]));for(const l of t.receipts)c.set(l.receipt.id,l);return{...a,available:i,snapshot:{...t,...s?{}:{routing:(f=a.snapshot)==null?void 0:f.routing},receipts:[...c.values()].sort((l,h)=>h.receipt.docSeq-l.receipt.docSeq).slice(0,400)},events:t.resetRequired?a.events.filter(l=>l.docSeq>=t.retentionFloor):a.events}}function Js(e){var r,n,s,i,a,c,o,f,l,h,u,g;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:(i=e.binding)==null?void 0:i.owner,current:((a=e.binding)==null?void 0:a.current)??(()=>!1),approvedEventTypes:e.available?((o=(c=e.snapshot)==null?void 0:c.routing)==null?void 0:o.approvedEventTypes)??[]:[],destinationLabel:e.available?((l=(f=e.snapshot)==null?void 0:f.routing)==null?void 0:l.destinationLabel)??"Actions unavailable":"Actions unavailable",...e.snapshot?{snapshot:e.snapshot}:{},submit:((h=e.binding)==null?void 0:h.submit)??t,inspect:((u=e.binding)==null?void 0:u.inspect)??t,captureOriginal:(g=e.binding)==null?void 0:g.captureOriginal}}function Xs(e,t,r){return!!(e&&t&&r.incarnation&&V(t,r.incarnation)&&(r.highWatermark<e.highWatermark||r.stateRev<e.stateRev))}function Or(e,t,r,n){const s=e.documentId===r&&e.transport===n?e:he(r,n);return{...s,events:[...s.events,t].slice(-200)}}function Zs(e,t){if(e.incarnation&&(e.incarnation.documentId!==t||e.events.some(r=>r.documentId!==t||!r.incarnation||!V(e.incarnation,r.incarnation))))throw new Error("Document replay identity changed.")}const Ct=new WeakMap;function Ys(e,t,r){const n=Ss(e,t,r);if(n)return Ct.set(r,{owner:e,run:t,witness:n}),n}const Er=new WeakMap,Ve=new WeakMap,Rt=new WeakMap,Ot=new WeakMap;function ye(e,t){De(e);const r=t??Ve.get(e),n=r&&Er.get(r);return n&&n.owner===e&&Ve.get(e)===r&&n.active?n:void 0}function X(e){return De(e),Ve.get(e)}function be(e,t){const r=ye(e,t);return r?Object.freeze({birth:r.birth,httpBaseline:r.httpBaseline,snapshot:r.snapshot,verified:r.verified}):void 0}function Ge(e,t,r=!1){var i,a;const n=ye(e,t),s=ce(e);return!!n&&s.live&&n.verified&&n.transport===ut(e)&&(!r||((a=(i=n.snapshot)==null?void 0:i.routing)==null?void 0:a.enabled)===!0)}function Qs(e){const t=ye(e);Ve.delete(e),t&&(t.active=!1,t.verified=!1)}function vt(e,t){const r=ye(e,t);r&&(r.verified=!1)}function Ks(e,t,r){const n=ye(e,r);return!n||!re(e,t)?!1:(n.verified=!0,re(e,t))}function ei(e,t,r){const n=Ct.get(r);Ct.delete(r);const s=(n==null?void 0:n.owner)===e&&n.run===t?n.witness:void 0;if(!s||!re(e,t))return!1;const i=s.response.incarnation;let a=ye(e);if(!a&&!i)return re(e,t);if(!a&&i){const c=ce(e),o=()=>{const w=ce(e);return re(e,t)&&w.epoch===c.epoch&&w.observation===c.observation&&X(e)===c.subject},f=ut(e),l=f.ingestCanvasEvent;if(!o())return!1;const h=Function.prototype.bind.call(l,f),u=f.getCanvasEventReceipt;if(!o())return!1;const g=Function.prototype.bind.call(u,f);if(!o())return!1;a={owner:e,token:Object.freeze({}),birth:Object.freeze({...i}),active:!0,verified:!1,submit:h,inspect:g,transport:f},Er.set(a.token,a),Ve.set(e,a.token),a.httpBaseline=Object.freeze({birth:a.birth,floor:s.response.receiptRetentionFloor}),Rt.set(r,Object.freeze({owner:e,run:t,epoch:c.epoch,previous:c.subject,subject:a.token}));try{Ds(e,t,r)}catch(w){throw ye(e)===a&&pi(e,t,r),w}finally{Rt.delete(r)}if(!re(e,t))return!1}else if(a){if(!i||!V(a.birth,i))return!1;a.httpBaseline=Object.freeze({birth:a.birth,floor:s.response.receiptRetentionFloor})}return re(e,t)?(a&&(a.verified=mi(e)||a.verified),!0):!1}function Nt(e,t,r){const n=zt(e),s=n.subject,i=()=>Ir(e,n,r);if(!s||!Ge(e,s)){const o=Pe(e);Be(e,o)}if(!i())return;const a=s&&Rr(e,s),c=Hs(e);n.dispatch(o=>{var h;if(!i())return o;const f=((h=o.binding)==null?void 0:h.owner)===s?o:he(n.documentId,n.transport),l=typeof t=="function"?t(f):t;return i()?{...l,...l.snapshot?{snapshot:Object.freeze({...l.snapshot})}:{},binding:a,frameAdmission:c}:o})}function ti(e,t,r,n,s){const i=zt(e),a=ye(e);Ir(e,i,s)&&(a&&(a.snapshot=t),Nt(e,c=>Vs(c,t,i.documentId,i.transport,r,n),s))}function ri(e,t,r,n){const s=Cr(e,t,r,n);if(!re(e,t)||!s)return!1;if(s.docSeq<=At(e).highest)return re(e,t);Ot.set(r,{owner:e,run:t,pending:n,frame:s});try{Is(e,t,r,n)}finally{Ot.delete(r)}if(!re(e,t))return!1;const i=zt(e);return Nt(e,a=>Or(a,s,i.documentId,i.transport),t),re(e,t)}function ni(e,t){const r=ye(e,t);if(!r)return;const n=ce(e).documentId;return{current:s=>Ge(e,t,s==="submit"),submit:(s,i)=>r.submit(n,s,{expectedGeneration:r.birth.generation},i),inspect:(s,i)=>r.inspect(n,s,{expectedGeneration:r.birth.generation},i),capture:()=>{const s=r.httpBaseline;return!s||!Ge(e,t,!0)||!V(s.birth,r.birth)?null:Object.freeze({current:i=>Ge(e,t,i==="submit")&&(i==="read"||r.httpBaseline===s),submit:(i,a)=>r.submit(n,i,{expectedGeneration:s.birth.generation},a),inspect:(i,a)=>r.inspect(n,i,{expectedGeneration:s.birth.generation},a)})}}}function _r(e,t,r){const n=Rt.get(r),s=ce(e);return n&&n.owner===e&&n.run===t&&s.epoch===n.epoch&&s.subject===n.subject&&s.live?n:void 0}function si(e,t,r,n){const s=Ot.get(r);return s&&s.owner===e&&s.run===t&&s.pending===n&&re(e,t)?s.frame:void 0}const Sr=new WeakMap,it=new WeakMap;function ii(e){const t=it.get(e);if(!t)throw new Error("Document construction ticket is foreign or consumed.");return it.delete(e),t}function oi(e,t,r){const n=Object.freeze({});it.set(n,Object.freeze({documentId:e,transport:t,dispatch:r}));try{const s=gi(n);return Sr.set(n,s),n}finally{it.delete(n)}}function Q(e){const t=Sr.get(e);if(!t)throw new Error("Document owner is foreign.");return t}function De(e){Q(e)}function ce(e){return Q(e).facts()}function ut(e){return Q(e).transport()}function sr(e){return Q(e).subject()}function _e(e,t){return Q(e).subjectFacts(t)}function ke(e,t,r=!1){return Q(e).subjectCurrent(t,r)}function ai(e,t){return Q(e).binding(t)}function ci(e,t){Q(e).reserve(t)}function re(e,t){return Q(e).current(t)}function ui(e,t,r){return Q(e).admit(t,r)}function ir(e,t,r,n){return Q(e).frame(t,r,n)}function or(e,t){return Q(e).qualify(t)}function li(e,t){Q(e).failed(t)}function di(e,t){Q(e).unavailable(t)}function fi(e,t){Q(e).start(t)}function hi(e){Q(e).dispose()}const Dr=new WeakMap;function zt(e){const t=Object.freeze(Q(e).projection());return Dr.set(t,Object.freeze({custodyKey:e,capture:t})),t}function Ir(e,t,r){const n=Dr.get(t);return(n==null?void 0:n.custodyKey)===e&&n.capture===t&&Q(e).projectionCurrent(t.epoch,t.subject,r)}function pi(e,t,r){Q(e).abortAdmission(t,r)}function mi(e){return Q(e).qualified()}const Et=new WeakMap;function gi(e){const{documentId:t,transport:r,dispatch:n}=ii(e);let s,i=!1,a;const c={live:!0};let o=0,f,l,h=!1,u,g,w=0;const m=()=>c.live,y=()=>Qs(e);let N=0;const D=()=>At(e),I=x=>{const b=nr(e,x);return!!b&&!b.ended&&m()&&s===x&&b.epoch===o&&b.subject===X(e)},M=(x=!1)=>{const b=Pe(e);y(),o++,s=void 0,x&&rr(e),Be(e,b)},T=(x,b)=>Nt(e,x,b),U=x=>{const b=As(e,x),S=X(e),_=S&&be(e,S);return!I(x)||!b||b.through>b.highest||!u||!_||!V(u,_.birth)||!Ks(e,x,S)?!1:(u=void 0,T(z=>({...z,available:!0}),x),I(x))},P=(x,b,S)=>{const _=X(e),z=_&&be(e,_),R=o,k=()=>m()&&R===o&&X(e)===_&&(!S||I(S));if(!k()||Xs(z==null?void 0:z.snapshot,z==null?void 0:z.birth,x))return;const L=b?x.routing:l;x={...x,routing:L&&Object.freeze({enabled:L.enabled,destinationLabel:L.destinationLabel,approvedEventTypes:Object.freeze([...L.approvedEventTypes])})},b&&(l=x.routing),!_&&!x.incarnation&&(h=!0),k()&&ti(e,x,b,u===void 0,S)},q=(x,b)=>{var ae;const S=Ys(e,x,b);if(!I(x)||!S)return"discard";const _=S.response;Zs(_,t);const z=_.incarnation;if((X(e)||u||g)&&!z)throw new Error("Document replay identity is unavailable.");if(g&&z&&!V(g,z))return M(!0),T(he(t,r)),"restart";const R=X(e),k=(R&&((ae=be(e,R))==null?void 0:ae.birth))??u;if(z&&(k&&!V(k,z)||!k&&h||S.targetBirth&&!V(S.targetBirth,z)))return u=z,h=!1,l=void 0,f=void 0,M(!0),T(he(t,r)),"restart";const{events:L,...W}=_,K=X(e);return!K&&z&&(u=g??z),!ei(e,x,b)||!I(x)?"discard":(!K&&z&&(g=void 0),P(W,S.revision===N,x),I(x)?"accepted":"discard")},$=(x,b,S)=>{var k;const _=Cr(e,x,b,S),z=X(e),R=(z&&((k=be(e,z))==null?void 0:k.birth))??u;return!I(x)||!_||_.documentId!==t||R&&(!_.incarnation||!V(R,_.incarnation))?!1:ri(e,x,b,S)},te=(x,b)=>{const S=Object.freeze({});Et.set(S,Object.freeze({owner:e,revision:N,observation:w,epoch:o,notification:x,mode:b}));try{return Ns(e,S)}finally{Et.delete(S)}},me=x=>{if(i||!m()||(i=!0,T(he(t,r)),!m()))return;const b=an(void 0,S=>{if(!m()||S.documentId!==t)return;const _=S.type==="canvas_channel_snapshot"?S.snapshot.incarnation:S.incarnation,z=X(e);if(!z){if(u&&!g&&(!_||!V(u,_))||!_||_.documentId!==t)return;if(!g||!V(g,_)){const R=!!g||!!u;if(g=Object.freeze({..._}),w++,l=void 0,f=void 0,h=!1,R&&(M(!0),T(he(t,r))),!m()||!g||!V(g,_))return}te(S,"quarantine"),m()&&x();return}if(u&&(!_||!V(u,_))){_&&x();return}if(_&&!V(be(e,z).birth,_)){u=_,h=!1,l=void 0,f=void 0,M(!0),T(he(t,r)),m()&&x();return}if(_){if(f!==void 0&&f!==S.scope){const R=Pe(e);if(f=S.scope,vt(e,z),o++,s=void 0,N++,Be(e,R),X(e)!==z||!m())return;T(k=>({...k,available:!1})),X(e)===z&&m()&&x();return}f=S.scope,N++,S.type==="canvas_channel_snapshot"?P(S.snapshot,!0):S.docSeq>D().highest+1?(te(S,"gap")&&m()&&T(k=>({...k,available:!1})),m()&&x()):te(S,"event")}},r,()=>{if(!m())return;const S=Pe(e),_=X(e);_&&vt(e,_),o++,s=void 0,N++,Be(e,S),T(z=>({...z,available:!1})),m()&&x()});m()?a=b:b(),m()&&x()};return Ar.set(e,x=>{const b=Je(e,x);if(!b||b.notification.type==="canvas_channel_snapshot")return;const S=X(e),_=o;!S||!b.notification.incarnation||!V(be(e,S).birth,b.notification.incarnation)||(T(z=>Or(z,b.notification,t,r)),!m()||_!==o||X(e))}),{facts:()=>Object.freeze({documentId:t,live:m(),epoch:o,revision:N,observation:w,subject:X(e)}),transport:()=>r,subject:()=>X(e),subjectFacts:x=>be(e,x),subjectCurrent:(x,b)=>Ge(e,x,b),binding:x=>Rr(e,x),qualified:()=>u===void 0,projection:()=>({documentId:t,transport:r,dispatch:n,epoch:o,run:s,subject:X(e)}),projectionCurrent:(x,b,S)=>m()&&x===o&&b===X(e)&&(!S||s===S),abortAdmission:(x,b)=>{_r(e,x,b)&&M(!0)},reserve:x=>{const b=nr(e,x);if(!b||b.ended||!m()||b.epoch!==o||b.subject!==X(e))throw new Error("Replay run is foreign or stale.");s=x},current:I,admit:q,frame:$,qualify:U,failed:x=>{if(!I(x))return;const b=X(e);b&&vt(e,b),T(S=>({...S,available:!1}),x)},unavailable:x=>{I(x)&&T(b=>({...b,available:!1}),x)},start:me,dispose:()=>{if(!m())return;const x=Pe(e);c.live=!1,s=void 0;const b=a;a=void 0,y(),o++,rr(e);try{Be(e,x)}finally{b==null||b()}}}}function Je(e,t){const r=Et.get(t),n=ce(e);if(!(!r||r.owner!==e||!n.live||n.epoch!==r.epoch||n.revision!==r.revision||n.observation!==r.observation))return r}function vi(e,t){var c;const r=Je(e,t);if(!r||r.notification.type==="canvas_channel_snapshot")return;const n=r.notification,i=ce(e).subject,a=i&&be(e,i);!a||!n.incarnation||!V(a.birth,n.incarnation)||n.docSeq<=At(e).highest||(zs(e,t),!(!Je(e,t)||ce(e).subject!==i)&&((c=Ar.get(e))==null||c(t)))}const Ar=new WeakMap;function bi(e,t,r){const n=oi(e,t,r);_s(n);const s=$s(n);return Object.freeze({beginRun:()=>Ts(n),frameAdmission:s,start:i=>fi(n,i),dispose:()=>hi(n)})}function wi(e,t){let r,n=0;const s=h=>{try{t==null||t(h)}catch{}},i=h=>{r===h&&(r=void 0)},a=(h,u)=>{h.settled||(h.settled=!0,r||s(!1),u?h.reject(u.cause):h.resolve())},c=()=>{l().catch(()=>{})},o=(h,u)=>{const g=()=>n===h.revision;if(!g())return;const w=u.beginFinalization();if(g()){if(w==="restart"){c();return}if(w==="drain")for(;g();){const m=u.drainOne();if(!g())return;if(m!=="again"){if(m==="restart")c();else if(m==="tail"){const y=u.finishFinalization();g()&&y==="restart"&&c()}return}}}},f=async h=>{let u,g;try{u=e();try{for(;await u.page()==="again";);}catch(w){u.failed(w)}}catch(w){g={cause:w}}finally{i(h);try{u&&o(h,u)}catch(w){g={cause:w}}finally{a(h,g)}}},l=()=>{if(r)return r.promise;let h,u;const g=new Promise((m,y)=>{h=m,u=y}),w={revision:++n,promise:g,resolve:h,reject:u,settled:!1};return r=w,s(!0),f(w),g};return Object.freeze({request:l})}function yi(e,t,r,n){const s=bi(e,t,r);let i=!1;const a=wi(()=>{const c=s.beginRun();return{async page(){const o=await c.readPage();if(!o)return"done";const f=c.consumePage(o);if(f.kind!=="frames")return f.kind;for(let l=0;l<f.count;l++)if(!c.advancePageFrame(o,l))return"done";return c.finishPage(o)},failed:()=>c.failed(),beginFinalization:()=>{const o=c.beginFinalization();return o!=="drain"&&c.end(),o},drainOne(){if(!c.current())return c.end(),"stop";const o=c.takePending();return o?c.advancePending(o)?"again":(c.end(),"stop"):"tail"},finishFinalization:()=>{try{return c.finishFinalization()}finally{c.end()}}}},c=>{i||n==null||n(c)});return s.start(()=>{a.request().catch(()=>{})}),Object.freeze({dispose(){i=!0,s.dispose()}})}function xi(e){var f,l,h;const t=ue(),[r,n]=p.useState(()=>he(e,t)),[s,i]=p.useState({documentId:e,transport:t,pending:!0});p.useLayoutEffect(()=>{const u=yi(e,t,n,g=>{i({documentId:e,transport:t,pending:g})});return()=>u.dispose()},[e,t]);const a=r.documentId===e&&r.transport===t?r:he(e,t),c=p.useMemo(()=>Js(a),[a]),o=p.useMemo(()=>{var w;const u=(w=a.snapshot)==null?void 0:w.incarnation,g=a.binding;return u&&g?Object.freeze({incarnation:Object.freeze({...u}),current:()=>g.current("read")}):void 0},[(f=a.snapshot)==null?void 0:f.incarnation,a.binding]);return{channel:c,events:a.events,frameAdmission:a.frameAdmission,fileSaveBinding:o,fileSaveObservation:s.documentId!==e||s.transport!==t||s.pending?"pending":a.available&&((l=a.binding)!=null&&l.verified)&&((h=a.snapshot)!=null&&h.incarnation)?"ready":"unavailable"}}function ki({content:e}){const[t]=St();return t?d.jsx("div",{className:"h-full w-full",children:d.jsx(mn,{sessionId:t,serverName:e.serverName,uri:e.uri,title:e.title})}):null}const ji=p.lazy(()=>Ce(()=>import("./CanvasFileContent-ClcHZ_l-.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}))),Ci=p.lazy(()=>Ce(()=>import("./CanvasModel3dContent-Cm3msNdQ.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}))),Ri=p.lazy(()=>Ce(()=>import("./CanvasCsvContent-ViqRJuhW.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}))),Oi=p.lazy(()=>Ce(()=>import("./index-DcZPWi_I.js").then(e=>e.uE),__vite__mapDeps([1,2])).then(e=>({default:e.CanvasDiffContent})));function Wi({documentId:e,widgetChannel:t,content:r,onContentChange:n}){switch(r.type){case"url":case"browser":return d.jsx(Yn,{documentId:e,content:r},`${e}:${r.url}`);case"markdown":return d.jsx(hs,{documentId:e,content:r,onContentChange:n},r.sourcePath??"generated");case"json":return d.jsx(ps,{content:r});case"image":return d.jsx(ws,{content:r});case"pdf":return d.jsx(xs,{content:r});case"audio":return d.jsx(Cs,{content:r});case"video":return d.jsx(Rs,{content:r});case"widget":return t?d.jsx(kr,{content:r,documentId:e,channel:t}):d.jsx(Ei,{documentId:e,content:r});case"mcp_app":return d.jsx(ki,{content:r});case"file":return d.jsx(p.Suspense,{fallback:d.jsx(Ke,{}),children:d.jsx(ji,{documentId:e,content:r})});case"model3d":return d.jsx(p.Suspense,{fallback:d.jsx(Ke,{}),children:d.jsx(Ci,{content:r})});case"csv":return d.jsx(p.Suspense,{fallback:d.jsx(Ke,{}),children:d.jsx(Ri,{content:r})});case"diff":return d.jsx(p.Suspense,{fallback:d.jsx(Ke,{}),children:d.jsx(Oi,{documentId:e,content:r},r.sourcePath)})}}function Ke(){return d.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"})}function Ei({documentId:e,content:t}){const{channel:r}=xi(e);return d.jsx(kr,{documentId:e,content:t,channel:r})}const _i=p.lazy(()=>Ce(()=>import("./BlintzCanvas-DoAZs5bz.js").then(e=>e.B),__vite__mapDeps([0,1,2,3,4,5])).then(e=>({default:e.BlintzCanvas})));function Gi({roomId:e,document:t,content:r,onSave:n}){const[s,i]=p.useState(null),[a,c]=p.useState(!1),[o,f]=p.useState(null),l=s!==null,h=r.sourcePath===void 0;Mn(e,l?t.id:null);const u=async()=>{if(s===null)return;if(s===r.content){i(null),f(null);return}c(!0),f(null);const g=await n(t.id,{...r,content:s});c(!1),g?i(null):f("Couldn’t save. Your words are still here. Try again.")};return d.jsxs("div",{className:"flex h-full flex-col",children:[h&&d.jsxs("div",{className:"flex items-center justify-end gap-2 border-b px-2 py-1",children:[l&&d.jsx("span",{className:"text-muted-foreground text-xs",children:a?"Saving…":"Everyone sees your save."}),d.jsx(et,{type:"button",size:"xs",variant:"ghost",disabled:a,"aria-label":l?"Save for the room":"Edit this document",onClick:()=>l?void u():i(r.content),children:l?d.jsx(lr,{className:"size-3.5"}):d.jsx(dr,{className:"size-3.5"})})]}),o!==null&&d.jsx("p",{role:"status",className:"text-destructive border-b px-2 py-1 text-xs",children:o}),d.jsx("div",{className:"flex-1 px-2 pb-6",children:d.jsx(p.Suspense,{fallback:d.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"}),children:d.jsx(_i,{value:s??r.content,editable:l,onChange:i},l?"editing":`rev-${t.rev}`)})})]})}const _t="dorkos-canvas-sessions",Si=1440*60*60*1e3;function Nr(){try{const e=localStorage.getItem(_t);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(_t):localStorage.setItem(_t,JSON.stringify(e))}catch{}}function Di(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 ot(e){return e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?`[${e.map(ot).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)}:${ot(n)}`).join(",")}}`}function Ii(e,t){const r=new Set,n=new Map;for(const i of e){const a=Jt(i.content);if(a!==null){r.add(a);continue}const c=ot(i.content);n.set(c,(n.get(c)??0)+1)}const s=[];for(const i of t){const a=Jt(i);if(a!==null){r.has(a)||s.push(i);continue}const c=ot(i),o=n.get(c)??0;o>0?n.set(c,o-1):s.push(i)}return s}const tt=new Set;function $i(){tt.clear()}function Hi(e,t={}){const r=ue(),n=t.canonical??!0;p.useEffect(()=>{e&&J.getState().loadCanvasForSession(e)},[e]),p.useEffect(()=>{if(!e||!n||tt.has(e))return;const s=Nr();if(!s)return;const i=s[e];if(!i){Ai(s);return}tt.add(e),(async()=>{try{const a=Di(i),c=Ii(await r.listSessionCanvas(e),a);if(c.length===0){ar(e);return}for(const o of c)await r.openSessionCanvasDocument(e,o);ar(e),J.getState().hydrateCanvasFromSnapshot(e,await r.listSessionCanvas(e))}catch{tt.delete(e)}})()},[e,n,r])}function ar(e){const t=Nr();if(!t)return;const{[e]:r,...n}=t;zr(n)}function Ai(e){const t=Date.now()-Si,r=Object.entries(e).filter(([,n])=>n.accessedAt===void 0||n.accessedAt>=t);r.length!==Object.keys(e).length&&zr(Object.fromEntries(r))}export{Wi as C,Bi as F,Gi as R,xi as a,Tn as b,zn as c,Ui as d,kr as e,$i as f,An as g,Hi as h,xr as r,us as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a1 as n,a3 as s,a4 as u,at as o,au as r}from"./index-DcZPWi_I.js";function c(){const t=n(),e=s();return u({mutationKey:o,mutationFn:a=>t.updateConfig(a),onSuccess:()=>{e.invalidateQueries({queryKey:r.current()})}})}export{c as u};
|