@halcyonlabs/app 0.47.0-halcyon.604 → 0.47.0-halcyon.607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (782) hide show
  1. package/app/dist/assets/{AddMachineDialog-BHF-GkBG.js → AddMachineDialog-CG2ZZhp-.js} +1 -1
  2. package/app/dist/assets/AddMachineDialog-CG2ZZhp-.js.br +0 -0
  3. package/app/dist/assets/AddMachineDialog-CG2ZZhp-.js.gz +0 -0
  4. package/app/dist/assets/{AppCommandShortcutHint-7JPI7Au-.js → AppCommandShortcutHint-CCVkbqD1.js} +1 -1
  5. package/app/dist/assets/{AppFileExternalNavigationDispatcher-BNbJsP1g.js → AppFileExternalNavigationDispatcher-DETVZfBW.js} +1 -1
  6. package/app/dist/assets/AppFileExternalNavigationDispatcher-DETVZfBW.js.br +0 -0
  7. package/app/dist/assets/AppFileExternalNavigationDispatcher-DETVZfBW.js.gz +0 -0
  8. package/app/dist/assets/{AppToasterView-DP33gZcS.js → AppToasterView-BpJaGVQ1.js} +1 -1
  9. package/app/dist/assets/{BrowserTabDeck-BlOoU-vR.js → BrowserTabDeck-c6VRKA-g.js} +1 -1
  10. package/app/dist/assets/BrowserTabDeck-c6VRKA-g.js.br +0 -0
  11. package/app/dist/assets/BrowserTabDeck-c6VRKA-g.js.gz +0 -0
  12. package/app/dist/assets/{CommandPaletteBody-CBbTgLrW.js → CommandPaletteBody-BeiWvSTK.js} +1 -1
  13. package/app/dist/assets/CommandPaletteBody-BeiWvSTK.js.br +0 -0
  14. package/app/dist/assets/CommandPaletteBody-BeiWvSTK.js.gz +0 -0
  15. package/app/dist/assets/{DiffHost-DYBSO1_c.js → DiffHost-xesYsZUt.js} +1 -1
  16. package/app/dist/assets/DiffHost-xesYsZUt.js.br +0 -0
  17. package/app/dist/assets/DiffHost-xesYsZUt.js.gz +0 -0
  18. package/app/dist/assets/{ExperimentalFileLinkMenu-DO2lGQoK.js → ExperimentalFileLinkMenu-CDVoETHe.js} +1 -1
  19. package/app/dist/assets/ExperimentalFileLinkMenu-CDVoETHe.js.br +0 -0
  20. package/app/dist/assets/ExperimentalFileLinkMenu-CDVoETHe.js.gz +0 -0
  21. package/app/dist/assets/{FilePreview-ORcgsTax.js → FilePreview-CzacGZ35.js} +1 -1
  22. package/app/dist/assets/FilePreview-CzacGZ35.js.br +0 -0
  23. package/app/dist/assets/FilePreview-CzacGZ35.js.gz +0 -0
  24. package/app/dist/assets/{GitDiffCardHeader-i4vt7tT5.js → GitDiffCardHeader-CJtFaq1K.js} +1 -1
  25. package/app/dist/assets/GitDiffCardHeader-CJtFaq1K.js.br +0 -0
  26. package/app/dist/assets/GitDiffCardHeader-CJtFaq1K.js.gz +0 -0
  27. package/app/dist/assets/{InlineMessageEditorFrame-y089xCLP.js → InlineMessageEditorFrame-C0rqOlNn.js} +1 -1
  28. package/app/dist/assets/InlineMessageEditorFrame-C0rqOlNn.js.br +0 -0
  29. package/app/dist/assets/InlineMessageEditorFrame-C0rqOlNn.js.gz +0 -0
  30. package/app/dist/assets/{MachineLabel-D07WUIMh.js → MachineLabel-vUI5j8ve.js} +1 -1
  31. package/app/dist/assets/MachineLabel-vUI5j8ve.js.br +0 -0
  32. package/app/dist/assets/MachineLabel-vUI5j8ve.js.gz +0 -0
  33. package/app/dist/assets/{MachineRenameDialog-RyrwvNas.js → MachineRenameDialog-CrnZuppe.js} +1 -1
  34. package/app/dist/assets/MachineRenameDialog-CrnZuppe.js.br +0 -0
  35. package/app/dist/assets/MachineRenameDialog-CrnZuppe.js.gz +0 -0
  36. package/app/dist/assets/{MachineSettingsView-Bg6Op62W.js → MachineSettingsView-BR6qseai.js} +1 -1
  37. package/app/dist/assets/MachineSettingsView-BR6qseai.js.br +0 -0
  38. package/app/dist/assets/MachineSettingsView-BR6qseai.js.gz +0 -0
  39. package/app/dist/assets/{MicrophonePreferences-DwsTYfON.js → MicrophonePreferences-wMQ36e_Q.js} +1 -1
  40. package/app/dist/assets/MicrophonePreferences-wMQ36e_Q.js.br +0 -0
  41. package/app/dist/assets/MicrophonePreferences-wMQ36e_Q.js.gz +0 -0
  42. package/app/dist/assets/{ModelReasoningMenu-Dth3XXm8.js → ModelReasoningMenu-Do0jyo5Q.js} +1 -1
  43. package/app/dist/assets/ModelReasoningMenu-Do0jyo5Q.js.br +0 -0
  44. package/app/dist/assets/ModelReasoningMenu-Do0jyo5Q.js.gz +0 -0
  45. package/app/dist/assets/{MoonletDiff-Da65ABAI.js → MoonletDiff-CCvaiEEC.js} +1 -1
  46. package/app/dist/assets/MoonletDiff-CCvaiEEC.js.br +0 -0
  47. package/app/dist/assets/MoonletDiff-CCvaiEEC.js.gz +0 -0
  48. package/app/dist/assets/{MoonletDiffSplit-Phl7m23w.js → MoonletDiffSplit-3xEwFpfu.js} +2 -2
  49. package/app/dist/assets/MoonletDiffSplit-3xEwFpfu.js.br +0 -0
  50. package/app/dist/assets/MoonletDiffSplit-3xEwFpfu.js.gz +0 -0
  51. package/app/dist/assets/{MoonletSourceCode-C5aa88dK.js → MoonletSourceCode-BgaVW-e6.js} +1 -1
  52. package/app/dist/assets/MoonletSourceCode-BgaVW-e6.js.br +0 -0
  53. package/app/dist/assets/MoonletSourceCode-BgaVW-e6.js.gz +0 -0
  54. package/app/dist/assets/{NewTabPage-BKkv1maV.js → NewTabPage-BOqCqqLe.js} +1 -1
  55. package/app/dist/assets/NewTabPage-BOqCqqLe.js.br +0 -0
  56. package/app/dist/assets/NewTabPage-BOqCqqLe.js.gz +0 -0
  57. package/app/dist/assets/{NewThreadComposer-00DY4i8k.js → NewThreadComposer-DyB52pmS.js} +1 -1
  58. package/app/dist/assets/NewThreadComposer-DyB52pmS.js.br +0 -0
  59. package/app/dist/assets/NewThreadComposer-DyB52pmS.js.gz +0 -0
  60. package/app/dist/assets/{OnboardingFlow-GwpuTTqu.js → OnboardingFlow-DTPixZrb.js} +1 -1
  61. package/app/dist/assets/OnboardingFlow-DTPixZrb.js.br +0 -0
  62. package/app/dist/assets/OnboardingFlow-DTPixZrb.js.gz +0 -0
  63. package/app/dist/assets/{OptionPicker-Cy_W5NWS.js → OptionPicker-CxOGHDd8.js} +1 -1
  64. package/app/dist/assets/OptionPicker-CxOGHDd8.js.br +0 -0
  65. package/app/dist/assets/OptionPicker-CxOGHDd8.js.gz +0 -0
  66. package/app/dist/assets/{PaletteShell-CRwrb4lb.js → PaletteShell-BMkwhUdz.js} +1 -1
  67. package/app/dist/assets/PaletteShell-BMkwhUdz.js.br +0 -0
  68. package/app/dist/assets/PaletteShell-BMkwhUdz.js.gz +0 -0
  69. package/app/dist/assets/{PaneMaximizeButton-CMp4cCoZ.js → PaneMaximizeButton-DgXn2p5T.js} +1 -1
  70. package/app/dist/assets/PaneMaximizeButton-DgXn2p5T.js.br +0 -0
  71. package/app/dist/assets/PaneMaximizeButton-DgXn2p5T.js.gz +0 -0
  72. package/app/dist/assets/{PierreLineSelectionActions-BXbCJV8P.js → PierreLineSelectionActions-V_GPrVau.js} +1 -1
  73. package/app/dist/assets/PierreLineSelectionActions-V_GPrVau.js.br +0 -0
  74. package/app/dist/assets/PierreLineSelectionActions-V_GPrVau.js.gz +0 -0
  75. package/app/dist/assets/{PluginPanelRightPanelHost-CuKRaAaL.js → PluginPanelRightPanelHost-CRDSntoM.js} +1 -1
  76. package/app/dist/assets/PluginPanelRightPanelHost-CRDSntoM.js.br +0 -0
  77. package/app/dist/assets/PluginPanelRightPanelHost-CRDSntoM.js.gz +0 -0
  78. package/app/dist/assets/{PluginSettingsSections-DJo5h7Qh.js → PluginSettingsSections-ZnUNrvlJ.js} +1 -1
  79. package/app/dist/assets/PluginSettingsSections-ZnUNrvlJ.js.br +0 -0
  80. package/app/dist/assets/PluginSettingsSections-ZnUNrvlJ.js.gz +0 -0
  81. package/app/dist/assets/{PluginThreadChat-BV6OMCzu.js → PluginThreadChat-DtIyKaqq.js} +1 -1
  82. package/app/dist/assets/PluginThreadChat-DtIyKaqq.js.br +0 -0
  83. package/app/dist/assets/PluginThreadChat-DtIyKaqq.js.gz +0 -0
  84. package/app/dist/assets/{ProjectDetailSettingsView-DdF6YsSg.js → ProjectDetailSettingsView-B3apTKMj.js} +1 -1
  85. package/app/dist/assets/ProjectDetailSettingsView-B3apTKMj.js.br +0 -0
  86. package/app/dist/assets/ProjectDetailSettingsView-B3apTKMj.js.gz +0 -0
  87. package/app/dist/assets/{ProjectMachineSetupDialog-CtbI4XxM.js → ProjectMachineSetupDialog-C43S09Ex.js} +1 -1
  88. package/app/dist/assets/ProjectMachineSetupDialog-C43S09Ex.js.br +0 -0
  89. package/app/dist/assets/ProjectMachineSetupDialog-C43S09Ex.js.gz +0 -0
  90. package/app/dist/assets/{ProjectsSettingsSection-BT1kXbPn.js → ProjectsSettingsSection-CIshX8Xc.js} +1 -1
  91. package/app/dist/assets/ProjectsSettingsSection-CIshX8Xc.js.br +0 -0
  92. package/app/dist/assets/ProjectsSettingsSection-CIshX8Xc.js.gz +0 -0
  93. package/app/dist/assets/{QueuedMessagesList-D1aAchqp.js → QueuedMessagesList-Dh5dxmNK.js} +1 -1
  94. package/app/dist/assets/QueuedMessagesList-Dh5dxmNK.js.br +0 -0
  95. package/app/dist/assets/QueuedMessagesList-Dh5dxmNK.js.gz +0 -0
  96. package/app/dist/assets/{RemotePathBrowser-vPIL8lVm.js → RemotePathBrowser-1A5-qAxD.js} +1 -1
  97. package/app/dist/assets/RemotePathBrowser-1A5-qAxD.js.br +0 -0
  98. package/app/dist/assets/RemotePathBrowser-1A5-qAxD.js.gz +0 -0
  99. package/app/dist/assets/{RootComposeView-DV6JGFlA.js → RootComposeView-BIZpqYG3.js} +1 -1
  100. package/app/dist/assets/RootComposeView-BIZpqYG3.js.br +0 -0
  101. package/app/dist/assets/RootComposeView-BIZpqYG3.js.gz +0 -0
  102. package/app/dist/assets/{SecondaryPanelLayout-BpHDgFJ_.js → SecondaryPanelLayout-BIQDxJLi.js} +1 -1
  103. package/app/dist/assets/SecondaryPanelLayout-BIQDxJLi.js.br +0 -0
  104. package/app/dist/assets/SecondaryPanelLayout-BIQDxJLi.js.gz +0 -0
  105. package/app/dist/assets/{ServerMoveOverlayView-CGkGzv8t.js → ServerMoveOverlayView-BSJahQeB.js} +1 -1
  106. package/app/dist/assets/ServerMoveOverlayView-BSJahQeB.js.br +0 -0
  107. package/app/dist/assets/ServerMoveOverlayView-BSJahQeB.js.gz +0 -0
  108. package/app/dist/assets/{SettingsSidebar-1XC0Uxwo.js → SettingsSidebar-DY_kbv4v.js} +1 -1
  109. package/app/dist/assets/SettingsSidebar-DY_kbv4v.js.br +0 -0
  110. package/app/dist/assets/SettingsSidebar-DY_kbv4v.js.gz +0 -0
  111. package/app/dist/assets/SettingsView-CR1GzBCl.js +7 -0
  112. package/app/dist/assets/SettingsView-CR1GzBCl.js.br +0 -0
  113. package/app/dist/assets/SettingsView-CR1GzBCl.js.gz +0 -0
  114. package/app/dist/assets/{SidebarFooterCustomize-D7sLYPwD.js → SidebarFooterCustomize-pIj856Zr.js} +1 -1
  115. package/app/dist/assets/SidebarFooterCustomize-pIj856Zr.js.br +0 -0
  116. package/app/dist/assets/SidebarFooterCustomize-pIj856Zr.js.gz +0 -0
  117. package/app/dist/assets/{SidebarVisibilityCustomize-DpTzFoGl.js → SidebarVisibilityCustomize-CR7hQOIF.js} +1 -1
  118. package/app/dist/assets/SidebarVisibilityCustomize-CR7hQOIF.js.br +0 -0
  119. package/app/dist/assets/SidebarVisibilityCustomize-CR7hQOIF.js.gz +0 -0
  120. package/app/dist/assets/{SourceCodeHost-DVEXLJK1.js → SourceCodeHost-DkoXO-RM.js} +2 -2
  121. package/app/dist/assets/SourceCodeHost-DkoXO-RM.js.br +0 -0
  122. package/app/dist/assets/SourceCodeHost-DkoXO-RM.js.gz +0 -0
  123. package/app/dist/assets/{SplitWorkspaceRoute-BfxQQdOx.js → SplitWorkspaceRoute-DN3j-Nio.js} +2 -2
  124. package/app/dist/assets/SplitWorkspaceRoute-DN3j-Nio.js.br +0 -0
  125. package/app/dist/assets/SplitWorkspaceRoute-DN3j-Nio.js.gz +0 -0
  126. package/app/dist/assets/{TerminalOutputBlock-COQNamKR.js → TerminalOutputBlock-DKsNjK8s.js} +1 -1
  127. package/app/dist/assets/TerminalOutputBlock-DKsNjK8s.js.br +0 -0
  128. package/app/dist/assets/TerminalOutputBlock-DKsNjK8s.js.gz +0 -0
  129. package/app/dist/assets/{ThreadActionsMenu-064Gcy7T.js → ThreadActionsMenu-BulopjpY.js} +1 -1
  130. package/app/dist/assets/ThreadActionsMenu-BulopjpY.js.br +0 -0
  131. package/app/dist/assets/ThreadActionsMenu-BulopjpY.js.gz +0 -0
  132. package/app/dist/assets/{ThreadDetailView-CjoXzweq.js → ThreadDetailView-C6cu9JmT.js} +3 -3
  133. package/app/dist/assets/ThreadDetailView-C6cu9JmT.js.br +0 -0
  134. package/app/dist/assets/ThreadDetailView-C6cu9JmT.js.gz +0 -0
  135. package/app/dist/assets/{ThreadSearchPaletteMode-CwdePsHK.js → ThreadSearchPaletteMode-D0MKJ8PL.js} +1 -1
  136. package/app/dist/assets/ThreadSearchPaletteMode-D0MKJ8PL.js.br +0 -0
  137. package/app/dist/assets/ThreadSearchPaletteMode-D0MKJ8PL.js.gz +0 -0
  138. package/app/dist/assets/{ThreadSecondaryPanel-CtYtgTla.js → ThreadSecondaryPanel-CzjhigwP.js} +1 -1
  139. package/app/dist/assets/ThreadSecondaryPanel-CzjhigwP.js.br +0 -0
  140. package/app/dist/assets/ThreadSecondaryPanel-CzjhigwP.js.gz +0 -0
  141. package/app/dist/assets/{ThreadSecondaryPanelTabContent-BNQi8b2n.js → ThreadSecondaryPanelTabContent-BX5A98YK.js} +1 -1
  142. package/app/dist/assets/ThreadSecondaryPanelTabContent-BX5A98YK.js.br +0 -0
  143. package/app/dist/assets/ThreadSecondaryPanelTabContent-BX5A98YK.js.gz +0 -0
  144. package/app/dist/assets/{ThreadStatusGlyph-DxxHDn0P.js → ThreadStatusGlyph-BYavMHiP.js} +1 -1
  145. package/app/dist/assets/ThreadStatusGlyph-BYavMHiP.js.br +0 -0
  146. package/app/dist/assets/ThreadStatusGlyph-BYavMHiP.js.gz +0 -0
  147. package/app/dist/assets/{ThreadTerminalPanel-fb5Kk0KG.js → ThreadTerminalPanel-Cfe76daj.js} +1 -1
  148. package/app/dist/assets/ThreadTerminalPanel-Cfe76daj.js.br +0 -0
  149. package/app/dist/assets/ThreadTerminalPanel-Cfe76daj.js.gz +0 -0
  150. package/app/dist/assets/{ThreadTerminalView-BiGdt3Fd.js → ThreadTerminalView-CgMKh6rk.js} +1 -1
  151. package/app/dist/assets/ThreadTerminalView-CgMKh6rk.js.br +0 -0
  152. package/app/dist/assets/ThreadTerminalView-CgMKh6rk.js.gz +0 -0
  153. package/app/dist/assets/{ThreadTimelineNavigationContext-epkIpS1J.js → ThreadTimelineNavigationContext-2--wIUmU.js} +2 -2
  154. package/app/dist/assets/ThreadTimelineNavigationContext-2--wIUmU.js.br +0 -0
  155. package/app/dist/assets/ThreadTimelineNavigationContext-2--wIUmU.js.gz +0 -0
  156. package/app/dist/assets/{ThreadUnarchiveButton-CExEP4wZ.js → ThreadUnarchiveButton-CiDbuPzJ.js} +1 -1
  157. package/app/dist/assets/{TimelineDetailScroll-D8gge5Y9.js → TimelineDetailScroll-DnMC8nYC.js} +1 -1
  158. package/app/dist/assets/TimelineDetailScroll-DnMC8nYC.js.br +0 -0
  159. package/app/dist/assets/TimelineDetailScroll-DnMC8nYC.js.gz +0 -0
  160. package/app/dist/assets/{TimelineFileDiffBlock-BJt7kifl.js → TimelineFileDiffBlock-D8pKEcE0.js} +1 -1
  161. package/app/dist/assets/TimelineFileDiffBlock-D8pKEcE0.js.br +0 -0
  162. package/app/dist/assets/TimelineFileDiffBlock-D8pKEcE0.js.gz +0 -0
  163. package/app/dist/assets/{TimelineSelectionMenu-DrK39LAT.js → TimelineSelectionMenu-DDYrgVgK.js} +1 -1
  164. package/app/dist/assets/TimelineSelectionMenu-DDYrgVgK.js.br +0 -0
  165. package/app/dist/assets/TimelineSelectionMenu-DDYrgVgK.js.gz +0 -0
  166. package/app/dist/assets/{ToolsView-4tUvUv2U.js → ToolsView-CXmmNmMz.js} +1 -1
  167. package/app/dist/assets/ToolsView-CXmmNmMz.js.br +0 -0
  168. package/app/dist/assets/ToolsView-CXmmNmMz.js.gz +0 -0
  169. package/app/dist/assets/{ToolsViewSplits-BWOxgNc1.js → ToolsViewSplits-VIMb0WxO.js} +2 -2
  170. package/app/dist/assets/ToolsViewSplits-VIMb0WxO.js.br +0 -0
  171. package/app/dist/assets/ToolsViewSplits-VIMb0WxO.js.gz +0 -0
  172. package/app/dist/assets/{WaveformVisualizer-C1SzIkiu.js → WaveformVisualizer-CyOfIcDU.js} +1 -1
  173. package/app/dist/assets/WaveformVisualizer-CyOfIcDU.js.br +0 -0
  174. package/app/dist/assets/WaveformVisualizer-CyOfIcDU.js.gz +0 -0
  175. package/app/dist/assets/{absolute-file-path-CbI5cppS.js → absolute-file-path-BxWHDkiV.js} +1 -1
  176. package/app/dist/assets/{app-fixed-tab-navigation-Cv4Tj7xZ.js → app-fixed-tab-navigation-nG5duhr6.js} +1 -1
  177. package/app/dist/assets/app-fixed-tab-navigation-nG5duhr6.js.br +0 -0
  178. package/app/dist/assets/app-fixed-tab-navigation-nG5duhr6.js.gz +0 -0
  179. package/app/dist/assets/{audio-input-device-preference-D8tr0bqw.js → audio-input-device-preference-Civxk2e_.js} +1 -1
  180. package/app/dist/assets/audio-input-device-preference-Civxk2e_.js.br +0 -0
  181. package/app/dist/assets/audio-input-device-preference-Civxk2e_.js.gz +0 -0
  182. package/app/dist/assets/{bottom-anchored-scroll-body-VYrnz8Hl.js → bottom-anchored-scroll-body-izL_2xQo.js} +1 -1
  183. package/app/dist/assets/bottom-anchored-scroll-body-izL_2xQo.js.br +0 -0
  184. package/app/dist/assets/bottom-anchored-scroll-body-izL_2xQo.js.gz +0 -0
  185. package/app/dist/assets/{browser-url-jhAVtSw2.js → browser-url-DQsPFWqd.js} +1 -1
  186. package/app/dist/assets/browser-url-DQsPFWqd.js.br +0 -0
  187. package/app/dist/assets/browser-url-DQsPFWqd.js.gz +0 -0
  188. package/app/dist/assets/{checkbox-qaQbU8-H.js → checkbox-Dxs9oAMl.js} +1 -1
  189. package/app/dist/assets/checkbox-Dxs9oAMl.js.br +0 -0
  190. package/app/dist/assets/checkbox-Dxs9oAMl.js.gz +0 -0
  191. package/app/dist/assets/{code-loading-skeletons-pfQDO26Y.js → code-loading-skeletons-CkiXPS0M.js} +1 -1
  192. package/app/dist/assets/code-loading-skeletons-CkiXPS0M.js.br +0 -0
  193. package/app/dist/assets/code-loading-skeletons-CkiXPS0M.js.gz +0 -0
  194. package/app/dist/assets/{code-rendering-CuFk1qJ1.js → code-rendering-DjLdb6cB.js} +1 -1
  195. package/app/dist/assets/{code-theme-registration-wCS4GRn4.js → code-theme-registration-DWaGQiqG.js} +1 -1
  196. package/app/dist/assets/{detail-card-C3OH86kJ.js → detail-card-BFm1NEQz.js} +1 -1
  197. package/app/dist/assets/detail-card-BFm1NEQz.js.br +0 -0
  198. package/app/dist/assets/detail-card-BFm1NEQz.js.gz +0 -0
  199. package/app/dist/assets/{diff-stats-tally-DkIHmiEl.js → diff-stats-tally-DQHS3tHN.js} +1 -1
  200. package/app/dist/assets/diff-stats-tally-DQHS3tHN.js.br +0 -0
  201. package/app/dist/assets/diff-stats-tally-DQHS3tHN.js.gz +0 -0
  202. package/app/dist/assets/{dist-CWXlD45B.js → dist-DCULoGTS.js} +1 -1
  203. package/app/dist/assets/dist-DCULoGTS.js.br +0 -0
  204. package/app/dist/assets/dist-DCULoGTS.js.gz +0 -0
  205. package/app/dist/assets/{environment-mutations-BrA6u8Ev.js → environment-mutations-Zes88JN-.js} +1 -1
  206. package/app/dist/assets/environment-mutations-Zes88JN-.js.br +0 -0
  207. package/app/dist/assets/environment-mutations-Zes88JN-.js.gz +0 -0
  208. package/app/dist/assets/{environment-workspace-display-0oqBMXMB.js → environment-workspace-display-Blt7U9Mn.js} +3 -3
  209. package/app/dist/assets/environment-workspace-display-Blt7U9Mn.js.br +0 -0
  210. package/app/dist/assets/environment-workspace-display-Blt7U9Mn.js.gz +0 -0
  211. package/app/dist/assets/{event-code-block-BfPSBXNn.js → event-code-block-QXnzoFqm.js} +1 -1
  212. package/app/dist/assets/event-code-block-QXnzoFqm.js.br +0 -0
  213. package/app/dist/assets/event-code-block-QXnzoFqm.js.gz +0 -0
  214. package/app/dist/assets/{expandable-text-01SvfXRm.js → expandable-text-DkUA9RQT.js} +1 -1
  215. package/app/dist/assets/expandable-text-DkUA9RQT.js.br +0 -0
  216. package/app/dist/assets/expandable-text-DkUA9RQT.js.gz +0 -0
  217. package/app/dist/assets/{file-opener-preference-C5_P-Zfr.js → file-opener-preference-CXZHmESv.js} +1 -1
  218. package/app/dist/assets/{file-path-link-Ddg7Fzor.js → file-path-link-D7DFjBWZ.js} +1 -1
  219. package/app/dist/assets/file-path-link-D7DFjBWZ.js.br +0 -0
  220. package/app/dist/assets/file-path-link-D7DFjBWZ.js.gz +0 -0
  221. package/app/dist/assets/{host-mutations-CAtir6jv.js → host-mutations-Fl0RjER0.js} +1 -1
  222. package/app/dist/assets/host-mutations-Fl0RjER0.js.br +0 -0
  223. package/app/dist/assets/host-mutations-Fl0RjER0.js.gz +0 -0
  224. package/app/dist/assets/{icon-extended-D2fR2GTF.js → icon-extended-C0LTNXfN.js} +1 -1
  225. package/app/dist/assets/icon-extended-C0LTNXfN.js.br +0 -0
  226. package/app/dist/assets/icon-extended-C0LTNXfN.js.gz +0 -0
  227. package/app/dist/assets/{image-lightbox-Dhmri6WK.js → image-lightbox-DhNslR-8.js} +1 -1
  228. package/app/dist/assets/image-lightbox-DhNslR-8.js.br +0 -0
  229. package/app/dist/assets/image-lightbox-DhNslR-8.js.gz +0 -0
  230. package/app/dist/assets/index-C2K528W0.css +2 -0
  231. package/app/dist/assets/index-C2K528W0.css.br +0 -0
  232. package/app/dist/assets/index-C2K528W0.css.gz +0 -0
  233. package/app/dist/assets/{index-CfvM6UcU.js → index-DCps_qBD.js} +8 -8
  234. package/app/dist/assets/index-DCps_qBD.js.br +0 -0
  235. package/app/dist/assets/index-DCps_qBD.js.gz +0 -0
  236. package/app/dist/assets/{inline-rename-editor-Bg8SXoZ3.js → inline-rename-editor-nrH2d_Gy.js} +1 -1
  237. package/app/dist/assets/inline-rename-editor-nrH2d_Gy.js.br +0 -0
  238. package/app/dist/assets/inline-rename-editor-nrH2d_Gy.js.gz +0 -0
  239. package/app/dist/assets/{launcherRow-CqPaUYWn.js → launcherRow-CVYGyeOl.js} +1 -1
  240. package/app/dist/assets/launcherRow-CVYGyeOl.js.br +0 -0
  241. package/app/dist/assets/launcherRow-CVYGyeOl.js.gz +0 -0
  242. package/app/dist/assets/{localhost-link-rewrite-description-DP-bXSL8.js → localhost-link-rewrite-description-C0FphFZq.js} +1 -1
  243. package/app/dist/assets/localhost-link-rewrite-description-C0FphFZq.js.br +0 -0
  244. package/app/dist/assets/localhost-link-rewrite-description-C0FphFZq.js.gz +0 -0
  245. package/app/dist/assets/{machine-provider-queries-CoghZyj9.js → machine-provider-queries-BTz8Sz3J.js} +1 -1
  246. package/app/dist/assets/{machine-server-access-Drk0mdHH.js → machine-server-access-CGfd5e1r.js} +1 -1
  247. package/app/dist/assets/{markdown-file-image-routing-BJjI1Te3.js → markdown-file-image-routing-BhGjphhz.js} +1 -1
  248. package/app/dist/assets/{markdown-html-BU8qsXmq.js → markdown-html-CLi3FhDR.js} +1 -1
  249. package/app/dist/assets/markdown-html-CLi3FhDR.js.br +0 -0
  250. package/app/dist/assets/markdown-html-CLi3FhDR.js.gz +0 -0
  251. package/app/dist/assets/{markdown-local-file-link-D-MSnVWD.js → markdown-local-file-link-BROpdQPF.js} +1 -1
  252. package/app/dist/assets/markdown-local-file-link-BROpdQPF.js.br +0 -0
  253. package/app/dist/assets/markdown-local-file-link-BROpdQPF.js.gz +0 -0
  254. package/app/dist/assets/{markdown-preview-BLL1QuNp.js → markdown-preview-CGXXNhJo.js} +3 -3
  255. package/app/dist/assets/markdown-preview-CGXXNhJo.js.br +0 -0
  256. package/app/dist/assets/markdown-preview-CGXXNhJo.js.gz +0 -0
  257. package/app/dist/assets/{markdown-prompt-mentions-B5LVmCbO.js → markdown-prompt-mentions-CPWKCtMa.js} +1 -1
  258. package/app/dist/assets/markdown-prompt-mentions-CPWKCtMa.js.br +0 -0
  259. package/app/dist/assets/markdown-prompt-mentions-CPWKCtMa.js.gz +0 -0
  260. package/app/dist/assets/{model-load-error-message-Dmp1hUNg.js → model-load-error-message-CH_k4E7q.js} +1 -1
  261. package/app/dist/assets/model-load-error-message-CH_k4E7q.js.br +0 -0
  262. package/app/dist/assets/model-load-error-message-CH_k4E7q.js.gz +0 -0
  263. package/app/dist/assets/onboarding-telemetry-BXIyQ5F4.js +1 -0
  264. package/app/dist/assets/{open-in-editor-button-D0wnpT6x.js → open-in-editor-button-tA10Nkqn.js} +1 -1
  265. package/app/dist/assets/open-in-editor-button-tA10Nkqn.js.br +0 -0
  266. package/app/dist/assets/open-in-editor-button-tA10Nkqn.js.gz +0 -0
  267. package/app/dist/assets/{page-shell-CgSxnF9m.js → page-shell-CNCVT3Uj.js} +1 -1
  268. package/app/dist/assets/page-shell-CNCVT3Uj.js.br +0 -0
  269. package/app/dist/assets/page-shell-CNCVT3Uj.js.gz +0 -0
  270. package/app/dist/assets/{pierre-worker-pool-CHGWu76e.js → pierre-worker-pool-pXJFsMd7.js} +1 -1
  271. package/app/dist/assets/pierre-worker-pool-pXJFsMd7.js.br +0 -0
  272. package/app/dist/assets/pierre-worker-pool-pXJFsMd7.js.gz +0 -0
  273. package/app/dist/assets/{plugin-detail-navigation-DuR8_JCx.js → plugin-detail-navigation-SAqiVR3K.js} +1 -1
  274. package/app/dist/assets/plugin-detail-navigation-SAqiVR3K.js.br +0 -0
  275. package/app/dist/assets/plugin-detail-navigation-SAqiVR3K.js.gz +0 -0
  276. package/app/dist/assets/{plugin-frontend-D5ijLuKC.js → plugin-frontend-DoWZV45B.js} +3 -3
  277. package/app/dist/assets/plugin-frontend-DoWZV45B.js.br +0 -0
  278. package/app/dist/assets/plugin-frontend-DoWZV45B.js.gz +0 -0
  279. package/app/dist/assets/{plugin-ui-Dpa8hcuk.js → plugin-ui-Cu8MrXLJ.js} +1 -1
  280. package/app/dist/assets/plugin-ui-Cu8MrXLJ.js.br +0 -0
  281. package/app/dist/assets/plugin-ui-Cu8MrXLJ.js.gz +0 -0
  282. package/app/dist/assets/{project-default-execution-options-query-DfOIRKKL.js → project-default-execution-options-query-gaQEWNK0.js} +1 -1
  283. package/app/dist/assets/{queued-editor-typeahead-layout-Czaq8Cl9.js → queued-editor-typeahead-layout-DTUSPVuA.js} +1 -1
  284. package/app/dist/assets/queued-editor-typeahead-layout-DTUSPVuA.js.br +0 -0
  285. package/app/dist/assets/queued-editor-typeahead-layout-DTUSPVuA.js.gz +0 -0
  286. package/app/dist/assets/{queued-messages-layout-B5xwiued.js → queued-messages-layout-Bj1foecI.js} +1 -1
  287. package/app/dist/assets/queued-messages-layout-Bj1foecI.js.br +0 -0
  288. package/app/dist/assets/queued-messages-layout-Bj1foecI.js.gz +0 -0
  289. package/app/dist/assets/{resource-list-BKpxiO2e.js → resource-list-DLZLjUCf.js} +1 -1
  290. package/app/dist/assets/resource-list-DLZLjUCf.js.br +0 -0
  291. package/app/dist/assets/resource-list-DLZLjUCf.js.gz +0 -0
  292. package/app/dist/assets/root-compose-create-preference-Bv_dFEsH.js +1 -0
  293. package/app/dist/assets/{save-file-CNFl2iiR.js → save-file-B8sl9wgP.js} +1 -1
  294. package/app/dist/assets/{settings-nav-C9-jh_HN.js → settings-nav-D5tWYG52.js} +1 -1
  295. package/app/dist/assets/settings-nav-D5tWYG52.js.br +0 -0
  296. package/app/dist/assets/settings-nav-D5tWYG52.js.gz +0 -0
  297. package/app/dist/assets/{settings-sections-BMr_XU5l.js → settings-sections-Dfo35J2q.js} +1 -1
  298. package/app/dist/assets/settings-sections-Dfo35J2q.js.br +0 -0
  299. package/app/dist/assets/settings-sections-Dfo35J2q.js.gz +0 -0
  300. package/app/dist/assets/{shortcut-pill-_XSUZHxZ.js → shortcut-pill-BMlNncTw.js} +1 -1
  301. package/app/dist/assets/{sidebarTouchSensor-DG_A1RmT.js → sidebarTouchSensor-Da_E8eSx.js} +1 -1
  302. package/app/dist/assets/sidebarTouchSensor-Da_E8eSx.js.br +0 -0
  303. package/app/dist/assets/sidebarTouchSensor-Da_E8eSx.js.gz +0 -0
  304. package/app/dist/assets/{switch-BjJ8825r.js → switch-BRYzbFH-.js} +1 -1
  305. package/app/dist/assets/switch-BRYzbFH-.js.br +0 -0
  306. package/app/dist/assets/switch-BRYzbFH-.js.gz +0 -0
  307. package/app/dist/assets/{textarea-DY_k-BJR.js → textarea-DpRLVuDl.js} +1 -1
  308. package/app/dist/assets/{thread-event-parser-ma5CGP66.js → thread-event-parser-BrLyjs4v.js} +1 -1
  309. package/app/dist/assets/thread-event-parser-BrLyjs4v.js.br +0 -0
  310. package/app/dist/assets/thread-event-parser-BrLyjs4v.js.gz +0 -0
  311. package/app/dist/assets/{thread-panel-queries-BXeOzk_6.js → thread-panel-queries-s8vzntf7.js} +1 -1
  312. package/app/dist/assets/thread-panel-queries-s8vzntf7.js.br +0 -0
  313. package/app/dist/assets/thread-panel-queries-s8vzntf7.js.gz +0 -0
  314. package/app/dist/assets/{thread-runtime-mutations-DmKkyel0.js → thread-runtime-mutations-BOdkZ-H-.js} +1 -1
  315. package/app/dist/assets/thread-runtime-mutations-BOdkZ-H-.js.br +0 -0
  316. package/app/dist/assets/thread-runtime-mutations-BOdkZ-H-.js.gz +0 -0
  317. package/app/dist/assets/{thread-terminal-queries-AFVZ5K6p.js → thread-terminal-queries-Blou76c_.js} +1 -1
  318. package/app/dist/assets/thread-terminal-queries-Blou76c_.js.br +0 -0
  319. package/app/dist/assets/thread-terminal-queries-Blou76c_.js.gz +0 -0
  320. package/app/dist/assets/{threadRecentItems-DXsdcpBk.js → threadRecentItems-BiCe3SkL.js} +1 -1
  321. package/app/dist/assets/threadRecentItems-BiCe3SkL.js.br +0 -0
  322. package/app/dist/assets/threadRecentItems-BiCe3SkL.js.gz +0 -0
  323. package/app/dist/assets/{threadWorkspaceOpenPath-DwKd-s_5.js → threadWorkspaceOpenPath-C9eC_XGN.js} +1 -1
  324. package/app/dist/assets/threadWorkspaceOpenPath-C9eC_XGN.js.br +0 -0
  325. package/app/dist/assets/threadWorkspaceOpenPath-C9eC_XGN.js.gz +0 -0
  326. package/app/dist/assets/{title-bar-scroll-fade-Dw_BPLyx.js → title-bar-scroll-fade-OrK4M84v.js} +1 -1
  327. package/app/dist/assets/title-bar-scroll-fade-OrK4M84v.js.br +0 -0
  328. package/app/dist/assets/title-bar-scroll-fade-OrK4M84v.js.gz +0 -0
  329. package/app/dist/assets/{truncate-start-CGyRoGtG.js → truncate-start-Ck1IPV62.js} +1 -1
  330. package/app/dist/assets/{use-hover-popover-DzrAfLzd.js → use-hover-popover-uokpMJ80.js} +1 -1
  331. package/app/dist/assets/use-hover-popover-uokpMJ80.js.br +0 -0
  332. package/app/dist/assets/use-hover-popover-uokpMJ80.js.gz +0 -0
  333. package/app/dist/assets/{useElementWidth-Kv5FX-9C.js → useElementWidth-EbzKQ0bg.js} +1 -1
  334. package/app/dist/assets/useElementWidth-EbzKQ0bg.js.br +0 -0
  335. package/app/dist/assets/useElementWidth-EbzKQ0bg.js.gz +0 -0
  336. package/app/dist/assets/{useLocalOpenTargets-B7rqz64L.js → useLocalOpenTargets-CtvcdlZg.js} +1 -1
  337. package/app/dist/assets/useLocalOpenTargets-CtvcdlZg.js.br +0 -0
  338. package/app/dist/assets/useLocalOpenTargets-CtvcdlZg.js.gz +0 -0
  339. package/app/dist/assets/{usePanelResizeSnap-Dizp45Ab.js → usePanelResizeSnap-CuwA4rg3.js} +1 -1
  340. package/app/dist/assets/usePanelResizeSnap-CuwA4rg3.js.br +0 -0
  341. package/app/dist/assets/usePanelResizeSnap-CuwA4rg3.js.gz +0 -0
  342. package/app/dist/assets/{usePanelTerminals-ByzphxXd.js → usePanelTerminals-BZhTVWNX.js} +1 -1
  343. package/app/dist/assets/usePanelTerminals-BZhTVWNX.js.br +0 -0
  344. package/app/dist/assets/usePanelTerminals-BZhTVWNX.js.gz +0 -0
  345. package/app/dist/assets/{usePathSuggestions-Bd5UhdCh.js → usePathSuggestions-DZ1XPM_t.js} +1 -1
  346. package/app/dist/assets/usePathSuggestions-DZ1XPM_t.js.br +0 -0
  347. package/app/dist/assets/usePathSuggestions-DZ1XPM_t.js.gz +0 -0
  348. package/app/dist/assets/{useResolvedLiveFileTarget-x5Gd-Gzx.js → useResolvedLiveFileTarget-DlZUgf7A.js} +1 -1
  349. package/app/dist/assets/useResolvedLiveFileTarget-DlZUgf7A.js.br +0 -0
  350. package/app/dist/assets/useResolvedLiveFileTarget-DlZUgf7A.js.gz +0 -0
  351. package/app/dist/assets/{useThreadTerminalController-CUnfO0Da.js → useThreadTerminalController-D4Cr2aY0.js} +1 -1
  352. package/app/dist/assets/useThreadTerminalController-D4Cr2aY0.js.br +0 -0
  353. package/app/dist/assets/useThreadTerminalController-D4Cr2aY0.js.gz +0 -0
  354. package/app/dist/assets/{workspace-change-summary-CLNpSq_E.js → workspace-change-summary-C1EKX0Np.js} +1 -1
  355. package/app/dist/assets/workspace-change-summary-C1EKX0Np.js.br +0 -0
  356. package/app/dist/assets/workspace-change-summary-C1EKX0Np.js.gz +0 -0
  357. package/app/dist/assets/{workspace-checkout-display-Aad1Wxi4.js → workspace-checkout-display-DRAc3j4u.js} +4 -4
  358. package/app/dist/assets/workspace-checkout-display-DRAc3j4u.js.br +0 -0
  359. package/app/dist/assets/workspace-checkout-display-DRAc3j4u.js.gz +0 -0
  360. package/app/dist/index.html +17 -17
  361. package/app/dist/index.html.br +0 -0
  362. package/app/dist/index.html.gz +0 -0
  363. package/dist/bb-app.js +1 -1
  364. package/dist/index.d.ts +64 -64
  365. package/dist/index.js +39 -34
  366. package/host-daemon/dist/bb +2 -2
  367. package/host-daemon/dist/daemon-bundle.mjs +9 -9
  368. package/host-daemon/dist/moonlet +2 -2
  369. package/host-daemon/dist/moonlet-chunks/{browser-LWDG5PCA.js → browser-3YADF5CZ.js} +1 -1
  370. package/host-daemon/dist/moonlet-chunks/{chunk-4BNITW7L.js → chunk-CJVCV7LA.js} +1 -1
  371. package/host-daemon/dist/moonlet-chunks/{chunk-5AOUW4I4.js → chunk-DYWN65E6.js} +1 -1
  372. package/host-daemon/dist/moonlet-chunks/{chunk-GUMXNH56.js → chunk-GJNT53PW.js} +1 -1
  373. package/host-daemon/dist/moonlet-chunks/chunk-MNJOOMMT.js +2 -0
  374. package/host-daemon/dist/moonlet-chunks/{chunk-2QTAZF4P.js → chunk-OZFHGPH4.js} +2 -2
  375. package/host-daemon/dist/moonlet-chunks/{chunk-OW2VWWPF.js → chunk-UASCWFYV.js} +1 -1
  376. package/host-daemon/dist/moonlet-chunks/{chunk-3GDA5QRC.js → chunk-UBCGVKZ2.js} +1 -1
  377. package/host-daemon/dist/moonlet-chunks/{chunk-ZJ3M74CR.js → chunk-UZIJUXRX.js} +1 -1
  378. package/host-daemon/dist/moonlet-chunks/{chunk-I2TDLRZL.js → chunk-VRIDG567.js} +80 -80
  379. package/host-daemon/dist/moonlet-chunks/{chunk-LQ55GYT2.js → chunk-Z7UFAOBI.js} +1 -1
  380. package/host-daemon/dist/moonlet-chunks/{chunk-IRGDLZXQ.js → chunk-ZY4JRPPT.js} +1 -1
  381. package/host-daemon/dist/moonlet-chunks/{client-LVL2RUQ5.js → client-HJ57QVLD.js} +1 -1
  382. package/host-daemon/dist/moonlet-chunks/{commander-errors-RQKAT5HQ.js → commander-errors-VI7J6RNT.js} +1 -1
  383. package/host-daemon/dist/moonlet-chunks/{context-env-74PECPQU.js → context-env-C4YEBBVX.js} +1 -1
  384. package/host-daemon/dist/moonlet-chunks/{context-hints-GQMM7IUB.js → context-hints-FZ224BCX.js} +1 -1
  385. package/host-daemon/dist/moonlet-chunks/{diagnostics-GZNLDKFH.js → diagnostics-OU2KW3CN.js} +1 -1
  386. package/host-daemon/dist/moonlet-chunks/{environment-2OF5OYK6.js → environment-45XH2PJT.js} +1 -1
  387. package/host-daemon/dist/moonlet-chunks/{file-ICBUEP7H.js → file-OHC2H5AH.js} +1 -1
  388. package/host-daemon/dist/moonlet-chunks/{guide-I3LO3KWD.js → guide-T2HEZTCZ.js} +1 -1
  389. package/host-daemon/dist/moonlet-chunks/{machine-ZH4VN36Y.js → machine-7DB7FE7G.js} +1 -1
  390. package/host-daemon/dist/moonlet-chunks/{marketplace-72G2CIZT.js → marketplace-GSP2IPGS.js} +1 -1
  391. package/host-daemon/dist/moonlet-chunks/{permissions-ZKMW6XVA.js → permissions-SOZPETLR.js} +1 -1
  392. package/host-daemon/dist/moonlet-chunks/{plugin-J33MYYP6.js → plugin-672NQWPG.js} +26 -26
  393. package/host-daemon/dist/moonlet-chunks/{plugin-cli-proxy-KK4YO745.js → plugin-cli-proxy-YK6LMDCS.js} +1 -1
  394. package/host-daemon/dist/moonlet-chunks/{project-CAOBT6PT.js → project-KMNJH6RG.js} +1 -1
  395. package/host-daemon/dist/moonlet-chunks/{prompt-history-3CTG22DW.js → prompt-history-H3Y2IHDY.js} +1 -1
  396. package/host-daemon/dist/moonlet-chunks/{provider-T7SNTFH5.js → provider-EKKSYF2D.js} +1 -1
  397. package/host-daemon/dist/moonlet-chunks/{schedule-2G2I4DCW.js → schedule-KVSISSIR.js} +1 -1
  398. package/host-daemon/dist/moonlet-chunks/{server-R3LHIEJF.js → server-53I6IGAP.js} +2 -2
  399. package/host-daemon/dist/moonlet-chunks/{settings-WR7UCFPE.js → settings-MKGSGNIO.js} +1 -1
  400. package/host-daemon/dist/moonlet-chunks/{skill-GHMBJF4G.js → skill-DXINIPQ3.js} +1 -1
  401. package/host-daemon/dist/moonlet-chunks/{status-ES5SEMUE.js → status-BSMUYEAO.js} +1 -1
  402. package/host-daemon/dist/moonlet-chunks/{terminal-45KOGD2U.js → terminal-VKBGZFLN.js} +1 -1
  403. package/host-daemon/dist/moonlet-chunks/{theme-DEIR5VHK.js → theme-3YCCZBGC.js} +1 -1
  404. package/host-daemon/dist/moonlet-chunks/{thread-NNUIM6R7.js → thread-PFBPLD4F.js} +1 -1
  405. package/host-daemon/dist/moonlet-chunks/{updates-23J52P44.js → updates-OO7GE7UB.js} +1 -1
  406. package/host-daemon/dist/moonlet-chunks/{voice-CSQR656B.js → voice-ZJOSAJW7.js} +1 -1
  407. package/package.json +3 -3
  408. package/server/dist/builtin-plugins/account-pool/dist/app.js +9 -9
  409. package/server/dist/builtin-plugins/account-pool/skills/account-pool/SKILL.md +1 -1
  410. package/server/dist/builtin-plugins/agent-annotations/dist/app.js +2 -2
  411. package/server/dist/builtin-plugins/agent-board/dist/THIRD_PARTY_NOTICES.md +3 -3
  412. package/server/dist/builtin-plugins/agent-board/dist/app.js +6 -6
  413. package/server/dist/builtin-plugins/agent-board/dist/server.js +1 -1
  414. package/server/dist/builtin-plugins/ask-user-question/dist/app.js +6 -6
  415. package/server/dist/builtin-plugins/automations/dist/app.js +1 -1
  416. package/server/dist/builtin-plugins/automations/skills/automations/SKILL.md +1 -1
  417. package/server/dist/builtin-plugins/bb-account/dist/app.js +1 -1
  418. package/server/dist/builtin-plugins/bb-account/skills/bb-account/SKILL.md +1 -1
  419. package/server/dist/builtin-plugins/bb-ai/dist/server.js +2 -2
  420. package/server/dist/builtin-plugins/bb-ai/skills/bb-cloud-ai/SKILL.md +1 -1
  421. package/server/dist/builtin-plugins/bb-guide/dist/app.js +1 -1
  422. package/server/dist/builtin-plugins/bb-guide/dist/server.js +2 -2
  423. package/server/dist/builtin-plugins/bb-guide/package.json +2 -2
  424. package/server/dist/builtin-plugins/bb-guide/skills/bb-cli/SKILL.md +3 -3
  425. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/SKILL.md +4 -4
  426. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/backend-cli-agents.md +6 -6
  427. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/backend-events.md +2 -2
  428. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/backend-foundation.md +1 -1
  429. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/backend-sdk.md +1 -1
  430. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/distribution.md +2 -2
  431. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/frontend-components.md +4 -4
  432. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/frontend-core-slots.md +15 -15
  433. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/frontend-hooks-and-ui.md +9 -9
  434. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/providers.md +3 -3
  435. package/server/dist/builtin-plugins/bb-guide/skills/bb-plugin-authoring/references/quickstart.md +10 -10
  436. package/server/dist/builtin-plugins/bb-guide/skills/skill-creator/SKILL.md +2 -2
  437. package/server/dist/builtin-plugins/bb-guide/skills/submit-a-plugin/SKILL.md +3 -3
  438. package/server/dist/builtin-plugins/bb-guide/skills/submit-a-plugin/references/marketplace-entry.md +8 -8
  439. package/server/dist/builtin-plugins/bb-guide/skills/submit-a-plugin/references/plugin-release.md +1 -1
  440. package/server/dist/builtin-plugins/browser-automation/dist/app.js +1 -1
  441. package/server/dist/builtin-plugins/browser-automation/dist/server.js +2 -2
  442. package/server/dist/builtin-plugins/browser-automation/skills/browser-automation/SKILL.md +3 -3
  443. package/server/dist/builtin-plugins/composer/dist/app.js +4 -4
  444. package/server/dist/builtin-plugins/concurrency-limit/dist/app.js +1 -1
  445. package/server/dist/builtin-plugins/concurrency-limit/skills/concurrency-limit/SKILL.md +1 -1
  446. package/server/dist/builtin-plugins/connect/dist/app.js +2 -2
  447. package/server/dist/builtin-plugins/connect/skills/share-server-links/SKILL.md +1 -1
  448. package/server/dist/builtin-plugins/connect-next/dist/app.js +2 -2
  449. package/server/dist/builtin-plugins/connect-next/dist/server.js +1 -1
  450. package/server/dist/builtin-plugins/connect-next/skills/connect-next/SKILL.md +1 -1
  451. package/server/dist/builtin-plugins/custom-instructions/dist/app.js +1 -1
  452. package/server/dist/builtin-plugins/docs/dist/app.js +3 -3
  453. package/server/dist/builtin-plugins/docs/skills/docs/SKILL.md +1 -1
  454. package/server/dist/builtin-plugins/drafts/dist/app.js +1 -1
  455. package/server/dist/builtin-plugins/environment-git-worktree/dist/app.js +1 -1
  456. package/server/dist/builtin-plugins/environment-modal-sandbox/dist/app.js +1 -1
  457. package/server/dist/builtin-plugins/environment-modal-sandbox/dist/server.js +1 -1
  458. package/server/dist/builtin-plugins/environment-modal-sandbox/skills/modal-sandboxes/SKILL.md +5 -5
  459. package/server/dist/builtin-plugins/environment-project-checkout/dist/app.js +1 -1
  460. package/server/dist/builtin-plugins/github/dist/app.js +2 -2
  461. package/server/dist/builtin-plugins/github/dist/server.js +7 -7
  462. package/server/dist/builtin-plugins/github/package.json +2 -2
  463. package/server/dist/builtin-plugins/github/skills/github-change/SKILL.md +2 -2
  464. package/server/dist/builtin-plugins/github/skills/github-change/references/merging.md +8 -8
  465. package/server/dist/builtin-plugins/github-pr-status/dist/app.js +6 -6
  466. package/server/dist/builtin-plugins/inline-vis/dist/app.js +2 -2
  467. package/server/dist/builtin-plugins/inline-vis/skills/inline-vis/SKILL.md +2 -2
  468. package/server/dist/builtin-plugins/keep-awake/dist/app.js +1 -1
  469. package/server/dist/builtin-plugins/keep-awake/dist/server.js +1 -1
  470. package/server/dist/builtin-plugins/library/dist/app.js +2 -2
  471. package/server/dist/builtin-plugins/mail/skills/mail/SKILL.md +1 -1
  472. package/server/dist/builtin-plugins/marketplace.json +10 -10
  473. package/server/dist/builtin-plugins/mcp/dist/server.js +8 -8
  474. package/server/dist/builtin-plugins/mcp/skills/mcp/SKILL.md +1 -1
  475. package/server/dist/builtin-plugins/memory/dist/app.js +1 -1
  476. package/server/dist/builtin-plugins/memory/dist/server.js +4 -4
  477. package/server/dist/builtin-plugins/memory/skills/memory/SKILL.md +5 -5
  478. package/server/dist/builtin-plugins/monaco-editor/dist/app.js +1 -1
  479. package/server/dist/builtin-plugins/navigation/dist/app.js +1 -1
  480. package/server/dist/builtin-plugins/notify-feed/dist/app.js +3 -3
  481. package/server/dist/builtin-plugins/notify-feed/dist/server.js +2 -2
  482. package/server/dist/builtin-plugins/orbit/dist/app.js +2 -2
  483. package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/docs/handoff-to-new-conversation.md +1 -1
  484. package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/fixed-runner/linux-x64/manifest.json +4 -4
  485. package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/revision +1 -1
  486. package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/source.json +1 -1
  487. package/server/dist/builtin-plugins/orbit/dist/assets/plugins/moonlet/back/CLAUDE.md +5 -5
  488. package/server/dist/builtin-plugins/orbit/dist/assets/plugins/moonlet/front/CLAUDE.md +15 -15
  489. package/server/dist/builtin-plugins/orbit/dist/host.js +49 -49
  490. package/server/dist/builtin-plugins/orbit/dist/host.meta.json +1 -1
  491. package/server/dist/builtin-plugins/orbit/dist/server.js +148 -148
  492. package/server/dist/builtin-plugins/pdf-preview/dist/app.js +1 -1
  493. package/server/dist/builtin-plugins/plugin-api-docs/dist/app.js +2 -2
  494. package/server/dist/builtin-plugins/plugin-api-tester/dist/app.js +1 -1
  495. package/server/dist/builtin-plugins/prompt-library/dist/app.js +2 -2
  496. package/server/dist/builtin-plugins/prompt-library/skills/prompt-library/SKILL.md +1 -1
  497. package/server/dist/builtin-plugins/provider-acp/dist/app.js +1 -1
  498. package/server/dist/builtin-plugins/provider-acp/dist/host.js +5 -5
  499. package/server/dist/builtin-plugins/provider-acp/dist/host.meta.json +1 -1
  500. package/server/dist/builtin-plugins/provider-acp/dist/server.js +97 -97
  501. package/server/dist/builtin-plugins/provider-acp/skills/acp-provider/SKILL.md +9 -9
  502. package/server/dist/builtin-plugins/provider-claude-code/dist/app.js +1 -1
  503. package/server/dist/builtin-plugins/provider-claude-code/dist/host.js +3 -3
  504. package/server/dist/builtin-plugins/provider-claude-code/dist/host.meta.json +1 -1
  505. package/server/dist/builtin-plugins/provider-claude-code/dist/server.js +1 -1
  506. package/server/dist/builtin-plugins/provider-codex/dist/app.js +2 -2
  507. package/server/dist/builtin-plugins/provider-codex/dist/host.js +45 -45
  508. package/server/dist/builtin-plugins/provider-codex/dist/host.meta.json +1 -1
  509. package/server/dist/builtin-plugins/provider-codex/dist/server.js +1 -1
  510. package/server/dist/builtin-plugins/provider-pi/dist/app.js +1 -1
  511. package/server/dist/builtin-plugins/provider-pi/skills/pi-provider/SKILL.md +1 -1
  512. package/server/dist/builtin-plugins/provider-retry/dist/app.js +1 -1
  513. package/server/dist/builtin-plugins/provider-retry/skills/provider-retry/SKILL.md +1 -1
  514. package/server/dist/builtin-plugins/provider-usage/dist/app.js +12 -12
  515. package/server/dist/builtin-plugins/push-notifications/dist/app.js +2 -2
  516. package/server/dist/builtin-plugins/push-notifications/skills/push-notifications/SKILL.md +1 -1
  517. package/server/dist/builtin-plugins/scheduled-send/dist/app.js +1 -1
  518. package/server/dist/builtin-plugins/secrets/dist/app.js +1 -1
  519. package/server/dist/builtin-plugins/side-chat/dist/app.js +1 -1
  520. package/server/dist/builtin-plugins/storage-retention/dist/app.js +1 -1
  521. package/server/dist/builtin-plugins/storage-retention/dist/server.js +2 -2
  522. package/server/dist/builtin-plugins/storage-retention/skills/storage-retention/SKILL.md +5 -5
  523. package/server/dist/builtin-plugins/tasks/dist/app.js +4 -4
  524. package/server/dist/builtin-plugins/tasks/skills/tasks/SKILL.md +1 -1
  525. package/server/dist/builtin-plugins/theme-preview/dist/app.js +2 -2
  526. package/server/dist/builtin-plugins/theme-preview/skills/bb-theme-authoring/SKILL.md +1 -1
  527. package/server/dist/builtin-plugins/thread-list/dist/app.js +2 -2
  528. package/server/dist/builtin-plugins/thread-list/dist/server.js +2 -2
  529. package/server/dist/builtin-plugins/workflows/dist/app.js +1 -1
  530. package/server/dist/builtin-plugins/workflows/dist/server.js +4 -4
  531. package/server/dist/builtin-plugins/workflows/skills/workflows/SKILL.md +4 -4
  532. package/server/dist/builtin-plugins/workflows/skills/workflows/references/authoring.md +7 -7
  533. package/server/dist/builtin-skills/bb-cli/SKILL.md +3 -3
  534. package/server/dist/builtin-skills/bb-plugin-authoring/SKILL.md +4 -4
  535. package/server/dist/builtin-skills/bb-plugin-authoring/references/backend-cli-agents.md +6 -6
  536. package/server/dist/builtin-skills/bb-plugin-authoring/references/backend-events.md +2 -2
  537. package/server/dist/builtin-skills/bb-plugin-authoring/references/backend-foundation.md +1 -1
  538. package/server/dist/builtin-skills/bb-plugin-authoring/references/backend-sdk.md +1 -1
  539. package/server/dist/builtin-skills/bb-plugin-authoring/references/distribution.md +2 -2
  540. package/server/dist/builtin-skills/bb-plugin-authoring/references/frontend-components.md +4 -4
  541. package/server/dist/builtin-skills/bb-plugin-authoring/references/frontend-core-slots.md +15 -15
  542. package/server/dist/builtin-skills/bb-plugin-authoring/references/frontend-hooks-and-ui.md +9 -9
  543. package/server/dist/builtin-skills/bb-plugin-authoring/references/providers.md +3 -3
  544. package/server/dist/builtin-skills/bb-plugin-authoring/references/quickstart.md +10 -10
  545. package/server/dist/builtin-skills/skill-creator/SKILL.md +2 -2
  546. package/server/dist/builtin-skills/submit-a-plugin/SKILL.md +3 -3
  547. package/server/dist/builtin-skills/submit-a-plugin/references/marketplace-entry.md +8 -8
  548. package/server/dist/builtin-skills/submit-a-plugin/references/plugin-release.md +1 -1
  549. package/server/dist/start-server.js +75 -70
  550. package/app/dist/assets/AddMachineDialog-BHF-GkBG.js.br +0 -0
  551. package/app/dist/assets/AddMachineDialog-BHF-GkBG.js.gz +0 -0
  552. package/app/dist/assets/AppFileExternalNavigationDispatcher-BNbJsP1g.js.br +0 -0
  553. package/app/dist/assets/AppFileExternalNavigationDispatcher-BNbJsP1g.js.gz +0 -0
  554. package/app/dist/assets/BrowserTabDeck-BlOoU-vR.js.br +0 -0
  555. package/app/dist/assets/BrowserTabDeck-BlOoU-vR.js.gz +0 -0
  556. package/app/dist/assets/CommandPaletteBody-CBbTgLrW.js.br +0 -0
  557. package/app/dist/assets/CommandPaletteBody-CBbTgLrW.js.gz +0 -0
  558. package/app/dist/assets/DiffHost-DYBSO1_c.js.br +0 -0
  559. package/app/dist/assets/DiffHost-DYBSO1_c.js.gz +0 -0
  560. package/app/dist/assets/ExperimentalFileLinkMenu-DO2lGQoK.js.br +0 -0
  561. package/app/dist/assets/ExperimentalFileLinkMenu-DO2lGQoK.js.gz +0 -0
  562. package/app/dist/assets/FilePreview-ORcgsTax.js.br +0 -0
  563. package/app/dist/assets/FilePreview-ORcgsTax.js.gz +0 -0
  564. package/app/dist/assets/GitDiffCardHeader-i4vt7tT5.js.br +0 -0
  565. package/app/dist/assets/GitDiffCardHeader-i4vt7tT5.js.gz +0 -0
  566. package/app/dist/assets/InlineMessageEditorFrame-y089xCLP.js.br +0 -0
  567. package/app/dist/assets/InlineMessageEditorFrame-y089xCLP.js.gz +0 -0
  568. package/app/dist/assets/MachineLabel-D07WUIMh.js.br +0 -0
  569. package/app/dist/assets/MachineLabel-D07WUIMh.js.gz +0 -0
  570. package/app/dist/assets/MachineRenameDialog-RyrwvNas.js.br +0 -0
  571. package/app/dist/assets/MachineRenameDialog-RyrwvNas.js.gz +0 -0
  572. package/app/dist/assets/MachineSettingsView-Bg6Op62W.js.br +0 -0
  573. package/app/dist/assets/MachineSettingsView-Bg6Op62W.js.gz +0 -0
  574. package/app/dist/assets/MicrophonePreferences-DwsTYfON.js.br +0 -0
  575. package/app/dist/assets/MicrophonePreferences-DwsTYfON.js.gz +0 -0
  576. package/app/dist/assets/ModelReasoningMenu-Dth3XXm8.js.br +0 -0
  577. package/app/dist/assets/ModelReasoningMenu-Dth3XXm8.js.gz +0 -0
  578. package/app/dist/assets/MoonletDiff-Da65ABAI.js.br +0 -0
  579. package/app/dist/assets/MoonletDiff-Da65ABAI.js.gz +0 -0
  580. package/app/dist/assets/MoonletDiffSplit-Phl7m23w.js.br +0 -0
  581. package/app/dist/assets/MoonletDiffSplit-Phl7m23w.js.gz +0 -0
  582. package/app/dist/assets/MoonletSourceCode-C5aa88dK.js.br +0 -0
  583. package/app/dist/assets/MoonletSourceCode-C5aa88dK.js.gz +0 -0
  584. package/app/dist/assets/NewTabPage-BKkv1maV.js.br +0 -0
  585. package/app/dist/assets/NewTabPage-BKkv1maV.js.gz +0 -0
  586. package/app/dist/assets/NewThreadComposer-00DY4i8k.js.br +0 -0
  587. package/app/dist/assets/NewThreadComposer-00DY4i8k.js.gz +0 -0
  588. package/app/dist/assets/OnboardingFlow-GwpuTTqu.js.br +0 -0
  589. package/app/dist/assets/OnboardingFlow-GwpuTTqu.js.gz +0 -0
  590. package/app/dist/assets/OptionPicker-Cy_W5NWS.js.br +0 -0
  591. package/app/dist/assets/OptionPicker-Cy_W5NWS.js.gz +0 -0
  592. package/app/dist/assets/PaletteShell-CRwrb4lb.js.br +0 -0
  593. package/app/dist/assets/PaletteShell-CRwrb4lb.js.gz +0 -0
  594. package/app/dist/assets/PaneMaximizeButton-CMp4cCoZ.js.br +0 -0
  595. package/app/dist/assets/PaneMaximizeButton-CMp4cCoZ.js.gz +0 -0
  596. package/app/dist/assets/PierreLineSelectionActions-BXbCJV8P.js.br +0 -0
  597. package/app/dist/assets/PierreLineSelectionActions-BXbCJV8P.js.gz +0 -0
  598. package/app/dist/assets/PluginPanelRightPanelHost-CuKRaAaL.js.br +0 -0
  599. package/app/dist/assets/PluginPanelRightPanelHost-CuKRaAaL.js.gz +0 -0
  600. package/app/dist/assets/PluginSettingsSections-DJo5h7Qh.js.br +0 -0
  601. package/app/dist/assets/PluginSettingsSections-DJo5h7Qh.js.gz +0 -0
  602. package/app/dist/assets/PluginThreadChat-BV6OMCzu.js.br +0 -0
  603. package/app/dist/assets/PluginThreadChat-BV6OMCzu.js.gz +0 -0
  604. package/app/dist/assets/ProjectDetailSettingsView-DdF6YsSg.js.br +0 -0
  605. package/app/dist/assets/ProjectDetailSettingsView-DdF6YsSg.js.gz +0 -0
  606. package/app/dist/assets/ProjectMachineSetupDialog-CtbI4XxM.js.br +0 -0
  607. package/app/dist/assets/ProjectMachineSetupDialog-CtbI4XxM.js.gz +0 -0
  608. package/app/dist/assets/ProjectsSettingsSection-BT1kXbPn.js.br +0 -0
  609. package/app/dist/assets/ProjectsSettingsSection-BT1kXbPn.js.gz +0 -0
  610. package/app/dist/assets/QueuedMessagesList-D1aAchqp.js.br +0 -0
  611. package/app/dist/assets/QueuedMessagesList-D1aAchqp.js.gz +0 -0
  612. package/app/dist/assets/RemotePathBrowser-vPIL8lVm.js.br +0 -0
  613. package/app/dist/assets/RemotePathBrowser-vPIL8lVm.js.gz +0 -0
  614. package/app/dist/assets/RootComposeView-DV6JGFlA.js.br +0 -0
  615. package/app/dist/assets/RootComposeView-DV6JGFlA.js.gz +0 -0
  616. package/app/dist/assets/SecondaryPanelLayout-BpHDgFJ_.js.br +0 -0
  617. package/app/dist/assets/SecondaryPanelLayout-BpHDgFJ_.js.gz +0 -0
  618. package/app/dist/assets/ServerMoveOverlayView-CGkGzv8t.js.br +0 -0
  619. package/app/dist/assets/ServerMoveOverlayView-CGkGzv8t.js.gz +0 -0
  620. package/app/dist/assets/SettingsSidebar-1XC0Uxwo.js.br +0 -0
  621. package/app/dist/assets/SettingsSidebar-1XC0Uxwo.js.gz +0 -0
  622. package/app/dist/assets/SettingsView-BUobmesT.js +0 -7
  623. package/app/dist/assets/SettingsView-BUobmesT.js.br +0 -0
  624. package/app/dist/assets/SettingsView-BUobmesT.js.gz +0 -0
  625. package/app/dist/assets/SidebarFooterCustomize-D7sLYPwD.js.br +0 -0
  626. package/app/dist/assets/SidebarFooterCustomize-D7sLYPwD.js.gz +0 -0
  627. package/app/dist/assets/SidebarVisibilityCustomize-DpTzFoGl.js.br +0 -0
  628. package/app/dist/assets/SidebarVisibilityCustomize-DpTzFoGl.js.gz +0 -0
  629. package/app/dist/assets/SourceCodeHost-DVEXLJK1.js.br +0 -0
  630. package/app/dist/assets/SourceCodeHost-DVEXLJK1.js.gz +0 -0
  631. package/app/dist/assets/SplitWorkspaceRoute-BfxQQdOx.js.br +0 -0
  632. package/app/dist/assets/SplitWorkspaceRoute-BfxQQdOx.js.gz +0 -0
  633. package/app/dist/assets/TerminalOutputBlock-COQNamKR.js.br +0 -0
  634. package/app/dist/assets/TerminalOutputBlock-COQNamKR.js.gz +0 -0
  635. package/app/dist/assets/ThreadActionsMenu-064Gcy7T.js.br +0 -0
  636. package/app/dist/assets/ThreadActionsMenu-064Gcy7T.js.gz +0 -0
  637. package/app/dist/assets/ThreadDetailView-CjoXzweq.js.br +0 -0
  638. package/app/dist/assets/ThreadDetailView-CjoXzweq.js.gz +0 -0
  639. package/app/dist/assets/ThreadSearchPaletteMode-CwdePsHK.js.br +0 -0
  640. package/app/dist/assets/ThreadSearchPaletteMode-CwdePsHK.js.gz +0 -0
  641. package/app/dist/assets/ThreadSecondaryPanel-CtYtgTla.js.br +0 -0
  642. package/app/dist/assets/ThreadSecondaryPanel-CtYtgTla.js.gz +0 -0
  643. package/app/dist/assets/ThreadSecondaryPanelTabContent-BNQi8b2n.js.br +0 -0
  644. package/app/dist/assets/ThreadSecondaryPanelTabContent-BNQi8b2n.js.gz +0 -0
  645. package/app/dist/assets/ThreadStatusGlyph-DxxHDn0P.js.br +0 -0
  646. package/app/dist/assets/ThreadStatusGlyph-DxxHDn0P.js.gz +0 -0
  647. package/app/dist/assets/ThreadTerminalPanel-fb5Kk0KG.js.br +0 -0
  648. package/app/dist/assets/ThreadTerminalPanel-fb5Kk0KG.js.gz +0 -0
  649. package/app/dist/assets/ThreadTerminalView-BiGdt3Fd.js.br +0 -0
  650. package/app/dist/assets/ThreadTerminalView-BiGdt3Fd.js.gz +0 -0
  651. package/app/dist/assets/ThreadTimelineNavigationContext-epkIpS1J.js.br +0 -0
  652. package/app/dist/assets/ThreadTimelineNavigationContext-epkIpS1J.js.gz +0 -0
  653. package/app/dist/assets/TimelineDetailScroll-D8gge5Y9.js.br +0 -0
  654. package/app/dist/assets/TimelineDetailScroll-D8gge5Y9.js.gz +0 -0
  655. package/app/dist/assets/TimelineFileDiffBlock-BJt7kifl.js.br +0 -0
  656. package/app/dist/assets/TimelineFileDiffBlock-BJt7kifl.js.gz +0 -0
  657. package/app/dist/assets/TimelineSelectionMenu-DrK39LAT.js.br +0 -0
  658. package/app/dist/assets/TimelineSelectionMenu-DrK39LAT.js.gz +0 -0
  659. package/app/dist/assets/ToolsView-4tUvUv2U.js.br +0 -0
  660. package/app/dist/assets/ToolsView-4tUvUv2U.js.gz +0 -0
  661. package/app/dist/assets/ToolsViewSplits-BWOxgNc1.js.br +0 -0
  662. package/app/dist/assets/ToolsViewSplits-BWOxgNc1.js.gz +0 -0
  663. package/app/dist/assets/WaveformVisualizer-C1SzIkiu.js.br +0 -0
  664. package/app/dist/assets/WaveformVisualizer-C1SzIkiu.js.gz +0 -0
  665. package/app/dist/assets/app-fixed-tab-navigation-Cv4Tj7xZ.js.br +0 -0
  666. package/app/dist/assets/app-fixed-tab-navigation-Cv4Tj7xZ.js.gz +0 -0
  667. package/app/dist/assets/audio-input-device-preference-D8tr0bqw.js.br +0 -0
  668. package/app/dist/assets/audio-input-device-preference-D8tr0bqw.js.gz +0 -0
  669. package/app/dist/assets/bottom-anchored-scroll-body-VYrnz8Hl.js.br +0 -0
  670. package/app/dist/assets/bottom-anchored-scroll-body-VYrnz8Hl.js.gz +0 -0
  671. package/app/dist/assets/browser-url-jhAVtSw2.js.br +0 -0
  672. package/app/dist/assets/browser-url-jhAVtSw2.js.gz +0 -0
  673. package/app/dist/assets/checkbox-qaQbU8-H.js.br +0 -0
  674. package/app/dist/assets/checkbox-qaQbU8-H.js.gz +0 -0
  675. package/app/dist/assets/code-loading-skeletons-pfQDO26Y.js.br +0 -0
  676. package/app/dist/assets/code-loading-skeletons-pfQDO26Y.js.gz +0 -0
  677. package/app/dist/assets/detail-card-C3OH86kJ.js.br +0 -0
  678. package/app/dist/assets/detail-card-C3OH86kJ.js.gz +0 -0
  679. package/app/dist/assets/diff-stats-tally-DkIHmiEl.js.br +0 -0
  680. package/app/dist/assets/diff-stats-tally-DkIHmiEl.js.gz +0 -0
  681. package/app/dist/assets/dist-CWXlD45B.js.br +0 -0
  682. package/app/dist/assets/dist-CWXlD45B.js.gz +0 -0
  683. package/app/dist/assets/environment-mutations-BrA6u8Ev.js.br +0 -0
  684. package/app/dist/assets/environment-mutations-BrA6u8Ev.js.gz +0 -0
  685. package/app/dist/assets/environment-workspace-display-0oqBMXMB.js.br +0 -0
  686. package/app/dist/assets/environment-workspace-display-0oqBMXMB.js.gz +0 -0
  687. package/app/dist/assets/event-code-block-BfPSBXNn.js.br +0 -0
  688. package/app/dist/assets/event-code-block-BfPSBXNn.js.gz +0 -0
  689. package/app/dist/assets/expandable-text-01SvfXRm.js.br +0 -0
  690. package/app/dist/assets/expandable-text-01SvfXRm.js.gz +0 -0
  691. package/app/dist/assets/file-path-link-Ddg7Fzor.js.br +0 -0
  692. package/app/dist/assets/file-path-link-Ddg7Fzor.js.gz +0 -0
  693. package/app/dist/assets/host-mutations-CAtir6jv.js.br +0 -0
  694. package/app/dist/assets/host-mutations-CAtir6jv.js.gz +0 -0
  695. package/app/dist/assets/icon-extended-D2fR2GTF.js.br +0 -0
  696. package/app/dist/assets/icon-extended-D2fR2GTF.js.gz +0 -0
  697. package/app/dist/assets/image-lightbox-Dhmri6WK.js.br +0 -0
  698. package/app/dist/assets/image-lightbox-Dhmri6WK.js.gz +0 -0
  699. package/app/dist/assets/index-5EQKiTkW.css +0 -2
  700. package/app/dist/assets/index-5EQKiTkW.css.br +0 -0
  701. package/app/dist/assets/index-5EQKiTkW.css.gz +0 -0
  702. package/app/dist/assets/index-CfvM6UcU.js.br +0 -0
  703. package/app/dist/assets/index-CfvM6UcU.js.gz +0 -0
  704. package/app/dist/assets/inline-rename-editor-Bg8SXoZ3.js.br +0 -0
  705. package/app/dist/assets/inline-rename-editor-Bg8SXoZ3.js.gz +0 -0
  706. package/app/dist/assets/launcherRow-CqPaUYWn.js.br +0 -0
  707. package/app/dist/assets/launcherRow-CqPaUYWn.js.gz +0 -0
  708. package/app/dist/assets/localhost-link-rewrite-description-DP-bXSL8.js.br +0 -0
  709. package/app/dist/assets/localhost-link-rewrite-description-DP-bXSL8.js.gz +0 -0
  710. package/app/dist/assets/markdown-html-BU8qsXmq.js.br +0 -0
  711. package/app/dist/assets/markdown-html-BU8qsXmq.js.gz +0 -0
  712. package/app/dist/assets/markdown-local-file-link-D-MSnVWD.js.br +0 -0
  713. package/app/dist/assets/markdown-local-file-link-D-MSnVWD.js.gz +0 -0
  714. package/app/dist/assets/markdown-preview-BLL1QuNp.js.br +0 -0
  715. package/app/dist/assets/markdown-preview-BLL1QuNp.js.gz +0 -0
  716. package/app/dist/assets/markdown-prompt-mentions-B5LVmCbO.js.br +0 -0
  717. package/app/dist/assets/markdown-prompt-mentions-B5LVmCbO.js.gz +0 -0
  718. package/app/dist/assets/model-load-error-message-Dmp1hUNg.js.br +0 -0
  719. package/app/dist/assets/model-load-error-message-Dmp1hUNg.js.gz +0 -0
  720. package/app/dist/assets/onboarding-telemetry-BSt5c7Sg.js +0 -1
  721. package/app/dist/assets/open-in-editor-button-D0wnpT6x.js.br +0 -0
  722. package/app/dist/assets/open-in-editor-button-D0wnpT6x.js.gz +0 -0
  723. package/app/dist/assets/page-shell-CgSxnF9m.js.br +0 -0
  724. package/app/dist/assets/page-shell-CgSxnF9m.js.gz +0 -0
  725. package/app/dist/assets/pierre-worker-pool-CHGWu76e.js.br +0 -0
  726. package/app/dist/assets/pierre-worker-pool-CHGWu76e.js.gz +0 -0
  727. package/app/dist/assets/plugin-detail-navigation-DuR8_JCx.js.br +0 -0
  728. package/app/dist/assets/plugin-detail-navigation-DuR8_JCx.js.gz +0 -0
  729. package/app/dist/assets/plugin-frontend-D5ijLuKC.js.br +0 -0
  730. package/app/dist/assets/plugin-frontend-D5ijLuKC.js.gz +0 -0
  731. package/app/dist/assets/plugin-ui-Dpa8hcuk.js.br +0 -0
  732. package/app/dist/assets/plugin-ui-Dpa8hcuk.js.gz +0 -0
  733. package/app/dist/assets/queued-editor-typeahead-layout-Czaq8Cl9.js.br +0 -0
  734. package/app/dist/assets/queued-editor-typeahead-layout-Czaq8Cl9.js.gz +0 -0
  735. package/app/dist/assets/queued-messages-layout-B5xwiued.js.br +0 -0
  736. package/app/dist/assets/queued-messages-layout-B5xwiued.js.gz +0 -0
  737. package/app/dist/assets/resource-list-BKpxiO2e.js.br +0 -0
  738. package/app/dist/assets/resource-list-BKpxiO2e.js.gz +0 -0
  739. package/app/dist/assets/root-compose-create-preference-BeAvwSHy.js +0 -1
  740. package/app/dist/assets/settings-nav-C9-jh_HN.js.br +0 -0
  741. package/app/dist/assets/settings-nav-C9-jh_HN.js.gz +0 -0
  742. package/app/dist/assets/settings-sections-BMr_XU5l.js.br +0 -0
  743. package/app/dist/assets/settings-sections-BMr_XU5l.js.gz +0 -0
  744. package/app/dist/assets/sidebarTouchSensor-DG_A1RmT.js.br +0 -0
  745. package/app/dist/assets/sidebarTouchSensor-DG_A1RmT.js.gz +0 -0
  746. package/app/dist/assets/switch-BjJ8825r.js.br +0 -0
  747. package/app/dist/assets/switch-BjJ8825r.js.gz +0 -0
  748. package/app/dist/assets/thread-event-parser-ma5CGP66.js.br +0 -0
  749. package/app/dist/assets/thread-event-parser-ma5CGP66.js.gz +0 -0
  750. package/app/dist/assets/thread-panel-queries-BXeOzk_6.js.br +0 -0
  751. package/app/dist/assets/thread-panel-queries-BXeOzk_6.js.gz +0 -0
  752. package/app/dist/assets/thread-runtime-mutations-DmKkyel0.js.br +0 -0
  753. package/app/dist/assets/thread-runtime-mutations-DmKkyel0.js.gz +0 -0
  754. package/app/dist/assets/thread-terminal-queries-AFVZ5K6p.js.br +0 -0
  755. package/app/dist/assets/thread-terminal-queries-AFVZ5K6p.js.gz +0 -0
  756. package/app/dist/assets/threadRecentItems-DXsdcpBk.js.br +0 -0
  757. package/app/dist/assets/threadRecentItems-DXsdcpBk.js.gz +0 -0
  758. package/app/dist/assets/threadWorkspaceOpenPath-DwKd-s_5.js.br +0 -0
  759. package/app/dist/assets/threadWorkspaceOpenPath-DwKd-s_5.js.gz +0 -0
  760. package/app/dist/assets/title-bar-scroll-fade-Dw_BPLyx.js.br +0 -0
  761. package/app/dist/assets/title-bar-scroll-fade-Dw_BPLyx.js.gz +0 -0
  762. package/app/dist/assets/use-hover-popover-DzrAfLzd.js.br +0 -0
  763. package/app/dist/assets/use-hover-popover-DzrAfLzd.js.gz +0 -0
  764. package/app/dist/assets/useElementWidth-Kv5FX-9C.js.br +0 -0
  765. package/app/dist/assets/useElementWidth-Kv5FX-9C.js.gz +0 -0
  766. package/app/dist/assets/useLocalOpenTargets-B7rqz64L.js.br +0 -0
  767. package/app/dist/assets/useLocalOpenTargets-B7rqz64L.js.gz +0 -0
  768. package/app/dist/assets/usePanelResizeSnap-Dizp45Ab.js.br +0 -0
  769. package/app/dist/assets/usePanelResizeSnap-Dizp45Ab.js.gz +0 -0
  770. package/app/dist/assets/usePanelTerminals-ByzphxXd.js.br +0 -0
  771. package/app/dist/assets/usePanelTerminals-ByzphxXd.js.gz +0 -0
  772. package/app/dist/assets/usePathSuggestions-Bd5UhdCh.js.br +0 -0
  773. package/app/dist/assets/usePathSuggestions-Bd5UhdCh.js.gz +0 -0
  774. package/app/dist/assets/useResolvedLiveFileTarget-x5Gd-Gzx.js.br +0 -0
  775. package/app/dist/assets/useResolvedLiveFileTarget-x5Gd-Gzx.js.gz +0 -0
  776. package/app/dist/assets/useThreadTerminalController-CUnfO0Da.js.br +0 -0
  777. package/app/dist/assets/useThreadTerminalController-CUnfO0Da.js.gz +0 -0
  778. package/app/dist/assets/workspace-change-summary-CLNpSq_E.js.br +0 -0
  779. package/app/dist/assets/workspace-change-summary-CLNpSq_E.js.gz +0 -0
  780. package/app/dist/assets/workspace-checkout-display-Aad1Wxi4.js.br +0 -0
  781. package/app/dist/assets/workspace-checkout-display-Aad1Wxi4.js.gz +0 -0
  782. package/host-daemon/dist/moonlet-chunks/chunk-4XWRV5U3.js +0 -2
@@ -1,4 +1,4 @@
1
- var ZT=Object.defineProperty;var cn=(e,t)=>{for(var n in t)ZT(e,n,{get:t[n],enumerable:!0})};var Sf=globalThis.__bbPluginRuntime;if(Sf==null||Sf.pluginSdkApp==null)throw new Error('Cannot load "@get-bb/plugin-sdk/app": this bundle must be loaded by the BB app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Hl=Sf.pluginSdkApp,uF="default"in Hl?Hl.default:Hl,{Markdown:H_,ThreadChat:Ef,ThreadTitle:dF,UrlLink:pF,definePluginApp:V_,experimental_BranchPicker:fF,experimental_ComposerRoot:hF,experimental_DetailRow:mF,experimental_Diff:gF,experimental_FailedVoiceRecordings:xF,experimental_FileLink:bF,experimental_Icon:pe,experimental_ImageLightbox:yF,experimental_InfoList:_F,experimental_InfoListRow:vF,experimental_InfoSection:wF,experimental_NewThreadComposer:kF,experimental_PermissionModePicker:SF,experimental_PluginIcon:EF,experimental_PluginRpcCallError:NF,experimental_PromptMentionIcon:AF,experimental_ProviderIcon:CF,experimental_ProviderModelPicker:TF,experimental_SettingsRow:Ei,experimental_SettingsSection:ct,experimental_ShortcutHint:RF,experimental_SidebarNavigationIcon:$F,experimental_SourceCode:IF,experimental_THREAD_ACTION_GROUPS:PF,experimental_THREAD_CONTEXT_SEGMENT_GROUPS:OF,experimental_THREAD_INFO_ROW_GROUPS:LF,experimental_THREAD_INFO_SECTION_GROUPS:MF,experimental_ThreadActionsContextMenu:DF,experimental_ThreadActionsMenu:FF,experimental_ThreadStatusGlyph:zF,experimental_ThreadTitleText:KF,experimental_VoiceInputButton:XF,experimental_VoiceInputTextarea:BF,experimental_VoiceRecordingBar:UF,experimental_copyToClipboard:Z_,experimental_describePromptMention:HF,experimental_promptMentionClipboardAttributes:VF,experimental_readPromptMentionClipboard:ZF,experimental_saveFile:WF,experimental_useAppPanel:W_,experimental_useArchiveEnvironmentThreads:jF,experimental_useBranches:QF,experimental_useCheckoutState:GF,experimental_useCodeTheme:YF,experimental_useComposerCommandSearch:qF,experimental_useComposerContributions:JF,experimental_useComposerMentionSearch:e4,experimental_useComposerRenderer:t4,experimental_useExperiment:n4,experimental_useFixedTabTarget:r4,experimental_usePluginId:o4,experimental_useProviders:s4,experimental_useQuestionFormHost:i4,experimental_useRpcKeyedQuery:a4,experimental_useRpcMutation:l4,experimental_useRpcQuery:c4,experimental_useRpcRefresh:u4,experimental_useSidebar:j_,experimental_useSidebarNavigation:d4,experimental_useSidebarNavigationSplit:p4,experimental_useSidebarThreadActions:f4,experimental_useSidebarThreadSplit:h4,experimental_useSidebarThreads:m4,experimental_useThreadActionRegistrations:g4,experimental_useThreadActions:x4,experimental_useThreadTitleDisplayText:b4,internal_DO_NOT_USE_Outlet:Vl,internal_DO_NOT_USE_useOutletFilled:Q_,useBbContext:G_,useBbNavigate:Ie,useComposer:Y_,useComposerView:y4,useComposers:_4,useEnvironmentProviders:v4,useRealtime:ke,useRealtimeConnectionState:q_,useRpc:J,useSdk:un,useSettings:w4,useSidebarSplitLayout:k4,useSidebarThreadDraft:S4,useSidebarThreadDraftIds:E4,useSidebarThreadRowStatus:N4,useSidebarThreadRowStatuses:A4,useSidebarThreadShortcut:C4,experimental_useSidebarThreadPullRequest:T4}=Hl;var $r={};cn($r,{Activity:()=>jT,Children:()=>Wl,Component:()=>QT,Fragment:()=>Af,Profiler:()=>GT,PureComponent:()=>YT,StrictMode:()=>qT,Suspense:()=>JT,act:()=>e2,cache:()=>t2,cacheSignal:()=>n2,captureOwnerStack:()=>r2,cloneElement:()=>Ni,createContext:()=>Cf,createElement:()=>J_,createRef:()=>o2,default:()=>WT,forwardRef:()=>Tn,isValidElement:()=>Po,lazy:()=>s2,memo:()=>i2,startTransition:()=>a2,unstable_useCacheRefresh:()=>l2,use:()=>c2,useActionState:()=>u2,useCallback:()=>q,useContext:()=>Tf,useDebugValue:()=>d2,useDeferredValue:()=>p2,useEffect:()=>K,useEffectEvent:()=>f2,useId:()=>Ai,useImperativeHandle:()=>h2,useInsertionEffect:()=>m2,useLayoutEffect:()=>ot,useMemo:()=>Lt,useOptimistic:()=>g2,useReducer:()=>x2,useRef:()=>Y,useState:()=>_,useSyncExternalStore:()=>xt,useTransition:()=>b2,version:()=>y2});var Nf=globalThis.__bbPluginRuntime;if(Nf==null||Nf.react==null)throw new Error('Cannot load "react": this bundle must be loaded by the BB app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Zl=Nf.react,WT="default"in Zl?Zl.default:Zl,{Activity:jT,Children:Wl,Component:QT,Fragment:Af,Profiler:GT,PureComponent:YT,StrictMode:qT,Suspense:JT,act:e2,cache:t2,cacheSignal:n2,captureOwnerStack:r2,cloneElement:Ni,createContext:Cf,createElement:J_,createRef:o2,forwardRef:Tn,isValidElement:Po,lazy:s2,memo:i2,startTransition:a2,unstable_useCacheRefresh:l2,use:c2,useActionState:u2,useCallback:q,useContext:Tf,useDebugValue:d2,useDeferredValue:p2,useEffect:K,useEffectEvent:f2,useId:Ai,useImperativeHandle:h2,useInsertionEffect:m2,useLayoutEffect:ot,useMemo:Lt,useOptimistic:g2,useReducer:x2,useRef:Y,useState:_,useSyncExternalStore:xt,useTransition:b2,version:y2}=Zl;function ev(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function _2(...e){return t=>{let n=!1,r=e.map(o=>{let s=ev(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){let s=r[o];typeof s=="function"?s():ev(e[o],null)}}}}function tv(...e){return q(_2(...e),e)}function v2(e){let t=Tn((n,r)=>{let{children:o,...s}=n,i=null,a=!1,u=[];nv(o)&&typeof jl=="function"&&(o=jl(o._payload)),Wl.forEach(o,f=>{if(N2(f)){a=!0;let h=f,g="child"in h.props?h.props.child:h.props.children;nv(g)&&typeof jl=="function"&&(g=jl(g._payload)),i=k2(h,g),u.push(i?.props?.children)}else u.push(f)}),i?i=Ni(i,void 0,u):!a&&Wl.count(o)===1&&Po(o)&&(i=o);let c=i?E2(i):void 0,d=tv(r,c);if(!i){if(o||o===0)throw new Error(a?R2(e):T2(e));return o}let p=S2(s,i.props??{});return i.type!==Af&&(p.ref=r?d:c),Ni(i,p)});return t.displayName=`${e}.Slot`,t}var Ql=v2("Slot"),w2=Symbol.for("radix.slottable");var k2=(e,t)=>{if("child"in e.props){let n=e.props.child;return Po(n)?Ni(n,void 0,e.props.children(n.props.children)):null}return Po(t)?t:null};function S2(e,t){let n={...t};for(let r in t){let o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{let u=s(...a);return o(...a),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function E2(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function N2(e){return Po(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===w2}var A2=Symbol.for("react.lazy");function nv(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===A2&&"_payload"in e&&C2(e._payload)}function C2(e){return typeof e=="object"&&e!==null&&"then"in e}var T2=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,R2=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,jl=$r[" use ".trim().toString()];var Rf=globalThis.__bbPluginRuntime;if(Rf==null||Rf.classVarianceAuthority==null)throw new Error('Cannot load "class-variance-authority": this bundle must be loaded by the BB app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Gl=Rf.classVarianceAuthority,O4="default"in Gl?Gl.default:Gl,{cva:rv,cx:L4}=Gl;var $f=globalThis.__bbPluginRuntime;if($f==null||$f.clsx==null)throw new Error('Cannot load "clsx": this bundle must be loaded by the BB app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Yl=$f.clsx,D4="default"in Yl?Yl.default:Yl,{clsx:ov}=Yl;var If=globalThis.__bbPluginRuntime;if(If==null||If.tailwindMerge==null)throw new Error('Cannot load "tailwind-merge": this bundle must be loaded by the BB app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var ql=If.tailwindMerge,z4="default"in ql?ql.default:ql,{createTailwindMerge:K4,extendTailwindMerge:X4,fromTheme:B4,getDefaultConfig:U4,mergeConfigs:H4,twJoin:V4,twMerge:sv,validators:Z4}=ql;function V(...e){return sv(ov(e))}var Jl="transition-colors duration-150 hover:duration-0";var Pf=globalThis.__bbPluginRuntime;if(Pf==null||Pf.jsxRuntime==null)throw new Error('Cannot load "react/jsx-runtime": this bundle must be loaded by the BB app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var ec=Pf.jsxRuntime,q4="default"in ec?ec.default:ec,{Fragment:he,jsx:l,jsxs:m}=ec;var $2=rv(`inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ${Jl} focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_[data-icon-root]]:pointer-events-none [&_[data-icon-root]]:size-4 [&_[data-icon-root]]:shrink-0`,{variants:{variant:{default:"bg-foreground text-background hover:bg-foreground/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-transparent hover:bg-state-hover hover:text-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-state-hover hover:text-foreground aria-pressed:bg-state-active aria-pressed:text-foreground aria-pressed:hover:bg-state-active data-[state=open]:bg-state-active data-[state=open]:text-foreground data-[state=open]:hover:bg-state-active",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),R=Tn(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>l(r?Ql:"button",{className:V($2({variant:t,size:n,className:e})),ref:s,...o}));R.displayName="Button";function I2({route:e,busy:t,answer:n,cancel:r,expiresAt:o}){return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[m("div",{className:"font-medium",children:[e.what==="spawn"?"Start work":e.what==="tell"?"Send a message":e.what==="relay"?"Relay a message":"Schedule a check"," ",e.what==="relay"?"to":"on"," ",l("span",{className:"font-mono",children:e.station}),e.when&&m("span",{className:"font-normal text-muted-foreground",children:[" (",e.when,")"]})]}),(e.provider||e.model)&&m("div",{className:"mt-1 text-xs",children:["Runs on ",l("span",{className:"font-mono",children:e.provider??"the project's provider"}),e.model&&m(he,{children:[" ","with ",l("span",{className:"font-mono",children:e.model})]}),e.provider==="codex"&&e.own&&" (Codex, under that machine's own Codex sign-in and settings; your moonlet's station protections don't apply)","."]}),m("div",{className:"mt-1 text-xs text-muted-foreground",children:["I\u2019m requesting this from ",e.from,".",e.what==="check"&&" The script runs as orbit on its station, outside Claude Code's sandbox, every time it's due.",e.own&&" I\u2019ll run as you on your machine, with access to your files and accounts.",e.what==="relay"&&" You set this to Ask in Settings \u2192 your moonlet \u2192 Relay. The message goes as written below, marked as relayed from your moonlet."]})]}),l("div",{className:"font-medium",children:e.title}),l("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 font-mono text-xs",children:e.brief}),o&&m("div",{className:"text-xs text-muted-foreground",children:["Expires at ",new Date(o).toLocaleTimeString(),"."]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:t,onClick:()=>n("once"),children:"Approve"}),l(R,{size:"sm",variant:"destructive",disabled:t,onClick:()=>n("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>{r()},children:"Dismiss"})]})]})}var P2=e=>({"orbit-keys.service":"Password service","orbit-relay.service":"Station connection","orbit-proton-bridge.service":"Mail connection",mail:"Mail connection",gate:"Station connection",plugin:"your moonlet service",turn:"Starting work","mail-check":"Mail check",events:"Background work service"})[e]??e;function O2({switching:e,busy:t,answer:n,cancel:r,expiresAt:o}){let s=e.what==="activate";return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[m("div",{className:"font-medium",children:["Switch ",s?"on":"off"," on the station: ",e.piece]}),m("div",{className:"mt-1 text-xs",children:[e.words,"."]})]}),l("div",{className:"text-xs",children:s&&e.recovery?"Every health check still runs. This retry may keep only the known failures below. Another failure or an interrupted switch still undoes it.":s?"I\u2019ll switch this on and check the station\u2019s health. A failed check or interrupted switch restores the previous state.":"I\u2019ll switch this off now. The effect is described above."}),e.recovery&&m("div",{className:"space-y-2 rounded-md border p-2",children:[l("p",{className:"font-medium",children:"Retry and keep this switch if the same checks still fail?"}),l("ul",{className:"list-disc pl-5",children:e.recovery.failures.map(i=>l("li",{children:P2(i)},i))}),l("p",{children:"Approve retries the same switch with the same settings and allows these known failures for this attempt. Services may remain unavailable until repaired. Other failures still undo the switch."})]}),m("div",{className:"text-xs text-muted-foreground",children:["This approves the switch described above.",o&&` Expires at ${new Date(o).toLocaleTimeString()}.`]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:t,onClick:()=>n("once"),children:"Approve"}),l(R,{size:"sm",variant:"destructive",disabled:t,onClick:()=>n("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>{r()},children:"Dismiss"})]})]})}function L2({login:e,offers:t,busy:n,answer:r,cancel:o,expiresAt:s}){let i=e.otp?"one-time codes":"sign-ins";return e.humanCheck?m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[l("div",{className:"font-medium",children:"Proton wants a human check before Bridge signs in"}),l("div",{className:"mt-1 text-xs text-muted-foreground",children:"It's open in Chrome on your moonlet's desktop: solve it there from the Desktop panel (Proton accepts it only from your moonlet's own computer), then press Done. Bridge's sign-in is waiting and carries on from there. The link, in case the window closed:"})]}),l("a",{className:"break-all font-mono text-xs underline",href:e.humanCheck,target:"_blank",rel:"noreferrer noopener",children:e.humanCheck}),s&&m("div",{className:"text-xs text-muted-foreground",children:["Cancelled if unanswered by ",new Date(s).toLocaleTimeString(),"."]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:n,onClick:()=>r("once"),children:"Done"}),l(R,{size:"sm",variant:"destructive",disabled:n,onClick:()=>r("deny"),children:"Cancel"})]})]}):m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[l("div",{children:e.bridge?m(he,{children:[m("div",{className:"font-medium",children:["Sign Proton Mail Bridge in with ",l("span",{className:"font-mono",children:e.item})]}),l("div",{className:"mt-1 text-xs text-muted-foreground",children:"I\u2019ll sign Bridge in through the vault without seeing the password or code. Then I can read and send its mail through Bridge."})]}):m(he,{children:[m("div",{className:"font-medium",children:["Sign your moonlet in: fill ",e.otp?"the one-time code":"the username and password"," from ",l("span",{className:"font-mono",children:e.item})," ","into ",l("span",{className:"font-mono",children:e.unit}),"'s sign-in page, ",l("span",{className:"font-mono",children:e.url})]}),m("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.otp?"The broker fills it into the text field that has the focus on that page; your moonlet never sees it.":"The broker fills them into that page's form (the password only into its password field) and signs in; your moonlet never sees them."," ","You can see the sign-in form in the Desktop panel."]})]})}),m("ul",{className:"list-disc space-y-0.5 pl-5 text-xs text-muted-foreground",children:[t.includes("thread")&&m("li",{children:[l("b",{children:"For this conversation"}),": ",i," for ",l("span",{className:"font-mono",children:e.name})," asked as this conversation, until Moonlet reloads your moonlet."]}),t.includes("always")&&m("li",{children:[l("b",{children:"Always"}),": ",i," for ",l("span",{className:"font-mono",children:e.name})," from any of the station's conversations, from now on. Revoke it in Settings \u2192 your moonlet."]}),s&&m("li",{children:["Expires at ",new Date(s).toLocaleTimeString(),"."]})]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:n,onClick:()=>r("once"),children:"Approve"}),t.includes("thread")&&l(R,{size:"sm",variant:"secondary",disabled:n,onClick:()=>r("thread"),children:"For this conversation"}),t.includes("always")&&l(R,{size:"sm",variant:"secondary",disabled:n,onClick:()=>r("always"),children:"Always"}),l(R,{size:"sm",variant:"destructive",disabled:n,onClick:()=>r("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:n,onClick:()=>{o()},children:"Dismiss"})]})]})}function M2({change:e,busy:t,answer:n}){return m("div",{className:"space-y-3 p-3 text-sm",children:[m("p",{className:"font-medium",children:[e.mergeReasons?"Allow merging":e.checks?"Proceed with these checks for":"Approve change"," #",e.number," in ",e.repo,"?"]}),l("a",{className:"underline",href:`https://github.com/${e.repo}/pull/${e.number}/files/${e.head}`,target:"_blank",rel:"noreferrer noopener",children:"Read this version of the change"}),e.mergeReasons?m("p",{children:["Allow this reviewed version to be merged despite:"," ",e.mergeReasons.map(r=>({author:"the author restriction",protected_paths:"protected files",changes_requested:"a request for changes"})[r]).join(", "),". Every check must still pass, the review must match this commit, and the pull request must be ready and mergeable. This changes the default branch."]}):e.checks?m(he,{children:[l("p",{children:"Allow merging this version despite the results below. Tests may be incomplete or the change may be broken. This also approves the change, including core files. It does not install anything."}),l("a",{className:"underline",href:`https://github.com/${e.repo}/pull/${e.number}/checks`,target:"_blank",rel:"noreferrer noopener",children:"Read the check details"}),l("ul",{className:"list-disc pl-5",children:e.checks.failures.map((r,o)=>l("li",{children:r},o))}),l("p",{className:"text-xs",children:"Only these exact check runs and this version are covered. A rerun, changed result, extra check or later push needs a new decision. Repository, identity and version checks still apply."})]}):l("p",{children:"This approves this whole version, including its core files. A later push needs approval of its own. Every other merge check still applies."}),l("p",{className:"text-xs",children:"This records your approval of the change. It does not install anything."}),l("pre",{className:"whitespace-pre-wrap break-all text-xs",children:e.head}),m("div",{className:"flex gap-2",children:[l(R,{size:"sm",disabled:t,onClick:()=>n("once"),children:"Approve"}),l(R,{size:"sm",variant:"destructive",disabled:t,onClick:()=>n("deny"),children:"Decline"})]})]})}function D2({mail:e,busy:t,answer:n,cancel:r,expiresAt:o}){let s=(i,a)=>a&&m("div",{children:[m("span",{className:"text-muted-foreground",children:[i,":"]})," ",l("span",{className:"whitespace-pre-wrap break-all font-mono",children:a})]});return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[l("div",{className:"font-medium",children:"Your moonlet wants to send this mail from its Gmail account"}),l("div",{className:"mt-1 text-xs text-muted-foreground",children:"Exactly as shown: the protected mail runner sends this message and nothing else. Sending only this one, once; a sent mail can't be taken back."})]}),m("div",{className:"flex flex-col gap-0.5 text-xs",children:[s("From",e.from),s("To",e.to),s("Cc",e.cc),s("Subject",e.subject),s("Date",e.date),s("Message-ID",e.messageId),s("In reply to",e.inReplyTo),s("References",e.references)]}),l("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 font-mono text-xs",children:e.body}),o&&m("div",{className:"text-xs text-muted-foreground",children:["Refused if unanswered by ",new Date(o).toLocaleTimeString(),"."]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:t,onClick:()=>n("once"),children:"Send"}),l(R,{size:"sm",variant:"destructive",disabled:t,onClick:()=>n("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>{r()},children:"Dismiss"})]})]})}function tc({interaction:e,submit:t,cancel:n}){let r=e.payload,[o,s]=_(!1),i=u=>{s(!0),t({choice:u}).catch(()=>s(!1))};if(r.change)return l(M2,{change:r.change,busy:o,answer:i});if(r.switching)return l(O2,{switching:r.switching,busy:o,answer:i,cancel:()=>{n()},expiresAt:r.expiresAt});if(r.mail)return l(D2,{mail:r.mail,busy:o,answer:i,cancel:()=>{n()},expiresAt:r.expiresAt});if(r.route)return l(I2,{route:r.route,busy:o,answer:i,cancel:()=>{n()},expiresAt:r.expiresAt});if(r.login)return l(L2,{login:r.login,offers:r.offers,busy:o,answer:i,cancel:()=>{n()},expiresAt:r.expiresAt});let a=new Set(r.offers);return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[m("div",{className:"font-medium",children:["I\u2019d like to ",r.level==="act"?"make a change":"look"," with ",l("span",{className:"font-mono",children:r.capability})]}),l("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted p-2 font-mono text-xs",children:r.command})]}),m("ul",{className:"list-disc space-y-0.5 pl-5 text-xs text-muted-foreground",children:[a.has("thread")&&m("li",{children:[l("b",{children:"For this conversation"}),": any ",l("span",{className:"font-mono",children:r.rule})," command on ",r.capability,", until Moonlet reloads your moonlet."]}),a.has("always")&&m("li",{children:[l("b",{children:"Always"}),": this exact command, from now on. Revoke it in Settings \u2192 your moonlet."]}),r.sensitive&&m("li",{children:["This command is on ",r.capability,"'s sensitive list, so it asks every time."]}),r.expiresAt&&m("li",{children:["Expires at ",new Date(r.expiresAt).toLocaleTimeString(),"."]})]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:o,onClick:()=>i("once"),children:"Approve"}),a.has("thread")&&l(R,{size:"sm",variant:"secondary",disabled:o,onClick:()=>i("thread"),children:"Allow for this conversation"}),a.has("always")&&l(R,{size:"sm",variant:"secondary",disabled:o,onClick:()=>i("always"),children:"Always allow"}),l(R,{size:"sm",variant:"destructive",disabled:o,onClick:()=>i("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:o,onClick:()=>{n()},children:"Dismiss"})]})]})}function nc({interaction:e,submit:t,cancel:n}){let r=e.payload,[o,s]=_(!1),i=a=>{s(!0),t({hostId:a}).catch(()=>s(!1))};return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[m("div",{className:"font-medium",children:["Which machine manages ",l("span",{className:"font-mono",children:r.station}),"?"]}),m("p",{className:"mt-1 text-xs text-muted-foreground",children:["Several machines have your moonlet's station key and this station's VM. Your moonlet reaches the station only through the one you pick, which receives its credentials when they change. Change it later with ",l("span",{className:"font-mono",children:"moonlet station manager"}),"."]})]}),m("div",{className:"flex flex-wrap gap-2",children:[r.machines.map(a=>l(R,{size:"sm",variant:"secondary",disabled:o,onClick:()=>i(a.id),children:a.name},a.id)),l(R,{size:"sm",variant:"ghost",disabled:o,onClick:()=>{n()},children:"Dismiss"})]})]})}function iv({payload:e}){let t=e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.proposal=="string"?e.proposal:"";return/^[a-f0-9]{32}$/.test(t)?l(Ci,{id:t}):l("p",{children:"The settings result is unavailable."})}function Ci({id:e}){let t=J(),[n,r]=_([]),[o,s]=_(!1);return K(()=>{let i=!0,a,u=async()=>{try{let c=e?await t.call("policy-proposals.result",{id:e}).then(d=>d?[d]:[]):await t.call("policy-proposals.history",null);i&&(r(c),s(!1))}catch{i&&s(!0)}i&&(a=setTimeout(()=>{u()},5e3))};return u(),()=>{i=!1,clearTimeout(a)}},[t,e]),!n.length&&!o?null:m("section",{className:"space-y-2 p-3 text-sm","aria-label":"Station settings results",children:[!e&&l("h2",{className:"font-medium",children:"Recent station settings requests"}),o&&l("p",{role:"alert",children:"The settings result could not be checked. Trying again."}),n.slice(0,e?1:10).map(i=>m("div",{className:"space-y-1 rounded border p-2",children:[l("p",{className:"font-medium",children:i.title}),l("p",{children:i.message})]},i.id))]})}function rc({interaction:e,submit:t}){let n=e.payload,r=J(),[o,s]=_(!1),[i,a]=_(!1),[u,c]=_(null),[d,p]=_(null),[f,h]=_([]),g=Date.now()>=n.deadline,x=!!n.restore&&f.length===0;async function b(v){if(!(o||g||v&&(n.explanation.extraConfirmation&&!i||x))){s(!0),p(null);try{await t(n.restore?{approve:v,acknowledgeRisk:i,restore:v?f:[]}:{approve:v,acknowledgeRisk:i})}catch{p("Your answer did not go through. Try again."),s(!1)}}}return m("div",{className:"space-y-3 p-3 text-sm",children:[l("p",{className:"font-medium",children:n.restore?"Approve secret use again?":"Change station permissions?"}),n.explanation.sections.map(v=>m("section",{className:"space-y-1",children:[l("h3",{className:"font-medium",children:v.heading}),v.sentences.map((w,C)=>l("p",{className:"whitespace-pre-wrap break-words",children:w},C))]},v.heading)),n.restore&&m("fieldset",{className:"space-y-2",children:[l("legend",{className:"font-medium",children:"Secret uses to approve again"}),n.restore.map(v=>m("label",{className:"flex gap-2",children:[l("input",{type:"checkbox","aria-label":`Approve ${v.id} again`,checked:f.includes(v.id),disabled:o||g,onChange:w=>h(C=>w.target.checked?[...C,v.id].sort():C.filter(y=>y!==v.id))}),m("span",{children:[l("span",{className:"whitespace-pre-wrap break-all font-mono",children:v.id}),l("span",{className:"block whitespace-pre-wrap break-words",children:v.sentence})]})]},v.id))]}),l("p",{children:"This answer covers only these settings and their application. Declining or leaving this unanswered changes nothing."}),m("p",{children:["Expires ",new Date(n.deadline).toLocaleString(),"."]}),m("details",{onToggle:v=>{v.currentTarget.open&&!u&&r.call("policy-proposals.text",{id:n.id}).then(c).catch(()=>p("The exact text could not be loaded. Try opening it again."))},children:[l("summary",{className:"cursor-pointer underline",children:"More details"}),m("p",{children:["Proposer's title: ",n.title]}),l("p",{children:"Proposer's own words (not verified):"}),l("p",{className:"whitespace-pre-wrap break-words",children:n.explanation.details.proposerWords}),n.explanation.details.unchanged.map((v,w)=>l("p",{children:v},w)),u?m("div",{className:"space-y-2",children:[l("p",{children:"Current settings"}),l("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-all",children:u.before}),l("p",{children:"Proposed settings"}),l("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-all",children:u.after}),l("p",{children:"Checked review"}),l("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-all",children:u.preview})]}):l("p",{children:"Loading\u2026"})]}),n.explanation.extraConfirmation&&m("label",{className:"flex gap-2",children:[l("input",{type:"checkbox",checked:i,disabled:o||g,onChange:v=>a(v.target.checked)}),"I understand the extra access described above."]}),g&&l("p",{role:"alert",children:"This request has expired. Nothing was changed."}),d&&l("p",{role:"alert",children:d}),m("div",{className:"flex gap-2",children:[l(R,{size:"sm",disabled:o||g||n.explanation.extraConfirmation&&!i||x,onClick:()=>{b(!0)},children:"Approve"}),l(R,{size:"sm",variant:"destructive",disabled:o||g,onClick:()=>{b(!1)},children:"Decline"})]})]})}var F2=/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/;function oc({url:e,label:t,size:n=64}){let r={width:n,height:n};return!e||!F2.test(e)?l("span",{role:"img","aria-label":`${t}: none`,className:"inline-block shrink-0 rounded-full border border-dashed border-border bg-muted",style:r}):l("img",{src:e,alt:t,className:"shrink-0 rounded-full border border-border bg-muted object-cover",style:r})}var z2=[{value:"approve",label:"Approve"},{value:"decline",label:"Decline"},{value:"later",label:"Later"}];function Of({id:e,beforeLabel:t="Now"}){let n=J(),[r,o]=_(null),[s,i]=_(null);return m("details",{onToggle:a=>{a.currentTarget.open&&!r&&n.call("owner-changes.details",{id:e}).then(o).catch(()=>i("The details could not be loaded. Try opening them again."))},children:[l("summary",{className:"cursor-pointer underline",children:"More details"}),s&&l("p",{role:"alert",children:s}),r&&m("div",{className:"mt-2 space-y-2",children:[r.pictures.map(a=>m("div",{className:"flex flex-col items-start gap-1",children:[l(oc,{url:a.url,label:a.label,size:96}),l("span",{className:"text-xs text-muted-foreground",children:a.label})]},a.label)),m("div",{className:"grid gap-2 md:grid-cols-2",children:[m("div",{children:[l("div",{className:"mb-1 text-xs text-muted-foreground",children:t}),l("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 text-xs",children:r.before})]}),m("div",{children:[l("div",{className:"mb-1 text-xs text-muted-foreground",children:"After"}),l("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 text-xs",children:r.after})]})]})]})]})}function K2({item:e,choice:t,onChoice:n,acknowledged:r,onAcknowledge:o,narrowing:s,onNarrow:i,expired:a}){let u=e.offer;return m("article",{className:"space-y-2 rounded-md border p-3","aria-disabled":a,children:[l("p",{className:"font-medium",children:e.summary}),e.explanation.sections.map(c=>m("section",{className:"space-y-1",children:[l("h4",{className:"font-medium",children:c.heading}),c.sentences.map((d,p)=>l("p",{className:"whitespace-pre-wrap break-words",children:d},p))]},c.heading)),(e.title||e.explanation.details.proposerWords)&&m("details",{children:[l("summary",{className:"cursor-pointer underline",children:"Proposer's own words (not verified)"}),e.title&&l("p",{className:"whitespace-pre-wrap break-words",children:e.title}),l("p",{className:"whitespace-pre-wrap break-words",children:e.explanation.details.proposerWords})]}),l(Of,{id:e.id}),!a&&u?.expiry&&!s.once&&m("label",{className:"block",children:["Permission ends (leave empty for no time limit)",l("input",{"aria-label":"Permission ends",className:"block rounded border p-1",type:"datetime-local",value:s.until,onChange:c=>i({...s,until:c.target.value})})]}),!a&&u?.once&&m("label",{className:"flex items-center gap-2",children:[l("input",{type:"checkbox",checked:s.once,onChange:c=>i({...s,once:c.target.checked})}),"Only this once, for the operation waiting now (no standing permission)"]}),e.explanation.extraConfirmation&&m("label",{className:"flex items-center gap-2",children:[l("input",{type:"checkbox",checked:r,disabled:a,onChange:c=>o(c.target.checked)}),"I understand the extra access described above."]}),a?l("p",{children:"This request expired before your answer; it won't be applied."}):m("fieldset",{className:"flex flex-wrap gap-3",children:[l("legend",{className:"sr-only",children:"Your answer"}),z2.map(c=>m("label",{className:"flex items-center gap-1",children:[l("input",{type:"radio",name:`choice-${e.id}`,value:c.value,checked:t===c.value,onChange:()=>n(c.value)}),c.label]},c.value))]}),m("p",{className:"text-xs text-muted-foreground",children:["Expires ",new Date(e.deadline).toLocaleString(),"."]})]})}function sc({interaction:e,submit:t,cancel:n}){let r=e.payload,[o,s]=_(()=>Object.fromEntries(r.items.map(T=>[T.id,"later"]))),[i,a]=_({}),[u,c]=_({}),[d,p]=_(!1),[f,h]=_(null),[g,x]=_(()=>Date.now());K(()=>{let T=r.items.map(S=>S.deadline).filter(S=>S>g).sort((S,$)=>S-$)[0];if(T===void 0)return;let N=setTimeout(()=>x(Date.now()),Math.min(T-g+50,2**31-1));return()=>clearTimeout(N)},[r.items,g]);let b=r.items.some(T=>o[T.id]==="approve"&&T.explanation.extraConfirmation&&!i[T.id]),v=T=>u[T]??{until:"",once:!1};function w(T){let N=T.offer;if(o[T.id]!=="approve"||!N)return;let S=v(T.id);if(N.once&&S.once)return{once:!0};if(N.expiry)return{expiresAt:S.until?Date.parse(S.until):null}}let C=r.items.some(T=>{let N=w(T)?.expiresAt;return typeof N=="number"&&(!Number.isFinite(N)||N<=Date.now())});async function y(){if(d||b||C)return;p(!0),h(null);let T=r.items.filter(N=>N.deadline>Date.now()).map(N=>{let S=w(N);return{id:N.id,planHash:N.planHash,choice:o[N.id]??"later",acknowledgeRisk:i[N.id]===!0,...S?{options:S}:{}}});try{await t({form:r.form,answers:T})}catch{h("Your answer did not go through. Try again."),p(!1)}}return m("div",{className:"space-y-3 p-3 text-sm",children:[l("p",{className:"font-medium",children:r.items.length===1?"A change your moonlet asked for":`${r.items.length} changes your moonlet asked for`}),r.items.map(T=>l(K2,{item:T,choice:o[T.id]??"later",onChoice:N=>s({...o,[T.id]:N}),acknowledged:i[T.id]===!0,onAcknowledge:N=>a({...i,[T.id]:N}),narrowing:v(T.id),onNarrow:N=>c({...u,[T.id]:N}),expired:T.deadline<=g},T.id)),l("p",{children:"Approve applies exactly what is shown. Decline is remembered for 30 days. Later keeps it for another time. Nothing changes until you send your answers."}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:d||b||C,onClick:()=>{y()},children:"Send answers"}),l(R,{size:"sm",variant:"ghost",disabled:d,onClick:()=>{n()},children:"Not now"})]}),b&&l("p",{children:"Tick the confirmation on each high-risk change you approve."}),C&&l("p",{children:"Choose a future end time, or leave it empty for no time limit."}),f&&l("p",{role:"alert",children:f})]})}function av(e){return e>>>0}function Ti(e){return e|0}var lv="warn",de=()=>{},Qe=()=>{},Ye=()=>{},Me=()=>{};function X2(e){if(typeof e>"u"?e=lv:lv=e,de=Qe=Ye=Me=()=>{},typeof window.console<"u")switch(e){case"debug":de=console.debug.bind(window.console);case"info":Qe=console.info.bind(window.console);case"warn":Ye=console.warn.bind(window.console);case"error":Me=console.error.bind(window.console);case"none":break;default:throw new window.Error("invalid logging type '"+e+"'")}}X2();function ic(e,t=!1){try{return decodeURIComponent(escape(e))}catch(n){if(n instanceof URIError&&t)return e;throw n}}function Gt(e){return unescape(encodeURIComponent(e))}var Oo={toBase64Table:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),base64Pad:"=",encode(e){"use strict";let t="",n=e.length,r=n%3;for(let s=0;s<n-2;s+=3)t+=this.toBase64Table[e[s]>>2],t+=this.toBase64Table[((e[s]&3)<<4)+(e[s+1]>>4)],t+=this.toBase64Table[((e[s+1]&15)<<2)+(e[s+2]>>6)],t+=this.toBase64Table[e[s+2]&63];let o=n-r;return r===2?(t+=this.toBase64Table[e[o]>>2],t+=this.toBase64Table[((e[o]&3)<<4)+(e[o+1]>>4)],t+=this.toBase64Table[(e[o+1]&15)<<2],t+=this.toBase64Table[64]):r===1&&(t+=this.toBase64Table[e[o]>>2],t+=this.toBase64Table[(e[o]&3)<<4],t+=this.toBase64Table[64],t+=this.toBase64Table[64]),t},toBinaryTable:[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1],decode(e,t=0){let n=e.indexOf("=")-t;n<0&&(n=e.length-t);let r=(n>>2)*3+Math.floor(n%4/1.5),o=new Array(r),s=0,i=0;for(let a=0,u=t;u<e.length;u++){let c=this.toBinaryTable[e.charCodeAt(u)&127],d=e.charAt(u)===this.base64Pad;if(c===-1){Me("Illegal character code "+e.charCodeAt(u)+" at position "+u);continue}i=i<<6|c,s+=6,s>=8&&(s-=8,d||(o[a++]=i>>s&255),i&=(1<<s)-1)}if(s){let a=new Error("Corrupted base64 string");throw a.name="Base64-Error",a}return o}};var Lf="ontouchstart"in document.documentElement||document.ontouchstart!==void 0||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;window.addEventListener("touchstart",function e(){Lf=!0,window.removeEventListener("touchstart",e,!1)},!1);var Ri=10*(window.devicePixelRatio||1),cv=!1;try{let e=document.createElement("canvas");e.style.cursor='url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default',e.style.cursor.indexOf("url")===0?(Qe("Data URI scheme cursor supported"),cv=!0):Ye("Data URI scheme cursor not supported")}catch(e){Me("Data URI scheme cursor test exception: "+e)}var uv=cv,B2=!0;try{let e=document.createElement("div");e.style.visibility="hidden",e.style.overflow="scroll",document.body.appendChild(e);let t=document.createElement("div");e.appendChild(t);let n=e.offsetWidth-t.offsetWidth;e.parentNode.removeChild(e),B2=n!=0}catch(e){Me("Scrollbar test exception: "+e)}var Mf=!1;async function U2(){if(!("VideoDecoder"in window))return!1;let e={codec:"avc1.42401f",codedWidth:1920,codedHeight:1080,optimizeForLatency:!0};if(!(await VideoDecoder.isConfigSupported(e)).supported)return!1;let n=new Uint8Array(Oo.decode("AAAAAWdCwBTZnpuAgICgAAADACAAAAZB4oVNAAAAAWjJYyyAAAABBgX//4HcRem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY0IHIzMTA4IDMxZTE5ZjkgLSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDIzIC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9uczogY2FiYWM9MCByZWY9NSBkZWJsb2NrPTE6MDowIGFuYWx5c2U9MHgxOjB4MTExIG1lPWhleCBzdWJtZT04IHBzeT0xIHBzeV9yZD0xLjAwOjAuMDAgbWl4ZWRfcmVmPTEgbWVfcmFuZ2U9MTYgY2hyb21hX21lPTEgdHJlbGxpcz0yIDh4OGRjdD0wIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJvbWFfcXBfb2Zmc2V0PS0yIHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTAgd2VpZ2h0cD0wIGtleWludD1pbmZpbml0ZSBrZXlpbnRfbWluPTI1IHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NTAgcmM9YWJyIG1idHJlZT0xIGJpdHJhdGU9NDAwIHJhdGV0b2w9MS4wIHFjb21wPTAuNjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAABZYiEBrxmKAAPVccAAS044AA5DRJMnkycJk4TPw==")),r=!1,o=null,s=new VideoDecoder({output:a=>{r=!0,a.close()},error:a=>{o=a}}),i=new EncodedVideoChunk({timestamp:0,type:"key",data:n});s.configure(e),s.decode(i);try{await s.flush()}catch(a){o=a}return!(!r||o!==null)}Mf=await U2();function Jn(){return!!/mac/i.exec(navigator.platform)}function Lo(){return!!/win/i.exec(navigator.platform)}function Mo(){return!!/ipad/i.exec(navigator.platform)||!!/iphone/i.exec(navigator.platform)||!!/ipod/i.exec(navigator.platform)}function Do(e,t,n){let r=n.getBoundingClientRect(),o={x:0,y:0};return e<r.left?o.x=0:e>=r.right?o.x=r.width-1:o.x=e-r.left,t<r.top?o.y=0:t>=r.bottom?o.y=r.height-1:o.y=t-r.top,o}function Pr(e){e.stopPropagation(),e.preventDefault()}var Df=!1,pv=null;document.captureElement=null;function Ir(e){if(Df)return;let t=new e.constructor(e.type,e);Df=!0,document.captureElement?document.captureElement.dispatchEvent(t):pv.dispatchEvent(t),Df=!1,e.stopPropagation(),t.defaultPrevented&&e.preventDefault(),e.type==="mouseup"&&gv()}function fv(){let e=document.getElementById("noVNC_mouse_capture_elem");e.style.cursor=window.getComputedStyle(document.captureElement).cursor}var hv=new MutationObserver(fv);function mv(e){if(e.setCapture)e.setCapture(),document.captureElement=e;else{gv();let t=document.getElementById("noVNC_mouse_capture_elem");t===null&&(t=document.createElement("div"),t.id="noVNC_mouse_capture_elem",t.style.position="fixed",t.style.top="0px",t.style.left="0px",t.style.width="100%",t.style.height="100%",t.style.zIndex=1e4,t.style.display="none",document.body.appendChild(t),t.addEventListener("contextmenu",Ir),t.addEventListener("mousemove",Ir),t.addEventListener("mouseup",Ir)),document.captureElement=e,hv.observe(e,{attributes:!0}),fv(),t.style.display="",window.addEventListener("mousemove",Ir),window.addEventListener("mouseup",Ir)}}function gv(){if(document.releaseCapture)document.releaseCapture(),document.captureElement=null;else{if(!document.captureElement)return;pv=document.captureElement,document.captureElement=null,hv.disconnect();let e=document.getElementById("noVNC_mouse_capture_elem");e.style.display="none",window.removeEventListener("mousemove",Ir),window.removeEventListener("mouseup",Ir)}}var Or=class{constructor(){this._listeners=new Map}addEventListener(t,n){this._listeners.has(t)||this._listeners.set(t,new Set),this._listeners.get(t).add(n)}removeEventListener(t,n){this._listeners.has(t)&&this._listeners.get(t).delete(n)}dispatchEvent(t){return this._listeners.has(t.type)?(this._listeners.get(t.type).forEach(n=>n.call(this,t)),!t.defaultPrevented):!0}};var $i=class{constructor(t){if(this._drawCtx=null,this._renderQ=[],this._flushPromise=null,this._fbWidth=0,this._fbHeight=0,this._prevDrawStyle="",de(">> Display.constructor"),this._target=t,!this._target)throw new Error("Target must be set");if(typeof this._target=="string")throw new Error("target must be a DOM element");if(!this._target.getContext)throw new Error("no getContext method");this._targetCtx=this._target.getContext("2d"),this._viewportLoc={x:0,y:0,w:this._target.width,h:this._target.height},this._backbuffer=document.createElement("canvas"),this._drawCtx=this._backbuffer.getContext("2d"),this._damageBounds={left:0,top:0,right:this._backbuffer.width,bottom:this._backbuffer.height},de("User Agent: "+navigator.userAgent),de("<< Display.constructor"),this._scale=1,this._clipViewport=!1}get scale(){return this._scale}set scale(t){this._rescale(t)}get clipViewport(){return this._clipViewport}set clipViewport(t){this._clipViewport=t;let n=this._viewportLoc;this.viewportChangeSize(n.w,n.h),this.viewportChangePos(0,0)}get width(){return this._fbWidth}get height(){return this._fbHeight}viewportChangePos(t,n){let r=this._viewportLoc;t=Math.floor(t),n=Math.floor(n),this._clipViewport||(t=-r.w,n=-r.h);let o=r.x+r.w-1,s=r.y+r.h-1;t<0&&r.x+t<0&&(t=-r.x),o+t>=this._fbWidth&&(t-=o+t-this._fbWidth+1),r.y+n<0&&(n=-r.y),s+n>=this._fbHeight&&(n-=s+n-this._fbHeight+1),!(t===0&&n===0)&&(de("viewportChange deltaX: "+t+", deltaY: "+n),r.x+=t,r.y+=n,this._damage(r.x,r.y,r.w,r.h),this.flip())}viewportChangeSize(t,n){(!this._clipViewport||typeof t>"u"||typeof n>"u")&&(de("Setting viewport to full display region"),t=this._fbWidth,n=this._fbHeight),t=Math.floor(t),n=Math.floor(n),t>this._fbWidth&&(t=this._fbWidth),n>this._fbHeight&&(n=this._fbHeight);let r=this._viewportLoc;if(r.w!==t||r.h!==n){r.w=t,r.h=n;let o=this._target;o.width=t,o.height=n,this.viewportChangePos(0,0),this._damage(r.x,r.y,r.w,r.h),this.flip(),this._rescale(this._scale)}}absX(t){return this._scale===0?0:Ti(t/this._scale+this._viewportLoc.x)}absY(t){return this._scale===0?0:Ti(t/this._scale+this._viewportLoc.y)}resize(t,n){this._prevDrawStyle="",this._fbWidth=t,this._fbHeight=n;let r=this._backbuffer;if(r.width!==t||r.height!==n){let s=null;r.width>0&&r.height>0&&(s=this._drawCtx.getImageData(0,0,r.width,r.height)),r.width!==t&&(r.width=t),r.height!==n&&(r.height=n),s&&this._drawCtx.putImageData(s,0,0)}let o=this._viewportLoc;this.viewportChangeSize(o.w,o.h),this.viewportChangePos(0,0)}getImageData(){return this._drawCtx.getImageData(0,0,this.width,this.height)}toDataURL(t,n){return this._backbuffer.toDataURL(t,n)}toBlob(t,n,r){return this._backbuffer.toBlob(t,n,r)}_damage(t,n,r,o){t<this._damageBounds.left&&(this._damageBounds.left=t),n<this._damageBounds.top&&(this._damageBounds.top=n),t+r>this._damageBounds.right&&(this._damageBounds.right=t+r),n+o>this._damageBounds.bottom&&(this._damageBounds.bottom=n+o)}flip(t){if(this._renderQ.length!==0&&!t)this._renderQPush({type:"flip"});else{let n=this._damageBounds.left,r=this._damageBounds.top,o=this._damageBounds.right-n,s=this._damageBounds.bottom-r,i=n-this._viewportLoc.x,a=r-this._viewportLoc.y;i<0&&(o+=i,n-=i,i=0),a<0&&(s+=a,r-=a,a=0),i+o>this._viewportLoc.w&&(o=this._viewportLoc.w-i),a+s>this._viewportLoc.h&&(s=this._viewportLoc.h-a),o>0&&s>0&&this._targetCtx.drawImage(this._backbuffer,n,r,o,s,i,a,o,s),this._damageBounds.left=this._damageBounds.top=65535,this._damageBounds.right=this._damageBounds.bottom=0}}pending(){return this._renderQ.length>0}flush(){return this._renderQ.length===0?Promise.resolve():(this._flushPromise===null&&(this._flushPromise=new Promise(t=>{this._flushResolve=t})),this._flushPromise)}fillRect(t,n,r,o,s,i){this._renderQ.length!==0&&!i?this._renderQPush({type:"fill",x:t,y:n,width:r,height:o,color:s}):(this._setFillColor(s),this._drawCtx.fillRect(t,n,r,o),this._damage(t,n,r,o))}copyImage(t,n,r,o,s,i,a){this._renderQ.length!==0&&!a?this._renderQPush({type:"copy",oldX:t,oldY:n,x:r,y:o,width:s,height:i}):(this._drawCtx.mozImageSmoothingEnabled=!1,this._drawCtx.webkitImageSmoothingEnabled=!1,this._drawCtx.msImageSmoothingEnabled=!1,this._drawCtx.imageSmoothingEnabled=!1,this._drawCtx.drawImage(this._backbuffer,t,n,s,i,r,o,s,i),this._damage(r,o,s,i))}imageRect(t,n,r,o,s,i){if(r===0||o===0)return;let a=new Image;a.src="data: "+s+";base64,"+Oo.encode(i),this._renderQPush({type:"img",img:a,x:t,y:n,width:r,height:o})}videoFrame(t,n,r,o,s){this._renderQPush({type:"frame",frame:s,x:t,y:n,width:r,height:o})}blitImage(t,n,r,o,s,i,a){if(this._renderQ.length!==0&&!a){let u=new Uint8Array(r*o*4);u.set(new Uint8Array(s.buffer,0,u.length)),this._renderQPush({type:"blit",data:u,x:t,y:n,width:r,height:o})}else{let u=new Uint8ClampedArray(s.buffer,s.byteOffset+i,r*o*4),c=new ImageData(u,r,o);this._drawCtx.putImageData(c,t,n),this._damage(t,n,r,o)}}drawImage(t,...n){if(this._drawCtx.drawImage(t,...n),n.length<=4){let[r,o]=n;this._damage(r,o,t.width,t.height)}else{let[,,r,o,s,i]=n;this._damage(s,i,r,o)}}autoscale(t,n){let r;if(t===0||n===0)r=0;else{let o=this._viewportLoc,s=t/n;o.w/o.h>=s?r=t/o.w:r=n/o.h}this._rescale(r)}_rescale(t){this._scale=t;let n=this._viewportLoc,r=t*n.w+"px",o=t*n.h+"px";(this._target.style.width!==r||this._target.style.height!==o)&&(this._target.style.width=r,this._target.style.height=o)}_setFillColor(t){let n="rgb("+t[0]+","+t[1]+","+t[2]+")";n!==this._prevDrawStyle&&(this._drawCtx.fillStyle=n,this._prevDrawStyle=n)}_renderQPush(t){this._renderQ.push(t),this._renderQ.length===1&&this._scanRenderQ()}_resumeRenderQ(){this.removeEventListener("load",this._noVNCDisplay._resumeRenderQ),this._noVNCDisplay._scanRenderQ()}_scanRenderQ(){let t=!0;for(;t&&this._renderQ.length>0;){let n=this._renderQ[0];switch(n.type){case"flip":this.flip(!0);break;case"copy":this.copyImage(n.oldX,n.oldY,n.x,n.y,n.width,n.height,!0);break;case"fill":this.fillRect(n.x,n.y,n.width,n.height,n.color,!0);break;case"blit":this.blitImage(n.x,n.y,n.width,n.height,n.data,0,!0);break;case"img":if(n.img.complete){if(n.img.width!==n.width||n.img.height!==n.height){Me("Decoded image has incorrect dimensions. Got "+n.img.width+"x"+n.img.height+". Expected "+n.width+"x"+n.height+".");return}this.drawImage(n.img,n.x,n.y),n.img.src=""}else n.img._noVNCDisplay=this,n.img.addEventListener("load",this._resumeRenderQ),t=!1;break;case"frame":if(n.frame.ready){let r=n.frame.frame;(r.codedWidth<n.width||r.codedHeight<n.height)&&Ye("Decoded video frame does not cover its full rectangle area. Expecting at least "+n.width+"x"+n.height+" but got "+r.codedWidth+"x"+r.codedHeight);let o=0,s=0,i=n.width,a=n.height,u=n.x,c=n.y,d=i,p=a;this.drawImage(r,o,s,i,a,u,c,d,p),r.close()}else{let r=this;n.frame.promise.then(()=>{r._scanRenderQ()}),t=!1}break}t&&this._renderQ.shift()}this._renderQ.length===0&&this._flushPromise!==null&&(this._flushResolve(),this._flushPromise=null,this._flushResolve=null)}};function Xt(e,t,n,r,o){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),o);return}for(var s=0;s<r;s++)e[o+s]=t[n+s]}var Fo=Uint8Array,bt=Uint16Array,Ii=Int32Array;function zo(e,t,n,r){for(var o=e&65535|0,s=e>>>16&65535|0,i=0;n!==0;){i=n>2e3?2e3:n,n-=i;do o=o+t[r++]|0,s=s+o|0;while(--i);o%=65521,s%=65521}return o|s<<16|0}function Ue(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var Bz=Ue();var lc=30,H2=12;function Ff(e,t){var n,r,o,s,i,a,u,c,d,p,f,h,g,x,b,v,w,C,y,T,N,S,$,P,L;n=e.state,r=e.next_in,P=e.input,o=r+(e.avail_in-5),s=e.next_out,L=e.output,i=s-(t-e.avail_out),a=s+(e.avail_out-257),u=n.dmax,c=n.wsize,d=n.whave,p=n.wnext,f=n.window,h=n.hold,g=n.bits,x=n.lencode,b=n.distcode,v=(1<<n.lenbits)-1,w=(1<<n.distbits)-1;e:do{g<15&&(h+=P[r++]<<g,g+=8,h+=P[r++]<<g,g+=8),C=x[h&v];t:for(;;){if(y=C>>>24,h>>>=y,g-=y,y=C>>>16&255,y===0)L[s++]=C&65535;else if(y&16){T=C&65535,y&=15,y&&(g<y&&(h+=P[r++]<<g,g+=8),T+=h&(1<<y)-1,h>>>=y,g-=y),g<15&&(h+=P[r++]<<g,g+=8,h+=P[r++]<<g,g+=8),C=b[h&w];n:for(;;){if(y=C>>>24,h>>>=y,g-=y,y=C>>>16&255,y&16){if(N=C&65535,y&=15,g<y&&(h+=P[r++]<<g,g+=8,g<y&&(h+=P[r++]<<g,g+=8)),N+=h&(1<<y)-1,N>u){e.msg="invalid distance too far back",n.mode=lc;break e}if(h>>>=y,g-=y,y=s-i,N>y){if(y=N-y,y>d&&n.sane){e.msg="invalid distance too far back",n.mode=lc;break e}if(S=0,$=f,p===0){if(S+=c-y,y<T){T-=y;do L[s++]=f[S++];while(--y);S=s-N,$=L}}else if(p<y){if(S+=c+p-y,y-=p,y<T){T-=y;do L[s++]=f[S++];while(--y);if(S=0,p<T){y=p,T-=y;do L[s++]=f[S++];while(--y);S=s-N,$=L}}}else if(S+=p-y,y<T){T-=y;do L[s++]=f[S++];while(--y);S=s-N,$=L}for(;T>2;)L[s++]=$[S++],L[s++]=$[S++],L[s++]=$[S++],T-=3;T&&(L[s++]=$[S++],T>1&&(L[s++]=$[S++]))}else{S=s-N;do L[s++]=L[S++],L[s++]=L[S++],L[s++]=L[S++],T-=3;while(T>2);T&&(L[s++]=L[S++],T>1&&(L[s++]=L[S++]))}}else if((y&64)===0){C=b[(C&65535)+(h&(1<<y)-1)];continue n}else{e.msg="invalid distance code",n.mode=lc;break e}break}}else if((y&64)===0){C=x[(C&65535)+(h&(1<<y)-1)];continue t}else if(y&32){n.mode=H2;break e}else{e.msg="invalid literal/length code",n.mode=lc;break e}break}}while(r<o&&s<a);T=g>>3,r-=T,g-=T<<3,h&=(1<<g)-1,e.next_in=r,e.next_out=s,e.avail_in=r<o?5+(o-r):5-(r-o),e.avail_out=s<a?257+(a-s):257-(s-a),n.hold=h,n.bits=g}var Ko=15,xv=852,bv=592,yv=0,zf=1,_v=2,V2=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Z2=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],W2=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],j2=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function Lr(e,t,n,r,o,s,i,a){var u=a.bits,c=0,d=0,p=0,f=0,h=0,g=0,x=0,b=0,v=0,w=0,C,y,T,N,S,$=null,P=0,L,ne=new bt(Ko+1),se=new bt(Ko+1),_e=null,ie=0,Q,j,G;for(c=0;c<=Ko;c++)ne[c]=0;for(d=0;d<r;d++)ne[t[n+d]]++;for(h=u,f=Ko;f>=1&&ne[f]===0;f--);if(h>f&&(h=f),f===0)return o[s++]=1<<24|64<<16|0,o[s++]=1<<24|64<<16|0,a.bits=1,0;for(p=1;p<f&&ne[p]===0;p++);for(h<p&&(h=p),b=1,c=1;c<=Ko;c++)if(b<<=1,b-=ne[c],b<0)return-1;if(b>0&&(e===yv||f!==1))return-1;for(se[1]=0,c=1;c<Ko;c++)se[c+1]=se[c]+ne[c];for(d=0;d<r;d++)t[n+d]!==0&&(i[se[t[n+d]]++]=d);if(e===yv?($=_e=i,L=19):e===zf?($=V2,P-=257,_e=Z2,ie-=257,L=256):($=W2,_e=j2,L=-1),w=0,d=0,c=p,S=s,g=h,x=0,T=-1,v=1<<h,N=v-1,e===zf&&v>xv||e===_v&&v>bv)return 1;for(;;){Q=c-x,i[d]<L?(j=0,G=i[d]):i[d]>L?(j=_e[ie+i[d]],G=$[P+i[d]]):(j=96,G=0),C=1<<c-x,y=1<<g,p=y;do y-=C,o[S+(w>>x)+y]=Q<<24|j<<16|G|0;while(y!==0);for(C=1<<c-1;w&C;)C>>=1;if(C!==0?(w&=C-1,w+=C):w=0,d++,--ne[c]===0){if(c===f)break;c=t[n+i[d]]}if(c>h&&(w&N)!==T){for(x===0&&(x=h),S+=p,g=c-x,b=1<<g;g+x<f&&(b-=ne[g+x],!(b<=0));)g++,b<<=1;if(v+=1<<g,e===zf&&v>xv||e===_v&&v>bv)return 1;T=w&N,o[T]=h<<24|g<<16|S-s|0}}return w!==0&&(o[S+w]=c-x<<24|64<<16|0),a.bits=h,0}var Q2=0,Qv=1,Gv=2,vv=4,G2=5,cc=6,pc=0,Y2=1,q2=2,Mr=-2,J2=-3,wv=-4,eR=-5,kv=8,Yv=1,Sv=2,Ev=3,Nv=4,Av=5,Cv=6,Tv=7,Rv=8,$v=9,Iv=10,Pv=11,$n=12,Kf=13,Ov=14,Xf=15,Lv=16,Mv=17,Dv=18,Fv=19,uc=20,dc=21,zv=22,Kv=23,Xv=24,Bv=25,Uv=26,Bf=27,Hv=28,Vv=29,Ke=30,Zv=31,tR=32,nR=852,rR=592,oR=15,sR=oR;function Wv(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function iR(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new bt(320),this.work=new bt(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function aR(e){var t;return!e||!e.state?Mr:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Yv,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Ii(nR),t.distcode=t.distdyn=new Ii(rR),t.sane=1,t.back=-1,pc)}function Vf(e){var t;return!e||!e.state?Mr:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,aR(e))}function lR(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Mr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Vf(e))}function cR(e,t){var n,r;return e?(r=new iR,e.state=r,r.window=null,n=lR(e,t),n!==pc&&(e.state=null),n):Mr}function qv(e){return cR(e,sR)}var jv=!0,Uf,Hf;function uR(e){if(jv){var t;for(Uf=new Ii(512),Hf=new Ii(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Lr(Qv,e.lens,0,288,Uf,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Lr(Gv,e.lens,0,32,Hf,0,e.work,{bits:5}),jv=!1}e.lencode=Uf,e.lenbits=9,e.distcode=Hf,e.distbits=5}function dR(e,t,n,r){var o,s=e.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Fo(s.wsize)),r>=s.wsize?(Xt(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(o=s.wsize-s.wnext,o>r&&(o=r),Xt(s.window,t,n-r,o,s.wnext),r-=o,r?(Xt(s.window,t,n-r,r,0),s.wnext=r,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=o))),0}function Jv(e,t){var n,r,o,s,i,a,u,c,d,p,f,h,g,x,b=0,v,w,C,y,T,N,S,$,P=new Fo(4),L,ne,se=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return Mr;n=e.state,n.mode===$n&&(n.mode=Kf),i=e.next_out,o=e.output,u=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,c=n.hold,d=n.bits,p=a,f=u,$=pc;e:for(;;)switch(n.mode){case Yv:if(n.wrap===0){n.mode=Kf;break}for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(n.wrap&2&&c===35615){n.check=0,P[0]=c&255,P[1]=c>>>8&255,n.check=Ue(n.check,P,2,0),c=0,d=0,n.mode=Sv;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=Ke;break}if((c&15)!==kv){e.msg="unknown compression method",n.mode=Ke;break}if(c>>>=4,d-=4,S=(c&15)+8,n.wbits===0)n.wbits=S;else if(S>n.wbits){e.msg="invalid window size",n.mode=Ke;break}n.dmax=1<<S,e.adler=n.check=1,n.mode=c&512?Iv:$n,c=0,d=0;break;case Sv:for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(n.flags=c,(n.flags&255)!==kv){e.msg="unknown compression method",n.mode=Ke;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=Ke;break}n.head&&(n.head.text=c>>8&1),n.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,n.check=Ue(n.check,P,2,0)),c=0,d=0,n.mode=Ev;case Ev:for(;d<32;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.head&&(n.head.time=c),n.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,P[2]=c>>>16&255,P[3]=c>>>24&255,n.check=Ue(n.check,P,4,0)),c=0,d=0,n.mode=Nv;case Nv:for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.head&&(n.head.xflags=c&255,n.head.os=c>>8),n.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,n.check=Ue(n.check,P,2,0)),c=0,d=0,n.mode=Av;case Av:if(n.flags&1024){for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.length=c,n.head&&(n.head.extra_len=c),n.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,n.check=Ue(n.check,P,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=Cv;case Cv:if(n.flags&1024&&(h=n.length,h>a&&(h=a),h&&(n.head&&(S=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Xt(n.head.extra,r,s,h,S)),n.flags&512&&(n.check=Ue(n.check,r,h,s)),a-=h,s+=h,n.length-=h),n.length))break e;n.length=0,n.mode=Tv;case Tv:if(n.flags&2048){if(a===0)break e;h=0;do S=r[s+h++],n.head&&S&&n.length<65536&&(n.head.name+=String.fromCharCode(S));while(S&&h<a);if(n.flags&512&&(n.check=Ue(n.check,r,h,s)),a-=h,s+=h,S)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=Rv;case Rv:if(n.flags&4096){if(a===0)break e;h=0;do S=r[s+h++],n.head&&S&&n.length<65536&&(n.head.comment+=String.fromCharCode(S));while(S&&h<a);if(n.flags&512&&(n.check=Ue(n.check,r,h,s)),a-=h,s+=h,S)break e}else n.head&&(n.head.comment=null);n.mode=$v;case $v:if(n.flags&512){for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(c!==(n.check&65535)){e.msg="header crc mismatch",n.mode=Ke;break}c=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=$n;break;case Iv:for(;d<32;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}e.adler=n.check=Wv(c),c=0,d=0,n.mode=Pv;case Pv:if(n.havedict===0)return e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=a,n.hold=c,n.bits=d,q2;e.adler=n.check=1,n.mode=$n;case $n:if(t===G2||t===cc)break e;case Kf:if(n.last){c>>>=d&7,d-=d&7,n.mode=Bf;break}for(;d<3;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}switch(n.last=c&1,c>>>=1,d-=1,c&3){case 0:n.mode=Ov;break;case 1:if(uR(n),n.mode=uc,t===cc){c>>>=2,d-=2;break e}break;case 2:n.mode=Mv;break;case 3:e.msg="invalid block type",n.mode=Ke}c>>>=2,d-=2;break;case Ov:for(c>>>=d&7,d-=d&7;d<32;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",n.mode=Ke;break}if(n.length=c&65535,c=0,d=0,n.mode=Xf,t===cc)break e;case Xf:n.mode=Lv;case Lv:if(h=n.length,h){if(h>a&&(h=a),h>u&&(h=u),h===0)break e;Xt(o,r,s,h,i),a-=h,s+=h,u-=h,i+=h,n.length-=h;break}n.mode=$n;break;case Mv:for(;d<14;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(n.nlen=(c&31)+257,c>>>=5,d-=5,n.ndist=(c&31)+1,c>>>=5,d-=5,n.ncode=(c&15)+4,c>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Ke;break}n.have=0,n.mode=Dv;case Dv:for(;n.have<n.ncode;){for(;d<3;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.lens[se[n.have++]]=c&7,c>>>=3,d-=3}for(;n.have<19;)n.lens[se[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,L={bits:n.lenbits},$=Lr(Q2,n.lens,0,19,n.lencode,0,n.work,L),n.lenbits=L.bits,$){e.msg="invalid code lengths set",n.mode=Ke;break}n.have=0,n.mode=Fv;case Fv:for(;n.have<n.nlen+n.ndist;){for(;b=n.lencode[c&(1<<n.lenbits)-1],v=b>>>24,w=b>>>16&255,C=b&65535,!(v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(C<16)c>>>=v,d-=v,n.lens[n.have++]=C;else{if(C===16){for(ne=v+2;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(c>>>=v,d-=v,n.have===0){e.msg="invalid bit length repeat",n.mode=Ke;break}S=n.lens[n.have-1],h=3+(c&3),c>>>=2,d-=2}else if(C===17){for(ne=v+3;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}c>>>=v,d-=v,S=0,h=3+(c&7),c>>>=3,d-=3}else{for(ne=v+7;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}c>>>=v,d-=v,S=0,h=11+(c&127),c>>>=7,d-=7}if(n.have+h>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Ke;break}for(;h--;)n.lens[n.have++]=S}}if(n.mode===Ke)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Ke;break}if(n.lenbits=9,L={bits:n.lenbits},$=Lr(Qv,n.lens,0,n.nlen,n.lencode,0,n.work,L),n.lenbits=L.bits,$){e.msg="invalid literal/lengths set",n.mode=Ke;break}if(n.distbits=6,n.distcode=n.distdyn,L={bits:n.distbits},$=Lr(Gv,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,L),n.distbits=L.bits,$){e.msg="invalid distances set",n.mode=Ke;break}if(n.mode=uc,t===cc)break e;case uc:n.mode=dc;case dc:if(a>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=a,n.hold=c,n.bits=d,Ff(e,f),i=e.next_out,o=e.output,u=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,c=n.hold,d=n.bits,n.mode===$n&&(n.back=-1);break}for(n.back=0;b=n.lencode[c&(1<<n.lenbits)-1],v=b>>>24,w=b>>>16&255,C=b&65535,!(v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(w&&(w&240)===0){for(y=v,T=w,N=C;b=n.lencode[N+((c&(1<<y+T)-1)>>y)],v=b>>>24,w=b>>>16&255,C=b&65535,!(y+v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}c>>>=y,d-=y,n.back+=y}if(c>>>=v,d-=v,n.back+=v,n.length=C,w===0){n.mode=Uv;break}if(w&32){n.back=-1,n.mode=$n;break}if(w&64){e.msg="invalid literal/length code",n.mode=Ke;break}n.extra=w&15,n.mode=zv;case zv:if(n.extra){for(ne=n.extra;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Kv;case Kv:for(;b=n.distcode[c&(1<<n.distbits)-1],v=b>>>24,w=b>>>16&255,C=b&65535,!(v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if((w&240)===0){for(y=v,T=w,N=C;b=n.distcode[N+((c&(1<<y+T)-1)>>y)],v=b>>>24,w=b>>>16&255,C=b&65535,!(y+v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}c>>>=y,d-=y,n.back+=y}if(c>>>=v,d-=v,n.back+=v,w&64){e.msg="invalid distance code",n.mode=Ke;break}n.offset=C,n.extra=w&15,n.mode=Xv;case Xv:if(n.extra){for(ne=n.extra;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Ke;break}n.mode=Bv;case Bv:if(u===0)break e;if(h=f-u,n.offset>h){if(h=n.offset-h,h>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Ke;break}h>n.wnext?(h-=n.wnext,g=n.wsize-h):g=n.wnext-h,h>n.length&&(h=n.length),x=n.window}else x=o,g=i-n.offset,h=n.length;h>u&&(h=u),u-=h,n.length-=h;do o[i++]=x[g++];while(--h);n.length===0&&(n.mode=dc);break;case Uv:if(u===0)break e;o[i++]=n.length,u--,n.mode=dc;break;case Bf:if(n.wrap){for(;d<32;){if(a===0)break e;a--,c|=r[s++]<<d,d+=8}if(f-=u,e.total_out+=f,n.total+=f,f&&(e.adler=n.check=n.flags?Ue(n.check,o,f,i-f):zo(n.check,o,f,i-f)),f=u,(n.flags?c:Wv(c))!==n.check){e.msg="incorrect data check",n.mode=Ke;break}c=0,d=0}n.mode=Hv;case Hv:if(n.wrap&&n.flags){for(;d<32;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(c!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=Ke;break}c=0,d=0}n.mode=Vv;case Vv:$=Y2;break e;case Ke:$=J2;break e;case Zv:return wv;case tR:default:return Mr}return e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=a,n.hold=c,n.bits=d,(n.wsize||f!==e.avail_out&&n.mode<Ke&&(n.mode<Bf||t!==vv))&&dR(e,e.output,e.next_out,f-e.avail_out)?(n.mode=Zv,wv):(p-=e.avail_in,f-=e.avail_out,e.total_in+=p,e.total_out+=f,n.total+=f,n.wrap&&f&&(e.adler=n.check=n.flags?Ue(n.check,o,f,e.next_out-f):zo(n.check,o,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===$n?128:0)+(n.mode===uc||n.mode===Xf?256:0),(p===0&&f===0||t===vv)&&$===pc&&($=eR),$)}function Pi(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Yt=class{constructor(){this.strm=new Pi,this.chunkSize=1024*10*10,this.strm.output=new Uint8Array(this.chunkSize),qv(this.strm)}setInput(t){t?(this.strm.input=t,this.strm.avail_in=this.strm.input.length,this.strm.next_in=0):(this.strm.input=null,this.strm.avail_in=0,this.strm.next_in=0)}inflate(t){if(t>this.chunkSize&&(this.chunkSize=t,this.strm.output=new Uint8Array(this.chunkSize)),this.strm.next_out=0,this.strm.avail_out=t,Jv(this.strm,0)<0)throw new Error("zlib inflate failed");if(this.strm.next_out!=t)throw new Error("Incomplete zlib block");return new Uint8Array(this.strm.output.buffer,0,this.strm.next_out)}reset(){Vf(this.strm)}};var pR=4,ew=0,tw=1,fR=2;function Bo(e){for(var t=e.length;--t>=0;)e[t]=0}var hR=0,aw=1,mR=2,gR=3,xR=258,qf=29,zi=256,Li=zi+1+qf,Xo=30,Jf=19,lw=2*Li+1,Dr=15,Zf=16,bR=7,eh=256,cw=16,uw=17,dw=18,Gf=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],fc=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],yR=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],pw=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],_R=512,In=new Array((Li+2)*2);Bo(In);var Oi=new Array(Xo*2);Bo(Oi);var Mi=new Array(_R);Bo(Mi);var Di=new Array(xR-gR+1);Bo(Di);var th=new Array(qf);Bo(th);var hc=new Array(Xo);Bo(hc);function Wf(e,t,n,r,o){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=o,this.has_stree=e&&e.length}var fw,hw,mw;function jf(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function gw(e){return e<256?Mi[e]:Mi[256+(e>>>7)]}function Fi(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Nt(e,t,n){e.bi_valid>Zf-n?(e.bi_buf|=t<<e.bi_valid&65535,Fi(e,e.bi_buf),e.bi_buf=t>>Zf-e.bi_valid,e.bi_valid+=n-Zf):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function dn(e,t,n){Nt(e,n[t*2],n[t*2+1])}function xw(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function vR(e){e.bi_valid===16?(Fi(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function wR(e,t){var n=t.dyn_tree,r=t.max_code,o=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,u=t.stat_desc.max_length,c,d,p,f,h,g,x=0;for(f=0;f<=Dr;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<lw;c++)d=e.heap[c],f=n[n[d*2+1]*2+1]+1,f>u&&(f=u,x++),n[d*2+1]=f,!(d>r)&&(e.bl_count[f]++,h=0,d>=a&&(h=i[d-a]),g=n[d*2],e.opt_len+=g*(f+h),s&&(e.static_len+=g*(o[d*2+1]+h)));if(x!==0){do{for(f=u-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[u]--,x-=2}while(x>0);for(f=u;f!==0;f--)for(d=e.bl_count[f];d!==0;)p=e.heap[--c],!(p>r)&&(n[p*2+1]!==f&&(e.opt_len+=(f-n[p*2+1])*n[p*2],n[p*2+1]=f),d--)}}function bw(e,t,n){var r=new Array(Dr+1),o=0,s,i;for(s=1;s<=Dr;s++)r[s]=o=o+n[s-1]<<1;for(i=0;i<=t;i++){var a=e[i*2+1];a!==0&&(e[i*2]=xw(r[a]++,a))}}function kR(){var e,t,n,r,o,s=new Array(Dr+1);for(n=0,r=0;r<qf-1;r++)for(th[r]=n,e=0;e<1<<Gf[r];e++)Di[n++]=r;for(Di[n-1]=r,o=0,r=0;r<16;r++)for(hc[r]=o,e=0;e<1<<fc[r];e++)Mi[o++]=r;for(o>>=7;r<Xo;r++)for(hc[r]=o<<7,e=0;e<1<<fc[r]-7;e++)Mi[256+o++]=r;for(t=0;t<=Dr;t++)s[t]=0;for(e=0;e<=143;)In[e*2+1]=8,e++,s[8]++;for(;e<=255;)In[e*2+1]=9,e++,s[9]++;for(;e<=279;)In[e*2+1]=7,e++,s[7]++;for(;e<=287;)In[e*2+1]=8,e++,s[8]++;for(bw(In,Li+1,s),e=0;e<Xo;e++)Oi[e*2+1]=5,Oi[e*2]=xw(e,5);fw=new Wf(In,Gf,zi+1,Li,Dr),hw=new Wf(Oi,fc,0,Xo,Dr),mw=new Wf(new Array(0),yR,0,Jf,bR)}function yw(e){var t;for(t=0;t<Li;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Xo;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Jf;t++)e.bl_tree[t*2]=0;e.dyn_ltree[eh*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function _w(e){e.bi_valid>8?Fi(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function SR(e,t,n,r){_w(e),r&&(Fi(e,n),Fi(e,~n)),Xt(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function nw(e,t,n,r){var o=t*2,s=n*2;return e[o]<e[s]||e[o]===e[s]&&r[t]<=r[n]}function Qf(e,t,n){for(var r=e.heap[n],o=n<<1;o<=e.heap_len&&(o<e.heap_len&&nw(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!nw(t,r,e.heap[o],e.depth));)e.heap[n]=e.heap[o],n=o,o<<=1;e.heap[n]=r}function rw(e,t,n){var r,o,s=0,i,a;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+s*2]<<8|e.pending_buf[e.d_buf+s*2+1],o=e.pending_buf[e.l_buf+s],s++,r===0?dn(e,o,t):(i=Di[o],dn(e,i+zi+1,t),a=Gf[i],a!==0&&(o-=th[i],Nt(e,o,a)),r--,i=gw(r),dn(e,i,n),a=fc[i],a!==0&&(r-=hc[i],Nt(e,r,a)));while(s<e.last_lit);dn(e,eh,t)}function Yf(e,t){var n=t.dyn_tree,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.elems,i,a,u=-1,c;for(e.heap_len=0,e.heap_max=lw,i=0;i<s;i++)n[i*2]!==0?(e.heap[++e.heap_len]=u=i,e.depth[i]=0):n[i*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=u<2?++u:0,n[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=r[c*2+1]);for(t.max_code=u,i=e.heap_len>>1;i>=1;i--)Qf(e,n,i);c=s;do i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Qf(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=a,n[c*2]=n[i*2]+n[a*2],e.depth[c]=(e.depth[i]>=e.depth[a]?e.depth[i]:e.depth[a])+1,n[i*2+1]=n[a*2+1]=c,e.heap[1]=c++,Qf(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],wR(e,t),bw(n,u,e.bl_count)}function ow(e,t,n){var r,o=-1,s,i=t[1],a=0,u=7,c=4;for(i===0&&(u=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)s=i,i=t[(r+1)*2+1],!(++a<u&&s===i)&&(a<c?e.bl_tree[s*2]+=a:s!==0?(s!==o&&e.bl_tree[s*2]++,e.bl_tree[cw*2]++):a<=10?e.bl_tree[uw*2]++:e.bl_tree[dw*2]++,a=0,o=s,i===0?(u=138,c=3):s===i?(u=6,c=3):(u=7,c=4))}function sw(e,t,n){var r,o=-1,s,i=t[1],a=0,u=7,c=4;for(i===0&&(u=138,c=3),r=0;r<=n;r++)if(s=i,i=t[(r+1)*2+1],!(++a<u&&s===i)){if(a<c)do dn(e,s,e.bl_tree);while(--a!==0);else s!==0?(s!==o&&(dn(e,s,e.bl_tree),a--),dn(e,cw,e.bl_tree),Nt(e,a-3,2)):a<=10?(dn(e,uw,e.bl_tree),Nt(e,a-3,3)):(dn(e,dw,e.bl_tree),Nt(e,a-11,7));a=0,o=s,i===0?(u=138,c=3):s===i?(u=6,c=3):(u=7,c=4)}}function ER(e){var t;for(ow(e,e.dyn_ltree,e.l_desc.max_code),ow(e,e.dyn_dtree,e.d_desc.max_code),Yf(e,e.bl_desc),t=Jf-1;t>=3&&e.bl_tree[pw[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function NR(e,t,n,r){var o;for(Nt(e,t-257,5),Nt(e,n-1,5),Nt(e,r-4,4),o=0;o<r;o++)Nt(e,e.bl_tree[pw[o]*2+1],3);sw(e,e.dyn_ltree,t-1),sw(e,e.dyn_dtree,n-1)}function AR(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return ew;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return tw;for(n=32;n<zi;n++)if(e.dyn_ltree[n*2]!==0)return tw;return ew}var iw=!1;function vw(e){iw||(kR(),iw=!0),e.l_desc=new jf(e.dyn_ltree,fw),e.d_desc=new jf(e.dyn_dtree,hw),e.bl_desc=new jf(e.bl_tree,mw),e.bi_buf=0,e.bi_valid=0,yw(e)}function nh(e,t,n,r){Nt(e,(hR<<1)+(r?1:0),3),SR(e,t,n,!0)}function ww(e){Nt(e,aw<<1,3),dn(e,eh,In),vR(e)}function kw(e,t,n,r){var o,s,i=0;e.level>0?(e.strm.data_type===fR&&(e.strm.data_type=AR(e)),Yf(e,e.l_desc),Yf(e,e.d_desc),i=ER(e),o=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=o&&(o=s)):o=s=n+5,n+4<=o&&t!==-1?nh(e,t,n,r):e.strategy===pR||s===o?(Nt(e,(aw<<1)+(r?1:0),3),rw(e,In,Oi)):(Nt(e,(mR<<1)+(r?1:0),3),NR(e,e.l_desc.max_code+1,e.d_desc.max_code+1,i+1),rw(e,e.dyn_ltree,e.dyn_dtree)),yw(e),r&&_w(e)}function Pn(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(Di[n]+zi+1)*2]++,e.dyn_dtree[gw(t)*2]++),e.last_lit===e.lit_bufsize-1}var Sw={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};var Xr=0,TR=1,xc=3,nr=4,Ew=5,Fr=0,Nw=1,Zo=-2;var rh=-5,ch=-1,RR=1,mc=2,$R=3,IR=4,PR=0,OR=2,bc=8,LR=9,MR=15,DR=8,FR=29,zR=256,lh=zR+1+FR,KR=30,XR=19,BR=2*lh+1,UR=15,Ae=3,tr=258,qt=tr+Ae+1,HR=32,Tw=42,Aw=69,oh=73,sh=91,ih=103,Xi=113,gc=666,qe=1,Bi=2,Kr=3,Wo=4,VR=3;function Ho(e,t){return e.msg=Sw[t],t}function Cw(e){return(e<<1)-(e>4?9:0)}function zr(e){for(var t=e.length;--t>=0;)e[t]=0}function er(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(Xt(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function st(e,t){kw(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,er(e.strm)}function Ne(e,t){e.pending_buf[e.pending++]=t}function Ki(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function ZR(e,t,n,r){var o=e.avail_in;return o>r&&(o=r),o===0?0:(e.avail_in-=o,Xt(t,e.input,e.next_in,o,n),e.state.wrap===1?e.adler=zo(e.adler,t,o,n):e.state.wrap===2&&(e.adler=Ue(e.adler,t,o,n)),e.next_in+=o,e.total_in+=o,o)}function Rw(e,t){var n=e.max_chain_length,r=e.strstart,o,s,i=e.prev_length,a=e.nice_match,u=e.strstart>e.w_size-qt?e.strstart-(e.w_size-qt):0,c=e.window,d=e.w_mask,p=e.prev,f=e.strstart+tr,h=c[r+i-1],g=c[r+i];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do if(o=t,!(c[o+i]!==g||c[o+i-1]!==h||c[o]!==c[r]||c[++o]!==c[r+1])){r+=2,o++;do;while(c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&r<f);if(s=tr-(f-r),r=f-tr,s>i){if(e.match_start=t,i=s,s>=a)break;h=c[r+i-1],g=c[r+i]}}while((t=p[t&d])>u&&--n!==0);return i<=e.lookahead?i:e.lookahead}function Ui(e){var t=e.w_size,n,r,o,s,i;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-qt)){Xt(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do o=e.head[--n],e.head[n]=o>=t?o-t:0;while(--r);r=t,n=r;do o=e.prev[--n],e.prev[n]=o>=t?o-t:0;while(--r);s+=t}if(e.strm.avail_in===0)break;if(r=ZR(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=r,e.lookahead+e.insert>=Ae)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=(e.ins_h<<e.hash_shift^e.window[i+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[i+Ae-1])&e.hash_mask,e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<Ae)););}while(e.lookahead<qt&&e.strm.avail_in!==0)}function WR(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Ui(e),e.lookahead===0&&t===Xr)return qe;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,st(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-qt&&(st(e,!1),e.strm.avail_out===0))return qe}return e.insert=0,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):(e.strstart>e.block_start&&(st(e,!1),e.strm.avail_out===0),qe)}function ah(e,t){for(var n,r;;){if(e.lookahead<qt){if(Ui(e),e.lookahead<qt&&t===Xr)return qe;if(e.lookahead===0)break}if(n=0,e.lookahead>=Ae&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ae-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-qt&&(e.match_length=Rw(e,n)),e.match_length>=Ae)if(r=Pn(e,e.strstart-e.match_start,e.match_length-Ae),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Ae){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ae-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=Pn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(st(e,!1),e.strm.avail_out===0))return qe}return e.insert=e.strstart<Ae-1?e.strstart:Ae-1,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):e.last_lit&&(st(e,!1),e.strm.avail_out===0)?qe:Bi}function Uo(e,t){for(var n,r,o;;){if(e.lookahead<qt){if(Ui(e),e.lookahead<qt&&t===Xr)return qe;if(e.lookahead===0)break}if(n=0,e.lookahead>=Ae&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ae-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Ae-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-qt&&(e.match_length=Rw(e,n),e.match_length<=5&&(e.strategy===RR||e.match_length===Ae&&e.strstart-e.match_start>4096)&&(e.match_length=Ae-1)),e.prev_length>=Ae&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-Ae,r=Pn(e,e.strstart-1-e.prev_match,e.prev_length-Ae),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ae-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Ae-1,e.strstart++,r&&(st(e,!1),e.strm.avail_out===0))return qe}else if(e.match_available){if(r=Pn(e,0,e.window[e.strstart-1]),r&&st(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return qe}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Pn(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Ae-1?e.strstart:Ae-1,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):e.last_lit&&(st(e,!1),e.strm.avail_out===0)?qe:Bi}function jR(e,t){for(var n,r,o,s,i=e.window;;){if(e.lookahead<=tr){if(Ui(e),e.lookahead<=tr&&t===Xr)return qe;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Ae&&e.strstart>0&&(o=e.strstart-1,r=i[o],r===i[++o]&&r===i[++o]&&r===i[++o])){s=e.strstart+tr;do;while(r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&o<s);e.match_length=tr-(s-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Ae?(n=Pn(e,1,e.match_length-Ae),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Pn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(st(e,!1),e.strm.avail_out===0))return qe}return e.insert=0,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):e.last_lit&&(st(e,!1),e.strm.avail_out===0)?qe:Bi}function QR(e,t){for(var n;;){if(e.lookahead===0&&(Ui(e),e.lookahead===0)){if(t===Xr)return qe;break}if(e.match_length=0,n=Pn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(st(e,!1),e.strm.avail_out===0))return qe}return e.insert=0,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):e.last_lit&&(st(e,!1),e.strm.avail_out===0)?qe:Bi}function pn(e,t,n,r,o){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=o}var Vo;Vo=[new pn(0,0,0,0,WR),new pn(4,4,8,4,ah),new pn(4,5,16,8,ah),new pn(4,6,32,32,ah),new pn(4,4,16,16,Uo),new pn(8,16,32,32,Uo),new pn(8,16,128,128,Uo),new pn(8,32,128,256,Uo),new pn(32,128,258,1024,Uo),new pn(32,258,258,4096,Uo)];function GR(e){e.window_size=2*e.w_size,zr(e.head),e.max_lazy_match=Vo[e.level].max_lazy,e.good_match=Vo[e.level].good_length,e.nice_match=Vo[e.level].nice_length,e.max_chain_length=Vo[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Ae-1,e.match_available=0,e.ins_h=0}function YR(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=bc,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new bt(BR*2),this.dyn_dtree=new bt((2*KR+1)*2),this.bl_tree=new bt((2*XR+1)*2),zr(this.dyn_ltree),zr(this.dyn_dtree),zr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new bt(UR+1),this.heap=new bt(2*lh+1),zr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new bt(2*lh+1),zr(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function qR(e){var t;return!e||!e.state?Ho(e,Zo):(e.total_in=e.total_out=0,e.data_type=OR,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Tw:Xi,e.adler=t.wrap===2?0:1,t.last_flush=Xr,vw(t),Fr)}function JR(e){var t=qR(e);return t===Fr&&GR(e.state),t}function e$(e,t,n,r,o,s){if(!e)return Zo;var i=1;if(t===ch&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),o<1||o>LR||n!==bc||r<8||r>15||t<0||t>9||s<0||s>IR)return Ho(e,Zo);r===8&&(r=9);var a=new YR;return e.state=a,a.strm=e,a.wrap=i,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=o+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+Ae-1)/Ae),a.window=new Fo(a.w_size*2),a.head=new bt(a.hash_size),a.prev=new bt(a.w_size),a.lit_bufsize=1<<o+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Fo(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=t,a.strategy=s,a.method=n,JR(e)}function $w(e,t){return e$(e,t,bc,MR,DR,PR)}function uh(e,t){var n,r,o,s;if(!e||!e.state||t>Ew||t<0)return e?Ho(e,Zo):Zo;if(r=e.state,!e.output||!e.input&&e.avail_in!==0||r.status===gc&&t!==nr)return Ho(e,e.avail_out===0?rh:Zo);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===Tw)if(r.wrap===2)e.adler=0,Ne(r,31),Ne(r,139),Ne(r,8),r.gzhead?(Ne(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Ne(r,r.gzhead.time&255),Ne(r,r.gzhead.time>>8&255),Ne(r,r.gzhead.time>>16&255),Ne(r,r.gzhead.time>>24&255),Ne(r,r.level===9?2:r.strategy>=mc||r.level<2?4:0),Ne(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(Ne(r,r.gzhead.extra.length&255),Ne(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Ue(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=Aw):(Ne(r,0),Ne(r,0),Ne(r,0),Ne(r,0),Ne(r,0),Ne(r,r.level===9?2:r.strategy>=mc||r.level<2?4:0),Ne(r,VR),r.status=Xi);else{var i=bc+(r.w_bits-8<<4)<<8,a=-1;r.strategy>=mc||r.level<2?a=0:r.level<6?a=1:r.level===6?a=2:a=3,i|=a<<6,r.strstart!==0&&(i|=HR),i+=31-i%31,r.status=Xi,Ki(r,i),r.strstart!==0&&(Ki(r,e.adler>>>16),Ki(r,e.adler&65535)),e.adler=1}if(r.status===Aw)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),er(e),o=r.pending,r.pending===r.pending_buf_size));)Ne(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=oh)}else r.status=oh;if(r.status===oh)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),er(e),o=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindex<r.gzhead.name.length?s=r.gzhead.name.charCodeAt(r.gzindex++)&255:s=0,Ne(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),s===0&&(r.gzindex=0,r.status=sh)}else r.status=sh;if(r.status===sh)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),er(e),o=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindex<r.gzhead.comment.length?s=r.gzhead.comment.charCodeAt(r.gzindex++)&255:s=0,Ne(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),s===0&&(r.status=ih)}else r.status=ih;if(r.status===ih&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&er(e),r.pending+2<=r.pending_buf_size&&(Ne(r,e.adler&255),Ne(r,e.adler>>8&255),e.adler=0,r.status=Xi)):r.status=Xi),r.pending!==0){if(er(e),e.avail_out===0)return r.last_flush=-1,Fr}else if(e.avail_in===0&&Cw(t)<=Cw(n)&&t!==nr)return Ho(e,rh);if(r.status===gc&&e.avail_in!==0)return Ho(e,rh);if(e.avail_in!==0||r.lookahead!==0||t!==Xr&&r.status!==gc){var u=r.strategy===mc?QR(r,t):r.strategy===$R?jR(r,t):Vo[r.level].func(r,t);if((u===Kr||u===Wo)&&(r.status=gc),u===qe||u===Kr)return e.avail_out===0&&(r.last_flush=-1),Fr;if(u===Bi&&(t===TR?ww(r):t!==Ew&&(nh(r,0,0,!1),t===xc&&(zr(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),er(e),e.avail_out===0))return r.last_flush=-1,Fr}return t!==nr?Fr:r.wrap<=0?Nw:(r.wrap===2?(Ne(r,e.adler&255),Ne(r,e.adler>>8&255),Ne(r,e.adler>>16&255),Ne(r,e.adler>>24&255),Ne(r,e.total_in&255),Ne(r,e.total_in>>8&255),Ne(r,e.total_in>>16&255),Ne(r,e.total_in>>24&255)):(Ki(r,e.adler>>>16),Ki(r,e.adler&65535)),er(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?Fr:Nw)}var Hi=class{constructor(){this.strm=new Pi,this.chunkSize=1024*10*10,this.outputBuffer=new Uint8Array(this.chunkSize),$w(this.strm,ch)}deflate(t){this.strm.input=t,this.strm.avail_in=this.strm.input.length,this.strm.next_in=0,this.strm.output=this.outputBuffer,this.strm.avail_out=this.chunkSize,this.strm.next_out=0;let n=uh(this.strm,xc),r=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);if(n<0)throw new Error("zlib deflate failed");if(this.strm.avail_in>0){let o=[r],s=r.length;do{if(this.strm.output=new Uint8Array(this.chunkSize),this.strm.next_out=0,this.strm.avail_out=this.chunkSize,n=uh(this.strm,xc),n<0)throw new Error("zlib deflate failed");let u=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);s+=u.length,o.push(u)}while(this.strm.avail_in>0);let i=new Uint8Array(s),a=0;for(let u=0;u<o.length;u++)i.set(o[u],a),a+=o[u].length;r=i}return this.strm.input=null,this.strm.avail_in=0,this.strm.next_in=0,r}};var A={XK_VoidSymbol:16777215,XK_BackSpace:65288,XK_Tab:65289,XK_Linefeed:65290,XK_Clear:65291,XK_Return:65293,XK_Pause:65299,XK_Scroll_Lock:65300,XK_Sys_Req:65301,XK_Escape:65307,XK_Delete:65535,XK_Multi_key:65312,XK_Codeinput:65335,XK_SingleCandidate:65340,XK_MultipleCandidate:65341,XK_PreviousCandidate:65342,XK_Kanji:65313,XK_Muhenkan:65314,XK_Henkan_Mode:65315,XK_Henkan:65315,XK_Romaji:65316,XK_Hiragana:65317,XK_Katakana:65318,XK_Hiragana_Katakana:65319,XK_Zenkaku:65320,XK_Hankaku:65321,XK_Zenkaku_Hankaku:65322,XK_Touroku:65323,XK_Massyo:65324,XK_Kana_Lock:65325,XK_Kana_Shift:65326,XK_Eisu_Shift:65327,XK_Eisu_toggle:65328,XK_Kanji_Bangou:65335,XK_Zen_Koho:65341,XK_Mae_Koho:65342,XK_Home:65360,XK_Left:65361,XK_Up:65362,XK_Right:65363,XK_Down:65364,XK_Prior:65365,XK_Page_Up:65365,XK_Next:65366,XK_Page_Down:65366,XK_End:65367,XK_Begin:65368,XK_Select:65376,XK_Print:65377,XK_Execute:65378,XK_Insert:65379,XK_Undo:65381,XK_Redo:65382,XK_Menu:65383,XK_Find:65384,XK_Cancel:65385,XK_Help:65386,XK_Break:65387,XK_Mode_switch:65406,XK_script_switch:65406,XK_Num_Lock:65407,XK_KP_Space:65408,XK_KP_Tab:65417,XK_KP_Enter:65421,XK_KP_F1:65425,XK_KP_F2:65426,XK_KP_F3:65427,XK_KP_F4:65428,XK_KP_Home:65429,XK_KP_Left:65430,XK_KP_Up:65431,XK_KP_Right:65432,XK_KP_Down:65433,XK_KP_Prior:65434,XK_KP_Page_Up:65434,XK_KP_Next:65435,XK_KP_Page_Down:65435,XK_KP_End:65436,XK_KP_Begin:65437,XK_KP_Insert:65438,XK_KP_Delete:65439,XK_KP_Equal:65469,XK_KP_Multiply:65450,XK_KP_Add:65451,XK_KP_Separator:65452,XK_KP_Subtract:65453,XK_KP_Decimal:65454,XK_KP_Divide:65455,XK_KP_0:65456,XK_KP_1:65457,XK_KP_2:65458,XK_KP_3:65459,XK_KP_4:65460,XK_KP_5:65461,XK_KP_6:65462,XK_KP_7:65463,XK_KP_8:65464,XK_KP_9:65465,XK_F1:65470,XK_F2:65471,XK_F3:65472,XK_F4:65473,XK_F5:65474,XK_F6:65475,XK_F7:65476,XK_F8:65477,XK_F9:65478,XK_F10:65479,XK_F11:65480,XK_L1:65480,XK_F12:65481,XK_L2:65481,XK_F13:65482,XK_L3:65482,XK_F14:65483,XK_L4:65483,XK_F15:65484,XK_L5:65484,XK_F16:65485,XK_L6:65485,XK_F17:65486,XK_L7:65486,XK_F18:65487,XK_L8:65487,XK_F19:65488,XK_L9:65488,XK_F20:65489,XK_L10:65489,XK_F21:65490,XK_R1:65490,XK_F22:65491,XK_R2:65491,XK_F23:65492,XK_R3:65492,XK_F24:65493,XK_R4:65493,XK_F25:65494,XK_R5:65494,XK_F26:65495,XK_R6:65495,XK_F27:65496,XK_R7:65496,XK_F28:65497,XK_R8:65497,XK_F29:65498,XK_R9:65498,XK_F30:65499,XK_R10:65499,XK_F31:65500,XK_R11:65500,XK_F32:65501,XK_R12:65501,XK_F33:65502,XK_R13:65502,XK_F34:65503,XK_R14:65503,XK_F35:65504,XK_R15:65504,XK_Shift_L:65505,XK_Shift_R:65506,XK_Control_L:65507,XK_Control_R:65508,XK_Caps_Lock:65509,XK_Shift_Lock:65510,XK_Meta_L:65511,XK_Meta_R:65512,XK_Alt_L:65513,XK_Alt_R:65514,XK_Super_L:65515,XK_Super_R:65516,XK_Hyper_L:65517,XK_Hyper_R:65518,XK_ISO_Level3_Shift:65027,XK_ISO_Next_Group:65032,XK_ISO_Prev_Group:65034,XK_ISO_First_Group:65036,XK_ISO_Last_Group:65038,XK_space:32,XK_exclam:33,XK_quotedbl:34,XK_numbersign:35,XK_dollar:36,XK_percent:37,XK_ampersand:38,XK_apostrophe:39,XK_quoteright:39,XK_parenleft:40,XK_parenright:41,XK_asterisk:42,XK_plus:43,XK_comma:44,XK_minus:45,XK_period:46,XK_slash:47,XK_0:48,XK_1:49,XK_2:50,XK_3:51,XK_4:52,XK_5:53,XK_6:54,XK_7:55,XK_8:56,XK_9:57,XK_colon:58,XK_semicolon:59,XK_less:60,XK_equal:61,XK_greater:62,XK_question:63,XK_at:64,XK_A:65,XK_B:66,XK_C:67,XK_D:68,XK_E:69,XK_F:70,XK_G:71,XK_H:72,XK_I:73,XK_J:74,XK_K:75,XK_L:76,XK_M:77,XK_N:78,XK_O:79,XK_P:80,XK_Q:81,XK_R:82,XK_S:83,XK_T:84,XK_U:85,XK_V:86,XK_W:87,XK_X:88,XK_Y:89,XK_Z:90,XK_bracketleft:91,XK_backslash:92,XK_bracketright:93,XK_asciicircum:94,XK_underscore:95,XK_grave:96,XK_quoteleft:96,XK_a:97,XK_b:98,XK_c:99,XK_d:100,XK_e:101,XK_f:102,XK_g:103,XK_h:104,XK_i:105,XK_j:106,XK_k:107,XK_l:108,XK_m:109,XK_n:110,XK_o:111,XK_p:112,XK_q:113,XK_r:114,XK_s:115,XK_t:116,XK_u:117,XK_v:118,XK_w:119,XK_x:120,XK_y:121,XK_z:122,XK_braceleft:123,XK_bar:124,XK_braceright:125,XK_asciitilde:126,XK_nobreakspace:160,XK_exclamdown:161,XK_cent:162,XK_sterling:163,XK_currency:164,XK_yen:165,XK_brokenbar:166,XK_section:167,XK_diaeresis:168,XK_copyright:169,XK_ordfeminine:170,XK_guillemotleft:171,XK_notsign:172,XK_hyphen:173,XK_registered:174,XK_macron:175,XK_degree:176,XK_plusminus:177,XK_twosuperior:178,XK_threesuperior:179,XK_acute:180,XK_mu:181,XK_paragraph:182,XK_periodcentered:183,XK_cedilla:184,XK_onesuperior:185,XK_masculine:186,XK_guillemotright:187,XK_onequarter:188,XK_onehalf:189,XK_threequarters:190,XK_questiondown:191,XK_Agrave:192,XK_Aacute:193,XK_Acircumflex:194,XK_Atilde:195,XK_Adiaeresis:196,XK_Aring:197,XK_AE:198,XK_Ccedilla:199,XK_Egrave:200,XK_Eacute:201,XK_Ecircumflex:202,XK_Ediaeresis:203,XK_Igrave:204,XK_Iacute:205,XK_Icircumflex:206,XK_Idiaeresis:207,XK_ETH:208,XK_Eth:208,XK_Ntilde:209,XK_Ograve:210,XK_Oacute:211,XK_Ocircumflex:212,XK_Otilde:213,XK_Odiaeresis:214,XK_multiply:215,XK_Oslash:216,XK_Ooblique:216,XK_Ugrave:217,XK_Uacute:218,XK_Ucircumflex:219,XK_Udiaeresis:220,XK_Yacute:221,XK_THORN:222,XK_Thorn:222,XK_ssharp:223,XK_agrave:224,XK_aacute:225,XK_acircumflex:226,XK_atilde:227,XK_adiaeresis:228,XK_aring:229,XK_ae:230,XK_ccedilla:231,XK_egrave:232,XK_eacute:233,XK_ecircumflex:234,XK_ediaeresis:235,XK_igrave:236,XK_iacute:237,XK_icircumflex:238,XK_idiaeresis:239,XK_eth:240,XK_ntilde:241,XK_ograve:242,XK_oacute:243,XK_ocircumflex:244,XK_otilde:245,XK_odiaeresis:246,XK_division:247,XK_oslash:248,XK_ooblique:248,XK_ugrave:249,XK_uacute:250,XK_ucircumflex:251,XK_udiaeresis:252,XK_yacute:253,XK_thorn:254,XK_ydiaeresis:255,XK_Hangul:65329,XK_Hangul_Hanja:65332,XK_Hangul_Jeonja:65336,XF86XK_ModeLock:269025025,XF86XK_MonBrightnessUp:269025026,XF86XK_MonBrightnessDown:269025027,XF86XK_KbdLightOnOff:269025028,XF86XK_KbdBrightnessUp:269025029,XF86XK_KbdBrightnessDown:269025030,XF86XK_Standby:269025040,XF86XK_AudioLowerVolume:269025041,XF86XK_AudioMute:269025042,XF86XK_AudioRaiseVolume:269025043,XF86XK_AudioPlay:269025044,XF86XK_AudioStop:269025045,XF86XK_AudioPrev:269025046,XF86XK_AudioNext:269025047,XF86XK_HomePage:269025048,XF86XK_Mail:269025049,XF86XK_Start:269025050,XF86XK_Search:269025051,XF86XK_AudioRecord:269025052,XF86XK_Calculator:269025053,XF86XK_Memo:269025054,XF86XK_ToDoList:269025055,XF86XK_Calendar:269025056,XF86XK_PowerDown:269025057,XF86XK_ContrastAdjust:269025058,XF86XK_RockerUp:269025059,XF86XK_RockerDown:269025060,XF86XK_RockerEnter:269025061,XF86XK_Back:269025062,XF86XK_Forward:269025063,XF86XK_Stop:269025064,XF86XK_Refresh:269025065,XF86XK_PowerOff:269025066,XF86XK_WakeUp:269025067,XF86XK_Eject:269025068,XF86XK_ScreenSaver:269025069,XF86XK_WWW:269025070,XF86XK_Sleep:269025071,XF86XK_Favorites:269025072,XF86XK_AudioPause:269025073,XF86XK_AudioMedia:269025074,XF86XK_MyComputer:269025075,XF86XK_VendorHome:269025076,XF86XK_LightBulb:269025077,XF86XK_Shop:269025078,XF86XK_History:269025079,XF86XK_OpenURL:269025080,XF86XK_AddFavorite:269025081,XF86XK_HotLinks:269025082,XF86XK_BrightnessAdjust:269025083,XF86XK_Finance:269025084,XF86XK_Community:269025085,XF86XK_AudioRewind:269025086,XF86XK_BackForward:269025087,XF86XK_Launch0:269025088,XF86XK_Launch1:269025089,XF86XK_Launch2:269025090,XF86XK_Launch3:269025091,XF86XK_Launch4:269025092,XF86XK_Launch5:269025093,XF86XK_Launch6:269025094,XF86XK_Launch7:269025095,XF86XK_Launch8:269025096,XF86XK_Launch9:269025097,XF86XK_LaunchA:269025098,XF86XK_LaunchB:269025099,XF86XK_LaunchC:269025100,XF86XK_LaunchD:269025101,XF86XK_LaunchE:269025102,XF86XK_LaunchF:269025103,XF86XK_ApplicationLeft:269025104,XF86XK_ApplicationRight:269025105,XF86XK_Book:269025106,XF86XK_CD:269025107,XF86XK_Calculater:269025108,XF86XK_Clear:269025109,XF86XK_Close:269025110,XF86XK_Copy:269025111,XF86XK_Cut:269025112,XF86XK_Display:269025113,XF86XK_DOS:269025114,XF86XK_Documents:269025115,XF86XK_Excel:269025116,XF86XK_Explorer:269025117,XF86XK_Game:269025118,XF86XK_Go:269025119,XF86XK_iTouch:269025120,XF86XK_LogOff:269025121,XF86XK_Market:269025122,XF86XK_Meeting:269025123,XF86XK_MenuKB:269025125,XF86XK_MenuPB:269025126,XF86XK_MySites:269025127,XF86XK_New:269025128,XF86XK_News:269025129,XF86XK_OfficeHome:269025130,XF86XK_Open:269025131,XF86XK_Option:269025132,XF86XK_Paste:269025133,XF86XK_Phone:269025134,XF86XK_Q:269025136,XF86XK_Reply:269025138,XF86XK_Reload:269025139,XF86XK_RotateWindows:269025140,XF86XK_RotationPB:269025141,XF86XK_RotationKB:269025142,XF86XK_Save:269025143,XF86XK_ScrollUp:269025144,XF86XK_ScrollDown:269025145,XF86XK_ScrollClick:269025146,XF86XK_Send:269025147,XF86XK_Spell:269025148,XF86XK_SplitScreen:269025149,XF86XK_Support:269025150,XF86XK_TaskPane:269025151,XF86XK_Terminal:269025152,XF86XK_Tools:269025153,XF86XK_Travel:269025154,XF86XK_UserPB:269025156,XF86XK_User1KB:269025157,XF86XK_User2KB:269025158,XF86XK_Video:269025159,XF86XK_WheelButton:269025160,XF86XK_Word:269025161,XF86XK_Xfer:269025162,XF86XK_ZoomIn:269025163,XF86XK_ZoomOut:269025164,XF86XK_Away:269025165,XF86XK_Messenger:269025166,XF86XK_WebCam:269025167,XF86XK_MailForward:269025168,XF86XK_Pictures:269025169,XF86XK_Music:269025170,XF86XK_Battery:269025171,XF86XK_Bluetooth:269025172,XF86XK_WLAN:269025173,XF86XK_UWB:269025174,XF86XK_AudioForward:269025175,XF86XK_AudioRepeat:269025176,XF86XK_AudioRandomPlay:269025177,XF86XK_Subtitle:269025178,XF86XK_AudioCycleTrack:269025179,XF86XK_CycleAngle:269025180,XF86XK_FrameBack:269025181,XF86XK_FrameForward:269025182,XF86XK_Time:269025183,XF86XK_Select:269025184,XF86XK_View:269025185,XF86XK_TopMenu:269025186,XF86XK_Red:269025187,XF86XK_Green:269025188,XF86XK_Yellow:269025189,XF86XK_Blue:269025190,XF86XK_Suspend:269025191,XF86XK_Hibernate:269025192,XF86XK_TouchpadToggle:269025193,XF86XK_TouchpadOn:269025200,XF86XK_TouchpadOff:269025201,XF86XK_AudioMicMute:269025202,XF86XK_Switch_VT_1:269024769,XF86XK_Switch_VT_2:269024770,XF86XK_Switch_VT_3:269024771,XF86XK_Switch_VT_4:269024772,XF86XK_Switch_VT_5:269024773,XF86XK_Switch_VT_6:269024774,XF86XK_Switch_VT_7:269024775,XF86XK_Switch_VT_8:269024776,XF86XK_Switch_VT_9:269024777,XF86XK_Switch_VT_10:269024778,XF86XK_Switch_VT_11:269024779,XF86XK_Switch_VT_12:269024780,XF86XK_Ungrab:269024800,XF86XK_ClearGrab:269024801,XF86XK_Next_VMode:269024802,XF86XK_Prev_VMode:269024803,XF86XK_LogWindowTree:269024804,XF86XK_LogGrabInfo:269024805};var t$={256:960,257:992,258:451,259:483,260:417,261:433,262:454,263:486,264:710,265:742,266:709,267:741,268:456,269:488,270:463,271:495,272:464,273:496,274:938,275:954,278:972,279:1004,280:458,281:490,282:460,283:492,284:728,285:760,286:683,287:699,288:725,289:757,290:939,291:955,292:678,293:694,294:673,295:689,296:933,297:949,298:975,299:1007,302:967,303:999,304:681,305:697,308:684,309:700,310:979,311:1011,312:930,313:453,314:485,315:934,316:950,317:421,318:437,321:419,322:435,323:465,324:497,325:977,326:1009,327:466,328:498,330:957,331:959,332:978,333:1010,336:469,337:501,338:5052,339:5053,340:448,341:480,342:931,343:947,344:472,345:504,346:422,347:438,348:734,349:766,350:426,351:442,352:425,353:441,354:478,355:510,356:427,357:443,358:940,359:956,360:989,361:1021,362:990,363:1022,364:733,365:765,366:473,367:505,368:475,369:507,370:985,371:1017,376:5054,377:428,378:444,379:431,380:447,381:430,382:446,402:2294,466:16777681,711:439,728:418,729:511,731:434,733:445,901:1966,902:1953,904:1954,905:1955,906:1956,908:1959,910:1960,911:1963,912:1974,913:1985,914:1986,915:1987,916:1988,917:1989,918:1990,919:1991,920:1992,921:1993,922:1994,923:1995,924:1996,925:1997,926:1998,927:1999,928:2e3,929:2001,931:2002,932:2004,933:2005,934:2006,935:2007,936:2008,937:2009,938:1957,939:1961,940:1969,941:1970,942:1971,943:1972,944:1978,945:2017,946:2018,947:2019,948:2020,949:2021,950:2022,951:2023,952:2024,953:2025,954:2026,955:2027,956:2028,957:2029,958:2030,959:2031,960:2032,961:2033,962:2035,963:2034,964:2036,965:2037,966:2038,967:2039,968:2040,969:2041,970:1973,971:1977,972:1975,973:1976,974:1979,1025:1715,1026:1713,1027:1714,1028:1716,1029:1717,1030:1718,1031:1719,1032:1720,1033:1721,1034:1722,1035:1723,1036:1724,1038:1726,1039:1727,1040:1761,1041:1762,1042:1783,1043:1767,1044:1764,1045:1765,1046:1782,1047:1786,1048:1769,1049:1770,1050:1771,1051:1772,1052:1773,1053:1774,1054:1775,1055:1776,1056:1778,1057:1779,1058:1780,1059:1781,1060:1766,1061:1768,1062:1763,1063:1790,1064:1787,1065:1789,1066:1791,1067:1785,1068:1784,1069:1788,1070:1760,1071:1777,1072:1729,1073:1730,1074:1751,1075:1735,1076:1732,1077:1733,1078:1750,1079:1754,1080:1737,1081:1738,1082:1739,1083:1740,1084:1741,1085:1742,1086:1743,1087:1744,1088:1746,1089:1747,1090:1748,1091:1749,1092:1734,1093:1736,1094:1731,1095:1758,1096:1755,1097:1757,1098:1759,1099:1753,1100:1752,1101:1756,1102:1728,1103:1745,1105:1699,1106:1697,1107:1698,1108:1700,1109:1701,1110:1702,1111:1703,1112:1704,1113:1705,1114:1706,1115:1707,1116:1708,1118:1710,1119:1711,1168:1725,1169:1709,1488:3296,1489:3297,1490:3298,1491:3299,1492:3300,1493:3301,1494:3302,1495:3303,1496:3304,1497:3305,1498:3306,1499:3307,1500:3308,1501:3309,1502:3310,1503:3311,1504:3312,1505:3313,1506:3314,1507:3315,1508:3316,1509:3317,1510:3318,1511:3319,1512:3320,1513:3321,1514:3322,1548:1452,1563:1467,1567:1471,1569:1473,1570:1474,1571:1475,1572:1476,1573:1477,1574:1478,1575:1479,1576:1480,1577:1481,1578:1482,1579:1483,1580:1484,1581:1485,1582:1486,1583:1487,1584:1488,1585:1489,1586:1490,1587:1491,1588:1492,1589:1493,1590:1494,1591:1495,1592:1496,1593:1497,1594:1498,1600:1504,1601:1505,1602:1506,1603:1507,1604:1508,1605:1509,1606:1510,1607:1511,1608:1512,1609:1513,1610:1514,1611:1515,1612:1516,1613:1517,1614:1518,1615:1519,1616:1520,1617:1521,1618:1522,3585:3489,3586:3490,3587:3491,3588:3492,3589:3493,3590:3494,3591:3495,3592:3496,3593:3497,3594:3498,3595:3499,3596:3500,3597:3501,3598:3502,3599:3503,3600:3504,3601:3505,3602:3506,3603:3507,3604:3508,3605:3509,3606:3510,3607:3511,3608:3512,3609:3513,3610:3514,3611:3515,3612:3516,3613:3517,3614:3518,3615:3519,3616:3520,3617:3521,3618:3522,3619:3523,3620:3524,3621:3525,3622:3526,3623:3527,3624:3528,3625:3529,3626:3530,3627:3531,3628:3532,3629:3533,3630:3534,3631:3535,3632:3536,3633:3537,3634:3538,3635:3539,3636:3540,3637:3541,3638:3542,3639:3543,3640:3544,3641:3545,3642:3546,3647:3551,3648:3552,3649:3553,3650:3554,3651:3555,3652:3556,3653:3557,3654:3558,3655:3559,3656:3560,3657:3561,3658:3562,3659:3563,3660:3564,3661:3565,3664:3568,3665:3569,3666:3570,3667:3571,3668:3572,3669:3573,3670:3574,3671:3575,3672:3576,3673:3577,8194:2722,8195:2721,8196:2723,8197:2724,8199:2725,8200:2726,8201:2727,8202:2728,8210:2747,8211:2730,8212:2729,8213:1967,8215:3295,8216:2768,8217:2769,8218:2813,8220:2770,8221:2771,8222:2814,8224:2801,8225:2802,8226:2790,8229:2735,8230:2734,8240:2773,8242:2774,8243:2775,8248:2812,8254:1150,8361:3839,8364:8364,8453:2744,8470:1712,8471:2811,8478:2772,8482:2761,8531:2736,8532:2737,8533:2738,8534:2739,8535:2740,8536:2741,8537:2742,8538:2743,8539:2755,8540:2756,8541:2757,8542:2758,8592:2299,8593:2300,8594:2301,8595:2302,8658:2254,8660:2253,8706:2287,8711:2245,8728:3018,8730:2262,8733:2241,8734:2242,8743:2270,8744:2271,8745:2268,8746:2269,8747:2239,8756:2240,8764:2248,8771:2249,8773:16785992,8800:2237,8801:2255,8804:2236,8805:2238,8834:2266,8835:2267,8866:3068,8867:3036,8868:3010,8869:3022,8968:3027,8970:3012,8981:2810,8992:2212,8993:2213,9109:3020,9115:2219,9117:2220,9118:2221,9120:2222,9121:2215,9123:2216,9124:2217,9126:2218,9128:2223,9132:2224,9143:2209,9146:2543,9147:2544,9148:2546,9149:2547,9225:2530,9226:2533,9227:2537,9228:2531,9229:2532,9251:2732,9252:2536,9472:2211,9474:2214,9484:2210,9488:2539,9492:2541,9496:2538,9500:2548,9508:2549,9516:2551,9524:2550,9532:2542,9618:2529,9642:2791,9643:2785,9644:2779,9645:2786,9646:2783,9647:2767,9650:2792,9651:2787,9654:2781,9655:2765,9660:2793,9661:2788,9664:2780,9665:2764,9670:2528,9675:2766,9679:2782,9702:2784,9734:2789,9742:2809,9747:2762,9756:2794,9758:2795,9792:2808,9794:2807,9827:2796,9829:2798,9830:2797,9837:2806,9839:2805,10003:2803,10007:2804,10013:2777,10016:2800,10216:2748,10217:2750,12289:1188,12290:1185,12300:1186,12301:1187,12443:1246,12444:1247,12449:1191,12450:1201,12451:1192,12452:1202,12453:1193,12454:1203,12455:1194,12456:1204,12457:1195,12458:1205,12459:1206,12461:1207,12463:1208,12465:1209,12467:1210,12469:1211,12471:1212,12473:1213,12475:1214,12477:1215,12479:1216,12481:1217,12483:1199,12484:1218,12486:1219,12488:1220,12490:1221,12491:1222,12492:1223,12493:1224,12494:1225,12495:1226,12498:1227,12501:1228,12504:1229,12507:1230,12510:1231,12511:1232,12512:1233,12513:1234,12514:1235,12515:1196,12516:1236,12517:1197,12518:1237,12519:1198,12520:1238,12521:1239,12522:1240,12523:1241,12524:1242,12525:1243,12527:1244,12530:1190,12531:1245,12539:1189,12540:1200},Iw={lookup(e){if(e>=32&&e<=255)return e;let t=t$[e];return t!==void 0?t:16777216|e}};var dh={8:"Backspace",9:"Tab",10:"NumpadClear",13:"Enter",16:"ShiftLeft",17:"ControlLeft",18:"AltLeft",19:"Pause",20:"CapsLock",21:"Lang1",25:"Lang2",27:"Escape",28:"Convert",29:"NonConvert",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",41:"Select",44:"PrintScreen",45:"Insert",46:"Delete",47:"Help",48:"Digit0",49:"Digit1",50:"Digit2",51:"Digit3",52:"Digit4",53:"Digit5",54:"Digit6",55:"Digit7",56:"Digit8",57:"Digit9",91:"MetaLeft",92:"MetaRight",93:"ContextMenu",95:"Sleep",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9",106:"NumpadMultiply",107:"NumpadAdd",108:"NumpadDecimal",109:"NumpadSubtract",110:"NumpadDecimal",111:"NumpadDivide",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",124:"F13",125:"F14",126:"F15",127:"F16",128:"F17",129:"F18",130:"F19",131:"F20",132:"F21",133:"F22",134:"F23",135:"F24",144:"NumLock",145:"ScrollLock",166:"BrowserBack",167:"BrowserForward",168:"BrowserRefresh",169:"BrowserStop",170:"BrowserSearch",171:"BrowserFavorites",172:"BrowserHome",173:"AudioVolumeMute",174:"AudioVolumeDown",175:"AudioVolumeUp",176:"MediaTrackNext",177:"MediaTrackPrevious",178:"MediaStop",179:"MediaPlayPause",180:"LaunchMail",181:"MediaSelect",182:"LaunchApp1",183:"LaunchApp2",225:"AltRight"};var ph={Backspace:"Backspace",AltLeft:"Alt",AltRight:"Alt",CapsLock:"CapsLock",ContextMenu:"ContextMenu",ControlLeft:"Control",ControlRight:"Control",Enter:"Enter",MetaLeft:"Meta",MetaRight:"Meta",ShiftLeft:"Shift",ShiftRight:"Shift",Tab:"Tab",Delete:"Delete",End:"End",Help:"Help",Home:"Home",Insert:"Insert",PageDown:"PageDown",PageUp:"PageUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",ArrowUp:"ArrowUp",NumLock:"NumLock",NumpadBackspace:"Backspace",NumpadClear:"Clear",Escape:"Escape",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F30:"F30",F31:"F31",F32:"F32",F33:"F33",F34:"F34",F35:"F35",PrintScreen:"PrintScreen",ScrollLock:"ScrollLock",Pause:"Pause",BrowserBack:"BrowserBack",BrowserFavorites:"BrowserFavorites",BrowserForward:"BrowserForward",BrowserHome:"BrowserHome",BrowserRefresh:"BrowserRefresh",BrowserSearch:"BrowserSearch",BrowserStop:"BrowserStop",Eject:"Eject",LaunchApp1:"LaunchMyComputer",LaunchApp2:"LaunchCalendar",LaunchMail:"LaunchMail",MediaPlayPause:"MediaPlay",MediaStop:"MediaStop",MediaTrackNext:"MediaTrackNext",MediaTrackPrevious:"MediaTrackPrevious",Power:"Power",Sleep:"Sleep",AudioVolumeDown:"AudioVolumeDown",AudioVolumeMute:"AudioVolumeMute",AudioVolumeUp:"AudioVolumeUp",WakeUp:"WakeUp"};var Br={};function X(e,t){if(t===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(e in Br)throw new Error('Duplicate entry for key "'+e+'"');Br[e]=[t,t,t,t]}function yc(e,t,n){if(t===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(n===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(e in Br)throw new Error('Duplicate entry for key "'+e+'"');Br[e]=[t,t,n,t]}function Ce(e,t,n){if(t===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(n===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(e in Br)throw new Error('Duplicate entry for key "'+e+'"');Br[e]=[t,t,t,n]}yc("Alt",A.XK_Alt_L,A.XK_Alt_R);X("AltGraph",A.XK_ISO_Level3_Shift);X("CapsLock",A.XK_Caps_Lock);yc("Control",A.XK_Control_L,A.XK_Control_R);yc("Meta",A.XK_Super_L,A.XK_Super_R);X("NumLock",A.XK_Num_Lock);X("ScrollLock",A.XK_Scroll_Lock);yc("Shift",A.XK_Shift_L,A.XK_Shift_R);Ce("Enter",A.XK_Return,A.XK_KP_Enter);X("Tab",A.XK_Tab);Ce(" ",A.XK_space,A.XK_KP_Space);Ce("ArrowDown",A.XK_Down,A.XK_KP_Down);Ce("ArrowLeft",A.XK_Left,A.XK_KP_Left);Ce("ArrowRight",A.XK_Right,A.XK_KP_Right);Ce("ArrowUp",A.XK_Up,A.XK_KP_Up);Ce("End",A.XK_End,A.XK_KP_End);Ce("Home",A.XK_Home,A.XK_KP_Home);Ce("PageDown",A.XK_Next,A.XK_KP_Next);Ce("PageUp",A.XK_Prior,A.XK_KP_Prior);X("Backspace",A.XK_BackSpace);Ce("Clear",A.XK_Clear,A.XK_KP_Begin);X("Copy",A.XF86XK_Copy);X("Cut",A.XF86XK_Cut);Ce("Delete",A.XK_Delete,A.XK_KP_Delete);Ce("Insert",A.XK_Insert,A.XK_KP_Insert);X("Paste",A.XF86XK_Paste);X("Redo",A.XK_Redo);X("Undo",A.XK_Undo);X("Cancel",A.XK_Cancel);X("ContextMenu",A.XK_Menu);X("Escape",A.XK_Escape);X("Execute",A.XK_Execute);X("Find",A.XK_Find);X("Help",A.XK_Help);X("Pause",A.XK_Pause);X("Select",A.XK_Select);X("ZoomIn",A.XF86XK_ZoomIn);X("ZoomOut",A.XF86XK_ZoomOut);X("BrightnessDown",A.XF86XK_MonBrightnessDown);X("BrightnessUp",A.XF86XK_MonBrightnessUp);X("Eject",A.XF86XK_Eject);X("LogOff",A.XF86XK_LogOff);X("Power",A.XF86XK_PowerOff);X("PowerOff",A.XF86XK_PowerDown);X("PrintScreen",A.XK_Print);X("Hibernate",A.XF86XK_Hibernate);X("Standby",A.XF86XK_Standby);X("WakeUp",A.XF86XK_WakeUp);X("AllCandidates",A.XK_MultipleCandidate);X("Alphanumeric",A.XK_Eisu_toggle);X("CodeInput",A.XK_Codeinput);X("Compose",A.XK_Multi_key);X("Convert",A.XK_Henkan);X("GroupFirst",A.XK_ISO_First_Group);X("GroupLast",A.XK_ISO_Last_Group);X("GroupNext",A.XK_ISO_Next_Group);X("GroupPrevious",A.XK_ISO_Prev_Group);X("NonConvert",A.XK_Muhenkan);X("PreviousCandidate",A.XK_PreviousCandidate);X("SingleCandidate",A.XK_SingleCandidate);X("HangulMode",A.XK_Hangul);X("HanjaMode",A.XK_Hangul_Hanja);X("JunjaMode",A.XK_Hangul_Jeonja);X("Eisu",A.XK_Eisu_toggle);X("Hankaku",A.XK_Hankaku);X("Hiragana",A.XK_Hiragana);X("HiraganaKatakana",A.XK_Hiragana_Katakana);X("KanaMode",A.XK_Kana_Shift);X("KanjiMode",A.XK_Kanji);X("Katakana",A.XK_Katakana);X("Romaji",A.XK_Romaji);X("Zenkaku",A.XK_Zenkaku);X("ZenkakuHankaku",A.XK_Zenkaku_Hankaku);X("F1",A.XK_F1);X("F2",A.XK_F2);X("F3",A.XK_F3);X("F4",A.XK_F4);X("F5",A.XK_F5);X("F6",A.XK_F6);X("F7",A.XK_F7);X("F8",A.XK_F8);X("F9",A.XK_F9);X("F10",A.XK_F10);X("F11",A.XK_F11);X("F12",A.XK_F12);X("F13",A.XK_F13);X("F14",A.XK_F14);X("F15",A.XK_F15);X("F16",A.XK_F16);X("F17",A.XK_F17);X("F18",A.XK_F18);X("F19",A.XK_F19);X("F20",A.XK_F20);X("F21",A.XK_F21);X("F22",A.XK_F22);X("F23",A.XK_F23);X("F24",A.XK_F24);X("F25",A.XK_F25);X("F26",A.XK_F26);X("F27",A.XK_F27);X("F28",A.XK_F28);X("F29",A.XK_F29);X("F30",A.XK_F30);X("F31",A.XK_F31);X("F32",A.XK_F32);X("F33",A.XK_F33);X("F34",A.XK_F34);X("F35",A.XK_F35);X("Close",A.XF86XK_Close);X("MailForward",A.XF86XK_MailForward);X("MailReply",A.XF86XK_Reply);X("MailSend",A.XF86XK_Send);X("MediaFastForward",A.XF86XK_AudioForward);X("MediaPause",A.XF86XK_AudioPause);X("MediaPlay",A.XF86XK_AudioPlay);X("MediaRecord",A.XF86XK_AudioRecord);X("MediaRewind",A.XF86XK_AudioRewind);X("MediaStop",A.XF86XK_AudioStop);X("MediaTrackNext",A.XF86XK_AudioNext);X("MediaTrackPrevious",A.XF86XK_AudioPrev);X("New",A.XF86XK_New);X("Open",A.XF86XK_Open);X("Print",A.XK_Print);X("Save",A.XF86XK_Save);X("SpellCheck",A.XF86XK_Spell);X("AudioVolumeDown",A.XF86XK_AudioLowerVolume);X("AudioVolumeUp",A.XF86XK_AudioRaiseVolume);X("AudioVolumeMute",A.XF86XK_AudioMute);X("MicrophoneVolumeMute",A.XF86XK_AudioMicMute);X("LaunchApplication1",A.XF86XK_MyComputer);X("LaunchApplication2",A.XF86XK_Calculator);X("LaunchCalendar",A.XF86XK_Calendar);X("LaunchMail",A.XF86XK_Mail);X("LaunchMediaPlayer",A.XF86XK_AudioMedia);X("LaunchMusicPlayer",A.XF86XK_Music);X("LaunchPhone",A.XF86XK_Phone);X("LaunchScreenSaver",A.XF86XK_ScreenSaver);X("LaunchSpreadsheet",A.XF86XK_Excel);X("LaunchWebBrowser",A.XF86XK_WWW);X("LaunchWebCam",A.XF86XK_WebCam);X("LaunchWordProcessor",A.XF86XK_Word);X("BrowserBack",A.XF86XK_Back);X("BrowserFavorites",A.XF86XK_Favorites);X("BrowserForward",A.XF86XK_Forward);X("BrowserHome",A.XF86XK_HomePage);X("BrowserRefresh",A.XF86XK_Refresh);X("BrowserSearch",A.XF86XK_Search);X("BrowserStop",A.XF86XK_Stop);X("Dimmer",A.XF86XK_BrightnessAdjust);X("MediaAudioTrack",A.XF86XK_AudioCycleTrack);X("RandomToggle",A.XF86XK_AudioRandomPlay);X("SplitScreenToggle",A.XF86XK_SplitScreen);X("Subtitle",A.XF86XK_Subtitle);X("VideoModeNext",A.XF86XK_Next_VMode);Ce("=",A.XK_equal,A.XK_KP_Equal);Ce("+",A.XK_plus,A.XK_KP_Add);Ce("-",A.XK_minus,A.XK_KP_Subtract);Ce("*",A.XK_asterisk,A.XK_KP_Multiply);Ce("/",A.XK_slash,A.XK_KP_Divide);Ce(".",A.XK_period,A.XK_KP_Decimal);Ce(",",A.XK_comma,A.XK_KP_Separator);Ce("0",A.XK_0,A.XK_KP_0);Ce("1",A.XK_1,A.XK_KP_1);Ce("2",A.XK_2,A.XK_KP_2);Ce("3",A.XK_3,A.XK_KP_3);Ce("4",A.XK_4,A.XK_KP_4);Ce("5",A.XK_5,A.XK_KP_5);Ce("6",A.XK_6,A.XK_KP_6);Ce("7",A.XK_7,A.XK_KP_7);Ce("8",A.XK_8,A.XK_KP_8);Ce("9",A.XK_9,A.XK_KP_9);var fh=Br;function jo(e){if(e.code){switch(e.code){case"OSLeft":return"MetaLeft";case"OSRight":return"MetaRight"}return e.code}if(e.keyCode in dh){let t=dh[e.keyCode];if(Jn()&&t==="ContextMenu"&&(t="MetaRight"),e.location===2)switch(t){case"ShiftLeft":return"ShiftRight";case"ControlLeft":return"ControlRight";case"AltLeft":return"AltRight"}if(e.location===3)switch(t){case"Delete":return"NumpadDecimal";case"Insert":return"Numpad0";case"End":return"Numpad1";case"ArrowDown":return"Numpad2";case"PageDown":return"Numpad3";case"ArrowLeft":return"Numpad4";case"ArrowRight":return"Numpad6";case"Home":return"Numpad7";case"ArrowUp":return"Numpad8";case"PageUp":return"Numpad9";case"Enter":return"NumpadEnter"}return t}return"Unidentified"}function n$(e){if(e.key!==void 0&&e.key!=="Unidentified"){switch(e.key){case"OS":return"Meta";case"LaunchMyComputer":return"LaunchApplication1";case"LaunchCalculator":return"LaunchApplication2"}switch(e.key){case"UIKeyInputUpArrow":return"ArrowUp";case"UIKeyInputDownArrow":return"ArrowDown";case"UIKeyInputLeftArrow":return"ArrowLeft";case"UIKeyInputRightArrow":return"ArrowRight";case"UIKeyInputEscape":return"Escape"}return e.key==="\0"&&e.code==="NumpadDecimal"?"Delete":e.key}let t=jo(e);return t in ph?ph[t]:e.charCode?String.fromCharCode(e.charCode):"Unidentified"}function Pw(e){let t=n$(e);if(t==="Unidentified")return null;if(t in fh){let r=e.location;if(t==="Meta"&&r===0&&(r=2),t==="Clear"&&r===3&&jo(e)==="NumLock"&&(r=0),(r===void 0||r>3)&&(r=0),t==="Meta"){let o=jo(e);if(o==="AltLeft")return A.XK_Meta_L;if(o==="AltRight")return A.XK_Meta_R}if(t==="Clear"&&jo(e)==="NumLock")return A.XK_Num_Lock;if(Lo())switch(t){case"Zenkaku":case"Hankaku":return A.XK_Zenkaku_Hankaku;case"Romaji":case"KanaMode":return A.XK_Romaji}return fh[t][r]}if(t.length!==1)return null;let n=t.charCodeAt();return n?Iw.lookup(n):null}var Vi=class{constructor(t){this._target=t||null,this._keyDownList={},this._altGrArmed=!1,this._eventHandlers={keyup:this._handleKeyUp.bind(this),keydown:this._handleKeyDown.bind(this),blur:this._allKeysUp.bind(this)},this.onkeyevent=()=>{}}_sendKeyEvent(t,n,r,o=null,s=null){if(r)this._keyDownList[n]=t;else{if(!(n in this._keyDownList))return;delete this._keyDownList[n]}de("onkeyevent "+(r?"down":"up")+", keysym: "+t,", code: "+n+", numlock: "+o+", capslock: "+s),this.onkeyevent(t,n,r,o,s)}_getKeyCode(t){let n=jo(t);if(n!=="Unidentified")return n;if(t.keyCode&&t.keyCode!==229)return"Platform"+t.keyCode;if(t.keyIdentifier){if(t.keyIdentifier.substr(0,2)!=="U+")return t.keyIdentifier;let r=parseInt(t.keyIdentifier.substr(2),16);return"Platform"+String.fromCharCode(r).toUpperCase().charCodeAt()}return"Unidentified"}_handleKeyDown(t){let n=this._getKeyCode(t),r=Pw(t),o=t.getModifierState("NumLock"),s=t.getModifierState("CapsLock");if((Jn()||Mo())&&(o=null),this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),n==="AltRight"&&t.timeStamp-this._altGrCtrlTime<50?r=A.XK_ISO_Level3_Shift:this._sendKeyEvent(A.XK_Control_L,"ControlLeft",!0,o,s)),n==="Unidentified"){r&&(this._sendKeyEvent(r,n,!0,o,s),this._sendKeyEvent(r,n,!1,o,s)),Pr(t);return}if(Jn()||Mo())switch(r){case A.XK_Super_L:r=A.XK_Alt_L;break;case A.XK_Super_R:r=A.XK_Super_L;break;case A.XK_Alt_L:r=A.XK_Mode_switch;break;case A.XK_Alt_R:r=A.XK_ISO_Level3_Shift;break}if(n in this._keyDownList&&(r=this._keyDownList[n]),(Jn()||Mo())&&t.metaKey&&n!=="MetaLeft"&&n!=="MetaRight"){this._sendKeyEvent(r,n,!0,o,s),this._sendKeyEvent(r,n,!1,o,s),Pr(t);return}if((Jn()||Mo())&&n==="CapsLock"){this._sendKeyEvent(A.XK_Caps_Lock,"CapsLock",!0,o,s),this._sendKeyEvent(A.XK_Caps_Lock,"CapsLock",!1,o,s),Pr(t);return}let i=[A.XK_Zenkaku_Hankaku,A.XK_Eisu_toggle,A.XK_Katakana,A.XK_Hiragana,A.XK_Romaji];if(Lo()&&i.includes(r)){this._sendKeyEvent(r,n,!0,o,s),this._sendKeyEvent(r,n,!1,o,s),Pr(t);return}if(Pr(t),n==="ControlLeft"&&Lo()&&!("ControlLeft"in this._keyDownList)){this._altGrArmed=!0,this._altGrTimeout=setTimeout(this._interruptAltGrSequence.bind(this),100),this._altGrCtrlTime=t.timeStamp;return}this._sendKeyEvent(r,n,!0,o,s)}_handleKeyUp(t){Pr(t);let n=this._getKeyCode(t);if(this._interruptAltGrSequence(),(Jn()||Mo())&&n==="CapsLock"){this._sendKeyEvent(A.XK_Caps_Lock,"CapsLock",!0),this._sendKeyEvent(A.XK_Caps_Lock,"CapsLock",!1);return}this._sendKeyEvent(this._keyDownList[n],n,!1),Lo()&&(n==="ShiftLeft"||n==="ShiftRight")&&("ShiftRight"in this._keyDownList&&this._sendKeyEvent(this._keyDownList.ShiftRight,"ShiftRight",!1),"ShiftLeft"in this._keyDownList&&this._sendKeyEvent(this._keyDownList.ShiftLeft,"ShiftLeft",!1))}_interruptAltGrSequence(){this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),this._sendKeyEvent(A.XK_Control_L,"ControlLeft",!0))}_allKeysUp(){de(">> Keyboard.allKeysUp"),this._interruptAltGrSequence();for(let t in this._keyDownList)this._sendKeyEvent(this._keyDownList[t],t,!1);de("<< Keyboard.allKeysUp")}grab(){this._target.addEventListener("keydown",this._eventHandlers.keydown),this._target.addEventListener("keyup",this._eventHandlers.keyup),window.addEventListener("blur",this._eventHandlers.blur)}ungrab(){this._target.removeEventListener("keydown",this._eventHandlers.keydown),this._target.removeEventListener("keyup",this._eventHandlers.keyup),window.removeEventListener("blur",this._eventHandlers.blur),this._allKeysUp()}};var Zi=class{constructor(){this._target=null,this._state=127,this._tracked=[],this._ignored=[],this._waitingRelease=!1,this._releaseStart=0,this._longpressTimeoutId=null,this._twoTouchTimeoutId=null,this._boundEventHandler=this._eventHandler.bind(this)}attach(t){this.detach(),this._target=t,this._target.addEventListener("touchstart",this._boundEventHandler),this._target.addEventListener("touchmove",this._boundEventHandler),this._target.addEventListener("touchend",this._boundEventHandler),this._target.addEventListener("touchcancel",this._boundEventHandler)}detach(){this._target&&(this._stopLongpressTimeout(),this._stopTwoTouchTimeout(),this._target.removeEventListener("touchstart",this._boundEventHandler),this._target.removeEventListener("touchmove",this._boundEventHandler),this._target.removeEventListener("touchend",this._boundEventHandler),this._target.removeEventListener("touchcancel",this._boundEventHandler),this._target=null)}_eventHandler(t){let n;switch(t.stopPropagation(),t.preventDefault(),t.type){case"touchstart":n=this._touchStart;break;case"touchmove":n=this._touchMove;break;case"touchend":case"touchcancel":n=this._touchEnd;break}for(let r=0;r<t.changedTouches.length;r++){let o=t.changedTouches[r];n.call(this,o.identifier,o.clientX,o.clientY)}}_touchStart(t,n,r){if(this._hasDetectedGesture()||this._state===0){this._ignored.push(t);return}if(this._tracked.length>0&&Date.now()-this._tracked[0].started>250){this._state=0,this._ignored.push(t);return}if(this._waitingRelease){this._state=0,this._ignored.push(t);return}switch(this._tracked.push({id:t,started:Date.now(),active:!0,firstX:n,firstY:r,lastX:n,lastY:r,angle:0}),this._tracked.length){case 1:this._startLongpressTimeout();break;case 2:this._state&=-26,this._stopLongpressTimeout();break;case 3:this._state&=-99;break;default:this._state=0}}_touchMove(t,n,r){let o=this._tracked.find(a=>a.id===t);if(o===void 0)return;o.lastX=n,o.lastY=r;let s=n-o.firstX,i=r-o.firstY;if((o.firstX!==o.lastX||o.firstY!==o.lastY)&&(o.angle=Math.atan2(i,s)*180/Math.PI),!this._hasDetectedGesture()){if(Math.hypot(s,i)<50)return;if(this._state&=-24,this._stopLongpressTimeout(),this._tracked.length!==1&&(this._state&=-9),this._tracked.length!==2&&(this._state&=-97),this._tracked.length===2){let a=this._tracked.find(c=>c.id!==t);if(Math.hypot(a.firstX-a.lastX,a.firstY-a.lastY)>50){let c=Math.abs(o.angle-a.angle);c=Math.abs((c+180)%360-180),c>90?this._state&=-33:this._state&=-65,this._isTwoTouchTimeoutRunning()&&this._stopTwoTouchTimeout()}else this._isTwoTouchTimeoutRunning()||this._startTwoTouchTimeout()}if(!this._hasDetectedGesture())return;this._pushEvent("gesturestart")}this._pushEvent("gesturemove")}_touchEnd(t,n,r){if(this._ignored.indexOf(t)!==-1){this._ignored.splice(this._ignored.indexOf(t),1),this._ignored.length===0&&this._tracked.length===0&&(this._state=127,this._waitingRelease=!1);return}if(!this._hasDetectedGesture()&&this._isTwoTouchTimeoutRunning()&&(this._stopTwoTouchTimeout(),this._state=0),!this._hasDetectedGesture()&&(this._state&=-105,this._state&=-17,this._stopLongpressTimeout(),!this._waitingRelease))switch(this._releaseStart=Date.now(),this._waitingRelease=!0,this._tracked.length){case 1:this._state&=-7;break;case 2:this._state&=-6;break}if(this._waitingRelease){Date.now()-this._releaseStart>250&&(this._state=0),this._tracked.some(s=>Date.now()-s.started>1e3)&&(this._state=0);let o=this._tracked.find(s=>s.id===t);if(o.active=!1,this._hasDetectedGesture())this._pushEvent("gesturestart");else if(this._state!==0)return}this._hasDetectedGesture()&&this._pushEvent("gestureend");for(let o=0;o<this._tracked.length;o++)this._tracked[o].active&&this._ignored.push(this._tracked[o].id);this._tracked=[],this._state=0,this._ignored.indexOf(t)!==-1&&this._ignored.splice(this._ignored.indexOf(t),1),this._ignored.length===0&&(this._state=127,this._waitingRelease=!1)}_hasDetectedGesture(){return!(this._state===0||this._state&this._state-1||this._state&7&&this._tracked.some(t=>t.active))}_startLongpressTimeout(){this._stopLongpressTimeout(),this._longpressTimeoutId=setTimeout(()=>this._longpressTimeout(),1e3)}_stopLongpressTimeout(){clearTimeout(this._longpressTimeoutId),this._longpressTimeoutId=null}_longpressTimeout(){if(this._hasDetectedGesture())throw new Error("A longpress gesture failed, conflict with a different gesture");this._state=16,this._pushEvent("gesturestart")}_startTwoTouchTimeout(){this._stopTwoTouchTimeout(),this._twoTouchTimeoutId=setTimeout(()=>this._twoTouchTimeout(),50)}_stopTwoTouchTimeout(){clearTimeout(this._twoTouchTimeoutId),this._twoTouchTimeoutId=null}_isTwoTouchTimeoutRunning(){return this._twoTouchTimeoutId!==null}_twoTouchTimeout(){if(this._tracked.length===0)throw new Error("A pinch or two drag gesture failed, no tracked touches");let t=this._getAverageMovement(),n=Math.abs(t.x),r=Math.abs(t.y),o=this._getAverageDistance(),s=Math.abs(Math.hypot(o.first.x,o.first.y)-Math.hypot(o.last.x,o.last.y));r<s&&n<s?this._state=64:this._state=32,this._pushEvent("gesturestart"),this._pushEvent("gesturemove")}_pushEvent(t){let n={type:this._stateToGesture(this._state)},r=this._getPosition(),o=r.last;switch(t==="gesturestart"&&(o=r.first),this._state){case 32:case 64:o=r.first;break}if(n.clientX=o.x,n.clientY=o.y,this._state===64){let i=this._getAverageDistance();t==="gesturestart"?(n.magnitudeX=i.first.x,n.magnitudeY=i.first.y):(n.magnitudeX=i.last.x,n.magnitudeY=i.last.y)}else if(this._state===32)if(t==="gesturestart")n.magnitudeX=0,n.magnitudeY=0;else{let i=this._getAverageMovement();n.magnitudeX=i.x,n.magnitudeY=i.y}let s=new CustomEvent(t,{detail:n});this._target.dispatchEvent(s)}_stateToGesture(t){switch(t){case 1:return"onetap";case 2:return"twotap";case 4:return"threetap";case 8:return"drag";case 16:return"longpress";case 32:return"twodrag";case 64:return"pinch"}throw new Error("Unknown gesture state: "+t)}_getPosition(){if(this._tracked.length===0)throw new Error("Failed to get gesture position, no tracked touches");let t=this._tracked.length,n=0,r=0,o=0,s=0;for(let i=0;i<this._tracked.length;i++)n+=this._tracked[i].firstX,r+=this._tracked[i].firstY,o+=this._tracked[i].lastX,s+=this._tracked[i].lastY;return{first:{x:n/t,y:r/t},last:{x:o/t,y:s/t}}}_getAverageMovement(){if(this._tracked.length===0)throw new Error("Failed to get gesture movement, no tracked touches");let t,n;t=n=0;let r=this._tracked.length;for(let o=0;o<this._tracked.length;o++)t+=this._tracked[o].lastX-this._tracked[o].firstX,n+=this._tracked[o].lastY-this._tracked[o].firstY;return{x:t/r,y:n/r}}_getAverageDistance(){if(this._tracked.length===0)throw new Error("Failed to get gesture distance, no tracked touches");let t=this._tracked[0],n=this._tracked[this._tracked.length-1],r=Math.abs(n.firstX-t.firstX),o=Math.abs(n.firstY-t.firstY),s=Math.abs(n.lastX-t.lastX),i=Math.abs(n.lastY-t.lastY);return{first:{x:r,y:o},last:{x:s,y:i}}}};var Wi=!uv||Lf,ji=class{constructor(){this._target=null,this._canvas=document.createElement("canvas"),Wi&&(this._canvas.style.position="fixed",this._canvas.style.zIndex="65535",this._canvas.style.pointerEvents="none",this._canvas.style.userSelect="none",this._canvas.style.WebkitUserSelect="none",this._canvas.style.visibility="hidden"),this._position={x:0,y:0},this._hotSpot={x:0,y:0},this._eventHandlers={mouseover:this._handleMouseOver.bind(this),mouseleave:this._handleMouseLeave.bind(this),mousemove:this._handleMouseMove.bind(this),mouseup:this._handleMouseUp.bind(this)}}attach(t){if(this._target&&this.detach(),this._target=t,Wi){document.body.appendChild(this._canvas);let n={capture:!0,passive:!0};this._target.addEventListener("mouseover",this._eventHandlers.mouseover,n),this._target.addEventListener("mouseleave",this._eventHandlers.mouseleave,n),this._target.addEventListener("mousemove",this._eventHandlers.mousemove,n),this._target.addEventListener("mouseup",this._eventHandlers.mouseup,n)}this.clear()}detach(){if(this._target){if(Wi){let t={capture:!0,passive:!0};this._target.removeEventListener("mouseover",this._eventHandlers.mouseover,t),this._target.removeEventListener("mouseleave",this._eventHandlers.mouseleave,t),this._target.removeEventListener("mousemove",this._eventHandlers.mousemove,t),this._target.removeEventListener("mouseup",this._eventHandlers.mouseup,t),document.contains(this._canvas)&&document.body.removeChild(this._canvas)}this._target=null}}change(t,n,r,o,s){if(o===0||s===0){this.clear();return}this._position.x=this._position.x+this._hotSpot.x-n,this._position.y=this._position.y+this._hotSpot.y-r,this._hotSpot.x=n,this._hotSpot.y=r;let i=this._canvas.getContext("2d");this._canvas.width=o,this._canvas.height=s;let a=new ImageData(new Uint8ClampedArray(t),o,s);if(i.clearRect(0,0,o,s),i.putImageData(a,0,0),Wi)this._updatePosition();else{let u=this._canvas.toDataURL();this._target.style.cursor="url("+u+")"+n+" "+r+", default"}}clear(){this._target.style.cursor="none",this._canvas.width=0,this._canvas.height=0,this._position.x=this._position.x+this._hotSpot.x,this._position.y=this._position.y+this._hotSpot.y,this._hotSpot.x=0,this._hotSpot.y=0}move(t,n){if(!Wi)return;window.visualViewport?(this._position.x=t+window.visualViewport.offsetLeft,this._position.y=n+window.visualViewport.offsetTop):(this._position.x=t,this._position.y=n),this._updatePosition();let r=document.elementFromPoint(t,n);this._updateVisibility(r)}_handleMouseOver(t){this._handleMouseMove(t)}_handleMouseLeave(t){this._updateVisibility(t.relatedTarget)}_handleMouseMove(t){this._updateVisibility(t.target),this._position.x=t.clientX-this._hotSpot.x,this._position.y=t.clientY-this._hotSpot.y,this._updatePosition()}_handleMouseUp(t){let n=document.elementFromPoint(t.clientX,t.clientY);this._updateVisibility(n),this._captureIsActive()&&window.setTimeout(()=>{this._target&&(n=document.elementFromPoint(t.clientX,t.clientY),this._updateVisibility(n))},0)}_showCursor(){this._canvas.style.visibility==="hidden"&&(this._canvas.style.visibility="")}_hideCursor(){this._canvas.style.visibility!=="hidden"&&(this._canvas.style.visibility="hidden")}_shouldShowCursor(t){return t?t===this._target?!0:!(!this._target.contains(t)||window.getComputedStyle(t).cursor!=="none"):!1}_updateVisibility(t){this._captureIsActive()&&(t=document.captureElement),this._shouldShowCursor(t)?this._showCursor():this._hideCursor()}_updatePosition(){this._canvas.style.left=this._position.x+"px",this._canvas.style.top=this._position.y+"px"}_captureIsActive(){return document.captureElement&&document.documentElement.contains(document.captureElement)}};var hh=40*1024*1024,_c={CONNECTING:"connecting",OPEN:"open",CLOSING:"closing",CLOSED:"closed"},vc={CONNECTING:[WebSocket.CONNECTING,_c.CONNECTING],OPEN:[WebSocket.OPEN,_c.OPEN],CLOSING:[WebSocket.CLOSING,_c.CLOSING],CLOSED:[WebSocket.CLOSED,_c.CLOSED]},Ow=["send","close","binaryType","onerror","onmessage","onopen","protocol","readyState"],Qi=class{constructor(){this._websocket=null,this._rQi=0,this._rQlen=0,this._rQbufferSize=1024*1024*4,this._rQ=null,this._sQbufferSize=1024*10,this._sQlen=0,this._sQ=null,this._eventHandlers={message:()=>{},open:()=>{},close:()=>{},error:()=>{}}}get readyState(){let t;return this._websocket===null?"unused":(t=this._websocket.readyState,vc.CONNECTING.includes(t)?"connecting":vc.OPEN.includes(t)?"open":vc.CLOSING.includes(t)?"closing":vc.CLOSED.includes(t)?"closed":"unknown")}rQpeek8(){return this._rQ[this._rQi]}rQskipBytes(t){this._rQi+=t}rQshift8(){return this._rQshift(1)}rQshift16(){return this._rQshift(2)}rQshift32(){return this._rQshift(4)}_rQshift(t){let n=0;for(let r=t-1;r>=0;r--)n+=this._rQ[this._rQi++]<<r*8;return n>>>0}rQlen(){return this._rQlen-this._rQi}rQshiftStr(t){let n="";for(let r=0;r<t;r+=4096){let o=this.rQshiftBytes(Math.min(4096,t-r),!1);n+=String.fromCharCode.apply(null,o)}return n}rQshiftBytes(t,n=!0){return this._rQi+=t,n?this._rQ.slice(this._rQi-t,this._rQi):this._rQ.subarray(this._rQi-t,this._rQi)}rQshiftTo(t,n){t.set(new Uint8Array(this._rQ.buffer,this._rQi,n)),this._rQi+=n}rQpeekBytes(t,n=!0){return n?this._rQ.slice(this._rQi,this._rQi+t):this._rQ.subarray(this._rQi,this._rQi+t)}rQwait(t,n,r){if(this._rQlen-this._rQi<n){if(r){if(this._rQi<r)throw new Error("rQwait cannot backup "+r+" bytes");this._rQi-=r}return!0}return!1}sQpush8(t){this._sQensureSpace(1),this._sQ[this._sQlen++]=t}sQpush16(t){this._sQensureSpace(2),this._sQ[this._sQlen++]=t>>8&255,this._sQ[this._sQlen++]=t>>0&255}sQpush32(t){this._sQensureSpace(4),this._sQ[this._sQlen++]=t>>24&255,this._sQ[this._sQlen++]=t>>16&255,this._sQ[this._sQlen++]=t>>8&255,this._sQ[this._sQlen++]=t>>0&255}sQpushString(t){let n=t.split("").map(r=>r.charCodeAt(0));this.sQpushBytes(new Uint8Array(n))}sQpushBytes(t){for(let n=0;n<t.length;){this._sQensureSpace(1);let r=this._sQbufferSize-this._sQlen;r>t.length-n&&(r=t.length-n),this._sQ.set(t.subarray(n,n+r),this._sQlen),this._sQlen+=r,n+=r}}flush(){this._sQlen>0&&this.readyState==="open"&&(this._websocket.send(new Uint8Array(this._sQ.buffer,0,this._sQlen)),this._sQlen=0)}_sQensureSpace(t){this._sQbufferSize-this._sQlen<t&&this.flush()}off(t){this._eventHandlers[t]=()=>{}}on(t,n){this._eventHandlers[t]=n}_allocateBuffers(){this._rQ=new Uint8Array(this._rQbufferSize),this._sQ=new Uint8Array(this._sQbufferSize)}init(){this._allocateBuffers(),this._rQi=0,this._websocket=null}open(t,n){this.attach(new WebSocket(t,n))}attach(t){this.init();let n=[...Object.keys(t),...Object.getOwnPropertyNames(Object.getPrototypeOf(t))];for(let r=0;r<Ow.length;r++){let o=Ow[r];if(n.indexOf(o)<0)throw new Error("Raw channel missing property: "+o)}this._websocket=t,this._websocket.binaryType="arraybuffer",this._websocket.onmessage=this._recvMessage.bind(this),this._websocket.onopen=()=>{de(">> WebSock.onopen"),this._websocket.protocol&&Qe("Server choose sub-protocol: "+this._websocket.protocol),this._eventHandlers.open(),de("<< WebSock.onopen")},this._websocket.onclose=r=>{de(">> WebSock.onclose"),this._eventHandlers.close(r),de("<< WebSock.onclose")},this._websocket.onerror=r=>{de(">> WebSock.onerror: "+r),this._eventHandlers.error(r),de("<< WebSock.onerror: "+r)}}close(){this._websocket&&((this.readyState==="connecting"||this.readyState==="open")&&(Qe("Closing WebSocket connection"),this._websocket.close()),this._websocket.onmessage=()=>{})}_expandCompactRQ(t){let n=(this._rQlen-this._rQi+t)*8,r=this._rQbufferSize<n;if(r&&(this._rQbufferSize=Math.max(this._rQbufferSize*2,n)),this._rQbufferSize>hh&&(this._rQbufferSize=hh,this._rQbufferSize-(this._rQlen-this._rQi)<t))throw new Error("Receive queue buffer exceeded "+hh+" bytes, and the new message could not fit");if(r){let o=this._rQ.buffer;this._rQ=new Uint8Array(this._rQbufferSize),this._rQ.set(new Uint8Array(o,this._rQi,this._rQlen-this._rQi))}else this._rQ.copyWithin(0,this._rQi,this._rQlen);this._rQlen=this._rQlen-this._rQi,this._rQi=0}_recvMessage(t){this._rQlen==this._rQi&&(this._rQlen=0,this._rQi=0);let n=new Uint8Array(t.data);n.length>this._rQbufferSize-this._rQlen&&this._expandCompactRQ(n.length),this._rQ.set(n,this._rQlen),this._rQlen+=n.length,this._rQlen-this._rQi>0?this._eventHandlers.message():de("Ignoring empty message")}};var Lw={Again:57349,AltLeft:56,AltRight:57400,ArrowDown:57424,ArrowLeft:57419,ArrowRight:57421,ArrowUp:57416,AudioVolumeDown:57390,AudioVolumeMute:57376,AudioVolumeUp:57392,Backquote:41,Backslash:43,Backspace:14,BracketLeft:26,BracketRight:27,BrowserBack:57450,BrowserFavorites:57446,BrowserForward:57449,BrowserHome:57394,BrowserRefresh:57447,BrowserSearch:57445,BrowserStop:57448,CapsLock:58,Comma:51,ContextMenu:57437,ControlLeft:29,ControlRight:57373,Convert:121,Copy:57464,Cut:57404,Delete:57427,Digit0:11,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Eject:57469,End:57423,Enter:28,Equal:13,Escape:1,F1:59,F10:68,F11:87,F12:88,F13:93,F14:94,F15:95,F16:85,F17:57347,F18:57463,F19:57348,F2:60,F20:90,F21:116,F22:57465,F23:109,F24:111,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,Find:57409,Help:57461,Hiragana:119,Home:57415,Insert:57426,IntlBackslash:86,IntlRo:115,IntlYen:125,KanaMode:112,Katakana:120,KeyA:30,KeyB:48,KeyC:46,KeyD:32,KeyE:18,KeyF:33,KeyG:34,KeyH:35,KeyI:23,KeyJ:36,KeyK:37,KeyL:38,KeyM:50,KeyN:49,KeyO:24,KeyP:25,KeyQ:16,KeyR:19,KeyS:31,KeyT:20,KeyU:22,KeyV:47,KeyW:17,KeyX:45,KeyY:21,KeyZ:44,Lang1:114,Lang2:113,Lang3:120,Lang4:119,Lang5:118,LaunchApp1:57451,LaunchApp2:57377,LaunchMail:57452,MediaPlayPause:57378,MediaSelect:57453,MediaStop:57380,MediaTrackNext:57369,MediaTrackPrevious:57360,MetaLeft:57435,MetaRight:57436,Minus:12,NonConvert:123,NumLock:69,Numpad0:82,Numpad1:79,Numpad2:80,Numpad3:81,Numpad4:75,Numpad5:76,Numpad6:77,Numpad7:71,Numpad8:72,Numpad9:73,NumpadAdd:78,NumpadComma:126,NumpadDecimal:83,NumpadDivide:57397,NumpadEnter:57372,NumpadEqual:89,NumpadMultiply:55,NumpadParenLeft:57462,NumpadParenRight:57467,NumpadSubtract:74,Open:100,PageDown:57425,PageUp:57417,Paste:101,Pause:57414,Period:52,Power:57438,PrintScreen:84,Props:57350,Quote:40,ScrollLock:70,Semicolon:39,ShiftLeft:42,ShiftRight:54,Slash:53,Sleep:57439,Space:57,Suspend:57381,Tab:15,Undo:57351,WakeUp:57443};var ge={encodingRaw:0,encodingCopyRect:1,encodingRRE:2,encodingHextile:5,encodingZlib:6,encodingTight:7,encodingZRLE:16,encodingTightPNG:-260,encodingJPEG:21,encodingH264:50,pseudoEncodingQualityLevel9:-23,pseudoEncodingQualityLevel0:-32,pseudoEncodingDesktopSize:-223,pseudoEncodingLastRect:-224,pseudoEncodingCursor:-239,pseudoEncodingQEMUExtendedKeyEvent:-258,pseudoEncodingQEMULedEvent:-261,pseudoEncodingDesktopName:-307,pseudoEncodingExtendedDesktopSize:-308,pseudoEncodingXvp:-309,pseudoEncodingFence:-312,pseudoEncodingContinuousUpdates:-313,pseudoEncodingExtendedMouseButtons:-316,pseudoEncodingCompressLevel9:-247,pseudoEncodingCompressLevel0:-256,pseudoEncodingVMwareCursor:1464686180,pseudoEncodingExtendedClipboard:3231835598};var wc=class e{constructor(){this._key=null}get algorithm(){return{name:"AES-ECB"}}static async importKey(t,n,r,o){let s=new e;return await s._importKey(t,r,o),s}async _importKey(t,n,r){this._key=await window.crypto.subtle.importKey("raw",t,{name:"AES-CBC"},n,r)}async encrypt(t,n){let r=new Uint8Array(n);if(r.length%16!==0||this._key===null)return null;let o=r.length/16;for(let s=0;s<o;s++){let i=new Uint8Array(await window.crypto.subtle.encrypt({name:"AES-CBC",iv:new Uint8Array(16)},this._key,r.slice(s*16,s*16+16))).slice(0,16);r.set(i,s*16)}return r}},kc=class e{constructor(){this._rawKey=null,this._ctrKey=null,this._cbcKey=null,this._zeroBlock=new Uint8Array(16),this._prefixBlock0=this._zeroBlock,this._prefixBlock1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]),this._prefixBlock2=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2])}get algorithm(){return{name:"AES-EAX"}}async _encryptBlock(t){let n=await window.crypto.subtle.encrypt({name:"AES-CBC",iv:this._zeroBlock},this._cbcKey,t);return new Uint8Array(n).slice(0,16)}async _initCMAC(){let t=await this._encryptBlock(this._zeroBlock),n=new Uint8Array(16),r=t[0]>>>6;for(let s=0;s<15;s++)n[s]=t[s+1]>>6|t[s]<<2,t[s]=t[s+1]>>7|t[s]<<1;let o=[0,135,14,137];n[14]^=r>>>1,n[15]=t[15]<<2^o[r],t[15]=t[15]<<1^o[r>>1],this._k1=t,this._k2=n}async _encryptCTR(t,n){let r=await window.crypto.subtle.encrypt({name:"AES-CTR",counter:n,length:128},this._ctrKey,t);return new Uint8Array(r)}async _decryptCTR(t,n){let r=await window.crypto.subtle.decrypt({name:"AES-CTR",counter:n,length:128},this._ctrKey,t);return new Uint8Array(r)}async _computeCMAC(t,n){if(n.length!==16)return null;let r=Math.floor(t.length/16),o=Math.ceil(t.length/16),s=t.length-r*16,i=new Uint8Array((o+1)*16);if(i.set(n),i.set(t,16),s===0)for(let c=0;c<16;c++)i[r*16+c]^=this._k1[c];else{i[(r+1)*16+s]=128;for(let c=0;c<16;c++)i[(r+1)*16+c]^=this._k2[c]}let a=await window.crypto.subtle.encrypt({name:"AES-CBC",iv:this._zeroBlock},this._cbcKey,i);return a=new Uint8Array(a),a.slice(a.length-32,a.length-16)}static async importKey(t,n,r,o){let s=new e;return await s._importKey(t),s}async _importKey(t){this._rawKey=t,this._ctrKey=await window.crypto.subtle.importKey("raw",t,{name:"AES-CTR"},!1,["encrypt","decrypt"]),this._cbcKey=await window.crypto.subtle.importKey("raw",t,{name:"AES-CBC"},!1,["encrypt"]),await this._initCMAC()}async encrypt(t,n){let r=t.additionalData,o=t.iv,s=await this._computeCMAC(o,this._prefixBlock0),i=await this._encryptCTR(n,s),a=await this._computeCMAC(r,this._prefixBlock1),u=await this._computeCMAC(i,this._prefixBlock2);for(let d=0;d<16;d++)u[d]^=s[d]^a[d];let c=new Uint8Array(16+i.length);return c.set(i),c.set(u,i.length),c}async decrypt(t,n){let r=n.slice(0,n.length-16),o=t.additionalData,s=t.iv,i=n.slice(n.length-16),a=await this._computeCMAC(s,this._prefixBlock0),u=await this._computeCMAC(o,this._prefixBlock1),c=await this._computeCMAC(r,this._prefixBlock2);for(let p=0;p<16;p++)c[p]^=a[p]^u[p];if(c.length!==i.length)return null;for(let p=0;p<i.length;p++)if(c[p]!==i[p])return null;return await this._decryptCTR(r,a)}};var Mw=[13,16,10,23,0,4,2,27,14,5,20,9,22,18,11,3,25,7,15,6,26,19,12,1,40,51,30,36,46,54,29,39,50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31],o$=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],E=0,M,D,B,F,z,U;M=65536;D=1<<24;B=M|D;F=4;z=1024;U=F|z;var Dw=[B|z,E|E,M|E,B|U,B|F,M|U,E|F,M|E,E|z,B|z,B|U,E|z,D|U,B|F,D|E,E|F,E|U,D|z,D|z,M|z,M|z,B|E,B|E,D|U,M|F,D|F,D|F,M|F,E|E,E|U,M|U,D|E,M|E,B|U,E|F,B|E,B|z,D|E,D|E,E|z,B|F,M|E,M|z,D|F,E|z,E|F,D|U,M|U,B|U,M|F,B|E,D|U,D|F,E|U,M|U,B|z,E|U,D|z,D|z,E|E,M|F,M|z,E|E,B|F];M=1<<20;D=1<<31;B=M|D;F=32;z=32768;U=F|z;var Fw=[B|U,D|z,E|z,M|U,M|E,E|F,B|F,D|U,D|F,B|U,B|z,D|E,D|z,M|E,E|F,B|F,M|z,M|F,D|U,E|E,D|E,E|z,M|U,B|E,M|F,D|F,E|E,M|z,E|U,B|z,B|E,E|U,E|E,M|U,B|F,M|E,D|U,B|E,B|z,E|z,B|E,D|z,E|F,B|U,M|U,E|F,E|z,D|E,E|U,B|z,M|E,D|F,M|F,D|U,D|F,M|F,M|z,E|E,D|z,E|U,D|E,B|F,B|U,M|z];M=1<<17;D=1<<27;B=M|D;F=8;z=512;U=F|z;var zw=[E|U,B|z,E|E,B|F,D|z,E|E,M|U,D|z,M|F,D|F,D|F,M|E,B|U,M|F,B|E,E|U,D|E,E|F,B|z,E|z,M|z,B|E,B|F,M|U,D|U,M|z,M|E,D|U,E|F,B|U,E|z,D|E,B|z,D|E,M|F,E|U,M|E,B|z,D|z,E|E,E|z,M|F,B|U,D|z,D|F,E|z,E|E,B|F,D|U,M|E,D|E,B|U,E|F,M|U,M|z,D|F,B|E,D|U,E|U,B|E,M|U,E|F,B|F,M|z];M=8192;D=1<<23;B=M|D;F=1;z=128;U=F|z;var Kw=[B|F,M|U,M|U,E|z,B|z,D|U,D|F,M|F,E|E,B|E,B|E,B|U,E|U,E|E,D|z,D|F,E|F,M|E,D|E,B|F,E|z,D|E,M|F,M|z,D|U,E|F,M|z,D|z,M|E,B|z,B|U,E|U,D|z,D|F,B|E,B|U,E|U,E|E,E|E,B|E,M|z,D|z,D|U,E|F,B|F,M|U,M|U,E|z,B|U,E|U,E|F,M|E,D|F,M|F,B|z,D|U,M|F,M|z,D|E,B|F,E|z,D|E,M|E,B|z];M=1<<25;D=1<<30;B=M|D;F=256;z=1<<19;U=F|z;var Xw=[E|F,M|U,M|z,B|F,E|z,E|F,D|E,M|z,D|U,E|z,M|F,D|U,B|F,B|z,E|U,D|E,M|E,D|z,D|z,E|E,D|F,B|U,B|U,M|F,B|z,D|F,E|E,B|E,M|U,M|E,B|E,E|U,E|z,B|F,E|F,M|E,D|E,M|z,B|F,D|U,M|F,D|E,B|z,M|U,D|U,E|F,M|E,B|z,B|U,E|U,B|E,B|U,M|z,E|E,D|z,B|E,E|U,M|F,D|F,E|z,E|E,D|z,M|U,D|F];M=1<<22;D=1<<29;B=M|D;F=16;z=16384;U=F|z;var Bw=[D|F,B|E,E|z,B|U,B|E,E|F,B|U,M|E,D|z,M|U,M|E,D|F,M|F,D|z,D|E,E|U,E|E,M|F,D|U,E|z,M|z,D|U,E|F,B|F,B|F,E|E,M|U,B|z,E|U,M|z,B|z,D|E,D|z,E|F,B|F,M|z,B|U,M|E,E|U,D|F,M|E,D|z,D|E,E|U,D|F,B|U,M|z,B|E,M|U,B|z,E|E,B|F,E|F,E|z,B|E,M|U,E|z,M|F,D|U,E|E,B|z,D|E,M|F,D|U];M=1<<21;D=1<<26;B=M|D;F=2;z=2048;U=F|z;var Uw=[M|E,B|F,D|U,E|E,E|z,D|U,M|U,B|z,B|U,M|E,E|E,D|F,E|F,D|E,B|F,E|U,D|z,M|U,M|F,D|z,D|F,B|E,B|z,M|F,B|E,E|z,E|U,B|U,M|z,E|F,D|E,M|z,D|E,M|z,M|E,D|U,D|U,B|F,B|F,E|F,M|F,D|E,D|z,M|E,B|z,E|U,M|U,B|z,E|U,D|F,B|U,B|E,M|z,E|E,E|F,B|U,E|E,M|U,B|E,E|z,D|F,D|z,E|z,M|F];M=1<<18;D=1<<28;B=M|D;F=64;z=4096;U=F|z;var Hw=[D|U,E|z,M|E,B|U,D|E,D|U,E|F,D|E,M|F,B|E,B|U,M|z,B|z,M|U,E|z,E|F,B|E,D|F,D|z,E|U,M|z,M|F,B|F,B|z,E|U,E|E,E|E,B|F,D|F,D|z,M|U,M|E,M|U,M|E,B|z,E|z,E|F,B|F,E|z,M|U,D|z,E|F,D|F,B|E,B|F,D|E,M|E,D|U,E|E,B|U,M|F,D|F,B|E,D|z,D|U,E|E,B|U,M|z,M|z,E|U,E|U,M|F,D|E,B|z],Sc=class{constructor(t){this.keys=[];let n=[],r=[],o=[];for(let s=0,i=56;s<56;++s,i-=8){i+=i<-5?65:i<-3?31:i<-1?63:i===27?35:0;let a=i&7;n[s]=(t[i>>>3]&1<<a)!==0?1:0}for(let s=0;s<16;++s){let i=s<<1,a=i+1;o[i]=o[a]=0;for(let u=28;u<59;u+=28)for(let c=u-28;c<u;++c){let d=c+o$[s];r[c]=d<u?n[d]:n[d-28]}for(let u=0;u<24;++u)r[Mw[u]]!==0&&(o[i]|=1<<23-u),r[Mw[u+24]]!==0&&(o[a]|=1<<23-u)}for(let s=0,i=0,a=0;s<16;++s){let u=o[i++],c=o[i++];this.keys[a]=(u&16515072)<<6,this.keys[a]|=(u&4032)<<10,this.keys[a]|=(c&16515072)>>>10,this.keys[a]|=(c&4032)>>>6,++a,this.keys[a]=(u&258048)<<12,this.keys[a]|=(u&63)<<16,this.keys[a]|=(c&258048)>>>4,this.keys[a]|=c&63,++a}}enc8(t){let n=t.slice(),r=0,o,s,i;o=n[r++]<<24|n[r++]<<16|n[r++]<<8|n[r++],s=n[r++]<<24|n[r++]<<16|n[r++]<<8|n[r++],i=(o>>>4^s)&252645135,s^=i,o^=i<<4,i=(o>>>16^s)&65535,s^=i,o^=i<<16,i=(s>>>2^o)&858993459,o^=i,s^=i<<2,i=(s>>>8^o)&16711935,o^=i,s^=i<<8,s=s<<1|s>>>31&1,i=(o^s)&2863311530,o^=i,s^=i,o=o<<1|o>>>31&1;for(let a=0,u=0;a<8;++a){i=s<<28|s>>>4,i^=this.keys[u++];let c=Uw[i&63];c|=Xw[i>>>8&63],c|=zw[i>>>16&63],c|=Dw[i>>>24&63],i=s^this.keys[u++],c|=Hw[i&63],c|=Bw[i>>>8&63],c|=Kw[i>>>16&63],c|=Fw[i>>>24&63],o^=c,i=o<<28|o>>>4,i^=this.keys[u++],c=Uw[i&63],c|=Xw[i>>>8&63],c|=zw[i>>>16&63],c|=Dw[i>>>24&63],i=o^this.keys[u++],c|=Hw[i&63],c|=Bw[i>>>8&63],c|=Kw[i>>>16&63],c|=Fw[i>>>24&63],s^=c}for(s=s<<31|s>>>1,i=(o^s)&2863311530,o^=i,s^=i,o=o<<31|o>>>1,i=(o>>>8^s)&16711935,s^=i,o^=i<<8,i=(o>>>2^s)&858993459,s^=i,o^=i<<2,i=(s>>>16^o)&65535,o^=i,s^=i<<16,i=(s>>>4^o)&252645135,o^=i,s^=i<<4,i=[s,o],r=0;r<8;r++)n[r]=(i[r>>>2]>>>8*(3-r%4))%256,n[r]<0&&(n[r]+=256);return n}},Ec=class e{constructor(){this._cipher=null}get algorithm(){return{name:"DES-ECB"}}static importKey(t,n,r,o){let s=new e;return s._importKey(t),s}_importKey(t,n,r){this._cipher=new Sc(t)}encrypt(t,n){let r=new Uint8Array(n);if(r.length%8!==0||this._cipher===null)return null;let o=r.length/8;for(let s=0;s<o;s++)r.set(this._cipher.enc8(r.slice(s*8,s*8+8)),s*8);return r}},Nc=class e{constructor(){this._cipher=null}get algorithm(){return{name:"DES-CBC"}}static importKey(t,n,r,o){let s=new e;return s._importKey(t),s}_importKey(t){this._cipher=new Sc(t)}encrypt(t,n){let r=new Uint8Array(n),o=new Uint8Array(t.iv);if(r.length%8!==0||this._cipher===null)return null;let s=r.length/8;for(let i=0;i<s;i++){for(let a=0;a<8;a++)o[a]^=n[i*8+a];o=this._cipher.enc8(o),r.set(o,i*8)}return r}};function Qo(e,t,n){let r=1n;for(e=e%n;t>0n;)(t&1n)===1n&&(r=r*e%n),t=t>>1n,e=e*e%n;return r}function Go(e,t=0){let n=e.toString(16);t===0&&(t=Math.ceil(n.length/2)),n=n.padStart(t*2,"0");let r=n.length/2,o=new Uint8Array(r);for(let s=0;s<r;s++)o[s]=parseInt(n.slice(s*2,s*2+2),16);return o}function Mt(e){let t="0x";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return BigInt(t)}var Ac=class e{constructor(){this._keyLength=0,this._keyBytes=0,this._n=null,this._e=null,this._d=null,this._nBigInt=null,this._eBigInt=null,this._dBigInt=null,this._extractable=!1}get algorithm(){return{name:"RSA-PKCS1-v1_5"}}_base64urlDecode(t){return t=t.replace(/-/g,"+").replace(/_/g,"/"),t=t.padEnd(Math.ceil(t.length/4)*4,"="),Oo.decode(t)}_padArray(t,n){let r=new Uint8Array(n);return r.set(t,n-t.length),r}static async generateKey(t,n,r){let o=new e;return await o._generateKey(t,n),{privateKey:o}}async _generateKey(t,n){this._keyLength=t.modulusLength,this._keyBytes=Math.ceil(this._keyLength/8);let r=await window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:t.modulusLength,publicExponent:t.publicExponent,hash:{name:"SHA-256"}},!0,["encrypt","decrypt"]),o=await window.crypto.subtle.exportKey("jwk",r.privateKey);this._n=this._padArray(this._base64urlDecode(o.n),this._keyBytes),this._nBigInt=Mt(this._n),this._e=this._padArray(this._base64urlDecode(o.e),this._keyBytes),this._eBigInt=Mt(this._e),this._d=this._padArray(this._base64urlDecode(o.d),this._keyBytes),this._dBigInt=Mt(this._d),this._extractable=n}static async importKey(t,n,r,o){if(o.length!==1||o[0]!=="encrypt")throw new Error("only support importing RSA public key");let s=new e;return await s._importKey(t,r),s}async _importKey(t,n){let r=t.n,o=t.e;if(r.length!==o.length)throw new Error("the sizes of modulus and public exponent do not match");this._keyBytes=r.length,this._keyLength=this._keyBytes*8,this._n=new Uint8Array(this._keyBytes),this._e=new Uint8Array(this._keyBytes),this._n.set(r),this._e.set(o),this._nBigInt=Mt(this._n),this._eBigInt=Mt(this._e),this._extractable=n}async encrypt(t,n){if(n.length>this._keyBytes-11)return null;let r=new Uint8Array(this._keyBytes-n.length-3);window.crypto.getRandomValues(r);for(let a=0;a<r.length;a++)r[a]=Math.floor(r[a]*254/255+1);let o=new Uint8Array(this._keyBytes);o[1]=2,o.set(r,2),o.set(n,r.length+3);let s=Mt(o),i=Qo(s,this._eBigInt,this._nBigInt);return Go(i,this._keyBytes)}async decrypt(t,n){if(n.length!==this._keyBytes)return null;let r=Mt(n),o=Qo(r,this._dBigInt,this._nBigInt),s=Go(o,this._keyBytes);if(s[0]!==0||s[1]!==2)return null;let i=2;for(;i<s.length&&s[i]!==0;i++);return i===s.length?null:s.slice(i+1,s.length)}async exportKey(){if(!this._extractable)throw new Error("key is not extractable");return{n:this._n,e:this._e,d:this._d}}};var mh=class{constructor(t){this._key=t}get algorithm(){return{name:"DH"}}exportKey(){return this._key}},Cc=class e{constructor(){this._g=null,this._p=null,this._gBigInt=null,this._pBigInt=null,this._privateKey=null}get algorithm(){return{name:"DH"}}static generateKey(t,n){let r=new e;return r._generateKey(t),{privateKey:r,publicKey:new mh(r._publicKey)}}_generateKey(t){let n=t.g,r=t.p;this._keyBytes=r.length,this._gBigInt=Mt(n),this._pBigInt=Mt(r),this._privateKey=window.crypto.getRandomValues(new Uint8Array(this._keyBytes)),this._privateKeyBigInt=Mt(this._privateKey),this._publicKey=Go(Qo(this._gBigInt,this._privateKeyBigInt,this._pBigInt),this._keyBytes)}deriveBits(t,n){let r=Math.ceil(n/8),o=new Uint8Array(t.public),s=r>this._keyBytes?r:this._keyBytes,i=Qo(Mt(o),this._privateKeyBigInt,this._pBigInt);return Go(i,s).slice(0,s)}};async function Vw(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return s$(a$(l$(i$(t),8*t.length)))}function s$(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function i$(e){let t=Array(e.length>>2);for(let n=0;n<t.length;n++)t[n]=0;for(let n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<n%32;return t}function a$(e){let t="";for(let n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}function l$(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;let n=1732584193,r=-271733879,o=-1732584194,s=271733878;for(let i=0;i<e.length;i+=16){let a=n,u=r,c=o,d=s;r=ft(r=ft(r=ft(r=ft(r=pt(r=pt(r=pt(r=pt(r=dt(r=dt(r=dt(r=dt(r=ut(r=ut(r=ut(r=ut(r,o=ut(o,s=ut(s,n=ut(n,r,o,s,e[i+0],7,-680876936),r,o,e[i+1],12,-389564586),n,r,e[i+2],17,606105819),s,n,e[i+3],22,-1044525330),o=ut(o,s=ut(s,n=ut(n,r,o,s,e[i+4],7,-176418897),r,o,e[i+5],12,1200080426),n,r,e[i+6],17,-1473231341),s,n,e[i+7],22,-45705983),o=ut(o,s=ut(s,n=ut(n,r,o,s,e[i+8],7,1770035416),r,o,e[i+9],12,-1958414417),n,r,e[i+10],17,-42063),s,n,e[i+11],22,-1990404162),o=ut(o,s=ut(s,n=ut(n,r,o,s,e[i+12],7,1804603682),r,o,e[i+13],12,-40341101),n,r,e[i+14],17,-1502002290),s,n,e[i+15],22,1236535329),o=dt(o,s=dt(s,n=dt(n,r,o,s,e[i+1],5,-165796510),r,o,e[i+6],9,-1069501632),n,r,e[i+11],14,643717713),s,n,e[i+0],20,-373897302),o=dt(o,s=dt(s,n=dt(n,r,o,s,e[i+5],5,-701558691),r,o,e[i+10],9,38016083),n,r,e[i+15],14,-660478335),s,n,e[i+4],20,-405537848),o=dt(o,s=dt(s,n=dt(n,r,o,s,e[i+9],5,568446438),r,o,e[i+14],9,-1019803690),n,r,e[i+3],14,-187363961),s,n,e[i+8],20,1163531501),o=dt(o,s=dt(s,n=dt(n,r,o,s,e[i+13],5,-1444681467),r,o,e[i+2],9,-51403784),n,r,e[i+7],14,1735328473),s,n,e[i+12],20,-1926607734),o=pt(o,s=pt(s,n=pt(n,r,o,s,e[i+5],4,-378558),r,o,e[i+8],11,-2022574463),n,r,e[i+11],16,1839030562),s,n,e[i+14],23,-35309556),o=pt(o,s=pt(s,n=pt(n,r,o,s,e[i+1],4,-1530992060),r,o,e[i+4],11,1272893353),n,r,e[i+7],16,-155497632),s,n,e[i+10],23,-1094730640),o=pt(o,s=pt(s,n=pt(n,r,o,s,e[i+13],4,681279174),r,o,e[i+0],11,-358537222),n,r,e[i+3],16,-722521979),s,n,e[i+6],23,76029189),o=pt(o,s=pt(s,n=pt(n,r,o,s,e[i+9],4,-640364487),r,o,e[i+12],11,-421815835),n,r,e[i+15],16,530742520),s,n,e[i+2],23,-995338651),o=ft(o,s=ft(s,n=ft(n,r,o,s,e[i+0],6,-198630844),r,o,e[i+7],10,1126891415),n,r,e[i+14],15,-1416354905),s,n,e[i+5],21,-57434055),o=ft(o,s=ft(s,n=ft(n,r,o,s,e[i+12],6,1700485571),r,o,e[i+3],10,-1894986606),n,r,e[i+10],15,-1051523),s,n,e[i+1],21,-2054922799),o=ft(o,s=ft(s,n=ft(n,r,o,s,e[i+8],6,1873313359),r,o,e[i+15],10,-30611744),n,r,e[i+6],15,-1560198380),s,n,e[i+13],21,1309151649),o=ft(o,s=ft(s,n=ft(n,r,o,s,e[i+4],6,-145523070),r,o,e[i+11],10,-1120210379),n,r,e[i+2],15,718787259),s,n,e[i+9],21,-343485551),n=rr(n,a),r=rr(r,u),o=rr(o,c),s=rr(s,d)}return Array(n,r,o,s)}function Tc(e,t,n,r,o,s){return rr(c$(rr(rr(t,e),rr(r,s)),o),n)}function ut(e,t,n,r,o,s,i){return Tc(t&n|~t&r,e,t,o,s,i)}function dt(e,t,n,r,o,s,i){return Tc(t&r|n&~r,e,t,o,s,i)}function pt(e,t,n,r,o,s,i){return Tc(t^n^r,e,t,o,s,i)}function ft(e,t,n,r,o,s,i){return Tc(n^(t|~r),e,t,o,s,i)}function rr(e,t){let n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function c$(e,t){return e<<t|e>>>32-t}var gh=class{constructor(){this._algorithms={"AES-ECB":wc,"AES-EAX":kc,"DES-ECB":Ec,"DES-CBC":Nc,"RSA-PKCS1-v1_5":Ac,DH:Cc,MD5:Vw}}encrypt(t,n,r){if(n.algorithm.name!==t.name)throw new Error("algorithm does not match");if(typeof n.encrypt!="function")throw new Error("key does not support encryption");return n.encrypt(t,r)}decrypt(t,n,r){if(n.algorithm.name!==t.name)throw new Error("algorithm does not match");if(typeof n.decrypt!="function")throw new Error("key does not support encryption");return n.decrypt(t,r)}importKey(t,n,r,o,s){if(t!=="raw")throw new Error("key format is not supported");let i=this._algorithms[r.name];if(typeof i>"u"||typeof i.importKey!="function")throw new Error("algorithm is not supported");return i.importKey(n,r,o,s)}generateKey(t,n,r){let o=this._algorithms[t.name];if(typeof o>"u"||typeof o.generateKey!="function")throw new Error("algorithm is not supported");return o.generateKey(t,n,r)}exportKey(t,n){if(t!=="raw")throw new Error("key format is not supported");if(typeof n.exportKey!="function")throw new Error("key does not support exportKey");return n.exportKey()}digest(t,n){let r=this._algorithms[t];if(typeof r!="function")throw new Error("algorithm is not supported");return r(n)}deriveBits(t,n,r){if(n.algorithm.name!==t.name)throw new Error("algorithm does not match");if(typeof n.deriveBits!="function")throw new Error("key does not support deriveBits");return n.deriveBits(t,r)}},Xe=new gh;var Rc=class{constructor(){this._cipher=null,this._counter=new Uint8Array(16)}async setKey(t){this._cipher=await Xe.importKey("raw",t,{name:"AES-EAX"},!1,["encrypt, decrypt"])}async makeMessage(t){let n=new Uint8Array([(t.length&65280)>>>8,t.length&255]),r=await Xe.encrypt({name:"AES-EAX",iv:this._counter,additionalData:n},this._cipher,t);for(let s=0;s<16&&this._counter[s]++===255;s++);let o=new Uint8Array(t.length+2+16);return o.set(n),o.set(r,2),o}async receiveMessage(t,n){let r=new Uint8Array([(t&65280)>>>8,t&255]),o=await Xe.decrypt({name:"AES-EAX",iv:this._counter,additionalData:r},this._cipher,n);for(let s=0;s<16&&this._counter[s]++===255;s++);return o}},Gi=class extends Or{constructor(t,n){super(),this._hasStarted=!1,this._checkSock=null,this._checkCredentials=null,this._approveServerResolve=null,this._sockReject=null,this._credentialsReject=null,this._approveServerReject=null,this._sock=t,this._getCredentials=n}_waitSockAsync(t){return new Promise((n,r)=>{let o=()=>!this._sock.rQwait("RA2",t);o()?n():(this._checkSock=()=>{o()&&(n(),this._checkSock=null,this._sockReject=null)},this._sockReject=r)})}_waitApproveKeyAsync(){return new Promise((t,n)=>{this._approveServerResolve=t,this._approveServerReject=n})}_waitCredentialsAsync(t){let n=()=>t===1&&this._getCredentials().username!==void 0&&this._getCredentials().password!==void 0?!0:t===2&&this._getCredentials().password!==void 0;return new Promise((r,o)=>{n()?r():(this._checkCredentials=()=>{n()&&(r(),this._checkCredentials=null,this._credentialsReject=null)},this._credentialsReject=o)})}checkInternalEvents(){this._checkSock!==null&&this._checkSock(),this._checkCredentials!==null&&this._checkCredentials()}approveServer(){this._approveServerResolve!==null&&(this._approveServerResolve(),this._approveServerResolve=null)}disconnect(){this._sockReject!==null&&(this._sockReject(new Error("disconnect normally")),this._sockReject=null),this._credentialsReject!==null&&(this._credentialsReject(new Error("disconnect normally")),this._credentialsReject=null),this._approveServerReject!==null&&(this._approveServerReject(new Error("disconnect normally")),this._approveServerReject=null)}async negotiateRA2neAuthAsync(){this._hasStarted=!0,await this._waitSockAsync(4);let t=this._sock.rQpeekBytes(4),n=this._sock.rQshift32();if(n<1024)throw new Error("RA2: server public key is too short: "+n);if(n>8192)throw new Error("RA2: server public key is too long: "+n);let r=Math.ceil(n/8);await this._waitSockAsync(r*2);let o=this._sock.rQshiftBytes(r),s=this._sock.rQshiftBytes(r),i=await Xe.importKey("raw",{n:o,e:s},{name:"RSA-PKCS1-v1_5"},!1,["encrypt"]),a=new Uint8Array(4+r*2);a.set(t),a.set(o,4),a.set(s,4+r);let u=this._waitApproveKeyAsync();this.dispatchEvent(new CustomEvent("serververification",{detail:{type:"RSA",publickey:a}})),await u;let c=2048,d=Math.ceil(c/8),p=(await Xe.generateKey({name:"RSA-PKCS1-v1_5",modulusLength:c,publicExponent:new Uint8Array([1,0,1])},!0,["encrypt"])).privateKey,f=await Xe.exportKey("raw",p),h=f.n,g=f.e,x=new Uint8Array(4+d*2);x[0]=(c&4278190080)>>>24,x[1]=(c&16711680)>>>16,x[2]=(c&65280)>>>8,x[3]=c&255,x.set(h,4),x.set(g,4+d),this._sock.sQpushBytes(x),this._sock.flush();let b=new Uint8Array(16);window.crypto.getRandomValues(b);let v=await Xe.encrypt({name:"RSA-PKCS1-v1_5"},i,b),w=new Uint8Array(2+r);if(w[0]=(r&65280)>>>8,w[1]=r&255,w.set(v,2),this._sock.sQpushBytes(w),this._sock.flush(),await this._waitSockAsync(2),this._sock.rQshift16()!==d)throw new Error("RA2: wrong encrypted message length");let C=this._sock.rQshiftBytes(d),y=await Xe.decrypt({name:"RSA-PKCS1-v1_5"},p,C);if(y===null||y.length!==16)throw new Error("RA2: corrupted server encrypted random");let T=new Uint8Array(32),N=new Uint8Array(32);T.set(y),T.set(b,16),N.set(b),N.set(y,16),T=await window.crypto.subtle.digest("SHA-1",T),T=new Uint8Array(T).slice(0,16),N=await window.crypto.subtle.digest("SHA-1",N),N=new Uint8Array(N).slice(0,16);let S=new Rc;await S.setKey(T);let $=new Rc;await $.setKey(N);let P=new Uint8Array(8+r*2+d*2),L=new Uint8Array(8+r*2+d*2);if(P.set(a),P.set(x,4+r*2),L.set(x),L.set(a,4+d*2),P=await window.crypto.subtle.digest("SHA-1",P),L=await window.crypto.subtle.digest("SHA-1",L),P=new Uint8Array(P),L=new Uint8Array(L),this._sock.sQpushBytes(await S.makeMessage(L)),this._sock.flush(),await this._waitSockAsync(38),this._sock.rQshift16()!==20)throw new Error("RA2: wrong server hash");let ne=await $.receiveMessage(20,this._sock.rQshiftBytes(36));if(ne===null)throw new Error("RA2: failed to authenticate the message");for(let G=0;G<20;G++)if(ne[G]!==P[G])throw new Error("RA2: wrong server hash");if(await this._waitSockAsync(19),this._sock.rQshift16()!==1)throw new Error("RA2: wrong subtype");let se=await $.receiveMessage(1,this._sock.rQshiftBytes(17));if(se===null)throw new Error("RA2: failed to authenticate the message");se=se[0];let _e=this._waitCredentialsAsync(se);if(se===1)(this._getCredentials().username===void 0||this._getCredentials().password===void 0)&&this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}}));else if(se===2)this._getCredentials().password===void 0&&this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["password"]}}));else throw new Error("RA2: wrong subtype");await _e;let ie;se===1?ie=Gt(this._getCredentials().username).slice(0,255):ie="";let Q=Gt(this._getCredentials().password).slice(0,255),j=new Uint8Array(ie.length+Q.length+2);j[0]=ie.length,j[ie.length+1]=Q.length;for(let G=0;G<ie.length;G++)j[G+1]=ie.charCodeAt(G);for(let G=0;G<Q.length;G++)j[ie.length+2+G]=Q.charCodeAt(G);this._sock.sQpushBytes(await S.makeMessage(j)),this._sock.flush()}get hasStarted(){return this._hasStarted}set hasStarted(t){this._hasStarted=t}};var Yi=class{constructor(){this._lines=0}decodeRect(t,n,r,o,s,i,a){if(r===0||o===0)return!0;this._lines===0&&(this._lines=o);let u=a==8?1:4,c=r*u;for(;this._lines>0;){if(s.rQwait("RAW",c))return!1;let d=n+(o-this._lines),p=s.rQshiftBytes(c,!1);if(a==8){let f=new Uint8Array(r*4);for(let h=0;h<r;h++)f[h*4+0]=(p[h]>>0&3)*255/3,f[h*4+1]=(p[h]>>2&3)*255/3,f[h*4+2]=(p[h]>>4&3)*255/3,f[h*4+3]=255;p=f}for(let f=0;f<r;f++)p[f*4+3]=255;i.blitImage(t,d,r,1,p,0),this._lines--}return!0}};var qi=class{decodeRect(t,n,r,o,s,i,a){if(s.rQwait("COPYRECT",4))return!1;let u=s.rQshift16(),c=s.rQshift16();return r===0||o===0||i.copyImage(u,c,t,n,r,o),!0}};var Ji=class{constructor(){this._subrects=0}decodeRect(t,n,r,o,s,i,a){if(this._subrects===0){if(s.rQwait("RRE",8))return!1;this._subrects=s.rQshift32();let u=s.rQshiftBytes(4);i.fillRect(t,n,r,o,u)}for(;this._subrects>0;){if(s.rQwait("RRE",12))return!1;let u=s.rQshiftBytes(4),c=s.rQshift16(),d=s.rQshift16(),p=s.rQshift16(),f=s.rQshift16();i.fillRect(t+c,n+d,p,f,u),this._subrects--}return!0}};var ea=class{constructor(){this._tiles=0,this._lastsubencoding=0,this._tileBuffer=new Uint8Array(256*4)}decodeRect(t,n,r,o,s,i,a){for(this._tiles===0&&(this._tilesX=Math.ceil(r/16),this._tilesY=Math.ceil(o/16),this._totalTiles=this._tilesX*this._tilesY,this._tiles=this._totalTiles);this._tiles>0;){let u=1;if(s.rQwait("HEXTILE",u))return!1;let c=s.rQpeek8();if(c>30)throw new Error("Illegal hextile subencoding (subencoding: "+c+")");let d=this._totalTiles-this._tiles,p=d%this._tilesX,f=Math.floor(d/this._tilesX),h=t+p*16,g=n+f*16,x=Math.min(16,t+r-h),b=Math.min(16,n+o-g);if(c&1)u+=x*b*4;else if(c&2&&(u+=4),c&4&&(u+=4),c&8){if(u++,s.rQwait("HEXTILE",u))return!1;let v=s.rQpeekBytes(u).at(-1);c&16?u+=v*6:u+=v*2}if(s.rQwait("HEXTILE",u))return!1;if(s.rQshift8(),c===0)this._lastsubencoding&1?de(" Ignoring blank after RAW"):i.fillRect(h,g,x,b,this._background);else if(c&1){let v=x*b,w=s.rQshiftBytes(v*4,!1);for(let C=0;C<v;C++)w[C*4+3]=255;i.blitImage(h,g,x,b,w,0)}else{if(c&2&&(this._background=new Uint8Array(s.rQshiftBytes(4))),c&4&&(this._foreground=new Uint8Array(s.rQshiftBytes(4))),this._startTile(h,g,x,b,this._background),c&8){let v=s.rQshift8();for(let w=0;w<v;w++){let C;c&16?C=s.rQshiftBytes(4):C=this._foreground;let y=s.rQshift8(),T=y>>4,N=y&15,S=s.rQshift8(),$=(S>>4)+1,P=(S&15)+1;this._subTile(T,N,$,P,C)}}this._finishTile(i)}this._lastsubencoding=c,this._tiles--}return!0}_startTile(t,n,r,o,s){this._tileX=t,this._tileY=n,this._tileW=r,this._tileH=o;let i=s[0],a=s[1],u=s[2],c=this._tileBuffer;for(let d=0;d<r*o*4;d+=4)c[d]=i,c[d+1]=a,c[d+2]=u,c[d+3]=255}_subTile(t,n,r,o,s){let i=s[0],a=s[1],u=s[2],c=t+r,d=n+o,p=this._tileBuffer,f=this._tileW;for(let h=n;h<d;h++)for(let g=t;g<c;g++){let x=(g+h*f)*4;p[x]=i,p[x+1]=a,p[x+2]=u,p[x+3]=255}}_finishTile(t){t.blitImage(this._tileX,this._tileY,this._tileW,this._tileH,this._tileBuffer,0)}};var ta=class{constructor(){this._zlib=new Yt,this._length=0}decodeRect(t,n,r,o,s,i,a){if(r===0||o===0)return!0;if(this._length===0){if(s.rQwait("ZLIB",4))return!1;this._length=s.rQshift32()}if(s.rQwait("ZLIB",this._length))return!1;let u=new Uint8Array(s.rQshiftBytes(this._length,!1));this._length=0,this._zlib.setInput(u),u=this._zlib.inflate(r*o*4),this._zlib.setInput(null);for(let c=0;c<r*o;c++)u[c*4+3]=255;return i.blitImage(t,n,r,o,u,0),!0}};var Ur=class{constructor(){this._ctl=null,this._filter=null,this._numColors=0,this._palette=new Uint8Array(1024),this._len=0,this._zlibs=[];for(let t=0;t<4;t++)this._zlibs[t]=new Yt}decodeRect(t,n,r,o,s,i,a){if(this._ctl===null){if(s.rQwait("TIGHT compression-control",1))return!1;this._ctl=s.rQshift8();for(let c=0;c<4;c++)this._ctl>>c&1&&(this._zlibs[c].reset(),Qe("Reset zlib stream "+c));this._ctl=this._ctl>>4}let u;if(this._ctl===8)u=this._fillRect(t,n,r,o,s,i,a);else if(this._ctl===9)u=this._jpegRect(t,n,r,o,s,i,a);else if(this._ctl===10)u=this._pngRect(t,n,r,o,s,i,a);else if((this._ctl&8)==0)u=this._basicRect(this._ctl,t,n,r,o,s,i,a);else throw new Error("Illegal tight compression received (ctl: "+this._ctl+")");return u&&(this._ctl=null),u}_fillRect(t,n,r,o,s,i,a){if(s.rQwait("TIGHT",3))return!1;let u=s.rQshiftBytes(3);return i.fillRect(t,n,r,o,u,!1),!0}_jpegRect(t,n,r,o,s,i,a){let u=this._readData(s);return u===null?!1:(i.imageRect(t,n,r,o,"image/jpeg",u),!0)}_pngRect(t,n,r,o,s,i,a){throw new Error("PNG received in standard Tight rect")}_basicRect(t,n,r,o,s,i,a,u){if(this._filter===null)if(t&4){if(i.rQwait("TIGHT",1))return!1;this._filter=i.rQshift8()}else this._filter=0;let c=t&3,d;switch(this._filter){case 0:d=this._copyFilter(c,n,r,o,s,i,a,u);break;case 1:d=this._paletteFilter(c,n,r,o,s,i,a,u);break;case 2:d=this._gradientFilter(c,n,r,o,s,i,a,u);break;default:throw new Error("Illegal tight filter received (ctl: "+this._filter+")")}return d&&(this._filter=null),d}_copyFilter(t,n,r,o,s,i,a,u){let c=o*s*3,d;if(c===0)return!0;if(c<12){if(i.rQwait("TIGHT",c))return!1;d=i.rQshiftBytes(c)}else{if(d=this._readData(i),d===null)return!1;this._zlibs[t].setInput(d),d=this._zlibs[t].inflate(c),this._zlibs[t].setInput(null)}let p=new Uint8Array(o*s*4);for(let f=0,h=0;f<o*s*4;f+=4,h+=3)p[f]=d[h],p[f+1]=d[h+1],p[f+2]=d[h+2],p[f+3]=255;return a.blitImage(n,r,o,s,p,0,!1),!0}_paletteFilter(t,n,r,o,s,i,a,u){if(this._numColors===0){if(i.rQwait("TIGHT palette",1))return!1;let h=i.rQpeek8()+1,g=h*3;if(i.rQwait("TIGHT palette",1+g))return!1;this._numColors=h,i.rQskipBytes(1),i.rQshiftTo(this._palette,g)}let c=this._numColors<=2?1:8,p=Math.floor((o*c+7)/8)*s,f;if(p===0)return!0;if(p<12){if(i.rQwait("TIGHT",p))return!1;f=i.rQshiftBytes(p)}else{if(f=this._readData(i),f===null)return!1;this._zlibs[t].setInput(f),f=this._zlibs[t].inflate(p),this._zlibs[t].setInput(null)}return this._numColors==2?this._monoRect(n,r,o,s,f,this._palette,a):this._paletteRect(n,r,o,s,f,this._palette,a),this._numColors=0,!0}_monoRect(t,n,r,o,s,i,a){let u=this._getScratchBuffer(r*o*4),c=Math.floor((r+7)/8),d=Math.floor(r/8);for(let p=0;p<o;p++){let f,h,g;for(g=0;g<d;g++)for(let x=7;x>=0;x--)f=(p*r+g*8+7-x)*4,h=(s[p*c+g]>>x&1)*3,u[f]=i[h],u[f+1]=i[h+1],u[f+2]=i[h+2],u[f+3]=255;for(let x=7;x>=8-r%8;x--)f=(p*r+g*8+7-x)*4,h=(s[p*c+g]>>x&1)*3,u[f]=i[h],u[f+1]=i[h+1],u[f+2]=i[h+2],u[f+3]=255}a.blitImage(t,n,r,o,u,0,!1)}_paletteRect(t,n,r,o,s,i,a){let u=this._getScratchBuffer(r*o*4),c=r*o*4;for(let d=0,p=0;d<c;d+=4,p++){let f=s[p]*3;u[d]=i[f],u[d+1]=i[f+1],u[d+2]=i[f+2],u[d+3]=255}a.blitImage(t,n,r,o,u,0,!1)}_gradientFilter(t,n,r,o,s,i,a,u){let c=o*s*3,d;if(c===0)return!0;if(c<12){if(i.rQwait("TIGHT",c))return!1;d=i.rQshiftBytes(c)}else{if(d=this._readData(i),d===null)return!1;this._zlibs[t].setInput(d),d=this._zlibs[t].inflate(c),this._zlibs[t].setInput(null)}let p=new Uint8Array(4*o*s),f=0,h=0,g=new Uint8Array(3);for(let w=0;w<o;w++){for(let C=0;C<3;C++){let y=g[C],T=d[h++]+y;p[f++]=T,g[C]=T}p[f++]=255}let x=0,b=new Uint8Array(3),v=new Uint8Array(3);for(let w=1;w<s;w++){g.fill(0),v.fill(0);for(let C=0;C<o;C++){for(let y=0;y<3;y++){b[y]=p[x++];let T=g[y]+b[y]-v[y];T<0?T=0:T>255&&(T=255);let N=d[h++]+T;p[f++]=N,v[y]=b[y],g[y]=N}p[f++]=255,x++}}return a.blitImage(n,r,o,s,p,0,!1),!0}_readData(t){if(this._len===0){if(t.rQwait("TIGHT",3))return null;let r;r=t.rQshift8(),this._len=r&127,r&128&&(r=t.rQshift8(),this._len|=(r&127)<<7,r&128&&(r=t.rQshift8(),this._len|=r<<14))}if(t.rQwait("TIGHT",this._len))return null;let n=t.rQshiftBytes(this._len,!1);return this._len=0,n}_getScratchBuffer(t){return(!this._scratchBuffer||this._scratchBuffer.length<t)&&(this._scratchBuffer=new Uint8Array(t)),this._scratchBuffer}};var na=class extends Ur{_pngRect(t,n,r,o,s,i,a){let u=this._readData(s);return u===null?!1:(i.imageRect(t,n,r,o,"image/png",u),!0)}_basicRect(t,n,r,o,s,i,a,u){throw new Error("BasicCompression received in TightPNG rect")}};var $c=64,Ic=64,ra=class{constructor(){this._length=0,this._inflator=new Yt,this._pixelBuffer=new Uint8Array($c*Ic*4),this._tileBuffer=new Uint8Array($c*Ic*4)}decodeRect(t,n,r,o,s,i,a){if(this._length===0){if(s.rQwait("ZLib data length",4))return!1;this._length=s.rQshift32()}if(s.rQwait("Zlib data",this._length))return!1;let u=s.rQshiftBytes(this._length,!1);this._inflator.setInput(u);for(let c=n;c<n+o;c+=Ic){let d=Math.min(Ic,n+o-c);for(let p=t;p<t+r;p+=$c){let f=Math.min($c,t+r-p),h=f*d,g=this._inflator.inflate(1)[0];if(g===0){let x=this._readPixels(h);i.blitImage(p,c,f,d,x,0,!1)}else if(g===1){let x=this._readPixels(1);i.fillRect(p,c,f,d,[x[0],x[1],x[2]])}else if(g>=2&&g<=16){let x=this._decodePaletteTile(g,h,f,d);i.blitImage(p,c,f,d,x,0,!1)}else if(g===128){let x=this._decodeRLETile(h);i.blitImage(p,c,f,d,x,0,!1)}else if(g>=130&&g<=255){let x=this._decodeRLEPaletteTile(g-128,h);i.blitImage(p,c,f,d,x,0,!1)}else throw new Error("Unknown subencoding: "+g)}}return this._length=0,!0}_getBitsPerPixelInPalette(t){if(t<=2)return 1;if(t<=4)return 2;if(t<=16)return 4}_readPixels(t){let n=this._pixelBuffer,r=this._inflator.inflate(3*t);for(let o=0,s=0;o<t*4;o+=4,s+=3)n[o]=r[s],n[o+1]=r[s+1],n[o+2]=r[s+2],n[o+3]=255;return n}_decodePaletteTile(t,n,r,o){let s=this._tileBuffer,i=this._readPixels(t),a=this._getBitsPerPixelInPalette(t),u=(1<<a)-1,c=0,d=this._inflator.inflate(1)[0];for(let p=0;p<o;p++){let f=8-a;for(let h=0;h<r;h++){f<0&&(f=8-a,d=this._inflator.inflate(1)[0]);let g=d>>f&u;s[c]=i[g*4],s[c+1]=i[g*4+1],s[c+2]=i[g*4+2],s[c+3]=i[g*4+3],c+=4,f-=a}f<8-a&&p<o-1&&(d=this._inflator.inflate(1)[0])}return s}_decodeRLETile(t){let n=this._tileBuffer,r=0;for(;r<t;){let o=this._readPixels(1),s=this._readRLELength();for(let i=0;i<s;i++)n[r*4]=o[0],n[r*4+1]=o[1],n[r*4+2]=o[2],n[r*4+3]=o[3],r++}return n}_decodeRLEPaletteTile(t,n){let r=this._tileBuffer,o=this._readPixels(t),s=0;for(;s<n;){let i=this._inflator.inflate(1)[0],a=1;if(i>=128&&(i-=128,a=this._readRLELength()),i>t)throw new Error("Too big index in palette: "+i+", palette size: "+t);if(s+a>n)throw new Error("Too big rle length in palette mode: "+a+", allowed length is: "+(n-s));for(let u=0;u<a;u++)r[s*4]=o[i*4],r[s*4+1]=o[i*4+1],r[s*4+2]=o[i*4+2],r[s*4+3]=o[i*4+3],s++}return r}_readRLELength(){let t=0,n=0;do n=this._inflator.inflate(1)[0],t+=n;while(n===255);return t+1}};var oa=class{constructor(){this._cachedQuantTables=[],this._cachedHuffmanTables=[],this._segments=[]}decodeRect(t,n,r,o,s,i,a){for(;;){let h=this._readSegment(s);if(h===null)return!1;if(this._segments.push(h),h[1]===217)break}let u=[],c=[];for(let h of this._segments){let g=h[1];g===196?u.push(h):g===219&&c.push(h)}let d=this._segments.findIndex(h=>h[1]==192||h[1]==194);if(d==-1)throw new Error("Illegal JPEG image without SOF");c.length===0&&this._segments.splice(d+1,0,...this._cachedQuantTables),u.length===0&&this._segments.splice(d+1,0,...this._cachedHuffmanTables);let p=0;for(let h of this._segments)p+=h.length;let f=new Uint8Array(p);p=0;for(let h of this._segments)f.set(h,p),p+=h.length;return i.imageRect(t,n,r,o,"image/jpeg",f),u.length!==0&&(this._cachedHuffmanTables=u),c.length!==0&&(this._cachedQuantTables=c),this._segments=[],!0}_readSegment(t){if(t.rQwait("JPEG",2))return null;let n=t.rQshift8();if(n!=255)throw new Error("Illegal JPEG marker received (byte: "+n+")");let r=t.rQshift8();if(r>=208&&r<=217||r==1)return new Uint8Array([n,r]);if(t.rQwait("JPEG",2,2))return null;let o=t.rQshift16();if(o<2)throw new Error("Illegal JPEG length received (length: "+o+")");if(t.rQwait("JPEG",o-2,4))return null;let s=0;if(r===218){if(t.rQwait("JPEG",o-2+2,4))return null;let a=t.rQlen(),u=t.rQpeekBytes(a,!1);for(;;){let c=u.indexOf(255,o-2+s);if(c===-1||c===a-1)return t.rQwait("JPEG",1/0,4),null;if(u.at(c+1)===0||u.at(c+1)>=208&&u.at(c+1)<=215){s=c+2-(o-2);continue}s=c-(o-2);break}}let i=new Uint8Array(2+o+s);return i[0]=n,i[1]=r,i[2]=o>>8,i[3]=o,i.set(t.rQshiftBytes(o-2+s,!1),4),i}};var xh=class{constructor(t){this._data=t,this._index=0,this.profileIdc=null,this.constraintSet=null,this.levelIdc=null}_getStartSequenceLen(t){let n=this._data;return n[t+0]==0&&n[t+1]==0&&n[t+2]==0&&n[t+3]==1?4:n[t+0]==0&&n[t+1]==0&&n[t+2]==1?3:0}_indexOfNextNalUnit(t){let n=this._data;for(let r=t;r<n.length;++r)if(this._getStartSequenceLen(r)!=0)return r;return-1}_parseSps(t){this.profileIdc=this._data[t],this.constraintSet=this._data[t+1],this.levelIdc=this._data[t+2]}_parseNalUnit(t){let n=this._data[t];if(n&128)throw new Error("H264 parsing sanity check failed, forbidden zero bit is set");let r=n&31;switch(r){case 1:return{slice:!0};case 5:return{slice:!0,key:!0};case 6:return{};case 7:return this._parseSps(t+1),{};case 8:return{};default:Ye("Unhandled unit type: ",r);break}return{}}parse(){let t=this._index,n=!1;for(;this._index<this._data.length;){let r=this._getStartSequenceLen(this._index);if(r==0)throw new Error("Invalid start sequence in bit stream");let{slice:o,key:s}=this._parseNalUnit(this._index+r),i=this._indexOfNextNalUnit(this._index+r);if(i==-1?this._index=this._data.length:this._index=i,s&&(n=!0),o)break}return t===this._index?null:{frame:this._data.subarray(t,this._index),key:n}}},bh=class{constructor(t,n){this.lastUsed=0,this._width=t,this._height=n,this._profileIdc=null,this._constraintSet=null,this._levelIdc=null,this._decoder=null,this._pendingFrames=[]}_handleFrame(t){let n=this._pendingFrames.shift();if(n===void 0)throw new Error("Pending frame queue empty when receiving frame from decoder");if(n.timestamp!=t.timestamp)throw new Error("Video frame timestamp mismatch. Expected "+t.timestamp+" but but got "+n.timestamp);n.frame=t,n.ready=!0,n.resolve(),n.keep||t.close()}_handleError(t){throw new Error("Failed to decode frame: "+t.message)}_configureDecoder(t,n,r){(this._decoder===null||this._decoder.state==="closed")&&(this._decoder=new VideoDecoder({output:s=>this._handleFrame(s),error:s=>this._handleError(s)}));let o="avc1."+t.toString(16).padStart(2,"0")+n.toString(16).padStart(2,"0")+r.toString(16).padStart(2,"0");this._decoder.configure({codec:o,codedWidth:this._width,codedHeight:this._height,optimizeForLatency:!0})}_preparePendingFrame(t){let n={timestamp:t,promise:null,resolve:null,frame:null,ready:!1,keep:!1};return n.promise=new Promise(r=>{n.resolve=r}),this._pendingFrames.push(n),n}decode(t){let n=new xh(t),r=null,o=Math.round(window.performance.now()*1e3);for(;;){let s=n.parse();if(s===null)break;if(n.profileIdc!==null&&(self._profileIdc=n.profileIdc,self._constraintSet=n.constraintSet,self._levelIdc=n.levelIdc),this._decoder===null||this._decoder.state!=="configured"){if(!s.key){Ye("Missing key frame. Can't decode until one arrives");continue}if(self._profileIdc===null){Ye("Cannot config decoder. Have not received SPS and PPS yet.");continue}this._configureDecoder(self._profileIdc,self._constraintSet,self._levelIdc)}r=this._preparePendingFrame(o);let i=new EncodedVideoChunk({timestamp:o,type:s.key?"key":"delta",data:s.frame});try{this._decoder.decode(i)}catch(a){Ye("Failed to decode:",a)}}return r!==null&&(r.keep=!0),r}},sa=class{constructor(){this._tick=0,this._contexts={}}_contextId(t,n,r,o){return[t,n,r,o].join(",")}_findOldestContextId(){let t=Number.MAX_VALUE,n;for(let[r,o]of Object.entries(this._contexts))o.lastUsed<t&&(t=o.lastUsed,n=r);return n}_createContext(t,n,r,o){if(Object.keys(this._contexts).length>=64){let a=this._findOldestContextId();delete this._contexts[a]}let i=new bh(r,o);return this._contexts[this._contextId(t,n,r,o)]=i,i}_getContext(t,n,r,o){let s=this._contexts[this._contextId(t,n,r,o)];return s!==void 0?s:this._createContext(t,n,r,o)}_resetContext(t,n,r,o){delete this._contexts[this._contextId(t,n,r,o)]}_resetAllContexts(){this._contexts={}}decodeRect(t,n,r,o,s,i,a){if(s.rQwait("h264 header",8))return!1;let d=s.rQshift32(),p=s.rQshift32();if(s.rQwait("h264 payload",d,8))return!1;p&2?this._resetAllContexts():p&1&&this._resetContext(t,n,r,o);let f=this._getContext(t,n,r,o);if(f.lastUsed=this._tick++,d!==0){let h=s.rQshiftBytes(d,!1),g=f.decode(h);g!==null&&i.videoFrame(t,n,r,o,g)}return!0}};var u$=3,d$="rgb(40, 40, 40)",Zw=17,Ww=50,jw=19,ia=75,or=50,p$=1e3,f$=50,Qw=1,Pc=2,Gw=6,Yw=16,yh=19,qw=22,Jw=30,ek=113,tk=129,nk=256,fn=1;var rk=1<<24,Oc=1<<25,ok=1<<26,aa=1<<27,Lc=1<<28,yt=class e extends Or{constructor(t,n,r){if(!t)throw new Error("Must specify target");if(!n)throw new Error("Must specify URL, WebSocket or RTCDataChannel");window.isSecureContext||Me("noVNC requires a secure context (TLS). Expect crashes!"),super(),this._target=t,typeof n=="string"?this._url=n:(this._url=null,this._rawChannel=n),r=r||{},this._rfbCredentials=r.credentials||{},this._shared="shared"in r?!!r.shared:!0,this._repeaterID=r.repeaterID||"",this._wsProtocols=r.wsProtocols||[],this._rfbConnectionState="",this._rfbInitState="",this._rfbAuthScheme=-1,this._rfbCleanDisconnect=!0,this._rfbRSAAESAuthenticationState=null,this._rfbVersion=0,this._rfbMaxVersion=3.8,this._rfbTightVNC=!1,this._rfbVeNCryptState=0,this._rfbXvpVer=0,this._fbWidth=0,this._fbHeight=0,this._fbName="",this._capabilities={power:!1},this._supportsFence=!1,this._supportsContinuousUpdates=!1,this._enabledContinuousUpdates=!1,this._supportsSetDesktopSize=!1,this._screenID=0,this._screenFlags=0,this._pendingRemoteResize=!1,this._lastResize=0,this._qemuExtKeyEventSupported=!1,this._extendedPointerEventSupported=!1,this._clipboardText=null,this._clipboardServerCapabilitiesActions={},this._clipboardServerCapabilitiesFormats={},this._sock=null,this._display=null,this._flushing=!1,this._keyboard=null,this._gestures=null,this._resizeObserver=null,this._disconnTimer=null,this._resizeTimeout=null,this._mouseMoveTimer=null,this._decoders={},this._FBU={rects:0,x:0,y:0,width:0,height:0,encoding:null},this._mousePos={},this._mouseButtonMask=0,this._mouseLastMoveTime=0,this._viewportDragging=!1,this._viewportDragPos={},this._viewportHasMoved=!1,this._accumulatedWheelDeltaX=0,this._accumulatedWheelDeltaY=0,this._gestureLastTapTime=null,this._gestureFirstDoubleTapEv=null,this._gestureLastMagnitudeX=0,this._gestureLastMagnitudeY=0,this._eventHandlers={focusCanvas:this._focusCanvas.bind(this),handleResize:this._handleResize.bind(this),handleMouse:this._handleMouse.bind(this),handleWheel:this._handleWheel.bind(this),handleGesture:this._handleGesture.bind(this),handleRSAAESCredentialsRequired:this._handleRSAAESCredentialsRequired.bind(this),handleRSAAESServerVerification:this._handleRSAAESServerVerification.bind(this)},de(">> RFB.constructor"),this._screen=document.createElement("div"),this._screen.style.display="flex",this._screen.style.width="100%",this._screen.style.height="100%",this._screen.style.overflow="auto",this._screen.style.background=d$,this._canvas=document.createElement("canvas"),this._canvas.style.margin="auto",this._canvas.style.outline="none",this._canvas.width=0,this._canvas.height=0,this._canvas.tabIndex=-1,this._screen.appendChild(this._canvas),this._cursor=new ji,this._cursorImage=e.cursors.none,this._decoders[ge.encodingRaw]=new Yi,this._decoders[ge.encodingCopyRect]=new qi,this._decoders[ge.encodingRRE]=new Ji,this._decoders[ge.encodingHextile]=new ea,this._decoders[ge.encodingZlib]=new ta,this._decoders[ge.encodingTight]=new Ur,this._decoders[ge.encodingTightPNG]=new na,this._decoders[ge.encodingZRLE]=new ra,this._decoders[ge.encodingJPEG]=new oa,this._decoders[ge.encodingH264]=new sa;try{this._display=new $i(this._canvas)}catch(o){throw Me("Display exception: "+o),o}this._keyboard=new Vi(this._canvas),this._keyboard.onkeyevent=this._handleKeyEvent.bind(this),this._remoteCapsLock=null,this._remoteNumLock=null,this._gestures=new Zi,this._sock=new Qi,this._sock.on("open",this._socketOpen.bind(this)),this._sock.on("close",this._socketClose.bind(this)),this._sock.on("message",this._handleMessage.bind(this)),this._sock.on("error",this._socketError.bind(this)),this._expectedClientWidth=null,this._expectedClientHeight=null,this._resizeObserver=new ResizeObserver(this._eventHandlers.handleResize),this._updateConnectionState("connecting"),de("<< RFB.constructor"),this.dragViewport=!1,this.focusOnClick=!0,this._viewOnly=!1,this._clipViewport=!1,this._clippingViewport=!1,this._scaleViewport=!1,this._resizeSession=!1,this._showDotCursor=!1,this._qualityLevel=6,this._compressionLevel=2}get viewOnly(){return this._viewOnly}set viewOnly(t){this._viewOnly=t,(this._rfbConnectionState==="connecting"||this._rfbConnectionState==="connected")&&(t?this._keyboard.ungrab():this._keyboard.grab())}get capabilities(){return this._capabilities}get clippingViewport(){return this._clippingViewport}_setClippingViewport(t){t!==this._clippingViewport&&(this._clippingViewport=t,this.dispatchEvent(new CustomEvent("clippingviewport",{detail:this._clippingViewport})))}get touchButton(){return 0}set touchButton(t){Ye("Using old API!")}get clipViewport(){return this._clipViewport}set clipViewport(t){this._clipViewport=t,this._updateClip()}get scaleViewport(){return this._scaleViewport}set scaleViewport(t){this._scaleViewport=t,t&&this._clipViewport&&this._updateClip(),this._updateScale(),!t&&this._clipViewport&&this._updateClip()}get resizeSession(){return this._resizeSession}set resizeSession(t){this._resizeSession=t,t&&this._requestRemoteResize()}get showDotCursor(){return this._showDotCursor}set showDotCursor(t){this._showDotCursor=t,this._refreshCursor()}get background(){return this._screen.style.background}set background(t){this._screen.style.background=t}get qualityLevel(){return this._qualityLevel}set qualityLevel(t){if(!Number.isInteger(t)||t<0||t>9){Me("qualityLevel must be an integer between 0 and 9");return}this._qualityLevel!==t&&(this._qualityLevel=t,this._rfbConnectionState==="connected"&&this._sendEncodings())}get compressionLevel(){return this._compressionLevel}set compressionLevel(t){if(!Number.isInteger(t)||t<0||t>9){Me("compressionLevel must be an integer between 0 and 9");return}this._compressionLevel!==t&&(this._compressionLevel=t,this._rfbConnectionState==="connected"&&this._sendEncodings())}disconnect(){this._updateConnectionState("disconnecting"),this._sock.off("error"),this._sock.off("message"),this._sock.off("open"),this._rfbRSAAESAuthenticationState!==null&&this._rfbRSAAESAuthenticationState.disconnect()}approveServer(){this._rfbRSAAESAuthenticationState!==null&&this._rfbRSAAESAuthenticationState.approveServer()}sendCredentials(t){this._rfbCredentials=t,this._resumeAuthentication()}sendCtrlAltDel(){this._rfbConnectionState!=="connected"||this._viewOnly||(Qe("Sending Ctrl-Alt-Del"),this.sendKey(A.XK_Control_L,"ControlLeft",!0),this.sendKey(A.XK_Alt_L,"AltLeft",!0),this.sendKey(A.XK_Delete,"Delete",!0),this.sendKey(A.XK_Delete,"Delete",!1),this.sendKey(A.XK_Alt_L,"AltLeft",!1),this.sendKey(A.XK_Control_L,"ControlLeft",!1))}machineShutdown(){this._xvpOp(1,2)}machineReboot(){this._xvpOp(1,3)}machineReset(){this._xvpOp(1,4)}sendKey(t,n,r){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;if(r===void 0){this.sendKey(t,n,!0),this.sendKey(t,n,!1);return}let o=Lw[n];if(this._qemuExtKeyEventSupported&&o)t=t||0,Qe("Sending key ("+(r?"down":"up")+"): keysym "+t+", scancode "+o),e.messages.QEMUExtendedKeyEvent(this._sock,t,r,o);else{if(!t)return;Qe("Sending keysym ("+(r?"down":"up")+"): "+t),e.messages.keyEvent(this._sock,t,r?1:0)}}focus(t){this._canvas.focus(t)}blur(){this._canvas.blur()}clipboardPasteFrom(t){if(!(this._rfbConnectionState!=="connected"||this._viewOnly))if(this._clipboardServerCapabilitiesFormats[fn]&&this._clipboardServerCapabilitiesActions[aa])this._clipboardText=t,e.messages.extendedClipboardNotify(this._sock,[fn]);else{let n,r,o;n=0;for(let s of t)n++;o=new Uint8Array(n),r=0;for(let s of t){let i=s.codePointAt(0);i>255&&(i=63),o[r++]=i}e.messages.clientCutText(this._sock,o)}}getImageData(){return this._display.getImageData()}toDataURL(t,n){return this._display.toDataURL(t,n)}toBlob(t,n,r){return this._display.toBlob(t,n,r)}_connect(){if(de(">> RFB.connect"),this._url)Qe(`connecting to ${this._url}`),this._sock.open(this._url,this._wsProtocols);else{if(Qe(`attaching ${this._rawChannel} to Websock`),this._sock.attach(this._rawChannel),this._sock.readyState==="closed")throw Error("Cannot use already closed WebSocket/RTCDataChannel");this._sock.readyState==="open"&&this._socketOpen()}this._target.appendChild(this._screen),this._gestures.attach(this._canvas),this._cursor.attach(this._canvas),this._refreshCursor(),this._resizeObserver.observe(this._screen),this._canvas.addEventListener("mousedown",this._eventHandlers.focusCanvas),this._canvas.addEventListener("touchstart",this._eventHandlers.focusCanvas),this._canvas.addEventListener("mousedown",this._eventHandlers.handleMouse),this._canvas.addEventListener("mouseup",this._eventHandlers.handleMouse),this._canvas.addEventListener("mousemove",this._eventHandlers.handleMouse),this._canvas.addEventListener("click",this._eventHandlers.handleMouse),this._canvas.addEventListener("contextmenu",this._eventHandlers.handleMouse),this._canvas.addEventListener("wheel",this._eventHandlers.handleWheel),this._canvas.addEventListener("gesturestart",this._eventHandlers.handleGesture),this._canvas.addEventListener("gesturemove",this._eventHandlers.handleGesture),this._canvas.addEventListener("gestureend",this._eventHandlers.handleGesture),de("<< RFB.connect")}_disconnect(){de(">> RFB.disconnect"),this._cursor.detach(),this._canvas.removeEventListener("gesturestart",this._eventHandlers.handleGesture),this._canvas.removeEventListener("gesturemove",this._eventHandlers.handleGesture),this._canvas.removeEventListener("gestureend",this._eventHandlers.handleGesture),this._canvas.removeEventListener("wheel",this._eventHandlers.handleWheel),this._canvas.removeEventListener("mousedown",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mouseup",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mousemove",this._eventHandlers.handleMouse),this._canvas.removeEventListener("click",this._eventHandlers.handleMouse),this._canvas.removeEventListener("contextmenu",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mousedown",this._eventHandlers.focusCanvas),this._canvas.removeEventListener("touchstart",this._eventHandlers.focusCanvas),this._resizeObserver.disconnect(),this._keyboard.ungrab(),this._gestures.detach(),this._sock.close();try{this._target.removeChild(this._screen)}catch(t){if(t.name!=="NotFoundError")throw t}clearTimeout(this._resizeTimeout),clearTimeout(this._mouseMoveTimer),de("<< RFB.disconnect")}_socketOpen(){this._rfbConnectionState==="connecting"&&this._rfbInitState===""?(this._rfbInitState="ProtocolVersion",de("Starting VNC handshake")):this._fail("Unexpected server connection while "+this._rfbConnectionState)}_socketClose(t){de("WebSocket on-close event");let n="";switch(t.code&&(n="(code: "+t.code,t.reason&&(n+=", reason: "+t.reason),n+=")"),this._rfbConnectionState){case"connecting":this._fail("Connection closed "+n);break;case"connected":this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected");break;case"disconnecting":this._updateConnectionState("disconnected");break;case"disconnected":this._fail("Unexpected server disconnect when already disconnected "+n);break;default:this._fail("Unexpected server disconnect before connecting "+n);break}this._sock.off("close"),this._rawChannel=null}_socketError(t){Ye("WebSocket on-error event")}_focusCanvas(t){this.focusOnClick&&this.focus({preventScroll:!0})}_setDesktopName(t){this._fbName=t,this.dispatchEvent(new CustomEvent("desktopname",{detail:{name:this._fbName}}))}_saveExpectedClientSize(){this._expectedClientWidth=this._screen.clientWidth,this._expectedClientHeight=this._screen.clientHeight}_currentClientSize(){return[this._screen.clientWidth,this._screen.clientHeight]}_clientHasExpectedSize(){let[t,n]=this._currentClientSize();return t==this._expectedClientWidth&&n==this._expectedClientHeight}_handleResize(){this._clientHasExpectedSize()||(window.requestAnimationFrame(()=>{this._updateClip(),this._updateScale(),this._saveExpectedClientSize()}),this._requestRemoteResize())}_updateClip(){let t=this._display.clipViewport,n=this._clipViewport;if(this._scaleViewport&&(n=!1),t!==n&&(this._display.clipViewport=n),n){let r=this._screenSize();this._display.viewportChangeSize(r.w,r.h),this._fixScrollbars(),this._setClippingViewport(r.w<this._display.width||r.h<this._display.height)}else this._setClippingViewport(!1);t!==n&&this._saveExpectedClientSize()}_updateScale(){if(!this._scaleViewport)this._display.scale=1;else{let t=this._screenSize();this._display.autoscale(t.w,t.h)}this._fixScrollbars()}_requestRemoteResize(){if(!this._resizeSession||this._viewOnly||!this._supportsSetDesktopSize||this._pendingRemoteResize)return;if(Date.now()-this._lastResize<100){clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(this._requestRemoteResize.bind(this),100-(Date.now()-this._lastResize));return}this._resizeTimeout=null;let t=this._screenSize();t.w===this._fbWidth&&t.h===this._fbHeight||(this._pendingRemoteResize=!0,this._lastResize=Date.now(),e.messages.setDesktopSize(this._sock,Math.floor(t.w),Math.floor(t.h),this._screenID,this._screenFlags),de("Requested new desktop size: "+t.w+"x"+t.h))}_screenSize(){let t=this._screen.getBoundingClientRect();return{w:t.width,h:t.height}}_fixScrollbars(){let t=this._screen.style.overflow;this._screen.style.overflow="hidden",this._screen.getBoundingClientRect(),this._screen.style.overflow=t}_updateConnectionState(t){let n=this._rfbConnectionState;if(t===n){de("Already in state '"+t+"', ignoring");return}if(n==="disconnected"){Me("Tried changing state of a disconnected RFB object");return}switch(t){case"connected":if(n!=="connecting"){Me("Bad transition to connected state, previous connection state: "+n);return}break;case"disconnected":if(n!=="disconnecting"){Me("Bad transition to disconnected state, previous connection state: "+n);return}break;case"connecting":if(n!==""){Me("Bad transition to connecting state, previous connection state: "+n);return}break;case"disconnecting":if(n!=="connected"&&n!=="connecting"){Me("Bad transition to disconnecting state, previous connection state: "+n);return}break;default:Me("Unknown connection state: "+t);return}switch(this._rfbConnectionState=t,de("New state '"+t+"', was '"+n+"'."),this._disconnTimer&&t!=="disconnecting"&&(de("Clearing disconnect timer"),clearTimeout(this._disconnTimer),this._disconnTimer=null,this._sock.off("close")),t){case"connecting":this._connect();break;case"connected":this.dispatchEvent(new CustomEvent("connect",{detail:{}}));break;case"disconnecting":this._disconnect(),this._disconnTimer=setTimeout(()=>{Me("Disconnection timed out."),this._updateConnectionState("disconnected")},u$*1e3);break;case"disconnected":this.dispatchEvent(new CustomEvent("disconnect",{detail:{clean:this._rfbCleanDisconnect}}));break}}_fail(t){switch(this._rfbConnectionState){case"disconnecting":Me("Failed when disconnecting: "+t);break;case"connected":Me("Failed while connected: "+t);break;case"connecting":Me("Failed when connecting: "+t);break;default:Me("RFB failure: "+t);break}return this._rfbCleanDisconnect=!1,this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected"),!1}_setCapability(t,n){this._capabilities[t]=n,this.dispatchEvent(new CustomEvent("capabilities",{detail:{capabilities:this._capabilities}}))}_handleMessage(){if(this._sock.rQwait("message",1)){Ye("handleMessage called on an empty receive queue");return}switch(this._rfbConnectionState){case"disconnected":Me("Got data while disconnected");break;case"connected":for(;!(this._flushing||!this._normalMsg()||this._sock.rQwait("message",1)););break;case"connecting":for(;this._rfbConnectionState==="connecting"&&this._initMsg(););break;default:Me("Got data while in an invalid state");break}}_handleKeyEvent(t,n,r,o,s){n=="CapsLock"&&r&&(this._remoteCapsLock=null),this._remoteCapsLock!==null&&s!==null&&this._remoteCapsLock!==s&&r&&(de("Fixing remote caps lock"),this.sendKey(A.XK_Caps_Lock,"CapsLock",!0),this.sendKey(A.XK_Caps_Lock,"CapsLock",!1),this._remoteCapsLock=null),n=="NumLock"&&r&&(this._remoteNumLock=null),this._remoteNumLock!==null&&o!==null&&this._remoteNumLock!==o&&r&&(de("Fixing remote num lock"),this.sendKey(A.XK_Num_Lock,"NumLock",!0),this.sendKey(A.XK_Num_Lock,"NumLock",!1),this._remoteNumLock=null),this.sendKey(t,n,r)}static _convertButtonMask(t){let n={0:1,1:4,2:2,3:128,4:256},r=0;for(let o=0;o<5;o++)t&1<<o&&(r|=n[o]);return r}_handleMouse(t){if(t.type==="click"&&t.target!==this._canvas||(t.stopPropagation(),t.preventDefault(),t.type==="click"||t.type==="contextmenu"))return;let n=Do(t.clientX,t.clientY,this._canvas),r=e._convertButtonMask(t.buttons),o=t.type=="mousedown";switch(t.type){case"mousedown":case"mouseup":if(this.dragViewport)if(o&&!this._viewportDragging){this._viewportDragging=!0,this._viewportDragPos={x:n.x,y:n.y},this._viewportHasMoved=!1,this._flushMouseMoveTimer(n.x,n.y),this._mouseButtonMask=r;break}else{if(this._viewportDragging=!1,this._viewportHasMoved){this._mouseButtonMask=r;break}this._sendMouse(n.x,n.y,this._mouseButtonMask)}o&&mv(this._canvas),this._handleMouseButton(n.x,n.y,r);break;case"mousemove":if(this._viewportDragging){let s=this._viewportDragPos.x-n.x,i=this._viewportDragPos.y-n.y;(this._viewportHasMoved||Math.abs(s)>Ri||Math.abs(i)>Ri)&&(this._viewportHasMoved=!0,this._viewportDragPos={x:n.x,y:n.y},this._display.viewportChangePos(s,i));break}this._handleMouseMove(n.x,n.y);break}}_handleMouseButton(t,n,r){this._flushMouseMoveTimer(t,n),this._mouseButtonMask=r,this._sendMouse(t,n,this._mouseButtonMask)}_handleMouseMove(t,n){if(this._mousePos={x:t,y:n},this._mouseMoveTimer==null){let r=Date.now()-this._mouseLastMoveTime;r>Zw?(this._sendMouse(t,n,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()):this._mouseMoveTimer=setTimeout(()=>{this._handleDelayedMouseMove()},Zw-r)}}_handleDelayedMouseMove(){this._mouseMoveTimer=null,this._sendMouse(this._mousePos.x,this._mousePos.y,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()}_sendMouse(t,n,r){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;if(r&32768)throw new Error("Illegal mouse button mask (mask: "+r+")");let o=r&32640;this._extendedPointerEventSupported&&o?e.messages.extendedPointerEvent(this._sock,this._display.absX(t),this._display.absY(n),r):e.messages.pointerEvent(this._sock,this._display.absX(t),this._display.absY(n),r)}_handleWheel(t){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;t.stopPropagation(),t.preventDefault();let n=Do(t.clientX,t.clientY,this._canvas),r=e._convertButtonMask(t.buttons),o=t.deltaX,s=t.deltaY;t.deltaMode!==0&&(o*=jw,s*=jw),this._accumulatedWheelDeltaX+=o,this._accumulatedWheelDeltaY+=s,Math.abs(this._accumulatedWheelDeltaX)>=Ww&&(this._accumulatedWheelDeltaX<0?(this._handleMouseButton(n.x,n.y,r|32),this._handleMouseButton(n.x,n.y,r)):this._accumulatedWheelDeltaX>0&&(this._handleMouseButton(n.x,n.y,r|64),this._handleMouseButton(n.x,n.y,r)),this._accumulatedWheelDeltaX=0),Math.abs(this._accumulatedWheelDeltaY)>=Ww&&(this._accumulatedWheelDeltaY<0?(this._handleMouseButton(n.x,n.y,r|8),this._handleMouseButton(n.x,n.y,r)):this._accumulatedWheelDeltaY>0&&(this._handleMouseButton(n.x,n.y,r|16),this._handleMouseButton(n.x,n.y,r)),this._accumulatedWheelDeltaY=0)}_fakeMouseMove(t,n,r){this._handleMouseMove(n,r),this._cursor.move(t.detail.clientX,t.detail.clientY)}_handleTapEvent(t,n){let r=Do(t.detail.clientX,t.detail.clientY,this._canvas);if(this._gestureLastTapTime!==null&&Date.now()-this._gestureLastTapTime<p$&&this._gestureFirstDoubleTapEv.detail.type===t.detail.type){let o=this._gestureFirstDoubleTapEv.detail.clientX-t.detail.clientX,s=this._gestureFirstDoubleTapEv.detail.clientY-t.detail.clientY;Math.hypot(o,s)<f$?r=Do(this._gestureFirstDoubleTapEv.detail.clientX,this._gestureFirstDoubleTapEv.detail.clientY,this._canvas):this._gestureFirstDoubleTapEv=t}else this._gestureFirstDoubleTapEv=t;this._gestureLastTapTime=Date.now(),this._fakeMouseMove(this._gestureFirstDoubleTapEv,r.x,r.y),this._handleMouseButton(r.x,r.y,n),this._handleMouseButton(r.x,r.y,0)}_handleGesture(t){let n,r=Do(t.detail.clientX,t.detail.clientY,this._canvas);switch(t.type){case"gesturestart":switch(t.detail.type){case"onetap":this._handleTapEvent(t,1);break;case"twotap":this._handleTapEvent(t,4);break;case"threetap":this._handleTapEvent(t,2);break;case"drag":this.dragViewport?(this._viewportHasMoved=!1,this._viewportDragging=!0,this._viewportDragPos={x:r.x,y:r.y}):(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,1));break;case"longpress":this.dragViewport?(this._viewportHasMoved=!1,this._viewportDragPos={x:r.x,y:r.y}):(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,4));break;case"twodrag":this._gestureLastMagnitudeX=t.detail.magnitudeX,this._gestureLastMagnitudeY=t.detail.magnitudeY,this._fakeMouseMove(t,r.x,r.y);break;case"pinch":this._gestureLastMagnitudeX=Math.hypot(t.detail.magnitudeX,t.detail.magnitudeY),this._fakeMouseMove(t,r.x,r.y);break}break;case"gesturemove":switch(t.detail.type){case"onetap":case"twotap":case"threetap":break;case"drag":case"longpress":if(this.dragViewport){this._viewportDragging=!0;let o=this._viewportDragPos.x-r.x,s=this._viewportDragPos.y-r.y;(this._viewportHasMoved||Math.abs(o)>Ri||Math.abs(s)>Ri)&&(this._viewportHasMoved=!0,this._viewportDragPos={x:r.x,y:r.y},this._display.viewportChangePos(o,s))}else this._fakeMouseMove(t,r.x,r.y);break;case"twodrag":for(this._fakeMouseMove(t,r.x,r.y);t.detail.magnitudeY-this._gestureLastMagnitudeY>or;)this._handleMouseButton(r.x,r.y,8),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeY+=or;for(;t.detail.magnitudeY-this._gestureLastMagnitudeY<-or;)this._handleMouseButton(r.x,r.y,16),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeY-=or;for(;t.detail.magnitudeX-this._gestureLastMagnitudeX>or;)this._handleMouseButton(r.x,r.y,32),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeX+=or;for(;t.detail.magnitudeX-this._gestureLastMagnitudeX<-or;)this._handleMouseButton(r.x,r.y,64),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeX-=or;break;case"pinch":if(this._fakeMouseMove(t,r.x,r.y),n=Math.hypot(t.detail.magnitudeX,t.detail.magnitudeY),Math.abs(n-this._gestureLastMagnitudeX)>ia){for(this._handleKeyEvent(A.XK_Control_L,"ControlLeft",!0);n-this._gestureLastMagnitudeX>ia;)this._handleMouseButton(r.x,r.y,8),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeX+=ia;for(;n-this._gestureLastMagnitudeX<-ia;)this._handleMouseButton(r.x,r.y,16),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeX-=ia}this._handleKeyEvent(A.XK_Control_L,"ControlLeft",!1);break}break;case"gestureend":switch(t.detail.type){case"onetap":case"twotap":case"threetap":case"pinch":case"twodrag":break;case"drag":this.dragViewport?this._viewportDragging=!1:(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,0));break;case"longpress":if(this._viewportHasMoved)break;this.dragViewport&&!this._viewportHasMoved?(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,4),this._handleMouseButton(r.x,r.y,0),this._viewportDragging=!1):(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,0));break}break}}_flushMouseMoveTimer(t,n){this._mouseMoveTimer!==null&&(clearTimeout(this._mouseMoveTimer),this._mouseMoveTimer=null,this._sendMouse(t,n,this._mouseButtonMask))}_negotiateProtocolVersion(){if(this._sock.rQwait("version",12))return!1;let t=this._sock.rQshiftStr(12).substr(4,7);Qe("Server ProtocolVersion: "+t);let n=0;switch(t){case"000.000":n=1;break;case"003.003":case"003.006":this._rfbVersion=3.3;break;case"003.007":this._rfbVersion=3.7;break;case"003.008":case"003.889":case"004.000":case"004.001":case"005.000":this._rfbVersion=3.8;break;default:return this._fail("Invalid server version "+t)}if(n){let o="ID:"+this._repeaterID;for(;o.length<250;)o+="\0";return this._sock.sQpushString(o),this._sock.flush(),!0}this._rfbVersion>this._rfbMaxVersion&&(this._rfbVersion=this._rfbMaxVersion);let r="00"+parseInt(this._rfbVersion,10)+".00"+this._rfbVersion*10%10;this._sock.sQpushString("RFB "+r+`
1
+ var ZT=Object.defineProperty;var cn=(e,t)=>{for(var n in t)ZT(e,n,{get:t[n],enumerable:!0})};var Sf=globalThis.__bbPluginRuntime;if(Sf==null||Sf.pluginSdkApp==null)throw new Error('Cannot load "@get-bb/plugin-sdk/app": this bundle must be loaded by the Moonlet app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Hl=Sf.pluginSdkApp,uF="default"in Hl?Hl.default:Hl,{Markdown:H_,ThreadChat:Ef,ThreadTitle:dF,UrlLink:pF,definePluginApp:V_,experimental_BranchPicker:fF,experimental_ComposerRoot:hF,experimental_DetailRow:mF,experimental_Diff:gF,experimental_FailedVoiceRecordings:xF,experimental_FileLink:bF,experimental_Icon:pe,experimental_ImageLightbox:yF,experimental_InfoList:_F,experimental_InfoListRow:vF,experimental_InfoSection:wF,experimental_NewThreadComposer:kF,experimental_PermissionModePicker:SF,experimental_PluginIcon:EF,experimental_PluginRpcCallError:NF,experimental_PromptMentionIcon:AF,experimental_ProviderIcon:CF,experimental_ProviderModelPicker:TF,experimental_SettingsRow:Ei,experimental_SettingsSection:ct,experimental_ShortcutHint:RF,experimental_SidebarNavigationIcon:$F,experimental_SourceCode:IF,experimental_THREAD_ACTION_GROUPS:PF,experimental_THREAD_CONTEXT_SEGMENT_GROUPS:OF,experimental_THREAD_INFO_ROW_GROUPS:LF,experimental_THREAD_INFO_SECTION_GROUPS:MF,experimental_ThreadActionsContextMenu:DF,experimental_ThreadActionsMenu:FF,experimental_ThreadStatusGlyph:zF,experimental_ThreadTitleText:KF,experimental_VoiceInputButton:XF,experimental_VoiceInputTextarea:BF,experimental_VoiceRecordingBar:UF,experimental_copyToClipboard:Z_,experimental_describePromptMention:HF,experimental_promptMentionClipboardAttributes:VF,experimental_readPromptMentionClipboard:ZF,experimental_saveFile:WF,experimental_useAppPanel:W_,experimental_useArchiveEnvironmentThreads:jF,experimental_useBranches:QF,experimental_useCheckoutState:GF,experimental_useCodeTheme:YF,experimental_useComposerCommandSearch:qF,experimental_useComposerContributions:JF,experimental_useComposerMentionSearch:e4,experimental_useComposerRenderer:t4,experimental_useExperiment:n4,experimental_useFixedTabTarget:r4,experimental_usePluginId:o4,experimental_useProviders:s4,experimental_useQuestionFormHost:i4,experimental_useRpcKeyedQuery:a4,experimental_useRpcMutation:l4,experimental_useRpcQuery:c4,experimental_useRpcRefresh:u4,experimental_useSidebar:j_,experimental_useSidebarNavigation:d4,experimental_useSidebarNavigationSplit:p4,experimental_useSidebarThreadActions:f4,experimental_useSidebarThreadSplit:h4,experimental_useSidebarThreads:m4,experimental_useThreadActionRegistrations:g4,experimental_useThreadActions:x4,experimental_useThreadTitleDisplayText:b4,internal_DO_NOT_USE_Outlet:Vl,internal_DO_NOT_USE_useOutletFilled:Q_,useBbContext:G_,useBbNavigate:Ie,useComposer:Y_,useComposerView:y4,useComposers:_4,useEnvironmentProviders:v4,useRealtime:ke,useRealtimeConnectionState:q_,useRpc:J,useSdk:un,useSettings:w4,useSidebarSplitLayout:k4,useSidebarThreadDraft:S4,useSidebarThreadDraftIds:E4,useSidebarThreadRowStatus:N4,useSidebarThreadRowStatuses:A4,useSidebarThreadShortcut:C4,experimental_useSidebarThreadPullRequest:T4}=Hl;var $r={};cn($r,{Activity:()=>jT,Children:()=>Wl,Component:()=>QT,Fragment:()=>Af,Profiler:()=>GT,PureComponent:()=>YT,StrictMode:()=>qT,Suspense:()=>JT,act:()=>e2,cache:()=>t2,cacheSignal:()=>n2,captureOwnerStack:()=>r2,cloneElement:()=>Ni,createContext:()=>Cf,createElement:()=>J_,createRef:()=>o2,default:()=>WT,forwardRef:()=>Tn,isValidElement:()=>Po,lazy:()=>s2,memo:()=>i2,startTransition:()=>a2,unstable_useCacheRefresh:()=>l2,use:()=>c2,useActionState:()=>u2,useCallback:()=>q,useContext:()=>Tf,useDebugValue:()=>d2,useDeferredValue:()=>p2,useEffect:()=>K,useEffectEvent:()=>f2,useId:()=>Ai,useImperativeHandle:()=>h2,useInsertionEffect:()=>m2,useLayoutEffect:()=>ot,useMemo:()=>Lt,useOptimistic:()=>g2,useReducer:()=>x2,useRef:()=>Y,useState:()=>_,useSyncExternalStore:()=>xt,useTransition:()=>b2,version:()=>y2});var Nf=globalThis.__bbPluginRuntime;if(Nf==null||Nf.react==null)throw new Error('Cannot load "react": this bundle must be loaded by the Moonlet app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Zl=Nf.react,WT="default"in Zl?Zl.default:Zl,{Activity:jT,Children:Wl,Component:QT,Fragment:Af,Profiler:GT,PureComponent:YT,StrictMode:qT,Suspense:JT,act:e2,cache:t2,cacheSignal:n2,captureOwnerStack:r2,cloneElement:Ni,createContext:Cf,createElement:J_,createRef:o2,forwardRef:Tn,isValidElement:Po,lazy:s2,memo:i2,startTransition:a2,unstable_useCacheRefresh:l2,use:c2,useActionState:u2,useCallback:q,useContext:Tf,useDebugValue:d2,useDeferredValue:p2,useEffect:K,useEffectEvent:f2,useId:Ai,useImperativeHandle:h2,useInsertionEffect:m2,useLayoutEffect:ot,useMemo:Lt,useOptimistic:g2,useReducer:x2,useRef:Y,useState:_,useSyncExternalStore:xt,useTransition:b2,version:y2}=Zl;function ev(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function _2(...e){return t=>{let n=!1,r=e.map(o=>{let s=ev(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){let s=r[o];typeof s=="function"?s():ev(e[o],null)}}}}function tv(...e){return q(_2(...e),e)}function v2(e){let t=Tn((n,r)=>{let{children:o,...s}=n,i=null,a=!1,u=[];nv(o)&&typeof jl=="function"&&(o=jl(o._payload)),Wl.forEach(o,f=>{if(N2(f)){a=!0;let h=f,g="child"in h.props?h.props.child:h.props.children;nv(g)&&typeof jl=="function"&&(g=jl(g._payload)),i=k2(h,g),u.push(i?.props?.children)}else u.push(f)}),i?i=Ni(i,void 0,u):!a&&Wl.count(o)===1&&Po(o)&&(i=o);let c=i?E2(i):void 0,d=tv(r,c);if(!i){if(o||o===0)throw new Error(a?R2(e):T2(e));return o}let p=S2(s,i.props??{});return i.type!==Af&&(p.ref=r?d:c),Ni(i,p)});return t.displayName=`${e}.Slot`,t}var Ql=v2("Slot"),w2=Symbol.for("radix.slottable");var k2=(e,t)=>{if("child"in e.props){let n=e.props.child;return Po(n)?Ni(n,void 0,e.props.children(n.props.children)):null}return Po(t)?t:null};function S2(e,t){let n={...t};for(let r in t){let o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{let u=s(...a);return o(...a),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function E2(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function N2(e){return Po(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===w2}var A2=Symbol.for("react.lazy");function nv(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===A2&&"_payload"in e&&C2(e._payload)}function C2(e){return typeof e=="object"&&e!==null&&"then"in e}var T2=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,R2=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,jl=$r[" use ".trim().toString()];var Rf=globalThis.__bbPluginRuntime;if(Rf==null||Rf.classVarianceAuthority==null)throw new Error('Cannot load "class-variance-authority": this bundle must be loaded by the Moonlet app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Gl=Rf.classVarianceAuthority,O4="default"in Gl?Gl.default:Gl,{cva:rv,cx:L4}=Gl;var $f=globalThis.__bbPluginRuntime;if($f==null||$f.clsx==null)throw new Error('Cannot load "clsx": this bundle must be loaded by the Moonlet app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Yl=$f.clsx,D4="default"in Yl?Yl.default:Yl,{clsx:ov}=Yl;var If=globalThis.__bbPluginRuntime;if(If==null||If.tailwindMerge==null)throw new Error('Cannot load "tailwind-merge": this bundle must be loaded by the Moonlet app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var ql=If.tailwindMerge,z4="default"in ql?ql.default:ql,{createTailwindMerge:K4,extendTailwindMerge:X4,fromTheme:B4,getDefaultConfig:U4,mergeConfigs:H4,twJoin:V4,twMerge:sv,validators:Z4}=ql;function V(...e){return sv(ov(e))}var Jl="transition-colors duration-150 hover:duration-0";var Pf=globalThis.__bbPluginRuntime;if(Pf==null||Pf.jsxRuntime==null)throw new Error('Cannot load "react/jsx-runtime": this bundle must be loaded by the Moonlet app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var ec=Pf.jsxRuntime,q4="default"in ec?ec.default:ec,{Fragment:he,jsx:l,jsxs:m}=ec;var $2=rv(`inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ${Jl} focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_[data-icon-root]]:pointer-events-none [&_[data-icon-root]]:size-4 [&_[data-icon-root]]:shrink-0`,{variants:{variant:{default:"bg-foreground text-background hover:bg-foreground/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-transparent hover:bg-state-hover hover:text-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-state-hover hover:text-foreground aria-pressed:bg-state-active aria-pressed:text-foreground aria-pressed:hover:bg-state-active data-[state=open]:bg-state-active data-[state=open]:text-foreground data-[state=open]:hover:bg-state-active",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),R=Tn(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>l(r?Ql:"button",{className:V($2({variant:t,size:n,className:e})),ref:s,...o}));R.displayName="Button";function I2({route:e,busy:t,answer:n,cancel:r,expiresAt:o}){return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[m("div",{className:"font-medium",children:[e.what==="spawn"?"Start work":e.what==="tell"?"Send a message":e.what==="relay"?"Relay a message":"Schedule a check"," ",e.what==="relay"?"to":"on"," ",l("span",{className:"font-mono",children:e.station}),e.when&&m("span",{className:"font-normal text-muted-foreground",children:[" (",e.when,")"]})]}),(e.provider||e.model)&&m("div",{className:"mt-1 text-xs",children:["Runs on ",l("span",{className:"font-mono",children:e.provider??"the project's provider"}),e.model&&m(he,{children:[" ","with ",l("span",{className:"font-mono",children:e.model})]}),e.provider==="codex"&&e.own&&" (Codex, under that machine's own Codex sign-in and settings; your moonlet's station protections don't apply)","."]}),m("div",{className:"mt-1 text-xs text-muted-foreground",children:["I\u2019m requesting this from ",e.from,".",e.what==="check"&&" The script runs as orbit on its station, outside Claude Code's sandbox, every time it's due.",e.own&&" I\u2019ll run as you on your machine, with access to your files and accounts.",e.what==="relay"&&" You set this to Ask in Settings \u2192 your moonlet \u2192 Relay. The message goes as written below, marked as relayed from your moonlet."]})]}),l("div",{className:"font-medium",children:e.title}),l("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 font-mono text-xs",children:e.brief}),o&&m("div",{className:"text-xs text-muted-foreground",children:["Expires at ",new Date(o).toLocaleTimeString(),"."]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:t,onClick:()=>n("once"),children:"Approve"}),l(R,{size:"sm",variant:"destructive",disabled:t,onClick:()=>n("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>{r()},children:"Dismiss"})]})]})}var P2=e=>({"orbit-keys.service":"Password service","orbit-relay.service":"Station connection","orbit-proton-bridge.service":"Mail connection",mail:"Mail connection",gate:"Station connection",plugin:"your moonlet service",turn:"Starting work","mail-check":"Mail check",events:"Background work service"})[e]??e;function O2({switching:e,busy:t,answer:n,cancel:r,expiresAt:o}){let s=e.what==="activate";return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[m("div",{className:"font-medium",children:["Switch ",s?"on":"off"," on the station: ",e.piece]}),m("div",{className:"mt-1 text-xs",children:[e.words,"."]})]}),l("div",{className:"text-xs",children:s&&e.recovery?"Every health check still runs. This retry may keep only the known failures below. Another failure or an interrupted switch still undoes it.":s?"I\u2019ll switch this on and check the station\u2019s health. A failed check or interrupted switch restores the previous state.":"I\u2019ll switch this off now. The effect is described above."}),e.recovery&&m("div",{className:"space-y-2 rounded-md border p-2",children:[l("p",{className:"font-medium",children:"Retry and keep this switch if the same checks still fail?"}),l("ul",{className:"list-disc pl-5",children:e.recovery.failures.map(i=>l("li",{children:P2(i)},i))}),l("p",{children:"Approve retries the same switch with the same settings and allows these known failures for this attempt. Services may remain unavailable until repaired. Other failures still undo the switch."})]}),m("div",{className:"text-xs text-muted-foreground",children:["This approves the switch described above.",o&&` Expires at ${new Date(o).toLocaleTimeString()}.`]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:t,onClick:()=>n("once"),children:"Approve"}),l(R,{size:"sm",variant:"destructive",disabled:t,onClick:()=>n("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>{r()},children:"Dismiss"})]})]})}function L2({login:e,offers:t,busy:n,answer:r,cancel:o,expiresAt:s}){let i=e.otp?"one-time codes":"sign-ins";return e.humanCheck?m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[l("div",{className:"font-medium",children:"Proton wants a human check before Bridge signs in"}),l("div",{className:"mt-1 text-xs text-muted-foreground",children:"It's open in Chrome on your moonlet's desktop: solve it there from the Desktop panel (Proton accepts it only from your moonlet's own computer), then press Done. Bridge's sign-in is waiting and carries on from there. The link, in case the window closed:"})]}),l("a",{className:"break-all font-mono text-xs underline",href:e.humanCheck,target:"_blank",rel:"noreferrer noopener",children:e.humanCheck}),s&&m("div",{className:"text-xs text-muted-foreground",children:["Cancelled if unanswered by ",new Date(s).toLocaleTimeString(),"."]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:n,onClick:()=>r("once"),children:"Done"}),l(R,{size:"sm",variant:"destructive",disabled:n,onClick:()=>r("deny"),children:"Cancel"})]})]}):m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[l("div",{children:e.bridge?m(he,{children:[m("div",{className:"font-medium",children:["Sign Proton Mail Bridge in with ",l("span",{className:"font-mono",children:e.item})]}),l("div",{className:"mt-1 text-xs text-muted-foreground",children:"I\u2019ll sign Bridge in through the vault without seeing the password or code. Then I can read and send its mail through Bridge."})]}):m(he,{children:[m("div",{className:"font-medium",children:["Sign your moonlet in: fill ",e.otp?"the one-time code":"the username and password"," from ",l("span",{className:"font-mono",children:e.item})," ","into ",l("span",{className:"font-mono",children:e.unit}),"'s sign-in page, ",l("span",{className:"font-mono",children:e.url})]}),m("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.otp?"The broker fills it into the text field that has the focus on that page; your moonlet never sees it.":"The broker fills them into that page's form (the password only into its password field) and signs in; your moonlet never sees them."," ","You can see the sign-in form in the Desktop panel."]})]})}),m("ul",{className:"list-disc space-y-0.5 pl-5 text-xs text-muted-foreground",children:[t.includes("thread")&&m("li",{children:[l("b",{children:"For this conversation"}),": ",i," for ",l("span",{className:"font-mono",children:e.name})," asked as this conversation, until Moonlet reloads your moonlet."]}),t.includes("always")&&m("li",{children:[l("b",{children:"Always"}),": ",i," for ",l("span",{className:"font-mono",children:e.name})," from any of the station's conversations, from now on. Revoke it in Settings \u2192 your moonlet."]}),s&&m("li",{children:["Expires at ",new Date(s).toLocaleTimeString(),"."]})]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:n,onClick:()=>r("once"),children:"Approve"}),t.includes("thread")&&l(R,{size:"sm",variant:"secondary",disabled:n,onClick:()=>r("thread"),children:"For this conversation"}),t.includes("always")&&l(R,{size:"sm",variant:"secondary",disabled:n,onClick:()=>r("always"),children:"Always"}),l(R,{size:"sm",variant:"destructive",disabled:n,onClick:()=>r("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:n,onClick:()=>{o()},children:"Dismiss"})]})]})}function M2({change:e,busy:t,answer:n}){return m("div",{className:"space-y-3 p-3 text-sm",children:[m("p",{className:"font-medium",children:[e.mergeReasons?"Allow merging":e.checks?"Proceed with these checks for":"Approve change"," #",e.number," in ",e.repo,"?"]}),l("a",{className:"underline",href:`https://github.com/${e.repo}/pull/${e.number}/files/${e.head}`,target:"_blank",rel:"noreferrer noopener",children:"Read this version of the change"}),e.mergeReasons?m("p",{children:["Allow this reviewed version to be merged despite:"," ",e.mergeReasons.map(r=>({author:"the author restriction",protected_paths:"protected files",changes_requested:"a request for changes"})[r]).join(", "),". Every check must still pass, the review must match this commit, and the pull request must be ready and mergeable. This changes the default branch."]}):e.checks?m(he,{children:[l("p",{children:"Allow merging this version despite the results below. Tests may be incomplete or the change may be broken. This also approves the change, including core files. It does not install anything."}),l("a",{className:"underline",href:`https://github.com/${e.repo}/pull/${e.number}/checks`,target:"_blank",rel:"noreferrer noopener",children:"Read the check details"}),l("ul",{className:"list-disc pl-5",children:e.checks.failures.map((r,o)=>l("li",{children:r},o))}),l("p",{className:"text-xs",children:"Only these exact check runs and this version are covered. A rerun, changed result, extra check or later push needs a new decision. Repository, identity and version checks still apply."})]}):l("p",{children:"This approves this whole version, including its core files. A later push needs approval of its own. Every other merge check still applies."}),l("p",{className:"text-xs",children:"This records your approval of the change. It does not install anything."}),l("pre",{className:"whitespace-pre-wrap break-all text-xs",children:e.head}),m("div",{className:"flex gap-2",children:[l(R,{size:"sm",disabled:t,onClick:()=>n("once"),children:"Approve"}),l(R,{size:"sm",variant:"destructive",disabled:t,onClick:()=>n("deny"),children:"Decline"})]})]})}function D2({mail:e,busy:t,answer:n,cancel:r,expiresAt:o}){let s=(i,a)=>a&&m("div",{children:[m("span",{className:"text-muted-foreground",children:[i,":"]})," ",l("span",{className:"whitespace-pre-wrap break-all font-mono",children:a})]});return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[l("div",{className:"font-medium",children:"Your moonlet wants to send this mail from its Gmail account"}),l("div",{className:"mt-1 text-xs text-muted-foreground",children:"Exactly as shown: the protected mail runner sends this message and nothing else. Sending only this one, once; a sent mail can't be taken back."})]}),m("div",{className:"flex flex-col gap-0.5 text-xs",children:[s("From",e.from),s("To",e.to),s("Cc",e.cc),s("Subject",e.subject),s("Date",e.date),s("Message-ID",e.messageId),s("In reply to",e.inReplyTo),s("References",e.references)]}),l("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 font-mono text-xs",children:e.body}),o&&m("div",{className:"text-xs text-muted-foreground",children:["Refused if unanswered by ",new Date(o).toLocaleTimeString(),"."]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:t,onClick:()=>n("once"),children:"Send"}),l(R,{size:"sm",variant:"destructive",disabled:t,onClick:()=>n("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>{r()},children:"Dismiss"})]})]})}function tc({interaction:e,submit:t,cancel:n}){let r=e.payload,[o,s]=_(!1),i=u=>{s(!0),t({choice:u}).catch(()=>s(!1))};if(r.change)return l(M2,{change:r.change,busy:o,answer:i});if(r.switching)return l(O2,{switching:r.switching,busy:o,answer:i,cancel:()=>{n()},expiresAt:r.expiresAt});if(r.mail)return l(D2,{mail:r.mail,busy:o,answer:i,cancel:()=>{n()},expiresAt:r.expiresAt});if(r.route)return l(I2,{route:r.route,busy:o,answer:i,cancel:()=>{n()},expiresAt:r.expiresAt});if(r.login)return l(L2,{login:r.login,offers:r.offers,busy:o,answer:i,cancel:()=>{n()},expiresAt:r.expiresAt});let a=new Set(r.offers);return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[m("div",{className:"font-medium",children:["I\u2019d like to ",r.level==="act"?"make a change":"look"," with ",l("span",{className:"font-mono",children:r.capability})]}),l("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted p-2 font-mono text-xs",children:r.command})]}),m("ul",{className:"list-disc space-y-0.5 pl-5 text-xs text-muted-foreground",children:[a.has("thread")&&m("li",{children:[l("b",{children:"For this conversation"}),": any ",l("span",{className:"font-mono",children:r.rule})," command on ",r.capability,", until Moonlet reloads your moonlet."]}),a.has("always")&&m("li",{children:[l("b",{children:"Always"}),": this exact command, from now on. Revoke it in Settings \u2192 your moonlet."]}),r.sensitive&&m("li",{children:["This command is on ",r.capability,"'s sensitive list, so it asks every time."]}),r.expiresAt&&m("li",{children:["Expires at ",new Date(r.expiresAt).toLocaleTimeString(),"."]})]}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:o,onClick:()=>i("once"),children:"Approve"}),a.has("thread")&&l(R,{size:"sm",variant:"secondary",disabled:o,onClick:()=>i("thread"),children:"Allow for this conversation"}),a.has("always")&&l(R,{size:"sm",variant:"secondary",disabled:o,onClick:()=>i("always"),children:"Always allow"}),l(R,{size:"sm",variant:"destructive",disabled:o,onClick:()=>i("deny"),children:"Decline"}),l(R,{size:"sm",variant:"ghost",disabled:o,onClick:()=>{n()},children:"Dismiss"})]})]})}function nc({interaction:e,submit:t,cancel:n}){let r=e.payload,[o,s]=_(!1),i=a=>{s(!0),t({hostId:a}).catch(()=>s(!1))};return m("div",{className:"flex flex-col gap-3 p-3 text-sm",children:[m("div",{children:[m("div",{className:"font-medium",children:["Which machine manages ",l("span",{className:"font-mono",children:r.station}),"?"]}),m("p",{className:"mt-1 text-xs text-muted-foreground",children:["Several machines have your moonlet's station key and this station's VM. Your moonlet reaches the station only through the one you pick, which receives its credentials when they change. Change it later with ",l("span",{className:"font-mono",children:"moonlet station manager"}),"."]})]}),m("div",{className:"flex flex-wrap gap-2",children:[r.machines.map(a=>l(R,{size:"sm",variant:"secondary",disabled:o,onClick:()=>i(a.id),children:a.name},a.id)),l(R,{size:"sm",variant:"ghost",disabled:o,onClick:()=>{n()},children:"Dismiss"})]})]})}function iv({payload:e}){let t=e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.proposal=="string"?e.proposal:"";return/^[a-f0-9]{32}$/.test(t)?l(Ci,{id:t}):l("p",{children:"The settings result is unavailable."})}function Ci({id:e}){let t=J(),[n,r]=_([]),[o,s]=_(!1);return K(()=>{let i=!0,a,u=async()=>{try{let c=e?await t.call("policy-proposals.result",{id:e}).then(d=>d?[d]:[]):await t.call("policy-proposals.history",null);i&&(r(c),s(!1))}catch{i&&s(!0)}i&&(a=setTimeout(()=>{u()},5e3))};return u(),()=>{i=!1,clearTimeout(a)}},[t,e]),!n.length&&!o?null:m("section",{className:"space-y-2 p-3 text-sm","aria-label":"Station settings results",children:[!e&&l("h2",{className:"font-medium",children:"Recent station settings requests"}),o&&l("p",{role:"alert",children:"The settings result could not be checked. Trying again."}),n.slice(0,e?1:10).map(i=>m("div",{className:"space-y-1 rounded border p-2",children:[l("p",{className:"font-medium",children:i.title}),l("p",{children:i.message})]},i.id))]})}function rc({interaction:e,submit:t}){let n=e.payload,r=J(),[o,s]=_(!1),[i,a]=_(!1),[u,c]=_(null),[d,p]=_(null),[f,h]=_([]),g=Date.now()>=n.deadline,x=!!n.restore&&f.length===0;async function b(v){if(!(o||g||v&&(n.explanation.extraConfirmation&&!i||x))){s(!0),p(null);try{await t(n.restore?{approve:v,acknowledgeRisk:i,restore:v?f:[]}:{approve:v,acknowledgeRisk:i})}catch{p("Your answer did not go through. Try again."),s(!1)}}}return m("div",{className:"space-y-3 p-3 text-sm",children:[l("p",{className:"font-medium",children:n.restore?"Approve secret use again?":"Change station permissions?"}),n.explanation.sections.map(v=>m("section",{className:"space-y-1",children:[l("h3",{className:"font-medium",children:v.heading}),v.sentences.map((w,C)=>l("p",{className:"whitespace-pre-wrap break-words",children:w},C))]},v.heading)),n.restore&&m("fieldset",{className:"space-y-2",children:[l("legend",{className:"font-medium",children:"Secret uses to approve again"}),n.restore.map(v=>m("label",{className:"flex gap-2",children:[l("input",{type:"checkbox","aria-label":`Approve ${v.id} again`,checked:f.includes(v.id),disabled:o||g,onChange:w=>h(C=>w.target.checked?[...C,v.id].sort():C.filter(y=>y!==v.id))}),m("span",{children:[l("span",{className:"whitespace-pre-wrap break-all font-mono",children:v.id}),l("span",{className:"block whitespace-pre-wrap break-words",children:v.sentence})]})]},v.id))]}),l("p",{children:"This answer covers only these settings and their application. Declining or leaving this unanswered changes nothing."}),m("p",{children:["Expires ",new Date(n.deadline).toLocaleString(),"."]}),m("details",{onToggle:v=>{v.currentTarget.open&&!u&&r.call("policy-proposals.text",{id:n.id}).then(c).catch(()=>p("The exact text could not be loaded. Try opening it again."))},children:[l("summary",{className:"cursor-pointer underline",children:"More details"}),m("p",{children:["Proposer's title: ",n.title]}),l("p",{children:"Proposer's own words (not verified):"}),l("p",{className:"whitespace-pre-wrap break-words",children:n.explanation.details.proposerWords}),n.explanation.details.unchanged.map((v,w)=>l("p",{children:v},w)),u?m("div",{className:"space-y-2",children:[l("p",{children:"Current settings"}),l("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-all",children:u.before}),l("p",{children:"Proposed settings"}),l("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-all",children:u.after}),l("p",{children:"Checked review"}),l("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-all",children:u.preview})]}):l("p",{children:"Loading\u2026"})]}),n.explanation.extraConfirmation&&m("label",{className:"flex gap-2",children:[l("input",{type:"checkbox",checked:i,disabled:o||g,onChange:v=>a(v.target.checked)}),"I understand the extra access described above."]}),g&&l("p",{role:"alert",children:"This request has expired. Nothing was changed."}),d&&l("p",{role:"alert",children:d}),m("div",{className:"flex gap-2",children:[l(R,{size:"sm",disabled:o||g||n.explanation.extraConfirmation&&!i||x,onClick:()=>{b(!0)},children:"Approve"}),l(R,{size:"sm",variant:"destructive",disabled:o||g,onClick:()=>{b(!1)},children:"Decline"})]})]})}var F2=/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/;function oc({url:e,label:t,size:n=64}){let r={width:n,height:n};return!e||!F2.test(e)?l("span",{role:"img","aria-label":`${t}: none`,className:"inline-block shrink-0 rounded-full border border-dashed border-border bg-muted",style:r}):l("img",{src:e,alt:t,className:"shrink-0 rounded-full border border-border bg-muted object-cover",style:r})}var z2=[{value:"approve",label:"Approve"},{value:"decline",label:"Decline"},{value:"later",label:"Later"}];function Of({id:e,beforeLabel:t="Now"}){let n=J(),[r,o]=_(null),[s,i]=_(null);return m("details",{onToggle:a=>{a.currentTarget.open&&!r&&n.call("owner-changes.details",{id:e}).then(o).catch(()=>i("The details could not be loaded. Try opening them again."))},children:[l("summary",{className:"cursor-pointer underline",children:"More details"}),s&&l("p",{role:"alert",children:s}),r&&m("div",{className:"mt-2 space-y-2",children:[r.pictures.map(a=>m("div",{className:"flex flex-col items-start gap-1",children:[l(oc,{url:a.url,label:a.label,size:96}),l("span",{className:"text-xs text-muted-foreground",children:a.label})]},a.label)),m("div",{className:"grid gap-2 md:grid-cols-2",children:[m("div",{children:[l("div",{className:"mb-1 text-xs text-muted-foreground",children:t}),l("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 text-xs",children:r.before})]}),m("div",{children:[l("div",{className:"mb-1 text-xs text-muted-foreground",children:"After"}),l("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 text-xs",children:r.after})]})]})]})]})}function K2({item:e,choice:t,onChoice:n,acknowledged:r,onAcknowledge:o,narrowing:s,onNarrow:i,expired:a}){let u=e.offer;return m("article",{className:"space-y-2 rounded-md border p-3","aria-disabled":a,children:[l("p",{className:"font-medium",children:e.summary}),e.explanation.sections.map(c=>m("section",{className:"space-y-1",children:[l("h4",{className:"font-medium",children:c.heading}),c.sentences.map((d,p)=>l("p",{className:"whitespace-pre-wrap break-words",children:d},p))]},c.heading)),(e.title||e.explanation.details.proposerWords)&&m("details",{children:[l("summary",{className:"cursor-pointer underline",children:"Proposer's own words (not verified)"}),e.title&&l("p",{className:"whitespace-pre-wrap break-words",children:e.title}),l("p",{className:"whitespace-pre-wrap break-words",children:e.explanation.details.proposerWords})]}),l(Of,{id:e.id}),!a&&u?.expiry&&!s.once&&m("label",{className:"block",children:["Permission ends (leave empty for no time limit)",l("input",{"aria-label":"Permission ends",className:"block rounded border p-1",type:"datetime-local",value:s.until,onChange:c=>i({...s,until:c.target.value})})]}),!a&&u?.once&&m("label",{className:"flex items-center gap-2",children:[l("input",{type:"checkbox",checked:s.once,onChange:c=>i({...s,once:c.target.checked})}),"Only this once, for the operation waiting now (no standing permission)"]}),e.explanation.extraConfirmation&&m("label",{className:"flex items-center gap-2",children:[l("input",{type:"checkbox",checked:r,disabled:a,onChange:c=>o(c.target.checked)}),"I understand the extra access described above."]}),a?l("p",{children:"This request expired before your answer; it won't be applied."}):m("fieldset",{className:"flex flex-wrap gap-3",children:[l("legend",{className:"sr-only",children:"Your answer"}),z2.map(c=>m("label",{className:"flex items-center gap-1",children:[l("input",{type:"radio",name:`choice-${e.id}`,value:c.value,checked:t===c.value,onChange:()=>n(c.value)}),c.label]},c.value))]}),m("p",{className:"text-xs text-muted-foreground",children:["Expires ",new Date(e.deadline).toLocaleString(),"."]})]})}function sc({interaction:e,submit:t,cancel:n}){let r=e.payload,[o,s]=_(()=>Object.fromEntries(r.items.map(T=>[T.id,"later"]))),[i,a]=_({}),[u,c]=_({}),[d,p]=_(!1),[f,h]=_(null),[g,x]=_(()=>Date.now());K(()=>{let T=r.items.map(S=>S.deadline).filter(S=>S>g).sort((S,$)=>S-$)[0];if(T===void 0)return;let N=setTimeout(()=>x(Date.now()),Math.min(T-g+50,2**31-1));return()=>clearTimeout(N)},[r.items,g]);let b=r.items.some(T=>o[T.id]==="approve"&&T.explanation.extraConfirmation&&!i[T.id]),v=T=>u[T]??{until:"",once:!1};function w(T){let N=T.offer;if(o[T.id]!=="approve"||!N)return;let S=v(T.id);if(N.once&&S.once)return{once:!0};if(N.expiry)return{expiresAt:S.until?Date.parse(S.until):null}}let C=r.items.some(T=>{let N=w(T)?.expiresAt;return typeof N=="number"&&(!Number.isFinite(N)||N<=Date.now())});async function y(){if(d||b||C)return;p(!0),h(null);let T=r.items.filter(N=>N.deadline>Date.now()).map(N=>{let S=w(N);return{id:N.id,planHash:N.planHash,choice:o[N.id]??"later",acknowledgeRisk:i[N.id]===!0,...S?{options:S}:{}}});try{await t({form:r.form,answers:T})}catch{h("Your answer did not go through. Try again."),p(!1)}}return m("div",{className:"space-y-3 p-3 text-sm",children:[l("p",{className:"font-medium",children:r.items.length===1?"A change your moonlet asked for":`${r.items.length} changes your moonlet asked for`}),r.items.map(T=>l(K2,{item:T,choice:o[T.id]??"later",onChoice:N=>s({...o,[T.id]:N}),acknowledged:i[T.id]===!0,onAcknowledge:N=>a({...i,[T.id]:N}),narrowing:v(T.id),onNarrow:N=>c({...u,[T.id]:N}),expired:T.deadline<=g},T.id)),l("p",{children:"Approve applies exactly what is shown. Decline is remembered for 30 days. Later keeps it for another time. Nothing changes until you send your answers."}),m("div",{className:"flex flex-wrap gap-2",children:[l(R,{size:"sm",disabled:d||b||C,onClick:()=>{y()},children:"Send answers"}),l(R,{size:"sm",variant:"ghost",disabled:d,onClick:()=>{n()},children:"Not now"})]}),b&&l("p",{children:"Tick the confirmation on each high-risk change you approve."}),C&&l("p",{children:"Choose a future end time, or leave it empty for no time limit."}),f&&l("p",{role:"alert",children:f})]})}function av(e){return e>>>0}function Ti(e){return e|0}var lv="warn",de=()=>{},Qe=()=>{},Ye=()=>{},Me=()=>{};function X2(e){if(typeof e>"u"?e=lv:lv=e,de=Qe=Ye=Me=()=>{},typeof window.console<"u")switch(e){case"debug":de=console.debug.bind(window.console);case"info":Qe=console.info.bind(window.console);case"warn":Ye=console.warn.bind(window.console);case"error":Me=console.error.bind(window.console);case"none":break;default:throw new window.Error("invalid logging type '"+e+"'")}}X2();function ic(e,t=!1){try{return decodeURIComponent(escape(e))}catch(n){if(n instanceof URIError&&t)return e;throw n}}function Gt(e){return unescape(encodeURIComponent(e))}var Oo={toBase64Table:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),base64Pad:"=",encode(e){"use strict";let t="",n=e.length,r=n%3;for(let s=0;s<n-2;s+=3)t+=this.toBase64Table[e[s]>>2],t+=this.toBase64Table[((e[s]&3)<<4)+(e[s+1]>>4)],t+=this.toBase64Table[((e[s+1]&15)<<2)+(e[s+2]>>6)],t+=this.toBase64Table[e[s+2]&63];let o=n-r;return r===2?(t+=this.toBase64Table[e[o]>>2],t+=this.toBase64Table[((e[o]&3)<<4)+(e[o+1]>>4)],t+=this.toBase64Table[(e[o+1]&15)<<2],t+=this.toBase64Table[64]):r===1&&(t+=this.toBase64Table[e[o]>>2],t+=this.toBase64Table[(e[o]&3)<<4],t+=this.toBase64Table[64],t+=this.toBase64Table[64]),t},toBinaryTable:[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1],decode(e,t=0){let n=e.indexOf("=")-t;n<0&&(n=e.length-t);let r=(n>>2)*3+Math.floor(n%4/1.5),o=new Array(r),s=0,i=0;for(let a=0,u=t;u<e.length;u++){let c=this.toBinaryTable[e.charCodeAt(u)&127],d=e.charAt(u)===this.base64Pad;if(c===-1){Me("Illegal character code "+e.charCodeAt(u)+" at position "+u);continue}i=i<<6|c,s+=6,s>=8&&(s-=8,d||(o[a++]=i>>s&255),i&=(1<<s)-1)}if(s){let a=new Error("Corrupted base64 string");throw a.name="Base64-Error",a}return o}};var Lf="ontouchstart"in document.documentElement||document.ontouchstart!==void 0||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;window.addEventListener("touchstart",function e(){Lf=!0,window.removeEventListener("touchstart",e,!1)},!1);var Ri=10*(window.devicePixelRatio||1),cv=!1;try{let e=document.createElement("canvas");e.style.cursor='url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default',e.style.cursor.indexOf("url")===0?(Qe("Data URI scheme cursor supported"),cv=!0):Ye("Data URI scheme cursor not supported")}catch(e){Me("Data URI scheme cursor test exception: "+e)}var uv=cv,B2=!0;try{let e=document.createElement("div");e.style.visibility="hidden",e.style.overflow="scroll",document.body.appendChild(e);let t=document.createElement("div");e.appendChild(t);let n=e.offsetWidth-t.offsetWidth;e.parentNode.removeChild(e),B2=n!=0}catch(e){Me("Scrollbar test exception: "+e)}var Mf=!1;async function U2(){if(!("VideoDecoder"in window))return!1;let e={codec:"avc1.42401f",codedWidth:1920,codedHeight:1080,optimizeForLatency:!0};if(!(await VideoDecoder.isConfigSupported(e)).supported)return!1;let n=new Uint8Array(Oo.decode("AAAAAWdCwBTZnpuAgICgAAADACAAAAZB4oVNAAAAAWjJYyyAAAABBgX//4HcRem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY0IHIzMTA4IDMxZTE5ZjkgLSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDIzIC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9uczogY2FiYWM9MCByZWY9NSBkZWJsb2NrPTE6MDowIGFuYWx5c2U9MHgxOjB4MTExIG1lPWhleCBzdWJtZT04IHBzeT0xIHBzeV9yZD0xLjAwOjAuMDAgbWl4ZWRfcmVmPTEgbWVfcmFuZ2U9MTYgY2hyb21hX21lPTEgdHJlbGxpcz0yIDh4OGRjdD0wIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJvbWFfcXBfb2Zmc2V0PS0yIHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTAgd2VpZ2h0cD0wIGtleWludD1pbmZpbml0ZSBrZXlpbnRfbWluPTI1IHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NTAgcmM9YWJyIG1idHJlZT0xIGJpdHJhdGU9NDAwIHJhdGV0b2w9MS4wIHFjb21wPTAuNjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAABZYiEBrxmKAAPVccAAS044AA5DRJMnkycJk4TPw==")),r=!1,o=null,s=new VideoDecoder({output:a=>{r=!0,a.close()},error:a=>{o=a}}),i=new EncodedVideoChunk({timestamp:0,type:"key",data:n});s.configure(e),s.decode(i);try{await s.flush()}catch(a){o=a}return!(!r||o!==null)}Mf=await U2();function Jn(){return!!/mac/i.exec(navigator.platform)}function Lo(){return!!/win/i.exec(navigator.platform)}function Mo(){return!!/ipad/i.exec(navigator.platform)||!!/iphone/i.exec(navigator.platform)||!!/ipod/i.exec(navigator.platform)}function Do(e,t,n){let r=n.getBoundingClientRect(),o={x:0,y:0};return e<r.left?o.x=0:e>=r.right?o.x=r.width-1:o.x=e-r.left,t<r.top?o.y=0:t>=r.bottom?o.y=r.height-1:o.y=t-r.top,o}function Pr(e){e.stopPropagation(),e.preventDefault()}var Df=!1,pv=null;document.captureElement=null;function Ir(e){if(Df)return;let t=new e.constructor(e.type,e);Df=!0,document.captureElement?document.captureElement.dispatchEvent(t):pv.dispatchEvent(t),Df=!1,e.stopPropagation(),t.defaultPrevented&&e.preventDefault(),e.type==="mouseup"&&gv()}function fv(){let e=document.getElementById("noVNC_mouse_capture_elem");e.style.cursor=window.getComputedStyle(document.captureElement).cursor}var hv=new MutationObserver(fv);function mv(e){if(e.setCapture)e.setCapture(),document.captureElement=e;else{gv();let t=document.getElementById("noVNC_mouse_capture_elem");t===null&&(t=document.createElement("div"),t.id="noVNC_mouse_capture_elem",t.style.position="fixed",t.style.top="0px",t.style.left="0px",t.style.width="100%",t.style.height="100%",t.style.zIndex=1e4,t.style.display="none",document.body.appendChild(t),t.addEventListener("contextmenu",Ir),t.addEventListener("mousemove",Ir),t.addEventListener("mouseup",Ir)),document.captureElement=e,hv.observe(e,{attributes:!0}),fv(),t.style.display="",window.addEventListener("mousemove",Ir),window.addEventListener("mouseup",Ir)}}function gv(){if(document.releaseCapture)document.releaseCapture(),document.captureElement=null;else{if(!document.captureElement)return;pv=document.captureElement,document.captureElement=null,hv.disconnect();let e=document.getElementById("noVNC_mouse_capture_elem");e.style.display="none",window.removeEventListener("mousemove",Ir),window.removeEventListener("mouseup",Ir)}}var Or=class{constructor(){this._listeners=new Map}addEventListener(t,n){this._listeners.has(t)||this._listeners.set(t,new Set),this._listeners.get(t).add(n)}removeEventListener(t,n){this._listeners.has(t)&&this._listeners.get(t).delete(n)}dispatchEvent(t){return this._listeners.has(t.type)?(this._listeners.get(t.type).forEach(n=>n.call(this,t)),!t.defaultPrevented):!0}};var $i=class{constructor(t){if(this._drawCtx=null,this._renderQ=[],this._flushPromise=null,this._fbWidth=0,this._fbHeight=0,this._prevDrawStyle="",de(">> Display.constructor"),this._target=t,!this._target)throw new Error("Target must be set");if(typeof this._target=="string")throw new Error("target must be a DOM element");if(!this._target.getContext)throw new Error("no getContext method");this._targetCtx=this._target.getContext("2d"),this._viewportLoc={x:0,y:0,w:this._target.width,h:this._target.height},this._backbuffer=document.createElement("canvas"),this._drawCtx=this._backbuffer.getContext("2d"),this._damageBounds={left:0,top:0,right:this._backbuffer.width,bottom:this._backbuffer.height},de("User Agent: "+navigator.userAgent),de("<< Display.constructor"),this._scale=1,this._clipViewport=!1}get scale(){return this._scale}set scale(t){this._rescale(t)}get clipViewport(){return this._clipViewport}set clipViewport(t){this._clipViewport=t;let n=this._viewportLoc;this.viewportChangeSize(n.w,n.h),this.viewportChangePos(0,0)}get width(){return this._fbWidth}get height(){return this._fbHeight}viewportChangePos(t,n){let r=this._viewportLoc;t=Math.floor(t),n=Math.floor(n),this._clipViewport||(t=-r.w,n=-r.h);let o=r.x+r.w-1,s=r.y+r.h-1;t<0&&r.x+t<0&&(t=-r.x),o+t>=this._fbWidth&&(t-=o+t-this._fbWidth+1),r.y+n<0&&(n=-r.y),s+n>=this._fbHeight&&(n-=s+n-this._fbHeight+1),!(t===0&&n===0)&&(de("viewportChange deltaX: "+t+", deltaY: "+n),r.x+=t,r.y+=n,this._damage(r.x,r.y,r.w,r.h),this.flip())}viewportChangeSize(t,n){(!this._clipViewport||typeof t>"u"||typeof n>"u")&&(de("Setting viewport to full display region"),t=this._fbWidth,n=this._fbHeight),t=Math.floor(t),n=Math.floor(n),t>this._fbWidth&&(t=this._fbWidth),n>this._fbHeight&&(n=this._fbHeight);let r=this._viewportLoc;if(r.w!==t||r.h!==n){r.w=t,r.h=n;let o=this._target;o.width=t,o.height=n,this.viewportChangePos(0,0),this._damage(r.x,r.y,r.w,r.h),this.flip(),this._rescale(this._scale)}}absX(t){return this._scale===0?0:Ti(t/this._scale+this._viewportLoc.x)}absY(t){return this._scale===0?0:Ti(t/this._scale+this._viewportLoc.y)}resize(t,n){this._prevDrawStyle="",this._fbWidth=t,this._fbHeight=n;let r=this._backbuffer;if(r.width!==t||r.height!==n){let s=null;r.width>0&&r.height>0&&(s=this._drawCtx.getImageData(0,0,r.width,r.height)),r.width!==t&&(r.width=t),r.height!==n&&(r.height=n),s&&this._drawCtx.putImageData(s,0,0)}let o=this._viewportLoc;this.viewportChangeSize(o.w,o.h),this.viewportChangePos(0,0)}getImageData(){return this._drawCtx.getImageData(0,0,this.width,this.height)}toDataURL(t,n){return this._backbuffer.toDataURL(t,n)}toBlob(t,n,r){return this._backbuffer.toBlob(t,n,r)}_damage(t,n,r,o){t<this._damageBounds.left&&(this._damageBounds.left=t),n<this._damageBounds.top&&(this._damageBounds.top=n),t+r>this._damageBounds.right&&(this._damageBounds.right=t+r),n+o>this._damageBounds.bottom&&(this._damageBounds.bottom=n+o)}flip(t){if(this._renderQ.length!==0&&!t)this._renderQPush({type:"flip"});else{let n=this._damageBounds.left,r=this._damageBounds.top,o=this._damageBounds.right-n,s=this._damageBounds.bottom-r,i=n-this._viewportLoc.x,a=r-this._viewportLoc.y;i<0&&(o+=i,n-=i,i=0),a<0&&(s+=a,r-=a,a=0),i+o>this._viewportLoc.w&&(o=this._viewportLoc.w-i),a+s>this._viewportLoc.h&&(s=this._viewportLoc.h-a),o>0&&s>0&&this._targetCtx.drawImage(this._backbuffer,n,r,o,s,i,a,o,s),this._damageBounds.left=this._damageBounds.top=65535,this._damageBounds.right=this._damageBounds.bottom=0}}pending(){return this._renderQ.length>0}flush(){return this._renderQ.length===0?Promise.resolve():(this._flushPromise===null&&(this._flushPromise=new Promise(t=>{this._flushResolve=t})),this._flushPromise)}fillRect(t,n,r,o,s,i){this._renderQ.length!==0&&!i?this._renderQPush({type:"fill",x:t,y:n,width:r,height:o,color:s}):(this._setFillColor(s),this._drawCtx.fillRect(t,n,r,o),this._damage(t,n,r,o))}copyImage(t,n,r,o,s,i,a){this._renderQ.length!==0&&!a?this._renderQPush({type:"copy",oldX:t,oldY:n,x:r,y:o,width:s,height:i}):(this._drawCtx.mozImageSmoothingEnabled=!1,this._drawCtx.webkitImageSmoothingEnabled=!1,this._drawCtx.msImageSmoothingEnabled=!1,this._drawCtx.imageSmoothingEnabled=!1,this._drawCtx.drawImage(this._backbuffer,t,n,s,i,r,o,s,i),this._damage(r,o,s,i))}imageRect(t,n,r,o,s,i){if(r===0||o===0)return;let a=new Image;a.src="data: "+s+";base64,"+Oo.encode(i),this._renderQPush({type:"img",img:a,x:t,y:n,width:r,height:o})}videoFrame(t,n,r,o,s){this._renderQPush({type:"frame",frame:s,x:t,y:n,width:r,height:o})}blitImage(t,n,r,o,s,i,a){if(this._renderQ.length!==0&&!a){let u=new Uint8Array(r*o*4);u.set(new Uint8Array(s.buffer,0,u.length)),this._renderQPush({type:"blit",data:u,x:t,y:n,width:r,height:o})}else{let u=new Uint8ClampedArray(s.buffer,s.byteOffset+i,r*o*4),c=new ImageData(u,r,o);this._drawCtx.putImageData(c,t,n),this._damage(t,n,r,o)}}drawImage(t,...n){if(this._drawCtx.drawImage(t,...n),n.length<=4){let[r,o]=n;this._damage(r,o,t.width,t.height)}else{let[,,r,o,s,i]=n;this._damage(s,i,r,o)}}autoscale(t,n){let r;if(t===0||n===0)r=0;else{let o=this._viewportLoc,s=t/n;o.w/o.h>=s?r=t/o.w:r=n/o.h}this._rescale(r)}_rescale(t){this._scale=t;let n=this._viewportLoc,r=t*n.w+"px",o=t*n.h+"px";(this._target.style.width!==r||this._target.style.height!==o)&&(this._target.style.width=r,this._target.style.height=o)}_setFillColor(t){let n="rgb("+t[0]+","+t[1]+","+t[2]+")";n!==this._prevDrawStyle&&(this._drawCtx.fillStyle=n,this._prevDrawStyle=n)}_renderQPush(t){this._renderQ.push(t),this._renderQ.length===1&&this._scanRenderQ()}_resumeRenderQ(){this.removeEventListener("load",this._noVNCDisplay._resumeRenderQ),this._noVNCDisplay._scanRenderQ()}_scanRenderQ(){let t=!0;for(;t&&this._renderQ.length>0;){let n=this._renderQ[0];switch(n.type){case"flip":this.flip(!0);break;case"copy":this.copyImage(n.oldX,n.oldY,n.x,n.y,n.width,n.height,!0);break;case"fill":this.fillRect(n.x,n.y,n.width,n.height,n.color,!0);break;case"blit":this.blitImage(n.x,n.y,n.width,n.height,n.data,0,!0);break;case"img":if(n.img.complete){if(n.img.width!==n.width||n.img.height!==n.height){Me("Decoded image has incorrect dimensions. Got "+n.img.width+"x"+n.img.height+". Expected "+n.width+"x"+n.height+".");return}this.drawImage(n.img,n.x,n.y),n.img.src=""}else n.img._noVNCDisplay=this,n.img.addEventListener("load",this._resumeRenderQ),t=!1;break;case"frame":if(n.frame.ready){let r=n.frame.frame;(r.codedWidth<n.width||r.codedHeight<n.height)&&Ye("Decoded video frame does not cover its full rectangle area. Expecting at least "+n.width+"x"+n.height+" but got "+r.codedWidth+"x"+r.codedHeight);let o=0,s=0,i=n.width,a=n.height,u=n.x,c=n.y,d=i,p=a;this.drawImage(r,o,s,i,a,u,c,d,p),r.close()}else{let r=this;n.frame.promise.then(()=>{r._scanRenderQ()}),t=!1}break}t&&this._renderQ.shift()}this._renderQ.length===0&&this._flushPromise!==null&&(this._flushResolve(),this._flushPromise=null,this._flushResolve=null)}};function Xt(e,t,n,r,o){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),o);return}for(var s=0;s<r;s++)e[o+s]=t[n+s]}var Fo=Uint8Array,bt=Uint16Array,Ii=Int32Array;function zo(e,t,n,r){for(var o=e&65535|0,s=e>>>16&65535|0,i=0;n!==0;){i=n>2e3?2e3:n,n-=i;do o=o+t[r++]|0,s=s+o|0;while(--i);o%=65521,s%=65521}return o|s<<16|0}function Ue(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var Bz=Ue();var lc=30,H2=12;function Ff(e,t){var n,r,o,s,i,a,u,c,d,p,f,h,g,x,b,v,w,C,y,T,N,S,$,P,L;n=e.state,r=e.next_in,P=e.input,o=r+(e.avail_in-5),s=e.next_out,L=e.output,i=s-(t-e.avail_out),a=s+(e.avail_out-257),u=n.dmax,c=n.wsize,d=n.whave,p=n.wnext,f=n.window,h=n.hold,g=n.bits,x=n.lencode,b=n.distcode,v=(1<<n.lenbits)-1,w=(1<<n.distbits)-1;e:do{g<15&&(h+=P[r++]<<g,g+=8,h+=P[r++]<<g,g+=8),C=x[h&v];t:for(;;){if(y=C>>>24,h>>>=y,g-=y,y=C>>>16&255,y===0)L[s++]=C&65535;else if(y&16){T=C&65535,y&=15,y&&(g<y&&(h+=P[r++]<<g,g+=8),T+=h&(1<<y)-1,h>>>=y,g-=y),g<15&&(h+=P[r++]<<g,g+=8,h+=P[r++]<<g,g+=8),C=b[h&w];n:for(;;){if(y=C>>>24,h>>>=y,g-=y,y=C>>>16&255,y&16){if(N=C&65535,y&=15,g<y&&(h+=P[r++]<<g,g+=8,g<y&&(h+=P[r++]<<g,g+=8)),N+=h&(1<<y)-1,N>u){e.msg="invalid distance too far back",n.mode=lc;break e}if(h>>>=y,g-=y,y=s-i,N>y){if(y=N-y,y>d&&n.sane){e.msg="invalid distance too far back",n.mode=lc;break e}if(S=0,$=f,p===0){if(S+=c-y,y<T){T-=y;do L[s++]=f[S++];while(--y);S=s-N,$=L}}else if(p<y){if(S+=c+p-y,y-=p,y<T){T-=y;do L[s++]=f[S++];while(--y);if(S=0,p<T){y=p,T-=y;do L[s++]=f[S++];while(--y);S=s-N,$=L}}}else if(S+=p-y,y<T){T-=y;do L[s++]=f[S++];while(--y);S=s-N,$=L}for(;T>2;)L[s++]=$[S++],L[s++]=$[S++],L[s++]=$[S++],T-=3;T&&(L[s++]=$[S++],T>1&&(L[s++]=$[S++]))}else{S=s-N;do L[s++]=L[S++],L[s++]=L[S++],L[s++]=L[S++],T-=3;while(T>2);T&&(L[s++]=L[S++],T>1&&(L[s++]=L[S++]))}}else if((y&64)===0){C=b[(C&65535)+(h&(1<<y)-1)];continue n}else{e.msg="invalid distance code",n.mode=lc;break e}break}}else if((y&64)===0){C=x[(C&65535)+(h&(1<<y)-1)];continue t}else if(y&32){n.mode=H2;break e}else{e.msg="invalid literal/length code",n.mode=lc;break e}break}}while(r<o&&s<a);T=g>>3,r-=T,g-=T<<3,h&=(1<<g)-1,e.next_in=r,e.next_out=s,e.avail_in=r<o?5+(o-r):5-(r-o),e.avail_out=s<a?257+(a-s):257-(s-a),n.hold=h,n.bits=g}var Ko=15,xv=852,bv=592,yv=0,zf=1,_v=2,V2=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Z2=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],W2=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],j2=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function Lr(e,t,n,r,o,s,i,a){var u=a.bits,c=0,d=0,p=0,f=0,h=0,g=0,x=0,b=0,v=0,w=0,C,y,T,N,S,$=null,P=0,L,ne=new bt(Ko+1),se=new bt(Ko+1),_e=null,ie=0,Q,j,G;for(c=0;c<=Ko;c++)ne[c]=0;for(d=0;d<r;d++)ne[t[n+d]]++;for(h=u,f=Ko;f>=1&&ne[f]===0;f--);if(h>f&&(h=f),f===0)return o[s++]=1<<24|64<<16|0,o[s++]=1<<24|64<<16|0,a.bits=1,0;for(p=1;p<f&&ne[p]===0;p++);for(h<p&&(h=p),b=1,c=1;c<=Ko;c++)if(b<<=1,b-=ne[c],b<0)return-1;if(b>0&&(e===yv||f!==1))return-1;for(se[1]=0,c=1;c<Ko;c++)se[c+1]=se[c]+ne[c];for(d=0;d<r;d++)t[n+d]!==0&&(i[se[t[n+d]]++]=d);if(e===yv?($=_e=i,L=19):e===zf?($=V2,P-=257,_e=Z2,ie-=257,L=256):($=W2,_e=j2,L=-1),w=0,d=0,c=p,S=s,g=h,x=0,T=-1,v=1<<h,N=v-1,e===zf&&v>xv||e===_v&&v>bv)return 1;for(;;){Q=c-x,i[d]<L?(j=0,G=i[d]):i[d]>L?(j=_e[ie+i[d]],G=$[P+i[d]]):(j=96,G=0),C=1<<c-x,y=1<<g,p=y;do y-=C,o[S+(w>>x)+y]=Q<<24|j<<16|G|0;while(y!==0);for(C=1<<c-1;w&C;)C>>=1;if(C!==0?(w&=C-1,w+=C):w=0,d++,--ne[c]===0){if(c===f)break;c=t[n+i[d]]}if(c>h&&(w&N)!==T){for(x===0&&(x=h),S+=p,g=c-x,b=1<<g;g+x<f&&(b-=ne[g+x],!(b<=0));)g++,b<<=1;if(v+=1<<g,e===zf&&v>xv||e===_v&&v>bv)return 1;T=w&N,o[T]=h<<24|g<<16|S-s|0}}return w!==0&&(o[S+w]=c-x<<24|64<<16|0),a.bits=h,0}var Q2=0,Qv=1,Gv=2,vv=4,G2=5,cc=6,pc=0,Y2=1,q2=2,Mr=-2,J2=-3,wv=-4,eR=-5,kv=8,Yv=1,Sv=2,Ev=3,Nv=4,Av=5,Cv=6,Tv=7,Rv=8,$v=9,Iv=10,Pv=11,$n=12,Kf=13,Ov=14,Xf=15,Lv=16,Mv=17,Dv=18,Fv=19,uc=20,dc=21,zv=22,Kv=23,Xv=24,Bv=25,Uv=26,Bf=27,Hv=28,Vv=29,Ke=30,Zv=31,tR=32,nR=852,rR=592,oR=15,sR=oR;function Wv(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function iR(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new bt(320),this.work=new bt(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function aR(e){var t;return!e||!e.state?Mr:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Yv,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Ii(nR),t.distcode=t.distdyn=new Ii(rR),t.sane=1,t.back=-1,pc)}function Vf(e){var t;return!e||!e.state?Mr:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,aR(e))}function lR(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Mr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Vf(e))}function cR(e,t){var n,r;return e?(r=new iR,e.state=r,r.window=null,n=lR(e,t),n!==pc&&(e.state=null),n):Mr}function qv(e){return cR(e,sR)}var jv=!0,Uf,Hf;function uR(e){if(jv){var t;for(Uf=new Ii(512),Hf=new Ii(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Lr(Qv,e.lens,0,288,Uf,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Lr(Gv,e.lens,0,32,Hf,0,e.work,{bits:5}),jv=!1}e.lencode=Uf,e.lenbits=9,e.distcode=Hf,e.distbits=5}function dR(e,t,n,r){var o,s=e.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Fo(s.wsize)),r>=s.wsize?(Xt(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(o=s.wsize-s.wnext,o>r&&(o=r),Xt(s.window,t,n-r,o,s.wnext),r-=o,r?(Xt(s.window,t,n-r,r,0),s.wnext=r,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=o))),0}function Jv(e,t){var n,r,o,s,i,a,u,c,d,p,f,h,g,x,b=0,v,w,C,y,T,N,S,$,P=new Fo(4),L,ne,se=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return Mr;n=e.state,n.mode===$n&&(n.mode=Kf),i=e.next_out,o=e.output,u=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,c=n.hold,d=n.bits,p=a,f=u,$=pc;e:for(;;)switch(n.mode){case Yv:if(n.wrap===0){n.mode=Kf;break}for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(n.wrap&2&&c===35615){n.check=0,P[0]=c&255,P[1]=c>>>8&255,n.check=Ue(n.check,P,2,0),c=0,d=0,n.mode=Sv;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=Ke;break}if((c&15)!==kv){e.msg="unknown compression method",n.mode=Ke;break}if(c>>>=4,d-=4,S=(c&15)+8,n.wbits===0)n.wbits=S;else if(S>n.wbits){e.msg="invalid window size",n.mode=Ke;break}n.dmax=1<<S,e.adler=n.check=1,n.mode=c&512?Iv:$n,c=0,d=0;break;case Sv:for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(n.flags=c,(n.flags&255)!==kv){e.msg="unknown compression method",n.mode=Ke;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=Ke;break}n.head&&(n.head.text=c>>8&1),n.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,n.check=Ue(n.check,P,2,0)),c=0,d=0,n.mode=Ev;case Ev:for(;d<32;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.head&&(n.head.time=c),n.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,P[2]=c>>>16&255,P[3]=c>>>24&255,n.check=Ue(n.check,P,4,0)),c=0,d=0,n.mode=Nv;case Nv:for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.head&&(n.head.xflags=c&255,n.head.os=c>>8),n.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,n.check=Ue(n.check,P,2,0)),c=0,d=0,n.mode=Av;case Av:if(n.flags&1024){for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.length=c,n.head&&(n.head.extra_len=c),n.flags&512&&(P[0]=c&255,P[1]=c>>>8&255,n.check=Ue(n.check,P,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=Cv;case Cv:if(n.flags&1024&&(h=n.length,h>a&&(h=a),h&&(n.head&&(S=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Xt(n.head.extra,r,s,h,S)),n.flags&512&&(n.check=Ue(n.check,r,h,s)),a-=h,s+=h,n.length-=h),n.length))break e;n.length=0,n.mode=Tv;case Tv:if(n.flags&2048){if(a===0)break e;h=0;do S=r[s+h++],n.head&&S&&n.length<65536&&(n.head.name+=String.fromCharCode(S));while(S&&h<a);if(n.flags&512&&(n.check=Ue(n.check,r,h,s)),a-=h,s+=h,S)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=Rv;case Rv:if(n.flags&4096){if(a===0)break e;h=0;do S=r[s+h++],n.head&&S&&n.length<65536&&(n.head.comment+=String.fromCharCode(S));while(S&&h<a);if(n.flags&512&&(n.check=Ue(n.check,r,h,s)),a-=h,s+=h,S)break e}else n.head&&(n.head.comment=null);n.mode=$v;case $v:if(n.flags&512){for(;d<16;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(c!==(n.check&65535)){e.msg="header crc mismatch",n.mode=Ke;break}c=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=$n;break;case Iv:for(;d<32;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}e.adler=n.check=Wv(c),c=0,d=0,n.mode=Pv;case Pv:if(n.havedict===0)return e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=a,n.hold=c,n.bits=d,q2;e.adler=n.check=1,n.mode=$n;case $n:if(t===G2||t===cc)break e;case Kf:if(n.last){c>>>=d&7,d-=d&7,n.mode=Bf;break}for(;d<3;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}switch(n.last=c&1,c>>>=1,d-=1,c&3){case 0:n.mode=Ov;break;case 1:if(uR(n),n.mode=uc,t===cc){c>>>=2,d-=2;break e}break;case 2:n.mode=Mv;break;case 3:e.msg="invalid block type",n.mode=Ke}c>>>=2,d-=2;break;case Ov:for(c>>>=d&7,d-=d&7;d<32;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",n.mode=Ke;break}if(n.length=c&65535,c=0,d=0,n.mode=Xf,t===cc)break e;case Xf:n.mode=Lv;case Lv:if(h=n.length,h){if(h>a&&(h=a),h>u&&(h=u),h===0)break e;Xt(o,r,s,h,i),a-=h,s+=h,u-=h,i+=h,n.length-=h;break}n.mode=$n;break;case Mv:for(;d<14;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(n.nlen=(c&31)+257,c>>>=5,d-=5,n.ndist=(c&31)+1,c>>>=5,d-=5,n.ncode=(c&15)+4,c>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Ke;break}n.have=0,n.mode=Dv;case Dv:for(;n.have<n.ncode;){for(;d<3;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.lens[se[n.have++]]=c&7,c>>>=3,d-=3}for(;n.have<19;)n.lens[se[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,L={bits:n.lenbits},$=Lr(Q2,n.lens,0,19,n.lencode,0,n.work,L),n.lenbits=L.bits,$){e.msg="invalid code lengths set",n.mode=Ke;break}n.have=0,n.mode=Fv;case Fv:for(;n.have<n.nlen+n.ndist;){for(;b=n.lencode[c&(1<<n.lenbits)-1],v=b>>>24,w=b>>>16&255,C=b&65535,!(v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(C<16)c>>>=v,d-=v,n.lens[n.have++]=C;else{if(C===16){for(ne=v+2;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(c>>>=v,d-=v,n.have===0){e.msg="invalid bit length repeat",n.mode=Ke;break}S=n.lens[n.have-1],h=3+(c&3),c>>>=2,d-=2}else if(C===17){for(ne=v+3;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}c>>>=v,d-=v,S=0,h=3+(c&7),c>>>=3,d-=3}else{for(ne=v+7;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}c>>>=v,d-=v,S=0,h=11+(c&127),c>>>=7,d-=7}if(n.have+h>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Ke;break}for(;h--;)n.lens[n.have++]=S}}if(n.mode===Ke)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=Ke;break}if(n.lenbits=9,L={bits:n.lenbits},$=Lr(Qv,n.lens,0,n.nlen,n.lencode,0,n.work,L),n.lenbits=L.bits,$){e.msg="invalid literal/lengths set",n.mode=Ke;break}if(n.distbits=6,n.distcode=n.distdyn,L={bits:n.distbits},$=Lr(Gv,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,L),n.distbits=L.bits,$){e.msg="invalid distances set",n.mode=Ke;break}if(n.mode=uc,t===cc)break e;case uc:n.mode=dc;case dc:if(a>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=a,n.hold=c,n.bits=d,Ff(e,f),i=e.next_out,o=e.output,u=e.avail_out,s=e.next_in,r=e.input,a=e.avail_in,c=n.hold,d=n.bits,n.mode===$n&&(n.back=-1);break}for(n.back=0;b=n.lencode[c&(1<<n.lenbits)-1],v=b>>>24,w=b>>>16&255,C=b&65535,!(v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(w&&(w&240)===0){for(y=v,T=w,N=C;b=n.lencode[N+((c&(1<<y+T)-1)>>y)],v=b>>>24,w=b>>>16&255,C=b&65535,!(y+v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}c>>>=y,d-=y,n.back+=y}if(c>>>=v,d-=v,n.back+=v,n.length=C,w===0){n.mode=Uv;break}if(w&32){n.back=-1,n.mode=$n;break}if(w&64){e.msg="invalid literal/length code",n.mode=Ke;break}n.extra=w&15,n.mode=zv;case zv:if(n.extra){for(ne=n.extra;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Kv;case Kv:for(;b=n.distcode[c&(1<<n.distbits)-1],v=b>>>24,w=b>>>16&255,C=b&65535,!(v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if((w&240)===0){for(y=v,T=w,N=C;b=n.distcode[N+((c&(1<<y+T)-1)>>y)],v=b>>>24,w=b>>>16&255,C=b&65535,!(y+v<=d);){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}c>>>=y,d-=y,n.back+=y}if(c>>>=v,d-=v,n.back+=v,w&64){e.msg="invalid distance code",n.mode=Ke;break}n.offset=C,n.extra=w&15,n.mode=Xv;case Xv:if(n.extra){for(ne=n.extra;d<ne;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Ke;break}n.mode=Bv;case Bv:if(u===0)break e;if(h=f-u,n.offset>h){if(h=n.offset-h,h>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Ke;break}h>n.wnext?(h-=n.wnext,g=n.wsize-h):g=n.wnext-h,h>n.length&&(h=n.length),x=n.window}else x=o,g=i-n.offset,h=n.length;h>u&&(h=u),u-=h,n.length-=h;do o[i++]=x[g++];while(--h);n.length===0&&(n.mode=dc);break;case Uv:if(u===0)break e;o[i++]=n.length,u--,n.mode=dc;break;case Bf:if(n.wrap){for(;d<32;){if(a===0)break e;a--,c|=r[s++]<<d,d+=8}if(f-=u,e.total_out+=f,n.total+=f,f&&(e.adler=n.check=n.flags?Ue(n.check,o,f,i-f):zo(n.check,o,f,i-f)),f=u,(n.flags?c:Wv(c))!==n.check){e.msg="incorrect data check",n.mode=Ke;break}c=0,d=0}n.mode=Hv;case Hv:if(n.wrap&&n.flags){for(;d<32;){if(a===0)break e;a--,c+=r[s++]<<d,d+=8}if(c!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=Ke;break}c=0,d=0}n.mode=Vv;case Vv:$=Y2;break e;case Ke:$=J2;break e;case Zv:return wv;case tR:default:return Mr}return e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=a,n.hold=c,n.bits=d,(n.wsize||f!==e.avail_out&&n.mode<Ke&&(n.mode<Bf||t!==vv))&&dR(e,e.output,e.next_out,f-e.avail_out)?(n.mode=Zv,wv):(p-=e.avail_in,f-=e.avail_out,e.total_in+=p,e.total_out+=f,n.total+=f,n.wrap&&f&&(e.adler=n.check=n.flags?Ue(n.check,o,f,e.next_out-f):zo(n.check,o,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===$n?128:0)+(n.mode===uc||n.mode===Xf?256:0),(p===0&&f===0||t===vv)&&$===pc&&($=eR),$)}function Pi(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Yt=class{constructor(){this.strm=new Pi,this.chunkSize=1024*10*10,this.strm.output=new Uint8Array(this.chunkSize),qv(this.strm)}setInput(t){t?(this.strm.input=t,this.strm.avail_in=this.strm.input.length,this.strm.next_in=0):(this.strm.input=null,this.strm.avail_in=0,this.strm.next_in=0)}inflate(t){if(t>this.chunkSize&&(this.chunkSize=t,this.strm.output=new Uint8Array(this.chunkSize)),this.strm.next_out=0,this.strm.avail_out=t,Jv(this.strm,0)<0)throw new Error("zlib inflate failed");if(this.strm.next_out!=t)throw new Error("Incomplete zlib block");return new Uint8Array(this.strm.output.buffer,0,this.strm.next_out)}reset(){Vf(this.strm)}};var pR=4,ew=0,tw=1,fR=2;function Bo(e){for(var t=e.length;--t>=0;)e[t]=0}var hR=0,aw=1,mR=2,gR=3,xR=258,qf=29,zi=256,Li=zi+1+qf,Xo=30,Jf=19,lw=2*Li+1,Dr=15,Zf=16,bR=7,eh=256,cw=16,uw=17,dw=18,Gf=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],fc=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],yR=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],pw=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],_R=512,In=new Array((Li+2)*2);Bo(In);var Oi=new Array(Xo*2);Bo(Oi);var Mi=new Array(_R);Bo(Mi);var Di=new Array(xR-gR+1);Bo(Di);var th=new Array(qf);Bo(th);var hc=new Array(Xo);Bo(hc);function Wf(e,t,n,r,o){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=o,this.has_stree=e&&e.length}var fw,hw,mw;function jf(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function gw(e){return e<256?Mi[e]:Mi[256+(e>>>7)]}function Fi(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Nt(e,t,n){e.bi_valid>Zf-n?(e.bi_buf|=t<<e.bi_valid&65535,Fi(e,e.bi_buf),e.bi_buf=t>>Zf-e.bi_valid,e.bi_valid+=n-Zf):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function dn(e,t,n){Nt(e,n[t*2],n[t*2+1])}function xw(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function vR(e){e.bi_valid===16?(Fi(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function wR(e,t){var n=t.dyn_tree,r=t.max_code,o=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,u=t.stat_desc.max_length,c,d,p,f,h,g,x=0;for(f=0;f<=Dr;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<lw;c++)d=e.heap[c],f=n[n[d*2+1]*2+1]+1,f>u&&(f=u,x++),n[d*2+1]=f,!(d>r)&&(e.bl_count[f]++,h=0,d>=a&&(h=i[d-a]),g=n[d*2],e.opt_len+=g*(f+h),s&&(e.static_len+=g*(o[d*2+1]+h)));if(x!==0){do{for(f=u-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[u]--,x-=2}while(x>0);for(f=u;f!==0;f--)for(d=e.bl_count[f];d!==0;)p=e.heap[--c],!(p>r)&&(n[p*2+1]!==f&&(e.opt_len+=(f-n[p*2+1])*n[p*2],n[p*2+1]=f),d--)}}function bw(e,t,n){var r=new Array(Dr+1),o=0,s,i;for(s=1;s<=Dr;s++)r[s]=o=o+n[s-1]<<1;for(i=0;i<=t;i++){var a=e[i*2+1];a!==0&&(e[i*2]=xw(r[a]++,a))}}function kR(){var e,t,n,r,o,s=new Array(Dr+1);for(n=0,r=0;r<qf-1;r++)for(th[r]=n,e=0;e<1<<Gf[r];e++)Di[n++]=r;for(Di[n-1]=r,o=0,r=0;r<16;r++)for(hc[r]=o,e=0;e<1<<fc[r];e++)Mi[o++]=r;for(o>>=7;r<Xo;r++)for(hc[r]=o<<7,e=0;e<1<<fc[r]-7;e++)Mi[256+o++]=r;for(t=0;t<=Dr;t++)s[t]=0;for(e=0;e<=143;)In[e*2+1]=8,e++,s[8]++;for(;e<=255;)In[e*2+1]=9,e++,s[9]++;for(;e<=279;)In[e*2+1]=7,e++,s[7]++;for(;e<=287;)In[e*2+1]=8,e++,s[8]++;for(bw(In,Li+1,s),e=0;e<Xo;e++)Oi[e*2+1]=5,Oi[e*2]=xw(e,5);fw=new Wf(In,Gf,zi+1,Li,Dr),hw=new Wf(Oi,fc,0,Xo,Dr),mw=new Wf(new Array(0),yR,0,Jf,bR)}function yw(e){var t;for(t=0;t<Li;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Xo;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Jf;t++)e.bl_tree[t*2]=0;e.dyn_ltree[eh*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function _w(e){e.bi_valid>8?Fi(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function SR(e,t,n,r){_w(e),r&&(Fi(e,n),Fi(e,~n)),Xt(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function nw(e,t,n,r){var o=t*2,s=n*2;return e[o]<e[s]||e[o]===e[s]&&r[t]<=r[n]}function Qf(e,t,n){for(var r=e.heap[n],o=n<<1;o<=e.heap_len&&(o<e.heap_len&&nw(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!nw(t,r,e.heap[o],e.depth));)e.heap[n]=e.heap[o],n=o,o<<=1;e.heap[n]=r}function rw(e,t,n){var r,o,s=0,i,a;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+s*2]<<8|e.pending_buf[e.d_buf+s*2+1],o=e.pending_buf[e.l_buf+s],s++,r===0?dn(e,o,t):(i=Di[o],dn(e,i+zi+1,t),a=Gf[i],a!==0&&(o-=th[i],Nt(e,o,a)),r--,i=gw(r),dn(e,i,n),a=fc[i],a!==0&&(r-=hc[i],Nt(e,r,a)));while(s<e.last_lit);dn(e,eh,t)}function Yf(e,t){var n=t.dyn_tree,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.elems,i,a,u=-1,c;for(e.heap_len=0,e.heap_max=lw,i=0;i<s;i++)n[i*2]!==0?(e.heap[++e.heap_len]=u=i,e.depth[i]=0):n[i*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=u<2?++u:0,n[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=r[c*2+1]);for(t.max_code=u,i=e.heap_len>>1;i>=1;i--)Qf(e,n,i);c=s;do i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Qf(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=a,n[c*2]=n[i*2]+n[a*2],e.depth[c]=(e.depth[i]>=e.depth[a]?e.depth[i]:e.depth[a])+1,n[i*2+1]=n[a*2+1]=c,e.heap[1]=c++,Qf(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],wR(e,t),bw(n,u,e.bl_count)}function ow(e,t,n){var r,o=-1,s,i=t[1],a=0,u=7,c=4;for(i===0&&(u=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)s=i,i=t[(r+1)*2+1],!(++a<u&&s===i)&&(a<c?e.bl_tree[s*2]+=a:s!==0?(s!==o&&e.bl_tree[s*2]++,e.bl_tree[cw*2]++):a<=10?e.bl_tree[uw*2]++:e.bl_tree[dw*2]++,a=0,o=s,i===0?(u=138,c=3):s===i?(u=6,c=3):(u=7,c=4))}function sw(e,t,n){var r,o=-1,s,i=t[1],a=0,u=7,c=4;for(i===0&&(u=138,c=3),r=0;r<=n;r++)if(s=i,i=t[(r+1)*2+1],!(++a<u&&s===i)){if(a<c)do dn(e,s,e.bl_tree);while(--a!==0);else s!==0?(s!==o&&(dn(e,s,e.bl_tree),a--),dn(e,cw,e.bl_tree),Nt(e,a-3,2)):a<=10?(dn(e,uw,e.bl_tree),Nt(e,a-3,3)):(dn(e,dw,e.bl_tree),Nt(e,a-11,7));a=0,o=s,i===0?(u=138,c=3):s===i?(u=6,c=3):(u=7,c=4)}}function ER(e){var t;for(ow(e,e.dyn_ltree,e.l_desc.max_code),ow(e,e.dyn_dtree,e.d_desc.max_code),Yf(e,e.bl_desc),t=Jf-1;t>=3&&e.bl_tree[pw[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function NR(e,t,n,r){var o;for(Nt(e,t-257,5),Nt(e,n-1,5),Nt(e,r-4,4),o=0;o<r;o++)Nt(e,e.bl_tree[pw[o]*2+1],3);sw(e,e.dyn_ltree,t-1),sw(e,e.dyn_dtree,n-1)}function AR(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return ew;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return tw;for(n=32;n<zi;n++)if(e.dyn_ltree[n*2]!==0)return tw;return ew}var iw=!1;function vw(e){iw||(kR(),iw=!0),e.l_desc=new jf(e.dyn_ltree,fw),e.d_desc=new jf(e.dyn_dtree,hw),e.bl_desc=new jf(e.bl_tree,mw),e.bi_buf=0,e.bi_valid=0,yw(e)}function nh(e,t,n,r){Nt(e,(hR<<1)+(r?1:0),3),SR(e,t,n,!0)}function ww(e){Nt(e,aw<<1,3),dn(e,eh,In),vR(e)}function kw(e,t,n,r){var o,s,i=0;e.level>0?(e.strm.data_type===fR&&(e.strm.data_type=AR(e)),Yf(e,e.l_desc),Yf(e,e.d_desc),i=ER(e),o=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=o&&(o=s)):o=s=n+5,n+4<=o&&t!==-1?nh(e,t,n,r):e.strategy===pR||s===o?(Nt(e,(aw<<1)+(r?1:0),3),rw(e,In,Oi)):(Nt(e,(mR<<1)+(r?1:0),3),NR(e,e.l_desc.max_code+1,e.d_desc.max_code+1,i+1),rw(e,e.dyn_ltree,e.dyn_dtree)),yw(e),r&&_w(e)}function Pn(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(Di[n]+zi+1)*2]++,e.dyn_dtree[gw(t)*2]++),e.last_lit===e.lit_bufsize-1}var Sw={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};var Xr=0,TR=1,xc=3,nr=4,Ew=5,Fr=0,Nw=1,Zo=-2;var rh=-5,ch=-1,RR=1,mc=2,$R=3,IR=4,PR=0,OR=2,bc=8,LR=9,MR=15,DR=8,FR=29,zR=256,lh=zR+1+FR,KR=30,XR=19,BR=2*lh+1,UR=15,Ae=3,tr=258,qt=tr+Ae+1,HR=32,Tw=42,Aw=69,oh=73,sh=91,ih=103,Xi=113,gc=666,qe=1,Bi=2,Kr=3,Wo=4,VR=3;function Ho(e,t){return e.msg=Sw[t],t}function Cw(e){return(e<<1)-(e>4?9:0)}function zr(e){for(var t=e.length;--t>=0;)e[t]=0}function er(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(Xt(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function st(e,t){kw(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,er(e.strm)}function Ne(e,t){e.pending_buf[e.pending++]=t}function Ki(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function ZR(e,t,n,r){var o=e.avail_in;return o>r&&(o=r),o===0?0:(e.avail_in-=o,Xt(t,e.input,e.next_in,o,n),e.state.wrap===1?e.adler=zo(e.adler,t,o,n):e.state.wrap===2&&(e.adler=Ue(e.adler,t,o,n)),e.next_in+=o,e.total_in+=o,o)}function Rw(e,t){var n=e.max_chain_length,r=e.strstart,o,s,i=e.prev_length,a=e.nice_match,u=e.strstart>e.w_size-qt?e.strstart-(e.w_size-qt):0,c=e.window,d=e.w_mask,p=e.prev,f=e.strstart+tr,h=c[r+i-1],g=c[r+i];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do if(o=t,!(c[o+i]!==g||c[o+i-1]!==h||c[o]!==c[r]||c[++o]!==c[r+1])){r+=2,o++;do;while(c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&c[++r]===c[++o]&&r<f);if(s=tr-(f-r),r=f-tr,s>i){if(e.match_start=t,i=s,s>=a)break;h=c[r+i-1],g=c[r+i]}}while((t=p[t&d])>u&&--n!==0);return i<=e.lookahead?i:e.lookahead}function Ui(e){var t=e.w_size,n,r,o,s,i;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-qt)){Xt(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do o=e.head[--n],e.head[n]=o>=t?o-t:0;while(--r);r=t,n=r;do o=e.prev[--n],e.prev[n]=o>=t?o-t:0;while(--r);s+=t}if(e.strm.avail_in===0)break;if(r=ZR(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=r,e.lookahead+e.insert>=Ae)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=(e.ins_h<<e.hash_shift^e.window[i+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[i+Ae-1])&e.hash_mask,e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<Ae)););}while(e.lookahead<qt&&e.strm.avail_in!==0)}function WR(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Ui(e),e.lookahead===0&&t===Xr)return qe;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,st(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-qt&&(st(e,!1),e.strm.avail_out===0))return qe}return e.insert=0,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):(e.strstart>e.block_start&&(st(e,!1),e.strm.avail_out===0),qe)}function ah(e,t){for(var n,r;;){if(e.lookahead<qt){if(Ui(e),e.lookahead<qt&&t===Xr)return qe;if(e.lookahead===0)break}if(n=0,e.lookahead>=Ae&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ae-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-qt&&(e.match_length=Rw(e,n)),e.match_length>=Ae)if(r=Pn(e,e.strstart-e.match_start,e.match_length-Ae),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Ae){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ae-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=Pn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(st(e,!1),e.strm.avail_out===0))return qe}return e.insert=e.strstart<Ae-1?e.strstart:Ae-1,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):e.last_lit&&(st(e,!1),e.strm.avail_out===0)?qe:Bi}function Uo(e,t){for(var n,r,o;;){if(e.lookahead<qt){if(Ui(e),e.lookahead<qt&&t===Xr)return qe;if(e.lookahead===0)break}if(n=0,e.lookahead>=Ae&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ae-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Ae-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-qt&&(e.match_length=Rw(e,n),e.match_length<=5&&(e.strategy===RR||e.match_length===Ae&&e.strstart-e.match_start>4096)&&(e.match_length=Ae-1)),e.prev_length>=Ae&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-Ae,r=Pn(e,e.strstart-1-e.prev_match,e.prev_length-Ae),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ae-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Ae-1,e.strstart++,r&&(st(e,!1),e.strm.avail_out===0))return qe}else if(e.match_available){if(r=Pn(e,0,e.window[e.strstart-1]),r&&st(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return qe}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Pn(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Ae-1?e.strstart:Ae-1,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):e.last_lit&&(st(e,!1),e.strm.avail_out===0)?qe:Bi}function jR(e,t){for(var n,r,o,s,i=e.window;;){if(e.lookahead<=tr){if(Ui(e),e.lookahead<=tr&&t===Xr)return qe;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Ae&&e.strstart>0&&(o=e.strstart-1,r=i[o],r===i[++o]&&r===i[++o]&&r===i[++o])){s=e.strstart+tr;do;while(r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&r===i[++o]&&o<s);e.match_length=tr-(s-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Ae?(n=Pn(e,1,e.match_length-Ae),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Pn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(st(e,!1),e.strm.avail_out===0))return qe}return e.insert=0,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):e.last_lit&&(st(e,!1),e.strm.avail_out===0)?qe:Bi}function QR(e,t){for(var n;;){if(e.lookahead===0&&(Ui(e),e.lookahead===0)){if(t===Xr)return qe;break}if(e.match_length=0,n=Pn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(st(e,!1),e.strm.avail_out===0))return qe}return e.insert=0,t===nr?(st(e,!0),e.strm.avail_out===0?Kr:Wo):e.last_lit&&(st(e,!1),e.strm.avail_out===0)?qe:Bi}function pn(e,t,n,r,o){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=o}var Vo;Vo=[new pn(0,0,0,0,WR),new pn(4,4,8,4,ah),new pn(4,5,16,8,ah),new pn(4,6,32,32,ah),new pn(4,4,16,16,Uo),new pn(8,16,32,32,Uo),new pn(8,16,128,128,Uo),new pn(8,32,128,256,Uo),new pn(32,128,258,1024,Uo),new pn(32,258,258,4096,Uo)];function GR(e){e.window_size=2*e.w_size,zr(e.head),e.max_lazy_match=Vo[e.level].max_lazy,e.good_match=Vo[e.level].good_length,e.nice_match=Vo[e.level].nice_length,e.max_chain_length=Vo[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Ae-1,e.match_available=0,e.ins_h=0}function YR(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=bc,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new bt(BR*2),this.dyn_dtree=new bt((2*KR+1)*2),this.bl_tree=new bt((2*XR+1)*2),zr(this.dyn_ltree),zr(this.dyn_dtree),zr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new bt(UR+1),this.heap=new bt(2*lh+1),zr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new bt(2*lh+1),zr(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function qR(e){var t;return!e||!e.state?Ho(e,Zo):(e.total_in=e.total_out=0,e.data_type=OR,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Tw:Xi,e.adler=t.wrap===2?0:1,t.last_flush=Xr,vw(t),Fr)}function JR(e){var t=qR(e);return t===Fr&&GR(e.state),t}function e$(e,t,n,r,o,s){if(!e)return Zo;var i=1;if(t===ch&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),o<1||o>LR||n!==bc||r<8||r>15||t<0||t>9||s<0||s>IR)return Ho(e,Zo);r===8&&(r=9);var a=new YR;return e.state=a,a.strm=e,a.wrap=i,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=o+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+Ae-1)/Ae),a.window=new Fo(a.w_size*2),a.head=new bt(a.hash_size),a.prev=new bt(a.w_size),a.lit_bufsize=1<<o+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Fo(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=t,a.strategy=s,a.method=n,JR(e)}function $w(e,t){return e$(e,t,bc,MR,DR,PR)}function uh(e,t){var n,r,o,s;if(!e||!e.state||t>Ew||t<0)return e?Ho(e,Zo):Zo;if(r=e.state,!e.output||!e.input&&e.avail_in!==0||r.status===gc&&t!==nr)return Ho(e,e.avail_out===0?rh:Zo);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===Tw)if(r.wrap===2)e.adler=0,Ne(r,31),Ne(r,139),Ne(r,8),r.gzhead?(Ne(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Ne(r,r.gzhead.time&255),Ne(r,r.gzhead.time>>8&255),Ne(r,r.gzhead.time>>16&255),Ne(r,r.gzhead.time>>24&255),Ne(r,r.level===9?2:r.strategy>=mc||r.level<2?4:0),Ne(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(Ne(r,r.gzhead.extra.length&255),Ne(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Ue(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=Aw):(Ne(r,0),Ne(r,0),Ne(r,0),Ne(r,0),Ne(r,0),Ne(r,r.level===9?2:r.strategy>=mc||r.level<2?4:0),Ne(r,VR),r.status=Xi);else{var i=bc+(r.w_bits-8<<4)<<8,a=-1;r.strategy>=mc||r.level<2?a=0:r.level<6?a=1:r.level===6?a=2:a=3,i|=a<<6,r.strstart!==0&&(i|=HR),i+=31-i%31,r.status=Xi,Ki(r,i),r.strstart!==0&&(Ki(r,e.adler>>>16),Ki(r,e.adler&65535)),e.adler=1}if(r.status===Aw)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),er(e),o=r.pending,r.pending===r.pending_buf_size));)Ne(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=oh)}else r.status=oh;if(r.status===oh)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),er(e),o=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindex<r.gzhead.name.length?s=r.gzhead.name.charCodeAt(r.gzindex++)&255:s=0,Ne(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),s===0&&(r.gzindex=0,r.status=sh)}else r.status=sh;if(r.status===sh)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),er(e),o=r.pending,r.pending===r.pending_buf_size)){s=1;break}r.gzindex<r.gzhead.comment.length?s=r.gzhead.comment.charCodeAt(r.gzindex++)&255:s=0,Ne(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=Ue(e.adler,r.pending_buf,r.pending-o,o)),s===0&&(r.status=ih)}else r.status=ih;if(r.status===ih&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&er(e),r.pending+2<=r.pending_buf_size&&(Ne(r,e.adler&255),Ne(r,e.adler>>8&255),e.adler=0,r.status=Xi)):r.status=Xi),r.pending!==0){if(er(e),e.avail_out===0)return r.last_flush=-1,Fr}else if(e.avail_in===0&&Cw(t)<=Cw(n)&&t!==nr)return Ho(e,rh);if(r.status===gc&&e.avail_in!==0)return Ho(e,rh);if(e.avail_in!==0||r.lookahead!==0||t!==Xr&&r.status!==gc){var u=r.strategy===mc?QR(r,t):r.strategy===$R?jR(r,t):Vo[r.level].func(r,t);if((u===Kr||u===Wo)&&(r.status=gc),u===qe||u===Kr)return e.avail_out===0&&(r.last_flush=-1),Fr;if(u===Bi&&(t===TR?ww(r):t!==Ew&&(nh(r,0,0,!1),t===xc&&(zr(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),er(e),e.avail_out===0))return r.last_flush=-1,Fr}return t!==nr?Fr:r.wrap<=0?Nw:(r.wrap===2?(Ne(r,e.adler&255),Ne(r,e.adler>>8&255),Ne(r,e.adler>>16&255),Ne(r,e.adler>>24&255),Ne(r,e.total_in&255),Ne(r,e.total_in>>8&255),Ne(r,e.total_in>>16&255),Ne(r,e.total_in>>24&255)):(Ki(r,e.adler>>>16),Ki(r,e.adler&65535)),er(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?Fr:Nw)}var Hi=class{constructor(){this.strm=new Pi,this.chunkSize=1024*10*10,this.outputBuffer=new Uint8Array(this.chunkSize),$w(this.strm,ch)}deflate(t){this.strm.input=t,this.strm.avail_in=this.strm.input.length,this.strm.next_in=0,this.strm.output=this.outputBuffer,this.strm.avail_out=this.chunkSize,this.strm.next_out=0;let n=uh(this.strm,xc),r=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);if(n<0)throw new Error("zlib deflate failed");if(this.strm.avail_in>0){let o=[r],s=r.length;do{if(this.strm.output=new Uint8Array(this.chunkSize),this.strm.next_out=0,this.strm.avail_out=this.chunkSize,n=uh(this.strm,xc),n<0)throw new Error("zlib deflate failed");let u=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);s+=u.length,o.push(u)}while(this.strm.avail_in>0);let i=new Uint8Array(s),a=0;for(let u=0;u<o.length;u++)i.set(o[u],a),a+=o[u].length;r=i}return this.strm.input=null,this.strm.avail_in=0,this.strm.next_in=0,r}};var A={XK_VoidSymbol:16777215,XK_BackSpace:65288,XK_Tab:65289,XK_Linefeed:65290,XK_Clear:65291,XK_Return:65293,XK_Pause:65299,XK_Scroll_Lock:65300,XK_Sys_Req:65301,XK_Escape:65307,XK_Delete:65535,XK_Multi_key:65312,XK_Codeinput:65335,XK_SingleCandidate:65340,XK_MultipleCandidate:65341,XK_PreviousCandidate:65342,XK_Kanji:65313,XK_Muhenkan:65314,XK_Henkan_Mode:65315,XK_Henkan:65315,XK_Romaji:65316,XK_Hiragana:65317,XK_Katakana:65318,XK_Hiragana_Katakana:65319,XK_Zenkaku:65320,XK_Hankaku:65321,XK_Zenkaku_Hankaku:65322,XK_Touroku:65323,XK_Massyo:65324,XK_Kana_Lock:65325,XK_Kana_Shift:65326,XK_Eisu_Shift:65327,XK_Eisu_toggle:65328,XK_Kanji_Bangou:65335,XK_Zen_Koho:65341,XK_Mae_Koho:65342,XK_Home:65360,XK_Left:65361,XK_Up:65362,XK_Right:65363,XK_Down:65364,XK_Prior:65365,XK_Page_Up:65365,XK_Next:65366,XK_Page_Down:65366,XK_End:65367,XK_Begin:65368,XK_Select:65376,XK_Print:65377,XK_Execute:65378,XK_Insert:65379,XK_Undo:65381,XK_Redo:65382,XK_Menu:65383,XK_Find:65384,XK_Cancel:65385,XK_Help:65386,XK_Break:65387,XK_Mode_switch:65406,XK_script_switch:65406,XK_Num_Lock:65407,XK_KP_Space:65408,XK_KP_Tab:65417,XK_KP_Enter:65421,XK_KP_F1:65425,XK_KP_F2:65426,XK_KP_F3:65427,XK_KP_F4:65428,XK_KP_Home:65429,XK_KP_Left:65430,XK_KP_Up:65431,XK_KP_Right:65432,XK_KP_Down:65433,XK_KP_Prior:65434,XK_KP_Page_Up:65434,XK_KP_Next:65435,XK_KP_Page_Down:65435,XK_KP_End:65436,XK_KP_Begin:65437,XK_KP_Insert:65438,XK_KP_Delete:65439,XK_KP_Equal:65469,XK_KP_Multiply:65450,XK_KP_Add:65451,XK_KP_Separator:65452,XK_KP_Subtract:65453,XK_KP_Decimal:65454,XK_KP_Divide:65455,XK_KP_0:65456,XK_KP_1:65457,XK_KP_2:65458,XK_KP_3:65459,XK_KP_4:65460,XK_KP_5:65461,XK_KP_6:65462,XK_KP_7:65463,XK_KP_8:65464,XK_KP_9:65465,XK_F1:65470,XK_F2:65471,XK_F3:65472,XK_F4:65473,XK_F5:65474,XK_F6:65475,XK_F7:65476,XK_F8:65477,XK_F9:65478,XK_F10:65479,XK_F11:65480,XK_L1:65480,XK_F12:65481,XK_L2:65481,XK_F13:65482,XK_L3:65482,XK_F14:65483,XK_L4:65483,XK_F15:65484,XK_L5:65484,XK_F16:65485,XK_L6:65485,XK_F17:65486,XK_L7:65486,XK_F18:65487,XK_L8:65487,XK_F19:65488,XK_L9:65488,XK_F20:65489,XK_L10:65489,XK_F21:65490,XK_R1:65490,XK_F22:65491,XK_R2:65491,XK_F23:65492,XK_R3:65492,XK_F24:65493,XK_R4:65493,XK_F25:65494,XK_R5:65494,XK_F26:65495,XK_R6:65495,XK_F27:65496,XK_R7:65496,XK_F28:65497,XK_R8:65497,XK_F29:65498,XK_R9:65498,XK_F30:65499,XK_R10:65499,XK_F31:65500,XK_R11:65500,XK_F32:65501,XK_R12:65501,XK_F33:65502,XK_R13:65502,XK_F34:65503,XK_R14:65503,XK_F35:65504,XK_R15:65504,XK_Shift_L:65505,XK_Shift_R:65506,XK_Control_L:65507,XK_Control_R:65508,XK_Caps_Lock:65509,XK_Shift_Lock:65510,XK_Meta_L:65511,XK_Meta_R:65512,XK_Alt_L:65513,XK_Alt_R:65514,XK_Super_L:65515,XK_Super_R:65516,XK_Hyper_L:65517,XK_Hyper_R:65518,XK_ISO_Level3_Shift:65027,XK_ISO_Next_Group:65032,XK_ISO_Prev_Group:65034,XK_ISO_First_Group:65036,XK_ISO_Last_Group:65038,XK_space:32,XK_exclam:33,XK_quotedbl:34,XK_numbersign:35,XK_dollar:36,XK_percent:37,XK_ampersand:38,XK_apostrophe:39,XK_quoteright:39,XK_parenleft:40,XK_parenright:41,XK_asterisk:42,XK_plus:43,XK_comma:44,XK_minus:45,XK_period:46,XK_slash:47,XK_0:48,XK_1:49,XK_2:50,XK_3:51,XK_4:52,XK_5:53,XK_6:54,XK_7:55,XK_8:56,XK_9:57,XK_colon:58,XK_semicolon:59,XK_less:60,XK_equal:61,XK_greater:62,XK_question:63,XK_at:64,XK_A:65,XK_B:66,XK_C:67,XK_D:68,XK_E:69,XK_F:70,XK_G:71,XK_H:72,XK_I:73,XK_J:74,XK_K:75,XK_L:76,XK_M:77,XK_N:78,XK_O:79,XK_P:80,XK_Q:81,XK_R:82,XK_S:83,XK_T:84,XK_U:85,XK_V:86,XK_W:87,XK_X:88,XK_Y:89,XK_Z:90,XK_bracketleft:91,XK_backslash:92,XK_bracketright:93,XK_asciicircum:94,XK_underscore:95,XK_grave:96,XK_quoteleft:96,XK_a:97,XK_b:98,XK_c:99,XK_d:100,XK_e:101,XK_f:102,XK_g:103,XK_h:104,XK_i:105,XK_j:106,XK_k:107,XK_l:108,XK_m:109,XK_n:110,XK_o:111,XK_p:112,XK_q:113,XK_r:114,XK_s:115,XK_t:116,XK_u:117,XK_v:118,XK_w:119,XK_x:120,XK_y:121,XK_z:122,XK_braceleft:123,XK_bar:124,XK_braceright:125,XK_asciitilde:126,XK_nobreakspace:160,XK_exclamdown:161,XK_cent:162,XK_sterling:163,XK_currency:164,XK_yen:165,XK_brokenbar:166,XK_section:167,XK_diaeresis:168,XK_copyright:169,XK_ordfeminine:170,XK_guillemotleft:171,XK_notsign:172,XK_hyphen:173,XK_registered:174,XK_macron:175,XK_degree:176,XK_plusminus:177,XK_twosuperior:178,XK_threesuperior:179,XK_acute:180,XK_mu:181,XK_paragraph:182,XK_periodcentered:183,XK_cedilla:184,XK_onesuperior:185,XK_masculine:186,XK_guillemotright:187,XK_onequarter:188,XK_onehalf:189,XK_threequarters:190,XK_questiondown:191,XK_Agrave:192,XK_Aacute:193,XK_Acircumflex:194,XK_Atilde:195,XK_Adiaeresis:196,XK_Aring:197,XK_AE:198,XK_Ccedilla:199,XK_Egrave:200,XK_Eacute:201,XK_Ecircumflex:202,XK_Ediaeresis:203,XK_Igrave:204,XK_Iacute:205,XK_Icircumflex:206,XK_Idiaeresis:207,XK_ETH:208,XK_Eth:208,XK_Ntilde:209,XK_Ograve:210,XK_Oacute:211,XK_Ocircumflex:212,XK_Otilde:213,XK_Odiaeresis:214,XK_multiply:215,XK_Oslash:216,XK_Ooblique:216,XK_Ugrave:217,XK_Uacute:218,XK_Ucircumflex:219,XK_Udiaeresis:220,XK_Yacute:221,XK_THORN:222,XK_Thorn:222,XK_ssharp:223,XK_agrave:224,XK_aacute:225,XK_acircumflex:226,XK_atilde:227,XK_adiaeresis:228,XK_aring:229,XK_ae:230,XK_ccedilla:231,XK_egrave:232,XK_eacute:233,XK_ecircumflex:234,XK_ediaeresis:235,XK_igrave:236,XK_iacute:237,XK_icircumflex:238,XK_idiaeresis:239,XK_eth:240,XK_ntilde:241,XK_ograve:242,XK_oacute:243,XK_ocircumflex:244,XK_otilde:245,XK_odiaeresis:246,XK_division:247,XK_oslash:248,XK_ooblique:248,XK_ugrave:249,XK_uacute:250,XK_ucircumflex:251,XK_udiaeresis:252,XK_yacute:253,XK_thorn:254,XK_ydiaeresis:255,XK_Hangul:65329,XK_Hangul_Hanja:65332,XK_Hangul_Jeonja:65336,XF86XK_ModeLock:269025025,XF86XK_MonBrightnessUp:269025026,XF86XK_MonBrightnessDown:269025027,XF86XK_KbdLightOnOff:269025028,XF86XK_KbdBrightnessUp:269025029,XF86XK_KbdBrightnessDown:269025030,XF86XK_Standby:269025040,XF86XK_AudioLowerVolume:269025041,XF86XK_AudioMute:269025042,XF86XK_AudioRaiseVolume:269025043,XF86XK_AudioPlay:269025044,XF86XK_AudioStop:269025045,XF86XK_AudioPrev:269025046,XF86XK_AudioNext:269025047,XF86XK_HomePage:269025048,XF86XK_Mail:269025049,XF86XK_Start:269025050,XF86XK_Search:269025051,XF86XK_AudioRecord:269025052,XF86XK_Calculator:269025053,XF86XK_Memo:269025054,XF86XK_ToDoList:269025055,XF86XK_Calendar:269025056,XF86XK_PowerDown:269025057,XF86XK_ContrastAdjust:269025058,XF86XK_RockerUp:269025059,XF86XK_RockerDown:269025060,XF86XK_RockerEnter:269025061,XF86XK_Back:269025062,XF86XK_Forward:269025063,XF86XK_Stop:269025064,XF86XK_Refresh:269025065,XF86XK_PowerOff:269025066,XF86XK_WakeUp:269025067,XF86XK_Eject:269025068,XF86XK_ScreenSaver:269025069,XF86XK_WWW:269025070,XF86XK_Sleep:269025071,XF86XK_Favorites:269025072,XF86XK_AudioPause:269025073,XF86XK_AudioMedia:269025074,XF86XK_MyComputer:269025075,XF86XK_VendorHome:269025076,XF86XK_LightBulb:269025077,XF86XK_Shop:269025078,XF86XK_History:269025079,XF86XK_OpenURL:269025080,XF86XK_AddFavorite:269025081,XF86XK_HotLinks:269025082,XF86XK_BrightnessAdjust:269025083,XF86XK_Finance:269025084,XF86XK_Community:269025085,XF86XK_AudioRewind:269025086,XF86XK_BackForward:269025087,XF86XK_Launch0:269025088,XF86XK_Launch1:269025089,XF86XK_Launch2:269025090,XF86XK_Launch3:269025091,XF86XK_Launch4:269025092,XF86XK_Launch5:269025093,XF86XK_Launch6:269025094,XF86XK_Launch7:269025095,XF86XK_Launch8:269025096,XF86XK_Launch9:269025097,XF86XK_LaunchA:269025098,XF86XK_LaunchB:269025099,XF86XK_LaunchC:269025100,XF86XK_LaunchD:269025101,XF86XK_LaunchE:269025102,XF86XK_LaunchF:269025103,XF86XK_ApplicationLeft:269025104,XF86XK_ApplicationRight:269025105,XF86XK_Book:269025106,XF86XK_CD:269025107,XF86XK_Calculater:269025108,XF86XK_Clear:269025109,XF86XK_Close:269025110,XF86XK_Copy:269025111,XF86XK_Cut:269025112,XF86XK_Display:269025113,XF86XK_DOS:269025114,XF86XK_Documents:269025115,XF86XK_Excel:269025116,XF86XK_Explorer:269025117,XF86XK_Game:269025118,XF86XK_Go:269025119,XF86XK_iTouch:269025120,XF86XK_LogOff:269025121,XF86XK_Market:269025122,XF86XK_Meeting:269025123,XF86XK_MenuKB:269025125,XF86XK_MenuPB:269025126,XF86XK_MySites:269025127,XF86XK_New:269025128,XF86XK_News:269025129,XF86XK_OfficeHome:269025130,XF86XK_Open:269025131,XF86XK_Option:269025132,XF86XK_Paste:269025133,XF86XK_Phone:269025134,XF86XK_Q:269025136,XF86XK_Reply:269025138,XF86XK_Reload:269025139,XF86XK_RotateWindows:269025140,XF86XK_RotationPB:269025141,XF86XK_RotationKB:269025142,XF86XK_Save:269025143,XF86XK_ScrollUp:269025144,XF86XK_ScrollDown:269025145,XF86XK_ScrollClick:269025146,XF86XK_Send:269025147,XF86XK_Spell:269025148,XF86XK_SplitScreen:269025149,XF86XK_Support:269025150,XF86XK_TaskPane:269025151,XF86XK_Terminal:269025152,XF86XK_Tools:269025153,XF86XK_Travel:269025154,XF86XK_UserPB:269025156,XF86XK_User1KB:269025157,XF86XK_User2KB:269025158,XF86XK_Video:269025159,XF86XK_WheelButton:269025160,XF86XK_Word:269025161,XF86XK_Xfer:269025162,XF86XK_ZoomIn:269025163,XF86XK_ZoomOut:269025164,XF86XK_Away:269025165,XF86XK_Messenger:269025166,XF86XK_WebCam:269025167,XF86XK_MailForward:269025168,XF86XK_Pictures:269025169,XF86XK_Music:269025170,XF86XK_Battery:269025171,XF86XK_Bluetooth:269025172,XF86XK_WLAN:269025173,XF86XK_UWB:269025174,XF86XK_AudioForward:269025175,XF86XK_AudioRepeat:269025176,XF86XK_AudioRandomPlay:269025177,XF86XK_Subtitle:269025178,XF86XK_AudioCycleTrack:269025179,XF86XK_CycleAngle:269025180,XF86XK_FrameBack:269025181,XF86XK_FrameForward:269025182,XF86XK_Time:269025183,XF86XK_Select:269025184,XF86XK_View:269025185,XF86XK_TopMenu:269025186,XF86XK_Red:269025187,XF86XK_Green:269025188,XF86XK_Yellow:269025189,XF86XK_Blue:269025190,XF86XK_Suspend:269025191,XF86XK_Hibernate:269025192,XF86XK_TouchpadToggle:269025193,XF86XK_TouchpadOn:269025200,XF86XK_TouchpadOff:269025201,XF86XK_AudioMicMute:269025202,XF86XK_Switch_VT_1:269024769,XF86XK_Switch_VT_2:269024770,XF86XK_Switch_VT_3:269024771,XF86XK_Switch_VT_4:269024772,XF86XK_Switch_VT_5:269024773,XF86XK_Switch_VT_6:269024774,XF86XK_Switch_VT_7:269024775,XF86XK_Switch_VT_8:269024776,XF86XK_Switch_VT_9:269024777,XF86XK_Switch_VT_10:269024778,XF86XK_Switch_VT_11:269024779,XF86XK_Switch_VT_12:269024780,XF86XK_Ungrab:269024800,XF86XK_ClearGrab:269024801,XF86XK_Next_VMode:269024802,XF86XK_Prev_VMode:269024803,XF86XK_LogWindowTree:269024804,XF86XK_LogGrabInfo:269024805};var t$={256:960,257:992,258:451,259:483,260:417,261:433,262:454,263:486,264:710,265:742,266:709,267:741,268:456,269:488,270:463,271:495,272:464,273:496,274:938,275:954,278:972,279:1004,280:458,281:490,282:460,283:492,284:728,285:760,286:683,287:699,288:725,289:757,290:939,291:955,292:678,293:694,294:673,295:689,296:933,297:949,298:975,299:1007,302:967,303:999,304:681,305:697,308:684,309:700,310:979,311:1011,312:930,313:453,314:485,315:934,316:950,317:421,318:437,321:419,322:435,323:465,324:497,325:977,326:1009,327:466,328:498,330:957,331:959,332:978,333:1010,336:469,337:501,338:5052,339:5053,340:448,341:480,342:931,343:947,344:472,345:504,346:422,347:438,348:734,349:766,350:426,351:442,352:425,353:441,354:478,355:510,356:427,357:443,358:940,359:956,360:989,361:1021,362:990,363:1022,364:733,365:765,366:473,367:505,368:475,369:507,370:985,371:1017,376:5054,377:428,378:444,379:431,380:447,381:430,382:446,402:2294,466:16777681,711:439,728:418,729:511,731:434,733:445,901:1966,902:1953,904:1954,905:1955,906:1956,908:1959,910:1960,911:1963,912:1974,913:1985,914:1986,915:1987,916:1988,917:1989,918:1990,919:1991,920:1992,921:1993,922:1994,923:1995,924:1996,925:1997,926:1998,927:1999,928:2e3,929:2001,931:2002,932:2004,933:2005,934:2006,935:2007,936:2008,937:2009,938:1957,939:1961,940:1969,941:1970,942:1971,943:1972,944:1978,945:2017,946:2018,947:2019,948:2020,949:2021,950:2022,951:2023,952:2024,953:2025,954:2026,955:2027,956:2028,957:2029,958:2030,959:2031,960:2032,961:2033,962:2035,963:2034,964:2036,965:2037,966:2038,967:2039,968:2040,969:2041,970:1973,971:1977,972:1975,973:1976,974:1979,1025:1715,1026:1713,1027:1714,1028:1716,1029:1717,1030:1718,1031:1719,1032:1720,1033:1721,1034:1722,1035:1723,1036:1724,1038:1726,1039:1727,1040:1761,1041:1762,1042:1783,1043:1767,1044:1764,1045:1765,1046:1782,1047:1786,1048:1769,1049:1770,1050:1771,1051:1772,1052:1773,1053:1774,1054:1775,1055:1776,1056:1778,1057:1779,1058:1780,1059:1781,1060:1766,1061:1768,1062:1763,1063:1790,1064:1787,1065:1789,1066:1791,1067:1785,1068:1784,1069:1788,1070:1760,1071:1777,1072:1729,1073:1730,1074:1751,1075:1735,1076:1732,1077:1733,1078:1750,1079:1754,1080:1737,1081:1738,1082:1739,1083:1740,1084:1741,1085:1742,1086:1743,1087:1744,1088:1746,1089:1747,1090:1748,1091:1749,1092:1734,1093:1736,1094:1731,1095:1758,1096:1755,1097:1757,1098:1759,1099:1753,1100:1752,1101:1756,1102:1728,1103:1745,1105:1699,1106:1697,1107:1698,1108:1700,1109:1701,1110:1702,1111:1703,1112:1704,1113:1705,1114:1706,1115:1707,1116:1708,1118:1710,1119:1711,1168:1725,1169:1709,1488:3296,1489:3297,1490:3298,1491:3299,1492:3300,1493:3301,1494:3302,1495:3303,1496:3304,1497:3305,1498:3306,1499:3307,1500:3308,1501:3309,1502:3310,1503:3311,1504:3312,1505:3313,1506:3314,1507:3315,1508:3316,1509:3317,1510:3318,1511:3319,1512:3320,1513:3321,1514:3322,1548:1452,1563:1467,1567:1471,1569:1473,1570:1474,1571:1475,1572:1476,1573:1477,1574:1478,1575:1479,1576:1480,1577:1481,1578:1482,1579:1483,1580:1484,1581:1485,1582:1486,1583:1487,1584:1488,1585:1489,1586:1490,1587:1491,1588:1492,1589:1493,1590:1494,1591:1495,1592:1496,1593:1497,1594:1498,1600:1504,1601:1505,1602:1506,1603:1507,1604:1508,1605:1509,1606:1510,1607:1511,1608:1512,1609:1513,1610:1514,1611:1515,1612:1516,1613:1517,1614:1518,1615:1519,1616:1520,1617:1521,1618:1522,3585:3489,3586:3490,3587:3491,3588:3492,3589:3493,3590:3494,3591:3495,3592:3496,3593:3497,3594:3498,3595:3499,3596:3500,3597:3501,3598:3502,3599:3503,3600:3504,3601:3505,3602:3506,3603:3507,3604:3508,3605:3509,3606:3510,3607:3511,3608:3512,3609:3513,3610:3514,3611:3515,3612:3516,3613:3517,3614:3518,3615:3519,3616:3520,3617:3521,3618:3522,3619:3523,3620:3524,3621:3525,3622:3526,3623:3527,3624:3528,3625:3529,3626:3530,3627:3531,3628:3532,3629:3533,3630:3534,3631:3535,3632:3536,3633:3537,3634:3538,3635:3539,3636:3540,3637:3541,3638:3542,3639:3543,3640:3544,3641:3545,3642:3546,3647:3551,3648:3552,3649:3553,3650:3554,3651:3555,3652:3556,3653:3557,3654:3558,3655:3559,3656:3560,3657:3561,3658:3562,3659:3563,3660:3564,3661:3565,3664:3568,3665:3569,3666:3570,3667:3571,3668:3572,3669:3573,3670:3574,3671:3575,3672:3576,3673:3577,8194:2722,8195:2721,8196:2723,8197:2724,8199:2725,8200:2726,8201:2727,8202:2728,8210:2747,8211:2730,8212:2729,8213:1967,8215:3295,8216:2768,8217:2769,8218:2813,8220:2770,8221:2771,8222:2814,8224:2801,8225:2802,8226:2790,8229:2735,8230:2734,8240:2773,8242:2774,8243:2775,8248:2812,8254:1150,8361:3839,8364:8364,8453:2744,8470:1712,8471:2811,8478:2772,8482:2761,8531:2736,8532:2737,8533:2738,8534:2739,8535:2740,8536:2741,8537:2742,8538:2743,8539:2755,8540:2756,8541:2757,8542:2758,8592:2299,8593:2300,8594:2301,8595:2302,8658:2254,8660:2253,8706:2287,8711:2245,8728:3018,8730:2262,8733:2241,8734:2242,8743:2270,8744:2271,8745:2268,8746:2269,8747:2239,8756:2240,8764:2248,8771:2249,8773:16785992,8800:2237,8801:2255,8804:2236,8805:2238,8834:2266,8835:2267,8866:3068,8867:3036,8868:3010,8869:3022,8968:3027,8970:3012,8981:2810,8992:2212,8993:2213,9109:3020,9115:2219,9117:2220,9118:2221,9120:2222,9121:2215,9123:2216,9124:2217,9126:2218,9128:2223,9132:2224,9143:2209,9146:2543,9147:2544,9148:2546,9149:2547,9225:2530,9226:2533,9227:2537,9228:2531,9229:2532,9251:2732,9252:2536,9472:2211,9474:2214,9484:2210,9488:2539,9492:2541,9496:2538,9500:2548,9508:2549,9516:2551,9524:2550,9532:2542,9618:2529,9642:2791,9643:2785,9644:2779,9645:2786,9646:2783,9647:2767,9650:2792,9651:2787,9654:2781,9655:2765,9660:2793,9661:2788,9664:2780,9665:2764,9670:2528,9675:2766,9679:2782,9702:2784,9734:2789,9742:2809,9747:2762,9756:2794,9758:2795,9792:2808,9794:2807,9827:2796,9829:2798,9830:2797,9837:2806,9839:2805,10003:2803,10007:2804,10013:2777,10016:2800,10216:2748,10217:2750,12289:1188,12290:1185,12300:1186,12301:1187,12443:1246,12444:1247,12449:1191,12450:1201,12451:1192,12452:1202,12453:1193,12454:1203,12455:1194,12456:1204,12457:1195,12458:1205,12459:1206,12461:1207,12463:1208,12465:1209,12467:1210,12469:1211,12471:1212,12473:1213,12475:1214,12477:1215,12479:1216,12481:1217,12483:1199,12484:1218,12486:1219,12488:1220,12490:1221,12491:1222,12492:1223,12493:1224,12494:1225,12495:1226,12498:1227,12501:1228,12504:1229,12507:1230,12510:1231,12511:1232,12512:1233,12513:1234,12514:1235,12515:1196,12516:1236,12517:1197,12518:1237,12519:1198,12520:1238,12521:1239,12522:1240,12523:1241,12524:1242,12525:1243,12527:1244,12530:1190,12531:1245,12539:1189,12540:1200},Iw={lookup(e){if(e>=32&&e<=255)return e;let t=t$[e];return t!==void 0?t:16777216|e}};var dh={8:"Backspace",9:"Tab",10:"NumpadClear",13:"Enter",16:"ShiftLeft",17:"ControlLeft",18:"AltLeft",19:"Pause",20:"CapsLock",21:"Lang1",25:"Lang2",27:"Escape",28:"Convert",29:"NonConvert",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",41:"Select",44:"PrintScreen",45:"Insert",46:"Delete",47:"Help",48:"Digit0",49:"Digit1",50:"Digit2",51:"Digit3",52:"Digit4",53:"Digit5",54:"Digit6",55:"Digit7",56:"Digit8",57:"Digit9",91:"MetaLeft",92:"MetaRight",93:"ContextMenu",95:"Sleep",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9",106:"NumpadMultiply",107:"NumpadAdd",108:"NumpadDecimal",109:"NumpadSubtract",110:"NumpadDecimal",111:"NumpadDivide",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",124:"F13",125:"F14",126:"F15",127:"F16",128:"F17",129:"F18",130:"F19",131:"F20",132:"F21",133:"F22",134:"F23",135:"F24",144:"NumLock",145:"ScrollLock",166:"BrowserBack",167:"BrowserForward",168:"BrowserRefresh",169:"BrowserStop",170:"BrowserSearch",171:"BrowserFavorites",172:"BrowserHome",173:"AudioVolumeMute",174:"AudioVolumeDown",175:"AudioVolumeUp",176:"MediaTrackNext",177:"MediaTrackPrevious",178:"MediaStop",179:"MediaPlayPause",180:"LaunchMail",181:"MediaSelect",182:"LaunchApp1",183:"LaunchApp2",225:"AltRight"};var ph={Backspace:"Backspace",AltLeft:"Alt",AltRight:"Alt",CapsLock:"CapsLock",ContextMenu:"ContextMenu",ControlLeft:"Control",ControlRight:"Control",Enter:"Enter",MetaLeft:"Meta",MetaRight:"Meta",ShiftLeft:"Shift",ShiftRight:"Shift",Tab:"Tab",Delete:"Delete",End:"End",Help:"Help",Home:"Home",Insert:"Insert",PageDown:"PageDown",PageUp:"PageUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",ArrowUp:"ArrowUp",NumLock:"NumLock",NumpadBackspace:"Backspace",NumpadClear:"Clear",Escape:"Escape",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F30:"F30",F31:"F31",F32:"F32",F33:"F33",F34:"F34",F35:"F35",PrintScreen:"PrintScreen",ScrollLock:"ScrollLock",Pause:"Pause",BrowserBack:"BrowserBack",BrowserFavorites:"BrowserFavorites",BrowserForward:"BrowserForward",BrowserHome:"BrowserHome",BrowserRefresh:"BrowserRefresh",BrowserSearch:"BrowserSearch",BrowserStop:"BrowserStop",Eject:"Eject",LaunchApp1:"LaunchMyComputer",LaunchApp2:"LaunchCalendar",LaunchMail:"LaunchMail",MediaPlayPause:"MediaPlay",MediaStop:"MediaStop",MediaTrackNext:"MediaTrackNext",MediaTrackPrevious:"MediaTrackPrevious",Power:"Power",Sleep:"Sleep",AudioVolumeDown:"AudioVolumeDown",AudioVolumeMute:"AudioVolumeMute",AudioVolumeUp:"AudioVolumeUp",WakeUp:"WakeUp"};var Br={};function X(e,t){if(t===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(e in Br)throw new Error('Duplicate entry for key "'+e+'"');Br[e]=[t,t,t,t]}function yc(e,t,n){if(t===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(n===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(e in Br)throw new Error('Duplicate entry for key "'+e+'"');Br[e]=[t,t,n,t]}function Ce(e,t,n){if(t===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(n===void 0)throw new Error('Undefined keysym for key "'+e+'"');if(e in Br)throw new Error('Duplicate entry for key "'+e+'"');Br[e]=[t,t,t,n]}yc("Alt",A.XK_Alt_L,A.XK_Alt_R);X("AltGraph",A.XK_ISO_Level3_Shift);X("CapsLock",A.XK_Caps_Lock);yc("Control",A.XK_Control_L,A.XK_Control_R);yc("Meta",A.XK_Super_L,A.XK_Super_R);X("NumLock",A.XK_Num_Lock);X("ScrollLock",A.XK_Scroll_Lock);yc("Shift",A.XK_Shift_L,A.XK_Shift_R);Ce("Enter",A.XK_Return,A.XK_KP_Enter);X("Tab",A.XK_Tab);Ce(" ",A.XK_space,A.XK_KP_Space);Ce("ArrowDown",A.XK_Down,A.XK_KP_Down);Ce("ArrowLeft",A.XK_Left,A.XK_KP_Left);Ce("ArrowRight",A.XK_Right,A.XK_KP_Right);Ce("ArrowUp",A.XK_Up,A.XK_KP_Up);Ce("End",A.XK_End,A.XK_KP_End);Ce("Home",A.XK_Home,A.XK_KP_Home);Ce("PageDown",A.XK_Next,A.XK_KP_Next);Ce("PageUp",A.XK_Prior,A.XK_KP_Prior);X("Backspace",A.XK_BackSpace);Ce("Clear",A.XK_Clear,A.XK_KP_Begin);X("Copy",A.XF86XK_Copy);X("Cut",A.XF86XK_Cut);Ce("Delete",A.XK_Delete,A.XK_KP_Delete);Ce("Insert",A.XK_Insert,A.XK_KP_Insert);X("Paste",A.XF86XK_Paste);X("Redo",A.XK_Redo);X("Undo",A.XK_Undo);X("Cancel",A.XK_Cancel);X("ContextMenu",A.XK_Menu);X("Escape",A.XK_Escape);X("Execute",A.XK_Execute);X("Find",A.XK_Find);X("Help",A.XK_Help);X("Pause",A.XK_Pause);X("Select",A.XK_Select);X("ZoomIn",A.XF86XK_ZoomIn);X("ZoomOut",A.XF86XK_ZoomOut);X("BrightnessDown",A.XF86XK_MonBrightnessDown);X("BrightnessUp",A.XF86XK_MonBrightnessUp);X("Eject",A.XF86XK_Eject);X("LogOff",A.XF86XK_LogOff);X("Power",A.XF86XK_PowerOff);X("PowerOff",A.XF86XK_PowerDown);X("PrintScreen",A.XK_Print);X("Hibernate",A.XF86XK_Hibernate);X("Standby",A.XF86XK_Standby);X("WakeUp",A.XF86XK_WakeUp);X("AllCandidates",A.XK_MultipleCandidate);X("Alphanumeric",A.XK_Eisu_toggle);X("CodeInput",A.XK_Codeinput);X("Compose",A.XK_Multi_key);X("Convert",A.XK_Henkan);X("GroupFirst",A.XK_ISO_First_Group);X("GroupLast",A.XK_ISO_Last_Group);X("GroupNext",A.XK_ISO_Next_Group);X("GroupPrevious",A.XK_ISO_Prev_Group);X("NonConvert",A.XK_Muhenkan);X("PreviousCandidate",A.XK_PreviousCandidate);X("SingleCandidate",A.XK_SingleCandidate);X("HangulMode",A.XK_Hangul);X("HanjaMode",A.XK_Hangul_Hanja);X("JunjaMode",A.XK_Hangul_Jeonja);X("Eisu",A.XK_Eisu_toggle);X("Hankaku",A.XK_Hankaku);X("Hiragana",A.XK_Hiragana);X("HiraganaKatakana",A.XK_Hiragana_Katakana);X("KanaMode",A.XK_Kana_Shift);X("KanjiMode",A.XK_Kanji);X("Katakana",A.XK_Katakana);X("Romaji",A.XK_Romaji);X("Zenkaku",A.XK_Zenkaku);X("ZenkakuHankaku",A.XK_Zenkaku_Hankaku);X("F1",A.XK_F1);X("F2",A.XK_F2);X("F3",A.XK_F3);X("F4",A.XK_F4);X("F5",A.XK_F5);X("F6",A.XK_F6);X("F7",A.XK_F7);X("F8",A.XK_F8);X("F9",A.XK_F9);X("F10",A.XK_F10);X("F11",A.XK_F11);X("F12",A.XK_F12);X("F13",A.XK_F13);X("F14",A.XK_F14);X("F15",A.XK_F15);X("F16",A.XK_F16);X("F17",A.XK_F17);X("F18",A.XK_F18);X("F19",A.XK_F19);X("F20",A.XK_F20);X("F21",A.XK_F21);X("F22",A.XK_F22);X("F23",A.XK_F23);X("F24",A.XK_F24);X("F25",A.XK_F25);X("F26",A.XK_F26);X("F27",A.XK_F27);X("F28",A.XK_F28);X("F29",A.XK_F29);X("F30",A.XK_F30);X("F31",A.XK_F31);X("F32",A.XK_F32);X("F33",A.XK_F33);X("F34",A.XK_F34);X("F35",A.XK_F35);X("Close",A.XF86XK_Close);X("MailForward",A.XF86XK_MailForward);X("MailReply",A.XF86XK_Reply);X("MailSend",A.XF86XK_Send);X("MediaFastForward",A.XF86XK_AudioForward);X("MediaPause",A.XF86XK_AudioPause);X("MediaPlay",A.XF86XK_AudioPlay);X("MediaRecord",A.XF86XK_AudioRecord);X("MediaRewind",A.XF86XK_AudioRewind);X("MediaStop",A.XF86XK_AudioStop);X("MediaTrackNext",A.XF86XK_AudioNext);X("MediaTrackPrevious",A.XF86XK_AudioPrev);X("New",A.XF86XK_New);X("Open",A.XF86XK_Open);X("Print",A.XK_Print);X("Save",A.XF86XK_Save);X("SpellCheck",A.XF86XK_Spell);X("AudioVolumeDown",A.XF86XK_AudioLowerVolume);X("AudioVolumeUp",A.XF86XK_AudioRaiseVolume);X("AudioVolumeMute",A.XF86XK_AudioMute);X("MicrophoneVolumeMute",A.XF86XK_AudioMicMute);X("LaunchApplication1",A.XF86XK_MyComputer);X("LaunchApplication2",A.XF86XK_Calculator);X("LaunchCalendar",A.XF86XK_Calendar);X("LaunchMail",A.XF86XK_Mail);X("LaunchMediaPlayer",A.XF86XK_AudioMedia);X("LaunchMusicPlayer",A.XF86XK_Music);X("LaunchPhone",A.XF86XK_Phone);X("LaunchScreenSaver",A.XF86XK_ScreenSaver);X("LaunchSpreadsheet",A.XF86XK_Excel);X("LaunchWebBrowser",A.XF86XK_WWW);X("LaunchWebCam",A.XF86XK_WebCam);X("LaunchWordProcessor",A.XF86XK_Word);X("BrowserBack",A.XF86XK_Back);X("BrowserFavorites",A.XF86XK_Favorites);X("BrowserForward",A.XF86XK_Forward);X("BrowserHome",A.XF86XK_HomePage);X("BrowserRefresh",A.XF86XK_Refresh);X("BrowserSearch",A.XF86XK_Search);X("BrowserStop",A.XF86XK_Stop);X("Dimmer",A.XF86XK_BrightnessAdjust);X("MediaAudioTrack",A.XF86XK_AudioCycleTrack);X("RandomToggle",A.XF86XK_AudioRandomPlay);X("SplitScreenToggle",A.XF86XK_SplitScreen);X("Subtitle",A.XF86XK_Subtitle);X("VideoModeNext",A.XF86XK_Next_VMode);Ce("=",A.XK_equal,A.XK_KP_Equal);Ce("+",A.XK_plus,A.XK_KP_Add);Ce("-",A.XK_minus,A.XK_KP_Subtract);Ce("*",A.XK_asterisk,A.XK_KP_Multiply);Ce("/",A.XK_slash,A.XK_KP_Divide);Ce(".",A.XK_period,A.XK_KP_Decimal);Ce(",",A.XK_comma,A.XK_KP_Separator);Ce("0",A.XK_0,A.XK_KP_0);Ce("1",A.XK_1,A.XK_KP_1);Ce("2",A.XK_2,A.XK_KP_2);Ce("3",A.XK_3,A.XK_KP_3);Ce("4",A.XK_4,A.XK_KP_4);Ce("5",A.XK_5,A.XK_KP_5);Ce("6",A.XK_6,A.XK_KP_6);Ce("7",A.XK_7,A.XK_KP_7);Ce("8",A.XK_8,A.XK_KP_8);Ce("9",A.XK_9,A.XK_KP_9);var fh=Br;function jo(e){if(e.code){switch(e.code){case"OSLeft":return"MetaLeft";case"OSRight":return"MetaRight"}return e.code}if(e.keyCode in dh){let t=dh[e.keyCode];if(Jn()&&t==="ContextMenu"&&(t="MetaRight"),e.location===2)switch(t){case"ShiftLeft":return"ShiftRight";case"ControlLeft":return"ControlRight";case"AltLeft":return"AltRight"}if(e.location===3)switch(t){case"Delete":return"NumpadDecimal";case"Insert":return"Numpad0";case"End":return"Numpad1";case"ArrowDown":return"Numpad2";case"PageDown":return"Numpad3";case"ArrowLeft":return"Numpad4";case"ArrowRight":return"Numpad6";case"Home":return"Numpad7";case"ArrowUp":return"Numpad8";case"PageUp":return"Numpad9";case"Enter":return"NumpadEnter"}return t}return"Unidentified"}function n$(e){if(e.key!==void 0&&e.key!=="Unidentified"){switch(e.key){case"OS":return"Meta";case"LaunchMyComputer":return"LaunchApplication1";case"LaunchCalculator":return"LaunchApplication2"}switch(e.key){case"UIKeyInputUpArrow":return"ArrowUp";case"UIKeyInputDownArrow":return"ArrowDown";case"UIKeyInputLeftArrow":return"ArrowLeft";case"UIKeyInputRightArrow":return"ArrowRight";case"UIKeyInputEscape":return"Escape"}return e.key==="\0"&&e.code==="NumpadDecimal"?"Delete":e.key}let t=jo(e);return t in ph?ph[t]:e.charCode?String.fromCharCode(e.charCode):"Unidentified"}function Pw(e){let t=n$(e);if(t==="Unidentified")return null;if(t in fh){let r=e.location;if(t==="Meta"&&r===0&&(r=2),t==="Clear"&&r===3&&jo(e)==="NumLock"&&(r=0),(r===void 0||r>3)&&(r=0),t==="Meta"){let o=jo(e);if(o==="AltLeft")return A.XK_Meta_L;if(o==="AltRight")return A.XK_Meta_R}if(t==="Clear"&&jo(e)==="NumLock")return A.XK_Num_Lock;if(Lo())switch(t){case"Zenkaku":case"Hankaku":return A.XK_Zenkaku_Hankaku;case"Romaji":case"KanaMode":return A.XK_Romaji}return fh[t][r]}if(t.length!==1)return null;let n=t.charCodeAt();return n?Iw.lookup(n):null}var Vi=class{constructor(t){this._target=t||null,this._keyDownList={},this._altGrArmed=!1,this._eventHandlers={keyup:this._handleKeyUp.bind(this),keydown:this._handleKeyDown.bind(this),blur:this._allKeysUp.bind(this)},this.onkeyevent=()=>{}}_sendKeyEvent(t,n,r,o=null,s=null){if(r)this._keyDownList[n]=t;else{if(!(n in this._keyDownList))return;delete this._keyDownList[n]}de("onkeyevent "+(r?"down":"up")+", keysym: "+t,", code: "+n+", numlock: "+o+", capslock: "+s),this.onkeyevent(t,n,r,o,s)}_getKeyCode(t){let n=jo(t);if(n!=="Unidentified")return n;if(t.keyCode&&t.keyCode!==229)return"Platform"+t.keyCode;if(t.keyIdentifier){if(t.keyIdentifier.substr(0,2)!=="U+")return t.keyIdentifier;let r=parseInt(t.keyIdentifier.substr(2),16);return"Platform"+String.fromCharCode(r).toUpperCase().charCodeAt()}return"Unidentified"}_handleKeyDown(t){let n=this._getKeyCode(t),r=Pw(t),o=t.getModifierState("NumLock"),s=t.getModifierState("CapsLock");if((Jn()||Mo())&&(o=null),this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),n==="AltRight"&&t.timeStamp-this._altGrCtrlTime<50?r=A.XK_ISO_Level3_Shift:this._sendKeyEvent(A.XK_Control_L,"ControlLeft",!0,o,s)),n==="Unidentified"){r&&(this._sendKeyEvent(r,n,!0,o,s),this._sendKeyEvent(r,n,!1,o,s)),Pr(t);return}if(Jn()||Mo())switch(r){case A.XK_Super_L:r=A.XK_Alt_L;break;case A.XK_Super_R:r=A.XK_Super_L;break;case A.XK_Alt_L:r=A.XK_Mode_switch;break;case A.XK_Alt_R:r=A.XK_ISO_Level3_Shift;break}if(n in this._keyDownList&&(r=this._keyDownList[n]),(Jn()||Mo())&&t.metaKey&&n!=="MetaLeft"&&n!=="MetaRight"){this._sendKeyEvent(r,n,!0,o,s),this._sendKeyEvent(r,n,!1,o,s),Pr(t);return}if((Jn()||Mo())&&n==="CapsLock"){this._sendKeyEvent(A.XK_Caps_Lock,"CapsLock",!0,o,s),this._sendKeyEvent(A.XK_Caps_Lock,"CapsLock",!1,o,s),Pr(t);return}let i=[A.XK_Zenkaku_Hankaku,A.XK_Eisu_toggle,A.XK_Katakana,A.XK_Hiragana,A.XK_Romaji];if(Lo()&&i.includes(r)){this._sendKeyEvent(r,n,!0,o,s),this._sendKeyEvent(r,n,!1,o,s),Pr(t);return}if(Pr(t),n==="ControlLeft"&&Lo()&&!("ControlLeft"in this._keyDownList)){this._altGrArmed=!0,this._altGrTimeout=setTimeout(this._interruptAltGrSequence.bind(this),100),this._altGrCtrlTime=t.timeStamp;return}this._sendKeyEvent(r,n,!0,o,s)}_handleKeyUp(t){Pr(t);let n=this._getKeyCode(t);if(this._interruptAltGrSequence(),(Jn()||Mo())&&n==="CapsLock"){this._sendKeyEvent(A.XK_Caps_Lock,"CapsLock",!0),this._sendKeyEvent(A.XK_Caps_Lock,"CapsLock",!1);return}this._sendKeyEvent(this._keyDownList[n],n,!1),Lo()&&(n==="ShiftLeft"||n==="ShiftRight")&&("ShiftRight"in this._keyDownList&&this._sendKeyEvent(this._keyDownList.ShiftRight,"ShiftRight",!1),"ShiftLeft"in this._keyDownList&&this._sendKeyEvent(this._keyDownList.ShiftLeft,"ShiftLeft",!1))}_interruptAltGrSequence(){this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),this._sendKeyEvent(A.XK_Control_L,"ControlLeft",!0))}_allKeysUp(){de(">> Keyboard.allKeysUp"),this._interruptAltGrSequence();for(let t in this._keyDownList)this._sendKeyEvent(this._keyDownList[t],t,!1);de("<< Keyboard.allKeysUp")}grab(){this._target.addEventListener("keydown",this._eventHandlers.keydown),this._target.addEventListener("keyup",this._eventHandlers.keyup),window.addEventListener("blur",this._eventHandlers.blur)}ungrab(){this._target.removeEventListener("keydown",this._eventHandlers.keydown),this._target.removeEventListener("keyup",this._eventHandlers.keyup),window.removeEventListener("blur",this._eventHandlers.blur),this._allKeysUp()}};var Zi=class{constructor(){this._target=null,this._state=127,this._tracked=[],this._ignored=[],this._waitingRelease=!1,this._releaseStart=0,this._longpressTimeoutId=null,this._twoTouchTimeoutId=null,this._boundEventHandler=this._eventHandler.bind(this)}attach(t){this.detach(),this._target=t,this._target.addEventListener("touchstart",this._boundEventHandler),this._target.addEventListener("touchmove",this._boundEventHandler),this._target.addEventListener("touchend",this._boundEventHandler),this._target.addEventListener("touchcancel",this._boundEventHandler)}detach(){this._target&&(this._stopLongpressTimeout(),this._stopTwoTouchTimeout(),this._target.removeEventListener("touchstart",this._boundEventHandler),this._target.removeEventListener("touchmove",this._boundEventHandler),this._target.removeEventListener("touchend",this._boundEventHandler),this._target.removeEventListener("touchcancel",this._boundEventHandler),this._target=null)}_eventHandler(t){let n;switch(t.stopPropagation(),t.preventDefault(),t.type){case"touchstart":n=this._touchStart;break;case"touchmove":n=this._touchMove;break;case"touchend":case"touchcancel":n=this._touchEnd;break}for(let r=0;r<t.changedTouches.length;r++){let o=t.changedTouches[r];n.call(this,o.identifier,o.clientX,o.clientY)}}_touchStart(t,n,r){if(this._hasDetectedGesture()||this._state===0){this._ignored.push(t);return}if(this._tracked.length>0&&Date.now()-this._tracked[0].started>250){this._state=0,this._ignored.push(t);return}if(this._waitingRelease){this._state=0,this._ignored.push(t);return}switch(this._tracked.push({id:t,started:Date.now(),active:!0,firstX:n,firstY:r,lastX:n,lastY:r,angle:0}),this._tracked.length){case 1:this._startLongpressTimeout();break;case 2:this._state&=-26,this._stopLongpressTimeout();break;case 3:this._state&=-99;break;default:this._state=0}}_touchMove(t,n,r){let o=this._tracked.find(a=>a.id===t);if(o===void 0)return;o.lastX=n,o.lastY=r;let s=n-o.firstX,i=r-o.firstY;if((o.firstX!==o.lastX||o.firstY!==o.lastY)&&(o.angle=Math.atan2(i,s)*180/Math.PI),!this._hasDetectedGesture()){if(Math.hypot(s,i)<50)return;if(this._state&=-24,this._stopLongpressTimeout(),this._tracked.length!==1&&(this._state&=-9),this._tracked.length!==2&&(this._state&=-97),this._tracked.length===2){let a=this._tracked.find(c=>c.id!==t);if(Math.hypot(a.firstX-a.lastX,a.firstY-a.lastY)>50){let c=Math.abs(o.angle-a.angle);c=Math.abs((c+180)%360-180),c>90?this._state&=-33:this._state&=-65,this._isTwoTouchTimeoutRunning()&&this._stopTwoTouchTimeout()}else this._isTwoTouchTimeoutRunning()||this._startTwoTouchTimeout()}if(!this._hasDetectedGesture())return;this._pushEvent("gesturestart")}this._pushEvent("gesturemove")}_touchEnd(t,n,r){if(this._ignored.indexOf(t)!==-1){this._ignored.splice(this._ignored.indexOf(t),1),this._ignored.length===0&&this._tracked.length===0&&(this._state=127,this._waitingRelease=!1);return}if(!this._hasDetectedGesture()&&this._isTwoTouchTimeoutRunning()&&(this._stopTwoTouchTimeout(),this._state=0),!this._hasDetectedGesture()&&(this._state&=-105,this._state&=-17,this._stopLongpressTimeout(),!this._waitingRelease))switch(this._releaseStart=Date.now(),this._waitingRelease=!0,this._tracked.length){case 1:this._state&=-7;break;case 2:this._state&=-6;break}if(this._waitingRelease){Date.now()-this._releaseStart>250&&(this._state=0),this._tracked.some(s=>Date.now()-s.started>1e3)&&(this._state=0);let o=this._tracked.find(s=>s.id===t);if(o.active=!1,this._hasDetectedGesture())this._pushEvent("gesturestart");else if(this._state!==0)return}this._hasDetectedGesture()&&this._pushEvent("gestureend");for(let o=0;o<this._tracked.length;o++)this._tracked[o].active&&this._ignored.push(this._tracked[o].id);this._tracked=[],this._state=0,this._ignored.indexOf(t)!==-1&&this._ignored.splice(this._ignored.indexOf(t),1),this._ignored.length===0&&(this._state=127,this._waitingRelease=!1)}_hasDetectedGesture(){return!(this._state===0||this._state&this._state-1||this._state&7&&this._tracked.some(t=>t.active))}_startLongpressTimeout(){this._stopLongpressTimeout(),this._longpressTimeoutId=setTimeout(()=>this._longpressTimeout(),1e3)}_stopLongpressTimeout(){clearTimeout(this._longpressTimeoutId),this._longpressTimeoutId=null}_longpressTimeout(){if(this._hasDetectedGesture())throw new Error("A longpress gesture failed, conflict with a different gesture");this._state=16,this._pushEvent("gesturestart")}_startTwoTouchTimeout(){this._stopTwoTouchTimeout(),this._twoTouchTimeoutId=setTimeout(()=>this._twoTouchTimeout(),50)}_stopTwoTouchTimeout(){clearTimeout(this._twoTouchTimeoutId),this._twoTouchTimeoutId=null}_isTwoTouchTimeoutRunning(){return this._twoTouchTimeoutId!==null}_twoTouchTimeout(){if(this._tracked.length===0)throw new Error("A pinch or two drag gesture failed, no tracked touches");let t=this._getAverageMovement(),n=Math.abs(t.x),r=Math.abs(t.y),o=this._getAverageDistance(),s=Math.abs(Math.hypot(o.first.x,o.first.y)-Math.hypot(o.last.x,o.last.y));r<s&&n<s?this._state=64:this._state=32,this._pushEvent("gesturestart"),this._pushEvent("gesturemove")}_pushEvent(t){let n={type:this._stateToGesture(this._state)},r=this._getPosition(),o=r.last;switch(t==="gesturestart"&&(o=r.first),this._state){case 32:case 64:o=r.first;break}if(n.clientX=o.x,n.clientY=o.y,this._state===64){let i=this._getAverageDistance();t==="gesturestart"?(n.magnitudeX=i.first.x,n.magnitudeY=i.first.y):(n.magnitudeX=i.last.x,n.magnitudeY=i.last.y)}else if(this._state===32)if(t==="gesturestart")n.magnitudeX=0,n.magnitudeY=0;else{let i=this._getAverageMovement();n.magnitudeX=i.x,n.magnitudeY=i.y}let s=new CustomEvent(t,{detail:n});this._target.dispatchEvent(s)}_stateToGesture(t){switch(t){case 1:return"onetap";case 2:return"twotap";case 4:return"threetap";case 8:return"drag";case 16:return"longpress";case 32:return"twodrag";case 64:return"pinch"}throw new Error("Unknown gesture state: "+t)}_getPosition(){if(this._tracked.length===0)throw new Error("Failed to get gesture position, no tracked touches");let t=this._tracked.length,n=0,r=0,o=0,s=0;for(let i=0;i<this._tracked.length;i++)n+=this._tracked[i].firstX,r+=this._tracked[i].firstY,o+=this._tracked[i].lastX,s+=this._tracked[i].lastY;return{first:{x:n/t,y:r/t},last:{x:o/t,y:s/t}}}_getAverageMovement(){if(this._tracked.length===0)throw new Error("Failed to get gesture movement, no tracked touches");let t,n;t=n=0;let r=this._tracked.length;for(let o=0;o<this._tracked.length;o++)t+=this._tracked[o].lastX-this._tracked[o].firstX,n+=this._tracked[o].lastY-this._tracked[o].firstY;return{x:t/r,y:n/r}}_getAverageDistance(){if(this._tracked.length===0)throw new Error("Failed to get gesture distance, no tracked touches");let t=this._tracked[0],n=this._tracked[this._tracked.length-1],r=Math.abs(n.firstX-t.firstX),o=Math.abs(n.firstY-t.firstY),s=Math.abs(n.lastX-t.lastX),i=Math.abs(n.lastY-t.lastY);return{first:{x:r,y:o},last:{x:s,y:i}}}};var Wi=!uv||Lf,ji=class{constructor(){this._target=null,this._canvas=document.createElement("canvas"),Wi&&(this._canvas.style.position="fixed",this._canvas.style.zIndex="65535",this._canvas.style.pointerEvents="none",this._canvas.style.userSelect="none",this._canvas.style.WebkitUserSelect="none",this._canvas.style.visibility="hidden"),this._position={x:0,y:0},this._hotSpot={x:0,y:0},this._eventHandlers={mouseover:this._handleMouseOver.bind(this),mouseleave:this._handleMouseLeave.bind(this),mousemove:this._handleMouseMove.bind(this),mouseup:this._handleMouseUp.bind(this)}}attach(t){if(this._target&&this.detach(),this._target=t,Wi){document.body.appendChild(this._canvas);let n={capture:!0,passive:!0};this._target.addEventListener("mouseover",this._eventHandlers.mouseover,n),this._target.addEventListener("mouseleave",this._eventHandlers.mouseleave,n),this._target.addEventListener("mousemove",this._eventHandlers.mousemove,n),this._target.addEventListener("mouseup",this._eventHandlers.mouseup,n)}this.clear()}detach(){if(this._target){if(Wi){let t={capture:!0,passive:!0};this._target.removeEventListener("mouseover",this._eventHandlers.mouseover,t),this._target.removeEventListener("mouseleave",this._eventHandlers.mouseleave,t),this._target.removeEventListener("mousemove",this._eventHandlers.mousemove,t),this._target.removeEventListener("mouseup",this._eventHandlers.mouseup,t),document.contains(this._canvas)&&document.body.removeChild(this._canvas)}this._target=null}}change(t,n,r,o,s){if(o===0||s===0){this.clear();return}this._position.x=this._position.x+this._hotSpot.x-n,this._position.y=this._position.y+this._hotSpot.y-r,this._hotSpot.x=n,this._hotSpot.y=r;let i=this._canvas.getContext("2d");this._canvas.width=o,this._canvas.height=s;let a=new ImageData(new Uint8ClampedArray(t),o,s);if(i.clearRect(0,0,o,s),i.putImageData(a,0,0),Wi)this._updatePosition();else{let u=this._canvas.toDataURL();this._target.style.cursor="url("+u+")"+n+" "+r+", default"}}clear(){this._target.style.cursor="none",this._canvas.width=0,this._canvas.height=0,this._position.x=this._position.x+this._hotSpot.x,this._position.y=this._position.y+this._hotSpot.y,this._hotSpot.x=0,this._hotSpot.y=0}move(t,n){if(!Wi)return;window.visualViewport?(this._position.x=t+window.visualViewport.offsetLeft,this._position.y=n+window.visualViewport.offsetTop):(this._position.x=t,this._position.y=n),this._updatePosition();let r=document.elementFromPoint(t,n);this._updateVisibility(r)}_handleMouseOver(t){this._handleMouseMove(t)}_handleMouseLeave(t){this._updateVisibility(t.relatedTarget)}_handleMouseMove(t){this._updateVisibility(t.target),this._position.x=t.clientX-this._hotSpot.x,this._position.y=t.clientY-this._hotSpot.y,this._updatePosition()}_handleMouseUp(t){let n=document.elementFromPoint(t.clientX,t.clientY);this._updateVisibility(n),this._captureIsActive()&&window.setTimeout(()=>{this._target&&(n=document.elementFromPoint(t.clientX,t.clientY),this._updateVisibility(n))},0)}_showCursor(){this._canvas.style.visibility==="hidden"&&(this._canvas.style.visibility="")}_hideCursor(){this._canvas.style.visibility!=="hidden"&&(this._canvas.style.visibility="hidden")}_shouldShowCursor(t){return t?t===this._target?!0:!(!this._target.contains(t)||window.getComputedStyle(t).cursor!=="none"):!1}_updateVisibility(t){this._captureIsActive()&&(t=document.captureElement),this._shouldShowCursor(t)?this._showCursor():this._hideCursor()}_updatePosition(){this._canvas.style.left=this._position.x+"px",this._canvas.style.top=this._position.y+"px"}_captureIsActive(){return document.captureElement&&document.documentElement.contains(document.captureElement)}};var hh=40*1024*1024,_c={CONNECTING:"connecting",OPEN:"open",CLOSING:"closing",CLOSED:"closed"},vc={CONNECTING:[WebSocket.CONNECTING,_c.CONNECTING],OPEN:[WebSocket.OPEN,_c.OPEN],CLOSING:[WebSocket.CLOSING,_c.CLOSING],CLOSED:[WebSocket.CLOSED,_c.CLOSED]},Ow=["send","close","binaryType","onerror","onmessage","onopen","protocol","readyState"],Qi=class{constructor(){this._websocket=null,this._rQi=0,this._rQlen=0,this._rQbufferSize=1024*1024*4,this._rQ=null,this._sQbufferSize=1024*10,this._sQlen=0,this._sQ=null,this._eventHandlers={message:()=>{},open:()=>{},close:()=>{},error:()=>{}}}get readyState(){let t;return this._websocket===null?"unused":(t=this._websocket.readyState,vc.CONNECTING.includes(t)?"connecting":vc.OPEN.includes(t)?"open":vc.CLOSING.includes(t)?"closing":vc.CLOSED.includes(t)?"closed":"unknown")}rQpeek8(){return this._rQ[this._rQi]}rQskipBytes(t){this._rQi+=t}rQshift8(){return this._rQshift(1)}rQshift16(){return this._rQshift(2)}rQshift32(){return this._rQshift(4)}_rQshift(t){let n=0;for(let r=t-1;r>=0;r--)n+=this._rQ[this._rQi++]<<r*8;return n>>>0}rQlen(){return this._rQlen-this._rQi}rQshiftStr(t){let n="";for(let r=0;r<t;r+=4096){let o=this.rQshiftBytes(Math.min(4096,t-r),!1);n+=String.fromCharCode.apply(null,o)}return n}rQshiftBytes(t,n=!0){return this._rQi+=t,n?this._rQ.slice(this._rQi-t,this._rQi):this._rQ.subarray(this._rQi-t,this._rQi)}rQshiftTo(t,n){t.set(new Uint8Array(this._rQ.buffer,this._rQi,n)),this._rQi+=n}rQpeekBytes(t,n=!0){return n?this._rQ.slice(this._rQi,this._rQi+t):this._rQ.subarray(this._rQi,this._rQi+t)}rQwait(t,n,r){if(this._rQlen-this._rQi<n){if(r){if(this._rQi<r)throw new Error("rQwait cannot backup "+r+" bytes");this._rQi-=r}return!0}return!1}sQpush8(t){this._sQensureSpace(1),this._sQ[this._sQlen++]=t}sQpush16(t){this._sQensureSpace(2),this._sQ[this._sQlen++]=t>>8&255,this._sQ[this._sQlen++]=t>>0&255}sQpush32(t){this._sQensureSpace(4),this._sQ[this._sQlen++]=t>>24&255,this._sQ[this._sQlen++]=t>>16&255,this._sQ[this._sQlen++]=t>>8&255,this._sQ[this._sQlen++]=t>>0&255}sQpushString(t){let n=t.split("").map(r=>r.charCodeAt(0));this.sQpushBytes(new Uint8Array(n))}sQpushBytes(t){for(let n=0;n<t.length;){this._sQensureSpace(1);let r=this._sQbufferSize-this._sQlen;r>t.length-n&&(r=t.length-n),this._sQ.set(t.subarray(n,n+r),this._sQlen),this._sQlen+=r,n+=r}}flush(){this._sQlen>0&&this.readyState==="open"&&(this._websocket.send(new Uint8Array(this._sQ.buffer,0,this._sQlen)),this._sQlen=0)}_sQensureSpace(t){this._sQbufferSize-this._sQlen<t&&this.flush()}off(t){this._eventHandlers[t]=()=>{}}on(t,n){this._eventHandlers[t]=n}_allocateBuffers(){this._rQ=new Uint8Array(this._rQbufferSize),this._sQ=new Uint8Array(this._sQbufferSize)}init(){this._allocateBuffers(),this._rQi=0,this._websocket=null}open(t,n){this.attach(new WebSocket(t,n))}attach(t){this.init();let n=[...Object.keys(t),...Object.getOwnPropertyNames(Object.getPrototypeOf(t))];for(let r=0;r<Ow.length;r++){let o=Ow[r];if(n.indexOf(o)<0)throw new Error("Raw channel missing property: "+o)}this._websocket=t,this._websocket.binaryType="arraybuffer",this._websocket.onmessage=this._recvMessage.bind(this),this._websocket.onopen=()=>{de(">> WebSock.onopen"),this._websocket.protocol&&Qe("Server choose sub-protocol: "+this._websocket.protocol),this._eventHandlers.open(),de("<< WebSock.onopen")},this._websocket.onclose=r=>{de(">> WebSock.onclose"),this._eventHandlers.close(r),de("<< WebSock.onclose")},this._websocket.onerror=r=>{de(">> WebSock.onerror: "+r),this._eventHandlers.error(r),de("<< WebSock.onerror: "+r)}}close(){this._websocket&&((this.readyState==="connecting"||this.readyState==="open")&&(Qe("Closing WebSocket connection"),this._websocket.close()),this._websocket.onmessage=()=>{})}_expandCompactRQ(t){let n=(this._rQlen-this._rQi+t)*8,r=this._rQbufferSize<n;if(r&&(this._rQbufferSize=Math.max(this._rQbufferSize*2,n)),this._rQbufferSize>hh&&(this._rQbufferSize=hh,this._rQbufferSize-(this._rQlen-this._rQi)<t))throw new Error("Receive queue buffer exceeded "+hh+" bytes, and the new message could not fit");if(r){let o=this._rQ.buffer;this._rQ=new Uint8Array(this._rQbufferSize),this._rQ.set(new Uint8Array(o,this._rQi,this._rQlen-this._rQi))}else this._rQ.copyWithin(0,this._rQi,this._rQlen);this._rQlen=this._rQlen-this._rQi,this._rQi=0}_recvMessage(t){this._rQlen==this._rQi&&(this._rQlen=0,this._rQi=0);let n=new Uint8Array(t.data);n.length>this._rQbufferSize-this._rQlen&&this._expandCompactRQ(n.length),this._rQ.set(n,this._rQlen),this._rQlen+=n.length,this._rQlen-this._rQi>0?this._eventHandlers.message():de("Ignoring empty message")}};var Lw={Again:57349,AltLeft:56,AltRight:57400,ArrowDown:57424,ArrowLeft:57419,ArrowRight:57421,ArrowUp:57416,AudioVolumeDown:57390,AudioVolumeMute:57376,AudioVolumeUp:57392,Backquote:41,Backslash:43,Backspace:14,BracketLeft:26,BracketRight:27,BrowserBack:57450,BrowserFavorites:57446,BrowserForward:57449,BrowserHome:57394,BrowserRefresh:57447,BrowserSearch:57445,BrowserStop:57448,CapsLock:58,Comma:51,ContextMenu:57437,ControlLeft:29,ControlRight:57373,Convert:121,Copy:57464,Cut:57404,Delete:57427,Digit0:11,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Eject:57469,End:57423,Enter:28,Equal:13,Escape:1,F1:59,F10:68,F11:87,F12:88,F13:93,F14:94,F15:95,F16:85,F17:57347,F18:57463,F19:57348,F2:60,F20:90,F21:116,F22:57465,F23:109,F24:111,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,Find:57409,Help:57461,Hiragana:119,Home:57415,Insert:57426,IntlBackslash:86,IntlRo:115,IntlYen:125,KanaMode:112,Katakana:120,KeyA:30,KeyB:48,KeyC:46,KeyD:32,KeyE:18,KeyF:33,KeyG:34,KeyH:35,KeyI:23,KeyJ:36,KeyK:37,KeyL:38,KeyM:50,KeyN:49,KeyO:24,KeyP:25,KeyQ:16,KeyR:19,KeyS:31,KeyT:20,KeyU:22,KeyV:47,KeyW:17,KeyX:45,KeyY:21,KeyZ:44,Lang1:114,Lang2:113,Lang3:120,Lang4:119,Lang5:118,LaunchApp1:57451,LaunchApp2:57377,LaunchMail:57452,MediaPlayPause:57378,MediaSelect:57453,MediaStop:57380,MediaTrackNext:57369,MediaTrackPrevious:57360,MetaLeft:57435,MetaRight:57436,Minus:12,NonConvert:123,NumLock:69,Numpad0:82,Numpad1:79,Numpad2:80,Numpad3:81,Numpad4:75,Numpad5:76,Numpad6:77,Numpad7:71,Numpad8:72,Numpad9:73,NumpadAdd:78,NumpadComma:126,NumpadDecimal:83,NumpadDivide:57397,NumpadEnter:57372,NumpadEqual:89,NumpadMultiply:55,NumpadParenLeft:57462,NumpadParenRight:57467,NumpadSubtract:74,Open:100,PageDown:57425,PageUp:57417,Paste:101,Pause:57414,Period:52,Power:57438,PrintScreen:84,Props:57350,Quote:40,ScrollLock:70,Semicolon:39,ShiftLeft:42,ShiftRight:54,Slash:53,Sleep:57439,Space:57,Suspend:57381,Tab:15,Undo:57351,WakeUp:57443};var ge={encodingRaw:0,encodingCopyRect:1,encodingRRE:2,encodingHextile:5,encodingZlib:6,encodingTight:7,encodingZRLE:16,encodingTightPNG:-260,encodingJPEG:21,encodingH264:50,pseudoEncodingQualityLevel9:-23,pseudoEncodingQualityLevel0:-32,pseudoEncodingDesktopSize:-223,pseudoEncodingLastRect:-224,pseudoEncodingCursor:-239,pseudoEncodingQEMUExtendedKeyEvent:-258,pseudoEncodingQEMULedEvent:-261,pseudoEncodingDesktopName:-307,pseudoEncodingExtendedDesktopSize:-308,pseudoEncodingXvp:-309,pseudoEncodingFence:-312,pseudoEncodingContinuousUpdates:-313,pseudoEncodingExtendedMouseButtons:-316,pseudoEncodingCompressLevel9:-247,pseudoEncodingCompressLevel0:-256,pseudoEncodingVMwareCursor:1464686180,pseudoEncodingExtendedClipboard:3231835598};var wc=class e{constructor(){this._key=null}get algorithm(){return{name:"AES-ECB"}}static async importKey(t,n,r,o){let s=new e;return await s._importKey(t,r,o),s}async _importKey(t,n,r){this._key=await window.crypto.subtle.importKey("raw",t,{name:"AES-CBC"},n,r)}async encrypt(t,n){let r=new Uint8Array(n);if(r.length%16!==0||this._key===null)return null;let o=r.length/16;for(let s=0;s<o;s++){let i=new Uint8Array(await window.crypto.subtle.encrypt({name:"AES-CBC",iv:new Uint8Array(16)},this._key,r.slice(s*16,s*16+16))).slice(0,16);r.set(i,s*16)}return r}},kc=class e{constructor(){this._rawKey=null,this._ctrKey=null,this._cbcKey=null,this._zeroBlock=new Uint8Array(16),this._prefixBlock0=this._zeroBlock,this._prefixBlock1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]),this._prefixBlock2=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2])}get algorithm(){return{name:"AES-EAX"}}async _encryptBlock(t){let n=await window.crypto.subtle.encrypt({name:"AES-CBC",iv:this._zeroBlock},this._cbcKey,t);return new Uint8Array(n).slice(0,16)}async _initCMAC(){let t=await this._encryptBlock(this._zeroBlock),n=new Uint8Array(16),r=t[0]>>>6;for(let s=0;s<15;s++)n[s]=t[s+1]>>6|t[s]<<2,t[s]=t[s+1]>>7|t[s]<<1;let o=[0,135,14,137];n[14]^=r>>>1,n[15]=t[15]<<2^o[r],t[15]=t[15]<<1^o[r>>1],this._k1=t,this._k2=n}async _encryptCTR(t,n){let r=await window.crypto.subtle.encrypt({name:"AES-CTR",counter:n,length:128},this._ctrKey,t);return new Uint8Array(r)}async _decryptCTR(t,n){let r=await window.crypto.subtle.decrypt({name:"AES-CTR",counter:n,length:128},this._ctrKey,t);return new Uint8Array(r)}async _computeCMAC(t,n){if(n.length!==16)return null;let r=Math.floor(t.length/16),o=Math.ceil(t.length/16),s=t.length-r*16,i=new Uint8Array((o+1)*16);if(i.set(n),i.set(t,16),s===0)for(let c=0;c<16;c++)i[r*16+c]^=this._k1[c];else{i[(r+1)*16+s]=128;for(let c=0;c<16;c++)i[(r+1)*16+c]^=this._k2[c]}let a=await window.crypto.subtle.encrypt({name:"AES-CBC",iv:this._zeroBlock},this._cbcKey,i);return a=new Uint8Array(a),a.slice(a.length-32,a.length-16)}static async importKey(t,n,r,o){let s=new e;return await s._importKey(t),s}async _importKey(t){this._rawKey=t,this._ctrKey=await window.crypto.subtle.importKey("raw",t,{name:"AES-CTR"},!1,["encrypt","decrypt"]),this._cbcKey=await window.crypto.subtle.importKey("raw",t,{name:"AES-CBC"},!1,["encrypt"]),await this._initCMAC()}async encrypt(t,n){let r=t.additionalData,o=t.iv,s=await this._computeCMAC(o,this._prefixBlock0),i=await this._encryptCTR(n,s),a=await this._computeCMAC(r,this._prefixBlock1),u=await this._computeCMAC(i,this._prefixBlock2);for(let d=0;d<16;d++)u[d]^=s[d]^a[d];let c=new Uint8Array(16+i.length);return c.set(i),c.set(u,i.length),c}async decrypt(t,n){let r=n.slice(0,n.length-16),o=t.additionalData,s=t.iv,i=n.slice(n.length-16),a=await this._computeCMAC(s,this._prefixBlock0),u=await this._computeCMAC(o,this._prefixBlock1),c=await this._computeCMAC(r,this._prefixBlock2);for(let p=0;p<16;p++)c[p]^=a[p]^u[p];if(c.length!==i.length)return null;for(let p=0;p<i.length;p++)if(c[p]!==i[p])return null;return await this._decryptCTR(r,a)}};var Mw=[13,16,10,23,0,4,2,27,14,5,20,9,22,18,11,3,25,7,15,6,26,19,12,1,40,51,30,36,46,54,29,39,50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31],o$=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],E=0,M,D,B,F,z,U;M=65536;D=1<<24;B=M|D;F=4;z=1024;U=F|z;var Dw=[B|z,E|E,M|E,B|U,B|F,M|U,E|F,M|E,E|z,B|z,B|U,E|z,D|U,B|F,D|E,E|F,E|U,D|z,D|z,M|z,M|z,B|E,B|E,D|U,M|F,D|F,D|F,M|F,E|E,E|U,M|U,D|E,M|E,B|U,E|F,B|E,B|z,D|E,D|E,E|z,B|F,M|E,M|z,D|F,E|z,E|F,D|U,M|U,B|U,M|F,B|E,D|U,D|F,E|U,M|U,B|z,E|U,D|z,D|z,E|E,M|F,M|z,E|E,B|F];M=1<<20;D=1<<31;B=M|D;F=32;z=32768;U=F|z;var Fw=[B|U,D|z,E|z,M|U,M|E,E|F,B|F,D|U,D|F,B|U,B|z,D|E,D|z,M|E,E|F,B|F,M|z,M|F,D|U,E|E,D|E,E|z,M|U,B|E,M|F,D|F,E|E,M|z,E|U,B|z,B|E,E|U,E|E,M|U,B|F,M|E,D|U,B|E,B|z,E|z,B|E,D|z,E|F,B|U,M|U,E|F,E|z,D|E,E|U,B|z,M|E,D|F,M|F,D|U,D|F,M|F,M|z,E|E,D|z,E|U,D|E,B|F,B|U,M|z];M=1<<17;D=1<<27;B=M|D;F=8;z=512;U=F|z;var zw=[E|U,B|z,E|E,B|F,D|z,E|E,M|U,D|z,M|F,D|F,D|F,M|E,B|U,M|F,B|E,E|U,D|E,E|F,B|z,E|z,M|z,B|E,B|F,M|U,D|U,M|z,M|E,D|U,E|F,B|U,E|z,D|E,B|z,D|E,M|F,E|U,M|E,B|z,D|z,E|E,E|z,M|F,B|U,D|z,D|F,E|z,E|E,B|F,D|U,M|E,D|E,B|U,E|F,M|U,M|z,D|F,B|E,D|U,E|U,B|E,M|U,E|F,B|F,M|z];M=8192;D=1<<23;B=M|D;F=1;z=128;U=F|z;var Kw=[B|F,M|U,M|U,E|z,B|z,D|U,D|F,M|F,E|E,B|E,B|E,B|U,E|U,E|E,D|z,D|F,E|F,M|E,D|E,B|F,E|z,D|E,M|F,M|z,D|U,E|F,M|z,D|z,M|E,B|z,B|U,E|U,D|z,D|F,B|E,B|U,E|U,E|E,E|E,B|E,M|z,D|z,D|U,E|F,B|F,M|U,M|U,E|z,B|U,E|U,E|F,M|E,D|F,M|F,B|z,D|U,M|F,M|z,D|E,B|F,E|z,D|E,M|E,B|z];M=1<<25;D=1<<30;B=M|D;F=256;z=1<<19;U=F|z;var Xw=[E|F,M|U,M|z,B|F,E|z,E|F,D|E,M|z,D|U,E|z,M|F,D|U,B|F,B|z,E|U,D|E,M|E,D|z,D|z,E|E,D|F,B|U,B|U,M|F,B|z,D|F,E|E,B|E,M|U,M|E,B|E,E|U,E|z,B|F,E|F,M|E,D|E,M|z,B|F,D|U,M|F,D|E,B|z,M|U,D|U,E|F,M|E,B|z,B|U,E|U,B|E,B|U,M|z,E|E,D|z,B|E,E|U,M|F,D|F,E|z,E|E,D|z,M|U,D|F];M=1<<22;D=1<<29;B=M|D;F=16;z=16384;U=F|z;var Bw=[D|F,B|E,E|z,B|U,B|E,E|F,B|U,M|E,D|z,M|U,M|E,D|F,M|F,D|z,D|E,E|U,E|E,M|F,D|U,E|z,M|z,D|U,E|F,B|F,B|F,E|E,M|U,B|z,E|U,M|z,B|z,D|E,D|z,E|F,B|F,M|z,B|U,M|E,E|U,D|F,M|E,D|z,D|E,E|U,D|F,B|U,M|z,B|E,M|U,B|z,E|E,B|F,E|F,E|z,B|E,M|U,E|z,M|F,D|U,E|E,B|z,D|E,M|F,D|U];M=1<<21;D=1<<26;B=M|D;F=2;z=2048;U=F|z;var Uw=[M|E,B|F,D|U,E|E,E|z,D|U,M|U,B|z,B|U,M|E,E|E,D|F,E|F,D|E,B|F,E|U,D|z,M|U,M|F,D|z,D|F,B|E,B|z,M|F,B|E,E|z,E|U,B|U,M|z,E|F,D|E,M|z,D|E,M|z,M|E,D|U,D|U,B|F,B|F,E|F,M|F,D|E,D|z,M|E,B|z,E|U,M|U,B|z,E|U,D|F,B|U,B|E,M|z,E|E,E|F,B|U,E|E,M|U,B|E,E|z,D|F,D|z,E|z,M|F];M=1<<18;D=1<<28;B=M|D;F=64;z=4096;U=F|z;var Hw=[D|U,E|z,M|E,B|U,D|E,D|U,E|F,D|E,M|F,B|E,B|U,M|z,B|z,M|U,E|z,E|F,B|E,D|F,D|z,E|U,M|z,M|F,B|F,B|z,E|U,E|E,E|E,B|F,D|F,D|z,M|U,M|E,M|U,M|E,B|z,E|z,E|F,B|F,E|z,M|U,D|z,E|F,D|F,B|E,B|F,D|E,M|E,D|U,E|E,B|U,M|F,D|F,B|E,D|z,D|U,E|E,B|U,M|z,M|z,E|U,E|U,M|F,D|E,B|z],Sc=class{constructor(t){this.keys=[];let n=[],r=[],o=[];for(let s=0,i=56;s<56;++s,i-=8){i+=i<-5?65:i<-3?31:i<-1?63:i===27?35:0;let a=i&7;n[s]=(t[i>>>3]&1<<a)!==0?1:0}for(let s=0;s<16;++s){let i=s<<1,a=i+1;o[i]=o[a]=0;for(let u=28;u<59;u+=28)for(let c=u-28;c<u;++c){let d=c+o$[s];r[c]=d<u?n[d]:n[d-28]}for(let u=0;u<24;++u)r[Mw[u]]!==0&&(o[i]|=1<<23-u),r[Mw[u+24]]!==0&&(o[a]|=1<<23-u)}for(let s=0,i=0,a=0;s<16;++s){let u=o[i++],c=o[i++];this.keys[a]=(u&16515072)<<6,this.keys[a]|=(u&4032)<<10,this.keys[a]|=(c&16515072)>>>10,this.keys[a]|=(c&4032)>>>6,++a,this.keys[a]=(u&258048)<<12,this.keys[a]|=(u&63)<<16,this.keys[a]|=(c&258048)>>>4,this.keys[a]|=c&63,++a}}enc8(t){let n=t.slice(),r=0,o,s,i;o=n[r++]<<24|n[r++]<<16|n[r++]<<8|n[r++],s=n[r++]<<24|n[r++]<<16|n[r++]<<8|n[r++],i=(o>>>4^s)&252645135,s^=i,o^=i<<4,i=(o>>>16^s)&65535,s^=i,o^=i<<16,i=(s>>>2^o)&858993459,o^=i,s^=i<<2,i=(s>>>8^o)&16711935,o^=i,s^=i<<8,s=s<<1|s>>>31&1,i=(o^s)&2863311530,o^=i,s^=i,o=o<<1|o>>>31&1;for(let a=0,u=0;a<8;++a){i=s<<28|s>>>4,i^=this.keys[u++];let c=Uw[i&63];c|=Xw[i>>>8&63],c|=zw[i>>>16&63],c|=Dw[i>>>24&63],i=s^this.keys[u++],c|=Hw[i&63],c|=Bw[i>>>8&63],c|=Kw[i>>>16&63],c|=Fw[i>>>24&63],o^=c,i=o<<28|o>>>4,i^=this.keys[u++],c=Uw[i&63],c|=Xw[i>>>8&63],c|=zw[i>>>16&63],c|=Dw[i>>>24&63],i=o^this.keys[u++],c|=Hw[i&63],c|=Bw[i>>>8&63],c|=Kw[i>>>16&63],c|=Fw[i>>>24&63],s^=c}for(s=s<<31|s>>>1,i=(o^s)&2863311530,o^=i,s^=i,o=o<<31|o>>>1,i=(o>>>8^s)&16711935,s^=i,o^=i<<8,i=(o>>>2^s)&858993459,s^=i,o^=i<<2,i=(s>>>16^o)&65535,o^=i,s^=i<<16,i=(s>>>4^o)&252645135,o^=i,s^=i<<4,i=[s,o],r=0;r<8;r++)n[r]=(i[r>>>2]>>>8*(3-r%4))%256,n[r]<0&&(n[r]+=256);return n}},Ec=class e{constructor(){this._cipher=null}get algorithm(){return{name:"DES-ECB"}}static importKey(t,n,r,o){let s=new e;return s._importKey(t),s}_importKey(t,n,r){this._cipher=new Sc(t)}encrypt(t,n){let r=new Uint8Array(n);if(r.length%8!==0||this._cipher===null)return null;let o=r.length/8;for(let s=0;s<o;s++)r.set(this._cipher.enc8(r.slice(s*8,s*8+8)),s*8);return r}},Nc=class e{constructor(){this._cipher=null}get algorithm(){return{name:"DES-CBC"}}static importKey(t,n,r,o){let s=new e;return s._importKey(t),s}_importKey(t){this._cipher=new Sc(t)}encrypt(t,n){let r=new Uint8Array(n),o=new Uint8Array(t.iv);if(r.length%8!==0||this._cipher===null)return null;let s=r.length/8;for(let i=0;i<s;i++){for(let a=0;a<8;a++)o[a]^=n[i*8+a];o=this._cipher.enc8(o),r.set(o,i*8)}return r}};function Qo(e,t,n){let r=1n;for(e=e%n;t>0n;)(t&1n)===1n&&(r=r*e%n),t=t>>1n,e=e*e%n;return r}function Go(e,t=0){let n=e.toString(16);t===0&&(t=Math.ceil(n.length/2)),n=n.padStart(t*2,"0");let r=n.length/2,o=new Uint8Array(r);for(let s=0;s<r;s++)o[s]=parseInt(n.slice(s*2,s*2+2),16);return o}function Mt(e){let t="0x";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return BigInt(t)}var Ac=class e{constructor(){this._keyLength=0,this._keyBytes=0,this._n=null,this._e=null,this._d=null,this._nBigInt=null,this._eBigInt=null,this._dBigInt=null,this._extractable=!1}get algorithm(){return{name:"RSA-PKCS1-v1_5"}}_base64urlDecode(t){return t=t.replace(/-/g,"+").replace(/_/g,"/"),t=t.padEnd(Math.ceil(t.length/4)*4,"="),Oo.decode(t)}_padArray(t,n){let r=new Uint8Array(n);return r.set(t,n-t.length),r}static async generateKey(t,n,r){let o=new e;return await o._generateKey(t,n),{privateKey:o}}async _generateKey(t,n){this._keyLength=t.modulusLength,this._keyBytes=Math.ceil(this._keyLength/8);let r=await window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:t.modulusLength,publicExponent:t.publicExponent,hash:{name:"SHA-256"}},!0,["encrypt","decrypt"]),o=await window.crypto.subtle.exportKey("jwk",r.privateKey);this._n=this._padArray(this._base64urlDecode(o.n),this._keyBytes),this._nBigInt=Mt(this._n),this._e=this._padArray(this._base64urlDecode(o.e),this._keyBytes),this._eBigInt=Mt(this._e),this._d=this._padArray(this._base64urlDecode(o.d),this._keyBytes),this._dBigInt=Mt(this._d),this._extractable=n}static async importKey(t,n,r,o){if(o.length!==1||o[0]!=="encrypt")throw new Error("only support importing RSA public key");let s=new e;return await s._importKey(t,r),s}async _importKey(t,n){let r=t.n,o=t.e;if(r.length!==o.length)throw new Error("the sizes of modulus and public exponent do not match");this._keyBytes=r.length,this._keyLength=this._keyBytes*8,this._n=new Uint8Array(this._keyBytes),this._e=new Uint8Array(this._keyBytes),this._n.set(r),this._e.set(o),this._nBigInt=Mt(this._n),this._eBigInt=Mt(this._e),this._extractable=n}async encrypt(t,n){if(n.length>this._keyBytes-11)return null;let r=new Uint8Array(this._keyBytes-n.length-3);window.crypto.getRandomValues(r);for(let a=0;a<r.length;a++)r[a]=Math.floor(r[a]*254/255+1);let o=new Uint8Array(this._keyBytes);o[1]=2,o.set(r,2),o.set(n,r.length+3);let s=Mt(o),i=Qo(s,this._eBigInt,this._nBigInt);return Go(i,this._keyBytes)}async decrypt(t,n){if(n.length!==this._keyBytes)return null;let r=Mt(n),o=Qo(r,this._dBigInt,this._nBigInt),s=Go(o,this._keyBytes);if(s[0]!==0||s[1]!==2)return null;let i=2;for(;i<s.length&&s[i]!==0;i++);return i===s.length?null:s.slice(i+1,s.length)}async exportKey(){if(!this._extractable)throw new Error("key is not extractable");return{n:this._n,e:this._e,d:this._d}}};var mh=class{constructor(t){this._key=t}get algorithm(){return{name:"DH"}}exportKey(){return this._key}},Cc=class e{constructor(){this._g=null,this._p=null,this._gBigInt=null,this._pBigInt=null,this._privateKey=null}get algorithm(){return{name:"DH"}}static generateKey(t,n){let r=new e;return r._generateKey(t),{privateKey:r,publicKey:new mh(r._publicKey)}}_generateKey(t){let n=t.g,r=t.p;this._keyBytes=r.length,this._gBigInt=Mt(n),this._pBigInt=Mt(r),this._privateKey=window.crypto.getRandomValues(new Uint8Array(this._keyBytes)),this._privateKeyBigInt=Mt(this._privateKey),this._publicKey=Go(Qo(this._gBigInt,this._privateKeyBigInt,this._pBigInt),this._keyBytes)}deriveBits(t,n){let r=Math.ceil(n/8),o=new Uint8Array(t.public),s=r>this._keyBytes?r:this._keyBytes,i=Qo(Mt(o),this._privateKeyBigInt,this._pBigInt);return Go(i,s).slice(0,s)}};async function Vw(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return s$(a$(l$(i$(t),8*t.length)))}function s$(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function i$(e){let t=Array(e.length>>2);for(let n=0;n<t.length;n++)t[n]=0;for(let n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<n%32;return t}function a$(e){let t="";for(let n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}function l$(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;let n=1732584193,r=-271733879,o=-1732584194,s=271733878;for(let i=0;i<e.length;i+=16){let a=n,u=r,c=o,d=s;r=ft(r=ft(r=ft(r=ft(r=pt(r=pt(r=pt(r=pt(r=dt(r=dt(r=dt(r=dt(r=ut(r=ut(r=ut(r=ut(r,o=ut(o,s=ut(s,n=ut(n,r,o,s,e[i+0],7,-680876936),r,o,e[i+1],12,-389564586),n,r,e[i+2],17,606105819),s,n,e[i+3],22,-1044525330),o=ut(o,s=ut(s,n=ut(n,r,o,s,e[i+4],7,-176418897),r,o,e[i+5],12,1200080426),n,r,e[i+6],17,-1473231341),s,n,e[i+7],22,-45705983),o=ut(o,s=ut(s,n=ut(n,r,o,s,e[i+8],7,1770035416),r,o,e[i+9],12,-1958414417),n,r,e[i+10],17,-42063),s,n,e[i+11],22,-1990404162),o=ut(o,s=ut(s,n=ut(n,r,o,s,e[i+12],7,1804603682),r,o,e[i+13],12,-40341101),n,r,e[i+14],17,-1502002290),s,n,e[i+15],22,1236535329),o=dt(o,s=dt(s,n=dt(n,r,o,s,e[i+1],5,-165796510),r,o,e[i+6],9,-1069501632),n,r,e[i+11],14,643717713),s,n,e[i+0],20,-373897302),o=dt(o,s=dt(s,n=dt(n,r,o,s,e[i+5],5,-701558691),r,o,e[i+10],9,38016083),n,r,e[i+15],14,-660478335),s,n,e[i+4],20,-405537848),o=dt(o,s=dt(s,n=dt(n,r,o,s,e[i+9],5,568446438),r,o,e[i+14],9,-1019803690),n,r,e[i+3],14,-187363961),s,n,e[i+8],20,1163531501),o=dt(o,s=dt(s,n=dt(n,r,o,s,e[i+13],5,-1444681467),r,o,e[i+2],9,-51403784),n,r,e[i+7],14,1735328473),s,n,e[i+12],20,-1926607734),o=pt(o,s=pt(s,n=pt(n,r,o,s,e[i+5],4,-378558),r,o,e[i+8],11,-2022574463),n,r,e[i+11],16,1839030562),s,n,e[i+14],23,-35309556),o=pt(o,s=pt(s,n=pt(n,r,o,s,e[i+1],4,-1530992060),r,o,e[i+4],11,1272893353),n,r,e[i+7],16,-155497632),s,n,e[i+10],23,-1094730640),o=pt(o,s=pt(s,n=pt(n,r,o,s,e[i+13],4,681279174),r,o,e[i+0],11,-358537222),n,r,e[i+3],16,-722521979),s,n,e[i+6],23,76029189),o=pt(o,s=pt(s,n=pt(n,r,o,s,e[i+9],4,-640364487),r,o,e[i+12],11,-421815835),n,r,e[i+15],16,530742520),s,n,e[i+2],23,-995338651),o=ft(o,s=ft(s,n=ft(n,r,o,s,e[i+0],6,-198630844),r,o,e[i+7],10,1126891415),n,r,e[i+14],15,-1416354905),s,n,e[i+5],21,-57434055),o=ft(o,s=ft(s,n=ft(n,r,o,s,e[i+12],6,1700485571),r,o,e[i+3],10,-1894986606),n,r,e[i+10],15,-1051523),s,n,e[i+1],21,-2054922799),o=ft(o,s=ft(s,n=ft(n,r,o,s,e[i+8],6,1873313359),r,o,e[i+15],10,-30611744),n,r,e[i+6],15,-1560198380),s,n,e[i+13],21,1309151649),o=ft(o,s=ft(s,n=ft(n,r,o,s,e[i+4],6,-145523070),r,o,e[i+11],10,-1120210379),n,r,e[i+2],15,718787259),s,n,e[i+9],21,-343485551),n=rr(n,a),r=rr(r,u),o=rr(o,c),s=rr(s,d)}return Array(n,r,o,s)}function Tc(e,t,n,r,o,s){return rr(c$(rr(rr(t,e),rr(r,s)),o),n)}function ut(e,t,n,r,o,s,i){return Tc(t&n|~t&r,e,t,o,s,i)}function dt(e,t,n,r,o,s,i){return Tc(t&r|n&~r,e,t,o,s,i)}function pt(e,t,n,r,o,s,i){return Tc(t^n^r,e,t,o,s,i)}function ft(e,t,n,r,o,s,i){return Tc(n^(t|~r),e,t,o,s,i)}function rr(e,t){let n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function c$(e,t){return e<<t|e>>>32-t}var gh=class{constructor(){this._algorithms={"AES-ECB":wc,"AES-EAX":kc,"DES-ECB":Ec,"DES-CBC":Nc,"RSA-PKCS1-v1_5":Ac,DH:Cc,MD5:Vw}}encrypt(t,n,r){if(n.algorithm.name!==t.name)throw new Error("algorithm does not match");if(typeof n.encrypt!="function")throw new Error("key does not support encryption");return n.encrypt(t,r)}decrypt(t,n,r){if(n.algorithm.name!==t.name)throw new Error("algorithm does not match");if(typeof n.decrypt!="function")throw new Error("key does not support encryption");return n.decrypt(t,r)}importKey(t,n,r,o,s){if(t!=="raw")throw new Error("key format is not supported");let i=this._algorithms[r.name];if(typeof i>"u"||typeof i.importKey!="function")throw new Error("algorithm is not supported");return i.importKey(n,r,o,s)}generateKey(t,n,r){let o=this._algorithms[t.name];if(typeof o>"u"||typeof o.generateKey!="function")throw new Error("algorithm is not supported");return o.generateKey(t,n,r)}exportKey(t,n){if(t!=="raw")throw new Error("key format is not supported");if(typeof n.exportKey!="function")throw new Error("key does not support exportKey");return n.exportKey()}digest(t,n){let r=this._algorithms[t];if(typeof r!="function")throw new Error("algorithm is not supported");return r(n)}deriveBits(t,n,r){if(n.algorithm.name!==t.name)throw new Error("algorithm does not match");if(typeof n.deriveBits!="function")throw new Error("key does not support deriveBits");return n.deriveBits(t,r)}},Xe=new gh;var Rc=class{constructor(){this._cipher=null,this._counter=new Uint8Array(16)}async setKey(t){this._cipher=await Xe.importKey("raw",t,{name:"AES-EAX"},!1,["encrypt, decrypt"])}async makeMessage(t){let n=new Uint8Array([(t.length&65280)>>>8,t.length&255]),r=await Xe.encrypt({name:"AES-EAX",iv:this._counter,additionalData:n},this._cipher,t);for(let s=0;s<16&&this._counter[s]++===255;s++);let o=new Uint8Array(t.length+2+16);return o.set(n),o.set(r,2),o}async receiveMessage(t,n){let r=new Uint8Array([(t&65280)>>>8,t&255]),o=await Xe.decrypt({name:"AES-EAX",iv:this._counter,additionalData:r},this._cipher,n);for(let s=0;s<16&&this._counter[s]++===255;s++);return o}},Gi=class extends Or{constructor(t,n){super(),this._hasStarted=!1,this._checkSock=null,this._checkCredentials=null,this._approveServerResolve=null,this._sockReject=null,this._credentialsReject=null,this._approveServerReject=null,this._sock=t,this._getCredentials=n}_waitSockAsync(t){return new Promise((n,r)=>{let o=()=>!this._sock.rQwait("RA2",t);o()?n():(this._checkSock=()=>{o()&&(n(),this._checkSock=null,this._sockReject=null)},this._sockReject=r)})}_waitApproveKeyAsync(){return new Promise((t,n)=>{this._approveServerResolve=t,this._approveServerReject=n})}_waitCredentialsAsync(t){let n=()=>t===1&&this._getCredentials().username!==void 0&&this._getCredentials().password!==void 0?!0:t===2&&this._getCredentials().password!==void 0;return new Promise((r,o)=>{n()?r():(this._checkCredentials=()=>{n()&&(r(),this._checkCredentials=null,this._credentialsReject=null)},this._credentialsReject=o)})}checkInternalEvents(){this._checkSock!==null&&this._checkSock(),this._checkCredentials!==null&&this._checkCredentials()}approveServer(){this._approveServerResolve!==null&&(this._approveServerResolve(),this._approveServerResolve=null)}disconnect(){this._sockReject!==null&&(this._sockReject(new Error("disconnect normally")),this._sockReject=null),this._credentialsReject!==null&&(this._credentialsReject(new Error("disconnect normally")),this._credentialsReject=null),this._approveServerReject!==null&&(this._approveServerReject(new Error("disconnect normally")),this._approveServerReject=null)}async negotiateRA2neAuthAsync(){this._hasStarted=!0,await this._waitSockAsync(4);let t=this._sock.rQpeekBytes(4),n=this._sock.rQshift32();if(n<1024)throw new Error("RA2: server public key is too short: "+n);if(n>8192)throw new Error("RA2: server public key is too long: "+n);let r=Math.ceil(n/8);await this._waitSockAsync(r*2);let o=this._sock.rQshiftBytes(r),s=this._sock.rQshiftBytes(r),i=await Xe.importKey("raw",{n:o,e:s},{name:"RSA-PKCS1-v1_5"},!1,["encrypt"]),a=new Uint8Array(4+r*2);a.set(t),a.set(o,4),a.set(s,4+r);let u=this._waitApproveKeyAsync();this.dispatchEvent(new CustomEvent("serververification",{detail:{type:"RSA",publickey:a}})),await u;let c=2048,d=Math.ceil(c/8),p=(await Xe.generateKey({name:"RSA-PKCS1-v1_5",modulusLength:c,publicExponent:new Uint8Array([1,0,1])},!0,["encrypt"])).privateKey,f=await Xe.exportKey("raw",p),h=f.n,g=f.e,x=new Uint8Array(4+d*2);x[0]=(c&4278190080)>>>24,x[1]=(c&16711680)>>>16,x[2]=(c&65280)>>>8,x[3]=c&255,x.set(h,4),x.set(g,4+d),this._sock.sQpushBytes(x),this._sock.flush();let b=new Uint8Array(16);window.crypto.getRandomValues(b);let v=await Xe.encrypt({name:"RSA-PKCS1-v1_5"},i,b),w=new Uint8Array(2+r);if(w[0]=(r&65280)>>>8,w[1]=r&255,w.set(v,2),this._sock.sQpushBytes(w),this._sock.flush(),await this._waitSockAsync(2),this._sock.rQshift16()!==d)throw new Error("RA2: wrong encrypted message length");let C=this._sock.rQshiftBytes(d),y=await Xe.decrypt({name:"RSA-PKCS1-v1_5"},p,C);if(y===null||y.length!==16)throw new Error("RA2: corrupted server encrypted random");let T=new Uint8Array(32),N=new Uint8Array(32);T.set(y),T.set(b,16),N.set(b),N.set(y,16),T=await window.crypto.subtle.digest("SHA-1",T),T=new Uint8Array(T).slice(0,16),N=await window.crypto.subtle.digest("SHA-1",N),N=new Uint8Array(N).slice(0,16);let S=new Rc;await S.setKey(T);let $=new Rc;await $.setKey(N);let P=new Uint8Array(8+r*2+d*2),L=new Uint8Array(8+r*2+d*2);if(P.set(a),P.set(x,4+r*2),L.set(x),L.set(a,4+d*2),P=await window.crypto.subtle.digest("SHA-1",P),L=await window.crypto.subtle.digest("SHA-1",L),P=new Uint8Array(P),L=new Uint8Array(L),this._sock.sQpushBytes(await S.makeMessage(L)),this._sock.flush(),await this._waitSockAsync(38),this._sock.rQshift16()!==20)throw new Error("RA2: wrong server hash");let ne=await $.receiveMessage(20,this._sock.rQshiftBytes(36));if(ne===null)throw new Error("RA2: failed to authenticate the message");for(let G=0;G<20;G++)if(ne[G]!==P[G])throw new Error("RA2: wrong server hash");if(await this._waitSockAsync(19),this._sock.rQshift16()!==1)throw new Error("RA2: wrong subtype");let se=await $.receiveMessage(1,this._sock.rQshiftBytes(17));if(se===null)throw new Error("RA2: failed to authenticate the message");se=se[0];let _e=this._waitCredentialsAsync(se);if(se===1)(this._getCredentials().username===void 0||this._getCredentials().password===void 0)&&this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}}));else if(se===2)this._getCredentials().password===void 0&&this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["password"]}}));else throw new Error("RA2: wrong subtype");await _e;let ie;se===1?ie=Gt(this._getCredentials().username).slice(0,255):ie="";let Q=Gt(this._getCredentials().password).slice(0,255),j=new Uint8Array(ie.length+Q.length+2);j[0]=ie.length,j[ie.length+1]=Q.length;for(let G=0;G<ie.length;G++)j[G+1]=ie.charCodeAt(G);for(let G=0;G<Q.length;G++)j[ie.length+2+G]=Q.charCodeAt(G);this._sock.sQpushBytes(await S.makeMessage(j)),this._sock.flush()}get hasStarted(){return this._hasStarted}set hasStarted(t){this._hasStarted=t}};var Yi=class{constructor(){this._lines=0}decodeRect(t,n,r,o,s,i,a){if(r===0||o===0)return!0;this._lines===0&&(this._lines=o);let u=a==8?1:4,c=r*u;for(;this._lines>0;){if(s.rQwait("RAW",c))return!1;let d=n+(o-this._lines),p=s.rQshiftBytes(c,!1);if(a==8){let f=new Uint8Array(r*4);for(let h=0;h<r;h++)f[h*4+0]=(p[h]>>0&3)*255/3,f[h*4+1]=(p[h]>>2&3)*255/3,f[h*4+2]=(p[h]>>4&3)*255/3,f[h*4+3]=255;p=f}for(let f=0;f<r;f++)p[f*4+3]=255;i.blitImage(t,d,r,1,p,0),this._lines--}return!0}};var qi=class{decodeRect(t,n,r,o,s,i,a){if(s.rQwait("COPYRECT",4))return!1;let u=s.rQshift16(),c=s.rQshift16();return r===0||o===0||i.copyImage(u,c,t,n,r,o),!0}};var Ji=class{constructor(){this._subrects=0}decodeRect(t,n,r,o,s,i,a){if(this._subrects===0){if(s.rQwait("RRE",8))return!1;this._subrects=s.rQshift32();let u=s.rQshiftBytes(4);i.fillRect(t,n,r,o,u)}for(;this._subrects>0;){if(s.rQwait("RRE",12))return!1;let u=s.rQshiftBytes(4),c=s.rQshift16(),d=s.rQshift16(),p=s.rQshift16(),f=s.rQshift16();i.fillRect(t+c,n+d,p,f,u),this._subrects--}return!0}};var ea=class{constructor(){this._tiles=0,this._lastsubencoding=0,this._tileBuffer=new Uint8Array(256*4)}decodeRect(t,n,r,o,s,i,a){for(this._tiles===0&&(this._tilesX=Math.ceil(r/16),this._tilesY=Math.ceil(o/16),this._totalTiles=this._tilesX*this._tilesY,this._tiles=this._totalTiles);this._tiles>0;){let u=1;if(s.rQwait("HEXTILE",u))return!1;let c=s.rQpeek8();if(c>30)throw new Error("Illegal hextile subencoding (subencoding: "+c+")");let d=this._totalTiles-this._tiles,p=d%this._tilesX,f=Math.floor(d/this._tilesX),h=t+p*16,g=n+f*16,x=Math.min(16,t+r-h),b=Math.min(16,n+o-g);if(c&1)u+=x*b*4;else if(c&2&&(u+=4),c&4&&(u+=4),c&8){if(u++,s.rQwait("HEXTILE",u))return!1;let v=s.rQpeekBytes(u).at(-1);c&16?u+=v*6:u+=v*2}if(s.rQwait("HEXTILE",u))return!1;if(s.rQshift8(),c===0)this._lastsubencoding&1?de(" Ignoring blank after RAW"):i.fillRect(h,g,x,b,this._background);else if(c&1){let v=x*b,w=s.rQshiftBytes(v*4,!1);for(let C=0;C<v;C++)w[C*4+3]=255;i.blitImage(h,g,x,b,w,0)}else{if(c&2&&(this._background=new Uint8Array(s.rQshiftBytes(4))),c&4&&(this._foreground=new Uint8Array(s.rQshiftBytes(4))),this._startTile(h,g,x,b,this._background),c&8){let v=s.rQshift8();for(let w=0;w<v;w++){let C;c&16?C=s.rQshiftBytes(4):C=this._foreground;let y=s.rQshift8(),T=y>>4,N=y&15,S=s.rQshift8(),$=(S>>4)+1,P=(S&15)+1;this._subTile(T,N,$,P,C)}}this._finishTile(i)}this._lastsubencoding=c,this._tiles--}return!0}_startTile(t,n,r,o,s){this._tileX=t,this._tileY=n,this._tileW=r,this._tileH=o;let i=s[0],a=s[1],u=s[2],c=this._tileBuffer;for(let d=0;d<r*o*4;d+=4)c[d]=i,c[d+1]=a,c[d+2]=u,c[d+3]=255}_subTile(t,n,r,o,s){let i=s[0],a=s[1],u=s[2],c=t+r,d=n+o,p=this._tileBuffer,f=this._tileW;for(let h=n;h<d;h++)for(let g=t;g<c;g++){let x=(g+h*f)*4;p[x]=i,p[x+1]=a,p[x+2]=u,p[x+3]=255}}_finishTile(t){t.blitImage(this._tileX,this._tileY,this._tileW,this._tileH,this._tileBuffer,0)}};var ta=class{constructor(){this._zlib=new Yt,this._length=0}decodeRect(t,n,r,o,s,i,a){if(r===0||o===0)return!0;if(this._length===0){if(s.rQwait("ZLIB",4))return!1;this._length=s.rQshift32()}if(s.rQwait("ZLIB",this._length))return!1;let u=new Uint8Array(s.rQshiftBytes(this._length,!1));this._length=0,this._zlib.setInput(u),u=this._zlib.inflate(r*o*4),this._zlib.setInput(null);for(let c=0;c<r*o;c++)u[c*4+3]=255;return i.blitImage(t,n,r,o,u,0),!0}};var Ur=class{constructor(){this._ctl=null,this._filter=null,this._numColors=0,this._palette=new Uint8Array(1024),this._len=0,this._zlibs=[];for(let t=0;t<4;t++)this._zlibs[t]=new Yt}decodeRect(t,n,r,o,s,i,a){if(this._ctl===null){if(s.rQwait("TIGHT compression-control",1))return!1;this._ctl=s.rQshift8();for(let c=0;c<4;c++)this._ctl>>c&1&&(this._zlibs[c].reset(),Qe("Reset zlib stream "+c));this._ctl=this._ctl>>4}let u;if(this._ctl===8)u=this._fillRect(t,n,r,o,s,i,a);else if(this._ctl===9)u=this._jpegRect(t,n,r,o,s,i,a);else if(this._ctl===10)u=this._pngRect(t,n,r,o,s,i,a);else if((this._ctl&8)==0)u=this._basicRect(this._ctl,t,n,r,o,s,i,a);else throw new Error("Illegal tight compression received (ctl: "+this._ctl+")");return u&&(this._ctl=null),u}_fillRect(t,n,r,o,s,i,a){if(s.rQwait("TIGHT",3))return!1;let u=s.rQshiftBytes(3);return i.fillRect(t,n,r,o,u,!1),!0}_jpegRect(t,n,r,o,s,i,a){let u=this._readData(s);return u===null?!1:(i.imageRect(t,n,r,o,"image/jpeg",u),!0)}_pngRect(t,n,r,o,s,i,a){throw new Error("PNG received in standard Tight rect")}_basicRect(t,n,r,o,s,i,a,u){if(this._filter===null)if(t&4){if(i.rQwait("TIGHT",1))return!1;this._filter=i.rQshift8()}else this._filter=0;let c=t&3,d;switch(this._filter){case 0:d=this._copyFilter(c,n,r,o,s,i,a,u);break;case 1:d=this._paletteFilter(c,n,r,o,s,i,a,u);break;case 2:d=this._gradientFilter(c,n,r,o,s,i,a,u);break;default:throw new Error("Illegal tight filter received (ctl: "+this._filter+")")}return d&&(this._filter=null),d}_copyFilter(t,n,r,o,s,i,a,u){let c=o*s*3,d;if(c===0)return!0;if(c<12){if(i.rQwait("TIGHT",c))return!1;d=i.rQshiftBytes(c)}else{if(d=this._readData(i),d===null)return!1;this._zlibs[t].setInput(d),d=this._zlibs[t].inflate(c),this._zlibs[t].setInput(null)}let p=new Uint8Array(o*s*4);for(let f=0,h=0;f<o*s*4;f+=4,h+=3)p[f]=d[h],p[f+1]=d[h+1],p[f+2]=d[h+2],p[f+3]=255;return a.blitImage(n,r,o,s,p,0,!1),!0}_paletteFilter(t,n,r,o,s,i,a,u){if(this._numColors===0){if(i.rQwait("TIGHT palette",1))return!1;let h=i.rQpeek8()+1,g=h*3;if(i.rQwait("TIGHT palette",1+g))return!1;this._numColors=h,i.rQskipBytes(1),i.rQshiftTo(this._palette,g)}let c=this._numColors<=2?1:8,p=Math.floor((o*c+7)/8)*s,f;if(p===0)return!0;if(p<12){if(i.rQwait("TIGHT",p))return!1;f=i.rQshiftBytes(p)}else{if(f=this._readData(i),f===null)return!1;this._zlibs[t].setInput(f),f=this._zlibs[t].inflate(p),this._zlibs[t].setInput(null)}return this._numColors==2?this._monoRect(n,r,o,s,f,this._palette,a):this._paletteRect(n,r,o,s,f,this._palette,a),this._numColors=0,!0}_monoRect(t,n,r,o,s,i,a){let u=this._getScratchBuffer(r*o*4),c=Math.floor((r+7)/8),d=Math.floor(r/8);for(let p=0;p<o;p++){let f,h,g;for(g=0;g<d;g++)for(let x=7;x>=0;x--)f=(p*r+g*8+7-x)*4,h=(s[p*c+g]>>x&1)*3,u[f]=i[h],u[f+1]=i[h+1],u[f+2]=i[h+2],u[f+3]=255;for(let x=7;x>=8-r%8;x--)f=(p*r+g*8+7-x)*4,h=(s[p*c+g]>>x&1)*3,u[f]=i[h],u[f+1]=i[h+1],u[f+2]=i[h+2],u[f+3]=255}a.blitImage(t,n,r,o,u,0,!1)}_paletteRect(t,n,r,o,s,i,a){let u=this._getScratchBuffer(r*o*4),c=r*o*4;for(let d=0,p=0;d<c;d+=4,p++){let f=s[p]*3;u[d]=i[f],u[d+1]=i[f+1],u[d+2]=i[f+2],u[d+3]=255}a.blitImage(t,n,r,o,u,0,!1)}_gradientFilter(t,n,r,o,s,i,a,u){let c=o*s*3,d;if(c===0)return!0;if(c<12){if(i.rQwait("TIGHT",c))return!1;d=i.rQshiftBytes(c)}else{if(d=this._readData(i),d===null)return!1;this._zlibs[t].setInput(d),d=this._zlibs[t].inflate(c),this._zlibs[t].setInput(null)}let p=new Uint8Array(4*o*s),f=0,h=0,g=new Uint8Array(3);for(let w=0;w<o;w++){for(let C=0;C<3;C++){let y=g[C],T=d[h++]+y;p[f++]=T,g[C]=T}p[f++]=255}let x=0,b=new Uint8Array(3),v=new Uint8Array(3);for(let w=1;w<s;w++){g.fill(0),v.fill(0);for(let C=0;C<o;C++){for(let y=0;y<3;y++){b[y]=p[x++];let T=g[y]+b[y]-v[y];T<0?T=0:T>255&&(T=255);let N=d[h++]+T;p[f++]=N,v[y]=b[y],g[y]=N}p[f++]=255,x++}}return a.blitImage(n,r,o,s,p,0,!1),!0}_readData(t){if(this._len===0){if(t.rQwait("TIGHT",3))return null;let r;r=t.rQshift8(),this._len=r&127,r&128&&(r=t.rQshift8(),this._len|=(r&127)<<7,r&128&&(r=t.rQshift8(),this._len|=r<<14))}if(t.rQwait("TIGHT",this._len))return null;let n=t.rQshiftBytes(this._len,!1);return this._len=0,n}_getScratchBuffer(t){return(!this._scratchBuffer||this._scratchBuffer.length<t)&&(this._scratchBuffer=new Uint8Array(t)),this._scratchBuffer}};var na=class extends Ur{_pngRect(t,n,r,o,s,i,a){let u=this._readData(s);return u===null?!1:(i.imageRect(t,n,r,o,"image/png",u),!0)}_basicRect(t,n,r,o,s,i,a,u){throw new Error("BasicCompression received in TightPNG rect")}};var $c=64,Ic=64,ra=class{constructor(){this._length=0,this._inflator=new Yt,this._pixelBuffer=new Uint8Array($c*Ic*4),this._tileBuffer=new Uint8Array($c*Ic*4)}decodeRect(t,n,r,o,s,i,a){if(this._length===0){if(s.rQwait("ZLib data length",4))return!1;this._length=s.rQshift32()}if(s.rQwait("Zlib data",this._length))return!1;let u=s.rQshiftBytes(this._length,!1);this._inflator.setInput(u);for(let c=n;c<n+o;c+=Ic){let d=Math.min(Ic,n+o-c);for(let p=t;p<t+r;p+=$c){let f=Math.min($c,t+r-p),h=f*d,g=this._inflator.inflate(1)[0];if(g===0){let x=this._readPixels(h);i.blitImage(p,c,f,d,x,0,!1)}else if(g===1){let x=this._readPixels(1);i.fillRect(p,c,f,d,[x[0],x[1],x[2]])}else if(g>=2&&g<=16){let x=this._decodePaletteTile(g,h,f,d);i.blitImage(p,c,f,d,x,0,!1)}else if(g===128){let x=this._decodeRLETile(h);i.blitImage(p,c,f,d,x,0,!1)}else if(g>=130&&g<=255){let x=this._decodeRLEPaletteTile(g-128,h);i.blitImage(p,c,f,d,x,0,!1)}else throw new Error("Unknown subencoding: "+g)}}return this._length=0,!0}_getBitsPerPixelInPalette(t){if(t<=2)return 1;if(t<=4)return 2;if(t<=16)return 4}_readPixels(t){let n=this._pixelBuffer,r=this._inflator.inflate(3*t);for(let o=0,s=0;o<t*4;o+=4,s+=3)n[o]=r[s],n[o+1]=r[s+1],n[o+2]=r[s+2],n[o+3]=255;return n}_decodePaletteTile(t,n,r,o){let s=this._tileBuffer,i=this._readPixels(t),a=this._getBitsPerPixelInPalette(t),u=(1<<a)-1,c=0,d=this._inflator.inflate(1)[0];for(let p=0;p<o;p++){let f=8-a;for(let h=0;h<r;h++){f<0&&(f=8-a,d=this._inflator.inflate(1)[0]);let g=d>>f&u;s[c]=i[g*4],s[c+1]=i[g*4+1],s[c+2]=i[g*4+2],s[c+3]=i[g*4+3],c+=4,f-=a}f<8-a&&p<o-1&&(d=this._inflator.inflate(1)[0])}return s}_decodeRLETile(t){let n=this._tileBuffer,r=0;for(;r<t;){let o=this._readPixels(1),s=this._readRLELength();for(let i=0;i<s;i++)n[r*4]=o[0],n[r*4+1]=o[1],n[r*4+2]=o[2],n[r*4+3]=o[3],r++}return n}_decodeRLEPaletteTile(t,n){let r=this._tileBuffer,o=this._readPixels(t),s=0;for(;s<n;){let i=this._inflator.inflate(1)[0],a=1;if(i>=128&&(i-=128,a=this._readRLELength()),i>t)throw new Error("Too big index in palette: "+i+", palette size: "+t);if(s+a>n)throw new Error("Too big rle length in palette mode: "+a+", allowed length is: "+(n-s));for(let u=0;u<a;u++)r[s*4]=o[i*4],r[s*4+1]=o[i*4+1],r[s*4+2]=o[i*4+2],r[s*4+3]=o[i*4+3],s++}return r}_readRLELength(){let t=0,n=0;do n=this._inflator.inflate(1)[0],t+=n;while(n===255);return t+1}};var oa=class{constructor(){this._cachedQuantTables=[],this._cachedHuffmanTables=[],this._segments=[]}decodeRect(t,n,r,o,s,i,a){for(;;){let h=this._readSegment(s);if(h===null)return!1;if(this._segments.push(h),h[1]===217)break}let u=[],c=[];for(let h of this._segments){let g=h[1];g===196?u.push(h):g===219&&c.push(h)}let d=this._segments.findIndex(h=>h[1]==192||h[1]==194);if(d==-1)throw new Error("Illegal JPEG image without SOF");c.length===0&&this._segments.splice(d+1,0,...this._cachedQuantTables),u.length===0&&this._segments.splice(d+1,0,...this._cachedHuffmanTables);let p=0;for(let h of this._segments)p+=h.length;let f=new Uint8Array(p);p=0;for(let h of this._segments)f.set(h,p),p+=h.length;return i.imageRect(t,n,r,o,"image/jpeg",f),u.length!==0&&(this._cachedHuffmanTables=u),c.length!==0&&(this._cachedQuantTables=c),this._segments=[],!0}_readSegment(t){if(t.rQwait("JPEG",2))return null;let n=t.rQshift8();if(n!=255)throw new Error("Illegal JPEG marker received (byte: "+n+")");let r=t.rQshift8();if(r>=208&&r<=217||r==1)return new Uint8Array([n,r]);if(t.rQwait("JPEG",2,2))return null;let o=t.rQshift16();if(o<2)throw new Error("Illegal JPEG length received (length: "+o+")");if(t.rQwait("JPEG",o-2,4))return null;let s=0;if(r===218){if(t.rQwait("JPEG",o-2+2,4))return null;let a=t.rQlen(),u=t.rQpeekBytes(a,!1);for(;;){let c=u.indexOf(255,o-2+s);if(c===-1||c===a-1)return t.rQwait("JPEG",1/0,4),null;if(u.at(c+1)===0||u.at(c+1)>=208&&u.at(c+1)<=215){s=c+2-(o-2);continue}s=c-(o-2);break}}let i=new Uint8Array(2+o+s);return i[0]=n,i[1]=r,i[2]=o>>8,i[3]=o,i.set(t.rQshiftBytes(o-2+s,!1),4),i}};var xh=class{constructor(t){this._data=t,this._index=0,this.profileIdc=null,this.constraintSet=null,this.levelIdc=null}_getStartSequenceLen(t){let n=this._data;return n[t+0]==0&&n[t+1]==0&&n[t+2]==0&&n[t+3]==1?4:n[t+0]==0&&n[t+1]==0&&n[t+2]==1?3:0}_indexOfNextNalUnit(t){let n=this._data;for(let r=t;r<n.length;++r)if(this._getStartSequenceLen(r)!=0)return r;return-1}_parseSps(t){this.profileIdc=this._data[t],this.constraintSet=this._data[t+1],this.levelIdc=this._data[t+2]}_parseNalUnit(t){let n=this._data[t];if(n&128)throw new Error("H264 parsing sanity check failed, forbidden zero bit is set");let r=n&31;switch(r){case 1:return{slice:!0};case 5:return{slice:!0,key:!0};case 6:return{};case 7:return this._parseSps(t+1),{};case 8:return{};default:Ye("Unhandled unit type: ",r);break}return{}}parse(){let t=this._index,n=!1;for(;this._index<this._data.length;){let r=this._getStartSequenceLen(this._index);if(r==0)throw new Error("Invalid start sequence in bit stream");let{slice:o,key:s}=this._parseNalUnit(this._index+r),i=this._indexOfNextNalUnit(this._index+r);if(i==-1?this._index=this._data.length:this._index=i,s&&(n=!0),o)break}return t===this._index?null:{frame:this._data.subarray(t,this._index),key:n}}},bh=class{constructor(t,n){this.lastUsed=0,this._width=t,this._height=n,this._profileIdc=null,this._constraintSet=null,this._levelIdc=null,this._decoder=null,this._pendingFrames=[]}_handleFrame(t){let n=this._pendingFrames.shift();if(n===void 0)throw new Error("Pending frame queue empty when receiving frame from decoder");if(n.timestamp!=t.timestamp)throw new Error("Video frame timestamp mismatch. Expected "+t.timestamp+" but but got "+n.timestamp);n.frame=t,n.ready=!0,n.resolve(),n.keep||t.close()}_handleError(t){throw new Error("Failed to decode frame: "+t.message)}_configureDecoder(t,n,r){(this._decoder===null||this._decoder.state==="closed")&&(this._decoder=new VideoDecoder({output:s=>this._handleFrame(s),error:s=>this._handleError(s)}));let o="avc1."+t.toString(16).padStart(2,"0")+n.toString(16).padStart(2,"0")+r.toString(16).padStart(2,"0");this._decoder.configure({codec:o,codedWidth:this._width,codedHeight:this._height,optimizeForLatency:!0})}_preparePendingFrame(t){let n={timestamp:t,promise:null,resolve:null,frame:null,ready:!1,keep:!1};return n.promise=new Promise(r=>{n.resolve=r}),this._pendingFrames.push(n),n}decode(t){let n=new xh(t),r=null,o=Math.round(window.performance.now()*1e3);for(;;){let s=n.parse();if(s===null)break;if(n.profileIdc!==null&&(self._profileIdc=n.profileIdc,self._constraintSet=n.constraintSet,self._levelIdc=n.levelIdc),this._decoder===null||this._decoder.state!=="configured"){if(!s.key){Ye("Missing key frame. Can't decode until one arrives");continue}if(self._profileIdc===null){Ye("Cannot config decoder. Have not received SPS and PPS yet.");continue}this._configureDecoder(self._profileIdc,self._constraintSet,self._levelIdc)}r=this._preparePendingFrame(o);let i=new EncodedVideoChunk({timestamp:o,type:s.key?"key":"delta",data:s.frame});try{this._decoder.decode(i)}catch(a){Ye("Failed to decode:",a)}}return r!==null&&(r.keep=!0),r}},sa=class{constructor(){this._tick=0,this._contexts={}}_contextId(t,n,r,o){return[t,n,r,o].join(",")}_findOldestContextId(){let t=Number.MAX_VALUE,n;for(let[r,o]of Object.entries(this._contexts))o.lastUsed<t&&(t=o.lastUsed,n=r);return n}_createContext(t,n,r,o){if(Object.keys(this._contexts).length>=64){let a=this._findOldestContextId();delete this._contexts[a]}let i=new bh(r,o);return this._contexts[this._contextId(t,n,r,o)]=i,i}_getContext(t,n,r,o){let s=this._contexts[this._contextId(t,n,r,o)];return s!==void 0?s:this._createContext(t,n,r,o)}_resetContext(t,n,r,o){delete this._contexts[this._contextId(t,n,r,o)]}_resetAllContexts(){this._contexts={}}decodeRect(t,n,r,o,s,i,a){if(s.rQwait("h264 header",8))return!1;let d=s.rQshift32(),p=s.rQshift32();if(s.rQwait("h264 payload",d,8))return!1;p&2?this._resetAllContexts():p&1&&this._resetContext(t,n,r,o);let f=this._getContext(t,n,r,o);if(f.lastUsed=this._tick++,d!==0){let h=s.rQshiftBytes(d,!1),g=f.decode(h);g!==null&&i.videoFrame(t,n,r,o,g)}return!0}};var u$=3,d$="rgb(40, 40, 40)",Zw=17,Ww=50,jw=19,ia=75,or=50,p$=1e3,f$=50,Qw=1,Pc=2,Gw=6,Yw=16,yh=19,qw=22,Jw=30,ek=113,tk=129,nk=256,fn=1;var rk=1<<24,Oc=1<<25,ok=1<<26,aa=1<<27,Lc=1<<28,yt=class e extends Or{constructor(t,n,r){if(!t)throw new Error("Must specify target");if(!n)throw new Error("Must specify URL, WebSocket or RTCDataChannel");window.isSecureContext||Me("noVNC requires a secure context (TLS). Expect crashes!"),super(),this._target=t,typeof n=="string"?this._url=n:(this._url=null,this._rawChannel=n),r=r||{},this._rfbCredentials=r.credentials||{},this._shared="shared"in r?!!r.shared:!0,this._repeaterID=r.repeaterID||"",this._wsProtocols=r.wsProtocols||[],this._rfbConnectionState="",this._rfbInitState="",this._rfbAuthScheme=-1,this._rfbCleanDisconnect=!0,this._rfbRSAAESAuthenticationState=null,this._rfbVersion=0,this._rfbMaxVersion=3.8,this._rfbTightVNC=!1,this._rfbVeNCryptState=0,this._rfbXvpVer=0,this._fbWidth=0,this._fbHeight=0,this._fbName="",this._capabilities={power:!1},this._supportsFence=!1,this._supportsContinuousUpdates=!1,this._enabledContinuousUpdates=!1,this._supportsSetDesktopSize=!1,this._screenID=0,this._screenFlags=0,this._pendingRemoteResize=!1,this._lastResize=0,this._qemuExtKeyEventSupported=!1,this._extendedPointerEventSupported=!1,this._clipboardText=null,this._clipboardServerCapabilitiesActions={},this._clipboardServerCapabilitiesFormats={},this._sock=null,this._display=null,this._flushing=!1,this._keyboard=null,this._gestures=null,this._resizeObserver=null,this._disconnTimer=null,this._resizeTimeout=null,this._mouseMoveTimer=null,this._decoders={},this._FBU={rects:0,x:0,y:0,width:0,height:0,encoding:null},this._mousePos={},this._mouseButtonMask=0,this._mouseLastMoveTime=0,this._viewportDragging=!1,this._viewportDragPos={},this._viewportHasMoved=!1,this._accumulatedWheelDeltaX=0,this._accumulatedWheelDeltaY=0,this._gestureLastTapTime=null,this._gestureFirstDoubleTapEv=null,this._gestureLastMagnitudeX=0,this._gestureLastMagnitudeY=0,this._eventHandlers={focusCanvas:this._focusCanvas.bind(this),handleResize:this._handleResize.bind(this),handleMouse:this._handleMouse.bind(this),handleWheel:this._handleWheel.bind(this),handleGesture:this._handleGesture.bind(this),handleRSAAESCredentialsRequired:this._handleRSAAESCredentialsRequired.bind(this),handleRSAAESServerVerification:this._handleRSAAESServerVerification.bind(this)},de(">> RFB.constructor"),this._screen=document.createElement("div"),this._screen.style.display="flex",this._screen.style.width="100%",this._screen.style.height="100%",this._screen.style.overflow="auto",this._screen.style.background=d$,this._canvas=document.createElement("canvas"),this._canvas.style.margin="auto",this._canvas.style.outline="none",this._canvas.width=0,this._canvas.height=0,this._canvas.tabIndex=-1,this._screen.appendChild(this._canvas),this._cursor=new ji,this._cursorImage=e.cursors.none,this._decoders[ge.encodingRaw]=new Yi,this._decoders[ge.encodingCopyRect]=new qi,this._decoders[ge.encodingRRE]=new Ji,this._decoders[ge.encodingHextile]=new ea,this._decoders[ge.encodingZlib]=new ta,this._decoders[ge.encodingTight]=new Ur,this._decoders[ge.encodingTightPNG]=new na,this._decoders[ge.encodingZRLE]=new ra,this._decoders[ge.encodingJPEG]=new oa,this._decoders[ge.encodingH264]=new sa;try{this._display=new $i(this._canvas)}catch(o){throw Me("Display exception: "+o),o}this._keyboard=new Vi(this._canvas),this._keyboard.onkeyevent=this._handleKeyEvent.bind(this),this._remoteCapsLock=null,this._remoteNumLock=null,this._gestures=new Zi,this._sock=new Qi,this._sock.on("open",this._socketOpen.bind(this)),this._sock.on("close",this._socketClose.bind(this)),this._sock.on("message",this._handleMessage.bind(this)),this._sock.on("error",this._socketError.bind(this)),this._expectedClientWidth=null,this._expectedClientHeight=null,this._resizeObserver=new ResizeObserver(this._eventHandlers.handleResize),this._updateConnectionState("connecting"),de("<< RFB.constructor"),this.dragViewport=!1,this.focusOnClick=!0,this._viewOnly=!1,this._clipViewport=!1,this._clippingViewport=!1,this._scaleViewport=!1,this._resizeSession=!1,this._showDotCursor=!1,this._qualityLevel=6,this._compressionLevel=2}get viewOnly(){return this._viewOnly}set viewOnly(t){this._viewOnly=t,(this._rfbConnectionState==="connecting"||this._rfbConnectionState==="connected")&&(t?this._keyboard.ungrab():this._keyboard.grab())}get capabilities(){return this._capabilities}get clippingViewport(){return this._clippingViewport}_setClippingViewport(t){t!==this._clippingViewport&&(this._clippingViewport=t,this.dispatchEvent(new CustomEvent("clippingviewport",{detail:this._clippingViewport})))}get touchButton(){return 0}set touchButton(t){Ye("Using old API!")}get clipViewport(){return this._clipViewport}set clipViewport(t){this._clipViewport=t,this._updateClip()}get scaleViewport(){return this._scaleViewport}set scaleViewport(t){this._scaleViewport=t,t&&this._clipViewport&&this._updateClip(),this._updateScale(),!t&&this._clipViewport&&this._updateClip()}get resizeSession(){return this._resizeSession}set resizeSession(t){this._resizeSession=t,t&&this._requestRemoteResize()}get showDotCursor(){return this._showDotCursor}set showDotCursor(t){this._showDotCursor=t,this._refreshCursor()}get background(){return this._screen.style.background}set background(t){this._screen.style.background=t}get qualityLevel(){return this._qualityLevel}set qualityLevel(t){if(!Number.isInteger(t)||t<0||t>9){Me("qualityLevel must be an integer between 0 and 9");return}this._qualityLevel!==t&&(this._qualityLevel=t,this._rfbConnectionState==="connected"&&this._sendEncodings())}get compressionLevel(){return this._compressionLevel}set compressionLevel(t){if(!Number.isInteger(t)||t<0||t>9){Me("compressionLevel must be an integer between 0 and 9");return}this._compressionLevel!==t&&(this._compressionLevel=t,this._rfbConnectionState==="connected"&&this._sendEncodings())}disconnect(){this._updateConnectionState("disconnecting"),this._sock.off("error"),this._sock.off("message"),this._sock.off("open"),this._rfbRSAAESAuthenticationState!==null&&this._rfbRSAAESAuthenticationState.disconnect()}approveServer(){this._rfbRSAAESAuthenticationState!==null&&this._rfbRSAAESAuthenticationState.approveServer()}sendCredentials(t){this._rfbCredentials=t,this._resumeAuthentication()}sendCtrlAltDel(){this._rfbConnectionState!=="connected"||this._viewOnly||(Qe("Sending Ctrl-Alt-Del"),this.sendKey(A.XK_Control_L,"ControlLeft",!0),this.sendKey(A.XK_Alt_L,"AltLeft",!0),this.sendKey(A.XK_Delete,"Delete",!0),this.sendKey(A.XK_Delete,"Delete",!1),this.sendKey(A.XK_Alt_L,"AltLeft",!1),this.sendKey(A.XK_Control_L,"ControlLeft",!1))}machineShutdown(){this._xvpOp(1,2)}machineReboot(){this._xvpOp(1,3)}machineReset(){this._xvpOp(1,4)}sendKey(t,n,r){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;if(r===void 0){this.sendKey(t,n,!0),this.sendKey(t,n,!1);return}let o=Lw[n];if(this._qemuExtKeyEventSupported&&o)t=t||0,Qe("Sending key ("+(r?"down":"up")+"): keysym "+t+", scancode "+o),e.messages.QEMUExtendedKeyEvent(this._sock,t,r,o);else{if(!t)return;Qe("Sending keysym ("+(r?"down":"up")+"): "+t),e.messages.keyEvent(this._sock,t,r?1:0)}}focus(t){this._canvas.focus(t)}blur(){this._canvas.blur()}clipboardPasteFrom(t){if(!(this._rfbConnectionState!=="connected"||this._viewOnly))if(this._clipboardServerCapabilitiesFormats[fn]&&this._clipboardServerCapabilitiesActions[aa])this._clipboardText=t,e.messages.extendedClipboardNotify(this._sock,[fn]);else{let n,r,o;n=0;for(let s of t)n++;o=new Uint8Array(n),r=0;for(let s of t){let i=s.codePointAt(0);i>255&&(i=63),o[r++]=i}e.messages.clientCutText(this._sock,o)}}getImageData(){return this._display.getImageData()}toDataURL(t,n){return this._display.toDataURL(t,n)}toBlob(t,n,r){return this._display.toBlob(t,n,r)}_connect(){if(de(">> RFB.connect"),this._url)Qe(`connecting to ${this._url}`),this._sock.open(this._url,this._wsProtocols);else{if(Qe(`attaching ${this._rawChannel} to Websock`),this._sock.attach(this._rawChannel),this._sock.readyState==="closed")throw Error("Cannot use already closed WebSocket/RTCDataChannel");this._sock.readyState==="open"&&this._socketOpen()}this._target.appendChild(this._screen),this._gestures.attach(this._canvas),this._cursor.attach(this._canvas),this._refreshCursor(),this._resizeObserver.observe(this._screen),this._canvas.addEventListener("mousedown",this._eventHandlers.focusCanvas),this._canvas.addEventListener("touchstart",this._eventHandlers.focusCanvas),this._canvas.addEventListener("mousedown",this._eventHandlers.handleMouse),this._canvas.addEventListener("mouseup",this._eventHandlers.handleMouse),this._canvas.addEventListener("mousemove",this._eventHandlers.handleMouse),this._canvas.addEventListener("click",this._eventHandlers.handleMouse),this._canvas.addEventListener("contextmenu",this._eventHandlers.handleMouse),this._canvas.addEventListener("wheel",this._eventHandlers.handleWheel),this._canvas.addEventListener("gesturestart",this._eventHandlers.handleGesture),this._canvas.addEventListener("gesturemove",this._eventHandlers.handleGesture),this._canvas.addEventListener("gestureend",this._eventHandlers.handleGesture),de("<< RFB.connect")}_disconnect(){de(">> RFB.disconnect"),this._cursor.detach(),this._canvas.removeEventListener("gesturestart",this._eventHandlers.handleGesture),this._canvas.removeEventListener("gesturemove",this._eventHandlers.handleGesture),this._canvas.removeEventListener("gestureend",this._eventHandlers.handleGesture),this._canvas.removeEventListener("wheel",this._eventHandlers.handleWheel),this._canvas.removeEventListener("mousedown",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mouseup",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mousemove",this._eventHandlers.handleMouse),this._canvas.removeEventListener("click",this._eventHandlers.handleMouse),this._canvas.removeEventListener("contextmenu",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mousedown",this._eventHandlers.focusCanvas),this._canvas.removeEventListener("touchstart",this._eventHandlers.focusCanvas),this._resizeObserver.disconnect(),this._keyboard.ungrab(),this._gestures.detach(),this._sock.close();try{this._target.removeChild(this._screen)}catch(t){if(t.name!=="NotFoundError")throw t}clearTimeout(this._resizeTimeout),clearTimeout(this._mouseMoveTimer),de("<< RFB.disconnect")}_socketOpen(){this._rfbConnectionState==="connecting"&&this._rfbInitState===""?(this._rfbInitState="ProtocolVersion",de("Starting VNC handshake")):this._fail("Unexpected server connection while "+this._rfbConnectionState)}_socketClose(t){de("WebSocket on-close event");let n="";switch(t.code&&(n="(code: "+t.code,t.reason&&(n+=", reason: "+t.reason),n+=")"),this._rfbConnectionState){case"connecting":this._fail("Connection closed "+n);break;case"connected":this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected");break;case"disconnecting":this._updateConnectionState("disconnected");break;case"disconnected":this._fail("Unexpected server disconnect when already disconnected "+n);break;default:this._fail("Unexpected server disconnect before connecting "+n);break}this._sock.off("close"),this._rawChannel=null}_socketError(t){Ye("WebSocket on-error event")}_focusCanvas(t){this.focusOnClick&&this.focus({preventScroll:!0})}_setDesktopName(t){this._fbName=t,this.dispatchEvent(new CustomEvent("desktopname",{detail:{name:this._fbName}}))}_saveExpectedClientSize(){this._expectedClientWidth=this._screen.clientWidth,this._expectedClientHeight=this._screen.clientHeight}_currentClientSize(){return[this._screen.clientWidth,this._screen.clientHeight]}_clientHasExpectedSize(){let[t,n]=this._currentClientSize();return t==this._expectedClientWidth&&n==this._expectedClientHeight}_handleResize(){this._clientHasExpectedSize()||(window.requestAnimationFrame(()=>{this._updateClip(),this._updateScale(),this._saveExpectedClientSize()}),this._requestRemoteResize())}_updateClip(){let t=this._display.clipViewport,n=this._clipViewport;if(this._scaleViewport&&(n=!1),t!==n&&(this._display.clipViewport=n),n){let r=this._screenSize();this._display.viewportChangeSize(r.w,r.h),this._fixScrollbars(),this._setClippingViewport(r.w<this._display.width||r.h<this._display.height)}else this._setClippingViewport(!1);t!==n&&this._saveExpectedClientSize()}_updateScale(){if(!this._scaleViewport)this._display.scale=1;else{let t=this._screenSize();this._display.autoscale(t.w,t.h)}this._fixScrollbars()}_requestRemoteResize(){if(!this._resizeSession||this._viewOnly||!this._supportsSetDesktopSize||this._pendingRemoteResize)return;if(Date.now()-this._lastResize<100){clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(this._requestRemoteResize.bind(this),100-(Date.now()-this._lastResize));return}this._resizeTimeout=null;let t=this._screenSize();t.w===this._fbWidth&&t.h===this._fbHeight||(this._pendingRemoteResize=!0,this._lastResize=Date.now(),e.messages.setDesktopSize(this._sock,Math.floor(t.w),Math.floor(t.h),this._screenID,this._screenFlags),de("Requested new desktop size: "+t.w+"x"+t.h))}_screenSize(){let t=this._screen.getBoundingClientRect();return{w:t.width,h:t.height}}_fixScrollbars(){let t=this._screen.style.overflow;this._screen.style.overflow="hidden",this._screen.getBoundingClientRect(),this._screen.style.overflow=t}_updateConnectionState(t){let n=this._rfbConnectionState;if(t===n){de("Already in state '"+t+"', ignoring");return}if(n==="disconnected"){Me("Tried changing state of a disconnected RFB object");return}switch(t){case"connected":if(n!=="connecting"){Me("Bad transition to connected state, previous connection state: "+n);return}break;case"disconnected":if(n!=="disconnecting"){Me("Bad transition to disconnected state, previous connection state: "+n);return}break;case"connecting":if(n!==""){Me("Bad transition to connecting state, previous connection state: "+n);return}break;case"disconnecting":if(n!=="connected"&&n!=="connecting"){Me("Bad transition to disconnecting state, previous connection state: "+n);return}break;default:Me("Unknown connection state: "+t);return}switch(this._rfbConnectionState=t,de("New state '"+t+"', was '"+n+"'."),this._disconnTimer&&t!=="disconnecting"&&(de("Clearing disconnect timer"),clearTimeout(this._disconnTimer),this._disconnTimer=null,this._sock.off("close")),t){case"connecting":this._connect();break;case"connected":this.dispatchEvent(new CustomEvent("connect",{detail:{}}));break;case"disconnecting":this._disconnect(),this._disconnTimer=setTimeout(()=>{Me("Disconnection timed out."),this._updateConnectionState("disconnected")},u$*1e3);break;case"disconnected":this.dispatchEvent(new CustomEvent("disconnect",{detail:{clean:this._rfbCleanDisconnect}}));break}}_fail(t){switch(this._rfbConnectionState){case"disconnecting":Me("Failed when disconnecting: "+t);break;case"connected":Me("Failed while connected: "+t);break;case"connecting":Me("Failed when connecting: "+t);break;default:Me("RFB failure: "+t);break}return this._rfbCleanDisconnect=!1,this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected"),!1}_setCapability(t,n){this._capabilities[t]=n,this.dispatchEvent(new CustomEvent("capabilities",{detail:{capabilities:this._capabilities}}))}_handleMessage(){if(this._sock.rQwait("message",1)){Ye("handleMessage called on an empty receive queue");return}switch(this._rfbConnectionState){case"disconnected":Me("Got data while disconnected");break;case"connected":for(;!(this._flushing||!this._normalMsg()||this._sock.rQwait("message",1)););break;case"connecting":for(;this._rfbConnectionState==="connecting"&&this._initMsg(););break;default:Me("Got data while in an invalid state");break}}_handleKeyEvent(t,n,r,o,s){n=="CapsLock"&&r&&(this._remoteCapsLock=null),this._remoteCapsLock!==null&&s!==null&&this._remoteCapsLock!==s&&r&&(de("Fixing remote caps lock"),this.sendKey(A.XK_Caps_Lock,"CapsLock",!0),this.sendKey(A.XK_Caps_Lock,"CapsLock",!1),this._remoteCapsLock=null),n=="NumLock"&&r&&(this._remoteNumLock=null),this._remoteNumLock!==null&&o!==null&&this._remoteNumLock!==o&&r&&(de("Fixing remote num lock"),this.sendKey(A.XK_Num_Lock,"NumLock",!0),this.sendKey(A.XK_Num_Lock,"NumLock",!1),this._remoteNumLock=null),this.sendKey(t,n,r)}static _convertButtonMask(t){let n={0:1,1:4,2:2,3:128,4:256},r=0;for(let o=0;o<5;o++)t&1<<o&&(r|=n[o]);return r}_handleMouse(t){if(t.type==="click"&&t.target!==this._canvas||(t.stopPropagation(),t.preventDefault(),t.type==="click"||t.type==="contextmenu"))return;let n=Do(t.clientX,t.clientY,this._canvas),r=e._convertButtonMask(t.buttons),o=t.type=="mousedown";switch(t.type){case"mousedown":case"mouseup":if(this.dragViewport)if(o&&!this._viewportDragging){this._viewportDragging=!0,this._viewportDragPos={x:n.x,y:n.y},this._viewportHasMoved=!1,this._flushMouseMoveTimer(n.x,n.y),this._mouseButtonMask=r;break}else{if(this._viewportDragging=!1,this._viewportHasMoved){this._mouseButtonMask=r;break}this._sendMouse(n.x,n.y,this._mouseButtonMask)}o&&mv(this._canvas),this._handleMouseButton(n.x,n.y,r);break;case"mousemove":if(this._viewportDragging){let s=this._viewportDragPos.x-n.x,i=this._viewportDragPos.y-n.y;(this._viewportHasMoved||Math.abs(s)>Ri||Math.abs(i)>Ri)&&(this._viewportHasMoved=!0,this._viewportDragPos={x:n.x,y:n.y},this._display.viewportChangePos(s,i));break}this._handleMouseMove(n.x,n.y);break}}_handleMouseButton(t,n,r){this._flushMouseMoveTimer(t,n),this._mouseButtonMask=r,this._sendMouse(t,n,this._mouseButtonMask)}_handleMouseMove(t,n){if(this._mousePos={x:t,y:n},this._mouseMoveTimer==null){let r=Date.now()-this._mouseLastMoveTime;r>Zw?(this._sendMouse(t,n,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()):this._mouseMoveTimer=setTimeout(()=>{this._handleDelayedMouseMove()},Zw-r)}}_handleDelayedMouseMove(){this._mouseMoveTimer=null,this._sendMouse(this._mousePos.x,this._mousePos.y,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()}_sendMouse(t,n,r){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;if(r&32768)throw new Error("Illegal mouse button mask (mask: "+r+")");let o=r&32640;this._extendedPointerEventSupported&&o?e.messages.extendedPointerEvent(this._sock,this._display.absX(t),this._display.absY(n),r):e.messages.pointerEvent(this._sock,this._display.absX(t),this._display.absY(n),r)}_handleWheel(t){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;t.stopPropagation(),t.preventDefault();let n=Do(t.clientX,t.clientY,this._canvas),r=e._convertButtonMask(t.buttons),o=t.deltaX,s=t.deltaY;t.deltaMode!==0&&(o*=jw,s*=jw),this._accumulatedWheelDeltaX+=o,this._accumulatedWheelDeltaY+=s,Math.abs(this._accumulatedWheelDeltaX)>=Ww&&(this._accumulatedWheelDeltaX<0?(this._handleMouseButton(n.x,n.y,r|32),this._handleMouseButton(n.x,n.y,r)):this._accumulatedWheelDeltaX>0&&(this._handleMouseButton(n.x,n.y,r|64),this._handleMouseButton(n.x,n.y,r)),this._accumulatedWheelDeltaX=0),Math.abs(this._accumulatedWheelDeltaY)>=Ww&&(this._accumulatedWheelDeltaY<0?(this._handleMouseButton(n.x,n.y,r|8),this._handleMouseButton(n.x,n.y,r)):this._accumulatedWheelDeltaY>0&&(this._handleMouseButton(n.x,n.y,r|16),this._handleMouseButton(n.x,n.y,r)),this._accumulatedWheelDeltaY=0)}_fakeMouseMove(t,n,r){this._handleMouseMove(n,r),this._cursor.move(t.detail.clientX,t.detail.clientY)}_handleTapEvent(t,n){let r=Do(t.detail.clientX,t.detail.clientY,this._canvas);if(this._gestureLastTapTime!==null&&Date.now()-this._gestureLastTapTime<p$&&this._gestureFirstDoubleTapEv.detail.type===t.detail.type){let o=this._gestureFirstDoubleTapEv.detail.clientX-t.detail.clientX,s=this._gestureFirstDoubleTapEv.detail.clientY-t.detail.clientY;Math.hypot(o,s)<f$?r=Do(this._gestureFirstDoubleTapEv.detail.clientX,this._gestureFirstDoubleTapEv.detail.clientY,this._canvas):this._gestureFirstDoubleTapEv=t}else this._gestureFirstDoubleTapEv=t;this._gestureLastTapTime=Date.now(),this._fakeMouseMove(this._gestureFirstDoubleTapEv,r.x,r.y),this._handleMouseButton(r.x,r.y,n),this._handleMouseButton(r.x,r.y,0)}_handleGesture(t){let n,r=Do(t.detail.clientX,t.detail.clientY,this._canvas);switch(t.type){case"gesturestart":switch(t.detail.type){case"onetap":this._handleTapEvent(t,1);break;case"twotap":this._handleTapEvent(t,4);break;case"threetap":this._handleTapEvent(t,2);break;case"drag":this.dragViewport?(this._viewportHasMoved=!1,this._viewportDragging=!0,this._viewportDragPos={x:r.x,y:r.y}):(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,1));break;case"longpress":this.dragViewport?(this._viewportHasMoved=!1,this._viewportDragPos={x:r.x,y:r.y}):(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,4));break;case"twodrag":this._gestureLastMagnitudeX=t.detail.magnitudeX,this._gestureLastMagnitudeY=t.detail.magnitudeY,this._fakeMouseMove(t,r.x,r.y);break;case"pinch":this._gestureLastMagnitudeX=Math.hypot(t.detail.magnitudeX,t.detail.magnitudeY),this._fakeMouseMove(t,r.x,r.y);break}break;case"gesturemove":switch(t.detail.type){case"onetap":case"twotap":case"threetap":break;case"drag":case"longpress":if(this.dragViewport){this._viewportDragging=!0;let o=this._viewportDragPos.x-r.x,s=this._viewportDragPos.y-r.y;(this._viewportHasMoved||Math.abs(o)>Ri||Math.abs(s)>Ri)&&(this._viewportHasMoved=!0,this._viewportDragPos={x:r.x,y:r.y},this._display.viewportChangePos(o,s))}else this._fakeMouseMove(t,r.x,r.y);break;case"twodrag":for(this._fakeMouseMove(t,r.x,r.y);t.detail.magnitudeY-this._gestureLastMagnitudeY>or;)this._handleMouseButton(r.x,r.y,8),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeY+=or;for(;t.detail.magnitudeY-this._gestureLastMagnitudeY<-or;)this._handleMouseButton(r.x,r.y,16),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeY-=or;for(;t.detail.magnitudeX-this._gestureLastMagnitudeX>or;)this._handleMouseButton(r.x,r.y,32),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeX+=or;for(;t.detail.magnitudeX-this._gestureLastMagnitudeX<-or;)this._handleMouseButton(r.x,r.y,64),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeX-=or;break;case"pinch":if(this._fakeMouseMove(t,r.x,r.y),n=Math.hypot(t.detail.magnitudeX,t.detail.magnitudeY),Math.abs(n-this._gestureLastMagnitudeX)>ia){for(this._handleKeyEvent(A.XK_Control_L,"ControlLeft",!0);n-this._gestureLastMagnitudeX>ia;)this._handleMouseButton(r.x,r.y,8),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeX+=ia;for(;n-this._gestureLastMagnitudeX<-ia;)this._handleMouseButton(r.x,r.y,16),this._handleMouseButton(r.x,r.y,0),this._gestureLastMagnitudeX-=ia}this._handleKeyEvent(A.XK_Control_L,"ControlLeft",!1);break}break;case"gestureend":switch(t.detail.type){case"onetap":case"twotap":case"threetap":case"pinch":case"twodrag":break;case"drag":this.dragViewport?this._viewportDragging=!1:(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,0));break;case"longpress":if(this._viewportHasMoved)break;this.dragViewport&&!this._viewportHasMoved?(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,4),this._handleMouseButton(r.x,r.y,0),this._viewportDragging=!1):(this._fakeMouseMove(t,r.x,r.y),this._handleMouseButton(r.x,r.y,0));break}break}}_flushMouseMoveTimer(t,n){this._mouseMoveTimer!==null&&(clearTimeout(this._mouseMoveTimer),this._mouseMoveTimer=null,this._sendMouse(t,n,this._mouseButtonMask))}_negotiateProtocolVersion(){if(this._sock.rQwait("version",12))return!1;let t=this._sock.rQshiftStr(12).substr(4,7);Qe("Server ProtocolVersion: "+t);let n=0;switch(t){case"000.000":n=1;break;case"003.003":case"003.006":this._rfbVersion=3.3;break;case"003.007":this._rfbVersion=3.7;break;case"003.008":case"003.889":case"004.000":case"004.001":case"005.000":this._rfbVersion=3.8;break;default:return this._fail("Invalid server version "+t)}if(n){let o="ID:"+this._repeaterID;for(;o.length<250;)o+="\0";return this._sock.sQpushString(o),this._sock.flush(),!0}this._rfbVersion>this._rfbMaxVersion&&(this._rfbVersion=this._rfbMaxVersion);let r="00"+parseInt(this._rfbVersion,10)+".00"+this._rfbVersion*10%10;this._sock.sQpushString("RFB "+r+`
2
2
  `),this._sock.flush(),de("Sent ProtocolVersion: "+r),this._rfbInitState="Security"}_isSupportedSecurityType(t){return[Qw,Pc,Gw,Yw,yh,qw,Jw,ek,nk].includes(t)}_negotiateSecurity(){if(this._rfbVersion>=3.7){let t=this._sock.rQshift8();if(this._sock.rQwait("security type",t,1))return!1;if(t===0)return this._rfbInitState="SecurityReason",this._securityContext="no security types",this._securityStatus=1,!0;let n=this._sock.rQshiftBytes(t);de("Server security types: "+n),this._rfbAuthScheme=-1;for(let r of n)if(this._isSupportedSecurityType(r)){this._rfbAuthScheme=r;break}if(this._rfbAuthScheme===-1)return this._fail("Unsupported security types (types: "+n+")");this._sock.sQpush8(this._rfbAuthScheme),this._sock.flush()}else{if(this._sock.rQwait("security scheme",4))return!1;if(this._rfbAuthScheme=this._sock.rQshift32(),this._rfbAuthScheme==0)return this._rfbInitState="SecurityReason",this._securityContext="authentication scheme",this._securityStatus=1,!0}return this._rfbInitState="Authentication",de("Authenticating using scheme: "+this._rfbAuthScheme),!0}_handleSecurityReason(){if(this._sock.rQwait("reason length",4))return!1;let t=this._sock.rQshift32(),n="";if(t>0){if(this._sock.rQwait("reason",t,4))return!1;n=this._sock.rQshiftStr(t)}return n!==""?(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:this._securityStatus,reason:n}})),this._fail("Security negotiation failed on "+this._securityContext+" (reason: "+n+")")):(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:this._securityStatus}})),this._fail("Security negotiation failed on "+this._securityContext))}_negotiateXvpAuth(){return this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0||this._rfbCredentials.target===void 0?(this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password","target"]}})),!1):(this._sock.sQpush8(this._rfbCredentials.username.length),this._sock.sQpush8(this._rfbCredentials.target.length),this._sock.sQpushString(this._rfbCredentials.username),this._sock.sQpushString(this._rfbCredentials.target),this._sock.flush(),this._rfbAuthScheme=Pc,this._negotiateAuthentication())}_negotiateVeNCryptAuth(){if(this._rfbVeNCryptState==0){if(this._sock.rQwait("vencrypt version",2))return!1;let t=this._sock.rQshift8(),n=this._sock.rQshift8();if(!(t==0&&n==2))return this._fail("Unsupported VeNCrypt version "+t+"."+n);this._sock.sQpush8(0),this._sock.sQpush8(2),this._sock.flush(),this._rfbVeNCryptState=1}if(this._rfbVeNCryptState==1){if(this._sock.rQwait("vencrypt ack",1))return!1;let t=this._sock.rQshift8();if(t!=0)return this._fail("VeNCrypt failure "+t);this._rfbVeNCryptState=2}if(this._rfbVeNCryptState==2){if(this._sock.rQwait("vencrypt subtypes length",1))return!1;let t=this._sock.rQshift8();if(t<1)return this._fail("VeNCrypt subtypes empty");this._rfbVeNCryptSubtypesLength=t,this._rfbVeNCryptState=3}if(this._rfbVeNCryptState==3){if(this._sock.rQwait("vencrypt subtypes",4*this._rfbVeNCryptSubtypesLength))return!1;let t=[];for(let n=0;n<this._rfbVeNCryptSubtypesLength;n++)t.push(this._sock.rQshift32());this._rfbAuthScheme=-1;for(let n of t)if(n!==yh&&this._isSupportedSecurityType(n)){this._rfbAuthScheme=n;break}return this._rfbAuthScheme===-1?this._fail("Unsupported security types (types: "+t+")"):(this._sock.sQpush32(this._rfbAuthScheme),this._sock.flush(),this._rfbVeNCryptState=4,!0)}}_negotiatePlainAuth(){if(this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1;let t=Gt(this._rfbCredentials.username),n=Gt(this._rfbCredentials.password);return this._sock.sQpush32(t.length),this._sock.sQpush32(n.length),this._sock.sQpushString(t),this._sock.sQpushString(n),this._sock.flush(),this._rfbInitState="SecurityResult",!0}_negotiateStdVNCAuth(){if(this._sock.rQwait("auth challenge",16))return!1;if(this._rfbCredentials.password===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["password"]}})),!1;let t=Array.prototype.slice.call(this._sock.rQshiftBytes(16)),n=e.genDES(this._rfbCredentials.password,t);return this._sock.sQpushBytes(n),this._sock.flush(),this._rfbInitState="SecurityResult",!0}_negotiateARDAuth(){if(this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1;if(this._rfbCredentials.ardPublicKey!=null&&this._rfbCredentials.ardCredentials!=null)return this._sock.sQpushBytes(this._rfbCredentials.ardCredentials),this._sock.sQpushBytes(this._rfbCredentials.ardPublicKey),this._sock.flush(),this._rfbCredentials.ardCredentials=null,this._rfbCredentials.ardPublicKey=null,this._rfbInitState="SecurityResult",!0;if(this._sock.rQwait("read ard",4))return!1;let t=this._sock.rQshiftBytes(2),n=this._sock.rQshift16();if(this._sock.rQwait("read ard keylength",n*2,4))return!1;let r=this._sock.rQshiftBytes(n),o=this._sock.rQshiftBytes(n),s=Xe.generateKey({name:"DH",g:t,p:r},!1,["deriveBits"]);return this._negotiateARDAuthAsync(n,o,s),!1}async _negotiateARDAuthAsync(t,n,r){let o=Xe.exportKey("raw",r.publicKey),s=Xe.deriveBits({name:"DH",public:n},r.privateKey,t*8),i=Gt(this._rfbCredentials.username).substring(0,63),a=Gt(this._rfbCredentials.password).substring(0,63),u=window.crypto.getRandomValues(new Uint8Array(128));for(let f=0;f<i.length;f++)u[f]=i.charCodeAt(f);u[i.length]=0;for(let f=0;f<a.length;f++)u[64+f]=a.charCodeAt(f);u[64+a.length]=0;let c=await Xe.digest("MD5",s),d=await Xe.importKey("raw",c,{name:"AES-ECB"},!1,["encrypt"]),p=await Xe.encrypt({name:"AES-ECB"},d,u);this._rfbCredentials.ardCredentials=p,this._rfbCredentials.ardPublicKey=o,this._resumeAuthentication()}_negotiateTightUnixAuth(){return this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0?(this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1):(this._sock.sQpush32(this._rfbCredentials.username.length),this._sock.sQpush32(this._rfbCredentials.password.length),this._sock.sQpushString(this._rfbCredentials.username),this._sock.sQpushString(this._rfbCredentials.password),this._sock.flush(),this._rfbInitState="SecurityResult",!0)}_negotiateTightTunnels(t){let n={0:{vendor:"TGHT",signature:"NOTUNNEL"}},r={};for(let o=0;o<t;o++){let s=this._sock.rQshift32(),i=this._sock.rQshiftStr(4),a=this._sock.rQshiftStr(8);r[s]={vendor:i,signature:a}}return de("Server Tight tunnel types: "+r),r[1]&&r[1].vendor==="SICR"&&r[1].signature==="SCHANNEL"&&(de("Detected Siemens server. Assuming NOTUNNEL support."),r[0]={vendor:"TGHT",signature:"NOTUNNEL"}),r[0]?r[0].vendor!=n[0].vendor||r[0].signature!=n[0].signature?this._fail("Client's tunnel type had the incorrect vendor or signature"):(de("Selected tunnel type: "+n[0]),this._sock.sQpush32(0),this._sock.flush(),!1):this._fail("Server wanted tunnels, but doesn't support the notunnel type")}_negotiateTightAuth(){if(!this._rfbTightVNC){if(this._sock.rQwait("num tunnels",4))return!1;let o=this._sock.rQshift32();if(o>0&&this._sock.rQwait("tunnel capabilities",16*o,4))return!1;if(this._rfbTightVNC=!0,o>0)return this._negotiateTightTunnels(o),!1}if(this._sock.rQwait("sub auth count",4))return!1;let t=this._sock.rQshift32();if(t===0)return this._rfbInitState="SecurityResult",!0;if(this._sock.rQwait("sub auth capabilities",16*t,4))return!1;let n={STDVNOAUTH__:1,STDVVNCAUTH_:2,TGHTULGNAUTH:129},r=[];for(let o=0;o<t;o++){this._sock.rQshift32();let s=this._sock.rQshiftStr(12);r.push(s)}de("Server Tight authentication types: "+r);for(let o in n)if(r.indexOf(o)!=-1)switch(this._sock.sQpush32(n[o]),this._sock.flush(),de("Selected authentication type: "+o),o){case"STDVNOAUTH__":return this._rfbInitState="SecurityResult",!0;case"STDVVNCAUTH_":return this._rfbAuthScheme=Pc,!0;case"TGHTULGNAUTH":return this._rfbAuthScheme=tk,!0;default:return this._fail("Unsupported tiny auth scheme (scheme: "+o+")")}return this._fail("No supported sub-auth types!")}_handleRSAAESCredentialsRequired(t){this.dispatchEvent(t)}_handleRSAAESServerVerification(t){this.dispatchEvent(t)}_negotiateRA2neAuth(){return this._rfbRSAAESAuthenticationState===null&&(this._rfbRSAAESAuthenticationState=new Gi(this._sock,()=>this._rfbCredentials),this._rfbRSAAESAuthenticationState.addEventListener("serververification",this._eventHandlers.handleRSAAESServerVerification),this._rfbRSAAESAuthenticationState.addEventListener("credentialsrequired",this._eventHandlers.handleRSAAESCredentialsRequired)),this._rfbRSAAESAuthenticationState.checkInternalEvents(),this._rfbRSAAESAuthenticationState.hasStarted||this._rfbRSAAESAuthenticationState.negotiateRA2neAuthAsync().catch(t=>{t.message!=="disconnect normally"&&this._fail(t.message)}).then(()=>(this._rfbInitState="SecurityResult",!0)).finally(()=>{this._rfbRSAAESAuthenticationState.removeEventListener("serververification",this._eventHandlers.handleRSAAESServerVerification),this._rfbRSAAESAuthenticationState.removeEventListener("credentialsrequired",this._eventHandlers.handleRSAAESCredentialsRequired),this._rfbRSAAESAuthenticationState=null}),!1}_negotiateMSLogonIIAuth(){if(this._sock.rQwait("mslogonii dh param",24))return!1;if(this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1;let t=this._sock.rQshiftBytes(8),n=this._sock.rQshiftBytes(8),r=this._sock.rQshiftBytes(8),o=Xe.generateKey({name:"DH",g:t,p:n},!0,["deriveBits"]),s=Xe.exportKey("raw",o.publicKey),i=Xe.deriveBits({name:"DH",public:r},o.privateKey,64),a=Xe.importKey("raw",i,{name:"DES-CBC"},!1,["encrypt"]),u=Gt(this._rfbCredentials.username).substring(0,255),c=Gt(this._rfbCredentials.password).substring(0,63),d=new Uint8Array(256),p=new Uint8Array(64);window.crypto.getRandomValues(d),window.crypto.getRandomValues(p);for(let f=0;f<u.length;f++)d[f]=u.charCodeAt(f);d[u.length]=0;for(let f=0;f<c.length;f++)p[f]=c.charCodeAt(f);return p[c.length]=0,d=Xe.encrypt({name:"DES-CBC",iv:i},a,d),p=Xe.encrypt({name:"DES-CBC",iv:i},a,p),this._sock.sQpushBytes(s),this._sock.sQpushBytes(d),this._sock.sQpushBytes(p),this._sock.flush(),this._rfbInitState="SecurityResult",!0}_negotiateAuthentication(){switch(this._rfbAuthScheme){case Qw:return this._rfbVersion>=3.8?this._rfbInitState="SecurityResult":this._rfbInitState="ClientInitialisation",!0;case qw:return this._negotiateXvpAuth();case Jw:return this._negotiateARDAuth();case Pc:return this._negotiateStdVNCAuth();case Yw:return this._negotiateTightAuth();case yh:return this._negotiateVeNCryptAuth();case nk:return this._negotiatePlainAuth();case tk:return this._negotiateTightUnixAuth();case Gw:return this._negotiateRA2neAuth();case ek:return this._negotiateMSLogonIIAuth();default:return this._fail("Unsupported auth scheme (scheme: "+this._rfbAuthScheme+")")}}_handleSecurityResult(){if(this._sock.rQwait("VNC auth response ",4))return!1;let t=this._sock.rQshift32();return t===0?(this._rfbInitState="ClientInitialisation",de("Authentication OK"),!0):this._rfbVersion>=3.8?(this._rfbInitState="SecurityReason",this._securityContext="security result",this._securityStatus=t,!0):(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:t}})),this._fail("Security handshake failed"))}_negotiateServerInit(){if(this._sock.rQwait("server initialization",24))return!1;let t=this._sock.rQshift16(),n=this._sock.rQshift16(),r=this._sock.rQshift8(),o=this._sock.rQshift8(),s=this._sock.rQshift8(),i=this._sock.rQshift8(),a=this._sock.rQshift16(),u=this._sock.rQshift16(),c=this._sock.rQshift16(),d=this._sock.rQshift8(),p=this._sock.rQshift8(),f=this._sock.rQshift8();this._sock.rQskipBytes(3);let h=this._sock.rQshift32();if(this._sock.rQwait("server init name",h,24))return!1;let g=this._sock.rQshiftStr(h);if(g=ic(g,!0),this._rfbTightVNC){if(this._sock.rQwait("TightVNC extended server init header",8,24+h))return!1;let x=this._sock.rQshift16(),b=this._sock.rQshift16(),v=this._sock.rQshift16();this._sock.rQskipBytes(2);let w=(x+b+v)*16;if(this._sock.rQwait("TightVNC extended server init header",w,32+h))return!1;this._sock.rQskipBytes(16*x),this._sock.rQskipBytes(16*b),this._sock.rQskipBytes(16*v)}return Qe("Screen: "+t+"x"+n+", bpp: "+r+", depth: "+o+", bigEndian: "+s+", trueColor: "+i+", redMax: "+a+", greenMax: "+u+", blueMax: "+c+", redShift: "+d+", greenShift: "+p+", blueShift: "+f),this._setDesktopName(g),this._resize(t,n),this._viewOnly||this._keyboard.grab(),this._fbDepth=24,this._fbName==="Intel(r) AMT KVM"&&(Ye("Intel AMT KVM only supports 8/16 bit depths. Using low color mode."),this._fbDepth=8),e.messages.pixelFormat(this._sock,this._fbDepth,!0),this._sendEncodings(),e.messages.fbUpdateRequest(this._sock,!1,0,0,this._fbWidth,this._fbHeight),this._updateConnectionState("connected"),!0}_sendEncodings(){let t=[];t.push(ge.encodingCopyRect),this._fbDepth==24&&(Mf&&t.push(ge.encodingH264),t.push(ge.encodingTight),t.push(ge.encodingTightPNG),t.push(ge.encodingZRLE),t.push(ge.encodingJPEG),t.push(ge.encodingHextile),t.push(ge.encodingRRE),t.push(ge.encodingZlib)),t.push(ge.encodingRaw),t.push(ge.pseudoEncodingQualityLevel0+this._qualityLevel),t.push(ge.pseudoEncodingCompressLevel0+this._compressionLevel),t.push(ge.pseudoEncodingDesktopSize),t.push(ge.pseudoEncodingLastRect),t.push(ge.pseudoEncodingQEMUExtendedKeyEvent),t.push(ge.pseudoEncodingQEMULedEvent),t.push(ge.pseudoEncodingExtendedDesktopSize),t.push(ge.pseudoEncodingXvp),t.push(ge.pseudoEncodingFence),t.push(ge.pseudoEncodingContinuousUpdates),t.push(ge.pseudoEncodingDesktopName),t.push(ge.pseudoEncodingExtendedClipboard),t.push(ge.pseudoEncodingExtendedMouseButtons),this._fbDepth==24&&(t.push(ge.pseudoEncodingVMwareCursor),t.push(ge.pseudoEncodingCursor)),e.messages.clientEncodings(this._sock,t)}_initMsg(){switch(this._rfbInitState){case"ProtocolVersion":return this._negotiateProtocolVersion();case"Security":return this._negotiateSecurity();case"Authentication":return this._negotiateAuthentication();case"SecurityResult":return this._handleSecurityResult();case"SecurityReason":return this._handleSecurityReason();case"ClientInitialisation":return this._sock.sQpush8(this._shared?1:0),this._sock.flush(),this._rfbInitState="ServerInitialisation",!0;case"ServerInitialisation":return this._negotiateServerInit();default:return this._fail("Unknown init state (state: "+this._rfbInitState+")")}}_resumeAuthentication(){setTimeout(this._initMsg.bind(this),0)}_handleSetColourMapMsg(){return de("SetColorMapEntries"),this._fail("Unexpected SetColorMapEntries message")}_handleServerCutText(){if(de("ServerCutText"),this._sock.rQwait("ServerCutText header",7,1))return!1;this._sock.rQskipBytes(3);let t=this._sock.rQshift32();if(t=Ti(t),this._sock.rQwait("ServerCutText content",Math.abs(t),8))return!1;if(t>=0){let n=this._sock.rQshiftStr(t);if(this._viewOnly)return!0;this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:n}}))}else{t=Math.abs(t);let n=this._sock.rQshift32(),r=n&65535,o=n&4278190080;if(!!(o&rk)){this._clipboardServerCapabilitiesFormats={},this._clipboardServerCapabilitiesActions={};for(let a=0;a<=15;a++){let u=1<<a;r&u&&(this._clipboardServerCapabilitiesFormats[u]=!0,this._sock.rQshift32())}for(let a=24;a<=31;a++){let u=1<<a;this._clipboardServerCapabilitiesActions[u]=!!(o&u)}let i=[rk,Oc,ok,aa,Lc];e.messages.extendedClipboardCaps(this._sock,i,{extendedClipboardFormatText:0})}else if(o===Oc){if(this._viewOnly)return!0;this._clipboardText!=null&&this._clipboardServerCapabilitiesActions[Lc]&&r&fn&&e.messages.extendedClipboardProvide(this._sock,[fn],[this._clipboardText])}else if(o===ok){if(this._viewOnly)return!0;this._clipboardServerCapabilitiesActions[aa]&&(this._clipboardText!=null?e.messages.extendedClipboardNotify(this._sock,[fn]):e.messages.extendedClipboardNotify(this._sock,[]))}else if(o===aa){if(this._viewOnly)return!0;this._clipboardServerCapabilitiesActions[Oc]&&r&fn&&e.messages.extendedClipboardRequest(this._sock,[fn])}else if(o===Lc){if(this._viewOnly||!(r&fn))return!0;this._clipboardText=null;let i=this._sock.rQshiftBytes(t-4),a=new Yt,u=null;a.setInput(i);for(let c=0;c<=15;c++){let d=1<<c;if(r&d){let p=0,f=a.inflate(4);p|=f[0]<<24,p|=f[1]<<16,p|=f[2]<<8,p|=f[3];let h=a.inflate(p);d===fn&&(u=h)}}if(a.setInput(null),u!==null){let c="";for(let d=0;d<u.length;d++)c+=String.fromCharCode(u[d]);u=c,u=ic(u),u.length>0&&u.charAt(u.length-1)==="\0"&&(u=u.slice(0,-1)),u=u.replaceAll(`\r
3
3
  `,`
4
4
  `),this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:u}}))}}else return this._fail("Unexpected action in extended clipboard message: "+o)}return!0}_handleServerFenceMsg(){if(this._sock.rQwait("ServerFence header",8,1))return!1;this._sock.rQskipBytes(3);let t=this._sock.rQshift32(),n=this._sock.rQshift8();if(this._sock.rQwait("ServerFence payload",n,9))return!1;n>64&&(Ye("Bad payload length ("+n+") in fence response"),n=64);let r=this._sock.rQshiftStr(n);return this._supportsFence=!0,t&1<<31?(t&=3,e.messages.clientFence(this._sock,t,r),!0):this._fail("Unexpected fence response")}_handleXvpMsg(){if(this._sock.rQwait("XVP version and message",3,1))return!1;this._sock.rQskipBytes(1);let t=this._sock.rQshift8(),n=this._sock.rQshift8();switch(n){case 0:Me("XVP operation failed");break;case 1:this._rfbXvpVer=t,Qe("XVP extensions enabled (version "+this._rfbXvpVer+")"),this._setCapability("power",!0);break;default:this._fail("Illegal server XVP message (msg: "+n+")");break}return!0}_normalMsg(){let t;this._FBU.rects>0?t=0:t=this._sock.rQshift8();let n,r;switch(t){case 0:return r=this._framebufferUpdate(),r&&!this._enabledContinuousUpdates&&e.messages.fbUpdateRequest(this._sock,!0,0,0,this._fbWidth,this._fbHeight),r;case 1:return this._handleSetColourMapMsg();case 2:return de("Bell"),this.dispatchEvent(new CustomEvent("bell",{detail:{}})),!0;case 3:return this._handleServerCutText();case 150:return n=!this._supportsContinuousUpdates,this._supportsContinuousUpdates=!0,this._enabledContinuousUpdates=!1,n&&(this._enabledContinuousUpdates=!0,this._updateContinuousUpdates(),Qe("Enabling continuous updates.")),!0;case 248:return this._handleServerFenceMsg();case 250:return this._handleXvpMsg();default:return this._fail("Unexpected server message (type "+t+")"),de("sock.rQpeekBytes(30): "+this._sock.rQpeekBytes(30)),!0}}_framebufferUpdate(){if(this._FBU.rects===0){if(this._sock.rQwait("FBU header",3,1))return!1;if(this._sock.rQskipBytes(1),this._FBU.rects=this._sock.rQshift16(),this._display.pending())return this._flushing=!0,this._display.flush().then(()=>{this._flushing=!1,this._sock.rQwait("message",1)||this._handleMessage()}),!1}for(;this._FBU.rects>0;){if(this._FBU.encoding===null){if(this._sock.rQwait("rect header",12))return!1;this._FBU.x=this._sock.rQshift16(),this._FBU.y=this._sock.rQshift16(),this._FBU.width=this._sock.rQshift16(),this._FBU.height=this._sock.rQshift16(),this._FBU.encoding=this._sock.rQshift32(),this._FBU.encoding>>=0}if(!this._handleRect())return!1;this._FBU.rects--,this._FBU.encoding=null}return this._display.flip(),!0}_handleRect(){switch(this._FBU.encoding){case ge.pseudoEncodingLastRect:return this._FBU.rects=1,!0;case ge.pseudoEncodingVMwareCursor:return this._handleVMwareCursor();case ge.pseudoEncodingCursor:return this._handleCursor();case ge.pseudoEncodingQEMUExtendedKeyEvent:return this._qemuExtKeyEventSupported=!0,!0;case ge.pseudoEncodingDesktopName:return this._handleDesktopName();case ge.pseudoEncodingDesktopSize:return this._resize(this._FBU.width,this._FBU.height),!0;case ge.pseudoEncodingExtendedDesktopSize:return this._handleExtendedDesktopSize();case ge.pseudoEncodingExtendedMouseButtons:return this._extendedPointerEventSupported=!0,!0;case ge.pseudoEncodingQEMULedEvent:return this._handleLedEvent();default:return this._handleDataRect()}}_handleVMwareCursor(){let t=this._FBU.x,n=this._FBU.y,r=this._FBU.width,o=this._FBU.height;if(this._sock.rQwait("VMware cursor encoding",1))return!1;let s=this._sock.rQshift8();this._sock.rQshift8();let i,a=4;if(s==0){if(i=new Array(r*o*a),this._sock.rQwait("VMware cursor classic encoding",r*o*a*2,2))return!1;let c=new Array(r*o);for(let p=0;p<r*o;p++)c[p]=this._sock.rQshift32();let d=new Array(r*o);for(let p=0;p<r*o;p++)d[p]=this._sock.rQshift32();for(let p=0;p<r*o;p++)if(c[p]==0){let f=d[p],h=f>>8&255,g=f>>16&255,x=f>>24&255;i[p*a]=h,i[p*a+1]=g,i[p*a+2]=x,i[p*a+3]=255}else(c[p]&-256)==-256?d[p]==0?(i[p*a]=0,i[p*a+1]=0,i[p*a+2]=0,i[p*a+3]=0):(d[p]&-256,i[p*a]=0,i[p*a+1]=0,i[p*a+2]=0,i[p*a+3]=255):(i[p*a]=0,i[p*a+1]=0,i[p*a+2]=0,i[p*a+3]=255)}else if(s==1){if(this._sock.rQwait("VMware cursor alpha encoding",r*o*4,2))return!1;i=new Array(r*o*a);for(let u=0;u<r*o;u++){let c=this._sock.rQshift32();i[u*4]=c>>24&255,i[u*4+1]=c>>16&255,i[u*4+2]=c>>8&255,i[u*4+3]=c&255}}else return Ye("The given cursor type is not supported: "+s+" given."),!1;return this._updateCursor(i,t,n,r,o),!0}_handleCursor(){let t=this._FBU.x,n=this._FBU.y,r=this._FBU.width,o=this._FBU.height,s=r*o*4,i=Math.ceil(r/8)*o,a=s+i;if(this._sock.rQwait("cursor encoding",a))return!1;let u=this._sock.rQshiftBytes(s),c=this._sock.rQshiftBytes(i),d=new Uint8Array(r*o*4),p=0;for(let f=0;f<o;f++)for(let h=0;h<r;h++){let g=f*Math.ceil(r/8)+Math.floor(h/8),x=c[g]<<h%8&128?255:0;d[p]=u[p+2],d[p+1]=u[p+1],d[p+2]=u[p],d[p+3]=x,p+=4}return this._updateCursor(d,t,n,r,o),!0}_handleDesktopName(){if(this._sock.rQwait("DesktopName",4))return!1;let t=this._sock.rQshift32();if(this._sock.rQwait("DesktopName",t,4))return!1;let n=this._sock.rQshiftStr(t);return n=ic(n,!0),this._setDesktopName(n),!0}_handleLedEvent(){if(this._sock.rQwait("LED status",1))return!1;let t=this._sock.rQshift8(),n=!!(t&2),r=!!(t&4);return this._remoteCapsLock=r,this._remoteNumLock=n,!0}_handleExtendedDesktopSize(){if(this._sock.rQwait("ExtendedDesktopSize",4))return!1;let t=this._sock.rQpeek8(),n=4+t*16;if(this._sock.rQwait("ExtendedDesktopSize",n))return!1;let r=!this._supportsSetDesktopSize;this._supportsSetDesktopSize=!0,this._sock.rQskipBytes(1),this._sock.rQskipBytes(3);for(let o=0;o<t;o+=1)o===0?(this._screenID=this._sock.rQshift32(),this._sock.rQskipBytes(2),this._sock.rQskipBytes(2),this._sock.rQskipBytes(2),this._sock.rQskipBytes(2),this._screenFlags=this._sock.rQshift32()):this._sock.rQskipBytes(16);if(this._FBU.x===1&&(this._pendingRemoteResize=!1),this._FBU.x===1&&this._FBU.y!==0){let o="";switch(this._FBU.y){case 1:o="Resize is administratively prohibited";break;case 2:o="Out of resources";break;case 3:o="Invalid screen layout";break;default:o="Unknown reason";break}Ye("Server did not accept the resize request: "+o)}else this._resize(this._FBU.width,this._FBU.height);return r&&this._requestRemoteResize(),this._FBU.x===1&&this._FBU.y===0&&this._requestRemoteResize(),!0}_handleDataRect(){let t=this._decoders[this._FBU.encoding];if(!t)return this._fail("Unsupported encoding (encoding: "+this._FBU.encoding+")"),!1;try{return t.decodeRect(this._FBU.x,this._FBU.y,this._FBU.width,this._FBU.height,this._sock,this._display,this._fbDepth)}catch(n){return this._fail("Error decoding rect: "+n),!1}}_updateContinuousUpdates(){this._enabledContinuousUpdates&&e.messages.enableContinuousUpdates(this._sock,!0,0,0,this._fbWidth,this._fbHeight)}_resize(t,n){this._fbWidth=t,this._fbHeight=n,this._display.resize(this._fbWidth,this._fbHeight),this._updateClip(),this._updateScale(),this._updateContinuousUpdates(),this._saveExpectedClientSize()}_xvpOp(t,n){this._rfbXvpVer<t||(Qe("Sending XVP operation "+n+" (version "+t+")"),e.messages.xvpOp(this._sock,t,n))}_updateCursor(t,n,r,o,s){this._cursorImage={rgbaPixels:t,hotx:n,hoty:r,w:o,h:s},this._refreshCursor()}_shouldShowDotCursor(){if(!this._showDotCursor)return!1;for(let t=3;t<this._cursorImage.rgbaPixels.length;t+=4)if(this._cursorImage.rgbaPixels[t])return!1;return!0}_refreshCursor(){if(this._rfbConnectionState!=="connecting"&&this._rfbConnectionState!=="connected")return;let t=this._shouldShowDotCursor()?e.cursors.dot:this._cursorImage;this._cursor.change(t.rgbaPixels,t.hotx,t.hoty,t.w,t.h)}static genDES(t,n){let r=t.split("").map(s=>s.charCodeAt(0)),o=Xe.importKey("raw",r,{name:"DES-ECB"},!1,["encrypt"]);return Xe.encrypt({name:"DES-ECB"},o,n)}};yt.messages={keyEvent(e,t,n){e.sQpush8(4),e.sQpush8(n),e.sQpush16(0),e.sQpush32(t),e.flush()},QEMUExtendedKeyEvent(e,t,n,r){function o(i){let a=r>>8,u=r&255;return a===224&&u<127?u|128:i}e.sQpush8(255),e.sQpush8(0),e.sQpush16(n),e.sQpush32(t);let s=o(r);e.sQpush32(s),e.flush()},pointerEvent(e,t,n,r){e.sQpush8(5),r=r&127,e.sQpush8(r),e.sQpush16(t),e.sQpush16(n),e.flush()},extendedPointerEvent(e,t,n,r){e.sQpush8(5);let o=r>>7&255;if(o&252)throw new Error("Invalid mouse button mask: "+r);let s=r&127;s|=128,e.sQpush8(s),e.sQpush16(t),e.sQpush16(n),e.sQpush8(o),e.flush()},_buildExtendedClipboardFlags(e,t){let n=new Uint8Array(4),r=0,o=0;for(let s=0;s<e.length;s++)o|=e[s];for(let s=0;s<t.length;s++)r|=t[s];return n[0]=o>>24,n[1]=0,n[2]=0,n[3]=r,n},extendedClipboardProvide(e,t,n){let r=new Hi,o=[];for(let a=0;a<t.length;a++){if(t[a]!=fn)throw new Error("Unsupported extended clipboard format for Provide message.");n[a]=n[a].replace(/\r\n|\r|\n/gm,`\r
@@ -139,7 +139,7 @@ Working folder: ${t.cwd}`:t.command};case"file_change":return{title:"Approve cha
139
139
  `)||"No additional access requested"}}}function j1(){let{scope:e}=Y_();return l(pu,{onlyThread:e.kind==="thread"?e.threadId:""})}function pu({onlyThread:e}){let t=J(),n=un(),[r,o]=_(null),[s,i]=_(null),a=Y(()=>{});if(K(()=>{let d=!0,p=!1,f=!1,h,g=async()=>{if(p){f=!0;return}clearTimeout(h),p=!0;do{f=!1;try{let v=await t.call("work.parents",null);if(e!==void 0&&e!==v.orbit)d&&!f&&(o({orbit:v.orbit,jobs:[],warning:null}),i(null));else{let{jobs:w,errors:C}=await du(n,v);d&&!f&&(o(y=>({orbit:v.orbit,jobs:[...w,...y?.jobs.filter(T=>C.includes(T.interaction.threadId))??[]],warning:C.length?"Some work could not be checked. Trying again.":null})),i(null))}}catch{d&&!f&&i("Could not check waiting work. Trying again.")}}while(d&&f);p=!1,d&&(h=setTimeout(()=>{g()},5e3))};a.current=()=>{g()};let x=n.subscribe({event:"thread:changed",callback:v=>{v.changes.some(w=>["interactions-changed","thread-created","thread-deleted","parent-changed","archived-changed"].includes(w))&&g()}}),b=n.subscribe({event:"realtime:connection",callback:v=>{v.state==="connected"&&g()}});return g(),()=>{d=!1,a.current=()=>{},clearTimeout(h),x(),b()}},[t,n,e]),e!==void 0&&r&&r.orbit!==e)return null;let u=r?.jobs.filter(d=>d.interaction.threadId!==e)??[],c=s||r?.warning;return e!==void 0&&!u.length?c?l("p",{role:"alert",className:"text-sm",children:c}):null:m("section",{"aria-label":"Waiting for you",className:"max-h-[50vh] space-y-3 overflow-auto rounded-md border p-3 text-sm",children:[l("h2",{className:"font-medium",children:"Waiting for you"}),(s||r?.warning)&&l("p",{role:"alert",children:s||r?.warning}),!r&&!s&&l("p",{children:"Checking work\u2026"}),r&&!u.length&&!s&&!r.warning&&l("p",{children:"No questions or approvals waiting."}),u.map(d=>l($I,{job:d,sdk:n,done:()=>{o(p=>p&&{...p,jobs:p.jobs.filter(f=>f.interaction.id!==d.interaction.id)}),a.current()}},d.interaction.id))]})}function $I({job:e,sdk:t,done:n}){let{interaction:r}=e,o=Ie(),[s,i]=_(!1),a=Y(!1),[u,c]=_(null),[d,p]=_({}),f=r.payload,h=async v=>{if(a.current)return!1;a.current=!0,i(!0),c(null);try{let w=await t.threads.interactions.get({threadId:r.threadId,interactionId:r.id});return w.status!=="pending"||w.expiresAt!=null&&w.expiresAt<=Date.now()?(n(),!0):(await v(w),n(),!0)}catch{return c("The answer did not go through. Check the work and try again."),!1}finally{a.current=!1,i(!1)}},g={threadId:r.threadId,interactionId:r.id},x=v=>h(()=>t.threads.interactions.resolve({...g,resolution:v})),b;if(f.kind==="approval"){let v=W1(f);b=m("div",{className:"space-y-2",children:[l("p",{children:v.title}),f.reason&&l("p",{children:f.reason}),l("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words",children:v.detail}),m("div",{className:"flex gap-2",children:[l(R,{disabled:s||!f.availableDecisions.includes("allow_once"),onClick:()=>{x({decision:"allow_once",grantedPermissions:f.subject.kind==="permission_grant"?f.subject.permissions:null})},children:"Approve"}),l(R,{variant:"destructive",disabled:s||!f.availableDecisions.includes("deny"),onClick:()=>{x({decision:"deny"})},children:"Decline"})]})]})}else if(f.kind==="user_question")b=m("form",{className:"space-y-3",onSubmit:v=>{v.preventDefault(),sm(f.questions,d)&&x({kind:"user_answer",answers:d})},children:[f.questions.map(v=>m("fieldset",{disabled:s,className:"space-y-2",children:[l("legend",{children:v.prompt}),v.options?.map(w=>m("label",{className:"block",children:[l("input",{type:v.multiSelect?"checkbox":"radio",name:`${r.id}-${v.id}`,checked:d[v.id]?.selected.includes(w.value)??!1,onChange:C=>p(y=>({...y,[v.id]:{...v.multiSelect?y[v.id]:{},selected:v.multiSelect?C.target.checked?[...y[v.id]?.selected??[],w.value]:(y[v.id]?.selected??[]).filter(T=>T!==w.value):[w.value]}}))})," ",w.label,w.description&&l("span",{className:"block text-xs text-muted-foreground",children:w.description})]},w.value)),v.allowFreeText&&m("label",{className:"block",children:["Your answer",l("textarea",{className:"block w-full rounded border bg-background p-2",value:d[v.id]?.freeText??"",onChange:w=>p(C=>({...C,[v.id]:{selected:v.multiSelect?C[v.id]?.selected??[]:[],freeText:w.target.value}}))})]})]},v.id)),m("div",{className:"flex gap-2",children:[l(R,{type:"submit",disabled:s||!sm(f.questions,d),children:"Send answer"}),l(R,{type:"button",variant:"destructive",disabled:s,onClick:()=>{h(()=>t.threads.stop({threadId:r.threadId}))},children:"Stop work"})]}),l("p",{className:"text-xs text-muted-foreground",children:"Stop work stops this work, including the question it is waiting on."})]});else if(f.kind==="plugin"&&r.origin?.kind==="plugin"&&r.origin.pluginId==="orbit"){let v={interaction:{id:r.id,threadId:r.threadId,title:f.title,payload:f.data,createdAt:r.createdAt,expiresAt:r.expiresAt??null},submit:async w=>{if(!await h(()=>t.threads.interactions.respond({...g,value:w})))throw new Error("Answer failed")},cancel:async()=>{if(!await h(()=>t.threads.interactions.cancel(g)))throw new Error("Answer failed")}};b=r.origin.rendererId==="approval"?l(tc,{...v}):r.origin.rendererId==="policy-proposal"?l(rc,{...v}):r.origin.rendererId==="owner-changes"?l(sc,{...v}):r.origin.rendererId==="station-manager"?l(nc,{...v}):l("p",{children:"Open the work to answer this request."})}else b=l("p",{children:"Open the work to answer this request."});return m("article",{className:"space-y-2 rounded border p-3","aria-busy":s,children:[l("h3",{className:"font-medium",children:e.title}),l("fieldset",{disabled:s,children:b}),l(R,{variant:"ghost",onClick:()=>o.toThread(r.threadId),children:"Open work"}),u&&l("p",{role:"alert",children:u})]})}function Q1(){return m("main",{className:"mx-auto max-w-3xl p-4",children:[l("h1",{className:"mb-4 text-lg font-medium",children:"Your moonlet"}),l(pu,{}),l(Ci,{})]})}var fu="tasks",hu=[{id:"today",label:"Today"},{id:"upcoming",label:"Upcoming"},{id:"waiting",label:"Waiting on others"},{id:"scheduled",label:"Scheduled and watched"},{id:"journal",label:"Journal"},{id:"done",label:"Done"}],II=e=>hu.some(t=>t.id===e);function am(e){let[t,n]=(e??"").split("/").filter(Boolean);return{view:II(t)?t:"today",task:n?decodeURIComponent(n):null}}function en(){let e=Ie();return q((t,n=null)=>e.toPluginPanel(fu,{subPath:n?`${t}/${encodeURIComponent(n)}`:t}),[e])}function nt(){return J()}function We(e,t){let[n,r]=_(null),[o,s]=_(""),[i,a]=_(0),u=Y(e);u.current=e;let c=q(()=>a(d=>d+1),[]);return K(()=>{let d=!0;return u.current().then(p=>{d&&(r(p),s(""))},p=>d&&s(p instanceof Error?p.message:String(p))),()=>{d=!1}},[i,...t]),K(()=>{let d=setInterval(c,6e4);return()=>clearInterval(d)},[c]),ke("tasks",c),{data:n,error:o,reload:c}}function ds(){let e=nt();return We(()=>e.call("tasks.meta",null),[e]).data}function Ea(){let e=nt(),[t,n]=_(""),[r,o]=_(!1);return{change:q(async i=>{o(!0);try{let a=await e.call("tasks.change",i);return n(""),a}catch(a){return n(a instanceof Error?a.message:String(a)),null}finally{o(!1)}},[e]),error:t,busy:r,clearError:()=>n("")}}var PI={todo:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",followup:"M5 2h14M5 22h14M7 2v2.5C7 6.7 9 8.2 12 12c3-3.8 5-5.3 5-7.5V2M7 22v-2.5C7 17.3 9 15.8 12 12c3 3.8 5 5.3 5 7.5V22",once:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0",repeat:"m17 2 4 4-4 4M3 11v-1a4 4 0 0 1 4-4h14M7 22l-4-4 4-4M21 13v1a4 4 0 0 1-4 4H3",watch:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"};function jr(e){return e.kind==="followup"?"followup":e.kind==="scheduled"?e.when?.form==="repeat"?"repeat":"once":"todo"}function Ht({glyph:e,className:t}){return l("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:V("size-4 shrink-0",t),children:l("path",{d:PI[e]})})}var mu={todo:"To-do",followup:"Follow-up",scheduled:"Scheduled"},cs={urgent:"Urgent",high:"High",medium:"Medium",low:"Low",none:"No priority"};function us({level:e,withLabel:t=!1}){let n={urgent:3,high:3,medium:2,low:1,none:0}[e];return m("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs font-medium",title:`${cs[e]} priority`,children:[e==="urgent"?m("svg",{viewBox:"0 0 16 14",className:"h-3.5 w-4",role:"img","aria-label":"Urgent priority",children:[l("rect",{x:"1",y:"0",width:"14",height:"14",rx:"3.5",className:"fill-destructive"}),l("rect",{x:"7.1",y:"3",width:"1.8",height:"5.2",rx:".9",className:"fill-destructive-foreground"}),l("circle",{cx:"8",cy:"10.4",r:"1.05",className:"fill-destructive-foreground"})]}):l("svg",{viewBox:"0 0 16 14",className:"h-3.5 w-4",role:"img","aria-label":`${cs[e]} priority`,children:[[1.5,8,5],[6.5,4.5,8.5],[11.5,1,12]].map(([r,o,s],i)=>l("rect",{x:r,y:o,width:"3",height:s,rx:"1",className:i<n?"fill-foreground/70":"fill-foreground/15"},r))}),t?l("span",{children:cs[e]}):null]})}function De({origin:e,assistant:t,size:n=16}){return e==="assistant"?m("svg",{viewBox:"0 0 26 26",width:n,height:n,role:"img","aria-label":`Added by ${t}`,className:"shrink-0",children:[l("title",{children:`Added by ${t}`}),l("circle",{cx:"13",cy:"13",r:"13",style:{fill:"var(--moonlet-night, var(--color-foreground))"}}),l("circle",{cx:"13",cy:"13",r:"8",style:{fill:"var(--moonlet-moon-gold, var(--color-primary))"}}),l("circle",{cx:"10.3",cy:"10.8",r:"1.8",style:{fill:"var(--moonlet-moon-deep, var(--color-primary))"}}),l("circle",{cx:"15.3",cy:"15.6",r:"1.25",style:{fill:"var(--moonlet-moon-deep, var(--color-primary))"}})]}):m("svg",{viewBox:"0 0 26 26",width:n,height:n,role:"img","aria-label":"From you",className:"shrink-0",children:[l("title",{children:"From you"}),l("circle",{cx:"13",cy:"13",r:"12.25",className:"fill-muted stroke-border",strokeWidth:"1.5"}),l("circle",{cx:"13",cy:"10.4",r:"3.6",className:"fill-foreground/70"}),l("path",{d:"M6.6 20.2c1.3-3 3.6-4.5 6.4-4.5s5.1 1.5 6.4 4.5",className:"fill-foreground/70"})]})}function Sa({task:e,now:t,quiet:n=!1}){if(!e.whenText)return null;let r=e.dueAt!==null&&e.dueAt<t&&e.move!=="others",o=r||e.priority==="urgent"?"urgent":e.priority==="high"?"high":"plain";return l("span",{className:V("shrink-0 whitespace-nowrap rounded-md px-2 py-0.5 text-xs font-semibold",n&&o==="plain"?"px-0 font-medium text-muted-foreground":"",o==="urgent"&&"bg-surface-destructive text-destructive-text",o==="high"&&"bg-warning/15 text-warning-text",o==="plain"&&!n&&"bg-muted text-foreground"),children:r?`Late \xB7 ${e.whenText}`:Qr(e.whenText)})}var Qr=e=>e.charAt(0).toUpperCase()+e.slice(1);function Na({project:e}){return e.id==="personal"?null:l("span",{className:"inline-flex shrink-0 items-center rounded-md border border-border-hairline px-1.5 text-2xs font-semibold tracking-wide text-muted-foreground",title:e.name,children:e.key})}function lm({task:e,onToggle:t,busy:n}){let r=e.status==="done";return l("button",{type:"button","aria-label":r?`Reopen ${e.title}`:`Mark ${e.title} done`,"aria-pressed":r,disabled:n,onClick:o=>{o.stopPropagation(),t()},className:V("mt-0.5 grid size-5 shrink-0 cursor-pointer place-items-center rounded-full border-[1.5px] transition-colors",r?"border-foreground bg-foreground text-background":"border-foreground/35 hover:border-foreground/70 hover:bg-state-hover"),children:r?l("svg",{viewBox:"0 0 24 24",className:"size-3",fill:"none",stroke:"currentColor",strokeWidth:"3.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:l("path",{d:"M20 6 9 17l-5-5"})}):null})}function OI(e,t){return e.origin==="assistant"?`Added by ${t}${e.why?` \xB7 ${e.why}`:""}`:e.source?.kind==="import"?`From you \xB7 carried over from ${e.source.ref}`:"From you"}function q1({task:e,assistant:t,now:n,rich:r=!1,onOpen:o,onToggle:s,trailing:i,first:a}){let u=jr(e),c=e.move==="others"?`Waiting on ${e.waitingOn??"someone"}`:r?OI(e,t):e.say??e.why??e.description.split(`
140
140
  `)[0]??"";return m("div",{className:V("group flex items-start gap-3 px-4 transition-colors hover:bg-state-hover",r?"py-3.5":"py-2.5",!a&&"border-t border-border-hairline"),children:[l(lm,{task:e,onToggle:s}),m("button",{type:"button",onClick:o,className:"min-w-0 flex-1 cursor-pointer text-left",children:[m("span",{className:"flex min-w-0 items-center gap-2",children:[r?null:l(Ht,{glyph:u,className:"text-timeline-accent"}),l("span",{className:V("truncate",r?"text-base font-semibold":"text-sm font-medium"),children:e.title}),l(De,{origin:e.origin,assistant:t,size:15}),l(Na,{project:e.project}),e.watch?l(Ht,{glyph:"watch",className:"size-3.5 text-timeline-accent"}):null]}),r?m("span",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[l(Ht,{glyph:u,className:"size-3.5 text-foreground/70"}),l("span",{className:"shrink-0 font-medium text-foreground/80",children:mu[e.kind]}),l("span",{"aria-hidden":!0,children:"\xB7"}),l("span",{className:"truncate",children:c})]}):c?l("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:c}):null,m("span",{className:"mt-1.5 flex items-center gap-2 sm:hidden",children:[l(Sa,{task:e,now:n,quiet:!r}),l(us,{level:e.priority})]}),r&&e.say?m("span",{className:"mt-2 flex max-w-2xl items-start gap-2 rounded-lg bg-surface-selected px-3 py-2 text-sm leading-snug",children:[l(De,{origin:"assistant",assistant:t,size:16}),l("span",{children:e.say})]}):null]}),m("span",{className:"hidden shrink-0 items-center gap-2.5 pt-0.5 sm:flex",children:[i,l(Sa,{task:e,now:n,quiet:!r}),l(us,{level:e.priority})]})]})}function Dn({title:e,count:t,hint:n,children:r,action:o}){return m("section",{className:"space-y-2.5",children:[m("div",{className:"flex items-center gap-2",children:[l("h2",{className:"text-sm font-semibold",children:e}),t!==void 0?l("span",{className:"rounded-full bg-muted px-2 text-xs font-semibold text-muted-foreground",children:t}):null,n?l("span",{className:"ml-auto text-xs text-muted-foreground",children:n}):null,o]}),l("div",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:r})]})}function Oe({children:e}){return l("p",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:e})}function _t({label:e,value:t,options:n,onChange:r}){return l("div",{role:"radiogroup","aria-label":e,className:"inline-flex gap-0.5 rounded-lg bg-muted p-0.5",children:n.map(o=>l("button",{type:"button",role:"radio","aria-checked":t===o.value,onClick:()=>r(o.value),className:V("inline-flex cursor-pointer items-center gap-1.5 rounded-md px-3 py-1 text-xs font-semibold transition-colors",t===o.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:o.label},o.value))})}var J1="moonlet.tasks.filters";function LI(){try{let e=JSON.parse(globalThis.localStorage?.getItem(J1)??"null");if(e&&typeof e=="object"&&"origin"in e&&"project"in e)return{origin:e.origin==="owner"||e.origin==="assistant"?e.origin:"all",project:typeof e.project=="string"?e.project:""}}catch{}return{origin:"all",project:""}}var eS=null,im=new Set;function xn(e){eS=e;try{globalThis.localStorage?.setItem(J1,JSON.stringify(e))}catch{}for(let t of im)t()}function cm(){return[xt(t=>(im.add(t),()=>im.delete(t)),()=>eS??=LI()),xn]}var ps=e=>({...e.project?{project:e.project}:{},...e.origin!=="all"?{origin:e.origin}:{}});function Gr({filters:e,onChange:t,meta:n,children:r,origin:o=!0}){let s=n?.assistant??"Assistant";return m("div",{className:"flex flex-wrap items-center gap-3",children:[o?l(_t,{label:"Show tasks from",value:e.origin,onChange:i=>t({...e,origin:i}),options:[{value:"all",label:"All"},{value:"owner",label:m(he,{children:[l(De,{origin:"owner",assistant:s,size:14}),"From you"]})},{value:"assistant",label:m(he,{children:[l(De,{origin:"assistant",assistant:s,size:14}),`${s}\u2019s own`]})}]}):null,m("label",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:["Project",m("select",{value:e.project,onChange:i=>t({...e,project:i.target.value}),className:"h-8 cursor-pointer rounded-md border border-input bg-background px-2 text-xs font-medium text-foreground",children:[l("option",{value:"",children:"All projects"}),(n?.projects??[]).map(i=>m("option",{value:i.id,children:[i.name," (",i.key,")"]},i.id))]})]}),r]})}function fs(){let[e,t]=_(()=>Date.now());return K(()=>{let n=setInterval(()=>t(Date.now()),3e4);return()=>clearInterval(n)},[]),e}var G1=new Map;function Ge(e,t,n){let r=`${t}|${JSON.stringify(n)}`,o=G1.get(r);return o||(o=new Intl.DateTimeFormat(void 0,{timeZone:t,...n}),G1.set(r,o)),o.format(new Date(e))}var Ee=(e,t)=>Ge(e,t,{hour:"numeric",minute:"2-digit"}),Y1=new Map;function hs(e,t){let n=Y1.get(t);return n||(n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}),Y1.set(t,n)),n.format(new Date(e))}function Ct(e,t="long"){let n=Date.parse(`${e}T12:00:00Z`);return Ge(n,"UTC",t==="long"?{weekday:"long",day:"numeric",month:"long"}:{weekday:"short",day:"numeric",month:"short"})}var ur=(e,t="short")=>Ge(Date.parse(`${e}T12:00:00Z`),"UTC",{weekday:t});function Yr(e,t){return new Date(Date.parse(`${e}T12:00:00Z`)+t*864e5).toISOString().slice(0,10)}function tS(){let e=J(),[t,n]=_(null),[r,o]=_(null),s=u=>o(u instanceof Error?u.message:String(u)),i=q(()=>{e.call("owner-changes.history",null).then(u=>n(u.declines),s)},[e]);K(i,[i]),ke("config",i),ke("owner-changes",i);let a=u=>{e.call("owner-changes.forget",{target:u}).then(()=>{o("Forgotten."),i()},s)};return m("section",{className:"space-y-2 text-sm","aria-label":"Declines your moonlet remembers",children:[l("h2",{className:"text-sm font-semibold",children:"Declines your moonlet remembers"}),l("p",{className:"text-xs text-muted-foreground",children:"For 30 days after you decline a change, your moonlet doesn't ask about the same thing again unless it has changed. Forget lets it ask now."}),r&&l("p",{role:"status",children:r}),t===null?null:t.length?l("ul",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised",children:t.map((u,c)=>m("li",{className:c?"flex items-center gap-3 border-t border-border-hairline px-4 py-2":"flex items-center gap-3 px-4 py-2",children:[m("span",{className:"min-w-0 flex-1",children:[u.target.replace(/^[^:]+:/,"")," \xB7 declined ",new Date(u.at).toLocaleDateString()]}),l(R,{size:"sm",variant:"ghost",onClick:()=>a(u.target),children:"Forget"})]},u.target))}):l("p",{className:"text-muted-foreground",children:"None."})]})}var Aa="activity",Jr=e=>e.charAt(0).toUpperCase()+e.slice(1),dm=["timeline","since","week","behalf"];var xs=[{id:"timeline",label:"Today",short:"Today"},{id:"since",label:"Since you looked",short:"Since you looked"},{id:"week",label:"This week",short:"This week"},{id:"behalf",label:"On your behalf",short:"On your behalf"},{id:"needs",label:"Needs you",short:"Needs you"},{id:"undo",label:"You can undo",short:"You can undo"},{id:"work",label:"Work",short:"Work"},{id:"asks",label:"Asks and approvals",short:"Asks"},{id:"messages",label:"Messages",short:"Messages"},{id:"checks",label:"Checks and routines",short:"Checks"}],pm={undo:["change","filing"],work:["work","note"],asks:["approval"],messages:["message","relay"],checks:["check"]},MI={changed:["change","filing","learned"],work:["work","note"]},DI=e=>xs.some(t=>t.id===e),FI=/^\d{4}-\d{2}-\d{2}$/,zI=e=>{let t=Date.parse(`${e}T12:00:00Z`);return Number.isFinite(t)&&new Date(t).toISOString().slice(0,10)===e};function fm(e){let[t,...n]=(e??"").split("/").filter(Boolean),r=n[0]!==void 0&&FI.test(n[0]),o=r&&zI(n[0])?n[0]:null,s=(r?n[1]:n[0])??null;return{view:DI(t)?t:"timeline",day:o,entry:s?decodeURIComponent(s):null,landing:t===void 0}}var oS=(e,t,n)=>[e,t,n===null?null:encodeURIComponent(n)].filter(r=>r!==null).join("/"),je=e=>`${e.kind}:${e.id}`,nS=new Map;function gu(e,t){let n=nS.get(t);return n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),nS.set(t,n)),Object.fromEntries(n.formatToParts(new Date(e)).flatMap(r=>r.type==="literal"?[]:[[r.type,Number(r.value)]]))}function rS(e,t){let n=gu(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour%24,n.minute,n.second)-(e-(e%1e3+1e3)%1e3)}function qr(e,t){let n=Date.parse(`${e}T00:00:00Z`),r=n-rS(n,t);return n-rS(r,t)}function tn(e,t){return new Date(Date.parse(`${e}T12:00:00Z`)+t*864e5).toISOString().slice(0,10)}function xu(e,t){return{from:qr(e,t),to:qr(tn(e,1),t)}}var sS=(e,t)=>gu(e,t).hour%24,KI=[{from:21,label:"Late evening"},{from:17,label:"Evening"},{from:12,label:"Afternoon"},{from:9,label:"Late morning"},{from:6,label:"Early morning"},{from:0,label:"Overnight"}],XI=(e,t)=>KI.find(n=>sS(e,t)>=n.from).label,BI=new Set(["running","sharing","queued","needs_person"]),ms=e=>e.kind==="work"&&e.endedAt===null&&BI.has(e.state??""),UI=e=>e.kind==="check"&&e.title.startsWith("Check:");function gs(e){let t=e.state??"";return t==="running"?"running":t==="uncertain"?"unsure":t.startsWith("error")?"failed":t.startsWith("skipped")||t==="late-skipped"||t.startsWith("interrupted")?"skipped":UI(e)?t==="quiet"||t==="completed"?"quiet":"found":"done"}var um=e=>e.kind==="check"&&(gs(e)==="quiet"||gs(e)==="done"),HI=new Set(["completed","nothing","hit","quiet","ok","sent","sent for the owner"]);function bu(e){return e.kind!=="check"||e.detail===null||HI.has(e.detail)||e.detail===e.state?null:Jr(e.detail.replace(/^(?:error(?: \(exit \d+\))?|failed): /,""))}function iS(e,t,n,r){return e.filter(o=>(t==="everything"||o.kind==="visit"||MI[t].includes(o.kind))&&(!n||_m(o,n,r)))}function aS(e,t,n){let r=e.filter(ms),o=[];for(let s of e){if(ms(s))continue;let i=XI(s.at,t),a=o.at(-1);(!a||a.label!==i)&&(a={label:i,rows:[]},o.push(a)),s.kind==="visit"?a.rows.push({type:"visit",entry:s}):a.rows.push({type:"entry",entry:s})}if(!n)return{running:r,groups:o};for(let s of o){let i=s.rows.flatMap(c=>c.type==="entry"&&um(c.entry)?[c.entry]:[]);if(i.length<2)continue;let a=s.rows.findIndex(c=>c.type==="entry"&&um(c.entry)),u=s.rows.filter(c=>!(c.type==="entry"&&um(c.entry)));u.splice(a,0,{type:"quiet",entries:i}),s.rows=u}return{running:r,groups:o}}function yu(e,t){let n=[];for(let r of e){let o=gu(r.at,t),s=`${o.year}-${String(o.month).padStart(2,"0")}-${String(o.day).padStart(2,"0")}`,i=n.at(-1);i?.day===s?i.entries.push(r):n.push({day:s,entries:[r]})}return n}var hm=[{id:"you",label:"With you"},{id:"work",label:"Work"},{id:"checks",label:"Checks"},{id:"changes",label:"Changes, asks"}];function VI(e){return e.kind==="visit"||e.actor==="owner"?"you":e.kind==="check"?"checks":e.kind==="change"||e.kind==="filing"||e.kind==="approval"||e.kind==="learned"?"changes":"work"}function lS(e,t){return e.kind==="work"&&e.ran.length?e.ran.map(n=>({from:n.from,to:n.to??t})):e.kind==="work"||e.kind==="visit"?[{from:e.startedAt??e.at,to:e.endedAt??(ms(e)?t:null)}]:[{from:e.at,to:null}]}function _u(e,t,n){let r=t.to-t.from,o=s=>Math.min(1,Math.max(0,(s-t.from)/r));return e.flatMap(s=>lS(s,n).filter(i=>i.from<t.to&&(i.to??i.from)>=t.from).map((i,a)=>({lane:VI(s),start:o(i.from),end:i.to===null||i.to<=i.from?null:o(i.to),ref:je(s),key:`${je(s)}#${a}`})))}function mm(e,t,n){let[r,o]=e<t?[e,t]:[t,e],s=n.to-n.from,i=15*6e4,a=n.from+Math.floor(r*s/i)*i,u=n.from+Math.ceil(o*s/i)*i;return{from:a,to:Math.max(u,a+i)}}var ZI={queued:"Waiting its turn",running:"Working",sharing:"Working",needs_person:"Needs you",disposed:"Done",withdrawn:"Withdrawn",failed_before_run:"Didn\u2019t start"},WI={pending:"Waiting for your answer",applied:"Applied",undelivered:"Saved, not delivered yet",declined:"Declined",expired:"Expired",stale:"Asked again: its settings changed",withdrawn:"Withdrawn",reverted:"Undone"},jI={allow:"Allowed",deny:"Not allowed",pending:"Unanswered when Moonlet restarted"},QI={running:"Running",quiet:"Found nothing",found:"Found something",failed:"Failed",unsure:"Unsure how it went",skipped:"Skipped",done:"Done"},GI={delivered:"Delivered",read:"Delivered and read","not-woken":"Delivered, but the recipient couldn\u2019t be woken",held:"Held for you",discarded:"Discarded",refused:"Refused"},eo={work:"Work",check:"Check",change:"Change to your moonlet",filing:"Library",approval:"Approval",message:"Message",relay:"Relay",learned:"Learned",note:"Task note",visit:"Visit"};function nn(e){let t=e.state;if(t===null)return null;switch(e.kind){case"work":return e.failed&&t==="parked"?"Its last turn failed":ZI[t]??t.replaceAll("_"," ");case"check":return QI[gs(e)];case"change":return WI[t]??t;case"filing":return t==="undone"?"Undone":null;case"approval":return jI[t]??t;case"message":return GI[t]??t;case"relay":return Jr(t.replaceAll("_"," "));default:return null}}function cS(e){let t=Math.max(1,Math.round(e/6e4));if(t<60)return`${t} min`;let n=Math.floor(t/60);return t%60?`${n} h ${t%60} min`:`${n} h`}function to(e,t){if(e.kind!=="work"&&e.kind!=="visit"&&e.kind!=="check")return null;let n=e.startedAt??(e.kind==="work"?null:e.at);if(n===null)return null;let r=e.endedAt??(ms(e)?t:null);return r===null||r<n?null:cS(r-n)}var Tt=(e,t,n)=>`${e===1?"one":e} ${e===1?t:n}`;function no(e){let t=n=>e.filter(r=>r.kind===n);return{work:t("work").length,running:e.filter(ms).length,checks:t("check").length,found:t("check").filter(n=>gs(n)==="found").length,undoable:e.filter(n=>n.undo!==null).length,changes:t("change").length,filings:t("filing").length,asked:t("approval").length,allowed:t("approval").filter(n=>n.state?.startsWith("allow")).length,messages:t("message").length+t("relay").length,learned:t("learned").length}}function pr(e){return[e.work?`${Tt(e.work,"piece of work","pieces of work")}${e.running?`, ${e.running} still going`:""}`:null,e.checks?`${Tt(e.checks,"check or routine","checks and routines")}${e.found?`, ${e.found} found something`:""}`:null,e.changes||e.filings?`${Tt(e.changes+e.filings,"change","changes")}, ${e.undoable===0?"none":e.undoable} you can undo`:null,e.asked?`${Tt(e.asked,"approval","approvals")}, ${e.allowed===0?"none":e.allowed} allowed`:null,e.messages?Tt(e.messages,"message sent","messages sent"):null,e.learned?Tt(e.learned,"thing learned","things learned"):null].filter(t=>t!==null).map(Jr)}function ro(e,t,n){let r=e.changes+e.filings,o=[e.work?`I worked on ${Tt(e.work,"thing","things")}${e.running?`, and ${e.running} ${e.running===1?"is":"are"} still going`:""}.`:null,e.checks?`I ran ${Tt(e.checks,"check or routine","checks and routines")}${e.found?`, and ${Tt(e.found,"check","checks")} found something`:""}.`:null,r?`I made ${Tt(r,"change","changes")}${e.undoable===0?"":e.undoable===r?`; you can undo ${r===1?"it":"them all"}`:`; you can undo ${e.undoable}`}.`:null].filter(u=>u!==null),s={today:"So far today","so-far":"So far today",day:"That day",away:"While you were away,",week:"So far this week","past-week":"That week"}[n],i={today:"A quiet day so far.","so-far":"A quiet day so far.",day:"A quiet day.",away:"It was quiet while you were away.",week:"A quiet week so far.","past-week":"A quiet week."}[n],a=o.length?`${s} ${o.join(" ")}`:i;return n==="day"||n==="so-far"||n==="past-week"||t===null?a:`${a} ${t===0?"Nothing needs your answer.":Jr(`${Tt(t,"thing needs","things need")} your answer.`)}`}function Fn(e,t){let n=Math.floor(e/36e5);if(n<1)return cS(e);if(n<24)return t==="short"?`${n} h`:`${n} ${n===1?"hour":"hours"}`;if(t==="short"){let s=Math.round(n/12)/2;return s===1?"1 day":`${Math.floor(s)}${Number.isInteger(s)?"":"\xBD"} days`}let r=Math.floor(n/24),o=n%24;return`${r} ${r===1?"day":"days"}${o?`, ${o} ${o===1?"hour":"hours"}`:""}`}function bn(e,t){let n=gu(e,t);return`${n.year}-${String(n.month).padStart(2,"0")}-${String(n.day).padStart(2,"0")}`}var YI=new Intl.DateTimeFormat("en-US",{timeZone:"UTC",weekday:"long"}),qI=new Intl.DateTimeFormat("en-US",{timeZone:"UTC",weekday:"long",day:"numeric",month:"long"});function gm(e,t){let n=Date.parse(`${e}T12:00:00Z`),r=Math.round((Date.parse(`${t}T12:00:00Z`)-n)/864e5);return r===0?"Today":r===1?"Yesterday":r>1&&r<7?YI.format(n):qI.format(n)}var vu=(e,t,n,r)=>`${gm(bn(e,n),bn(t,n))} ${r(e)}`;function uS(e,t,n,r,o){let s=gm(e,bn(n,r));return e===bn(t,r)&&s!=="Today"?`${s} from ${o(t)}`:s}function wu(e,t,n,r,o){let s=gm(bn(t,r),bn(n,r)),i=s==="Today"?"":s==="Yesterday"?"yesterday ":`on ${s} `;return`${e} wrote this ${i}at ${o(t)}`}function xm(e){let t=new Date(`${e}T12:00:00Z`).getUTCDay();return tn(e,-((t+6)%7))}var bm=e=>Array.from({length:7},(t,n)=>tn(e,n));function JI(e,t,n){return Math.max(0,Math.min(t,n.to)-Math.max(e,n.from))}function ym(e,t,n){let r=0;for(let o of e)if(o.kind==="work")for(let s of o.ran)r+=JI(s.from,s.to??n,t);return r/36e5}var ku=e=>`${e<.05?0:e.toFixed(1)} h`;function dS(e,t,n){let r=new Map;for(let o of e){if(o.kind!=="work"&&o.kind!=="note"||o.task===null)continue;let s=o.task.project,i=r.get(s)??{work:[],notes:0,title:s};o.kind==="work"?i.work.push(o):i.notes++,r.set(s,i)}return[...r.entries()].map(([o,s])=>({key:o,title:s.title,hours:ym(s.work,t,n),done:s.work.filter(i=>i.state==="disposed").length,going:s.work.filter(ms).length,notes:s.notes})).sort((o,s)=>s.hours-o.hours||s.done-o.done||o.key.localeCompare(s.key))}function pS(e){let t=[e.done?Tt(e.done,"piece of work done","pieces of work done"):null,e.going?`${e.going} going`:null,e.notes?Tt(e.notes,"task note","task notes"):null].filter(n=>n!==null);return t.length?Jr(t.join(", ")):"Nothing finished yet"}function fS(e){return e.filter(t=>t.kind==="approval"&&t.startedAt!==null).map(t=>({entry:t,ms:Math.max(0,t.at-(t.startedAt??t.at))})).sort((t,n)=>n.ms-t.ms)}var eP=new Set(["failed_before_run","cut_off","withdrawn"]),tP=new Set(["refused","failed"]);function hS(e){return e.filter(t=>t.kind==="work"&&(eP.has(t.state??"")||t.failed)||t.kind==="check"&&(gs(t)==="failed"||gs(t)==="unsure")||(t.kind==="message"||t.kind==="relay")&&tP.has(t.state??""))}function _m(e,t,n){return lS(e,n).some(r=>r.to===null||r.to<=r.from?r.from>=t.from&&r.from<t.to:r.from<t.to&&r.to>t.from)}function mS(e,t,n){let r=e.to-e.from;return n.map(o=>{let s=e.from+o*36e5,i=[s,s-36e5,s+36e5].find(a=>a>=e.from&&a<e.to&&sS(a,t)===o)??s;return{hour:o,at:(i-e.from)/r}})}function bs(e,t){let n=r=>(r.kind==="work"||r.kind==="visit")&&(r.at<t.from||r.at>=t.to);return e.some(n)?e.map(r=>{if(!n(r))return r;if(r.kind==="visit")return{...r,at:Math.min(Math.max(r.at,t.from),t.to-1)};let o=r.ran.find(a=>a.from<t.to&&(a.to===null||a.to>t.from)),s=r.steps.find(a=>a.at>=t.from&&a.at<t.to),i=o?Math.max(t.from,o.from):s?s.at:Math.min(Math.max(r.at,t.from),t.to-1);return{...r,at:i}}).sort((r,o)=>o.at-r.at):e}var gS=[{id:"mail",label:"Mail sent"},{id:"signin",label:"Signed in for you"},{id:"commands",label:"Commands with your keys"},{id:"git",label:"Pushed and merged"},{id:"messages",label:"Messages"}],dr="secret-use-send",ys=e=>e===dr?"Mail":e;function xS(e,t){let n=t.filter(r=>wm(r)===e).map(r=>r.name);return e==="mail"&&!n.includes(dr)?[...n,dr]:n}var vm=(e,t)=>e===t&&e!==dr;function bS(e,t,n){let r=vm(e,t)?[e,dr]:[e],o=n.filter(s=>r.includes(s.capability));return o.length?{capability:e,uses:o.reduce((s,i)=>s+i.uses,0),changes:o.reduce((s,i)=>s+i.changes,0),asked:o.reduce((s,i)=>s+i.asked,0),refused:o.reduce((s,i)=>s+i.refused,0),last:Math.max(...o.map(s=>s.last))}:null}function wm(e){return e.kind==="mail"?"mail":e.kind==="login"?"signin":e.kind!=="cli"&&e.kind!=="ssh"?null:/mail/i.test(e.name)?"mail":/^git(hub)?\b/i.test(e.name)?"git":"commands"}var Su=[{level:"never-ask",label:"Never ask",about:"I use it without checking with you, sensitive commands included."},{level:"ask-changes",label:"Ask before changes",about:"Reading is free. A change waits for your yes, or one you already gave for it; sensitive ones ask every time."},{level:"always-ask",label:"Always ask",about:"Every use waits for your yes, or one you already gave for it; sensitive ones ask every time."},{level:"read-only",label:"Read only",about:"I can read with it but never change anything."}],km=e=>Su.find(t=>t.level===e)??null,nP={once:"You allowed it once",thread:"You allowed it for that conversation",always:"You allowed it from now on"};function yS(e){let t=e.startsWith("user: ")?nP[e.slice(6)]:void 0;return t||(e==="grant"?"Your earlier yes for this exact command":e==="thread"?"Your yes for that conversation":e==="standing decision"?"A standing permission":e.startsWith("existing owner decision")?"Your earlier decision":e==="level"||e==="read"||e==="owned-file"?"Its level allowed it":Jr(e))}function _S(e){let t=[e.uses?Tt(e.uses,"use","uses"):"no uses",e.changes?`${e.changes} changed something`:null,e.asked?`${e.asked} asked you first`:null,e.refused?`${e.refused} refused`:"none refused"].filter(n=>n!==null);return Jr(t.join(", "))}function yn(){let e=Ie();return q((t,n=null,r=null)=>e.toPluginPanel(Aa,{subPath:oS(t,r,n)}),[e])}function wS(e){ke("tasks",e),ke("approvals",e),ke("owner-changes",e),ke("config",e),ke("messages",e),ke("relay",e),ke("artifacts",e)}var kS=100;function ks(e,t,n){let r=J(),[o,s]=_(null),[i,a]=_(""),u=Y(()=>{}),c=q(()=>u.current(),[]),d=JSON.stringify([e.from,e.to,e.kinds,e.project,e.overlap===!0,e.behalf??null,t]);return K(()=>{let p=!0,f=!1,h=!1,g,x=async()=>{let v=[],w=null;for(let C=0;C<t;C++){let y=await r.call("activity.feed",{from:e.from,to:e.to,...e.kinds?{kinds:[...e.kinds]}:{},project:e.project,...e.overlap?{overlap:!0}:{},...e.behalf?{behalf:e.behalf}:{},before:w,limit:kS});if(!p)return null;if(v.push(...y.entries),w=y.next,!w)break}return{entries:v,more:w!==null}},b=async()=>{if(f){h=!0;return}f=!0,clearTimeout(g);do{h=!1;try{let v=await x();if(!p||!v)return;s({key:d,feed:v}),a("")}catch(v){if(!p)return;a(v instanceof Error?v.message:String(v))}}while(h);f=!1,g=setTimeout(()=>{b()},3e4)};return u.current=()=>{b()},b(),()=>{p=!1,clearTimeout(g),u.current=()=>{}}},[r,d,n]),wS(c),{data:o?.key===d?o.feed:null,error:i,reload:c}}function Em(){let e=J(),[t,n]=_(null),[r,o]=_(""),[s,i]=_(0);return K(()=>{let a=!0;return e.call("activity.since",null).then(u=>{a&&(n(u),o(""))},u=>a&&o(u instanceof Error?u.message:String(u))),()=>{a=!1}},[e,s]),K(()=>{let a=setInterval(()=>i(u=>u+1),6e4);return()=>clearInterval(a)},[]),{data:t,error:r}}var vS=10,Eu=60,zn=Eu*kS;function Ss(e,t){let[n,r]=_(vS),o=ks(e,n,t);K(()=>{o.data?.more&&n<Eu&&r(i=>Math.min(Eu,i+vS))},[o.data,n]);let s=o.data&&(!o.data.more||n>=Eu)?o.data:null;return{data:s,error:o.error,partial:s?.more===!0}}var rP=e=>Object.hasOwn(eo,e);function SS(e,t,n){let r=J(),[o,s]=_(0),i=q(()=>s(a=>a+1),[]);wS(i),K(()=>{if(e===null)return;let a=setInterval(i,3e4);return()=>clearInterval(a)},[e,i]),K(()=>{if(e===null)return;let a=e.indexOf(":"),u=e.slice(0,a);if(a<1||!rP(u))return;let c=!0;return r.call("activity.entry",{kind:u,id:e.slice(a+1)}).then(d=>{c&&d&&t([d])},()=>{}),()=>{c=!1}},[r,e,t,o,n])}function ES(e){let t=J(),n=J(),[r,o]=_(null),[s,i]=_(null);return{undo:q(async u=>{let c=u.undo;if(!c)return;let d=`${u.kind}:${u.id}`;i(d);try{let p=c.kind==="change"?{done:!0,text:(await t.call("owner-changes.undo",{id:c.id})).message}:await n.call("artifacts.undo",{id:c.id}).then(f=>f.state==="ok"?{done:!0,text:`Undone: ${f.summary}`}:{done:!1,text:`Not undone: ${f.reason}`});o({ref:d,...p})}catch(p){o({ref:d,done:!1,text:p instanceof Error?p.message:String(p)})}finally{i(null),e()}},[t,n,e]),said:r,busy:s}}var vs={jobs:[],held:0,checked:!1,error:null},Nu=new Set,ws=null,Sm,Au=!1,_s=!1,Ca=0;async function Cu(){if(Au){_s=!0;return}let e=Ca;clearTimeout(Sm),Au=!0;try{do{_s=!1;let t=ws;if(!t)break;try{let n=await t(vs);if(e!==Ca)return;_s||(vs={...n,checked:!0})}catch(n){if(e!==Ca)return;_s||(vs={...vs,error:n instanceof Error?n.message:String(n)})}for(let n of Nu)n()}while(_s&&ws)}finally{e===Ca&&(Au=!1,ws&&(Sm=setTimeout(()=>{Cu()},3e4)))}}function oP(e){return Nu.add(e),()=>{Nu.delete(e),!Nu.size&&(Ca++,ws=null,Au=!1,_s=!1,clearTimeout(Sm),vs={jobs:[],held:0,checked:!1,error:null})}}function Nm(){let e=un(),t=J(),n=J(),r=Y(async()=>({jobs:[],held:0,error:null}));r.current=async i=>{let[a,u]=await Promise.all([t.call("work.parents",null),n.call("messages.state",null)]),{jobs:c,errors:d}=await du(e,a),p=i.jobs.filter(f=>d.includes(f.interaction.threadId));return{jobs:[...c,...p].sort((f,h)=>f.interaction.createdAt-h.interaction.createdAt||f.interaction.id.localeCompare(h.interaction.id)),held:u.held.length,error:d.length?"Some work could not be checked. Trying again.":null}};let o=xt(oP,()=>vs);K(()=>{let i=ws===null;return ws=u=>r.current(u),i&&Cu(),e.subscribe({event:"thread:changed",callback:u=>{u.changes.some(c=>["interactions-changed","thread-created","thread-deleted","archived-changed"].includes(c))&&Cu()}})},[e]);let s=q(()=>{Cu()},[]);return ke("messages",s),ke("owner-changes",s),ke("approvals",s),o}var fr=e=>e.jobs.length+e.held,Es=e=>e.checked&&!e.error?fr(e):null;function Tu(e){let t=nt(),[n,r]=_(new Map),[o,s]=_(0),i=q(()=>s(u=>u+1),[]);ke("tasks",i),K(()=>{let u=setInterval(i,6e4);return()=>clearInterval(u)},[i]);let a=e.join(",");return K(()=>{let u=!0,c=a?a.split(","):[];return Promise.all(c.map(async d=>{let p=await t.call("tasks.journal",{day:d,limit:1});return[d,p.notes.find(f=>f.actor==="assistant")?.body??""]})).then(d=>u&&r(new Map(d.filter(([,p])=>p!==""))),()=>{}),()=>{u=!1}},[t,a,o]),n}var NS="text-sm max-md:pointer-coarse:text-base";var AS="h-[28px] w-[28px] rounded-md p-0 max-md:pointer-coarse:h-[36px] max-md:pointer-coarse:w-[36px]",HX=`${AS} [&_[data-icon-root]]:size-[16px] max-md:pointer-coarse:[&_[data-icon-root]]:size-[20px]`,VX=`${AS} [&_[data-icon-root]]:size-[13px] max-md:pointer-coarse:[&_[data-icon-root]]:size-[16px]`;var CS="h-9 max-md:pointer-coarse:h-10";var le=Tn(({className:e,type:t,...n},r)=>l("input",{type:t,autoComplete:"off",className:V(`flex w-full rounded-md border border-input bg-transparent pl-3 pr-3 py-1 ${Jl} file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,CS,NS,e),ref:r,...n}));le.displayName="Input";var sP={work:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94z",check:"M21 21l-4.3-4.3M19 11a8 8 0 1 1-16 0 8 8 0 0 1 16 0z",change:"M21 4h-7M10 4H3M21 12h-9M8 12H3M21 20h-5M12 20H3M14 2v4M8 10v4M16 18v4",filing:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z",approval:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1zM9 12l2 2 4-4",message:"M14.54 21.69a.5.5 0 0 0 .94-.03l6.5-19a.5.5 0 0 0-.64-.63l-19 6.5a.5.5 0 0 0-.03.93l7.93 3.18a2 2 0 0 1 1.11 1.11zM21.85 2.15 10.91 13.09",relay:"M15 17l5-5-5-5M4 18v-2a4 4 0 0 1 4-4h12",learned:"M12 3l1.9 5.8L20 10.7l-6.1 1.9L12 18.5l-1.9-5.9L4 10.7l6.1-1.9z",note:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z",visit:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"};function _n({kind:e,className:t}){return l("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:V("size-4 shrink-0",t),children:l("path",{d:sP[e]})})}var iP={you:"bg-foreground/55",work:"bg-timeline-accent",checks:"bg-foreground/30",changes:"bg-warning"};function aP(e,t){return[e.kind==="check"?e.title.split(":")[0]??eo.check:eo[e.kind],nn(e),to(e,t),e.task?`${e.task.key}`:null].filter(Boolean).join(" \xB7 ")}function Ta(e){return e.kind==="check"?e.title.slice(e.title.indexOf(":")+1).trim()||e.title:e.kind==="approval"?`Asked to use ${e.title}`:e.title}function lP({entry:e,meta:t}){return e.actor==="system"?l("span",{className:"mt-1 block size-3.5 shrink-0 rounded-full border border-border bg-muted",title:"Moonlet itself"}):l(De,{origin:e.actor==="owner"?"owner":"assistant",assistant:t.assistant,size:16})}function oo({entry:e,meta:t,now:n,onOpen:r,undo:o,first:s,showDay:i}){let a=Ie(),[u,c]=_(!1),d=je(e),p=bu(e),f=o.said?.ref===d?o.said:null;return m("li",{className:V("group grid grid-cols-[3.75rem_minmax(0,1fr)] gap-x-3 px-3 py-3 sm:grid-cols-[4.5rem_minmax(0,1fr)] sm:px-4",!s&&"border-t border-border-hairline"),children:[m("span",{className:"pt-0.5 text-right text-xs tabular-nums text-muted-foreground",children:[i?l("span",{className:"block",children:new Date(e.at).toLocaleDateString(void 0,{timeZone:t.zone,day:"numeric",month:"short"})}):null,Ee(e.at,t.zone)]}),m("div",{className:"min-w-0",children:[m("div",{className:"flex items-start gap-2.5",children:[l(_n,{kind:e.kind,className:V("mt-0.5",e.needsYou?"text-warning-text":"text-timeline-accent")}),m("button",{type:"button",onClick:()=>r(e),className:"min-w-0 flex-1 cursor-pointer text-left",children:[l("span",{className:V("block text-sm font-medium leading-snug",e.state==="undone"||e.state==="reverted"?"text-muted-foreground line-through":""),children:Ta(e)}),l("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:aP(e,n)}),p?l("span",{className:"mt-1 block text-sm leading-snug",children:p}):null,e.kind==="approval"&&e.detail?l("code",{className:"mt-1.5 block truncate rounded-md bg-muted px-2 py-1 font-mono text-xs",children:e.detail.split(`
141
141
  `)[0]}):e.detail&&e.kind!=="check"&&e.kind!=="message"&&e.kind!=="relay"?l("span",{className:"mt-1 line-clamp-2 block text-sm leading-snug text-foreground/85",children:e.detail}):null]}),l(lP,{entry:e,meta:t})]}),e.kind==="work"&&e.steps.length>1?m("div",{className:"mt-1.5 pl-6",children:[m("button",{type:"button","aria-expanded":u,onClick:()=>c(h=>!h),className:"inline-flex cursor-pointer items-center gap-1 text-xs font-semibold text-timeline-accent hover:underline",children:[l(pe,{name:u?"ChevronUp":"ChevronDown","aria-hidden":!0,className:"size-3"}),u?"Hide the steps":`${e.steps.length} steps`]}),u?l("ol",{className:"mt-1.5 space-y-1 border-l border-border-hairline pl-3",children:e.steps.map((h,g)=>m("li",{className:"grid grid-cols-[3.5rem_minmax(0,1fr)] gap-2 text-xs",children:[l("span",{className:"tabular-nums text-muted-foreground",children:Ee(h.at,t.zone)}),l("span",{className:"min-w-0 break-words",children:h.text})]},`${h.at}-${g}`))}):null]}):null,e.undo||e.thread&&e.kind==="work"||f?m("div",{className:"mt-2 flex flex-wrap items-center gap-2 pl-6",children:[e.undo&&!f?.done?l(R,{size:"sm",variant:"outline",disabled:o.busy!==null,onClick:()=>o.undo(e),children:"Undo"}):null,e.thread&&e.kind==="work"?l(R,{size:"sm",variant:"ghost",onClick:()=>a.toThread(e.thread),children:"Open conversation"}):null,f?l("span",{role:"status",className:f.done?"text-xs text-muted-foreground":"text-xs text-destructive",children:f.text}):null]}):null]})]})}function cP({entry:e,meta:t,now:n}){let r=to(e,n);return m("li",{className:"flex items-center gap-3 px-4 py-1.5","aria-label":`You looked in at ${Ee(e.startedAt??e.at,t.zone)}`,children:[l("span",{className:"h-px flex-1 bg-border-hairline"}),m("span",{className:"inline-flex items-center gap-1.5 text-xs font-semibold text-muted-foreground",children:[l(_n,{kind:"visit",className:"size-3.5"}),"You looked in at ",Ee(e.startedAt??e.at,t.zone),r&&r!=="1 min"?` for ${r}`:""]}),l("span",{className:"h-px flex-1 bg-border-hairline"})]})}function uP({entries:e,render:t}){let[n,r]=_(!1),o=[...new Set(e.map(s=>s.title.slice(s.title.indexOf(":")+1).trim()))];return n?l(he,{children:e.map((s,i)=>t(s,i===0))}):m("li",{className:"flex items-center gap-3 border-t border-border-hairline px-4 py-2.5 first:border-t-0",children:[l(_n,{kind:"check",className:"text-muted-foreground"}),m("span",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:[e.length," ran quietly: ",o.slice(0,3).join(", "),o.length>3?"\u2026":""]}),m("button",{type:"button",onClick:()=>r(!0),className:"cursor-pointer text-xs font-semibold text-timeline-accent hover:underline",children:["Show ",e.length]})]})}function TS({groups:e,meta:t,now:n,onOpen:r,undo:o}){let s=(i,a)=>l(oo,{entry:i,meta:t,now:n,onOpen:r,undo:o,first:a},je(i));return l(he,{children:e.map((i,a)=>m("section",{"aria-label":i.label,className:"space-y-2",children:[l("h3",{className:"px-1 text-xs font-semibold text-muted-foreground",children:i.label}),l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:i.rows.map((u,c)=>u.type==="visit"?l(cP,{entry:u.entry,meta:t,now:n},je(u.entry)):u.type==="quiet"?l(uP,{entries:u.entries,render:s},`quiet-${je(u.entries[0])}`):s(u.entry,c===0||i.rows[c-1]?.type==="visit"))})]},`${i.label}-${a}`))})}function RS({entries:e,meta:t,now:n,onOpen:r}){let o=Ie();return e.length?m("section",{"aria-label":"Right now",className:"space-y-2",children:[l("h3",{className:"px-1 text-xs font-semibold text-muted-foreground",children:"Right now"}),l("ul",{className:"space-y-2",children:e.map(s=>m("li",{className:"flex flex-wrap items-center gap-3 rounded-xl border border-timeline-accent/40 bg-surface-selected px-4 py-3",children:[m("span",{className:"relative flex size-2.5 shrink-0",children:[l("span",{className:"absolute inline-flex size-full animate-ping rounded-full bg-timeline-accent opacity-60"}),l("span",{className:"relative inline-flex size-2.5 rounded-full bg-timeline-accent"})]}),m("button",{type:"button",onClick:()=>r(s),className:"min-w-0 flex-1 cursor-pointer text-left",children:[l("span",{className:"block text-sm font-semibold leading-snug",children:Ta(s)}),l("span",{className:"block text-xs text-muted-foreground",children:[nn(s),to(s,n)?`${to(s,n)} so far`:`since ${Ee(s.at,t.zone)}`,s.task?.key].filter(Boolean).join(" \xB7 ")})]}),s.thread?l(R,{size:"sm",variant:"outline",onClick:()=>o.toThread(s.thread),children:"Open conversation"}):null]},je(s)))})]}):null}var dP=[0,3,6,9,12,15,18,21],pP=e=>e===0?"12a":e<12?`${e}a`:e===12?"12p":`${e-12}p`;function $S({entries:e,span:t,now:n,zone:r,stretch:o,onStretch:s}){let i=Y(null),[a,u]=_(null),c=_u(e,t,n),d=g=>{let x=i.current.getBoundingClientRect();return Math.min(1,Math.max(0,(g.clientX-x.left)/x.width))},p=t.to-t.from,f=a?mm(a.a,a.b,t):o,h=n>=t.from&&n<t.to?(n-t.from)/p:null;return m("section",{"aria-label":"The day by hour",className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h3",{className:"text-xs font-semibold text-muted-foreground",children:"The day"}),l("span",{className:"ml-auto text-xs text-muted-foreground",children:o?m("button",{type:"button",onClick:()=>s(null),className:"cursor-pointer font-semibold text-timeline-accent hover:underline",children:["Showing ",Ee(o.from,r),"\u2013",Ee(o.to,r)," \xB7 show the whole day"]}):l("span",{className:"hidden sm:inline",children:"Drag across it to narrow the list"})})]}),m("div",{className:"grid grid-cols-[minmax(0,1fr)] gap-x-2 rounded-xl border border-border-hairline bg-surface-raised px-3 py-2.5 sm:grid-cols-[6rem_minmax(0,1fr)]",children:[l("div",{className:"hidden flex-col gap-1 text-2xs font-medium text-muted-foreground sm:flex","aria-hidden":!0,children:hm.map(g=>l("span",{className:"flex h-3.5 items-center",children:g.label},g.id))}),m("div",{ref:i,role:"presentation",className:"relative cursor-crosshair touch-none select-none",onPointerDown:g=>{g.currentTarget.setPointerCapture(g.pointerId);let x=d(g);u({a:x,b:x})},onPointerMove:g=>a&&u({a:a.a,b:d(g)}),onPointerUp:()=>{a&&(s(Math.abs(a.b-a.a)<.01?null:mm(a.a,a.b,t)),u(null))},onPointerCancel:()=>u(null),children:[l("div",{className:"flex flex-col gap-1",children:hm.map(g=>l("div",{className:"relative my-0.75 h-2 rounded-full bg-muted",children:c.filter(x=>x.lane===g.id).map(x=>l("span",{className:V("absolute top-0 h-2 rounded-full",iP[g.id]),style:{left:`${x.start*100}%`,width:x.end===null?"0.5rem":`max(0.5rem, ${(x.end-x.start)*100}%)`}},x.key))},g.id))}),f?l("span",{className:"pointer-events-none absolute -inset-y-1 rounded-md bg-timeline-accent/15 ring-1 ring-timeline-accent/50",style:{left:`${(f.from-t.from)/p*100}%`,width:`${(f.to-f.from)/p*100}%`}}):null,h!==null?l("span",{className:"pointer-events-none absolute -inset-y-1 w-0.5 rounded-full bg-timeline-accent",style:{left:`${h*100}%`}}):null,l("div",{className:"relative mt-1.5 h-3 text-2xs text-muted-foreground","aria-hidden":!0,children:mS(t,r,dP).map(g=>l("span",{className:"absolute -translate-x-1/2 first:translate-x-0",style:{left:`${g.at*100}%`},children:pP(g.hour)},g.hour))})]})]})]})}function rn({eyebrow:e,title:t,children:n}){return m("div",{className:"flex flex-wrap items-end gap-3",children:[m("div",{className:"min-w-0 flex-1",children:[l("p",{className:"text-xs font-semibold text-muted-foreground",children:e}),l("h1",{className:"mt-0.5 text-2xl font-semibold tracking-tight",children:t})]}),n]})}function IS(e){let t=e.interaction.origin,n=t?.kind==="plugin"?t.rendererId:null;return n==="owner-changes"?"A change to your moonlet":n==="policy-proposal"?"A permission to decide":n==="approval"||e.interaction.payload.kind==="approval"?"An approval":"A question"}function Ns({needs:e,title:t="Needs you",hint:n="Stays here until you answer",now:r}){let o=yn(),s=fr(e);return!s&&!e.error?null:m("section",{"aria-label":t,className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:t}),s?l("span",{className:"rounded-full bg-warning/15 px-2 text-xs font-semibold text-warning-text",children:s}):null,l("span",{className:"ml-auto text-xs text-muted-foreground",children:n})]}),m("ul",{className:"overflow-hidden rounded-xl border border-warning/40 bg-surface-raised shadow-sm",children:[e.jobs.slice(0,4).map((i,a)=>m("li",{className:V("flex items-center gap-3 px-4 py-3",a>0&&"border-t border-border-hairline"),children:[l(_n,{kind:"approval",className:"text-warning-text"}),m("span",{className:"min-w-0 flex-1",children:[l("span",{className:"block text-xs text-muted-foreground",children:r===void 0?IS(i):`Waiting ${Fn(r-i.interaction.createdAt,"long")} \xB7 ${IS(i).toLowerCase()}`}),l("span",{className:"block truncate text-sm font-medium",children:i.title})]}),l(R,{size:"sm",variant:"outline",onClick:()=>o("needs"),children:"Answer"})]},i.interaction.id)),e.jobs.length>4?m("li",{className:"border-t border-border-hairline px-4 py-2.5 text-sm text-muted-foreground",children:[e.jobs.length-4," more in Needs you"]}):null,e.held?m("li",{className:V("flex items-center gap-3 px-4 py-3",e.jobs.length>0&&"border-t border-border-hairline"),children:[l(_n,{kind:"message",className:"text-warning-text"}),m("span",{className:"min-w-0 flex-1",children:[l("span",{className:"block text-xs text-muted-foreground",children:"Held messages"}),m("span",{className:"block text-sm font-medium",children:[e.held===1?"A message":`${e.held} messages`," from outside your conversations, waiting for your yes"]})]}),l(R,{size:"sm",variant:"outline",onClick:()=>o("needs"),children:"Read"})]}):null,e.error?l("li",{role:"status",className:V("px-4 py-2.5 text-sm text-muted-foreground",s>0&&"border-t border-border-hairline"),children:e.error}):null]})]})}var Am=864e5,fP=366*Am,Ru="standing";function hP(){let e=J(),t=We(()=>e.call("approvals.state",null),[e]);return ke("approvals",t.reload),t}function mP(e,t,n){return e==="month"?n-30*Am:e==="year"?qr(`${t.today.slice(0,4)}-01-01`,t.zone):null}function gP({entry:e,meta:t,levels:n,open:r,first:o}){let s=Ie(),i=e.kind==="approval",a=e.steps[0]?.text??"",u=i?n.get(e.title):void 0;return m("li",{className:V("grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1 px-4 py-3 sm:grid-cols-[4rem_minmax(0,1fr)_auto]",!o&&"border-t border-border-hairline"),children:[m("span",{className:"col-span-2 text-xs tabular-nums text-muted-foreground sm:col-span-1 sm:pt-0.5 sm:text-right",children:[m("span",{className:"sm:block",children:[Ge(e.at,t.zone,{weekday:"short"})," ",Ge(e.at,t.zone,{day:"numeric"})]}),l("span",{className:"sm:hidden",children:" \xB7 "}),Ee(e.at,t.zone)]}),m("div",{className:"flex min-w-0 items-start gap-2.5",children:[l(_n,{kind:e.kind,className:"mt-0.5 text-timeline-accent"}),m("button",{type:"button",onClick:()=>r(e),className:"min-w-0 flex-1 cursor-pointer text-left",children:[l("span",{className:"block break-words text-sm font-medium leading-snug",children:i?(e.detail??e.title).split(`
142
- `)[0]:e.title}),m("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:[i?`Used ${ys(e.title)}`:e.kind==="relay"?"Relayed to another machine":"Message to another conversation",!i&&nn(e)?` \xB7 ${nn(e)}`:""]}),i?m("span",{className:"mt-1 flex flex-wrap items-center gap-2 text-xs",children:[l("span",{className:"font-medium",children:yS(a)}),u?m("span",{className:"rounded-md border border-border-hairline px-1.5 py-0.5 text-muted-foreground",children:[ys(e.title)," now: ",km(u)?.label.toLowerCase()??u]}):null]}):null]})]}),e.thread?m(R,{size:"sm",variant:"ghost","aria-label":"Conversation",onClick:()=>s.toThread(e.thread),children:[l(pe,{name:"MessageSquare","aria-hidden":!0,className:"size-4 sm:hidden"}),l("span",{className:"hidden sm:inline",children:"Conversation"})]}):l("span",{})]})}function xP({meta:e,now:t,state:n}){let r=J(),o=J(),[s]=_(()=>Date.now()-30*Am),i=We(()=>o.call("activity.permissionUse",{from:s}),[o,s]);ke("approvals",i.reload);let[a,u]=_(null);if(!n.data||!i.data)return l("p",{className:"text-sm text-muted-foreground",children:n.error||i.error||"Loading\u2026"});let{mailSend:c}=n.data,d=n.data.capabilities.filter(y=>wm(y)!==null),p=i.data,f=y=>bS(y,c,p),h=y=>{let T=f(y);return T!==null&&(T.uses>0||T.refused>0)},g=d.filter(y=>h(y.name)),x=d.filter(y=>!h(y.name)),b=n.data.standing.filter(y=>!y.revoked&&!y.expired),v=(y,T,N)=>{let S=Su.find($=>$.level===N);S&&r.call("approvals.setCapability",{name:y,settings:{...T,level:S.level}}).then(()=>{u({key:y,text:`Now ${S.label.toLowerCase()}.`}),n.reload()},$=>u({key:y,text:$ instanceof Error?$.message:String($)}))},w=y=>{r.call("approvals.requestStandingRevoke",{id:y.id}).then(T=>{u({key:Ru,text:T.decision==="allow"?`Revoked: ${y.description}.`:T.decision==="pending"?`Asked to revoke ${y.description}; it ends once you confirm.`:T.reason??`${y.description} wasn\u2019t revoked.`}),n.reload()},T=>u({key:Ru,text:T instanceof Error?T.message:String(T)}))},C=y=>l("select",{"aria-label":`${ys(y.name)}: when to ask`,value:y.settings.level,onChange:T=>v(y.name,y.settings,T.target.value),className:"h-7 cursor-pointer rounded-md border border-input bg-background px-1.5 text-xs font-medium",children:Su.map(T=>l("option",{value:T.level,title:T.about,children:T.label},T.level))});return m("div",{className:"space-y-3",children:[g.map(y=>{let T=f(y.name);return m("div",{className:"space-y-1 rounded-xl border border-border-hairline bg-surface-raised px-3 py-2.5",children:[m("div",{className:"flex items-center gap-2",children:[l("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:ys(y.name)}),C(y)]}),l("p",{className:"text-xs text-muted-foreground",children:km(y.settings.level)?.about}),vm(y.name,c)?l("p",{className:"text-xs text-muted-foreground",children:"Its level also decides the mail I send."}):null,l("p",{className:"text-sm",children:_S(T)}),m("p",{className:"text-xs text-muted-foreground",children:["Last: ",vu(T.last,t,e.zone,N=>Ee(N,e.zone))]}),a?.key===y.name?l("p",{role:"status",className:"text-xs text-muted-foreground",children:a.text}):null]},y.name)}),b.length||a?.key===Ru?m("div",{className:"space-y-2",children:[l("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Standing permissions"}),b.map(y=>m("div",{className:"space-y-1 rounded-xl border border-border-hairline bg-surface-raised px-3 py-2.5",children:[l("p",{className:"text-sm",children:y.description}),m("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[m("span",{className:"min-w-0 flex-1",children:["On ",y.station,y.expiresAt!==null?`, until ${Ge(y.expiresAt,e.zone,{day:"numeric",month:"short"})}`:""]}),l(R,{size:"sm",variant:"outline",onClick:()=>w(y),children:"Revoke"})]})]},y.id)),a?.key===Ru?l("p",{role:"status",className:"text-xs text-muted-foreground",children:a.text}):null]}):null,x.length?m("div",{className:"space-y-1.5",children:[l("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Not used in 30 days"}),x.map(y=>m("div",{className:"flex items-center gap-2 text-sm",children:[l("span",{className:"min-w-0 flex-1 truncate",children:ys(y.name)}),C(y)]},y.name)),l("p",{className:"text-xs leading-snug text-muted-foreground",children:"You might not need these any more; Read only is the tightest."})]}):null,l("p",{className:"text-xs leading-snug text-muted-foreground",children:"Sensitive commands and how long questions wait are in Settings \u2192 Permissions."})]})}function PS({meta:e,now:t,open:n,signal:r,remember:o}){let s=J(),i=hP(),[a,u]=_(""),[c,d]=_(""),[p,f]=_("all"),[h,g]=_("anyone"),[x,b]=_(()=>({when:"all",chosen:Date.now()})),v=x.when,[w,C]=_(1),[y]=_(()=>Date.now()+fP);K(()=>{let j=setTimeout(()=>d(a.trim()),250);return()=>clearTimeout(j)},[a]),K(()=>C(1),[c,p,h,v]);let T=mP(v,e,x.chosen),N=i.data?.capabilities??[],S=j=>xS(j,N),$=We(()=>s.call("activity.behalfCounts",{from:T}),[s,T]),{data:P,error:L}=ks({from:T??0,to:y,kinds:p==="all"?null:p==="messages"?["message","relay"]:["approval"],project:null,behalf:{capabilities:p==="all"||p==="messages"?null:S(p),search:c||null,who:h}},w,r);K(()=>{P&&o(P.entries)},[P,o]);let ne=new Map(N.map(j=>[j.name,j.settings.level])),se=i.data?ne.get(i.data.mailSend):void 0;se&&!ne.has(dr)&&ne.set(dr,se);let _e=j=>j==="messages"?$.data?.messages??0:($.data?.capabilities??[]).filter(G=>S(j).includes(G.capability)).reduce((G,ee)=>G+ee.count,0),ie=[];for(let j of P?.entries??[]){let G=Ge(j.at,e.zone,{month:"long",year:"numeric"}),ee=ie.at(-1);ee?.month===G?ee.entries.push(j):ie.push({month:G,entries:[j]})}let Q=$.data?.since??null;return m("div",{className:"flex flex-wrap items-start gap-8",children:[m("div",{className:"min-w-0 flex-[999_1_34rem] space-y-5",children:[l(rn,{eyebrow:"Activity",title:"On your behalf"}),l("p",{className:"text-sm text-muted-foreground",children:"Everything I did that left your machines or used your accounts, and who said yes to it. Search it by person, place or command."}),m("label",{className:"flex items-center gap-2",children:[l(pe,{name:"Search","aria-hidden":!0,className:"size-4 text-muted-foreground"}),l("span",{className:"sr-only",children:"Search the record"}),l(le,{value:a,onChange:j=>u(j.target.value),placeholder:"Search the record","aria-label":"Search the record"}),P?m("span",{className:"shrink-0 text-xs text-muted-foreground",children:[P.entries.length,P.more?"+":""," ",P.entries.length===1?"result":"results"]}):null]}),l("div",{className:"flex flex-wrap gap-1.5",role:"group","aria-label":"What",children:[{id:"all",label:"All kinds"},...gS].map(j=>m("button",{type:"button","aria-pressed":p===j.id,onClick:()=>f(j.id),className:V("cursor-pointer rounded-full px-3 py-1 text-xs font-semibold",p===j.id?"bg-foreground text-background":"bg-muted text-muted-foreground hover:text-foreground"),children:[j.label,j.id!=="all"&&$.data?` \xB7 ${_e(j.id)||"none"}`:""]},j.id))}),m("div",{className:"flex flex-wrap items-center gap-3",children:[l(_t,{label:"Who said yes",value:h,onChange:g,options:[{value:"anyone",label:"Anyone"},{value:"owner",label:"You"},{value:"standing",label:"A standing permission"},{value:"level",label:"Its level"}]}),l(_t,{label:"When",value:v,onChange:j=>b({when:j,chosen:Date.now()}),options:[{value:"all",label:"All time"},{value:"month",label:"Last 30 days"},{value:"year",label:"This year"}]})]}),!P||p!=="all"&&p!=="messages"&&!i.data?l(Oe,{children:L||i.error||"Loading\u2026"}):P.entries.length===0?l(Oe,{children:c?`Nothing on record for \u201C${c}\u201D.`:"Nothing on record for these choices."}):m("div",{className:"space-y-5",children:[ie.map(({month:j,entries:G})=>m("section",{"aria-label":j,className:"space-y-2",children:[l("h2",{className:"px-1 text-xs font-semibold text-muted-foreground",children:j}),l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:G.map((ee,be)=>l(gP,{entry:ee,meta:e,levels:ne,open:n,first:be===0},je(ee)))})]},j)),P.more?m(R,{variant:"ghost",onClick:()=>C(j=>j+1),children:[l(pe,{name:"ChevronDown","aria-hidden":!0,className:"size-4"}),"Show older"]}):m("p",{className:"px-1 text-sm text-muted-foreground",children:[c?`That\u2019s everything for \u201C${c}\u201D. `:"",Q!==null?`The record starts on ${Ge(Q,e.zone,{day:"numeric",month:"long",year:"numeric"})}${bn(Q,e.zone)===e.today?", today":""}, and nothing is ever trimmed from it.`:""]})]})]}),m("aside",{className:"w-full shrink-0 space-y-3 xl:w-80","aria-label":"Your permissions, last 30 days",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"Your permissions, last 30 days"}),l(xP,{meta:e,now:t,state:i})]})]})}var bP=14,yP=366*864e5;function OS({since:e,meta:t,now:n,open:r,undo:o,needs:s,signal:i,remember:a}){let u=yn(),c=e.from,[d]=_(()=>Date.now()+yP),[p,f]=_(bP),{data:h,error:g,partial:x}=Ss({from:c??0,to:d,kinds:null,project:null,overlap:!0},i);K(()=>{h&&a(h.entries)},[h,a]);let b=bs(h?.entries??[],{from:c??0,to:d}),v=yu(b.filter(S=>S.kind!=="visit"),t.zone),w=v.slice(0,p),C=Tu(w.map(S=>S.day)),y=S=>Ee(S,t.zone);if(c===null)return m("div",{className:"mx-auto max-w-3xl space-y-6",children:[l(rn,{eyebrow:"Activity",title:"Since you looked"}),l(Oe,{children:"There\u2019s no earlier visit to catch up from yet. Today\u2019s timeline has everything so far."}),l(R,{variant:"outline",onClick:()=>u("timeline"),children:"Open today"})]});let T=b.filter(S=>(S.kind==="change"||S.kind==="filing")&&S.state!=="undone"&&S.state!=="reverted"),N=no(b);return m("div",{className:"flex flex-wrap items-start gap-8",children:[m("div",{className:"min-w-0 flex-[999_1_34rem] space-y-6",children:[l(rn,{eyebrow:`Since you last looked \xB7 ${Fn(n-c,"long")}`,title:`${vu(c,n,t.zone,y)} to now`,children:l(_t,{label:"Show",value:"since",onChange:S=>S==="today"&&u("timeline"),options:[{value:"since",label:"Since you looked"},{value:"today",label:"Just today"}]})}),e.note?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:t.assistant,size:28}),m("div",{className:"min-w-0",children:[l("p",{className:"whitespace-pre-wrap text-base leading-relaxed",children:e.note.body}),l("p",{className:"mt-1.5 text-xs text-muted-foreground",children:wu(t.assistant,e.note.at,n,t.zone,y)})]})]}):h?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:t.assistant,size:28}),l("p",{className:"text-base leading-relaxed",children:ro(N,Es(s),"away")})]}):null,l(Ns,{needs:s,title:"Still waiting for you",hint:"Oldest first",now:n}),T.length?m("section",{"aria-label":"Changed while you were away",className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:"Changed while you were away"}),l("span",{className:"ml-auto text-xs text-muted-foreground",children:"Undo is here while it can be"})]}),l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:T.map((S,$)=>l(oo,{entry:S,meta:t,now:n,onOpen:r,undo:o,first:$===0,showDay:!0},je(S)))})]}):null,m("section",{"aria-label":"Day by day",className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:"Day by day"}),l("span",{className:"ml-auto text-xs text-muted-foreground",children:"Newest first \xB7 open a day to read all of it"})]}),h?w.length===0?l(Oe,{children:"Nothing happened while you were away."}):l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:w.map(({day:S,entries:$},P)=>l("li",{className:P?"border-t border-border-hairline":void 0,children:m("div",{className:"flex items-start gap-3 px-4 py-3",children:[m("div",{className:"min-w-0 flex-1",children:[m("p",{className:"text-sm font-semibold",children:[uS(S,c,n,t.zone,y),m("span",{className:"ml-2 text-xs font-medium text-muted-foreground",children:[$.length," ",$.length===1?"entry":"entries",x&&P===v.length-1?" or more":""]})]}),l("p",{className:"mt-0.5 text-sm leading-snug text-foreground/85",children:C.get(S)??ro(no($),0,S===bn(n,t.zone)?"so-far":"day")})]}),l(R,{size:"sm",variant:"outline",onClick:()=>u("timeline",null,S),children:"Open"})]})},S))}):l(Oe,{children:g||"Loading\u2026"}),h&&v.length>p?m(R,{variant:"ghost",onClick:()=>f(S=>S+7),children:[l(pe,{name:"ChevronDown","aria-hidden":!0,className:"size-4"}),"Show earlier days"]}):null,x?m("p",{className:"px-1 text-sm text-muted-foreground",children:["More than ",zn.toLocaleString()," entries since you looked, so the summary and these counts cover the newest ",zn.toLocaleString(),"."]}):null]})]}),m("aside",{className:"hidden w-72 shrink-0 space-y-2 xl:block","aria-label":"Done while you were away",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"Done while you were away"}),h?pr(N).length?l("ul",{className:"space-y-1.5 text-sm",children:pr(N).map(S=>l("li",{children:S},S))}):l("p",{className:"text-sm text-muted-foreground",children:"Nothing yet."}):null]})]})}var LS={you:"bg-foreground/55",work:"bg-timeline-accent",checks:"bg-foreground/25",changes:"bg-warning"},_P=[{lane:"work",label:"Work"},{lane:"checks",label:"Checks and routines"},{lane:"you",label:"You"},{lane:"changes",label:"Changes and asks"}],MS=4;function vP(e){let t=J(),n=We(async()=>({week:e,...await t.call("activity.week",{week:e})}),[t,e]);return{data:n.data?.week===e?n.data:null,error:n.error,reload:n.reload}}function wP({entries:e,monday:t,today:n,meta:r,now:o}){let s=yn();return m("section",{"aria-label":"The week by hour",className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:"The week by hour"}),l("span",{className:"ml-auto text-xs text-muted-foreground",children:"Pick a day to open it"})]}),m("div",{className:"space-y-1 rounded-xl border border-border-hairline bg-surface-raised px-3 py-3",children:[bm(t).map(i=>{let a=xu(i,r.zone),u=i>n,c=e.filter(f=>_m(f,a,o)),d=_u(c,a,o),p=ym(e,a,o);return m("button",{type:"button",disabled:u,onClick:()=>s("timeline",null,i),"aria-label":`${Ct(i)}: ${u?"ahead":`${ku(p)} of work`}`,className:V("grid w-full cursor-pointer grid-cols-[3rem_minmax(0,1fr)_4.5rem] items-center gap-3 rounded-md px-1 py-1.5 text-left hover:bg-state-hover disabled:cursor-default disabled:hover:bg-transparent",i===n&&"bg-surface-selected"),children:[l("span",{className:V("text-xs font-semibold",u&&"text-muted-foreground"),children:ur(i)}),l("span",{className:V("relative h-3 rounded-full bg-muted",u&&"opacity-50"),children:d.map(f=>l("span",{className:V("absolute top-0.5 h-2 rounded-full",LS[f.lane]),style:{left:`${f.start*100}%`,width:f.end===null?"0.375rem":`max(0.375rem, ${(f.end-f.start)*100}%)`}},f.key))}),l("span",{className:"text-right text-xs tabular-nums text-muted-foreground",children:u?"ahead":`${ku(p)}${i===n?" so far":""}`})]},i)}),l("div",{className:"flex flex-wrap gap-x-4 gap-y-1 px-1 pt-2 text-2xs text-muted-foreground","aria-hidden":!0,children:_P.map(i=>m("span",{className:"inline-flex items-center gap-1.5",children:[l("span",{className:V("size-2 rounded-full",LS[i.lane])}),i.label]},i.lane))})]})]})}function kP({entries:e,needs:t,meta:n,now:r,open:o}){let[s,i]=_(!1),a=fS(e),u=s?a:a.slice(0,MS),c=a.slice(MS);return!a.length&&!fr(t)?null:m("section",{"aria-label":"What's waited on you",className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:"What\u2019s waited on you"}),l("span",{className:"ml-auto hidden text-xs text-muted-foreground sm:inline",children:"Open ones first, then the longest answered"})]}),l(Ns,{needs:t,title:"Waiting now",hint:"Oldest first",now:r}),u.length?l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:u.map(({entry:d,ms:p},f)=>l("li",{className:f?"border-t border-border-hairline":void 0,children:m("button",{type:"button",onClick:()=>o(d),className:"flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left hover:bg-state-hover",children:[m("span",{className:"min-w-0 flex-1",children:[m("span",{className:"block truncate text-sm font-medium",children:["Asked to use ",d.title]}),m("span",{className:"block text-xs text-muted-foreground",children:["Approval \xB7 asked ",Ge(d.startedAt??d.at,n.zone,{weekday:"short"})," ",Ee(d.startedAt??d.at,n.zone)]})]}),m("span",{className:"shrink-0 text-right text-xs",children:[l("span",{className:"block font-semibold tabular-nums",children:Fn(p,"long")}),l("span",{className:"block text-muted-foreground",children:nn(d)})]})]})},je(d)))}):null,c.length&&!s?m("button",{type:"button",onClick:()=>i(!0),className:"cursor-pointer px-1 text-xs font-semibold text-timeline-accent hover:underline",children:["And ",c.length," more this week, all answered within ",Fn(c[0].ms,"long"),". Show them"]}):null]})}function SP({entries:e,span:t,meta:n,now:r}){let o=en(),s=dS(e,t,r);return s.length?m("section",{"aria-label":"Where the work has gone",className:"space-y-2",children:[l("h2",{className:"px-1 text-sm font-semibold",children:"Where the work has gone"}),l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:s.map((i,a)=>{let u=n.projects.find(c=>c.key===i.key);return m("li",{className:V("flex items-center gap-3 px-4 py-2.5",a>0&&"border-t border-border-hairline"),children:[m("div",{className:"min-w-0 flex-1",children:[m("p",{className:"flex flex-wrap items-baseline gap-x-2 text-sm",children:[l("span",{className:"font-medium",children:u?.name??i.key}),l("span",{className:"text-2xs font-bold tracking-wide text-muted-foreground",children:i.key}),l("span",{className:"whitespace-nowrap tabular-nums text-muted-foreground",children:ku(i.hours)})]}),l("p",{className:"text-sm text-muted-foreground",children:pS(i)})]}),u?l(R,{size:"sm",variant:"ghost",onClick:()=>{xn({origin:"all",project:u.id}),o("today")},children:"Open"}):null]},i.key)})})]}):null}function DS({title:e,hint:t,entries:n,empty:r,meta:o,now:s,open:i,undo:a}){return m("section",{"aria-label":e,className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:e}),t?l("span",{className:"ml-auto hidden text-xs text-muted-foreground sm:inline",children:t}):null]}),n.length?l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:n.map((u,c)=>l(oo,{entry:u,meta:o,now:s,onOpen:i,undo:a,first:c===0,showDay:!0},je(u)))}):l("p",{className:"px-1 text-sm text-muted-foreground",children:r})]})}function EP({meta:e,today:t,monday:n}){let r=nt(),o=en(),s=Math.max(1,7-Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${n}T12:00:00Z`))/864e5)),{data:i}=We(()=>r.call("tasks.upcoming",{from:t,days:s}),[r,t,s]),a=(i?.items??[]).filter(u=>u.at>=Date.now()).slice(0,8);return m("section",{className:"space-y-2","aria-label":"Still ahead this week",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"Still ahead this week"}),a.length===0?l("p",{className:"text-sm text-muted-foreground",children:"Nothing timed for the rest of the week."}):null,l("ol",{className:"space-y-1",children:a.map(u=>m("li",{className:"grid grid-cols-[5.5rem_minmax(0,1fr)] gap-2 text-sm",children:[m("span",{className:"text-xs tabular-nums text-muted-foreground",children:[Ge(u.at,e.zone,{weekday:"short"})," ",Ee(u.at,e.zone)]}),l("span",{className:"min-w-0 leading-snug",children:u.task.title})]},`${u.task.id}-${u.at}`))}),l("button",{type:"button",onClick:()=>o("upcoming"),className:"cursor-pointer text-xs font-semibold text-timeline-accent hover:underline",children:"See it in Tasks \u203A Upcoming"})]})}function FS({meta:e,now:t,open:n,undo:r,needs:o,signal:s,remember:i,initialDay:a}){let u=Ie(),c=J(),d=xm(e.today),[p,f]=_(xm(a??e.today)),h=p===d,g={from:qr(p,e.zone),to:qr(tn(p,7),e.zone)},{data:x,error:b,partial:v}=Ss({...g,kinds:null,project:null,overlap:!0},s);K(()=>{x&&i(x.entries)},[x,i]);let w=vP(p),C=bm(p).filter(Q=>Q<=e.today),y=Tu(C),[T,N]=_(!1),[S,$]=_(""),P=bs(x?.entries??[],g),L=no(P),ne=Q=>Ee(Q,e.zone),se=()=>{N(!0),$(""),c.call("activity.talkWeek",{week:p}).then(({thread:Q})=>{N(!1),w.reload(),u.toThread(Q)},Q=>{N(!1),$(Q instanceof Error?Q.message:String(Q))})},_e=P.filter(Q=>Q.kind==="learned"||Q.kind==="change"),ie=hS(P);return m("div",{className:"flex flex-wrap items-start gap-8",children:[m("div",{className:"min-w-0 flex-[999_1_34rem] space-y-6",children:[m(rn,{eyebrow:h?`This week so far \xB7 ${Ct(p)} to now`:`${Ct(p)} to ${Ct(tn(p,6))}`,title:`Week of ${Ge(Date.parse(`${p}T12:00:00Z`),"UTC",{month:"long",day:"numeric"})}`,children:[l(R,{variant:"outline",size:"icon","aria-label":"The week before",onClick:()=>f(tn(p,-7)),children:l(pe,{name:"ChevronLeft","aria-hidden":!0,className:"size-4"})}),l(R,{variant:"outline",size:"icon","aria-label":"The week after",disabled:h,onClick:()=>f(tn(p,7)),children:l(pe,{name:"ChevronRight","aria-hidden":!0,className:"size-4"})}),m(R,{onClick:se,disabled:T,children:[l(pe,{name:"MessageSquare","aria-hidden":!0,className:"size-4"}),w.data?.thread?"Back to this week\u2019s conversation":`Talk it over with ${e.assistant}`]})]}),S?l("p",{role:"alert",className:"text-sm text-destructive",children:S}):null,w.error&&!w.data?m("p",{role:"alert",className:"text-sm text-destructive",children:["I couldn\u2019t load the note for this week: ",w.error]}):null,w.data?.note?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:e.assistant,size:28}),m("div",{className:"min-w-0",children:[l("p",{className:"whitespace-pre-wrap text-base leading-relaxed",children:w.data.note.body}),l("p",{className:"mt-1.5 text-xs text-muted-foreground",children:wu(e.assistant,w.data.note.at,t,e.zone,ne)})]})]}):x?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:e.assistant,size:28}),l("p",{className:"text-base leading-relaxed",children:ro(L,Es(o),h?"week":"past-week")})]}):null,v?m("p",{className:"px-1 text-sm text-muted-foreground",children:["This week has more than ",zn.toLocaleString()," entries, so these counts cover the newest ",zn.toLocaleString(),"."]}):null,x?m(he,{children:[l(wP,{entries:P,monday:p,today:e.today,meta:e,now:t}),h?l(kP,{entries:P,needs:o,meta:e,now:t,open:n}):null,l(SP,{entries:P,span:g,meta:e,now:t}),l(DS,{title:"How I\u2019ve changed",hint:"What I learned and what I changed about myself",entries:_e,empty:"No changes to me this week.",meta:e,now:t,open:n,undo:r}),l(DS,{title:"Hasn\u2019t gone well",entries:ie,empty:"Nothing went badly this week.",meta:e,now:t,open:n,undo:r})]}):l(Oe,{children:b||"Loading\u2026"})]}),m("aside",{className:"w-full shrink-0 space-y-6 xl:w-72","aria-label":"The week at a glance",children:[m("section",{className:"space-y-2","aria-label":"My note for each day",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"My note for each day"}),l("dl",{className:"space-y-1.5 text-sm",children:C.map(Q=>m("div",{className:"grid grid-cols-[4.5rem_minmax(0,1fr)] gap-2",children:[l("dt",{className:"text-xs font-semibold text-muted-foreground",children:Q===e.today?"Today":ur(Q,"long")}),l("dd",{className:V("leading-snug",!y.get(Q)&&"text-muted-foreground"),children:y.get(Q)??"Not written yet."})]},Q))})]}),h?l(EP,{meta:e,today:e.today,monday:p}):null,x?m("section",{className:"space-y-2",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:h?"This week so far":"That week"}),l("ul",{className:"space-y-1.5 text-sm",children:pr(L).map(Q=>l("li",{children:Q},Q))})]}):null]})]})}var $u=new Map;function NP(e){if(typeof window>"u"||!window.matchMedia)return null;let t=$u.get(e);if(t)return t;let n=window.matchMedia(e),r=new Set,o=()=>{for(let s of r)s()};return t={mql:n,subscribe(s){let i=r.size===0;return r.add(s),i&&n.addEventListener("change",o),()=>{r.delete(s),r.size===0&&(n.removeEventListener("change",o),$u.delete(e))}}},$u.set(e,t),t}function AP(e,t){return NP(e)?.subscribe(t)??(()=>{})}function CP(e){return typeof window>"u"||!window.matchMedia?!1:$u.get(e)?.mql.matches??window.matchMedia(e).matches}function Cm(e){return xt(t=>AP(e,t),()=>CP(e),()=>!1)}var TP="(max-width: 767px)",RP=Cf(null);function so(){let e=Tf(RP),t=Cm(TP);return e!==null?e:t}var Tm=globalThis.__bbPluginRuntime;if(Tm==null||Tm.reactDom==null)throw new Error('Cannot load "react-dom": this bundle must be loaded by the BB app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Iu=Tm.reactDom,YB="default"in Iu?Iu.default:Iu,{createPortal:zS,flushSync:qB,preconnect:JB,prefetchDNS:eU,preinit:tU,preinitModule:nU,preload:rU,preloadModule:oU,requestFormReset:sU,unstable_batchedUpdates:iU,useFormState:aU,useFormStatus:lU,version:cU}=Iu;var $P="select-none",IP=new Set(["button","checkbox","file","hidden","image","radio","range","reset","submit"]),XS=e=>V($P,e);function PP(e){return e instanceof HTMLTextAreaElement?!0:e instanceof HTMLInputElement?!e.disabled&&!e.readOnly&&!IP.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.closest("[contenteditable='true']")!==null:!1}function Pu(e){if(typeof document>"u")return;let t=document.activeElement;!t||!PP(t)||e!==null&&!e.contains(t)||t.blur()}function BS(){Pu(null)}function Rm(e){e.preventDefault()}var KS="pointer";typeof document<"u"&&(document.addEventListener("keydown",()=>{KS="keyboard"},{capture:!0}),document.addEventListener("pointerdown",()=>{KS="pointer"},{capture:!0}));function US(){let e="orbit";return{"data-bb-portaled-overlay":"","data-bb-plugin-root":"",...e!==void 0?{"data-bb-plugin":e}:{}}}var OP=120;var $m="--bb-drawer-keyboard-inset",LP=80;function Ou(e){e!==null&&(e.style.height="",e.style.bottom="",e.style.removeProperty($m))}function MP({layoutViewportHeight:e,visualViewportHeight:t,visualViewportOffsetTop:n}){let r=Math.round(e-(t+n));return r>=LP?r:0}function DP(e,t){K(()=>{let n=e.current,r=window.visualViewport;if(n===null||!t||!r)return;let o=null,s=()=>{if(o=null,r.scale!==1){Ou(n);return}let a=MP({layoutViewportHeight:n.ownerDocument.documentElement.clientHeight,visualViewportHeight:r.height,visualViewportOffsetTop:r.offsetTop});if(a===0){n.style.bottom="",n.style.removeProperty($m);return}n.style.bottom=`${a}px`,n.style.setProperty($m,`${a}px`)},i=()=>{o!==null&&window.cancelAnimationFrame(o),o=window.requestAnimationFrame(s)};return s(),r.addEventListener("resize",i),r.addEventListener("scroll",i),()=>{r.removeEventListener("resize",i),r.removeEventListener("scroll",i),o!==null&&window.cancelAnimationFrame(o),Ou(n)}},[t,e])}var FP=Tn(({asChild:e,open:t,onOpenChange:n,haspopup:r,onClick:o,children:s,className:i,...a},u)=>{let c=XS(i),d=f=>{o?.(f),f.defaultPrevented||(t||BS(),n(!t))},p={"aria-expanded":t,"aria-haspopup":r,"data-state":t?"open":"closed"};return e?l(Ql,{ref:u,onClick:d,onMouseDown:Rm,className:c,...p,...a,children:s}):l("button",{ref:u,type:"button",onClick:d,onMouseDown:Rm,className:c,...p,...a,children:s})});FP.displayName="MobileTrigger";var zP=["side","sideOffset","align","alignOffset","collisionPadding","collisionBoundary","arrowPadding","sticky","hideWhenDetached","avoidCollisions","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside"],EU=new Set(zP);function Lu({open:e,enabled:t=!0}){let[n,r]=_(!1),o=q(()=>r(!0),[]);return K(()=>{if(!t||!e||n)return;let s=null,i=null;s=window.requestAnimationFrame(()=>{s=null,i=window.requestAnimationFrame(()=>{i=null,o()})});let a=window.setTimeout(o,OP);return()=>{s!==null&&window.cancelAnimationFrame(s),i!==null&&window.cancelAnimationFrame(i),window.clearTimeout(a)}},[t,n,e,o]),{isContentRealized:t&&n,realizeContent:o}}var HS="cubic-bezier(0.32, 0.72, 0, 1)",KP=.25,XP=450,BP=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(","),Im=Symbol.for("bb.persistent-drawer-stack.v1");function UP(e){return typeof e=="object"&&e!==null&&"entries"in e&&Array.isArray(e.entries)&&"handleKeyDown"in e&&typeof e.handleKeyDown=="function"}function VS(e){let t=Reflect.get(e,Im);return UP(t)?t:void 0}function HP(e){return Array.from(e.querySelectorAll(BP)).filter(t=>t.closest('[aria-hidden="true"], [inert]')===null)}function VP(e,t){let n=e?.closest("[data-bb-portaled-overlay]");return n!=null&&n!==t}function ZP(e,t){let n=t.ownerDocument.activeElement;if(!t.contains(n)&&VP(n,t))return;let r=HP(t);if(e.preventDefault(),r.length===0){t.focus({preventScroll:!0});return}let o=r[0],s=r[r.length-1];if(e.shiftKey){if(!t.contains(n)||n===t||n===o){s?.focus({preventScroll:!0});return}let a=r.indexOf(n);r[Math.max(0,a-1)]?.focus({preventScroll:!0});return}if(!t.contains(n)||n===t||n===s){o?.focus({preventScroll:!0});return}let i=r.indexOf(n);r[Math.min(r.length-1,i+1)]?.focus({preventScroll:!0})}function WP(e,t){let n=VS(e);if(n===void 0){let r=[],o=s=>{if(s.defaultPrevented)return;let i=r[r.length-1],a=i?.panel()??null;i===void 0||a===null||(s.key==="Escape"?(i.dismissOnEscape(s),s.preventDefault()):s.key==="Tab"&&ZP(s,a))};n={entries:r,handleKeyDown:o},Reflect.set(e,Im,n),e.addEventListener("keydown",o)}return n.entries.push(t),()=>{let r=VS(e);if(r===void 0)return;let o=r.entries.indexOf(t);o>=0&&r.entries.splice(o,1),r.entries.length===0&&(e.removeEventListener("keydown",r.handleKeyDown),Reflect.deleteProperty(e,Im))}}function jP({onAfterCloseAutoFocus:e,onBeforeCloseAutoFocus:t,onEscapeKeyDown:n,open:r,panelRef:o,requestClose:s}){let i=Y(null),a=Y(n);ot(()=>{a.current=n},[n]),ot(()=>{if(!r)return;let c=o.current;if(c===null)return;let d=c.ownerDocument,p=d.activeElement;i.current=p instanceof HTMLElement&&p!==d.body?p:null;let f=WP(d,{panel:()=>o.current,dismissOnEscape:h=>{a.current?.(h),h.defaultPrevented||s()}});return c.focus({preventScroll:!0}),f},[r,o,s]);let u=Y(r);ot(()=>{let c;if(u.current&&!r){t?.();let d=i.current;if(d?.isConnected&&d.closest('[aria-hidden="true"], [inert]')===null&&(d.focus({preventScroll:!0}),d.ownerDocument.activeElement!==d)){let p=d.ownerDocument.defaultView;if(p!==null){let f=p.requestAnimationFrame(()=>{d.isConnected&&d.closest('[aria-hidden="true"], [inert]')===null&&d.focus({preventScroll:!0}),e?.()});c=()=>p.cancelAnimationFrame(f)}}i.current=null,c===void 0&&e?.()}return u.current=r,c},[e,t,r])}function Mu({open:e,onOpenChange:t,onAfterCloseAutoFocus:n,closeOnBackdropClick:r=!0,srLabel:o,labelledBy:s,describedBy:i,contentClassName:a,motionDurationMs:u=220,onContentAnimationEnd:c,onEscapeKeyDown:d,onPointerDownOutside:p,onInteractOutside:f,children:h}){let g=Y(null),x=Y(null),b=Y(null),v=Y(null),w=Y(null),C=Ai(),y=US(),T=`transform ${u}ms ${HS}`,N=`opacity ${u}ms ${HS}`,S=Y(t);ot(()=>{S.current=t},[t]);let $=q(()=>{Pu(g.current),Ou(g.current),S.current(!1)},[]),P=q(()=>{Pu(g.current),Ou(g.current)},[]);jP({onAfterCloseAutoFocus:n,onBeforeCloseAutoFocus:P,onEscapeKeyDown:d,open:e,panelRef:g,requestClose:$});let L=()=>{let G=b.current;if(b.current=null,!!r){if(G!==null){let ee=new CustomEvent("dismissableLayer.pointerDownOutside",{cancelable:!0,detail:{originalEvent:G}});if(p?.(ee),f?.(ee),ee.defaultPrevented)return}$()}};DP(g,e);let ne=q(G=>{w.current!==G&&(w.current=G,c?.(G))},[c]);K(()=>{w.current=null;let G=window.setTimeout(()=>ne(e),u+50);return()=>window.clearTimeout(G)},[u,e,ne]);let se=q((G,ee,be)=>{let H=g.current,xe=x.current;H===null||xe===null||(H.style.transition=be?T:"none",H.style.transform=`translate3d(0, ${G}px, 0)`,xe.style.transition=be?N:"none",xe.style.opacity=String(Math.max(0,Math.min(1,1-G/ee))))},[N,T]),_e=q(G=>{if(!e||G.button!==0)return;G.currentTarget.setPointerCapture(G.pointerId);let ee=Date.now(),be=Math.max(g.current?.clientHeight??0,1);v.current={pointerId:G.pointerId,startY:G.clientY,lastY:G.clientY,lastTimeMs:ee,velocityY:0,height:be},se(0,be,!1),G.preventDefault()},[e,se]),ie=q(G=>{let ee=v.current;if(ee===null||ee.pointerId!==G.pointerId)return;let be=Date.now(),H=be-ee.lastTimeMs;H>0&&(ee.velocityY=(G.clientY-ee.lastY)/H*1e3,ee.lastY=G.clientY,ee.lastTimeMs=be),se(Math.max(0,G.clientY-ee.startY),ee.height,!1),G.preventDefault()},[se]),Q=q((G,ee)=>{let be=v.current;if(be===null||be.pointerId!==G.pointerId)return;v.current=null;let H=Math.max(0,G.clientY-be.startY);!ee&&(H>=be.height*KP||be.velocityY>=XP)?(se(be.height,be.height,!0),$()):se(0,be.height,!0),G.preventDefault()},[$,se]),j=typeof document>"u"?null:document.body;return j===null?null:zS(m(he,{children:[l("div",{ref:x,...y,"aria-hidden":"true","data-persistent-drawer-backdrop":"","data-state":e?"open":"closed",className:"fixed inset-0 z-50 bg-black/40",style:{opacity:e?1:0,pointerEvents:e?"auto":"none",transition:N},onPointerDown:G=>{b.current=G.nativeEvent},onClick:L,onTouchMove:G=>G.preventDefault()}),m("div",{ref:g,...y,"aria-hidden":!e,"aria-labelledby":s??(o===void 0?void 0:C),"aria-describedby":i,"aria-modal":e||void 0,"data-bb-portaled-overlay":"","data-persistent-drawer-content":"","data-state":e?"open":"closed",inert:!e,role:"dialog",tabIndex:-1,className:V("fixed inset-x-0 bottom-0 z-50 mt-24 flex max-h-[calc(92dvh-var(--bb-drawer-keyboard-inset,0px))] flex-col rounded-t-xl border bg-background pb-[var(--bb-safe-area-bottom,env(safe-area-inset-bottom))] outline-none",a),style:{transform:e?"translate3d(0, 0, 0)":"translate3d(0, 100%, 0)",transition:T,willChange:e?"transform":void 0},onTransitionEnd:G=>{G.currentTarget===G.target&&G.propertyName==="transform"&&ne(e)},children:[l("div",{"data-persistent-drawer-handle":"",className:"mx-auto flex h-8 w-16 shrink-0 touch-none cursor-grab items-center justify-center active:cursor-grabbing",onPointerDown:_e,onPointerMove:ie,onPointerUp:G=>Q(G,!1),onPointerCancel:G=>Q(G,!0),children:l("div",{className:"h-1 w-10 rounded-full bg-muted-foreground/20"})}),o===void 0?null:l("h2",{id:C,className:"sr-only",children:o}),h]})]}),j)}function Fu({open:e,onClose:t,label:n,side:r="center",children:o}){let s=so(),{isContentRealized:i}=Lu({open:e,enabled:s});return K(()=>{if(!e||s)return;let a=u=>{u.key==="Escape"&&(u.preventDefault(),t())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,s,t]),s?l(Mu,{open:e,onOpenChange:a=>a?void 0:t(),srLabel:n,children:i?l("div",{className:"max-h-[85dvh] overflow-y-auto overscroll-contain pb-6",children:o}):null}):e?r==="right"?l("aside",{role:"dialog","aria-label":n,className:"fixed inset-y-0 right-0 z-40 flex w-full max-w-xl flex-col overflow-y-auto border-l border-border bg-background shadow-2xl",children:o}):l("div",{className:"fixed inset-0 z-40 grid place-items-center bg-surface-scrim p-4",onMouseDown:a=>a.target===a.currentTarget&&t(),children:l("div",{role:"dialog","aria-label":n,className:"max-h-[90dvh] w-full max-w-lg overflow-y-auto rounded-2xl border border-border bg-background shadow-2xl",children:o})}):null}var QP={todo:[{label:"Today",text:"today"},{label:"Tomorrow",text:"tomorrow"},{label:"This weekend",text:"this weekend"},{label:"Next week",text:"next week"},{label:"In a month",text:"in a month"}],followup:[{label:"Tomorrow morning",text:"check back tomorrow 9am"},{label:"In 3 days",text:"check back in 3 days 9am"},{label:"Next week",text:"check back next week 9am"}],scheduled:[{label:"Later today",text:"today 6pm"},{label:"Tomorrow morning",text:"tomorrow 9am"},{label:"Every weekday",text:"every weekday at 9am"},{label:"Every week",text:"every monday at 9am"},{label:"Monthly",text:"monthly on the 1st at 9am"}]};function YS({kind:e,zone:t,initial:n,onChange:r}){let o=nt(),[s,i]=_(n??""),[a,u]=_(null),c=Y(r);c.current=r;let d=p=>{i(p),u(null),c.current(null,!p.trim())};return K(()=>{if(!s.trim()){u(null),c.current(null,!0);return}let p=!0,f=setTimeout(()=>{o.call("tasks.when",{text:s,kind:e}).then(h=>{p&&(u(h.ok?{ok:!0,reading:h.reading,next:h.next}:h),c.current(h.ok?h.when:null,h.ok))})},220);return()=>{p=!1,clearTimeout(f)}},[s,e,o]),m("div",{className:"space-y-2.5",children:[l(le,{"aria-label":"When, in your own words",placeholder:e==="scheduled"?"every other friday at 4pm":e==="followup"?"check back friday 9am":"by friday",value:s,onChange:p=>d(p.target.value)}),a?.ok?m("div",{className:"rounded-lg bg-surface-selected px-3 py-2 text-sm",children:[m("p",{className:"flex items-center gap-2 font-semibold",children:[l(pe,{name:"Check","aria-hidden":!0,className:"size-4 text-success"}),Qr(a.reading)]}),a.next.length?l("ul",{className:"mt-1.5 space-y-0.5 pl-6 text-xs text-muted-foreground",children:a.next.map(p=>m("li",{children:[Ge(p,t,{weekday:"short",day:"numeric",month:"short"})," \xB7 ",Ee(p,t)]},p))}):null]}):a?l("p",{role:"status",className:"text-sm text-destructive-text",children:a.error}):null,l("div",{className:"flex flex-wrap gap-1.5",children:QP[e].map(p=>l("button",{type:"button",className:"cursor-pointer rounded-full border border-border px-2.5 py-1 text-xs font-medium hover:bg-state-hover",onClick:()=>d(p.text),children:p.label},p.label))})]})}function io({label:e,children:t}){return m("label",{className:"block space-y-1.5",children:[l("span",{className:"text-xs font-semibold text-muted-foreground",children:e}),t]})}var Du=["urgent","high","medium","low","none"],GP=["owner","assistant","others"];function Pm(e,t){return e.find(n=>n===t)??null}var ZS="h-9 w-full cursor-pointer rounded-md border border-input bg-background px-2 text-sm";function qS({open:e,onClose:t,meta:n,onMade:r}){let{change:o,error:s,busy:i}=Ea(),[a,u]=_(""),[c,d]=_("personal"),[p,f]=_("todo"),[h,g]=_(null),[x,b]=_(!0),[v,w]=_("medium"),[C,y]=_("assistant"),[T,N]=_(""),[S,$]=_(""),[P,L]=_(0),ne=n?.assistant??"Assistant",se=()=>{u(""),g(null),$(""),N(""),L(ie=>ie+1)};return l(Fu,{open:e,onClose:t,label:"New task",children:m("form",{onSubmit:async ie=>{if(ie.preventDefault(),!a.trim()||!x)return;let Q=await o({action:"create",task:{project:c,title:a,kind:p,when:h,priority:v,move:C,waitingOn:C==="others"&&T||null,description:S}});Q&&(se(),r(Q))},className:"space-y-4 p-5",children:[l("h2",{className:"text-lg font-semibold",children:"New task"}),l(io,{label:"What",children:l(le,{autoFocus:!0,value:a,onChange:ie=>u(ie.target.value),placeholder:"Renew the passport"})}),l("div",{className:"flex flex-wrap items-center gap-3",children:l(_t,{label:"Kind",value:p,onChange:ie=>{f(ie),ie==="followup"&&y("others")},options:["todo","followup","scheduled"].map(ie=>({value:ie,label:m(he,{children:[l(Ht,{glyph:ie==="scheduled"?"once":ie,className:"size-3.5"}),mu[ie]]})}))})}),l(io,{label:"When",children:l(YS,{kind:p,zone:n?.zone??"UTC",onChange:(ie,Q)=>{g(ie),b(Q)}},`${p}-${P}`)}),m("div",{className:"grid grid-cols-2 gap-3",children:[l(io,{label:"Project",children:l("select",{className:ZS,value:c,onChange:ie=>d(ie.target.value),children:(n?.projects??[{id:"personal",key:"ME",name:"Personal"}]).map(ie=>m("option",{value:ie.id,children:[ie.name," (",ie.key,")"]},ie.id))})}),l(io,{label:"Priority",children:l("select",{className:ZS,value:v,onChange:ie=>w(Pm(Du,ie.target.value)??"medium"),children:Du.map(ie=>l("option",{value:ie,children:cs[ie]},ie))})})]}),l(io,{label:"Whose move",children:l(_t,{label:"Whose move",value:C,onChange:y,options:[{value:"owner",label:"Mine"},{value:"assistant",label:`${ne}\u2019s`},{value:"others",label:"Waiting on someone"}]})}),C==="others"?l(io,{label:"Waiting on",children:l(le,{value:T,onChange:ie=>N(ie.target.value),placeholder:"Acme Mutual"})}):null,l(io,{label:"Notes",children:l("textarea",{value:S,onChange:ie=>$(ie.target.value),rows:3,className:"w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Anything that helps"})}),s?l("p",{role:"alert",className:"text-sm text-destructive-text",children:s}):null,m("div",{className:"flex justify-end gap-2 pt-1",children:[l(R,{type:"button",variant:"outline",onClick:t,children:"Cancel"}),l(R,{type:"submit",disabled:i||!a.trim()||!x||C==="others"&&!T.trim(),children:"Add task"})]})]})})}var YP=/^(?:https?:\/\/[^\s]+|\/api\/v1\/plugins\/tasks\/http\/attachments\/download\?attachmentId=[A-Za-z0-9_%-]+)$/i,WS="inline-flex max-w-full items-center gap-1.5 truncate rounded-md border border-border px-2 py-1 text-xs font-medium";function qP({link:e}){let t=Ie(),n=en(),r=m(he,{children:[l(pe,{name:e.kind==="pull_request"?"GitPullRequest":e.kind==="mail"?"Mail":e.kind==="conversation"?"ChildThread":"ExternalLink","aria-hidden":!0,className:"size-3.5"}),l("span",{className:"truncate",children:e.label??e.ref})]}),o=V(WS,"cursor-pointer hover:bg-state-hover");if(e.kind==="conversation"&&/^thr_[A-Za-z0-9_-]+$/.test(e.ref))return l("button",{type:"button",className:o,title:"Open the conversation",onClick:()=>t.toThread(e.ref),children:r});if(e.kind==="task")return l("button",{type:"button",className:o,title:"Open the task",onClick:()=>n("today",e.ref),children:r});if(YP.test(e.ref)){let s=e.ref.startsWith("/");return l("a",{href:e.ref,className:o,title:e.ref,...s?{download:e.label??!0}:{target:"_blank",rel:"noreferrer noopener"},children:r})}return l("span",{className:WS,title:e.ref,children:r})}var jS=200,QS=1e4,GS=e=>({owner:"Your move",assistant:`${e}\u2019s move`,others:"Waiting on others"});function JS({open:e,taskRef:t,meta:n,onClose:r}){let[o,s]=_("Task");return l(Fu,{open:e,onClose:r,label:o,side:"right",children:t?l(JP,{taskRef:t,meta:n,onClose:r,onLabel:s},t):null})}function JP({taskRef:e,meta:t,onClose:n,onLabel:r}){let o=nt(),{change:s,error:i}=Ea(),[a,u]=_(!1),[c,d]=_(""),[p,f]=_(jS),{data:h,error:g}=We(()=>o.call("tasks.show",{ref:e,recent:p}),[o,e,p]),[x,b]=_(""),[v,w]=_(""),[C,y]=_(!1),[T,N]=_({when:null,ok:!1}),[S,$]=_(!1),[P,L]=_(""),[ne,se]=_(!1),[_e,ie]=_(""),Q=t?.assistant??"Assistant",j=t?.zone??"UTC",G=h?.task.title??"Task";if(K(()=>r(G),[G,r]),!h)return l("p",{className:"p-6 text-sm text-muted-foreground",children:g||"Loading\u2026"});let ee=h.task,be=ee.id;return m(he,{children:[m("div",{className:"flex items-center gap-2 border-b border-border-hairline px-5 py-3 text-xs text-muted-foreground",children:[l("span",{className:"font-semibold text-foreground",children:ee.key}),l("span",{"aria-hidden":!0,children:"\xB7"}),l("span",{children:ee.project.name}),h.aliases.length?m("span",{children:["\xB7 also ",h.aliases.join(", ")]}):null,l(R,{variant:"ghost",size:"icon",className:"ml-auto size-8","aria-label":"Close",onClick:n,children:l(pe,{name:"ChevronRight","aria-hidden":!0,className:"size-4"})})]}),m("div",{className:"space-y-6 px-5 py-5",children:[m("div",{className:"flex items-start gap-3",children:[l(lm,{task:ee,onToggle:()=>{s(ee.status==="open"?{action:"done",ref:be,note:null}:{action:"reopen",ref:be,why:null})}}),ne?l("form",{className:"flex-1",onSubmit:H=>{H.preventDefault(),s({action:"update",ref:be,patch:{title:_e}}).then(xe=>xe&&se(!1))},children:l(le,{autoFocus:!0,value:_e,onChange:H=>ie(H.target.value),onBlur:()=>se(!1),"aria-label":"Title"})}):l("button",{type:"button",className:V("flex-1 cursor-text text-left text-xl font-semibold leading-snug",ee.status!=="open"&&"text-muted-foreground line-through"),onClick:()=>{ie(ee.title),se(!0)},children:ee.title})]}),m("dl",{className:"grid grid-cols-[7rem_minmax(0,1fr)] items-center gap-x-3 gap-y-2.5 text-sm",children:[l("dt",{className:"text-muted-foreground",children:"Kind"}),m("dd",{className:"flex items-center gap-1.5 font-medium",children:[l(Ht,{glyph:jr(ee),className:"text-timeline-accent"}),mu[ee.kind]]}),l("dt",{className:"text-muted-foreground",children:"Whose move"}),m("dd",{className:"flex flex-wrap items-center gap-2",children:[l("select",{"aria-label":"Whose move",className:"h-8 cursor-pointer rounded-md border border-input bg-background px-2 text-sm font-medium",value:a?"others":ee.move,onChange:H=>{let xe=Pm(GP,H.target.value);xe&&(xe==="others"?(d(ee.waitingOn??""),u(!0)):(u(!1),s({action:"update",ref:be,patch:{move:xe}})))},children:Object.entries(GS(Q)).map(([H,xe])=>l("option",{value:H,children:H==="others"&&ee.waitingOn?`Waiting on ${ee.waitingOn}`:xe},H))}),a?m("form",{className:"flex gap-2",onSubmit:H=>{H.preventDefault(),c.trim()&&s({action:"update",ref:be,patch:{move:"others",waitingOn:c}}).then(xe=>xe&&u(!1))},children:[l(le,{autoFocus:!0,value:c,onChange:H=>d(H.target.value),placeholder:"Who it waits on","aria-label":"Who it waits on",className:"h-8 w-44 text-sm"}),l(R,{size:"sm",type:"submit",disabled:!c.trim(),children:"Save"})]}):null]}),l("dt",{className:"text-muted-foreground",children:"From"}),m("dd",{className:"flex min-w-0 items-center gap-2",children:[l(De,{origin:ee.origin,assistant:Q,size:18}),l("span",{className:"truncate",children:ee.origin==="assistant"?`${Q}${ee.why?`: ${ee.why}`:""}`:"You"})]}),l("dt",{className:"text-muted-foreground",children:"Priority"}),m("dd",{className:"flex items-center gap-2",children:[l(us,{level:ee.priority}),l("select",{"aria-label":"Priority",className:"h-8 cursor-pointer rounded-md border border-input bg-background px-2 text-sm font-medium",value:ee.priority,onChange:H=>{let xe=Pm(Du,H.target.value);xe&&s({action:"update",ref:be,patch:{priority:xe}})},children:Du.map(H=>l("option",{value:H,children:cs[H]},H))})]}),l("dt",{className:"text-muted-foreground",children:"Project"}),l("dd",{children:l("select",{"aria-label":"Project",className:"h-8 cursor-pointer rounded-md border border-input bg-background px-2 text-sm font-medium",value:ee.project.id,onChange:H=>{s({action:"move",ref:be,project:H.target.value})},children:(t?.projects??[ee.project]).map(H=>m("option",{value:H.id,children:[H.name," (",H.key,")"]},H.id))})}),ee.doneWhen?m(he,{children:[l("dt",{className:"self-start text-muted-foreground",children:"Done when"}),l("dd",{className:"leading-relaxed",children:ee.doneWhen})]}):null]}),m("div",{className:"rounded-xl bg-surface-selected px-4 py-3.5",children:[l("p",{className:"text-xs font-semibold text-muted-foreground",children:ee.kind==="followup"?"Next check":ee.kind==="scheduled"?"When":"Due"}),C?m("div",{className:"mt-2 space-y-3",children:[l(YS,{kind:ee.kind,zone:j,onChange:(H,xe)=>N({when:H,ok:xe})}),m("div",{className:"flex gap-2",children:[l(R,{size:"sm",disabled:!T.ok,onClick:()=>{s({action:"update",ref:be,patch:{when:T.when}}).then(H=>H&&y(!1))},children:"Save"}),l(R,{size:"sm",variant:"outline",onClick:()=>y(!1),children:"Cancel"})]})]}):m(he,{children:[l("p",{className:"mt-0.5 text-base font-semibold",children:ee.whenText?Qr(ee.whenText):"Not set"}),ee.dueAt?l("p",{className:"text-xs text-muted-foreground",children:Ge(ee.dueAt,j,{weekday:"long",day:"numeric",month:"long",hour:"numeric",minute:"2-digit"})}):null,m("div",{className:"mt-3 flex flex-wrap gap-2",children:[m(R,{size:"sm",variant:"outline",onClick:()=>y(!0),children:[l(pe,{name:"Clock","aria-hidden":!0,className:"size-3.5"}),"Change when"]}),ee.status==="open"&&ee.move!=="owner"?l(R,{size:"sm",variant:"outline",onClick:()=>{s({action:"update",ref:be,patch:{move:"owner",why:"you took it over"}})},children:"I\u2019ll take it from here"}):null]})]})]}),ee.description?l("p",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground/90",children:ee.description}):null,m("section",{className:"space-y-2",children:[m("h3",{className:"text-sm font-semibold",children:["Steps"," ",h.steps.length?m("span",{className:"font-normal text-muted-foreground",children:[h.steps.filter(H=>H.doneAt).length," of ",h.steps.length]}):null]}),l("ul",{className:"space-y-1",children:h.steps.map(H=>m("li",{className:"flex items-center gap-2.5 text-sm",children:[l("input",{type:"checkbox","aria-label":H.title,className:"size-4 cursor-pointer accent-foreground",checked:H.doneAt!==null,onChange:xe=>{s({action:"checkStep",ref:be,position:H.position,done:xe.target.checked})}}),l("span",{className:V(H.doneAt&&"text-muted-foreground line-through"),children:H.title}),H.doneBy?l("span",{className:"ml-auto text-xs text-muted-foreground",children:H.doneBy==="assistant"?Q:H.doneBy==="owner"?"You":"System"}):null]},H.position))}),l("form",{className:"flex gap-2",onSubmit:H=>{H.preventDefault(),v.trim()&&s({action:"addStep",ref:be,title:v}).then(xe=>xe&&w(""))},children:l(le,{value:v,onChange:H=>w(H.target.value),placeholder:"Add a step","aria-label":"Add a step",className:"h-8 text-sm"})})]}),h.links.length?m("section",{className:"space-y-2",children:[l("h3",{className:"text-sm font-semibold",children:"Linked"}),l("div",{className:"flex flex-wrap gap-2",children:h.links.map(H=>l(qP,{link:H},`${H.kind}:${H.ref}`))})]}):null,m("section",{className:"space-y-3",children:[l("h3",{className:"text-sm font-semibold",children:"Journal"}),h.earlier!==null?p<QS?m("button",{type:"button",onClick:()=>f(H=>Math.min(H+jS,QS)),className:"flex cursor-pointer items-center gap-2 text-sm font-semibold text-timeline-accent hover:underline",children:[l(pe,{name:"ChevronUp","aria-hidden":!0,className:"size-3.5"}),"Show earlier"]}):m("p",{className:"text-xs text-muted-foreground",children:["Earlier lines: moonlet orbit tasks journal --task ",h.task.key," --before ",h.earlier]}):null,l("ol",{className:"relative space-y-3 border-l border-border-hairline pl-5",children:h.journal.map(H=>m("li",{className:"relative",children:[l("span",{className:"absolute -left-[1.85rem] top-0.5",children:H.actor==="system"?l("span",{className:"block size-4 rounded-full border border-border bg-muted"}):l(De,{origin:H.actor==="assistant"?"assistant":"owner",assistant:Q,size:18})}),m("p",{className:"text-xs text-muted-foreground",children:[Ge(H.at,j,{weekday:"short",day:"numeric",month:"short"})," \xB7 ",Ee(H.at,j)," \xB7"," ",H.actor==="assistant"?Q:H.actor==="owner"?"You":"System"]}),l("p",{className:V("mt-0.5 whitespace-pre-wrap text-sm leading-relaxed",H.actor==="owner"&&H.what==="note"&&"rounded-lg bg-muted px-3 py-2",H.what==="created"&&"text-muted-foreground"),children:H.body})]},H.seq))}),m("form",{className:"flex gap-2",onSubmit:H=>{H.preventDefault(),x.trim()&&s({action:"note",ref:be,body:x}).then(xe=>xe&&b(""))},children:[l(le,{value:x,onChange:H=>b(H.target.value),placeholder:`Add a note, or something for ${Q} to know`,"aria-label":"Add a note"}),l(R,{type:"submit",disabled:!x.trim(),children:"Add"})]})]}),i?l("p",{role:"alert",className:"text-sm text-destructive-text",children:i}):null,m("div",{className:"flex flex-wrap items-center gap-2 border-t border-border-hairline pt-4",children:[ee.status==="open"?m(he,{children:[m(R,{size:"sm",onClick:()=>{s({action:"done",ref:be,note:null})},children:[l(pe,{name:"Check","aria-hidden":!0,className:"size-3.5"}),"Done"]}),S?m("form",{className:"flex flex-1 gap-2",onSubmit:H=>{H.preventDefault(),P.trim()&&s({action:"drop",ref:be,reason:P}).then(xe=>xe&&$(!1))},children:[l(le,{autoFocus:!0,value:P,onChange:H=>L(H.target.value),placeholder:"Why it no longer matters","aria-label":"Why drop it",className:"h-8 text-sm"}),l(R,{size:"sm",variant:"outline",type:"submit",disabled:!P.trim(),children:"Drop"})]}):l(R,{size:"sm",variant:"outline",onClick:()=>$(!0),children:"Drop"})]}):m(R,{size:"sm",variant:"outline",onClick:()=>{s({action:"reopen",ref:be,why:null})},children:[l(pe,{name:"RotateCcw","aria-hidden":!0,className:"size-3.5"}),"Reopen"]}),m("span",{className:"ml-auto text-xs text-muted-foreground",children:[ee.status==="open"?GS(Q)[ee.move]:ee.status==="done"?"Done":`Dropped: ${ee.reason??""}`,ee.closedAt?` \xB7 ${Ge(ee.closedAt,j,{day:"numeric",month:"short"})}`:""]})]})]})]})}function eO(e,t){let n=Ge(e.at,t.zone,{weekday:"long",day:"numeric",month:"long"}),r=e.startedAt??e.at,o=e.endedAt;return o!==null&&o-r>=6e4?`${n}, ${Ee(r,t.zone)}\u2013${Ee(o,t.zone)}`:`${n}, ${Ee(e.at,t.zone)}`}function tO(e,t){return e.actor==="owner"?"You":e.actor==="system"?"Moonlet itself":t.assistant}function eE({entry:e,open:t,meta:n,now:r,undo:o,onClose:s}){let i=Ie(),a=en(),u=e&&o.said?.ref===je(e)?o.said:null,c=e?bu(e):null,d=e?to(e,r):null;return l(Fu,{open:t&&e!==null,onClose:s,label:e?Ta(e):"Activity",side:"right",children:e?m("div",{className:"flex flex-col gap-6 p-5 sm:p-6",children:[m("div",{className:"flex items-start gap-3",children:[m("div",{className:"min-w-0 flex-1",children:[m("p",{className:"flex items-center gap-1.5 text-xs font-semibold text-muted-foreground",children:[l(_n,{kind:e.kind,className:"size-3.5 text-timeline-accent"}),[e.kind==="check"?e.title.split(":")[0]:eo[e.kind],eO(e,n),d].filter(Boolean).join(" \xB7 ")]}),l("h2",{className:"mt-1.5 text-xl font-semibold leading-snug tracking-tight",children:Ta(e)})]}),l(R,{variant:"ghost",size:"icon","aria-label":"Close",onClick:s,children:l(pe,{name:"X","aria-hidden":!0,className:"size-4"})})]}),m("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[nn(e)?l("span",{className:e.needsYou?"rounded-md bg-warning/15 px-2 py-1 font-semibold text-warning-text":"rounded-md bg-muted px-2 py-1 font-semibold",children:nn(e)}):null,e.task?m("button",{type:"button",onClick:()=>a("today",e.task.key),className:"cursor-pointer rounded-md border border-border-hairline px-2 py-1 font-semibold hover:bg-state-hover",children:[e.task.key," \xB7 ",e.task.title]}):null,m("span",{className:"inline-flex items-center gap-1.5 rounded-md border border-border-hairline px-2 py-1 text-muted-foreground",children:[e.actor==="system"?null:l(De,{origin:e.actor==="owner"?"owner":"assistant",assistant:n.assistant,size:14}),tO(e,n)]})]}),c?l("p",{className:"rounded-xl bg-surface-selected px-4 py-3 text-base leading-relaxed",children:c}):null,e.kind==="approval"?m("section",{className:"space-y-2",children:[l("h3",{className:"text-xs font-semibold text-muted-foreground",children:"What it asked to run"}),l("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 font-mono text-xs",children:e.detail})]}):e.detail&&e.kind!=="check"?l("p",{className:"whitespace-pre-wrap text-base leading-relaxed",children:e.detail}):null,e.kind==="change"?l(Of,{id:e.id,beforeLabel:"Before"},e.id):null,e.steps.length?m("section",{className:"space-y-2",children:[l("h3",{className:"text-xs font-semibold text-muted-foreground",children:e.kind==="approval"?"How it was decided":"How it went"}),l("ol",{className:"space-y-1.5 border-l border-border-hairline pl-4",children:e.steps.map((p,f)=>m("li",{className:"grid grid-cols-[4rem_minmax(0,1fr)] gap-2 text-sm",children:[l("span",{className:"text-xs tabular-nums text-muted-foreground",children:Ee(p.at,n.zone)}),l("span",{className:"min-w-0 break-words",children:p.text})]},`${p.at}-${f}`))})]}):null,m("div",{className:"flex flex-wrap items-center gap-2 border-t border-border-hairline pt-4",children:[e.thread?m(R,{onClick:()=>i.toThread(e.thread),children:[l(pe,{name:"MessageSquare","aria-hidden":!0,className:"size-4"}),"Open the conversation"]}):null,e.task?m(R,{variant:"outline",onClick:()=>a("today",e.task.key),children:["Open ",e.task.key]}):null,e.undo&&!u?.done?l(R,{variant:"outline",disabled:o.busy!==null,onClick:()=>o.undo(e),children:"Undo"}):null,u?l("span",{role:"status",className:u.done?"text-sm text-muted-foreground":"text-sm text-destructive",children:u.text}):null]})]}):null})}function nO(e){return e.fromThread?`${e.fromName??"(not listed)"} ${e.fromThread}${e.fromHost?` on ${e.fromHost}`:""}`:"outside Moonlet's conversations (unverified)"}function tE(){let e=J(),[t,n]=_(null),[r,o]=_(null),[s,i]=_(null),a=Y(()=>{});K(()=>{let d=!0,p=!1,f=!1,h=async()=>{if(p){f=!0;return}p=!0;do{f=!1;try{let x=await e.call("messages.state",null);d&&!f&&(n(x.held),o(null))}catch(x){d&&o(x instanceof Error?x.message:String(x))}}while(d&&f);p=!1};a.current=()=>{h()},h();let g=setInterval(()=>{p||h()},5e3);return()=>{d=!1,clearInterval(g),a.current=()=>{}}},[e]);let u=q(()=>a.current(),[]);ke("messages",u);let c=async(d,p)=>{i(p),o(null);try{let f=await e.call(d,{id:p});n(h=>h?.filter(g=>g.id!==f.id||f.status==="held")??null),u()}catch(f){o(f instanceof Error?f.message:String(f))}finally{i(null)}};return m("section",{className:"flex min-w-0 flex-col gap-2 text-sm","aria-label":"Held messages",children:[l("h2",{className:"font-medium",children:"Messages held for you"}),l("p",{className:"text-xs text-muted-foreground",children:"A message from a sender that isn't listed waits here for your yes. A sender outside Moonlet's conversations is unverified, and a message is information for its recipient, never an approval in your name."}),r&&l("p",{role:"alert",className:"text-destructive",children:r}),t===null?r?null:l("p",{className:"text-muted-foreground",children:"Loading messages\u2026"}):t.length===0?l("p",{className:"text-muted-foreground",children:"No held messages."}):l("ul",{className:"divide-y text-xs",children:t.map(d=>m("li",{className:"flex flex-col gap-1 py-2",children:[m("div",{className:"flex flex-wrap gap-2",children:[m("span",{className:"w-10 shrink-0 font-mono",children:["#",d.id]}),l("span",{className:"w-36 shrink-0 text-muted-foreground",children:new Date(d.at).toLocaleString()}),m("span",{className:"flex-1",children:["to ",l("span",{className:"font-medium",children:d.to})," from ",l("span",{className:"font-mono",children:nO(d)})]})]}),l("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 font-mono",children:d.text}),m("div",{className:"flex gap-2",children:[m(R,{size:"sm",disabled:s!==null,onClick:()=>{c("messages.deliver",d.id)},children:["Deliver to ",d.to]}),l(R,{size:"sm",variant:"ghost",disabled:s!==null,onClick:()=>{c("messages.discard",d.id)},children:"Discard"})]})]},d.id))})]})}function oO({meta:e,now:t,open:n,undo:r,needs:o,signal:s,remember:i,day:a,onDay:u}){let[c,d]=_("everything"),[p,f]=_(!0),[h,g]=_(""),[x,b]=_(null),v=xu(a,e.zone),{data:w,error:C,partial:y}=Ss({...v,kinds:null,project:h||null,overlap:!0},s);K(()=>{w&&i(w.entries)},[w,i]);let T=a===e.today;K(()=>{b(null)},[a]);let N=se=>u(se),S=bs(w?.entries??[],v),$=iS(S,c,x,t),{running:P,groups:L}=aS($,e.zone,p),ne=no(S);return m("div",{className:"flex flex-wrap items-start gap-8",children:[m("div",{className:"min-w-0 flex-[999_1_34rem] space-y-6",children:[m(rn,{eyebrow:T?"Activity today":"Activity",title:Ct(a),children:[l(R,{variant:"outline",size:"icon","aria-label":"The day before",onClick:()=>N(tn(a,-1)),children:l(pe,{name:"ChevronLeft","aria-hidden":!0,className:"size-4"})}),l(R,{variant:"outline",size:"icon","aria-label":"The day after",disabled:T,onClick:()=>N(tn(a,1)),children:l(pe,{name:"ChevronRight","aria-hidden":!0,className:"size-4"})}),T?null:l(R,{variant:"outline",size:"sm",onClick:()=>N(e.today),children:"Back to today"})]}),w?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:e.assistant,size:28}),l("p",{className:"text-base leading-relaxed",children:ro(ne,Es(o),T?"today":"day")})]}):null,T?l(Ns,{needs:o}):null,w?l($S,{entries:S,span:v,now:t,zone:e.zone,stretch:x,onStretch:b}):null,m("div",{className:"flex flex-wrap items-center gap-3",children:[l(_t,{label:"Show",value:c,onChange:d,options:[{value:"everything",label:"Everything"},{value:"changed",label:"What changed"},{value:"work",label:"Work"}]}),m("label",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:["Project",m("select",{value:h,onChange:se=>g(se.target.value),className:"h-8 cursor-pointer rounded-md border border-input bg-background px-2 text-xs font-medium text-foreground",children:[l("option",{value:"",children:"All projects"}),e.projects.map(se=>m("option",{value:se.key,children:[se.name," (",se.key,")"]},se.id))]})]}),m("label",{className:"inline-flex cursor-pointer items-center gap-2 text-xs font-medium text-muted-foreground",children:[l("input",{type:"checkbox",className:"size-4 accent-foreground",checked:p,onChange:se=>f(se.target.checked)}),"Fold quiet checks"]})]}),w?m("div",{className:"space-y-5",children:[$.length===0?l(Oe,{children:x?"Nothing happened in that stretch.":T?"Nothing has happened yet today.":"Nothing happened that day."}):m(he,{children:[l(RS,{entries:P,meta:e,now:t,onOpen:n}),l(TS,{groups:L,meta:e,now:t,onOpen:n,undo:r})]}),y?m("p",{className:"px-1 text-sm text-muted-foreground",children:[T?"Today":"That day"," has more than ",zn.toLocaleString()," entries, so the summary, the hours and this list cover the newest"," ",zn.toLocaleString(),"."]}):null]}):l(Oe,{children:C||"Loading\u2026"})]}),l("aside",{className:"hidden w-72 shrink-0 space-y-6 xl:block","aria-label":"The day at a glance",children:m("section",{className:"space-y-2",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:T?"Today so far":"That day"}),w?pr(ne).length?l("ul",{className:"space-y-1.5 text-sm",children:pr(ne).map(se=>l("li",{children:se},se))}):l("p",{className:"text-sm text-muted-foreground",children:"Nothing yet."}):null]})})]})}var nE={undo:{hint:"Changes to your moonlet undo while their settings still match; library filings undo newest first.",empty:"Nothing to undo yet."},work:{hint:"Each piece of work with its steps and result, and the notes left on tasks.",empty:"No work yet."},asks:{hint:"Every approval asked, what it would run and how it was decided. Standing permissions are in Settings \u2192 Permissions.",empty:"Nothing asked yet."},messages:{hint:"Messages between conversations and relays to other machines. Recipient controls are in Settings \u2192 Permissions.",empty:"No messages yet."},checks:{hint:"Scheduled checks, routines and reminders, with what each found.",empty:"No checks have run yet."}};function sO({view:e,meta:t,now:n,open:r,undo:o,signal:s,remember:i}){let[a,u]=_(1),[c]=_(()=>Date.now()+366*864e5),{data:d,error:p}=ks({from:0,to:c,kinds:pm[e],project:null},a,s);K(()=>{d&&i(d.entries)},[d,i]);let f=xs.find(h=>h.id===e).label;return m("div",{className:"mx-auto max-w-4xl space-y-6",children:[l(rn,{eyebrow:"Activity",title:f}),l("p",{className:"text-sm text-muted-foreground",children:nE[e].hint}),d?d.entries.length===0?l(Oe,{children:nE[e].empty}):m("div",{className:"space-y-5",children:[yu(d.entries,t.zone).map(({day:h,entries:g})=>m("section",{"aria-label":Ct(h),className:"space-y-2",children:[l("h2",{className:"px-1 text-xs font-semibold text-muted-foreground",children:h===t.today?"Today":Ct(h)}),l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:g.map((x,b)=>l(oo,{entry:x,meta:t,now:n,onOpen:r,undo:o,first:b===0},je(x)))})]},h)),d.more?m(R,{variant:"ghost",onClick:()=>u(h=>h+1),children:[l(pe,{name:"ChevronDown","aria-hidden":!0,className:"size-4"}),"Show older"]}):null]}):l(Oe,{children:p||"Loading\u2026"}),e==="undo"?l(tS,{}):null]})}function iO(){return m("div",{className:"mx-auto max-w-4xl space-y-6",children:[l(rn,{eyebrow:"Activity",title:"Needs you"}),l("p",{className:"text-sm text-muted-foreground",children:"Questions, approvals and changes waiting for your answer, and messages held until you say yes."}),l(pu,{}),l(Ci,{}),l(tE,{})]})}function aO({view:e,needs:t}){let n=yn();return l("nav",{"aria-label":"Activity views",className:"-mx-1 flex min-w-0 gap-1 overflow-x-auto px-1 md:hidden",children:xs.map(r=>m("button",{type:"button","aria-current":e===r.id?"page":void 0,"aria-label":r.id==="needs"&&t?`${r.short}, ${t}`:void 0,onClick:()=>n(r.id),className:V("inline-flex shrink-0 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-semibold",e===r.id?"bg-foreground text-background":"bg-muted text-muted-foreground"),children:[r.short,r.id==="needs"&&t?l("span",{className:"rounded-full bg-warning px-1.5 text-2xs text-background",children:t}):null]},r.id))})}function rE({subPath:e}){let t=fm(e),n=yn(),r=ds(),o=fs(),s=Nm(),i=Em(),a=i.data!==null&&i.data.from!==null&&o-i.data.from>144e5,u=t.landing&&i.data===null&&i.error==="",c=t.landing&&a?"since":t.view,d=Y(!1);K(()=>{!t.landing||i.data===null||d.current||(d.current=!0,a&&n("since"))},[t.landing,i.data,a,n]);let[p,f]=_(new Map),[h,g]=_(null),[x,b]=_(0),v=q(P=>f(L=>new Map([...L,...P.map(ne=>[je(ne),ne])])),[]),w=t.entry===null?null:p.get(t.entry)??null;SS(t.entry,v,x),K(()=>{w&&g(w)},[w]);let C=ES(()=>b(P=>P+1)),y={busy:C.busy,said:C.said,undo:P=>{C.undo(P)}},T=c==="timeline"||c==="week"?t.day:null,S={meta:r,now:o,open:P=>n(c,je(P),T),undo:y,signal:x,remember:v},$=!r||u?l(Oe,{children:"Loading\u2026"}):c==="timeline"?l(oO,{...S,meta:r,needs:s,day:t.day??r.today,onDay:P=>n("timeline",null,P===r.today?null:P)}):c==="week"?l(FS,{...S,meta:r,needs:s,initialDay:t.day},t.day??"this-week"):c==="since"?l(OS,{...S,meta:r,needs:s,since:i.data??{from:null,note:null}}):c==="behalf"?l(PS,{...S,meta:r}):c==="needs"?l(iO,{}):l(sO,{...S,meta:r,view:c},c);return m("main",{className:"h-full overflow-auto",children:[m("div",{className:"mx-auto flex max-w-7xl flex-col gap-6 p-4 sm:p-8",children:[l(aO,{view:c,needs:fr(s)}),$]}),r?l(eE,{entry:w??h,open:w!==null,meta:r,now:o,undo:y,onClose:()=>n(c,null,T)}):null]})}function oE({subPath:e}){let t=fm(e),n=yn(),r=Nm(),[o]=_(()=>Date.now()+366*864e5),s=ks({from:0,to:o,kinds:pm.undo,project:null},1,0).data?.entries.filter(p=>p.undo!==null).length??0,i={needs:fr(r),undo:s},a=Em().data,u=fs(),c=a?.from!=null?{since:Fn(u-a.from,"short")}:{},d=p=>m("button",{type:"button","aria-current":t.view===p.id?"page":void 0,"aria-label":i[p.id]?`${p.label}, ${i[p.id]}`:void 0,onClick:()=>n(p.id),className:V("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm",t.view===p.id?"bg-muted font-semibold":"hover:bg-muted/60"),children:[l("span",{className:"min-w-0 flex-1 truncate",children:p.label}),i[p.id]?l("span",{className:V("rounded-full px-1.5 text-2xs font-bold",p.id==="needs"?"bg-warning/20 text-warning-text":"text-muted-foreground"),children:i[p.id]}):c[p.id]?l("span",{className:"text-2xs font-semibold text-muted-foreground",children:c[p.id]}):null]},p.id);return m("nav",{"aria-label":"Activity",className:"flex flex-col gap-0.5 p-2",children:[xs.filter(p=>dm.includes(p.id)).map(d),l("p",{className:"mt-4 px-2 pb-1 text-xs font-semibold text-muted-foreground",children:"Narrow to"}),xs.filter(p=>!dm.includes(p.id)).map(d),l("p",{className:"px-2 pt-3 text-xs leading-snug text-muted-foreground",children:"Every view is the same record, narrowed. After a few hours away, Activity opens on what happened since you looked."})]})}var ao="application/x-moonlet-artifacts";function sE(){try{return globalThis.sessionStorage??null}catch{return null}}var Xn={outcome:null,stack:X1(sE()),request:null,changed:null},Om=new Set,Kn=e=>{if(Xn={...Xn,...e},e.stack)try{sE()?.setItem(om,JSON.stringify(e.stack))}catch{}for(let t of Om)t()},Lm=e=>(Om.add(e),()=>Om.delete(e));function iE(){let e=xt(Lm,()=>Xn);return[e.outcome,e.stack.length>0,()=>Kn({outcome:null})]}function aE(){return xt(Lm,()=>Xn.changed)}function Mm(e){Kn({request:e})}function lE(){return[xt(Lm,()=>Xn.request),()=>Kn({request:null})]}function zu(e){try{let t=JSON.parse(e.getData(ao)||"[]");return Array.isArray(t)?t.filter(n=>typeof n=="string").slice(0,Qk):[]}catch{return[]}}function Ra(e){let t=J(),n=q(async o=>{try{let s=await t.call("artifacts.change",{action:o});return s.state==="refused"?(Kn({outcome:{kind:"refused",reason:s.reason}}),!1):(s.change&&Kn({outcome:{kind:"done",summary:s.change.summary},stack:[...Xn.stack,s.change].slice(-rm),changed:{action:o,moved:s.change.moved,n:(Xn.changed?.n??0)+1}}),e(),!0)}catch(s){return Kn({outcome:{kind:"refused",reason:s instanceof Error?s.message:String(s)}}),!1}},[t,e]),r=q(async()=>{let o=Xn.stack.at(-1);if(o)try{let s=await t.call("artifacts.undo",{id:o.id});s.state==="ok"?Kn({outcome:{kind:"undone",summary:s.summary},stack:Xn.stack.slice(0,-1)}):Kn({outcome:{kind:"refused",reason:s.reason},stack:[]}),e()}catch(s){Kn({outcome:{kind:"refused",reason:s instanceof Error?s.message:String(s)}})}},[t,e]);return{run:n,undo:r}}var cE=176;function As({request:e,onClose:t}){let n=so(),r=e!==null,[o,s]=_(e);K(()=>{e&&s(e)},[e]);let{isContentRealized:i}=Lu({open:r,enabled:n});K(()=>{if(!r||n)return;let c=p=>{if(p instanceof KeyboardEvent){if(p.key!=="Escape")return;p.preventDefault(),p.stopPropagation()}t()},d=setTimeout(()=>{window.addEventListener("pointerdown",c),window.addEventListener("keydown",c,!0),window.addEventListener("scroll",c,!0)});return()=>{clearTimeout(d),window.removeEventListener("pointerdown",c),window.removeEventListener("keydown",c,!0),window.removeEventListener("scroll",c,!0)}},[r,n,t]);let a=(o?.entries??[]).filter(c=>c!==null),u=c=>{t(),c.run()};return n?l(Mu,{open:r,onOpenChange:c=>c?void 0:t(),srLabel:o?.title??"Actions",children:i?m("div",{className:"flex min-h-0 flex-col pb-4",children:[l("p",{className:"px-4 pt-1 pb-2 text-sm font-medium text-muted-foreground",children:o?.title}),l("div",{role:"menu","aria-label":o?.title,className:"flex max-h-[70dvh] flex-col overflow-y-auto overscroll-contain",children:a.map((c,d)=>l("button",{type:"button",role:"menuitem",disabled:c.disabled,className:"px-4 py-3 text-left text-base hover:bg-muted disabled:opacity-40",onClick:()=>u(c),children:c.label},`${d}-${c.label}`))})]}):null}):e?l("div",{role:"menu","aria-label":e.title,className:"fixed z-50 flex flex-col rounded-md border bg-background py-1 text-sm shadow-md",style:{width:cE,left:Math.max(8,Math.min(e.x,window.innerWidth-cE-8)),top:Math.max(8,Math.min(e.y,window.innerHeight-32*a.length-16))},onPointerDown:c=>c.stopPropagation(),children:a.map((c,d)=>l("button",{type:"button",role:"menuitem",disabled:c.disabled,className:"px-3 py-1.5 text-left hover:bg-muted disabled:opacity-40",onClick:()=>u(c),children:c.label},`${d}-${c.label}`))}):null}function Cs({label:e,query:t,keyName:n,choices:r,onQuery:o,onMenu:s}){let i=Yk(t,n)??"",a=r.some(d=>d.value.toLowerCase()===i.toLowerCase()),u=so(),c=`h-8 max-w-44 rounded-md border px-2 text-sm ${i?"border-foreground/40 bg-muted font-medium":"bg-background text-muted-foreground"}`;if(u){let d=r.find(p=>p.value.toLowerCase()===i.toLowerCase());return l("button",{type:"button","aria-label":e,"aria-haspopup":"menu",className:`${c} truncate text-left`,onClick:p=>{let f=p.currentTarget.getBoundingClientRect();s({title:e,x:f.left,y:f.bottom+4,entries:[i?{label:`Any ${e.toLowerCase()}`,run:()=>o(va(t,n,null))}:null,...r.map(h=>({label:h===d?`\u2713 ${h.label}`:h.label,run:()=>o(va(t,n,h.value))}))]})},children:d?.label??(i||e)})}return m("select",{"aria-label":e,className:c,value:a?r.find(d=>d.value.toLowerCase()===i.toLowerCase()).value:i,onChange:d=>o(va(t,n,d.target.value||null)),children:[l("option",{value:"",children:e}),!a&&i?l("option",{value:i,children:i}):null,r.map(d=>l("option",{value:d.value,children:d.label},d.value))]})}function uE({query:e,onQuery:t,meta:n,inFolder:r,canSave:o,problems:s,inputRef:i,onSave:a}){let[u,c]=_(null),[d,p]=_(null),f=q(()=>p(null),[]),[h,g]=_(!1),x=S=>{if(S.length>ya)return g(!0);g(!1),t(S)},[b,v]=_(""),w=Gc(e),C=w.subfolders,y=_a(w),T=async()=>{if(u===null)return;let S=await a(u);S?v(S):(c(null),v(""))},N=m(he,{children:[l(Cs,{onMenu:p,label:"Kind",keyName:"kind",query:e,onQuery:x,choices:[{value:"page",label:"Page"},{value:"md",label:"Markdown"}]}),l(Cs,{onMenu:p,label:"Project",keyName:"project",query:e,onQuery:x,choices:(n?.projects??[]).map(S=>({value:S.id,label:S.name}))}),l(Cs,{onMenu:p,label:"Conversation",keyName:"conversation",query:e,onQuery:x,choices:(n?.conversations??[]).map(S=>({value:S.threadId,label:S.title??S.threadId}))}),l(Cs,{onMenu:p,label:"Tag",keyName:"tag",query:e,onQuery:x,choices:(n?.tags??[]).map(S=>({value:S.tag,label:`#${S.tag}`}))}),l(Cs,{onMenu:p,label:"Modified",keyName:"modified",query:e,onQuery:x,choices:[{value:"today",label:"Today"},{value:"<7d",label:"Last 7 days"},{value:"<30d",label:"Last 30 days"},{value:">90d",label:"Older than 90 days"}]}),l(Cs,{onMenu:p,label:"Written by",keyName:"by",query:e,onQuery:x,choices:[{value:"you",label:"You"},{value:"assistant",label:"The assistant"}]}),r?m("label",{className:"flex h-8 items-center gap-1.5 px-1 text-sm text-muted-foreground",children:[l("input",{type:"checkbox",checked:C||y,disabled:y,title:y?"A filter looks in every folder below this one":void 0,onChange:S=>x(va(e,"subfolders",S.target.checked?"yes":null))}),"Subfolders"]}):null]});return m("div",{className:"flex flex-col gap-1.5 border-b px-3 py-2",children:[l(As,{request:d,onClose:f}),m("div",{className:"flex flex-wrap items-center gap-1.5",children:[l(le,{ref:i,"aria-label":"Filter this list",className:"h-8 min-w-48 flex-1",placeholder:"Filter: words, tag:triage, kind:md, modified:<7d",value:e,maxLength:ya,onChange:S=>x(S.target.value),onKeyDown:S=>{S.key==="Escape"&&e&&(S.preventDefault(),S.stopPropagation(),x(""))}}),o&&u===null?l(R,{size:"sm",variant:"secondary",disabled:!e.trim(),onClick:()=>c(""),children:"Save"}):null]}),l("div",{className:"flex flex-wrap items-center gap-1.5",children:N}),u!==null?m("form",{className:"flex flex-wrap items-center gap-1.5",onSubmit:S=>{S.preventDefault(),T()},children:[l(le,{autoFocus:!0,"aria-label":"Name for this filter",className:"h-8 max-w-64",placeholder:"Name, such as Open security",value:u,maxLength:60,onChange:S=>c(S.target.value),onKeyDown:S=>{S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),c(null),v(""))}}),l(R,{size:"sm",type:"submit",disabled:!u.trim(),children:"Save filter"}),l(R,{size:"sm",variant:"secondary",type:"button",onClick:()=>(c(null),v("")),children:"Cancel"}),b?l("span",{className:"text-xs text-destructive",children:b}):null]}):null,h?m("p",{className:"text-xs text-destructive",children:["A filter is at most ",ya," characters; that change would make it longer."]}):null,s.length?l("p",{className:"text-xs text-destructive",children:s.join(" \xB7 ")}):null]})}var dE="\0new",pE=e=>e===""?"the library":e===Ze?"the Inbox":e,fE=e=>e.length===1?Pe(e[0]):`${e.length} items`;function Ku({children:e}){return l("div",{className:"flex flex-wrap items-center gap-1.5 border-b px-3 py-2 text-sm",children:e})}function hE({panel:e,folders:t,onRun:n,onClose:r}){let[o,s]=_(e.kind==="rename"?Pe(e.path):""),[i,a]=_(""),[u,c]=_("");K(()=>s(e.kind==="rename"?Pe(e.path):""),[e]);let d=async g=>{await n(g)&&r()},p=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),r())},f=l(R,{size:"sm",variant:"secondary",type:"button",onClick:r,children:"Cancel"});if(e.kind==="move"){let g=["",Ze,...t].filter(v=>!e.items.some(w=>v===w||v.startsWith(`${w}/`))),x=i===dE,b=u.trim().toLowerCase().replace(/^\/+|\/+$/g,"");return l("form",{className:"contents",onSubmit:v=>{v.preventDefault(),x?b&&d({kind:"move",items:e.items,to:b,make:!0}):d({kind:"move",items:e.items,to:i,make:!1})},children:m(Ku,{children:[m("span",{children:["Move ",fE(e.items)," to"]}),m("select",{"aria-label":"Move to",autoFocus:!0,className:"h-8 max-w-64 rounded-md border bg-background px-2 text-sm",value:i,onChange:v=>a(v.target.value),onKeyDown:p,children:[g.map(v=>l("option",{value:v,children:pE(v)},v||"(library)")),l("option",{value:dE,children:"A new folder\u2026"})]}),x?l(le,{autoFocus:!0,"aria-label":"New folder",className:"h-8 max-w-64",placeholder:"Name, such as plans or work/screens",value:u,maxLength:240,onChange:v=>c(v.target.value),onKeyDown:p}):null,l(R,{size:"sm",type:"submit",disabled:x&&!b,children:"Move"}),f,x?l("span",{className:"text-xs text-muted-foreground",children:"Lower-case letters, digits, . _ -"}):null]})})}if(e.kind==="tag")return l("form",{className:"contents",onSubmit:g=>{g.preventDefault();let x=o.split(",").map(b=>b.trim()).filter(Boolean);x.length&&d({kind:"tag",items:e.items,tags:x})},children:m(Ku,{children:[m("span",{children:["Tag ",fE(e.items)]}),l(le,{autoFocus:!0,"aria-label":"Tags to add",className:"h-8 max-w-64",placeholder:"Tags, such as trip, plan",value:o,onChange:g=>s(g.target.value),onKeyDown:p}),l(R,{size:"sm",type:"submit",disabled:!o.trim(),children:"Add"}),f,e.tags.length?l("span",{className:"text-xs text-muted-foreground",children:"Take off:"}):null,e.tags.map(g=>m("button",{type:"button","aria-label":`Take #${g} off`,className:"rounded border px-1.5 text-xs hover:bg-muted",onClick:()=>{d({kind:"untag",items:e.items,tags:[g]})},children:["#",g," \xD7"]},g))]})});let h=e.kind==="rename";return l("form",{className:"contents",onSubmit:g=>{g.preventDefault();let x=o.trim();x&&(e.kind==="rename"?d({kind:"rename",path:e.path,name:x}):d({kind:"mkdir",path:e.parent?`${e.parent}/${x.toLowerCase()}`:x.toLowerCase()}))},children:m(Ku,{children:[l("span",{children:h?`Rename ${Pe(e.path)} to`:`New folder in ${pE(e.kind==="mkdir"?e.parent:"")}`}),l(le,{autoFocus:!0,"aria-label":h?"New name":"Folder name",className:"h-8 max-w-64",placeholder:h?"":"Name, such as plans",value:o,maxLength:64,onFocus:g=>g.currentTarget.select(),onChange:g=>s(g.target.value),onKeyDown:p}),l(R,{size:"sm",type:"submit",disabled:!o.trim(),children:h?"Rename":"Make folder"}),f,l("span",{className:"text-xs text-muted-foreground",children:"Lower-case letters, digits, . _ -"})]})})}function mE({count:e,total:t,onAll:n,allStarred:r,onMove:o,onTag:s,onStar:i,onDelete:a,onClear:u}){return m(Ku,{children:[m("span",{className:"font-medium",children:[e," selected"]}),n?m(R,{size:"sm",variant:"secondary",onClick:n,children:["Select all ",t]}):null,l(R,{size:"sm",variant:"secondary",onClick:o,children:"Move to\u2026"}),s?l(R,{size:"sm",variant:"secondary",onClick:s,children:"Tag\u2026"}):null,i?l(R,{size:"sm",variant:"secondary",onClick:i,children:r?"Unstar":"Star"}):null,l(R,{size:"sm",variant:"secondary",onClick:a,children:"Delete"}),l(R,{size:"sm",variant:"secondary",onClick:u,children:"Clear"})]})}function gE({onUndo:e}){let[t,n,r]=iE();return t?m("div",{role:"status",className:`flex items-center gap-2 border-b px-3 py-1.5 text-sm ${t.kind==="refused"?"text-destructive":""}`,children:[l("span",{className:"min-w-0 flex-1 truncate",children:t.kind==="done"?t.summary:t.kind==="undone"?`Undone: ${t.summary}`:`That didn't happen: ${t.reason}`}),n&&t.kind!=="refused"?l(R,{size:"sm",variant:"secondary",onClick:e,children:t.kind==="undone"?"Undo the one before":"Undo"}):null,l("button",{type:"button","aria-label":"Dismiss",className:"px-1 text-muted-foreground hover:text-foreground",onClick:r,children:"\xD7"})]}):null}var xE="orbit.artifacts.open-folders",bE=0,Dm=new Set;function hr(){bE++;for(let e of Dm)e()}function Fm(){return xt(e=>(Dm.add(e),()=>Dm.delete(e)),()=>bE)}function lO(){try{let e=Mn()?.getItem(xE),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function zm(){let e=Ie();return t=>e.toPluginPanel(cu,{subPath:is(t)})}function cO(e){let{run:t}=Ra(hr),[n,r]=_(!1);return e===void 0?{over:!1,props:{}}:{over:n,props:{onDragOver:o=>{o.dataTransfer.types.includes(ao)&&(o.preventDefault(),o.dataTransfer.dropEffect="move",r(!0))},onDragLeave:()=>r(!1),onDrop:o=>{o.preventDefault(),r(!1);let s=zu(o.dataTransfer).filter(i=>i!==e);s.length&&t({kind:"move",items:s,to:e,make:!1})}}}}function Bn({active:e,label:t,count:n,depth:r=0,onClick:o,toggle:s,drop:i,onDoubleClick:a,onMenu:u,after:c}){let d=cO(i);return m("div",{className:`group relative flex items-center gap-1 rounded px-2 py-1 text-sm ${e?"bg-muted font-medium":"hover:bg-muted/60"} ${d.over?"outline outline-1 outline-ring":""}`,style:{paddingLeft:`${8+r*14}px`},onContextMenu:u?p=>{p.preventDefault(),u(p.clientX,p.clientY)}:void 0,...d.props,children:[s??l("span",{className:"w-4 shrink-0"}),l("button",{type:"button","aria-current":e?"page":void 0,className:"min-w-0 flex-1 truncate text-left",onClick:o,onDoubleClick:a,children:t}),n!==void 0&&n>0?l("span",{className:`shrink-0 text-xs text-muted-foreground ${u?"group-hover:hidden [@media(hover:none)]:hidden":""}`,children:n}):null,u?l("button",{type:"button","aria-label":`More for ${typeof t=="string"?t:"this folder"}`,"aria-haspopup":"menu",className:"hidden shrink-0 rounded px-1 text-muted-foreground hover:text-foreground focus:inline group-hover:inline [@media(hover:none)]:inline",onClick:p=>{let f=p.currentTarget.getBoundingClientRect();u(f.right-176,f.bottom+4)},children:"\u2026"}):null,c]})}function uO({path:e,count:t,depth:n,active:r,toggle:o,onOpen:s,onMenu:i}){let{run:a}=Ra(hr),[u,c]=_(null),d=(p,f)=>i({title:Pe(e),x:p,y:f,entries:[{label:"New folder inside",run:()=>c({kind:"mkdir",text:""})},{label:"Rename",run:()=>c({kind:"rename",text:Pe(e)})},{label:"Move to\u2026",run:()=>Mm({kind:"move",items:[e]})},{label:"Filter inside",run:()=>(s(),Mm({kind:"focus-filter"}))},{label:"Delete folder",run:()=>{a({kind:"delete",items:[e]})}}]});return u?m(he,{children:[u.kind==="mkdir"?l(Bn,{active:r,label:Pe(e),count:t,depth:n,toggle:o,onClick:s}):null,l("form",{className:"py-0.5 pr-2",style:{paddingLeft:`${8+(n+(u.kind==="mkdir"?1:0))*14+20}px`},onSubmit:p=>{p.preventDefault();let f=u.text.trim();c(null),f&&(u.kind==="rename"?f!==Pe(e)&&a({kind:"rename",path:e,name:f}):a({kind:"mkdir",path:`${e}/${f.toLowerCase()}`}))},children:l(le,{autoFocus:!0,"aria-label":u.kind==="rename"?`New name for ${Pe(e)}`:`New folder in ${Pe(e)}`,className:"h-7",placeholder:u.kind==="mkdir"?"New folder's name":"",maxLength:64,value:u.text,onFocus:p=>p.currentTarget.select(),onChange:p=>c({...u,text:p.target.value}),onBlur:p=>p.currentTarget.form?.requestSubmit(),onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),c(null))}})})]}):l(Bn,{active:r,label:Pe(e),count:t,depth:n,toggle:o,drop:e,onClick:s,onDoubleClick:()=>c({kind:"rename",text:Pe(e)}),onMenu:d})}function Xu({children:e}){return l("p",{className:"mt-3 px-2 pb-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e})}function dO({row:e,index:t,count:n,active:r,onOpen:o,onChanged:s,onDeleted:i,onMenu:a}){let u=J(),[c,d]=_(null),[p,f]=_(""),h=async x=>{let b=await x.catch(v=>({state:"refused",reason:v instanceof Error?v.message:String(v)}));b.state==="ok"?(f(""),s()):f(b.reason)},g=(x,b)=>a({title:e.name,x,y:b,entries:[{label:"Rename",run:()=>d(e.name)},{label:"Move up",disabled:t===0,run:()=>{h(u.call("artifacts.saved.move",{id:e.id,to:t-1}))}},{label:"Move down",disabled:t===n-1,run:()=>{h(u.call("artifacts.saved.move",{id:e.id,to:t+1}))}},{label:"Delete",run:()=>{h(u.call("artifacts.saved.delete",{id:e.id})).then(i)}}]});return c!==null?l("form",{className:"px-2 py-0.5",onSubmit:x=>{x.preventDefault(),c.trim()&&c.trim()!==e.name&&h(u.call("artifacts.saved.rename",{id:e.id,name:c})),d(null)},children:l(le,{autoFocus:!0,"aria-label":`New name for ${e.name}`,className:"h-7",onFocus:x=>x.currentTarget.select(),value:c,maxLength:60,onChange:x=>d(x.target.value),onBlur:x=>x.currentTarget.form?.requestSubmit(),onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),d(null))}})}):m("div",{className:`group relative flex items-center gap-1 rounded px-2 py-1 text-sm ${r?"bg-muted font-medium":"hover:bg-muted/60"}`,onContextMenu:x=>{x.preventDefault(),g(x.clientX,x.clientY)},children:[l("span",{className:"w-4 shrink-0"}),l("button",{type:"button","aria-current":r?"page":void 0,className:"min-w-0 flex-1 truncate text-left",onClick:o,onDoubleClick:()=>d(e.name),children:e.name}),l("button",{type:"button","aria-label":`More for ${e.name}`,"aria-haspopup":"menu",className:"shrink-0 rounded px-1 text-muted-foreground opacity-0 hover:text-foreground focus:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:x=>{let b=x.currentTarget.getBoundingClientRect();g(b.right-176,b.bottom+4)},children:"\u2026"}),p?l("span",{className:"absolute left-6 top-full z-10 text-xs text-destructive",children:p}):null]})}function yE({subPath:e}){let t=J(),n=zm(),r=as(e),o=Fm(),[s,i]=_(null),[a,u]=_(""),[c,d]=_(null),p=q(()=>d(null),[]),[f,h]=_(r.kind==="search"?r.q:""),[g,x]=_(lO);K(()=>{let $=!0;return t.call("artifacts.folders",{}).then(P=>{$&&(i(P),u(""))},P=>$&&u(P instanceof Error?P.message:String(P))),()=>{$=!1}},[t,o]);let b=r.kind==="place"&&r.place.kind==="folder"?r.place.path:null,v=new Set([...g,...b?ka(b):[]]),w=$=>{let P=new Set(g);P.has($)?P.delete($):P.add($),x(P);try{Mn()?.setItem(xE,JSON.stringify([...P]))}catch{}},C=s?.folders??[],y=$=>C.some(P=>Ut(P.path)===$),T=C.filter($=>ka(Ut($.path)).every(P=>v.has(P))),N=$=>S1(r,$),S=$=>r.kind==="group"&&r.by===$||r.kind==="place"&&r.place.kind===$;return K(()=>h(r.kind==="search"?r.q:""),[e]),m("nav",{"aria-label":"Artifacts",className:"flex flex-col gap-0.5 px-2 pb-4",children:[l("form",{className:"pb-2",onSubmit:$=>{$.preventDefault(),f.trim()&&n({kind:"search",q:f.trim()})},children:l(le,{"aria-label":"Search all artifacts",className:"h-8",placeholder:"Search all",value:f,onChange:$=>h($.target.value)})}),a?m("p",{className:"px-2 text-xs text-destructive",children:["Couldn't load the folders: ",a]}):null,l(Bn,{active:N(Bt(Ze)),label:"Inbox",count:s?.inbox,drop:Ze,onClick:()=>n(Bt(Ze))}),l(Bn,{active:N({kind:"place",place:{kind:"recent"}}),label:"Recent",onClick:()=>n({kind:"place",place:{kind:"recent"}})}),l(Bn,{active:N({kind:"place",place:{kind:"starred"}}),label:"Starred",count:s?.starred,onClick:()=>n({kind:"place",place:{kind:"starred"}})}),l(Xu,{children:"Library"}),l(Bn,{active:N(Bt("")),label:"All folders",drop:"",onClick:()=>n(Bt(""))}),T.map($=>{let P=$.path.split("/").length,L=y($.path)?l("button",{type:"button","aria-label":v.has($.path)?`Close ${Pe($.path)}`:`Open ${Pe($.path)}`,"aria-expanded":v.has($.path),className:"w-4 shrink-0 text-xs text-muted-foreground",onClick:()=>w($.path),children:v.has($.path)?"\u25BE":"\u25B8"}):void 0;return l(uO,{path:$.path,active:b===$.path,count:$.pages,depth:P,toggle:L,onOpen:()=>n(Bt($.path)),onMenu:d},$.path)}),s&&!C.length?l("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No folders yet."}):null,s?.saved.length?m(he,{children:[l(Xu,{children:"Saved"}),s.saved.map(($,P)=>l(dO,{row:$,index:P,count:s.saved.length,active:r.kind==="saved"&&r.id===$.id,onOpen:()=>n({kind:"saved",id:$.id}),onChanged:hr,onDeleted:()=>r.kind==="saved"&&r.id===$.id&&n(Bt("")),onMenu:d},$.id))]}):null,l(Xu,{children:"Views"}),l(Bn,{active:S("project"),label:"By project",onClick:()=>n({kind:"group",by:"project"})}),l(Bn,{active:S("conversation"),label:"By conversation",onClick:()=>n({kind:"group",by:"conversation"})}),s?.tags.length?m(he,{children:[l(Xu,{children:"Tags"}),s.tags.map($=>l(Bn,{active:N({kind:"place",place:{kind:"tag",tag:$.tag}}),label:`#${$.tag}`,count:$.pages,onClick:()=>n({kind:"place",place:{kind:"tag",tag:$.tag}})},$.tag))]}):null,l(As,{request:c,onClose:p})]})}var _E=1e3,pO=250;function vE(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function fO(){try{return globalThis.matchMedia?.("(hover: none)").matches===!0}catch{return!1}}var hO=[{by:"name",label:"Name"},{by:"modified",label:"Modified"},{by:null,label:"Project",wide:!0},{by:"conversation",label:"Conversation",wide:!0},{by:null,label:"Tags",wide:!0},{by:"versions",label:"Versions",wide:!0},{by:"size",label:"Size",wide:!0}],wE=(e,t)=>`${e} ${t}${e===1?"":"s"}`,mO=e=>[e.folders.length?wE(e.folders.length,"folder"):"",e.pages.length||!e.folders.length?`${wE(e.pages.length,"page")}${e.more?"+":""}`:""].filter(Boolean).join(" \xB7 "),gO=e=>e<1024?`${e} B`:`${Math.round(e/1024)} KB`;function xO(){let e=Y(null),[t,n]=_("wide");return ot(()=>{let r=e.current;if(!r)return;let o=()=>n(C1(r.getBoundingClientRect().width));o();let s=new ResizeObserver(o);return s.observe(r),()=>s.disconnect()},[]),[e,t]}function CE(e){return l(R,{size:"sm",variant:"secondary",onClick:hr,children:"Refresh"})}function TE({subPath:e}){let t=J(),n=J(),r=Ie(),o=zm(),s=as(e),i=e,a=Fm();ke("artifacts",hr);let[u,c]=xO(),[d,p]=_(()=>nm(Mn(),s)),[f,h]=_(null),[g,x]=_(null),[b,v]=_(""),[w,C]=_(""),[y,T]=_(null),[N,S]=_(!0),[$,P]=_(!1),[L,ne]=_(null),[se,_e]=_([]),[ie,Q]=_(null),[j,G]=_(null),[ee,be]=_(""),[H,xe]=_(new Set),[Cr,Cn]=_(null),[ue,ze]=_(null),zt=q(()=>ze(null),[]),[mt,gt]=_(null),[vi,To]=_(null),[S_,E_]=_(null),[Ro,nf]=_(()=>D1(Mn())),[wi,rf]=_(new Map),ki=Y(Ro);ki.current=Ro;let{run:Qn,undo:N_}=Ra(hr),[Ll,A_]=lE(),jt=aE(),C_=Y(jt?.n??0);K(()=>{if(!jt||jt.n===C_.current||(C_.current=jt.n,nf(O=>z1(O,jt.action,jt.moved)),rf(O=>M1(O,jt.action,jt.moved)),s.kind!=="place"||s.place.kind!=="folder"))return;let k=uu(jt.action,jt.moved,s.place.path);k!==null&&k!==s.place.path&&o(Bt(k))},[jt]),K(()=>F1(Mn(),Ro),[Ro]),K(()=>{if(!g)return;let k=new Set(g.folders.map(O=>O.path));nf(O=>[...O].every(Z=>k.has(Z))?O:new Set([...O].filter(Z=>k.has(Z))))},[g]),K(()=>{if(f?.state!=="refused"||!g||s.kind!=="place"||s.place.kind!=="folder")return;let k=s.place.path,O=new Set(g.folders.map(Z=>Z.path));k===""||k===Ze||O.has(k)||o(Bt(ka(Ut(k)).filter(Z=>O.has(Z)).at(-1)??""))},[f,g]);let[LT,of]=_(null),Tr=Y(null);K(()=>()=>{Tr.current&&clearTimeout(Tr.current)},[]);let Ml=Y(null),Dl=Y(null),Fl=k=>be(k instanceof Error?k.message:String(k)),MT=k=>{p(k),N1(Mn(),k)},zl=s.kind==="saved"?g?.saved.find(k=>k.id===s.id)??null:null,Qt=s.kind==="saved"?zl?tm(zl.place):null:s,Si=Qt?is(Qt):null,sf=zl?.query??"";K(()=>{T(null),xe(new Set),Cn(null),gt(null),ze(null),ne(null),P(!1),_e([]),p(nm(Mn(),as(i)))},[i]),K(()=>{Ll&&(Ll.kind==="move"?(gt({kind:"move",items:Ll.items}),A_()):Dl.current&&(Dl.current.focus(),A_()))},[Ll,i,f===null]),K(()=>of(null),[i]),K(()=>{v(sf),C(sf)},[i,sf]),K(()=>{if(b===w)return;let k=setTimeout(()=>C(b),250);return()=>clearTimeout(k)},[b,w]),K(()=>{t.call("artifacts.folders",{}).then(x,Fl)},[t,a]),K(()=>{let k=!0;h(null),be("");let O=Si===null?null:tm(Si),Z=ae=>k&&h(ae);if(!O){s.kind==="saved"&&g&&Z({state:"refused",reason:"That saved filter is gone."});return}return O.kind==="group"?t.call("artifacts.group",{by:O.by}).then(ae=>Z({state:"groups",by:O.by,groups:ae.groups}),Fl):O.kind==="search"?t.call("artifacts.search",{q:O.q,versions:!0}).then(ae=>Z({state:"search",results:ae.results}),Fl):O.kind==="place"&&t.call("artifacts.library",{place:O.place,sort:d,limit:_E,query:w,zone:vE()}).then(Z,Fl),()=>{k=!1}},[t,Si,d,a,w,g===null]);let af=Y({key:"",listed:!1});K(()=>{if(!L||!f||f.state!=="ok"&&f.state!=="search")return;let k=`${L.threadId}\0${L.name}`,O=f.state==="ok"?pf().find(ae=>ae.threadId===L.threadId&&ae.name===L.name)?.path:f.results.filter(ae=>ae.threadId===L.threadId&&ae.name===L.name).map(ae=>ae.kind==="moved"?ae.to:ae.path)[0],Z=af.current.key===k&&af.current.listed;O===void 0&&Z&&hf.length>0||(af.current={key:k,listed:O!==void 0},O!==void 0?O!==L.path&&(ne({...L,path:O}),T(ae=>ae===null||ae===L.path?O:ae)):Z&&(P(!1),ne(null)))},[f,L,wi]);let lf=Y(0),$o=q(k=>{let O=++lf.current;ne(k),Q(null),G(null),n.call("artifacts.read",{threadId:k.threadId,name:k.name}).then(Z=>{if(O!==lf.current||(Q(nu(Z)),G(Z.state==="ok"?ou(Z.page):null),Z.state!=="ok"))return;t.call("artifacts.seen",{threadId:k.threadId,name:k.name}).catch(()=>{});let ae=we=>we.map(Kt=>Kt.threadId===k.threadId&&Kt.name===k.name?{...Kt,unread:!1}:Kt);h(we=>we?.state==="ok"?{...we,pages:ae(we.pages)}:we),rf(we=>new Map([...we].map(([Kt,qn])=>[Kt,qn.branch.state==="ok"?{...qn,branch:{...qn.branch,pages:ae(qn.branch.pages)}}:qn])))},Z=>O===lf.current&&Q(ss(Z)))},[n,t]),T_=Y(a);K(()=>{T_.current!==a&&(T_.current=a,L&&$o(L))},[a]);let cf=k=>k?g?.projects.find(O=>O.id===k)?.name??k:"\u2014",uf=Gc(w),DT=uf.subfolders||_a(uf),df=f?.state==="ok"?I1(f,k=>wi.get(k)?.branch,Ro):[],Ve=f?.state==="ok"?P1(df):f?.state==="search"?f.results.map(k=>({kind:"page",path:k.kind==="moved"?k.to:k.path,threadId:k.threadId,name:k.name})):f?.state==="groups"?f.groups.map(k=>({kind:"folder",path:k.key})):[],Rr=`${a}:${d.by}:${d.desc?"desc":"asc"}`,R_=Y(Rr);R_.current=Rr;let pf=()=>f?.state==="ok"?L1(f.pages,wi.values(),Rr):f?.state==="search"?[...new Map(f.results.map(k=>[k.page.path,k.page])).values()]:[],$_=k=>pf().find(O=>O.path===k);K(()=>{if(!f)return;let k=new Set(f.state==="ok"||f.state==="search"?Ve.map(O=>O.path):[]);xe(O=>O.size&&[...O].some(Z=>!k.has(Z))?new Set([...O].filter(Z=>k.has(Z))):O),T(O=>O!==null&&!k.has(O)?null:O),Cn(O=>O!==null&&!k.has(O)?null:O)},[f,Ve.map(k=>k.path).join(`
142
+ `)[0]:e.title}),m("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:[i?`Used ${ys(e.title)}`:e.kind==="relay"?"Relayed to another machine":"Message to another conversation",!i&&nn(e)?` \xB7 ${nn(e)}`:""]}),i?m("span",{className:"mt-1 flex flex-wrap items-center gap-2 text-xs",children:[l("span",{className:"font-medium",children:yS(a)}),u?m("span",{className:"rounded-md border border-border-hairline px-1.5 py-0.5 text-muted-foreground",children:[ys(e.title)," now: ",km(u)?.label.toLowerCase()??u]}):null]}):null]})]}),e.thread?m(R,{size:"sm",variant:"ghost","aria-label":"Conversation",onClick:()=>s.toThread(e.thread),children:[l(pe,{name:"MessageSquare","aria-hidden":!0,className:"size-4 sm:hidden"}),l("span",{className:"hidden sm:inline",children:"Conversation"})]}):l("span",{})]})}function xP({meta:e,now:t,state:n}){let r=J(),o=J(),[s]=_(()=>Date.now()-30*Am),i=We(()=>o.call("activity.permissionUse",{from:s}),[o,s]);ke("approvals",i.reload);let[a,u]=_(null);if(!n.data||!i.data)return l("p",{className:"text-sm text-muted-foreground",children:n.error||i.error||"Loading\u2026"});let{mailSend:c}=n.data,d=n.data.capabilities.filter(y=>wm(y)!==null),p=i.data,f=y=>bS(y,c,p),h=y=>{let T=f(y);return T!==null&&(T.uses>0||T.refused>0)},g=d.filter(y=>h(y.name)),x=d.filter(y=>!h(y.name)),b=n.data.standing.filter(y=>!y.revoked&&!y.expired),v=(y,T,N)=>{let S=Su.find($=>$.level===N);S&&r.call("approvals.setCapability",{name:y,settings:{...T,level:S.level}}).then(()=>{u({key:y,text:`Now ${S.label.toLowerCase()}.`}),n.reload()},$=>u({key:y,text:$ instanceof Error?$.message:String($)}))},w=y=>{r.call("approvals.requestStandingRevoke",{id:y.id}).then(T=>{u({key:Ru,text:T.decision==="allow"?`Revoked: ${y.description}.`:T.decision==="pending"?`Asked to revoke ${y.description}; it ends once you confirm.`:T.reason??`${y.description} wasn\u2019t revoked.`}),n.reload()},T=>u({key:Ru,text:T instanceof Error?T.message:String(T)}))},C=y=>l("select",{"aria-label":`${ys(y.name)}: when to ask`,value:y.settings.level,onChange:T=>v(y.name,y.settings,T.target.value),className:"h-7 cursor-pointer rounded-md border border-input bg-background px-1.5 text-xs font-medium",children:Su.map(T=>l("option",{value:T.level,title:T.about,children:T.label},T.level))});return m("div",{className:"space-y-3",children:[g.map(y=>{let T=f(y.name);return m("div",{className:"space-y-1 rounded-xl border border-border-hairline bg-surface-raised px-3 py-2.5",children:[m("div",{className:"flex items-center gap-2",children:[l("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:ys(y.name)}),C(y)]}),l("p",{className:"text-xs text-muted-foreground",children:km(y.settings.level)?.about}),vm(y.name,c)?l("p",{className:"text-xs text-muted-foreground",children:"Its level also decides the mail I send."}):null,l("p",{className:"text-sm",children:_S(T)}),m("p",{className:"text-xs text-muted-foreground",children:["Last: ",vu(T.last,t,e.zone,N=>Ee(N,e.zone))]}),a?.key===y.name?l("p",{role:"status",className:"text-xs text-muted-foreground",children:a.text}):null]},y.name)}),b.length||a?.key===Ru?m("div",{className:"space-y-2",children:[l("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Standing permissions"}),b.map(y=>m("div",{className:"space-y-1 rounded-xl border border-border-hairline bg-surface-raised px-3 py-2.5",children:[l("p",{className:"text-sm",children:y.description}),m("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[m("span",{className:"min-w-0 flex-1",children:["On ",y.station,y.expiresAt!==null?`, until ${Ge(y.expiresAt,e.zone,{day:"numeric",month:"short"})}`:""]}),l(R,{size:"sm",variant:"outline",onClick:()=>w(y),children:"Revoke"})]})]},y.id)),a?.key===Ru?l("p",{role:"status",className:"text-xs text-muted-foreground",children:a.text}):null]}):null,x.length?m("div",{className:"space-y-1.5",children:[l("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Not used in 30 days"}),x.map(y=>m("div",{className:"flex items-center gap-2 text-sm",children:[l("span",{className:"min-w-0 flex-1 truncate",children:ys(y.name)}),C(y)]},y.name)),l("p",{className:"text-xs leading-snug text-muted-foreground",children:"You might not need these any more; Read only is the tightest."})]}):null,l("p",{className:"text-xs leading-snug text-muted-foreground",children:"Sensitive commands and how long questions wait are in Settings \u2192 Permissions."})]})}function PS({meta:e,now:t,open:n,signal:r,remember:o}){let s=J(),i=hP(),[a,u]=_(""),[c,d]=_(""),[p,f]=_("all"),[h,g]=_("anyone"),[x,b]=_(()=>({when:"all",chosen:Date.now()})),v=x.when,[w,C]=_(1),[y]=_(()=>Date.now()+fP);K(()=>{let j=setTimeout(()=>d(a.trim()),250);return()=>clearTimeout(j)},[a]),K(()=>C(1),[c,p,h,v]);let T=mP(v,e,x.chosen),N=i.data?.capabilities??[],S=j=>xS(j,N),$=We(()=>s.call("activity.behalfCounts",{from:T}),[s,T]),{data:P,error:L}=ks({from:T??0,to:y,kinds:p==="all"?null:p==="messages"?["message","relay"]:["approval"],project:null,behalf:{capabilities:p==="all"||p==="messages"?null:S(p),search:c||null,who:h}},w,r);K(()=>{P&&o(P.entries)},[P,o]);let ne=new Map(N.map(j=>[j.name,j.settings.level])),se=i.data?ne.get(i.data.mailSend):void 0;se&&!ne.has(dr)&&ne.set(dr,se);let _e=j=>j==="messages"?$.data?.messages??0:($.data?.capabilities??[]).filter(G=>S(j).includes(G.capability)).reduce((G,ee)=>G+ee.count,0),ie=[];for(let j of P?.entries??[]){let G=Ge(j.at,e.zone,{month:"long",year:"numeric"}),ee=ie.at(-1);ee?.month===G?ee.entries.push(j):ie.push({month:G,entries:[j]})}let Q=$.data?.since??null;return m("div",{className:"flex flex-wrap items-start gap-8",children:[m("div",{className:"min-w-0 flex-[999_1_34rem] space-y-5",children:[l(rn,{eyebrow:"Activity",title:"On your behalf"}),l("p",{className:"text-sm text-muted-foreground",children:"Everything I did that left your machines or used your accounts, and who said yes to it. Search it by person, place or command."}),m("label",{className:"flex items-center gap-2",children:[l(pe,{name:"Search","aria-hidden":!0,className:"size-4 text-muted-foreground"}),l("span",{className:"sr-only",children:"Search the record"}),l(le,{value:a,onChange:j=>u(j.target.value),placeholder:"Search the record","aria-label":"Search the record"}),P?m("span",{className:"shrink-0 text-xs text-muted-foreground",children:[P.entries.length,P.more?"+":""," ",P.entries.length===1?"result":"results"]}):null]}),l("div",{className:"flex flex-wrap gap-1.5",role:"group","aria-label":"What",children:[{id:"all",label:"All kinds"},...gS].map(j=>m("button",{type:"button","aria-pressed":p===j.id,onClick:()=>f(j.id),className:V("cursor-pointer rounded-full px-3 py-1 text-xs font-semibold",p===j.id?"bg-foreground text-background":"bg-muted text-muted-foreground hover:text-foreground"),children:[j.label,j.id!=="all"&&$.data?` \xB7 ${_e(j.id)||"none"}`:""]},j.id))}),m("div",{className:"flex flex-wrap items-center gap-3",children:[l(_t,{label:"Who said yes",value:h,onChange:g,options:[{value:"anyone",label:"Anyone"},{value:"owner",label:"You"},{value:"standing",label:"A standing permission"},{value:"level",label:"Its level"}]}),l(_t,{label:"When",value:v,onChange:j=>b({when:j,chosen:Date.now()}),options:[{value:"all",label:"All time"},{value:"month",label:"Last 30 days"},{value:"year",label:"This year"}]})]}),!P||p!=="all"&&p!=="messages"&&!i.data?l(Oe,{children:L||i.error||"Loading\u2026"}):P.entries.length===0?l(Oe,{children:c?`Nothing on record for \u201C${c}\u201D.`:"Nothing on record for these choices."}):m("div",{className:"space-y-5",children:[ie.map(({month:j,entries:G})=>m("section",{"aria-label":j,className:"space-y-2",children:[l("h2",{className:"px-1 text-xs font-semibold text-muted-foreground",children:j}),l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:G.map((ee,be)=>l(gP,{entry:ee,meta:e,levels:ne,open:n,first:be===0},je(ee)))})]},j)),P.more?m(R,{variant:"ghost",onClick:()=>C(j=>j+1),children:[l(pe,{name:"ChevronDown","aria-hidden":!0,className:"size-4"}),"Show older"]}):m("p",{className:"px-1 text-sm text-muted-foreground",children:[c?`That\u2019s everything for \u201C${c}\u201D. `:"",Q!==null?`The record starts on ${Ge(Q,e.zone,{day:"numeric",month:"long",year:"numeric"})}${bn(Q,e.zone)===e.today?", today":""}, and nothing is ever trimmed from it.`:""]})]})]}),m("aside",{className:"w-full shrink-0 space-y-3 xl:w-80","aria-label":"Your permissions, last 30 days",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"Your permissions, last 30 days"}),l(xP,{meta:e,now:t,state:i})]})]})}var bP=14,yP=366*864e5;function OS({since:e,meta:t,now:n,open:r,undo:o,needs:s,signal:i,remember:a}){let u=yn(),c=e.from,[d]=_(()=>Date.now()+yP),[p,f]=_(bP),{data:h,error:g,partial:x}=Ss({from:c??0,to:d,kinds:null,project:null,overlap:!0},i);K(()=>{h&&a(h.entries)},[h,a]);let b=bs(h?.entries??[],{from:c??0,to:d}),v=yu(b.filter(S=>S.kind!=="visit"),t.zone),w=v.slice(0,p),C=Tu(w.map(S=>S.day)),y=S=>Ee(S,t.zone);if(c===null)return m("div",{className:"mx-auto max-w-3xl space-y-6",children:[l(rn,{eyebrow:"Activity",title:"Since you looked"}),l(Oe,{children:"There\u2019s no earlier visit to catch up from yet. Today\u2019s timeline has everything so far."}),l(R,{variant:"outline",onClick:()=>u("timeline"),children:"Open today"})]});let T=b.filter(S=>(S.kind==="change"||S.kind==="filing")&&S.state!=="undone"&&S.state!=="reverted"),N=no(b);return m("div",{className:"flex flex-wrap items-start gap-8",children:[m("div",{className:"min-w-0 flex-[999_1_34rem] space-y-6",children:[l(rn,{eyebrow:`Since you last looked \xB7 ${Fn(n-c,"long")}`,title:`${vu(c,n,t.zone,y)} to now`,children:l(_t,{label:"Show",value:"since",onChange:S=>S==="today"&&u("timeline"),options:[{value:"since",label:"Since you looked"},{value:"today",label:"Just today"}]})}),e.note?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:t.assistant,size:28}),m("div",{className:"min-w-0",children:[l("p",{className:"whitespace-pre-wrap text-base leading-relaxed",children:e.note.body}),l("p",{className:"mt-1.5 text-xs text-muted-foreground",children:wu(t.assistant,e.note.at,n,t.zone,y)})]})]}):h?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:t.assistant,size:28}),l("p",{className:"text-base leading-relaxed",children:ro(N,Es(s),"away")})]}):null,l(Ns,{needs:s,title:"Still waiting for you",hint:"Oldest first",now:n}),T.length?m("section",{"aria-label":"Changed while you were away",className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:"Changed while you were away"}),l("span",{className:"ml-auto text-xs text-muted-foreground",children:"Undo is here while it can be"})]}),l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:T.map((S,$)=>l(oo,{entry:S,meta:t,now:n,onOpen:r,undo:o,first:$===0,showDay:!0},je(S)))})]}):null,m("section",{"aria-label":"Day by day",className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:"Day by day"}),l("span",{className:"ml-auto text-xs text-muted-foreground",children:"Newest first \xB7 open a day to read all of it"})]}),h?w.length===0?l(Oe,{children:"Nothing happened while you were away."}):l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:w.map(({day:S,entries:$},P)=>l("li",{className:P?"border-t border-border-hairline":void 0,children:m("div",{className:"flex items-start gap-3 px-4 py-3",children:[m("div",{className:"min-w-0 flex-1",children:[m("p",{className:"text-sm font-semibold",children:[uS(S,c,n,t.zone,y),m("span",{className:"ml-2 text-xs font-medium text-muted-foreground",children:[$.length," ",$.length===1?"entry":"entries",x&&P===v.length-1?" or more":""]})]}),l("p",{className:"mt-0.5 text-sm leading-snug text-foreground/85",children:C.get(S)??ro(no($),0,S===bn(n,t.zone)?"so-far":"day")})]}),l(R,{size:"sm",variant:"outline",onClick:()=>u("timeline",null,S),children:"Open"})]})},S))}):l(Oe,{children:g||"Loading\u2026"}),h&&v.length>p?m(R,{variant:"ghost",onClick:()=>f(S=>S+7),children:[l(pe,{name:"ChevronDown","aria-hidden":!0,className:"size-4"}),"Show earlier days"]}):null,x?m("p",{className:"px-1 text-sm text-muted-foreground",children:["More than ",zn.toLocaleString()," entries since you looked, so the summary and these counts cover the newest ",zn.toLocaleString(),"."]}):null]})]}),m("aside",{className:"hidden w-72 shrink-0 space-y-2 xl:block","aria-label":"Done while you were away",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"Done while you were away"}),h?pr(N).length?l("ul",{className:"space-y-1.5 text-sm",children:pr(N).map(S=>l("li",{children:S},S))}):l("p",{className:"text-sm text-muted-foreground",children:"Nothing yet."}):null]})]})}var LS={you:"bg-foreground/55",work:"bg-timeline-accent",checks:"bg-foreground/25",changes:"bg-warning"},_P=[{lane:"work",label:"Work"},{lane:"checks",label:"Checks and routines"},{lane:"you",label:"You"},{lane:"changes",label:"Changes and asks"}],MS=4;function vP(e){let t=J(),n=We(async()=>({week:e,...await t.call("activity.week",{week:e})}),[t,e]);return{data:n.data?.week===e?n.data:null,error:n.error,reload:n.reload}}function wP({entries:e,monday:t,today:n,meta:r,now:o}){let s=yn();return m("section",{"aria-label":"The week by hour",className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:"The week by hour"}),l("span",{className:"ml-auto text-xs text-muted-foreground",children:"Pick a day to open it"})]}),m("div",{className:"space-y-1 rounded-xl border border-border-hairline bg-surface-raised px-3 py-3",children:[bm(t).map(i=>{let a=xu(i,r.zone),u=i>n,c=e.filter(f=>_m(f,a,o)),d=_u(c,a,o),p=ym(e,a,o);return m("button",{type:"button",disabled:u,onClick:()=>s("timeline",null,i),"aria-label":`${Ct(i)}: ${u?"ahead":`${ku(p)} of work`}`,className:V("grid w-full cursor-pointer grid-cols-[3rem_minmax(0,1fr)_4.5rem] items-center gap-3 rounded-md px-1 py-1.5 text-left hover:bg-state-hover disabled:cursor-default disabled:hover:bg-transparent",i===n&&"bg-surface-selected"),children:[l("span",{className:V("text-xs font-semibold",u&&"text-muted-foreground"),children:ur(i)}),l("span",{className:V("relative h-3 rounded-full bg-muted",u&&"opacity-50"),children:d.map(f=>l("span",{className:V("absolute top-0.5 h-2 rounded-full",LS[f.lane]),style:{left:`${f.start*100}%`,width:f.end===null?"0.375rem":`max(0.375rem, ${(f.end-f.start)*100}%)`}},f.key))}),l("span",{className:"text-right text-xs tabular-nums text-muted-foreground",children:u?"ahead":`${ku(p)}${i===n?" so far":""}`})]},i)}),l("div",{className:"flex flex-wrap gap-x-4 gap-y-1 px-1 pt-2 text-2xs text-muted-foreground","aria-hidden":!0,children:_P.map(i=>m("span",{className:"inline-flex items-center gap-1.5",children:[l("span",{className:V("size-2 rounded-full",LS[i.lane])}),i.label]},i.lane))})]})]})}function kP({entries:e,needs:t,meta:n,now:r,open:o}){let[s,i]=_(!1),a=fS(e),u=s?a:a.slice(0,MS),c=a.slice(MS);return!a.length&&!fr(t)?null:m("section",{"aria-label":"What's waited on you",className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:"What\u2019s waited on you"}),l("span",{className:"ml-auto hidden text-xs text-muted-foreground sm:inline",children:"Open ones first, then the longest answered"})]}),l(Ns,{needs:t,title:"Waiting now",hint:"Oldest first",now:r}),u.length?l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:u.map(({entry:d,ms:p},f)=>l("li",{className:f?"border-t border-border-hairline":void 0,children:m("button",{type:"button",onClick:()=>o(d),className:"flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left hover:bg-state-hover",children:[m("span",{className:"min-w-0 flex-1",children:[m("span",{className:"block truncate text-sm font-medium",children:["Asked to use ",d.title]}),m("span",{className:"block text-xs text-muted-foreground",children:["Approval \xB7 asked ",Ge(d.startedAt??d.at,n.zone,{weekday:"short"})," ",Ee(d.startedAt??d.at,n.zone)]})]}),m("span",{className:"shrink-0 text-right text-xs",children:[l("span",{className:"block font-semibold tabular-nums",children:Fn(p,"long")}),l("span",{className:"block text-muted-foreground",children:nn(d)})]})]})},je(d)))}):null,c.length&&!s?m("button",{type:"button",onClick:()=>i(!0),className:"cursor-pointer px-1 text-xs font-semibold text-timeline-accent hover:underline",children:["And ",c.length," more this week, all answered within ",Fn(c[0].ms,"long"),". Show them"]}):null]})}function SP({entries:e,span:t,meta:n,now:r}){let o=en(),s=dS(e,t,r);return s.length?m("section",{"aria-label":"Where the work has gone",className:"space-y-2",children:[l("h2",{className:"px-1 text-sm font-semibold",children:"Where the work has gone"}),l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:s.map((i,a)=>{let u=n.projects.find(c=>c.key===i.key);return m("li",{className:V("flex items-center gap-3 px-4 py-2.5",a>0&&"border-t border-border-hairline"),children:[m("div",{className:"min-w-0 flex-1",children:[m("p",{className:"flex flex-wrap items-baseline gap-x-2 text-sm",children:[l("span",{className:"font-medium",children:u?.name??i.key}),l("span",{className:"text-2xs font-bold tracking-wide text-muted-foreground",children:i.key}),l("span",{className:"whitespace-nowrap tabular-nums text-muted-foreground",children:ku(i.hours)})]}),l("p",{className:"text-sm text-muted-foreground",children:pS(i)})]}),u?l(R,{size:"sm",variant:"ghost",onClick:()=>{xn({origin:"all",project:u.id}),o("today")},children:"Open"}):null]},i.key)})})]}):null}function DS({title:e,hint:t,entries:n,empty:r,meta:o,now:s,open:i,undo:a}){return m("section",{"aria-label":e,className:"space-y-2",children:[m("div",{className:"flex items-center gap-2 px-1",children:[l("h2",{className:"text-sm font-semibold",children:e}),t?l("span",{className:"ml-auto hidden text-xs text-muted-foreground sm:inline",children:t}):null]}),n.length?l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:n.map((u,c)=>l(oo,{entry:u,meta:o,now:s,onOpen:i,undo:a,first:c===0,showDay:!0},je(u)))}):l("p",{className:"px-1 text-sm text-muted-foreground",children:r})]})}function EP({meta:e,today:t,monday:n}){let r=nt(),o=en(),s=Math.max(1,7-Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${n}T12:00:00Z`))/864e5)),{data:i}=We(()=>r.call("tasks.upcoming",{from:t,days:s}),[r,t,s]),a=(i?.items??[]).filter(u=>u.at>=Date.now()).slice(0,8);return m("section",{className:"space-y-2","aria-label":"Still ahead this week",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"Still ahead this week"}),a.length===0?l("p",{className:"text-sm text-muted-foreground",children:"Nothing timed for the rest of the week."}):null,l("ol",{className:"space-y-1",children:a.map(u=>m("li",{className:"grid grid-cols-[5.5rem_minmax(0,1fr)] gap-2 text-sm",children:[m("span",{className:"text-xs tabular-nums text-muted-foreground",children:[Ge(u.at,e.zone,{weekday:"short"})," ",Ee(u.at,e.zone)]}),l("span",{className:"min-w-0 leading-snug",children:u.task.title})]},`${u.task.id}-${u.at}`))}),l("button",{type:"button",onClick:()=>o("upcoming"),className:"cursor-pointer text-xs font-semibold text-timeline-accent hover:underline",children:"See it in Tasks \u203A Upcoming"})]})}function FS({meta:e,now:t,open:n,undo:r,needs:o,signal:s,remember:i,initialDay:a}){let u=Ie(),c=J(),d=xm(e.today),[p,f]=_(xm(a??e.today)),h=p===d,g={from:qr(p,e.zone),to:qr(tn(p,7),e.zone)},{data:x,error:b,partial:v}=Ss({...g,kinds:null,project:null,overlap:!0},s);K(()=>{x&&i(x.entries)},[x,i]);let w=vP(p),C=bm(p).filter(Q=>Q<=e.today),y=Tu(C),[T,N]=_(!1),[S,$]=_(""),P=bs(x?.entries??[],g),L=no(P),ne=Q=>Ee(Q,e.zone),se=()=>{N(!0),$(""),c.call("activity.talkWeek",{week:p}).then(({thread:Q})=>{N(!1),w.reload(),u.toThread(Q)},Q=>{N(!1),$(Q instanceof Error?Q.message:String(Q))})},_e=P.filter(Q=>Q.kind==="learned"||Q.kind==="change"),ie=hS(P);return m("div",{className:"flex flex-wrap items-start gap-8",children:[m("div",{className:"min-w-0 flex-[999_1_34rem] space-y-6",children:[m(rn,{eyebrow:h?`This week so far \xB7 ${Ct(p)} to now`:`${Ct(p)} to ${Ct(tn(p,6))}`,title:`Week of ${Ge(Date.parse(`${p}T12:00:00Z`),"UTC",{month:"long",day:"numeric"})}`,children:[l(R,{variant:"outline",size:"icon","aria-label":"The week before",onClick:()=>f(tn(p,-7)),children:l(pe,{name:"ChevronLeft","aria-hidden":!0,className:"size-4"})}),l(R,{variant:"outline",size:"icon","aria-label":"The week after",disabled:h,onClick:()=>f(tn(p,7)),children:l(pe,{name:"ChevronRight","aria-hidden":!0,className:"size-4"})}),m(R,{onClick:se,disabled:T,children:[l(pe,{name:"MessageSquare","aria-hidden":!0,className:"size-4"}),w.data?.thread?"Back to this week\u2019s conversation":`Talk it over with ${e.assistant}`]})]}),S?l("p",{role:"alert",className:"text-sm text-destructive",children:S}):null,w.error&&!w.data?m("p",{role:"alert",className:"text-sm text-destructive",children:["I couldn\u2019t load the note for this week: ",w.error]}):null,w.data?.note?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:e.assistant,size:28}),m("div",{className:"min-w-0",children:[l("p",{className:"whitespace-pre-wrap text-base leading-relaxed",children:w.data.note.body}),l("p",{className:"mt-1.5 text-xs text-muted-foreground",children:wu(e.assistant,w.data.note.at,t,e.zone,ne)})]})]}):x?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:e.assistant,size:28}),l("p",{className:"text-base leading-relaxed",children:ro(L,Es(o),h?"week":"past-week")})]}):null,v?m("p",{className:"px-1 text-sm text-muted-foreground",children:["This week has more than ",zn.toLocaleString()," entries, so these counts cover the newest ",zn.toLocaleString(),"."]}):null,x?m(he,{children:[l(wP,{entries:P,monday:p,today:e.today,meta:e,now:t}),h?l(kP,{entries:P,needs:o,meta:e,now:t,open:n}):null,l(SP,{entries:P,span:g,meta:e,now:t}),l(DS,{title:"How I\u2019ve changed",hint:"What I learned and what I changed about myself",entries:_e,empty:"No changes to me this week.",meta:e,now:t,open:n,undo:r}),l(DS,{title:"Hasn\u2019t gone well",entries:ie,empty:"Nothing went badly this week.",meta:e,now:t,open:n,undo:r})]}):l(Oe,{children:b||"Loading\u2026"})]}),m("aside",{className:"w-full shrink-0 space-y-6 xl:w-72","aria-label":"The week at a glance",children:[m("section",{className:"space-y-2","aria-label":"My note for each day",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"My note for each day"}),l("dl",{className:"space-y-1.5 text-sm",children:C.map(Q=>m("div",{className:"grid grid-cols-[4.5rem_minmax(0,1fr)] gap-2",children:[l("dt",{className:"text-xs font-semibold text-muted-foreground",children:Q===e.today?"Today":ur(Q,"long")}),l("dd",{className:V("leading-snug",!y.get(Q)&&"text-muted-foreground"),children:y.get(Q)??"Not written yet."})]},Q))})]}),h?l(EP,{meta:e,today:e.today,monday:p}):null,x?m("section",{className:"space-y-2",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:h?"This week so far":"That week"}),l("ul",{className:"space-y-1.5 text-sm",children:pr(L).map(Q=>l("li",{children:Q},Q))})]}):null]})]})}var $u=new Map;function NP(e){if(typeof window>"u"||!window.matchMedia)return null;let t=$u.get(e);if(t)return t;let n=window.matchMedia(e),r=new Set,o=()=>{for(let s of r)s()};return t={mql:n,subscribe(s){let i=r.size===0;return r.add(s),i&&n.addEventListener("change",o),()=>{r.delete(s),r.size===0&&(n.removeEventListener("change",o),$u.delete(e))}}},$u.set(e,t),t}function AP(e,t){return NP(e)?.subscribe(t)??(()=>{})}function CP(e){return typeof window>"u"||!window.matchMedia?!1:$u.get(e)?.mql.matches??window.matchMedia(e).matches}function Cm(e){return xt(t=>AP(e,t),()=>CP(e),()=>!1)}var TP="(max-width: 767px)",RP=Cf(null);function so(){let e=Tf(RP),t=Cm(TP);return e!==null?e:t}var Tm=globalThis.__bbPluginRuntime;if(Tm==null||Tm.reactDom==null)throw new Error('Cannot load "react-dom": this bundle must be loaded by the Moonlet app, which provides the shared plugin runtime (globalThis.__bbPluginRuntime).');var Iu=Tm.reactDom,YB="default"in Iu?Iu.default:Iu,{createPortal:zS,flushSync:qB,preconnect:JB,prefetchDNS:eU,preinit:tU,preinitModule:nU,preload:rU,preloadModule:oU,requestFormReset:sU,unstable_batchedUpdates:iU,useFormState:aU,useFormStatus:lU,version:cU}=Iu;var $P="select-none",IP=new Set(["button","checkbox","file","hidden","image","radio","range","reset","submit"]),XS=e=>V($P,e);function PP(e){return e instanceof HTMLTextAreaElement?!0:e instanceof HTMLInputElement?!e.disabled&&!e.readOnly&&!IP.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.closest("[contenteditable='true']")!==null:!1}function Pu(e){if(typeof document>"u")return;let t=document.activeElement;!t||!PP(t)||e!==null&&!e.contains(t)||t.blur()}function BS(){Pu(null)}function Rm(e){e.preventDefault()}var KS="pointer";typeof document<"u"&&(document.addEventListener("keydown",()=>{KS="keyboard"},{capture:!0}),document.addEventListener("pointerdown",()=>{KS="pointer"},{capture:!0}));function US(){let e="orbit";return{"data-bb-portaled-overlay":"","data-bb-plugin-root":"",...e!==void 0?{"data-bb-plugin":e}:{}}}var OP=120;var $m="--bb-drawer-keyboard-inset",LP=80;function Ou(e){e!==null&&(e.style.height="",e.style.bottom="",e.style.removeProperty($m))}function MP({layoutViewportHeight:e,visualViewportHeight:t,visualViewportOffsetTop:n}){let r=Math.round(e-(t+n));return r>=LP?r:0}function DP(e,t){K(()=>{let n=e.current,r=window.visualViewport;if(n===null||!t||!r)return;let o=null,s=()=>{if(o=null,r.scale!==1){Ou(n);return}let a=MP({layoutViewportHeight:n.ownerDocument.documentElement.clientHeight,visualViewportHeight:r.height,visualViewportOffsetTop:r.offsetTop});if(a===0){n.style.bottom="",n.style.removeProperty($m);return}n.style.bottom=`${a}px`,n.style.setProperty($m,`${a}px`)},i=()=>{o!==null&&window.cancelAnimationFrame(o),o=window.requestAnimationFrame(s)};return s(),r.addEventListener("resize",i),r.addEventListener("scroll",i),()=>{r.removeEventListener("resize",i),r.removeEventListener("scroll",i),o!==null&&window.cancelAnimationFrame(o),Ou(n)}},[t,e])}var FP=Tn(({asChild:e,open:t,onOpenChange:n,haspopup:r,onClick:o,children:s,className:i,...a},u)=>{let c=XS(i),d=f=>{o?.(f),f.defaultPrevented||(t||BS(),n(!t))},p={"aria-expanded":t,"aria-haspopup":r,"data-state":t?"open":"closed"};return e?l(Ql,{ref:u,onClick:d,onMouseDown:Rm,className:c,...p,...a,children:s}):l("button",{ref:u,type:"button",onClick:d,onMouseDown:Rm,className:c,...p,...a,children:s})});FP.displayName="MobileTrigger";var zP=["side","sideOffset","align","alignOffset","collisionPadding","collisionBoundary","arrowPadding","sticky","hideWhenDetached","avoidCollisions","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside"],EU=new Set(zP);function Lu({open:e,enabled:t=!0}){let[n,r]=_(!1),o=q(()=>r(!0),[]);return K(()=>{if(!t||!e||n)return;let s=null,i=null;s=window.requestAnimationFrame(()=>{s=null,i=window.requestAnimationFrame(()=>{i=null,o()})});let a=window.setTimeout(o,OP);return()=>{s!==null&&window.cancelAnimationFrame(s),i!==null&&window.cancelAnimationFrame(i),window.clearTimeout(a)}},[t,n,e,o]),{isContentRealized:t&&n,realizeContent:o}}var HS="cubic-bezier(0.32, 0.72, 0, 1)",KP=.25,XP=450,BP=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(","),Im=Symbol.for("bb.persistent-drawer-stack.v1");function UP(e){return typeof e=="object"&&e!==null&&"entries"in e&&Array.isArray(e.entries)&&"handleKeyDown"in e&&typeof e.handleKeyDown=="function"}function VS(e){let t=Reflect.get(e,Im);return UP(t)?t:void 0}function HP(e){return Array.from(e.querySelectorAll(BP)).filter(t=>t.closest('[aria-hidden="true"], [inert]')===null)}function VP(e,t){let n=e?.closest("[data-bb-portaled-overlay]");return n!=null&&n!==t}function ZP(e,t){let n=t.ownerDocument.activeElement;if(!t.contains(n)&&VP(n,t))return;let r=HP(t);if(e.preventDefault(),r.length===0){t.focus({preventScroll:!0});return}let o=r[0],s=r[r.length-1];if(e.shiftKey){if(!t.contains(n)||n===t||n===o){s?.focus({preventScroll:!0});return}let a=r.indexOf(n);r[Math.max(0,a-1)]?.focus({preventScroll:!0});return}if(!t.contains(n)||n===t||n===s){o?.focus({preventScroll:!0});return}let i=r.indexOf(n);r[Math.min(r.length-1,i+1)]?.focus({preventScroll:!0})}function WP(e,t){let n=VS(e);if(n===void 0){let r=[],o=s=>{if(s.defaultPrevented)return;let i=r[r.length-1],a=i?.panel()??null;i===void 0||a===null||(s.key==="Escape"?(i.dismissOnEscape(s),s.preventDefault()):s.key==="Tab"&&ZP(s,a))};n={entries:r,handleKeyDown:o},Reflect.set(e,Im,n),e.addEventListener("keydown",o)}return n.entries.push(t),()=>{let r=VS(e);if(r===void 0)return;let o=r.entries.indexOf(t);o>=0&&r.entries.splice(o,1),r.entries.length===0&&(e.removeEventListener("keydown",r.handleKeyDown),Reflect.deleteProperty(e,Im))}}function jP({onAfterCloseAutoFocus:e,onBeforeCloseAutoFocus:t,onEscapeKeyDown:n,open:r,panelRef:o,requestClose:s}){let i=Y(null),a=Y(n);ot(()=>{a.current=n},[n]),ot(()=>{if(!r)return;let c=o.current;if(c===null)return;let d=c.ownerDocument,p=d.activeElement;i.current=p instanceof HTMLElement&&p!==d.body?p:null;let f=WP(d,{panel:()=>o.current,dismissOnEscape:h=>{a.current?.(h),h.defaultPrevented||s()}});return c.focus({preventScroll:!0}),f},[r,o,s]);let u=Y(r);ot(()=>{let c;if(u.current&&!r){t?.();let d=i.current;if(d?.isConnected&&d.closest('[aria-hidden="true"], [inert]')===null&&(d.focus({preventScroll:!0}),d.ownerDocument.activeElement!==d)){let p=d.ownerDocument.defaultView;if(p!==null){let f=p.requestAnimationFrame(()=>{d.isConnected&&d.closest('[aria-hidden="true"], [inert]')===null&&d.focus({preventScroll:!0}),e?.()});c=()=>p.cancelAnimationFrame(f)}}i.current=null,c===void 0&&e?.()}return u.current=r,c},[e,t,r])}function Mu({open:e,onOpenChange:t,onAfterCloseAutoFocus:n,closeOnBackdropClick:r=!0,srLabel:o,labelledBy:s,describedBy:i,contentClassName:a,motionDurationMs:u=220,onContentAnimationEnd:c,onEscapeKeyDown:d,onPointerDownOutside:p,onInteractOutside:f,children:h}){let g=Y(null),x=Y(null),b=Y(null),v=Y(null),w=Y(null),C=Ai(),y=US(),T=`transform ${u}ms ${HS}`,N=`opacity ${u}ms ${HS}`,S=Y(t);ot(()=>{S.current=t},[t]);let $=q(()=>{Pu(g.current),Ou(g.current),S.current(!1)},[]),P=q(()=>{Pu(g.current),Ou(g.current)},[]);jP({onAfterCloseAutoFocus:n,onBeforeCloseAutoFocus:P,onEscapeKeyDown:d,open:e,panelRef:g,requestClose:$});let L=()=>{let G=b.current;if(b.current=null,!!r){if(G!==null){let ee=new CustomEvent("dismissableLayer.pointerDownOutside",{cancelable:!0,detail:{originalEvent:G}});if(p?.(ee),f?.(ee),ee.defaultPrevented)return}$()}};DP(g,e);let ne=q(G=>{w.current!==G&&(w.current=G,c?.(G))},[c]);K(()=>{w.current=null;let G=window.setTimeout(()=>ne(e),u+50);return()=>window.clearTimeout(G)},[u,e,ne]);let se=q((G,ee,be)=>{let H=g.current,xe=x.current;H===null||xe===null||(H.style.transition=be?T:"none",H.style.transform=`translate3d(0, ${G}px, 0)`,xe.style.transition=be?N:"none",xe.style.opacity=String(Math.max(0,Math.min(1,1-G/ee))))},[N,T]),_e=q(G=>{if(!e||G.button!==0)return;G.currentTarget.setPointerCapture(G.pointerId);let ee=Date.now(),be=Math.max(g.current?.clientHeight??0,1);v.current={pointerId:G.pointerId,startY:G.clientY,lastY:G.clientY,lastTimeMs:ee,velocityY:0,height:be},se(0,be,!1),G.preventDefault()},[e,se]),ie=q(G=>{let ee=v.current;if(ee===null||ee.pointerId!==G.pointerId)return;let be=Date.now(),H=be-ee.lastTimeMs;H>0&&(ee.velocityY=(G.clientY-ee.lastY)/H*1e3,ee.lastY=G.clientY,ee.lastTimeMs=be),se(Math.max(0,G.clientY-ee.startY),ee.height,!1),G.preventDefault()},[se]),Q=q((G,ee)=>{let be=v.current;if(be===null||be.pointerId!==G.pointerId)return;v.current=null;let H=Math.max(0,G.clientY-be.startY);!ee&&(H>=be.height*KP||be.velocityY>=XP)?(se(be.height,be.height,!0),$()):se(0,be.height,!0),G.preventDefault()},[$,se]),j=typeof document>"u"?null:document.body;return j===null?null:zS(m(he,{children:[l("div",{ref:x,...y,"aria-hidden":"true","data-persistent-drawer-backdrop":"","data-state":e?"open":"closed",className:"fixed inset-0 z-50 bg-black/40",style:{opacity:e?1:0,pointerEvents:e?"auto":"none",transition:N},onPointerDown:G=>{b.current=G.nativeEvent},onClick:L,onTouchMove:G=>G.preventDefault()}),m("div",{ref:g,...y,"aria-hidden":!e,"aria-labelledby":s??(o===void 0?void 0:C),"aria-describedby":i,"aria-modal":e||void 0,"data-bb-portaled-overlay":"","data-persistent-drawer-content":"","data-state":e?"open":"closed",inert:!e,role:"dialog",tabIndex:-1,className:V("fixed inset-x-0 bottom-0 z-50 mt-24 flex max-h-[calc(92dvh-var(--bb-drawer-keyboard-inset,0px))] flex-col rounded-t-xl border bg-background pb-[var(--bb-safe-area-bottom,env(safe-area-inset-bottom))] outline-none",a),style:{transform:e?"translate3d(0, 0, 0)":"translate3d(0, 100%, 0)",transition:T,willChange:e?"transform":void 0},onTransitionEnd:G=>{G.currentTarget===G.target&&G.propertyName==="transform"&&ne(e)},children:[l("div",{"data-persistent-drawer-handle":"",className:"mx-auto flex h-8 w-16 shrink-0 touch-none cursor-grab items-center justify-center active:cursor-grabbing",onPointerDown:_e,onPointerMove:ie,onPointerUp:G=>Q(G,!1),onPointerCancel:G=>Q(G,!0),children:l("div",{className:"h-1 w-10 rounded-full bg-muted-foreground/20"})}),o===void 0?null:l("h2",{id:C,className:"sr-only",children:o}),h]})]}),j)}function Fu({open:e,onClose:t,label:n,side:r="center",children:o}){let s=so(),{isContentRealized:i}=Lu({open:e,enabled:s});return K(()=>{if(!e||s)return;let a=u=>{u.key==="Escape"&&(u.preventDefault(),t())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,s,t]),s?l(Mu,{open:e,onOpenChange:a=>a?void 0:t(),srLabel:n,children:i?l("div",{className:"max-h-[85dvh] overflow-y-auto overscroll-contain pb-6",children:o}):null}):e?r==="right"?l("aside",{role:"dialog","aria-label":n,className:"fixed inset-y-0 right-0 z-40 flex w-full max-w-xl flex-col overflow-y-auto border-l border-border bg-background shadow-2xl",children:o}):l("div",{className:"fixed inset-0 z-40 grid place-items-center bg-surface-scrim p-4",onMouseDown:a=>a.target===a.currentTarget&&t(),children:l("div",{role:"dialog","aria-label":n,className:"max-h-[90dvh] w-full max-w-lg overflow-y-auto rounded-2xl border border-border bg-background shadow-2xl",children:o})}):null}var QP={todo:[{label:"Today",text:"today"},{label:"Tomorrow",text:"tomorrow"},{label:"This weekend",text:"this weekend"},{label:"Next week",text:"next week"},{label:"In a month",text:"in a month"}],followup:[{label:"Tomorrow morning",text:"check back tomorrow 9am"},{label:"In 3 days",text:"check back in 3 days 9am"},{label:"Next week",text:"check back next week 9am"}],scheduled:[{label:"Later today",text:"today 6pm"},{label:"Tomorrow morning",text:"tomorrow 9am"},{label:"Every weekday",text:"every weekday at 9am"},{label:"Every week",text:"every monday at 9am"},{label:"Monthly",text:"monthly on the 1st at 9am"}]};function YS({kind:e,zone:t,initial:n,onChange:r}){let o=nt(),[s,i]=_(n??""),[a,u]=_(null),c=Y(r);c.current=r;let d=p=>{i(p),u(null),c.current(null,!p.trim())};return K(()=>{if(!s.trim()){u(null),c.current(null,!0);return}let p=!0,f=setTimeout(()=>{o.call("tasks.when",{text:s,kind:e}).then(h=>{p&&(u(h.ok?{ok:!0,reading:h.reading,next:h.next}:h),c.current(h.ok?h.when:null,h.ok))})},220);return()=>{p=!1,clearTimeout(f)}},[s,e,o]),m("div",{className:"space-y-2.5",children:[l(le,{"aria-label":"When, in your own words",placeholder:e==="scheduled"?"every other friday at 4pm":e==="followup"?"check back friday 9am":"by friday",value:s,onChange:p=>d(p.target.value)}),a?.ok?m("div",{className:"rounded-lg bg-surface-selected px-3 py-2 text-sm",children:[m("p",{className:"flex items-center gap-2 font-semibold",children:[l(pe,{name:"Check","aria-hidden":!0,className:"size-4 text-success"}),Qr(a.reading)]}),a.next.length?l("ul",{className:"mt-1.5 space-y-0.5 pl-6 text-xs text-muted-foreground",children:a.next.map(p=>m("li",{children:[Ge(p,t,{weekday:"short",day:"numeric",month:"short"})," \xB7 ",Ee(p,t)]},p))}):null]}):a?l("p",{role:"status",className:"text-sm text-destructive-text",children:a.error}):null,l("div",{className:"flex flex-wrap gap-1.5",children:QP[e].map(p=>l("button",{type:"button",className:"cursor-pointer rounded-full border border-border px-2.5 py-1 text-xs font-medium hover:bg-state-hover",onClick:()=>d(p.text),children:p.label},p.label))})]})}function io({label:e,children:t}){return m("label",{className:"block space-y-1.5",children:[l("span",{className:"text-xs font-semibold text-muted-foreground",children:e}),t]})}var Du=["urgent","high","medium","low","none"],GP=["owner","assistant","others"];function Pm(e,t){return e.find(n=>n===t)??null}var ZS="h-9 w-full cursor-pointer rounded-md border border-input bg-background px-2 text-sm";function qS({open:e,onClose:t,meta:n,onMade:r}){let{change:o,error:s,busy:i}=Ea(),[a,u]=_(""),[c,d]=_("personal"),[p,f]=_("todo"),[h,g]=_(null),[x,b]=_(!0),[v,w]=_("medium"),[C,y]=_("assistant"),[T,N]=_(""),[S,$]=_(""),[P,L]=_(0),ne=n?.assistant??"Assistant",se=()=>{u(""),g(null),$(""),N(""),L(ie=>ie+1)};return l(Fu,{open:e,onClose:t,label:"New task",children:m("form",{onSubmit:async ie=>{if(ie.preventDefault(),!a.trim()||!x)return;let Q=await o({action:"create",task:{project:c,title:a,kind:p,when:h,priority:v,move:C,waitingOn:C==="others"&&T||null,description:S}});Q&&(se(),r(Q))},className:"space-y-4 p-5",children:[l("h2",{className:"text-lg font-semibold",children:"New task"}),l(io,{label:"What",children:l(le,{autoFocus:!0,value:a,onChange:ie=>u(ie.target.value),placeholder:"Renew the passport"})}),l("div",{className:"flex flex-wrap items-center gap-3",children:l(_t,{label:"Kind",value:p,onChange:ie=>{f(ie),ie==="followup"&&y("others")},options:["todo","followup","scheduled"].map(ie=>({value:ie,label:m(he,{children:[l(Ht,{glyph:ie==="scheduled"?"once":ie,className:"size-3.5"}),mu[ie]]})}))})}),l(io,{label:"When",children:l(YS,{kind:p,zone:n?.zone??"UTC",onChange:(ie,Q)=>{g(ie),b(Q)}},`${p}-${P}`)}),m("div",{className:"grid grid-cols-2 gap-3",children:[l(io,{label:"Project",children:l("select",{className:ZS,value:c,onChange:ie=>d(ie.target.value),children:(n?.projects??[{id:"personal",key:"ME",name:"Personal"}]).map(ie=>m("option",{value:ie.id,children:[ie.name," (",ie.key,")"]},ie.id))})}),l(io,{label:"Priority",children:l("select",{className:ZS,value:v,onChange:ie=>w(Pm(Du,ie.target.value)??"medium"),children:Du.map(ie=>l("option",{value:ie,children:cs[ie]},ie))})})]}),l(io,{label:"Whose move",children:l(_t,{label:"Whose move",value:C,onChange:y,options:[{value:"owner",label:"Mine"},{value:"assistant",label:`${ne}\u2019s`},{value:"others",label:"Waiting on someone"}]})}),C==="others"?l(io,{label:"Waiting on",children:l(le,{value:T,onChange:ie=>N(ie.target.value),placeholder:"Acme Mutual"})}):null,l(io,{label:"Notes",children:l("textarea",{value:S,onChange:ie=>$(ie.target.value),rows:3,className:"w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Anything that helps"})}),s?l("p",{role:"alert",className:"text-sm text-destructive-text",children:s}):null,m("div",{className:"flex justify-end gap-2 pt-1",children:[l(R,{type:"button",variant:"outline",onClick:t,children:"Cancel"}),l(R,{type:"submit",disabled:i||!a.trim()||!x||C==="others"&&!T.trim(),children:"Add task"})]})]})})}var YP=/^(?:https?:\/\/[^\s]+|\/api\/v1\/plugins\/tasks\/http\/attachments\/download\?attachmentId=[A-Za-z0-9_%-]+)$/i,WS="inline-flex max-w-full items-center gap-1.5 truncate rounded-md border border-border px-2 py-1 text-xs font-medium";function qP({link:e}){let t=Ie(),n=en(),r=m(he,{children:[l(pe,{name:e.kind==="pull_request"?"GitPullRequest":e.kind==="mail"?"Mail":e.kind==="conversation"?"ChildThread":"ExternalLink","aria-hidden":!0,className:"size-3.5"}),l("span",{className:"truncate",children:e.label??e.ref})]}),o=V(WS,"cursor-pointer hover:bg-state-hover");if(e.kind==="conversation"&&/^thr_[A-Za-z0-9_-]+$/.test(e.ref))return l("button",{type:"button",className:o,title:"Open the conversation",onClick:()=>t.toThread(e.ref),children:r});if(e.kind==="task")return l("button",{type:"button",className:o,title:"Open the task",onClick:()=>n("today",e.ref),children:r});if(YP.test(e.ref)){let s=e.ref.startsWith("/");return l("a",{href:e.ref,className:o,title:e.ref,...s?{download:e.label??!0}:{target:"_blank",rel:"noreferrer noopener"},children:r})}return l("span",{className:WS,title:e.ref,children:r})}var jS=200,QS=1e4,GS=e=>({owner:"Your move",assistant:`${e}\u2019s move`,others:"Waiting on others"});function JS({open:e,taskRef:t,meta:n,onClose:r}){let[o,s]=_("Task");return l(Fu,{open:e,onClose:r,label:o,side:"right",children:t?l(JP,{taskRef:t,meta:n,onClose:r,onLabel:s},t):null})}function JP({taskRef:e,meta:t,onClose:n,onLabel:r}){let o=nt(),{change:s,error:i}=Ea(),[a,u]=_(!1),[c,d]=_(""),[p,f]=_(jS),{data:h,error:g}=We(()=>o.call("tasks.show",{ref:e,recent:p}),[o,e,p]),[x,b]=_(""),[v,w]=_(""),[C,y]=_(!1),[T,N]=_({when:null,ok:!1}),[S,$]=_(!1),[P,L]=_(""),[ne,se]=_(!1),[_e,ie]=_(""),Q=t?.assistant??"Assistant",j=t?.zone??"UTC",G=h?.task.title??"Task";if(K(()=>r(G),[G,r]),!h)return l("p",{className:"p-6 text-sm text-muted-foreground",children:g||"Loading\u2026"});let ee=h.task,be=ee.id;return m(he,{children:[m("div",{className:"flex items-center gap-2 border-b border-border-hairline px-5 py-3 text-xs text-muted-foreground",children:[l("span",{className:"font-semibold text-foreground",children:ee.key}),l("span",{"aria-hidden":!0,children:"\xB7"}),l("span",{children:ee.project.name}),h.aliases.length?m("span",{children:["\xB7 also ",h.aliases.join(", ")]}):null,l(R,{variant:"ghost",size:"icon",className:"ml-auto size-8","aria-label":"Close",onClick:n,children:l(pe,{name:"ChevronRight","aria-hidden":!0,className:"size-4"})})]}),m("div",{className:"space-y-6 px-5 py-5",children:[m("div",{className:"flex items-start gap-3",children:[l(lm,{task:ee,onToggle:()=>{s(ee.status==="open"?{action:"done",ref:be,note:null}:{action:"reopen",ref:be,why:null})}}),ne?l("form",{className:"flex-1",onSubmit:H=>{H.preventDefault(),s({action:"update",ref:be,patch:{title:_e}}).then(xe=>xe&&se(!1))},children:l(le,{autoFocus:!0,value:_e,onChange:H=>ie(H.target.value),onBlur:()=>se(!1),"aria-label":"Title"})}):l("button",{type:"button",className:V("flex-1 cursor-text text-left text-xl font-semibold leading-snug",ee.status!=="open"&&"text-muted-foreground line-through"),onClick:()=>{ie(ee.title),se(!0)},children:ee.title})]}),m("dl",{className:"grid grid-cols-[7rem_minmax(0,1fr)] items-center gap-x-3 gap-y-2.5 text-sm",children:[l("dt",{className:"text-muted-foreground",children:"Kind"}),m("dd",{className:"flex items-center gap-1.5 font-medium",children:[l(Ht,{glyph:jr(ee),className:"text-timeline-accent"}),mu[ee.kind]]}),l("dt",{className:"text-muted-foreground",children:"Whose move"}),m("dd",{className:"flex flex-wrap items-center gap-2",children:[l("select",{"aria-label":"Whose move",className:"h-8 cursor-pointer rounded-md border border-input bg-background px-2 text-sm font-medium",value:a?"others":ee.move,onChange:H=>{let xe=Pm(GP,H.target.value);xe&&(xe==="others"?(d(ee.waitingOn??""),u(!0)):(u(!1),s({action:"update",ref:be,patch:{move:xe}})))},children:Object.entries(GS(Q)).map(([H,xe])=>l("option",{value:H,children:H==="others"&&ee.waitingOn?`Waiting on ${ee.waitingOn}`:xe},H))}),a?m("form",{className:"flex gap-2",onSubmit:H=>{H.preventDefault(),c.trim()&&s({action:"update",ref:be,patch:{move:"others",waitingOn:c}}).then(xe=>xe&&u(!1))},children:[l(le,{autoFocus:!0,value:c,onChange:H=>d(H.target.value),placeholder:"Who it waits on","aria-label":"Who it waits on",className:"h-8 w-44 text-sm"}),l(R,{size:"sm",type:"submit",disabled:!c.trim(),children:"Save"})]}):null]}),l("dt",{className:"text-muted-foreground",children:"From"}),m("dd",{className:"flex min-w-0 items-center gap-2",children:[l(De,{origin:ee.origin,assistant:Q,size:18}),l("span",{className:"truncate",children:ee.origin==="assistant"?`${Q}${ee.why?`: ${ee.why}`:""}`:"You"})]}),l("dt",{className:"text-muted-foreground",children:"Priority"}),m("dd",{className:"flex items-center gap-2",children:[l(us,{level:ee.priority}),l("select",{"aria-label":"Priority",className:"h-8 cursor-pointer rounded-md border border-input bg-background px-2 text-sm font-medium",value:ee.priority,onChange:H=>{let xe=Pm(Du,H.target.value);xe&&s({action:"update",ref:be,patch:{priority:xe}})},children:Du.map(H=>l("option",{value:H,children:cs[H]},H))})]}),l("dt",{className:"text-muted-foreground",children:"Project"}),l("dd",{children:l("select",{"aria-label":"Project",className:"h-8 cursor-pointer rounded-md border border-input bg-background px-2 text-sm font-medium",value:ee.project.id,onChange:H=>{s({action:"move",ref:be,project:H.target.value})},children:(t?.projects??[ee.project]).map(H=>m("option",{value:H.id,children:[H.name," (",H.key,")"]},H.id))})}),ee.doneWhen?m(he,{children:[l("dt",{className:"self-start text-muted-foreground",children:"Done when"}),l("dd",{className:"leading-relaxed",children:ee.doneWhen})]}):null]}),m("div",{className:"rounded-xl bg-surface-selected px-4 py-3.5",children:[l("p",{className:"text-xs font-semibold text-muted-foreground",children:ee.kind==="followup"?"Next check":ee.kind==="scheduled"?"When":"Due"}),C?m("div",{className:"mt-2 space-y-3",children:[l(YS,{kind:ee.kind,zone:j,onChange:(H,xe)=>N({when:H,ok:xe})}),m("div",{className:"flex gap-2",children:[l(R,{size:"sm",disabled:!T.ok,onClick:()=>{s({action:"update",ref:be,patch:{when:T.when}}).then(H=>H&&y(!1))},children:"Save"}),l(R,{size:"sm",variant:"outline",onClick:()=>y(!1),children:"Cancel"})]})]}):m(he,{children:[l("p",{className:"mt-0.5 text-base font-semibold",children:ee.whenText?Qr(ee.whenText):"Not set"}),ee.dueAt?l("p",{className:"text-xs text-muted-foreground",children:Ge(ee.dueAt,j,{weekday:"long",day:"numeric",month:"long",hour:"numeric",minute:"2-digit"})}):null,m("div",{className:"mt-3 flex flex-wrap gap-2",children:[m(R,{size:"sm",variant:"outline",onClick:()=>y(!0),children:[l(pe,{name:"Clock","aria-hidden":!0,className:"size-3.5"}),"Change when"]}),ee.status==="open"&&ee.move!=="owner"?l(R,{size:"sm",variant:"outline",onClick:()=>{s({action:"update",ref:be,patch:{move:"owner",why:"you took it over"}})},children:"I\u2019ll take it from here"}):null]})]})]}),ee.description?l("p",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground/90",children:ee.description}):null,m("section",{className:"space-y-2",children:[m("h3",{className:"text-sm font-semibold",children:["Steps"," ",h.steps.length?m("span",{className:"font-normal text-muted-foreground",children:[h.steps.filter(H=>H.doneAt).length," of ",h.steps.length]}):null]}),l("ul",{className:"space-y-1",children:h.steps.map(H=>m("li",{className:"flex items-center gap-2.5 text-sm",children:[l("input",{type:"checkbox","aria-label":H.title,className:"size-4 cursor-pointer accent-foreground",checked:H.doneAt!==null,onChange:xe=>{s({action:"checkStep",ref:be,position:H.position,done:xe.target.checked})}}),l("span",{className:V(H.doneAt&&"text-muted-foreground line-through"),children:H.title}),H.doneBy?l("span",{className:"ml-auto text-xs text-muted-foreground",children:H.doneBy==="assistant"?Q:H.doneBy==="owner"?"You":"System"}):null]},H.position))}),l("form",{className:"flex gap-2",onSubmit:H=>{H.preventDefault(),v.trim()&&s({action:"addStep",ref:be,title:v}).then(xe=>xe&&w(""))},children:l(le,{value:v,onChange:H=>w(H.target.value),placeholder:"Add a step","aria-label":"Add a step",className:"h-8 text-sm"})})]}),h.links.length?m("section",{className:"space-y-2",children:[l("h3",{className:"text-sm font-semibold",children:"Linked"}),l("div",{className:"flex flex-wrap gap-2",children:h.links.map(H=>l(qP,{link:H},`${H.kind}:${H.ref}`))})]}):null,m("section",{className:"space-y-3",children:[l("h3",{className:"text-sm font-semibold",children:"Journal"}),h.earlier!==null?p<QS?m("button",{type:"button",onClick:()=>f(H=>Math.min(H+jS,QS)),className:"flex cursor-pointer items-center gap-2 text-sm font-semibold text-timeline-accent hover:underline",children:[l(pe,{name:"ChevronUp","aria-hidden":!0,className:"size-3.5"}),"Show earlier"]}):m("p",{className:"text-xs text-muted-foreground",children:["Earlier lines: moonlet orbit tasks journal --task ",h.task.key," --before ",h.earlier]}):null,l("ol",{className:"relative space-y-3 border-l border-border-hairline pl-5",children:h.journal.map(H=>m("li",{className:"relative",children:[l("span",{className:"absolute -left-[1.85rem] top-0.5",children:H.actor==="system"?l("span",{className:"block size-4 rounded-full border border-border bg-muted"}):l(De,{origin:H.actor==="assistant"?"assistant":"owner",assistant:Q,size:18})}),m("p",{className:"text-xs text-muted-foreground",children:[Ge(H.at,j,{weekday:"short",day:"numeric",month:"short"})," \xB7 ",Ee(H.at,j)," \xB7"," ",H.actor==="assistant"?Q:H.actor==="owner"?"You":"System"]}),l("p",{className:V("mt-0.5 whitespace-pre-wrap text-sm leading-relaxed",H.actor==="owner"&&H.what==="note"&&"rounded-lg bg-muted px-3 py-2",H.what==="created"&&"text-muted-foreground"),children:H.body})]},H.seq))}),m("form",{className:"flex gap-2",onSubmit:H=>{H.preventDefault(),x.trim()&&s({action:"note",ref:be,body:x}).then(xe=>xe&&b(""))},children:[l(le,{value:x,onChange:H=>b(H.target.value),placeholder:`Add a note, or something for ${Q} to know`,"aria-label":"Add a note"}),l(R,{type:"submit",disabled:!x.trim(),children:"Add"})]})]}),i?l("p",{role:"alert",className:"text-sm text-destructive-text",children:i}):null,m("div",{className:"flex flex-wrap items-center gap-2 border-t border-border-hairline pt-4",children:[ee.status==="open"?m(he,{children:[m(R,{size:"sm",onClick:()=>{s({action:"done",ref:be,note:null})},children:[l(pe,{name:"Check","aria-hidden":!0,className:"size-3.5"}),"Done"]}),S?m("form",{className:"flex flex-1 gap-2",onSubmit:H=>{H.preventDefault(),P.trim()&&s({action:"drop",ref:be,reason:P}).then(xe=>xe&&$(!1))},children:[l(le,{autoFocus:!0,value:P,onChange:H=>L(H.target.value),placeholder:"Why it no longer matters","aria-label":"Why drop it",className:"h-8 text-sm"}),l(R,{size:"sm",variant:"outline",type:"submit",disabled:!P.trim(),children:"Drop"})]}):l(R,{size:"sm",variant:"outline",onClick:()=>$(!0),children:"Drop"})]}):m(R,{size:"sm",variant:"outline",onClick:()=>{s({action:"reopen",ref:be,why:null})},children:[l(pe,{name:"RotateCcw","aria-hidden":!0,className:"size-3.5"}),"Reopen"]}),m("span",{className:"ml-auto text-xs text-muted-foreground",children:[ee.status==="open"?GS(Q)[ee.move]:ee.status==="done"?"Done":`Dropped: ${ee.reason??""}`,ee.closedAt?` \xB7 ${Ge(ee.closedAt,j,{day:"numeric",month:"short"})}`:""]})]})]})]})}function eO(e,t){let n=Ge(e.at,t.zone,{weekday:"long",day:"numeric",month:"long"}),r=e.startedAt??e.at,o=e.endedAt;return o!==null&&o-r>=6e4?`${n}, ${Ee(r,t.zone)}\u2013${Ee(o,t.zone)}`:`${n}, ${Ee(e.at,t.zone)}`}function tO(e,t){return e.actor==="owner"?"You":e.actor==="system"?"Moonlet itself":t.assistant}function eE({entry:e,open:t,meta:n,now:r,undo:o,onClose:s}){let i=Ie(),a=en(),u=e&&o.said?.ref===je(e)?o.said:null,c=e?bu(e):null,d=e?to(e,r):null;return l(Fu,{open:t&&e!==null,onClose:s,label:e?Ta(e):"Activity",side:"right",children:e?m("div",{className:"flex flex-col gap-6 p-5 sm:p-6",children:[m("div",{className:"flex items-start gap-3",children:[m("div",{className:"min-w-0 flex-1",children:[m("p",{className:"flex items-center gap-1.5 text-xs font-semibold text-muted-foreground",children:[l(_n,{kind:e.kind,className:"size-3.5 text-timeline-accent"}),[e.kind==="check"?e.title.split(":")[0]:eo[e.kind],eO(e,n),d].filter(Boolean).join(" \xB7 ")]}),l("h2",{className:"mt-1.5 text-xl font-semibold leading-snug tracking-tight",children:Ta(e)})]}),l(R,{variant:"ghost",size:"icon","aria-label":"Close",onClick:s,children:l(pe,{name:"X","aria-hidden":!0,className:"size-4"})})]}),m("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[nn(e)?l("span",{className:e.needsYou?"rounded-md bg-warning/15 px-2 py-1 font-semibold text-warning-text":"rounded-md bg-muted px-2 py-1 font-semibold",children:nn(e)}):null,e.task?m("button",{type:"button",onClick:()=>a("today",e.task.key),className:"cursor-pointer rounded-md border border-border-hairline px-2 py-1 font-semibold hover:bg-state-hover",children:[e.task.key," \xB7 ",e.task.title]}):null,m("span",{className:"inline-flex items-center gap-1.5 rounded-md border border-border-hairline px-2 py-1 text-muted-foreground",children:[e.actor==="system"?null:l(De,{origin:e.actor==="owner"?"owner":"assistant",assistant:n.assistant,size:14}),tO(e,n)]})]}),c?l("p",{className:"rounded-xl bg-surface-selected px-4 py-3 text-base leading-relaxed",children:c}):null,e.kind==="approval"?m("section",{className:"space-y-2",children:[l("h3",{className:"text-xs font-semibold text-muted-foreground",children:"What it asked to run"}),l("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 font-mono text-xs",children:e.detail})]}):e.detail&&e.kind!=="check"?l("p",{className:"whitespace-pre-wrap text-base leading-relaxed",children:e.detail}):null,e.kind==="change"?l(Of,{id:e.id,beforeLabel:"Before"},e.id):null,e.steps.length?m("section",{className:"space-y-2",children:[l("h3",{className:"text-xs font-semibold text-muted-foreground",children:e.kind==="approval"?"How it was decided":"How it went"}),l("ol",{className:"space-y-1.5 border-l border-border-hairline pl-4",children:e.steps.map((p,f)=>m("li",{className:"grid grid-cols-[4rem_minmax(0,1fr)] gap-2 text-sm",children:[l("span",{className:"text-xs tabular-nums text-muted-foreground",children:Ee(p.at,n.zone)}),l("span",{className:"min-w-0 break-words",children:p.text})]},`${p.at}-${f}`))})]}):null,m("div",{className:"flex flex-wrap items-center gap-2 border-t border-border-hairline pt-4",children:[e.thread?m(R,{onClick:()=>i.toThread(e.thread),children:[l(pe,{name:"MessageSquare","aria-hidden":!0,className:"size-4"}),"Open the conversation"]}):null,e.task?m(R,{variant:"outline",onClick:()=>a("today",e.task.key),children:["Open ",e.task.key]}):null,e.undo&&!u?.done?l(R,{variant:"outline",disabled:o.busy!==null,onClick:()=>o.undo(e),children:"Undo"}):null,u?l("span",{role:"status",className:u.done?"text-sm text-muted-foreground":"text-sm text-destructive",children:u.text}):null]})]}):null})}function nO(e){return e.fromThread?`${e.fromName??"(not listed)"} ${e.fromThread}${e.fromHost?` on ${e.fromHost}`:""}`:"outside Moonlet's conversations (unverified)"}function tE(){let e=J(),[t,n]=_(null),[r,o]=_(null),[s,i]=_(null),a=Y(()=>{});K(()=>{let d=!0,p=!1,f=!1,h=async()=>{if(p){f=!0;return}p=!0;do{f=!1;try{let x=await e.call("messages.state",null);d&&!f&&(n(x.held),o(null))}catch(x){d&&o(x instanceof Error?x.message:String(x))}}while(d&&f);p=!1};a.current=()=>{h()},h();let g=setInterval(()=>{p||h()},5e3);return()=>{d=!1,clearInterval(g),a.current=()=>{}}},[e]);let u=q(()=>a.current(),[]);ke("messages",u);let c=async(d,p)=>{i(p),o(null);try{let f=await e.call(d,{id:p});n(h=>h?.filter(g=>g.id!==f.id||f.status==="held")??null),u()}catch(f){o(f instanceof Error?f.message:String(f))}finally{i(null)}};return m("section",{className:"flex min-w-0 flex-col gap-2 text-sm","aria-label":"Held messages",children:[l("h2",{className:"font-medium",children:"Messages held for you"}),l("p",{className:"text-xs text-muted-foreground",children:"A message from a sender that isn't listed waits here for your yes. A sender outside Moonlet's conversations is unverified, and a message is information for its recipient, never an approval in your name."}),r&&l("p",{role:"alert",className:"text-destructive",children:r}),t===null?r?null:l("p",{className:"text-muted-foreground",children:"Loading messages\u2026"}):t.length===0?l("p",{className:"text-muted-foreground",children:"No held messages."}):l("ul",{className:"divide-y text-xs",children:t.map(d=>m("li",{className:"flex flex-col gap-1 py-2",children:[m("div",{className:"flex flex-wrap gap-2",children:[m("span",{className:"w-10 shrink-0 font-mono",children:["#",d.id]}),l("span",{className:"w-36 shrink-0 text-muted-foreground",children:new Date(d.at).toLocaleString()}),m("span",{className:"flex-1",children:["to ",l("span",{className:"font-medium",children:d.to})," from ",l("span",{className:"font-mono",children:nO(d)})]})]}),l("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-2 font-mono",children:d.text}),m("div",{className:"flex gap-2",children:[m(R,{size:"sm",disabled:s!==null,onClick:()=>{c("messages.deliver",d.id)},children:["Deliver to ",d.to]}),l(R,{size:"sm",variant:"ghost",disabled:s!==null,onClick:()=>{c("messages.discard",d.id)},children:"Discard"})]})]},d.id))})]})}function oO({meta:e,now:t,open:n,undo:r,needs:o,signal:s,remember:i,day:a,onDay:u}){let[c,d]=_("everything"),[p,f]=_(!0),[h,g]=_(""),[x,b]=_(null),v=xu(a,e.zone),{data:w,error:C,partial:y}=Ss({...v,kinds:null,project:h||null,overlap:!0},s);K(()=>{w&&i(w.entries)},[w,i]);let T=a===e.today;K(()=>{b(null)},[a]);let N=se=>u(se),S=bs(w?.entries??[],v),$=iS(S,c,x,t),{running:P,groups:L}=aS($,e.zone,p),ne=no(S);return m("div",{className:"flex flex-wrap items-start gap-8",children:[m("div",{className:"min-w-0 flex-[999_1_34rem] space-y-6",children:[m(rn,{eyebrow:T?"Activity today":"Activity",title:Ct(a),children:[l(R,{variant:"outline",size:"icon","aria-label":"The day before",onClick:()=>N(tn(a,-1)),children:l(pe,{name:"ChevronLeft","aria-hidden":!0,className:"size-4"})}),l(R,{variant:"outline",size:"icon","aria-label":"The day after",disabled:T,onClick:()=>N(tn(a,1)),children:l(pe,{name:"ChevronRight","aria-hidden":!0,className:"size-4"})}),T?null:l(R,{variant:"outline",size:"sm",onClick:()=>N(e.today),children:"Back to today"})]}),w?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:e.assistant,size:28}),l("p",{className:"text-base leading-relaxed",children:ro(ne,Es(o),T?"today":"day")})]}):null,T?l(Ns,{needs:o}):null,w?l($S,{entries:S,span:v,now:t,zone:e.zone,stretch:x,onStretch:b}):null,m("div",{className:"flex flex-wrap items-center gap-3",children:[l(_t,{label:"Show",value:c,onChange:d,options:[{value:"everything",label:"Everything"},{value:"changed",label:"What changed"},{value:"work",label:"Work"}]}),m("label",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:["Project",m("select",{value:h,onChange:se=>g(se.target.value),className:"h-8 cursor-pointer rounded-md border border-input bg-background px-2 text-xs font-medium text-foreground",children:[l("option",{value:"",children:"All projects"}),e.projects.map(se=>m("option",{value:se.key,children:[se.name," (",se.key,")"]},se.id))]})]}),m("label",{className:"inline-flex cursor-pointer items-center gap-2 text-xs font-medium text-muted-foreground",children:[l("input",{type:"checkbox",className:"size-4 accent-foreground",checked:p,onChange:se=>f(se.target.checked)}),"Fold quiet checks"]})]}),w?m("div",{className:"space-y-5",children:[$.length===0?l(Oe,{children:x?"Nothing happened in that stretch.":T?"Nothing has happened yet today.":"Nothing happened that day."}):m(he,{children:[l(RS,{entries:P,meta:e,now:t,onOpen:n}),l(TS,{groups:L,meta:e,now:t,onOpen:n,undo:r})]}),y?m("p",{className:"px-1 text-sm text-muted-foreground",children:[T?"Today":"That day"," has more than ",zn.toLocaleString()," entries, so the summary, the hours and this list cover the newest"," ",zn.toLocaleString(),"."]}):null]}):l(Oe,{children:C||"Loading\u2026"})]}),l("aside",{className:"hidden w-72 shrink-0 space-y-6 xl:block","aria-label":"The day at a glance",children:m("section",{className:"space-y-2",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:T?"Today so far":"That day"}),w?pr(ne).length?l("ul",{className:"space-y-1.5 text-sm",children:pr(ne).map(se=>l("li",{children:se},se))}):l("p",{className:"text-sm text-muted-foreground",children:"Nothing yet."}):null]})})]})}var nE={undo:{hint:"Changes to your moonlet undo while their settings still match; library filings undo newest first.",empty:"Nothing to undo yet."},work:{hint:"Each piece of work with its steps and result, and the notes left on tasks.",empty:"No work yet."},asks:{hint:"Every approval asked, what it would run and how it was decided. Standing permissions are in Settings \u2192 Permissions.",empty:"Nothing asked yet."},messages:{hint:"Messages between conversations and relays to other machines. Recipient controls are in Settings \u2192 Permissions.",empty:"No messages yet."},checks:{hint:"Scheduled checks, routines and reminders, with what each found.",empty:"No checks have run yet."}};function sO({view:e,meta:t,now:n,open:r,undo:o,signal:s,remember:i}){let[a,u]=_(1),[c]=_(()=>Date.now()+366*864e5),{data:d,error:p}=ks({from:0,to:c,kinds:pm[e],project:null},a,s);K(()=>{d&&i(d.entries)},[d,i]);let f=xs.find(h=>h.id===e).label;return m("div",{className:"mx-auto max-w-4xl space-y-6",children:[l(rn,{eyebrow:"Activity",title:f}),l("p",{className:"text-sm text-muted-foreground",children:nE[e].hint}),d?d.entries.length===0?l(Oe,{children:nE[e].empty}):m("div",{className:"space-y-5",children:[yu(d.entries,t.zone).map(({day:h,entries:g})=>m("section",{"aria-label":Ct(h),className:"space-y-2",children:[l("h2",{className:"px-1 text-xs font-semibold text-muted-foreground",children:h===t.today?"Today":Ct(h)}),l("ol",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised shadow-sm",children:g.map((x,b)=>l(oo,{entry:x,meta:t,now:n,onOpen:r,undo:o,first:b===0},je(x)))})]},h)),d.more?m(R,{variant:"ghost",onClick:()=>u(h=>h+1),children:[l(pe,{name:"ChevronDown","aria-hidden":!0,className:"size-4"}),"Show older"]}):null]}):l(Oe,{children:p||"Loading\u2026"}),e==="undo"?l(tS,{}):null]})}function iO(){return m("div",{className:"mx-auto max-w-4xl space-y-6",children:[l(rn,{eyebrow:"Activity",title:"Needs you"}),l("p",{className:"text-sm text-muted-foreground",children:"Questions, approvals and changes waiting for your answer, and messages held until you say yes."}),l(pu,{}),l(Ci,{}),l(tE,{})]})}function aO({view:e,needs:t}){let n=yn();return l("nav",{"aria-label":"Activity views",className:"-mx-1 flex min-w-0 gap-1 overflow-x-auto px-1 md:hidden",children:xs.map(r=>m("button",{type:"button","aria-current":e===r.id?"page":void 0,"aria-label":r.id==="needs"&&t?`${r.short}, ${t}`:void 0,onClick:()=>n(r.id),className:V("inline-flex shrink-0 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-semibold",e===r.id?"bg-foreground text-background":"bg-muted text-muted-foreground"),children:[r.short,r.id==="needs"&&t?l("span",{className:"rounded-full bg-warning px-1.5 text-2xs text-background",children:t}):null]},r.id))})}function rE({subPath:e}){let t=fm(e),n=yn(),r=ds(),o=fs(),s=Nm(),i=Em(),a=i.data!==null&&i.data.from!==null&&o-i.data.from>144e5,u=t.landing&&i.data===null&&i.error==="",c=t.landing&&a?"since":t.view,d=Y(!1);K(()=>{!t.landing||i.data===null||d.current||(d.current=!0,a&&n("since"))},[t.landing,i.data,a,n]);let[p,f]=_(new Map),[h,g]=_(null),[x,b]=_(0),v=q(P=>f(L=>new Map([...L,...P.map(ne=>[je(ne),ne])])),[]),w=t.entry===null?null:p.get(t.entry)??null;SS(t.entry,v,x),K(()=>{w&&g(w)},[w]);let C=ES(()=>b(P=>P+1)),y={busy:C.busy,said:C.said,undo:P=>{C.undo(P)}},T=c==="timeline"||c==="week"?t.day:null,S={meta:r,now:o,open:P=>n(c,je(P),T),undo:y,signal:x,remember:v},$=!r||u?l(Oe,{children:"Loading\u2026"}):c==="timeline"?l(oO,{...S,meta:r,needs:s,day:t.day??r.today,onDay:P=>n("timeline",null,P===r.today?null:P)}):c==="week"?l(FS,{...S,meta:r,needs:s,initialDay:t.day},t.day??"this-week"):c==="since"?l(OS,{...S,meta:r,needs:s,since:i.data??{from:null,note:null}}):c==="behalf"?l(PS,{...S,meta:r}):c==="needs"?l(iO,{}):l(sO,{...S,meta:r,view:c},c);return m("main",{className:"h-full overflow-auto",children:[m("div",{className:"mx-auto flex max-w-7xl flex-col gap-6 p-4 sm:p-8",children:[l(aO,{view:c,needs:fr(s)}),$]}),r?l(eE,{entry:w??h,open:w!==null,meta:r,now:o,undo:y,onClose:()=>n(c,null,T)}):null]})}function oE({subPath:e}){let t=fm(e),n=yn(),r=Nm(),[o]=_(()=>Date.now()+366*864e5),s=ks({from:0,to:o,kinds:pm.undo,project:null},1,0).data?.entries.filter(p=>p.undo!==null).length??0,i={needs:fr(r),undo:s},a=Em().data,u=fs(),c=a?.from!=null?{since:Fn(u-a.from,"short")}:{},d=p=>m("button",{type:"button","aria-current":t.view===p.id?"page":void 0,"aria-label":i[p.id]?`${p.label}, ${i[p.id]}`:void 0,onClick:()=>n(p.id),className:V("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm",t.view===p.id?"bg-muted font-semibold":"hover:bg-muted/60"),children:[l("span",{className:"min-w-0 flex-1 truncate",children:p.label}),i[p.id]?l("span",{className:V("rounded-full px-1.5 text-2xs font-bold",p.id==="needs"?"bg-warning/20 text-warning-text":"text-muted-foreground"),children:i[p.id]}):c[p.id]?l("span",{className:"text-2xs font-semibold text-muted-foreground",children:c[p.id]}):null]},p.id);return m("nav",{"aria-label":"Activity",className:"flex flex-col gap-0.5 p-2",children:[xs.filter(p=>dm.includes(p.id)).map(d),l("p",{className:"mt-4 px-2 pb-1 text-xs font-semibold text-muted-foreground",children:"Narrow to"}),xs.filter(p=>!dm.includes(p.id)).map(d),l("p",{className:"px-2 pt-3 text-xs leading-snug text-muted-foreground",children:"Every view is the same record, narrowed. After a few hours away, Activity opens on what happened since you looked."})]})}var ao="application/x-moonlet-artifacts";function sE(){try{return globalThis.sessionStorage??null}catch{return null}}var Xn={outcome:null,stack:X1(sE()),request:null,changed:null},Om=new Set,Kn=e=>{if(Xn={...Xn,...e},e.stack)try{sE()?.setItem(om,JSON.stringify(e.stack))}catch{}for(let t of Om)t()},Lm=e=>(Om.add(e),()=>Om.delete(e));function iE(){let e=xt(Lm,()=>Xn);return[e.outcome,e.stack.length>0,()=>Kn({outcome:null})]}function aE(){return xt(Lm,()=>Xn.changed)}function Mm(e){Kn({request:e})}function lE(){return[xt(Lm,()=>Xn.request),()=>Kn({request:null})]}function zu(e){try{let t=JSON.parse(e.getData(ao)||"[]");return Array.isArray(t)?t.filter(n=>typeof n=="string").slice(0,Qk):[]}catch{return[]}}function Ra(e){let t=J(),n=q(async o=>{try{let s=await t.call("artifacts.change",{action:o});return s.state==="refused"?(Kn({outcome:{kind:"refused",reason:s.reason}}),!1):(s.change&&Kn({outcome:{kind:"done",summary:s.change.summary},stack:[...Xn.stack,s.change].slice(-rm),changed:{action:o,moved:s.change.moved,n:(Xn.changed?.n??0)+1}}),e(),!0)}catch(s){return Kn({outcome:{kind:"refused",reason:s instanceof Error?s.message:String(s)}}),!1}},[t,e]),r=q(async()=>{let o=Xn.stack.at(-1);if(o)try{let s=await t.call("artifacts.undo",{id:o.id});s.state==="ok"?Kn({outcome:{kind:"undone",summary:s.summary},stack:Xn.stack.slice(0,-1)}):Kn({outcome:{kind:"refused",reason:s.reason},stack:[]}),e()}catch(s){Kn({outcome:{kind:"refused",reason:s instanceof Error?s.message:String(s)}})}},[t,e]);return{run:n,undo:r}}var cE=176;function As({request:e,onClose:t}){let n=so(),r=e!==null,[o,s]=_(e);K(()=>{e&&s(e)},[e]);let{isContentRealized:i}=Lu({open:r,enabled:n});K(()=>{if(!r||n)return;let c=p=>{if(p instanceof KeyboardEvent){if(p.key!=="Escape")return;p.preventDefault(),p.stopPropagation()}t()},d=setTimeout(()=>{window.addEventListener("pointerdown",c),window.addEventListener("keydown",c,!0),window.addEventListener("scroll",c,!0)});return()=>{clearTimeout(d),window.removeEventListener("pointerdown",c),window.removeEventListener("keydown",c,!0),window.removeEventListener("scroll",c,!0)}},[r,n,t]);let a=(o?.entries??[]).filter(c=>c!==null),u=c=>{t(),c.run()};return n?l(Mu,{open:r,onOpenChange:c=>c?void 0:t(),srLabel:o?.title??"Actions",children:i?m("div",{className:"flex min-h-0 flex-col pb-4",children:[l("p",{className:"px-4 pt-1 pb-2 text-sm font-medium text-muted-foreground",children:o?.title}),l("div",{role:"menu","aria-label":o?.title,className:"flex max-h-[70dvh] flex-col overflow-y-auto overscroll-contain",children:a.map((c,d)=>l("button",{type:"button",role:"menuitem",disabled:c.disabled,className:"px-4 py-3 text-left text-base hover:bg-muted disabled:opacity-40",onClick:()=>u(c),children:c.label},`${d}-${c.label}`))})]}):null}):e?l("div",{role:"menu","aria-label":e.title,className:"fixed z-50 flex flex-col rounded-md border bg-background py-1 text-sm shadow-md",style:{width:cE,left:Math.max(8,Math.min(e.x,window.innerWidth-cE-8)),top:Math.max(8,Math.min(e.y,window.innerHeight-32*a.length-16))},onPointerDown:c=>c.stopPropagation(),children:a.map((c,d)=>l("button",{type:"button",role:"menuitem",disabled:c.disabled,className:"px-3 py-1.5 text-left hover:bg-muted disabled:opacity-40",onClick:()=>u(c),children:c.label},`${d}-${c.label}`))}):null}function Cs({label:e,query:t,keyName:n,choices:r,onQuery:o,onMenu:s}){let i=Yk(t,n)??"",a=r.some(d=>d.value.toLowerCase()===i.toLowerCase()),u=so(),c=`h-8 max-w-44 rounded-md border px-2 text-sm ${i?"border-foreground/40 bg-muted font-medium":"bg-background text-muted-foreground"}`;if(u){let d=r.find(p=>p.value.toLowerCase()===i.toLowerCase());return l("button",{type:"button","aria-label":e,"aria-haspopup":"menu",className:`${c} truncate text-left`,onClick:p=>{let f=p.currentTarget.getBoundingClientRect();s({title:e,x:f.left,y:f.bottom+4,entries:[i?{label:`Any ${e.toLowerCase()}`,run:()=>o(va(t,n,null))}:null,...r.map(h=>({label:h===d?`\u2713 ${h.label}`:h.label,run:()=>o(va(t,n,h.value))}))]})},children:d?.label??(i||e)})}return m("select",{"aria-label":e,className:c,value:a?r.find(d=>d.value.toLowerCase()===i.toLowerCase()).value:i,onChange:d=>o(va(t,n,d.target.value||null)),children:[l("option",{value:"",children:e}),!a&&i?l("option",{value:i,children:i}):null,r.map(d=>l("option",{value:d.value,children:d.label},d.value))]})}function uE({query:e,onQuery:t,meta:n,inFolder:r,canSave:o,problems:s,inputRef:i,onSave:a}){let[u,c]=_(null),[d,p]=_(null),f=q(()=>p(null),[]),[h,g]=_(!1),x=S=>{if(S.length>ya)return g(!0);g(!1),t(S)},[b,v]=_(""),w=Gc(e),C=w.subfolders,y=_a(w),T=async()=>{if(u===null)return;let S=await a(u);S?v(S):(c(null),v(""))},N=m(he,{children:[l(Cs,{onMenu:p,label:"Kind",keyName:"kind",query:e,onQuery:x,choices:[{value:"page",label:"Page"},{value:"md",label:"Markdown"}]}),l(Cs,{onMenu:p,label:"Project",keyName:"project",query:e,onQuery:x,choices:(n?.projects??[]).map(S=>({value:S.id,label:S.name}))}),l(Cs,{onMenu:p,label:"Conversation",keyName:"conversation",query:e,onQuery:x,choices:(n?.conversations??[]).map(S=>({value:S.threadId,label:S.title??S.threadId}))}),l(Cs,{onMenu:p,label:"Tag",keyName:"tag",query:e,onQuery:x,choices:(n?.tags??[]).map(S=>({value:S.tag,label:`#${S.tag}`}))}),l(Cs,{onMenu:p,label:"Modified",keyName:"modified",query:e,onQuery:x,choices:[{value:"today",label:"Today"},{value:"<7d",label:"Last 7 days"},{value:"<30d",label:"Last 30 days"},{value:">90d",label:"Older than 90 days"}]}),l(Cs,{onMenu:p,label:"Written by",keyName:"by",query:e,onQuery:x,choices:[{value:"you",label:"You"},{value:"assistant",label:"The assistant"}]}),r?m("label",{className:"flex h-8 items-center gap-1.5 px-1 text-sm text-muted-foreground",children:[l("input",{type:"checkbox",checked:C||y,disabled:y,title:y?"A filter looks in every folder below this one":void 0,onChange:S=>x(va(e,"subfolders",S.target.checked?"yes":null))}),"Subfolders"]}):null]});return m("div",{className:"flex flex-col gap-1.5 border-b px-3 py-2",children:[l(As,{request:d,onClose:f}),m("div",{className:"flex flex-wrap items-center gap-1.5",children:[l(le,{ref:i,"aria-label":"Filter this list",className:"h-8 min-w-48 flex-1",placeholder:"Filter: words, tag:triage, kind:md, modified:<7d",value:e,maxLength:ya,onChange:S=>x(S.target.value),onKeyDown:S=>{S.key==="Escape"&&e&&(S.preventDefault(),S.stopPropagation(),x(""))}}),o&&u===null?l(R,{size:"sm",variant:"secondary",disabled:!e.trim(),onClick:()=>c(""),children:"Save"}):null]}),l("div",{className:"flex flex-wrap items-center gap-1.5",children:N}),u!==null?m("form",{className:"flex flex-wrap items-center gap-1.5",onSubmit:S=>{S.preventDefault(),T()},children:[l(le,{autoFocus:!0,"aria-label":"Name for this filter",className:"h-8 max-w-64",placeholder:"Name, such as Open security",value:u,maxLength:60,onChange:S=>c(S.target.value),onKeyDown:S=>{S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),c(null),v(""))}}),l(R,{size:"sm",type:"submit",disabled:!u.trim(),children:"Save filter"}),l(R,{size:"sm",variant:"secondary",type:"button",onClick:()=>(c(null),v("")),children:"Cancel"}),b?l("span",{className:"text-xs text-destructive",children:b}):null]}):null,h?m("p",{className:"text-xs text-destructive",children:["A filter is at most ",ya," characters; that change would make it longer."]}):null,s.length?l("p",{className:"text-xs text-destructive",children:s.join(" \xB7 ")}):null]})}var dE="\0new",pE=e=>e===""?"the library":e===Ze?"the Inbox":e,fE=e=>e.length===1?Pe(e[0]):`${e.length} items`;function Ku({children:e}){return l("div",{className:"flex flex-wrap items-center gap-1.5 border-b px-3 py-2 text-sm",children:e})}function hE({panel:e,folders:t,onRun:n,onClose:r}){let[o,s]=_(e.kind==="rename"?Pe(e.path):""),[i,a]=_(""),[u,c]=_("");K(()=>s(e.kind==="rename"?Pe(e.path):""),[e]);let d=async g=>{await n(g)&&r()},p=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),r())},f=l(R,{size:"sm",variant:"secondary",type:"button",onClick:r,children:"Cancel"});if(e.kind==="move"){let g=["",Ze,...t].filter(v=>!e.items.some(w=>v===w||v.startsWith(`${w}/`))),x=i===dE,b=u.trim().toLowerCase().replace(/^\/+|\/+$/g,"");return l("form",{className:"contents",onSubmit:v=>{v.preventDefault(),x?b&&d({kind:"move",items:e.items,to:b,make:!0}):d({kind:"move",items:e.items,to:i,make:!1})},children:m(Ku,{children:[m("span",{children:["Move ",fE(e.items)," to"]}),m("select",{"aria-label":"Move to",autoFocus:!0,className:"h-8 max-w-64 rounded-md border bg-background px-2 text-sm",value:i,onChange:v=>a(v.target.value),onKeyDown:p,children:[g.map(v=>l("option",{value:v,children:pE(v)},v||"(library)")),l("option",{value:dE,children:"A new folder\u2026"})]}),x?l(le,{autoFocus:!0,"aria-label":"New folder",className:"h-8 max-w-64",placeholder:"Name, such as plans or work/screens",value:u,maxLength:240,onChange:v=>c(v.target.value),onKeyDown:p}):null,l(R,{size:"sm",type:"submit",disabled:x&&!b,children:"Move"}),f,x?l("span",{className:"text-xs text-muted-foreground",children:"Lower-case letters, digits, . _ -"}):null]})})}if(e.kind==="tag")return l("form",{className:"contents",onSubmit:g=>{g.preventDefault();let x=o.split(",").map(b=>b.trim()).filter(Boolean);x.length&&d({kind:"tag",items:e.items,tags:x})},children:m(Ku,{children:[m("span",{children:["Tag ",fE(e.items)]}),l(le,{autoFocus:!0,"aria-label":"Tags to add",className:"h-8 max-w-64",placeholder:"Tags, such as trip, plan",value:o,onChange:g=>s(g.target.value),onKeyDown:p}),l(R,{size:"sm",type:"submit",disabled:!o.trim(),children:"Add"}),f,e.tags.length?l("span",{className:"text-xs text-muted-foreground",children:"Take off:"}):null,e.tags.map(g=>m("button",{type:"button","aria-label":`Take #${g} off`,className:"rounded border px-1.5 text-xs hover:bg-muted",onClick:()=>{d({kind:"untag",items:e.items,tags:[g]})},children:["#",g," \xD7"]},g))]})});let h=e.kind==="rename";return l("form",{className:"contents",onSubmit:g=>{g.preventDefault();let x=o.trim();x&&(e.kind==="rename"?d({kind:"rename",path:e.path,name:x}):d({kind:"mkdir",path:e.parent?`${e.parent}/${x.toLowerCase()}`:x.toLowerCase()}))},children:m(Ku,{children:[l("span",{children:h?`Rename ${Pe(e.path)} to`:`New folder in ${pE(e.kind==="mkdir"?e.parent:"")}`}),l(le,{autoFocus:!0,"aria-label":h?"New name":"Folder name",className:"h-8 max-w-64",placeholder:h?"":"Name, such as plans",value:o,maxLength:64,onFocus:g=>g.currentTarget.select(),onChange:g=>s(g.target.value),onKeyDown:p}),l(R,{size:"sm",type:"submit",disabled:!o.trim(),children:h?"Rename":"Make folder"}),f,l("span",{className:"text-xs text-muted-foreground",children:"Lower-case letters, digits, . _ -"})]})})}function mE({count:e,total:t,onAll:n,allStarred:r,onMove:o,onTag:s,onStar:i,onDelete:a,onClear:u}){return m(Ku,{children:[m("span",{className:"font-medium",children:[e," selected"]}),n?m(R,{size:"sm",variant:"secondary",onClick:n,children:["Select all ",t]}):null,l(R,{size:"sm",variant:"secondary",onClick:o,children:"Move to\u2026"}),s?l(R,{size:"sm",variant:"secondary",onClick:s,children:"Tag\u2026"}):null,i?l(R,{size:"sm",variant:"secondary",onClick:i,children:r?"Unstar":"Star"}):null,l(R,{size:"sm",variant:"secondary",onClick:a,children:"Delete"}),l(R,{size:"sm",variant:"secondary",onClick:u,children:"Clear"})]})}function gE({onUndo:e}){let[t,n,r]=iE();return t?m("div",{role:"status",className:`flex items-center gap-2 border-b px-3 py-1.5 text-sm ${t.kind==="refused"?"text-destructive":""}`,children:[l("span",{className:"min-w-0 flex-1 truncate",children:t.kind==="done"?t.summary:t.kind==="undone"?`Undone: ${t.summary}`:`That didn't happen: ${t.reason}`}),n&&t.kind!=="refused"?l(R,{size:"sm",variant:"secondary",onClick:e,children:t.kind==="undone"?"Undo the one before":"Undo"}):null,l("button",{type:"button","aria-label":"Dismiss",className:"px-1 text-muted-foreground hover:text-foreground",onClick:r,children:"\xD7"})]}):null}var xE="orbit.artifacts.open-folders",bE=0,Dm=new Set;function hr(){bE++;for(let e of Dm)e()}function Fm(){return xt(e=>(Dm.add(e),()=>Dm.delete(e)),()=>bE)}function lO(){try{let e=Mn()?.getItem(xE),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function zm(){let e=Ie();return t=>e.toPluginPanel(cu,{subPath:is(t)})}function cO(e){let{run:t}=Ra(hr),[n,r]=_(!1);return e===void 0?{over:!1,props:{}}:{over:n,props:{onDragOver:o=>{o.dataTransfer.types.includes(ao)&&(o.preventDefault(),o.dataTransfer.dropEffect="move",r(!0))},onDragLeave:()=>r(!1),onDrop:o=>{o.preventDefault(),r(!1);let s=zu(o.dataTransfer).filter(i=>i!==e);s.length&&t({kind:"move",items:s,to:e,make:!1})}}}}function Bn({active:e,label:t,count:n,depth:r=0,onClick:o,toggle:s,drop:i,onDoubleClick:a,onMenu:u,after:c}){let d=cO(i);return m("div",{className:`group relative flex items-center gap-1 rounded px-2 py-1 text-sm ${e?"bg-muted font-medium":"hover:bg-muted/60"} ${d.over?"outline outline-1 outline-ring":""}`,style:{paddingLeft:`${8+r*14}px`},onContextMenu:u?p=>{p.preventDefault(),u(p.clientX,p.clientY)}:void 0,...d.props,children:[s??l("span",{className:"w-4 shrink-0"}),l("button",{type:"button","aria-current":e?"page":void 0,className:"min-w-0 flex-1 truncate text-left",onClick:o,onDoubleClick:a,children:t}),n!==void 0&&n>0?l("span",{className:`shrink-0 text-xs text-muted-foreground ${u?"group-hover:hidden [@media(hover:none)]:hidden":""}`,children:n}):null,u?l("button",{type:"button","aria-label":`More for ${typeof t=="string"?t:"this folder"}`,"aria-haspopup":"menu",className:"hidden shrink-0 rounded px-1 text-muted-foreground hover:text-foreground focus:inline group-hover:inline [@media(hover:none)]:inline",onClick:p=>{let f=p.currentTarget.getBoundingClientRect();u(f.right-176,f.bottom+4)},children:"\u2026"}):null,c]})}function uO({path:e,count:t,depth:n,active:r,toggle:o,onOpen:s,onMenu:i}){let{run:a}=Ra(hr),[u,c]=_(null),d=(p,f)=>i({title:Pe(e),x:p,y:f,entries:[{label:"New folder inside",run:()=>c({kind:"mkdir",text:""})},{label:"Rename",run:()=>c({kind:"rename",text:Pe(e)})},{label:"Move to\u2026",run:()=>Mm({kind:"move",items:[e]})},{label:"Filter inside",run:()=>(s(),Mm({kind:"focus-filter"}))},{label:"Delete folder",run:()=>{a({kind:"delete",items:[e]})}}]});return u?m(he,{children:[u.kind==="mkdir"?l(Bn,{active:r,label:Pe(e),count:t,depth:n,toggle:o,onClick:s}):null,l("form",{className:"py-0.5 pr-2",style:{paddingLeft:`${8+(n+(u.kind==="mkdir"?1:0))*14+20}px`},onSubmit:p=>{p.preventDefault();let f=u.text.trim();c(null),f&&(u.kind==="rename"?f!==Pe(e)&&a({kind:"rename",path:e,name:f}):a({kind:"mkdir",path:`${e}/${f.toLowerCase()}`}))},children:l(le,{autoFocus:!0,"aria-label":u.kind==="rename"?`New name for ${Pe(e)}`:`New folder in ${Pe(e)}`,className:"h-7",placeholder:u.kind==="mkdir"?"New folder's name":"",maxLength:64,value:u.text,onFocus:p=>p.currentTarget.select(),onChange:p=>c({...u,text:p.target.value}),onBlur:p=>p.currentTarget.form?.requestSubmit(),onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),c(null))}})})]}):l(Bn,{active:r,label:Pe(e),count:t,depth:n,toggle:o,drop:e,onClick:s,onDoubleClick:()=>c({kind:"rename",text:Pe(e)}),onMenu:d})}function Xu({children:e}){return l("p",{className:"mt-3 px-2 pb-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e})}function dO({row:e,index:t,count:n,active:r,onOpen:o,onChanged:s,onDeleted:i,onMenu:a}){let u=J(),[c,d]=_(null),[p,f]=_(""),h=async x=>{let b=await x.catch(v=>({state:"refused",reason:v instanceof Error?v.message:String(v)}));b.state==="ok"?(f(""),s()):f(b.reason)},g=(x,b)=>a({title:e.name,x,y:b,entries:[{label:"Rename",run:()=>d(e.name)},{label:"Move up",disabled:t===0,run:()=>{h(u.call("artifacts.saved.move",{id:e.id,to:t-1}))}},{label:"Move down",disabled:t===n-1,run:()=>{h(u.call("artifacts.saved.move",{id:e.id,to:t+1}))}},{label:"Delete",run:()=>{h(u.call("artifacts.saved.delete",{id:e.id})).then(i)}}]});return c!==null?l("form",{className:"px-2 py-0.5",onSubmit:x=>{x.preventDefault(),c.trim()&&c.trim()!==e.name&&h(u.call("artifacts.saved.rename",{id:e.id,name:c})),d(null)},children:l(le,{autoFocus:!0,"aria-label":`New name for ${e.name}`,className:"h-7",onFocus:x=>x.currentTarget.select(),value:c,maxLength:60,onChange:x=>d(x.target.value),onBlur:x=>x.currentTarget.form?.requestSubmit(),onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),d(null))}})}):m("div",{className:`group relative flex items-center gap-1 rounded px-2 py-1 text-sm ${r?"bg-muted font-medium":"hover:bg-muted/60"}`,onContextMenu:x=>{x.preventDefault(),g(x.clientX,x.clientY)},children:[l("span",{className:"w-4 shrink-0"}),l("button",{type:"button","aria-current":r?"page":void 0,className:"min-w-0 flex-1 truncate text-left",onClick:o,onDoubleClick:()=>d(e.name),children:e.name}),l("button",{type:"button","aria-label":`More for ${e.name}`,"aria-haspopup":"menu",className:"shrink-0 rounded px-1 text-muted-foreground opacity-0 hover:text-foreground focus:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:x=>{let b=x.currentTarget.getBoundingClientRect();g(b.right-176,b.bottom+4)},children:"\u2026"}),p?l("span",{className:"absolute left-6 top-full z-10 text-xs text-destructive",children:p}):null]})}function yE({subPath:e}){let t=J(),n=zm(),r=as(e),o=Fm(),[s,i]=_(null),[a,u]=_(""),[c,d]=_(null),p=q(()=>d(null),[]),[f,h]=_(r.kind==="search"?r.q:""),[g,x]=_(lO);K(()=>{let $=!0;return t.call("artifacts.folders",{}).then(P=>{$&&(i(P),u(""))},P=>$&&u(P instanceof Error?P.message:String(P))),()=>{$=!1}},[t,o]);let b=r.kind==="place"&&r.place.kind==="folder"?r.place.path:null,v=new Set([...g,...b?ka(b):[]]),w=$=>{let P=new Set(g);P.has($)?P.delete($):P.add($),x(P);try{Mn()?.setItem(xE,JSON.stringify([...P]))}catch{}},C=s?.folders??[],y=$=>C.some(P=>Ut(P.path)===$),T=C.filter($=>ka(Ut($.path)).every(P=>v.has(P))),N=$=>S1(r,$),S=$=>r.kind==="group"&&r.by===$||r.kind==="place"&&r.place.kind===$;return K(()=>h(r.kind==="search"?r.q:""),[e]),m("nav",{"aria-label":"Artifacts",className:"flex flex-col gap-0.5 px-2 pb-4",children:[l("form",{className:"pb-2",onSubmit:$=>{$.preventDefault(),f.trim()&&n({kind:"search",q:f.trim()})},children:l(le,{"aria-label":"Search all artifacts",className:"h-8",placeholder:"Search all",value:f,onChange:$=>h($.target.value)})}),a?m("p",{className:"px-2 text-xs text-destructive",children:["Couldn't load the folders: ",a]}):null,l(Bn,{active:N(Bt(Ze)),label:"Inbox",count:s?.inbox,drop:Ze,onClick:()=>n(Bt(Ze))}),l(Bn,{active:N({kind:"place",place:{kind:"recent"}}),label:"Recent",onClick:()=>n({kind:"place",place:{kind:"recent"}})}),l(Bn,{active:N({kind:"place",place:{kind:"starred"}}),label:"Starred",count:s?.starred,onClick:()=>n({kind:"place",place:{kind:"starred"}})}),l(Xu,{children:"Library"}),l(Bn,{active:N(Bt("")),label:"All folders",drop:"",onClick:()=>n(Bt(""))}),T.map($=>{let P=$.path.split("/").length,L=y($.path)?l("button",{type:"button","aria-label":v.has($.path)?`Close ${Pe($.path)}`:`Open ${Pe($.path)}`,"aria-expanded":v.has($.path),className:"w-4 shrink-0 text-xs text-muted-foreground",onClick:()=>w($.path),children:v.has($.path)?"\u25BE":"\u25B8"}):void 0;return l(uO,{path:$.path,active:b===$.path,count:$.pages,depth:P,toggle:L,onOpen:()=>n(Bt($.path)),onMenu:d},$.path)}),s&&!C.length?l("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No folders yet."}):null,s?.saved.length?m(he,{children:[l(Xu,{children:"Saved"}),s.saved.map(($,P)=>l(dO,{row:$,index:P,count:s.saved.length,active:r.kind==="saved"&&r.id===$.id,onOpen:()=>n({kind:"saved",id:$.id}),onChanged:hr,onDeleted:()=>r.kind==="saved"&&r.id===$.id&&n(Bt("")),onMenu:d},$.id))]}):null,l(Xu,{children:"Views"}),l(Bn,{active:S("project"),label:"By project",onClick:()=>n({kind:"group",by:"project"})}),l(Bn,{active:S("conversation"),label:"By conversation",onClick:()=>n({kind:"group",by:"conversation"})}),s?.tags.length?m(he,{children:[l(Xu,{children:"Tags"}),s.tags.map($=>l(Bn,{active:N({kind:"place",place:{kind:"tag",tag:$.tag}}),label:`#${$.tag}`,count:$.pages,onClick:()=>n({kind:"place",place:{kind:"tag",tag:$.tag}})},$.tag))]}):null,l(As,{request:c,onClose:p})]})}var _E=1e3,pO=250;function vE(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function fO(){try{return globalThis.matchMedia?.("(hover: none)").matches===!0}catch{return!1}}var hO=[{by:"name",label:"Name"},{by:"modified",label:"Modified"},{by:null,label:"Project",wide:!0},{by:"conversation",label:"Conversation",wide:!0},{by:null,label:"Tags",wide:!0},{by:"versions",label:"Versions",wide:!0},{by:"size",label:"Size",wide:!0}],wE=(e,t)=>`${e} ${t}${e===1?"":"s"}`,mO=e=>[e.folders.length?wE(e.folders.length,"folder"):"",e.pages.length||!e.folders.length?`${wE(e.pages.length,"page")}${e.more?"+":""}`:""].filter(Boolean).join(" \xB7 "),gO=e=>e<1024?`${e} B`:`${Math.round(e/1024)} KB`;function xO(){let e=Y(null),[t,n]=_("wide");return ot(()=>{let r=e.current;if(!r)return;let o=()=>n(C1(r.getBoundingClientRect().width));o();let s=new ResizeObserver(o);return s.observe(r),()=>s.disconnect()},[]),[e,t]}function CE(e){return l(R,{size:"sm",variant:"secondary",onClick:hr,children:"Refresh"})}function TE({subPath:e}){let t=J(),n=J(),r=Ie(),o=zm(),s=as(e),i=e,a=Fm();ke("artifacts",hr);let[u,c]=xO(),[d,p]=_(()=>nm(Mn(),s)),[f,h]=_(null),[g,x]=_(null),[b,v]=_(""),[w,C]=_(""),[y,T]=_(null),[N,S]=_(!0),[$,P]=_(!1),[L,ne]=_(null),[se,_e]=_([]),[ie,Q]=_(null),[j,G]=_(null),[ee,be]=_(""),[H,xe]=_(new Set),[Cr,Cn]=_(null),[ue,ze]=_(null),zt=q(()=>ze(null),[]),[mt,gt]=_(null),[vi,To]=_(null),[S_,E_]=_(null),[Ro,nf]=_(()=>D1(Mn())),[wi,rf]=_(new Map),ki=Y(Ro);ki.current=Ro;let{run:Qn,undo:N_}=Ra(hr),[Ll,A_]=lE(),jt=aE(),C_=Y(jt?.n??0);K(()=>{if(!jt||jt.n===C_.current||(C_.current=jt.n,nf(O=>z1(O,jt.action,jt.moved)),rf(O=>M1(O,jt.action,jt.moved)),s.kind!=="place"||s.place.kind!=="folder"))return;let k=uu(jt.action,jt.moved,s.place.path);k!==null&&k!==s.place.path&&o(Bt(k))},[jt]),K(()=>F1(Mn(),Ro),[Ro]),K(()=>{if(!g)return;let k=new Set(g.folders.map(O=>O.path));nf(O=>[...O].every(Z=>k.has(Z))?O:new Set([...O].filter(Z=>k.has(Z))))},[g]),K(()=>{if(f?.state!=="refused"||!g||s.kind!=="place"||s.place.kind!=="folder")return;let k=s.place.path,O=new Set(g.folders.map(Z=>Z.path));k===""||k===Ze||O.has(k)||o(Bt(ka(Ut(k)).filter(Z=>O.has(Z)).at(-1)??""))},[f,g]);let[LT,of]=_(null),Tr=Y(null);K(()=>()=>{Tr.current&&clearTimeout(Tr.current)},[]);let Ml=Y(null),Dl=Y(null),Fl=k=>be(k instanceof Error?k.message:String(k)),MT=k=>{p(k),N1(Mn(),k)},zl=s.kind==="saved"?g?.saved.find(k=>k.id===s.id)??null:null,Qt=s.kind==="saved"?zl?tm(zl.place):null:s,Si=Qt?is(Qt):null,sf=zl?.query??"";K(()=>{T(null),xe(new Set),Cn(null),gt(null),ze(null),ne(null),P(!1),_e([]),p(nm(Mn(),as(i)))},[i]),K(()=>{Ll&&(Ll.kind==="move"?(gt({kind:"move",items:Ll.items}),A_()):Dl.current&&(Dl.current.focus(),A_()))},[Ll,i,f===null]),K(()=>of(null),[i]),K(()=>{v(sf),C(sf)},[i,sf]),K(()=>{if(b===w)return;let k=setTimeout(()=>C(b),250);return()=>clearTimeout(k)},[b,w]),K(()=>{t.call("artifacts.folders",{}).then(x,Fl)},[t,a]),K(()=>{let k=!0;h(null),be("");let O=Si===null?null:tm(Si),Z=ae=>k&&h(ae);if(!O){s.kind==="saved"&&g&&Z({state:"refused",reason:"That saved filter is gone."});return}return O.kind==="group"?t.call("artifacts.group",{by:O.by}).then(ae=>Z({state:"groups",by:O.by,groups:ae.groups}),Fl):O.kind==="search"?t.call("artifacts.search",{q:O.q,versions:!0}).then(ae=>Z({state:"search",results:ae.results}),Fl):O.kind==="place"&&t.call("artifacts.library",{place:O.place,sort:d,limit:_E,query:w,zone:vE()}).then(Z,Fl),()=>{k=!1}},[t,Si,d,a,w,g===null]);let af=Y({key:"",listed:!1});K(()=>{if(!L||!f||f.state!=="ok"&&f.state!=="search")return;let k=`${L.threadId}\0${L.name}`,O=f.state==="ok"?pf().find(ae=>ae.threadId===L.threadId&&ae.name===L.name)?.path:f.results.filter(ae=>ae.threadId===L.threadId&&ae.name===L.name).map(ae=>ae.kind==="moved"?ae.to:ae.path)[0],Z=af.current.key===k&&af.current.listed;O===void 0&&Z&&hf.length>0||(af.current={key:k,listed:O!==void 0},O!==void 0?O!==L.path&&(ne({...L,path:O}),T(ae=>ae===null||ae===L.path?O:ae)):Z&&(P(!1),ne(null)))},[f,L,wi]);let lf=Y(0),$o=q(k=>{let O=++lf.current;ne(k),Q(null),G(null),n.call("artifacts.read",{threadId:k.threadId,name:k.name}).then(Z=>{if(O!==lf.current||(Q(nu(Z)),G(Z.state==="ok"?ou(Z.page):null),Z.state!=="ok"))return;t.call("artifacts.seen",{threadId:k.threadId,name:k.name}).catch(()=>{});let ae=we=>we.map(Kt=>Kt.threadId===k.threadId&&Kt.name===k.name?{...Kt,unread:!1}:Kt);h(we=>we?.state==="ok"?{...we,pages:ae(we.pages)}:we),rf(we=>new Map([...we].map(([Kt,qn])=>[Kt,qn.branch.state==="ok"?{...qn,branch:{...qn.branch,pages:ae(qn.branch.pages)}}:qn])))},Z=>O===lf.current&&Q(ss(Z)))},[n,t]),T_=Y(a);K(()=>{T_.current!==a&&(T_.current=a,L&&$o(L))},[a]);let cf=k=>k?g?.projects.find(O=>O.id===k)?.name??k:"\u2014",uf=Gc(w),DT=uf.subfolders||_a(uf),df=f?.state==="ok"?I1(f,k=>wi.get(k)?.branch,Ro):[],Ve=f?.state==="ok"?P1(df):f?.state==="search"?f.results.map(k=>({kind:"page",path:k.kind==="moved"?k.to:k.path,threadId:k.threadId,name:k.name})):f?.state==="groups"?f.groups.map(k=>({kind:"folder",path:k.key})):[],Rr=`${a}:${d.by}:${d.desc?"desc":"asc"}`,R_=Y(Rr);R_.current=Rr;let pf=()=>f?.state==="ok"?L1(f.pages,wi.values(),Rr):f?.state==="search"?[...new Map(f.results.map(k=>[k.page.path,k.page])).values()]:[],$_=k=>pf().find(O=>O.path===k);K(()=>{if(!f)return;let k=new Set(f.state==="ok"||f.state==="search"?Ve.map(O=>O.path):[]);xe(O=>O.size&&[...O].some(Z=>!k.has(Z))?new Set([...O].filter(Z=>k.has(Z))):O),T(O=>O!==null&&!k.has(O)?null:O),Cn(O=>O!==null&&!k.has(O)?null:O)},[f,Ve.map(k=>k.path).join(`
143
143
  `)]);let ff=f?.state==="ok"&&L?.path&&!f.pages.some(k=>k.path===L.path)?Ut(L.path):null,hf=[...new Set([...df.flatMap(k=>k.kind==="folder"&&k.open?[k.folder.path]:[]),...ff!==null&&wi.has(ff)?[ff]:[]])].filter(k=>wi.get(k)?.gen!==Rr),mf=Y(new Set),FT=Y(0);K(()=>{for(let k of hf){let O=`${Rr}\0${k}`;if(mf.current.has(O))continue;mf.current.add(O);let Z=++FT.current,ae=we=>rf(Kt=>{let qn={n:Z,gen:Rr,branch:we};return O1(qn,Kt.get(k),R_.current)?new Map(Kt).set(k,qn):Kt});t.call("artifacts.library",{place:{kind:"folder",path:k},sort:d,limit:_E,query:"",zone:vE()}).then(we=>ae(we.state==="ok"?{state:"ok",folders:we.folders,pages:we.pages,more:we.more}:we),we=>ae({state:"refused",reason:we instanceof Error?we.message:String(we)})).finally(()=>mf.current.delete(O))}},[t,Rr,hf.join(`
144
144
  `)]);let gf=(k,O)=>{if(ki.current.has(k)===O)return;let Z=new Set(ki.current);if(O?Z.add(k):Z.delete(k),ki.current=Z,nf(Z),O)return;let ae=we=>we.startsWith(`${k}/`);T(we=>we!==null&&ae(we)?k:we),Cn(we=>we!==null&&ae(we)?k:we),xe(we=>[...we].some(ae)?new Set([...we].filter(Kt=>!ae(Kt))):we)},I_=k=>gf(k,!ki.current.has(k)),lt=f?.state==="ok"||f?.state==="search",Kl=Qt?.kind==="place"&&Qt.place.kind==="folder"?Qt.place.path:null,P_=Kl===Ze?null:Kl,O_=()=>{xe(new Set),T(null),Cn(null)},Gn=()=>H.size?[...H]:y&&lt?[y]:[],Xl=k=>pf().filter(O=>k.includes(O.path)),L_=k=>{let O=Xl(k);return O.length>0&&O.every(Z=>Z.starred)},xf=k=>f?.state==="ok"&&Ve.some(O=>O.kind==="folder"&&O.path===k),bf=(k,O)=>{xe(K1(Ve,H,Cr,k,O)),Cn(k)},yf=Ve.length>0&&Ve.every(k=>H.has(k.path)),M_=()=>xe(yf?new Set:new Set(Ve.map(k=>k.path))),zT=(k,O)=>{if(!lt)return Io(k);if(H.size&&!O.metaKey&&!O.ctrlKey&&fO())return bf(k.path,O.shiftKey);if(O.metaKey||O.ctrlKey){let Z=new Set(H.size?H:y?[y]:[]),ae=Z.has(k.path);ae?Z.delete(k.path):Z.add(k.path),xe(Z),Cn(k.path),T(ae?[...Z].at(-1)??null:k.path);return}if(O.shiftKey&&Cr){let Z=Ve.findIndex(we=>we.path===Cr),ae=Ve.findIndex(we=>we.path===k.path);if(Z>=0&&ae>=0){xe(new Set(Ve.slice(Math.min(Z,ae),Math.max(Z,ae)+1).map(we=>we.path))),T(k.path);return}}if(xe(new Set),Cn(k.path),k.kind==="folder"&&f?.state==="ok"){if(Tr.current&&clearTimeout(Tr.current),Tr.current=null,O.detail>=2)return of(k.path);T(k.path),Tr.current=setTimeout(()=>{Tr.current=null,I_(k.path)},pO);return}Io(k)},Bl=k=>k.length&&void Qn({kind:"delete",items:k}).then(O=>O&&(xe(new Set),ne(null),P(!1))),_f=k=>{let O=Xl(k);O.length&&Qn({kind:"star",items:O.map(Z=>Z.path),starred:!O.every(Z=>Z.starred)})},Ul=k=>{let O=k.filter(Z=>!xf(Z));O.length&&gt({kind:"tag",items:O,tags:[...new Set(Xl(O).flatMap(Z=>Z.tags))].sort()})},vf=k=>gt({kind:"rename",path:k,folder:xf(k)}),D_=(k,O)=>{O.preventDefault(),To(null);let Z=zu(O.dataTransfer).filter(ae=>ae!==k);Z.length&&Qn({kind:"move",items:Z,to:k,make:!1}).then(ae=>ae&&xe(new Set))},KT=k=>({onDragOver:O=>{O.dataTransfer.types.includes(ao)&&(O.preventDefault(),O.dataTransfer.dropEffect="move",To(k))},onDragLeave:()=>To(O=>O===k?null:O),onDrop:O=>D_(k,O)}),XT=k=>({onDragOver:O=>{!lt||!O.dataTransfer.types.includes(ao)||(O.preventDefault(),To(`crumb:${k}`))},onDragLeave:()=>To(O=>O===`crumb:${k}`?null:O),onDrop:O=>D_(k,O)}),F_=k=>{let O=Ve.find(ae=>ae.path===k);if(O)return O;let Z=$_(k);return Z&&{kind:"page",path:k,threadId:Z.threadId,name:Z.name}},BT=k=>{let O=F_(k);if(!O)return[];let Z=H.has(k)&&H.size>1?[...H]:[k],ae=Z.length>1;return O.kind==="folder"?[{label:"Open",run:()=>Io(O)},ae?null:{label:"New folder inside",run:()=>gt({kind:"mkdir",parent:k})},ae?null:{label:"Rename",run:()=>vf(k)},{label:"Move to\u2026",run:()=>gt({kind:"move",items:Z})},{label:ae?`Delete ${Z.length} items`:"Delete folder",run:()=>Bl(Z)}]:[ae?null:{label:"Open",run:()=>wf(O)},ae?null:{label:"Rename",run:()=>vf(k)},{label:"Move to\u2026",run:()=>gt({kind:"move",items:Z})},{label:"Tag\u2026",run:()=>Ul(Z)},{label:L_(Z)?"Unstar":"Star",run:()=>_f(Z)},{label:ae?`Delete ${Z.length} items`:"Delete",run:()=>Bl(Z)}]},Io=k=>{if(T(k.path),k.kind==="page"){_e([]),$o({threadId:k.threadId,name:k.name,path:k.path}),S(!0);return}f?.state==="groups"?o({kind:"place",place:f.by==="project"?{kind:"project",projectId:k.path}:{kind:"conversation",threadId:k.path}}):o(Bt(k.path))},wf=k=>{if(k.kind!=="page")return Io(k);Io(k),P(!0)},z_=()=>{P(!1),c!=="wide"&&ne(null),requestAnimationFrame(()=>Ml.current?.focus())},kf=k=>{T(k);let O=Ve.find(Z=>Z.path===k);O?.kind==="page"&&N&&c==="wide"&&$o({threadId:O.threadId,name:O.name,path:O.path}),Ml.current?.querySelector(`[data-path="${CSS.escape(k??"")}"]`)?.scrollIntoView({block:"nearest"})},UT=k=>{if(k.target instanceof HTMLInputElement&&k.key===" ")return;let O=Ve.find(Z=>Z.path===y);if(k.key==="ArrowDown"||k.key==="ArrowUp")k.preventDefault(),kf(T1(Ve,y,k.key==="ArrowDown"?1:-1));else if((k.key==="ArrowRight"||k.key==="ArrowLeft")&&f?.state==="ok"&&O){k.preventDefault();let Z=O.kind==="folder"&&Ro.has(O.path);if(k.key==="ArrowRight"){if(O.kind!=="folder")return;if(!Z)return gf(O.path,!0);let ae=Ve[Ve.indexOf(O)+1];ae?.path.startsWith(`${O.path}/`)&&kf(ae.path)}else Z?gf(O.path,!1):Ve.some(ae=>ae.kind==="folder"&&ae.path===Ut(O.path))&&kf(Ut(O.path))}else lt&&(k.metaKey||k.ctrlKey)&&k.key.toLowerCase()==="a"?(k.preventDefault(),xe(new Set(Ve.map(Z=>Z.path)))):lt&&(k.metaKey||k.ctrlKey)&&k.key.toLowerCase()==="x"&&Gn().length?(k.preventDefault(),E_(Gn())):lt&&(k.metaKey||k.ctrlKey)&&k.key.toLowerCase()==="v"&&S_&&Kl!==null?(k.preventDefault(),Qn({kind:"move",items:S_,to:Kl,make:!1}).then(Z=>Z&&E_(null))):(k.metaKey||k.ctrlKey)&&k.key.toLowerCase()==="z"?(k.preventDefault(),N_()):lt&&(k.key==="Delete"||k.key==="Backspace")&&Gn().length?(k.preventDefault(),Bl(Gn())):lt&&k.key==="F2"&&y?(k.preventDefault(),vf(y)):lt&&k.key==="t"&&!k.metaKey&&!k.ctrlKey&&Gn().length?(k.preventDefault(),Ul(Gn())):lt&&(k.key==="x"||k.key==="X")&&!k.metaKey&&!k.ctrlKey&&y?(k.preventDefault(),bf(y,k.shiftKey)):lt&&k.key==="s"&&!k.metaKey&&!k.ctrlKey&&Gn().length?(k.preventDefault(),_f(Gn())):k.key==="Escape"&&(H.size||mt)?(k.preventDefault(),k.stopPropagation(),H.size&&O_(),gt(null)):k.key==="/"&&K_?(k.preventDefault(),Dl.current?.focus()):k.key==="Enter"&&O?(k.preventDefault(),wf(O)):k.key===" "&&O?.kind==="page"&&(k.preventDefault(),N&&L?.path===O.path?S(!1):Io(O))},HT=E1(s,{project:k=>cf(k),conversation:k=>g?.conversations.find(O=>O.threadId===k)?.title??k,saved:()=>zl?.name??"\u2026"}),Yn=L&&N?L:null,K_=Qt?.kind==="place",X_=!$&&!(Yn&&c!=="wide"),B_=$||Yn!==null&&c!=="wide",U_=ue!==null||mt!==null;K(()=>{if(!B_)return;let k=O=>{O.key!=="Escape"||O.defaultPrevented||(O.preventDefault(),U_?(ze(null),gt(null)):$?z_():ne(null))};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[B_,$,U_]);let tt=L?.path?$_(L.path):void 0,VT=L?l(au,{threadId:L.threadId,name:L.name,shown:ie,about:j,onChanged:()=>$o(L),onNavigate:(k,O,Z)=>{_e(ae=>[...ae,L]),$o({threadId:k,name:O,path:Z})},onBack:se.length?()=>{let k=se.at(-1);_e(O=>O.slice(0,-1)),$o(k)}:null}):null;return m("div",{ref:u,className:"flex h-full min-h-0 flex-col",children:[m("div",{className:"flex min-h-10 items-center gap-1 border-b px-3 py-1.5 text-sm",children:[$||Yn&&c!=="wide"?l(R,{size:"sm",variant:"secondary",onClick:()=>$?z_():ne(null),children:"Back to the list"}):null,l("ol",{className:"flex min-w-0 flex-1 items-center gap-1 truncate","aria-label":"Where you are",children:HT.map((k,O)=>m("li",{className:"flex min-w-0 items-center gap-1",children:[O?l("span",{className:"text-muted-foreground",children:"\u203A"}):null,k.where?l("button",{type:"button",className:`truncate rounded px-0.5 text-muted-foreground hover:underline ${k.where.kind==="place"&&k.where.place.kind==="folder"&&vi===`crumb:${k.where.place.path}`?"bg-muted ring-1 ring-ring":""}`,onClick:()=>o(k.where),...k.where.kind==="place"&&k.where.place.kind==="folder"?XT(k.where.place.path):{},children:k.label}):l("span",{className:"truncate font-medium",children:k.label})]},`${O}:${k.label}`))}),f?.state==="ok"?l("span",{className:"shrink-0 text-xs text-muted-foreground",children:mO(f)}):null,P_!==null&&!$&&!(Yn&&c!=="wide")?l(R,{size:"sm",variant:"secondary",onClick:()=>gt({kind:"mkdir",parent:P_}),children:"New folder"}):null]}),l(gE,{onUndo:()=>{N_()}}),mt?l(hE,{panel:mt,folders:(g?.folders??[]).map(k=>k.path),onRun:Qn,onClose:()=>gt(null)}):null,H.size>0&&!mt&&!$?l(mE,{count:H.size,onAll:yf?null:M_,total:Ve.length,allStarred:L_([...H]),onMove:()=>gt({kind:"move",items:[...H]}),onTag:[...H].some(k=>!xf(k))?()=>Ul([...H]):null,onStar:Xl([...H]).length?()=>_f([...H]):null,onDelete:()=>Bl([...H]),onClear:O_}):null,K_&&H.size===0&&!$&&!(Yn&&c!=="wide")?l(uE,{query:b,onQuery:v,meta:g,inFolder:Qt?.kind==="place"&&Qt.place.kind==="folder"&&Qt.place.path!==Ze,canSave:Qt?.kind==="place",problems:f?.state==="ok"?f.problems:[],inputRef:Dl,onSave:async k=>{if(Si===null)return"There's nothing here to save.";let O=await t.call("artifacts.saved.create",{name:k,place:Si,query:b});return O.state!=="ok"?O.reason:(x(await t.call("artifacts.folders",{})),hr(),o({kind:"saved",id:O.id}),null)}}):null,ee?m("p",{className:"px-3 py-2 text-sm text-destructive",children:["Couldn't reach the artifacts: ",ee]}):null,m("div",{className:"flex min-h-0 flex-1",children:[l("div",{ref:Ml,role:"listbox","aria-label":"Artifacts","aria-hidden":!X_,tabIndex:0,onKeyDown:UT,onDoubleClick:k=>{if(k.target instanceof HTMLInputElement)return;let O=k.target.closest("[data-path]")?.getAttribute("data-path"),Z=Ve.find(ae=>ae.path===O);Z&&!(Z.kind==="folder"&&f?.state==="ok")&&wf(Z)},onContextMenu:k=>{let O=k.target.closest("[data-path]")?.getAttribute("data-path");!lt||!O||!Ve.some(Z=>Z.path===O)||(k.preventDefault(),H.has(O)||(xe(new Set),T(O)),ze({x:k.clientX,y:k.clientY,path:O}))},onDragStart:k=>{let O=k.target.closest("[data-path]")?.getAttribute("data-path");if(!lt||!O)return;let Z=H.has(O)?[...H]:[O];k.dataTransfer.setData(ao,JSON.stringify(Z)),k.dataTransfer.setData("text/plain",Z.join(`
145
145
  `)),k.dataTransfer.effectAllowed="move"},onDragEnd:()=>To(null),className:`min-h-0 overflow-auto outline-none ${X_?"":"hidden"} ${Yn?"w-1/2 border-r":"flex-1"}`,children:f?f.state==="refused"?l("p",{className:"p-3 text-sm text-destructive",children:f.reason}):l(bO,{listing:f,lines:df,onToggle:k=>{I_(k),Ml.current?.focus({preventScroll:!0})},layout:Yn||c==="compact"?"compact":"wide",sort:d,onSort:k=>MT(A1(d,k)),isChosen:k=>H.size?H.has(k):y===k,ticks:lt?{isTicked:k=>H.has(k),any:H.size>0,all:yf,tick:bf,tickAll:M_}:null,draggable:lt,dropOn:vi,dropTarget:KT,renaming:LT,onRename:(k,O)=>{of(null),O&&O!==Pe(k)&&Qn({kind:"rename",path:k,name:O})},projectName:cf,where:Qt??s,flat:DT,filtering:_a(uf),onSelect:zT}):l("p",{className:"p-3 text-sm text-muted-foreground",children:"Loading\u2026"})}),l(As,{request:ue?{title:Pe(ue.path),entries:BT(ue.path),x:ue.x,y:ue.y}:null,onClose:zt}),$||Yn?m("div",{className:"flex min-w-0 flex-1 flex-col",children:[tt||L?m("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b px-3 py-1.5 text-xs text-muted-foreground",children:[l("span",{className:"font-medium text-foreground",children:L?.path??L?.name}),tt?l("span",{children:cf(tt.projectId)}):null,tt?.threadTitle?l("span",{className:"truncate",children:tt.threadTitle}):null,tt?l("span",{children:Wr(tt.at)}):null,tt?.tags.map(k=>m("button",{type:"button","aria-label":`Take #${k} off`,title:`Take #${k} off`,className:"rounded px-1 hover:bg-muted hover:line-through",onClick:()=>{Qn({kind:"untag",items:[tt.path],tags:[k]})},children:["#",k]},k)),tt?l("button",{type:"button",className:"rounded px-1 hover:bg-muted",onClick:()=>Ul([tt.path]),children:"+ Tag"}):null,tt?l("button",{type:"button","aria-pressed":tt.starred,"aria-label":tt.starred?"Unstar":"Star",className:`rounded px-1 hover:bg-muted ${tt.starred?"text-foreground":""}`,onClick:()=>{Qn({kind:"star",items:[tt.path],starred:!tt.starred})},children:tt.starred?"\u2605":"\u2606"}):null,l("span",{className:"flex-1"}),$?null:l(R,{size:"sm",variant:"secondary",onClick:()=>P(!0),children:"Open"}),L?l(R,{size:"sm",variant:"secondary",onClick:()=>r.toThread(L.threadId),children:"Open in chat"}):null,L?.path&&lt&&F_(L.path)?l(R,{size:"sm",variant:"secondary","aria-label":`More for ${Pe(L.path)}`,"aria-haspopup":"menu",onClick:k=>{let O=k.currentTarget.getBoundingClientRect();L.path&&ze({x:O.right-176,y:O.bottom+4,path:L.path})},children:"\u2026"}):null]}):null,VT]}):null]})]})}function bO({listing:e,lines:t,onToggle:n,layout:r,sort:o,onSort:s,isChosen:i,ticks:a,draggable:u,dropOn:c,dropTarget:d,renaming:p,onRename:f,projectName:h,where:g,flat:x,filtering:b,onSelect:v}){if(e.state==="groups")return e.groups.length?l("ul",{children:e.groups.map(N=>{let S={kind:"folder",path:N.key};return m($a,{row:S,selected:i(N.key),onSelect:v,children:[l("span",{className:"min-w-0 flex-1 truncate",children:N.title??N.key}),e.by==="conversation"?l("span",{className:"hidden truncate text-muted-foreground sm:inline",children:h(N.projectId)}):null,m("span",{className:"shrink-0 text-xs text-muted-foreground",children:[N.pages," page",N.pages===1?"":"s"," \xB7 ",Wr(N.at)]})]},N.key)})}):l(Bu,{children:"No pages yet."});if(e.state==="search")return e.results.length?l("ul",{children:e.results.map(N=>{if(N.kind==="moved"){let $={kind:"page",path:N.to,threadId:N.threadId,name:N.name};return l($a,{row:$,selected:!1,onSelect:v,draggable:u,tall:!0,children:m("span",{className:"min-w-0 flex-1",children:[l("span",{className:"block truncate font-medium",children:N.to}),m("span",{className:"block truncate text-xs text-muted-foreground",children:["Moved from ",N.path]})]})},`moved:${N.path}`)}let S={kind:"page",path:N.path,threadId:N.threadId,name:N.name};return l($a,{row:S,selected:i(N.path),onSelect:v,draggable:u,ticks:a,tall:!0,children:m("span",{className:"min-w-0 flex-1",children:[l("span",{className:"block truncate font-medium",children:N.title}),m("span",{className:"block truncate text-xs text-muted-foreground",children:[N.path,N.version?` \xB7 matched in v${N.version}`:""]}),l("span",{className:"block truncate text-xs text-muted-foreground",children:N.snippet})]})},`page:${N.path}`)})}):l(Bu,{children:"Nothing matches."});let w=x||!(g.kind==="place"&&g.place.kind==="folder");if(!e.folders.length&&!e.pages.length)return l(Bu,{children:b?"Nothing matches this filter.":g.kind==="place"&&g.place.kind==="folder"&&g.place.path===Ze?"The Inbox is empty: every page is filed.":"Nothing here yet."});let C=t.some(N=>N.kind==="folder"),y=(N,S)=>N*16+(S?20:0);if(r!=="wide")return m("ul",{children:[t.map(N=>{if(N.kind==="note")return m("li",{className:"flex items-center gap-2 border-b border-border/40 px-3 py-1.5 text-xs text-muted-foreground",children:[a?l("span",{"aria-hidden":!0,className:"size-4 shrink-0 max-md:pointer-coarse:size-5"}):null,l("span",{className:"min-w-0 flex-1 truncate",style:{paddingLeft:`${y(N.depth,!0)}px`},children:N.text})]},N.key);if(N.kind==="folder"){let $=N.folder;return m($a,{row:{kind:"folder",path:$.path},selected:i($.path),onSelect:v,draggable:u,ticks:a,dropping:c===$.path,drop:d($.path),children:[m("span",{className:"min-w-0 flex-1 truncate",style:{paddingLeft:`${y(N.depth,!1)}px`},children:[l(kE,{path:$.path,open:N.open,onToggle:n}),p===$.path?l(EE,{path:$.path,onDone:f}):Pe($.path)]}),l("span",{className:"shrink-0 text-xs text-muted-foreground",children:$.pages})]},$.path)}let S=N.page;return l($a,{row:{kind:"page",path:S.path,threadId:S.threadId,name:S.name},selected:i(S.path),onSelect:v,draggable:u,ticks:a,tall:!0,children:m("span",{className:`min-w-0 flex-1 ${S.fileGone||S.threadGone?"opacity-60":""}`,style:{paddingLeft:`${y(N.depth,C)}px`},children:[m("span",{className:"block truncate",children:[S.unread?l(NE,{}):null,Pe(S.path),S.starred?l(AE,{}):null]}),m("span",{className:"block truncate text-xs text-muted-foreground",children:[w?`${Ut(S.path)||"Library"} \xB7 `:"",Wr(S.at)," \xB7 ",h(S.projectId)]})]})},S.path)}),e.more?m(Bu,{children:["Showing the first ",e.pages.length," pages."]}):null]});let T=(N,S)=>({paddingLeft:`${12+y(N,S)}px`});return m("table",{className:"w-full table-fixed text-sm",children:[l("thead",{className:"sticky top-0 bg-background text-left text-xs text-muted-foreground",children:m("tr",{className:"border-b",children:[a?l("th",{className:"w-8 py-1.5 pl-3 font-normal",children:l(Km,{label:a.all?"Select none":"Select all",on:a.all,mixed:a.any&&!a.all,shown:!0,onTick:a.tickAll})}):null,hO.map(N=>l("th",{className:`px-3 py-1.5 font-normal ${N.by==="name"?"w-[34%]":""}`,"aria-sort":N.by&&o.by===N.by?o.desc?"descending":"ascending":void 0,children:N.by?m("button",{type:"button",className:"hover:text-foreground",onClick:()=>s(N.by),children:[N.label,o.by===N.by?o.desc?" \u25BE":" \u25B4":""]}):N.label},N.label))]})}),m("tbody",{children:[t.map(N=>{if(N.kind==="note")return m("tr",{className:"border-b border-border/40",children:[a?l("td",{}):null,l("td",{colSpan:7,className:"truncate px-3 py-1.5 text-xs text-muted-foreground",style:T(N.depth,!0),children:N.text})]},N.key);if(N.kind==="folder"){let P=N.folder,L={kind:"folder",path:P.path};return m("tr",{"data-path":P.path,role:"option","aria-selected":i(P.path),draggable:u,className:`group cursor-default border-b border-border/40 ${i(P.path)?"bg-muted":"hover:bg-muted/50"} ${c===P.path?"outline outline-1 outline-ring":""}`,onClick:ne=>v(L,ne),...d(P.path),children:[a?l(SE,{path:P.path,ticks:a}):null,m("td",{className:"truncate px-3 py-1.5",style:T(N.depth,!1),children:[l(kE,{path:P.path,open:N.open,onToggle:n}),p===P.path?l(EE,{path:P.path,onDone:f}):`${Pe(P.path)}/`]}),l("td",{className:"px-3 py-1.5 text-muted-foreground",children:P.at?Wr(P.at):"\u2014"}),m("td",{className:"px-3 py-1.5 text-muted-foreground",colSpan:5,children:[P.pages," page",P.pages===1?"":"s"]})]},P.path)}let S=N.page,$={kind:"page",path:S.path,threadId:S.threadId,name:S.name};return m("tr",{"data-path":S.path,role:"option","aria-selected":i(S.path),draggable:u,className:`group cursor-default border-b border-border/40 ${i(S.path)?"bg-muted":"hover:bg-muted/50"} ${S.fileGone||S.threadGone?"opacity-60":""}`,onClick:P=>v($,P),children:[a?l(SE,{path:S.path,ticks:a}):null,m("td",{className:"truncate px-3 py-1.5",style:T(N.depth,C),children:[S.unread?l(NE,{}):null,Pe(S.path),S.starred?l(AE,{}):null,w?l("span",{className:"ml-2 text-xs text-muted-foreground",children:Ut(S.path)||"Library"}):null]}),l("td",{className:"truncate px-3 py-1.5 text-muted-foreground",children:Wr(S.at)}),l("td",{className:"truncate px-3 py-1.5 text-muted-foreground",children:h(S.projectId)}),l("td",{className:"truncate px-3 py-1.5 text-muted-foreground",children:S.threadTitle??"\u2014"}),l("td",{className:"truncate px-3 py-1.5 text-muted-foreground",children:S.tags.map(P=>`#${P}`).join(" ")}),l("td",{className:"px-3 py-1.5 text-muted-foreground",children:S.versions}),l("td",{className:"px-3 py-1.5 text-muted-foreground",children:gO(S.size)})]},S.path)}),e.more?l("tr",{children:m("td",{colSpan:a?8:7,className:"px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",e.pages.length," pages."]})}):null]})]})}function kE({path:e,open:t,onToggle:n}){return l("button",{type:"button",tabIndex:-1,"aria-expanded":t,"aria-label":`${t?"Collapse":"Expand"} ${Pe(e)}`,className:"mr-1 inline-block w-4 text-center text-muted-foreground hover:text-foreground",onMouseDown:r=>r.preventDefault(),onClick:r=>{r.stopPropagation(),n(e)},onDoubleClick:r=>r.stopPropagation(),children:t?"\u25BE":"\u25B8"})}function $a({row:e,selected:t,onSelect:n,draggable:r,ticks:o,dropping:s,drop:i,tall:a,children:u}){return m("li",{"data-path":e.path,role:"option","aria-selected":t,draggable:r,className:`group flex cursor-default items-center gap-2 border-b border-border/40 px-3 ${a?"py-2":"py-1.5"} text-sm ${t?"bg-muted":"hover:bg-muted/50"} ${s?"outline outline-1 outline-ring":""}`,onClick:c=>n(e,c),...i,children:[o?l(Km,{label:`Select ${Pe(e.path)}`,on:o.isTicked(e.path),shown:o.any,onTick:c=>o.tick(e.path,c),quiet:!0}):null,u]})}function SE({path:e,ticks:t}){return l("td",{className:"w-8 py-1.5 pl-3",children:l(Km,{label:`Select ${Pe(e)}`,on:t.isTicked(e),shown:t.any,onTick:n=>t.tick(e,n),quiet:!0})})}function Km({label:e,on:t,mixed:n=!1,shown:r,quiet:o=!1,onTick:s}){return l("span",{className:`-m-2 flex shrink-0 cursor-pointer items-center p-2 ${r||t||n?"":"opacity-0 focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100"}`,onClick:a=>{a.stopPropagation(),a.target===a.currentTarget&&s(a.shiftKey)},children:l("input",{type:"checkbox","aria-label":e,title:e,checked:t,readOnly:!0,tabIndex:o?-1:0,ref:a=>{a&&(a.indeterminate=n)},className:"size-4 cursor-pointer max-md:pointer-coarse:size-5",onClick:a=>{a.stopPropagation(),s(a.shiftKey)}})})}function EE({path:e,onDone:t}){let[n,r]=_(Pe(e)),o=s=>s.stopPropagation();return l("form",{className:"inline-block align-middle",onClick:o,onDoubleClick:o,onSubmit:s=>{s.preventDefault(),t(e,n.trim()||null)},children:l(le,{autoFocus:!0,"aria-label":`New name for ${Pe(e)}`,className:"h-7 w-48",maxLength:64,value:n,onFocus:s=>s.currentTarget.select(),onChange:s=>r(s.target.value),onBlur:s=>s.currentTarget.form?.requestSubmit(),onKeyDown:s=>{s.stopPropagation(),s.key==="Escape"&&(s.preventDefault(),t(e,null))}})})}function NE(){return l("span",{role:"img","aria-label":"Changed since you last opened it",className:"mr-1.5 inline-block size-1.5 rounded-full bg-foreground align-middle"})}function AE(){return l("span",{role:"img","aria-label":"Starred",className:"ml-1.5 text-muted-foreground",children:"\u2605"})}function Bu({children:e}){return l("p",{className:"p-3 text-sm text-muted-foreground",children:e})}var RE=(e,t,n)=>`${e===0?"No":e===1?"One":e} ${e===1?t:n}`;function $E(){let{change:e}=Ea();return t=>{e(t.status==="open"?{action:"done",ref:t.id,note:null}:{action:"reopen",ref:t.id,why:null})}}function Rs({eyebrow:e,title:t,children:n}){return m("div",{className:"flex flex-wrap items-end gap-4",children:[m("div",{className:"min-w-0 flex-1",children:[l("p",{className:"text-xs font-semibold text-muted-foreground",children:e}),l("h1",{className:"mt-0.5 text-2xl font-semibold tracking-tight",children:t})]}),n]})}function Ts({tasks:e,meta:t,now:n,open:r,rich:o,empty:s,limit:i}){let a=$E(),[u,c]=_(!1),d=i&&!u?e.slice(0,i):e;return e.length?m(he,{children:[d.map((p,f)=>l(q1,{task:p,assistant:t.assistant,now:n,rich:o,first:f===0,onOpen:()=>r(p),onToggle:()=>a(p)},p.id)),d.length<e.length?m("button",{type:"button",onClick:()=>c(!0),className:"flex w-full cursor-pointer items-center gap-2 border-t border-border-hairline px-4 py-2.5 text-left text-sm font-semibold text-timeline-accent hover:bg-state-hover",children:[l(pe,{name:"ChevronDown","aria-hidden":!0,className:"size-3.5"}),e.length-d.length," more:"," ",e.slice(d.length,d.length+4).map(p=>p.title.toLowerCase()).join(", "),e.length-d.length>4?"\u2026":""]}):null]}):l(Oe,{children:s})}function yO({meta:e,filters:t,open:n,now:r}){let o=nt(),s=ps(t),{data:i,error:a}=We(()=>o.call("tasks.today",s),[o,t.origin,t.project]),u=We(()=>o.call("tasks.upcoming",{...s,days:7}),[o,t.origin,t.project]).data,c=We(()=>o.call("tasks.journal",{day:e.today,newest:!0,limit:3}),[o,e.today]).data;if(!i)return l(Oe,{children:a||"Loading\u2026"});let d=i.yours.filter(x=>x.dueAt!==null&&hs(x.dueAt,i.zone)<=i.day).length,p=[i.yours.length===0?"Nothing needs you right now.":`${RE(i.yours.length,"thing needs","things need")} you${d?`, ${d===i.yours.length&&d>1?"all":d} today`:""}.`,`I\u2019m handling ${i.onIt.length===1?"one other":`${i.onIt.length} others`} and waiting on ${i.waiting.length===1?"one reply":`${i.waiting.length} replies`}.`].join(" "),f=Array.from({length:7},(x,b)=>Yr(i.day,b)),h=new Map(f.map(x=>[x,u?.items.filter(b=>hs(b.at,i.zone)===x)??[]])),g=(c?.entries??[]).slice(-3).reverse();return m("div",{className:"flex flex-wrap items-start gap-8",children:[m("div",{className:"min-w-0 flex-[999_1_34rem] space-y-7",children:[l(Rs,{eyebrow:"Today",title:Ct(i.day)}),m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:e.assistant,size:28}),l("p",{className:"text-base leading-relaxed",children:p})]}),l(Gr,{filters:t,onChange:xn,meta:e}),l(Dn,{title:"Your move",count:i.yours.length,hint:"By priority, then when",children:l(Ts,{tasks:i.yours,meta:e,now:r,open:n,rich:!0,empty:"Nothing is waiting on you. Enjoy it."})}),l(Dn,{title:`${e.assistant}\u2019s on it`,count:i.onIt.length,hint:"Nothing here needs you",children:l(Ts,{tasks:i.onIt,meta:e,now:r,open:n,limit:6,empty:`${e.assistant} has nothing in hand.`})}),l(Dn,{title:"Waiting on others",count:i.waiting.length,hint:`${e.assistant} checks back on the date shown`,children:l(Ts,{tasks:i.waiting,meta:e,now:r,open:n,empty:"Nobody owes you an answer."})})]}),m("aside",{className:"hidden w-80 shrink-0 space-y-7 xl:block","aria-label":"Today at a glance",children:[m("section",{className:"space-y-3",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"This week"}),l("div",{className:"grid grid-cols-7 gap-1",children:f.map((x,b)=>m("div",{className:V("flex flex-col items-center gap-1 rounded-lg py-2",b===0?"bg-foreground text-background":""),children:[l("span",{className:V("text-2xs font-semibold",b===0?"opacity-80":"text-muted-foreground"),children:ur(x)}),l("span",{className:"text-sm font-semibold",children:Number(x.slice(8))}),l("span",{className:"flex h-1.5 gap-0.5",children:(h.get(x)??[]).slice(0,4).map(v=>l("span",{className:V("size-1.5 rounded-full",b===0?"bg-background":v.task.move==="owner"?"bg-warning":"bg-timeline-accent")},`${v.task.id}-${v.at}`))})]},x))})]}),m("section",{className:"space-y-2",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"Today\u2019s schedule"}),i.schedule.length===0?l("p",{className:"text-sm text-muted-foreground",children:"Nothing timed today."}):null,l("ol",{className:"space-y-0.5",children:i.schedule.map((x,b)=>{let v=x.at<r,w=v&&(i.schedule[b+1]?.at??1/0)>=r;return m("li",{children:[m("button",{type:"button",onClick:()=>n(x.task),className:"grid w-full cursor-pointer grid-cols-[4rem_1rem_minmax(0,1fr)] items-start gap-2.5 rounded-md py-1.5 text-left hover:bg-state-hover",children:[l("span",{className:"pt-px text-right text-xs tabular-nums text-muted-foreground",children:Ee(x.at,i.zone)}),l(Ht,{glyph:jr(x.task),className:V("mt-px size-3.5",v?"text-muted-foreground":"text-timeline-accent")}),l("span",{className:V("min-w-0 text-sm leading-snug",v?"text-muted-foreground":"font-medium"),children:x.task.title})]}),w?m("div",{className:"my-1 grid grid-cols-[4rem_minmax(0,1fr)] items-center gap-2.5","aria-hidden":!0,children:[l("span",{className:"text-right text-2xs font-bold text-timeline-accent",children:Ee(r,i.zone)}),l("span",{className:"h-0.5 rounded-full bg-timeline-accent"})]}):null]},`${x.task.id}-${x.at}`)})})]}),g.length?m("section",{className:"space-y-3",children:[l("h2",{className:"text-xs font-semibold text-muted-foreground",children:"From the journal"}),g.map(x=>m("p",{className:"text-sm leading-snug",children:[m("span",{className:"block text-xs text-muted-foreground",children:[Ee(x.at,i.zone)," \xB7 ",x.actor==="assistant"?e.assistant:x.actor==="owner"?"You":"System"," \xB7 ",x.title]}),x.body]},x.seq))]}):null]})]})}function _O({meta:e,filters:t,open:n,now:r}){let o=nt(),[s,i]=_(!0),{data:a,error:u}=We(()=>o.call("tasks.upcoming",{...ps(t),days:28}),[o,t.origin,t.project]);if(!a)return l(Oe,{children:u||"Loading\u2026"});let c=g=>g.kind==="scheduled"&&g.project.id==="internal",d=a.items.filter(g=>s||!c(g.task)),p=new Map;for(let g of d)p.set(hs(g.at,a.zone),[...p.get(hs(g.at,a.zone))??[],g]);let f=Array.from({length:7},(g,x)=>Yr(a.from,x)),h=g=>g===a.from?"Today":g===Yr(a.from,1)?"Tomorrow":ur(g,"long");return m("div",{className:"space-y-7",children:[l(Rs,{eyebrow:"Upcoming",title:"This week and later",children:m("label",{className:"inline-flex cursor-pointer items-center gap-2 text-xs font-medium text-muted-foreground",children:[l("input",{type:"checkbox",className:"size-4 accent-foreground",checked:s,onChange:g=>i(g.target.checked)}),"Show ",e.assistant,"\u2019s routines"]})}),l(Gr,{filters:t,onChange:xn,meta:e}),l("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4 lg:grid-cols-7","aria-label":"The week ahead",children:f.map((g,x)=>m("div",{className:V("flex min-h-36 flex-col gap-1 rounded-xl border bg-surface-raised p-2.5",x===0?"border-foreground/40 ring-1 ring-foreground/20":"border-border-hairline"),children:[m("p",{className:"flex items-baseline gap-1.5",children:[l("span",{className:"text-base font-semibold",children:Number(g.slice(8))}),l("span",{className:"text-xs font-semibold text-muted-foreground",children:x===0?"Today":ur(g)})]}),(p.get(g)??[]).slice(0,5).map(b=>m("button",{type:"button",onClick:()=>n(b.task),className:V("flex cursor-pointer items-center gap-1.5 truncate rounded-md px-1.5 py-1 text-left text-xs",c(b.task)?"border border-dashed border-border text-muted-foreground":b.task.priority==="urgent"?"bg-surface-destructive font-semibold text-destructive-text":b.task.priority==="high"?"bg-warning/15 font-semibold text-warning-text":"bg-surface-selected font-medium"),children:[b.timed?l("span",{className:"shrink-0 tabular-nums opacity-75",children:Ee(b.at,a.zone)}):null,l("span",{className:"truncate",children:b.task.title})]},`${b.task.id}-${b.at}`)),(p.get(g)?.length??0)>5?m("span",{className:"px-1.5 text-2xs text-muted-foreground",children:["+",(p.get(g)?.length??0)-5," more"]}):null]},g))}),m("div",{className:"space-y-6",children:[[...p.entries()].map(([g,x])=>m("section",{className:"space-y-2",children:[m("h2",{className:"flex items-baseline gap-2",children:[l("span",{className:"text-sm font-semibold",children:h(g)}),l("span",{className:"text-xs text-muted-foreground",children:Ct(g)})]}),l("div",{className:"overflow-hidden rounded-xl border border-border-hairline bg-surface-raised",children:x.map((b,v)=>m("button",{type:"button",onClick:()=>n(b.task),className:V("grid w-full cursor-pointer grid-cols-[4.5rem_1rem_minmax(0,1fr)_auto] items-center gap-3 px-4 py-2.5 text-left hover:bg-state-hover",v>0&&"border-t border-border-hairline"),children:[l("span",{className:V("text-right text-xs font-semibold tabular-nums",(c(b.task)||!b.timed)&&"font-normal text-muted-foreground"),children:b.timed?Ee(b.at,a.zone):"Due"}),l(Ht,{glyph:jr(b.task),className:c(b.task)?"text-muted-foreground":"text-timeline-accent"}),m("span",{className:"flex min-w-0 items-center gap-2",children:[l("span",{className:V("truncate text-sm",c(b.task)?"text-muted-foreground":"font-semibold"),children:b.task.title}),l(De,{origin:b.task.origin,assistant:e.assistant,size:15}),l(Na,{project:b.task.project})]}),m("span",{className:"flex items-center gap-2.5",children:[l("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:b.task.whenText?Qr(b.task.whenText):""}),l(us,{level:b.task.priority})]})]},`${b.task.id}-${b.at}`))})]},g)),p.size===0?l(Oe,{children:"Nothing timed in the next four weeks."}):null,a.undated.length?l(Dn,{title:"No date",count:a.undated.length,hint:"Open, with no when",children:l(Ts,{tasks:a.undated,meta:e,now:r,open:n,limit:8,empty:""})}):null]})]})}async function IE(e,t,n,r){let o=[],s=0,i=0;for(let a=0;a<n&&s!==null;a++){let u=await e.call("tasks.list",{...t,limit:r,offset:s});o.push(...u.tasks),i=u.total,s=u.next}return{tasks:o,total:i,more:s!==null}}function PE({label:e,onClick:t}){return m("button",{type:"button",onClick:t,className:"flex w-full cursor-pointer items-center gap-2 border-t border-border-hairline px-4 py-2.5 text-left text-sm font-semibold text-timeline-accent hover:bg-state-hover",children:[l(pe,{name:"ChevronDown","aria-hidden":!0,className:"size-3.5"}),e]})}function vO({meta:e,filters:t,open:n,now:r}){let o=nt(),[s,i]=_(1),{data:a,error:u}=We(()=>IE(o,{...ps(t),move:"others",status:"open",sort:"due"},s,200),[o,s,t.origin,t.project]);return m("div",{className:"space-y-7",children:[l(Rs,{eyebrow:"Waiting on others",title:a?`${RE(a.total,"reply","replies")} outstanding`:"Waiting on others"}),l(Gr,{filters:t,onChange:xn,meta:e}),l(Dn,{title:"Waiting",count:a?.total,hint:`Soonest check-back first. ${e.assistant} nudges at most twice, then hands it back with what was tried`,children:a?m(he,{children:[l(Ts,{tasks:a.tasks,meta:e,now:r,open:n,rich:!0,empty:"Nobody owes you an answer."}),a.more?l(PE,{label:`Show more (${a.total-a.tasks.length} left)`,onClick:()=>i(c=>c+1)}):null]}):l(Oe,{children:u||"Loading\u2026"})})]})}function wO({meta:e,filters:t,open:n,now:r}){let o=nt(),[s,i]=_("both"),{data:a,error:u}=We(()=>o.call("tasks.rhythms",ps(t)),[o,t.origin,t.project]);if(!a)return l(Oe,{children:u||"Loading\u2026"});let c=Array.from({length:14},(d,p)=>Yr(a.from,p));return m("div",{className:"space-y-7",children:[l(Rs,{eyebrow:"Scheduled and watched",title:"What happens on a rhythm, and what\u2019s being watched"}),m("p",{className:"-mt-4 max-w-2xl text-sm text-muted-foreground",children:["Scheduled tasks happen at set times. A watch belongs to a task that\u2019s waiting: ",e.assistant," checks quietly and only acts or tells you when something changes."]}),l(Gr,{filters:t,onChange:xn,meta:e,children:l(_t,{label:"Show",value:s,onChange:i,options:[{value:"both",label:"Both"},{value:"scheduled",label:"Scheduled"},{value:"watching",label:"Watching"}]})}),s!=="watching"?l(Dn,{title:"Scheduled",count:a.scheduled.length,hint:"The next two weeks",children:a.scheduled.length?m(he,{children:[m("div",{className:"hidden grid-cols-[1rem_minmax(0,1.4fr)_minmax(0,1fr)_15rem] gap-4 border-b border-border-hairline bg-muted/40 px-4 py-2 text-2xs font-semibold text-muted-foreground md:grid",children:[l("span",{}),l("span",{children:"Name"}),l("span",{children:"When"}),l("span",{className:"grid gap-0.5 text-center",style:{gridTemplateColumns:"repeat(14, minmax(0, 1fr))"},children:c.map((d,p)=>l("span",{className:p===0?"text-foreground":"",children:ur(d).charAt(0)},d))})]}),a.scheduled.map(({task:d,next:p},f)=>{let h=new Set(p.map(g=>hs(g,a.zone)));return m("button",{type:"button",onClick:()=>n(d),className:V("grid w-full cursor-pointer grid-cols-[1rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 px-4 py-3 text-left hover:bg-state-hover md:grid-cols-[1rem_minmax(0,1.4fr)_minmax(0,1fr)_15rem]",f>0&&"border-t border-border-hairline"),children:[l(Ht,{glyph:"repeat",className:"text-timeline-accent"}),m("span",{className:"min-w-0",children:[m("span",{className:"flex items-center gap-2",children:[l("span",{className:"truncate text-sm font-semibold",children:d.title}),l(De,{origin:d.origin,assistant:e.assistant,size:15}),l(Na,{project:d.project})]}),l("span",{className:"block truncate text-xs text-muted-foreground",children:d.move==="owner"?"Reminder for you":`${e.assistant} does it`})]}),l("span",{className:"col-start-2 text-sm font-medium md:col-start-auto",children:d.whenText?Qr(d.whenText):""}),l("span",{className:"col-start-2 grid gap-0.5 md:col-start-auto",style:{gridTemplateColumns:"repeat(14, minmax(0, 1fr))"},"aria-label":`Runs on ${h.size} of the next 14 days`,children:c.map((g,x)=>l("span",{className:V("h-4 rounded",h.has(g)?d.move==="owner"?"bg-warning":"bg-foreground/80":"bg-muted",x===0&&"ring-2 ring-foreground/25 ring-offset-1 ring-offset-surface-raised")},g))})]},d.id)})]}):l(Oe,{children:"No repeating tasks yet. Say \u201Cevery Friday at 4pm, \u2026\u201D in the conversation, or add one here."})}):null,s!=="scheduled"?l(Dn,{title:"Watching",count:a.watched.length,hint:"Each one ends when its task does",children:a.watched.length?a.watched.map((d,p)=>m("button",{type:"button",onClick:()=>n(d),className:V("flex w-full cursor-pointer items-center gap-3 px-4 py-3 text-left hover:bg-state-hover",p>0&&"border-t border-border-hairline"),children:[l(Ht,{glyph:"watch",className:"text-timeline-accent"}),m("span",{className:"min-w-0 flex-1",children:[m("span",{className:"flex items-center gap-2",children:[l("span",{className:"truncate text-sm font-semibold",children:d.title}),l(De,{origin:d.origin,assistant:e.assistant,size:15}),l(Na,{project:d.project})]}),l("span",{className:"block truncate text-xs text-muted-foreground",children:d.when?.form==="on_change"&&d.watch===null?`No watch yet; ${e.assistant} sets one up`:d.waitingOn?`Waiting on ${d.waitingOn}`:d.why??""})]}),l(Sa,{task:d,now:r})]},d.id)):l(Oe,{children:"Nothing is being watched."})}):null]})}async function kO(e,t,n){let r=[],o=[],s=null;for(let i=0;i<n;i++){let a=await e.call("tasks.journal",{...t,newest:!0,limit:200,...s===null?{}:{before:s}});if(r.unshift(...a.entries),o=a.notes,s=a.next,s===null)break}return{entries:r,notes:o,more:s!==null}}function SO({meta:e,filters:t}){let n=nt(),[r,o]=_(e.today),[s,i]=_(1),[a,u]=_("both"),[c,d]=_(null),[p,f]=_(""),{data:h,error:g,reload:x}=We(async()=>({day:r,journal:await kO(n,{day:r,...a!=="both"?{actor:a}:{},...t.project?{project:t.project}:{}},s)}),[n,r,a,s,t.project]),b=h?.day===r?h.journal:null,v=b?.notes.find(y=>y.actor==="owner")?.body??"",w=b?.notes.find(y=>y.actor==="assistant")?.body,C=e.zone;return m("div",{className:"mx-auto max-w-3xl space-y-7",children:[m(Rs,{eyebrow:"Journal",title:Ct(r),children:[l(R,{variant:"outline",size:"icon","aria-label":"The day before",onClick:()=>(o(Yr(r,-1)),d(null),f(""),i(1)),children:l(pe,{name:"ChevronLeft","aria-hidden":!0,className:"size-4"})}),l(R,{variant:"outline",size:"icon","aria-label":"The day after",disabled:r>=e.today,onClick:()=>(o(Yr(r,1)),d(null),f(""),i(1)),children:l(pe,{name:"ChevronRight","aria-hidden":!0,className:"size-4"})}),r!==e.today?l(R,{variant:"outline",size:"sm",onClick:()=>(o(e.today),d(null),f(""),i(1)),children:"Today"}):null]}),w?m("div",{className:"flex items-start gap-3.5 rounded-2xl bg-surface-selected px-4 py-3.5",children:[l(De,{origin:"assistant",assistant:e.assistant,size:26}),l("p",{className:"whitespace-pre-wrap text-base leading-relaxed",children:w})]}):null,m("div",{className:"flex flex-wrap items-center gap-3",children:[l(_t,{label:"Whose lines",value:a,onChange:u,options:[{value:"both",label:"Both"},{value:"assistant",label:e.assistant},{value:"owner",label:"You"}]}),l(Gr,{filters:t,onChange:xn,meta:e,origin:!1})]}),b?b.entries.length===0?m(Oe,{children:["Nothing was written ",r===e.today?"yet today":"that day","."]}):m("ol",{className:"relative space-y-4 border-l border-border-hairline pl-6",children:[b.more?l("li",{children:m("button",{type:"button",onClick:()=>i(y=>y+1),className:"flex cursor-pointer items-center gap-2 text-sm font-semibold text-timeline-accent hover:underline",children:[l(pe,{name:"ChevronUp","aria-hidden":!0,className:"size-3.5"}),"Show earlier"]})}):null,b.entries.map(y=>m("li",{className:"relative",children:[l("span",{className:"absolute -left-[2.15rem] top-0",children:y.actor==="system"?l("span",{className:"block size-5 rounded-full border border-border bg-muted"}):l(De,{origin:y.actor==="assistant"?"assistant":"owner",assistant:e.assistant,size:22})}),m("p",{className:"text-xs text-muted-foreground",children:[Ee(y.at,C)," \xB7 ",y.actor==="assistant"?e.assistant:y.actor==="owner"?"You":"System"]}),l("p",{className:V("mt-0.5 whitespace-pre-wrap text-sm leading-relaxed",y.actor==="owner"&&y.what==="note"&&"rounded-lg border border-border-hairline bg-surface-raised px-3 py-2",y.what==="created"&&"text-muted-foreground"),children:y.body}),m("p",{className:"mt-1.5 text-xs font-medium text-muted-foreground",children:[y.key," \xB7 ",y.title]})]},y.seq))]}):l(Oe,{children:g||"Loading\u2026"}),m("form",{className:"space-y-2 rounded-2xl border border-border bg-surface-raised p-4",onSubmit:y=>{y.preventDefault(),b&&n.call("tasks.dayNote",{day:r,body:c??v}).then(()=>{f(`Saved ${Ee(Date.now(),C)}`),x()},T=>f(`Couldn\u2019t save: ${T instanceof Error?T.message:String(T)}`))},children:[m("label",{className:"flex items-center gap-2 text-sm font-semibold",children:[l(De,{origin:"owner",assistant:e.assistant,size:18}),"Your note for ",r===e.today?"today":Ct(r,"short")]}),l("textarea",{value:c??v,disabled:!b,onChange:y=>d(y.target.value),rows:3,className:"w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm leading-relaxed",placeholder:`How did it go? Anything on your mind, or anything ${e.assistant} should know?`}),m("div",{className:"flex items-center justify-end gap-3",children:[l("span",{className:"text-xs text-muted-foreground",children:p||`${e.assistant} reads your notes as context`}),l(R,{type:"submit",size:"sm",disabled:!b||c===null||c===v,children:"Save note"})]})]})]})}function EO({meta:e,filters:t,open:n,now:r}){let o=nt(),[s,i]=_("done"),[a,u]=_(1),{data:c,error:d}=We(()=>IE(o,{...ps(t),status:s,sort:"closed"},a,50),[o,s,a,t.origin,t.project]),p=c?.tasks??[];return m("div",{className:"space-y-7",children:[l(Rs,{eyebrow:"Done",title:"Finished and dropped",children:l(_t,{label:"Which",value:s,onChange:f=>{i(f),u(1)},options:[{value:"done",label:"Done"},{value:"dropped",label:"Dropped"}]})}),l(Gr,{filters:t,onChange:xn,meta:e}),l(Dn,{title:s==="done"?"Done":"Dropped",count:c?.total,hint:s==="dropped"?"Each with its reason; reopen any of them":"Most recent first",children:c?m(he,{children:[l(Ts,{tasks:p,meta:e,now:r,open:n,empty:s==="done"?"Nothing finished yet.":"Nothing dropped."}),c.more?l(PE,{label:"Show older",onClick:()=>u(f=>f+1)}):null]}):l(Oe,{children:d||"Loading\u2026"})})]})}function OE({subPath:e}){let t=am(e),[n,r]=_(t.task);K(()=>{t.task&&r(t.task)},[t.task]);let o=ds(),[s]=cm(),i=en(),a=fs(),[u,c]=_(!1),d=f=>i(t.view,f.key),p=o?{today:l(yO,{meta:o,filters:s,open:d,now:a}),upcoming:l(_O,{meta:o,filters:s,open:d,now:a}),waiting:l(vO,{meta:o,filters:s,open:d,now:a}),scheduled:l(wO,{meta:o,filters:s,open:d,now:a}),journal:l(SO,{meta:o,filters:s}),done:l(EO,{meta:o,filters:s,open:d,now:a})}:{today:null,upcoming:null,waiting:null,scheduled:null,journal:null,done:null};return m("main",{className:"h-full overflow-auto",children:[m("div",{className:"mx-auto flex max-w-7xl flex-col gap-6 p-4 sm:p-8",children:[m("div",{className:"flex items-center gap-2",children:[l("nav",{"aria-label":"Task views",className:"flex min-w-0 flex-1 gap-1 overflow-x-auto md:hidden",children:hu.map(f=>l("button",{type:"button","aria-current":t.view===f.id?"page":void 0,onClick:()=>i(f.id),className:V("shrink-0 cursor-pointer rounded-full px-3 py-1.5 text-xs font-semibold",t.view===f.id?"bg-foreground text-background":"bg-muted text-muted-foreground"),children:f.label},f.id))}),m(R,{className:"ml-auto shrink-0","aria-label":"New task",onClick:()=>c(!0),children:[l(pe,{name:"Plus","aria-hidden":!0,className:"size-4"}),l("span",{className:"hidden sm:inline",children:"New task"})]})]}),o?p[t.view]:l(Oe,{children:"Loading\u2026"})]}),l(qS,{open:u,onClose:()=>c(!1),meta:o,onMade:f=>{c(!1),i(t.view,f.key)}}),l(JS,{open:t.task!==null,taskRef:t.task??n,meta:o,onClose:()=>i(t.view)})]})}function LE({subPath:e}){let t=am(e),n=en(),r=nt(),o=ds(),[s,i]=cm(),a=We(()=>r.call("tasks.today",{}),[r]).data,u={today:a?.yours.length,waiting:a?.waiting.length};return m("nav",{"aria-label":"Tasks",className:"flex flex-col gap-0.5 p-2",children:[hu.map(c=>m("button",{type:"button","aria-current":t.view===c.id?"page":void 0,onClick:()=>n(c.id),className:V("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm",t.view===c.id?"bg-muted font-semibold":"hover:bg-muted/60"),children:[l("span",{className:"min-w-0 flex-1 truncate",children:c.label}),u[c.id]?l("span",{className:V("rounded-full px-1.5 text-2xs font-bold",c.id==="today"?"bg-foreground text-background":"text-muted-foreground"),children:u[c.id]}):null]},c.id)),l("p",{className:"mt-4 px-2 pb-1 text-xs font-semibold text-muted-foreground",children:"Projects"}),(o?.projects??[]).map(c=>m("button",{type:"button","aria-pressed":s.project===c.id,onClick:()=>i({...s,project:s.project===c.id?"":c.id}),className:V("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm",s.project===c.id?"bg-muted font-semibold":"hover:bg-muted/60"),children:[l("span",{className:"min-w-0 flex-1 truncate",children:c.name}),l("span",{className:"text-2xs font-bold tracking-wide text-muted-foreground",children:c.key})]},c.id)),m("p",{className:"px-2 pt-2 text-xs leading-snug text-muted-foreground",children:["A project is a GitHub repo. Personal holds your life; Internals holds ",o?.assistant??"the assistant","\u2019s own workings."]})]})}function ME(){let e=nt(),t=ds(),n=en(),r=fs(),o=$E(),{data:s,error:i}=We(()=>e.call("tasks.today",{}),[e]);if(!s||!t)return l(Oe,{children:i||"Loading\u2026"});let a=s.schedule.filter(u=>u.at>=r).slice(0,4);return m("div",{className:"space-y-6 p-4",children:[m("section",{className:"space-y-2",children:[m("h2",{className:"flex items-center gap-2 text-sm font-semibold",children:["Your move ",l("span",{className:"rounded-full bg-muted px-2 text-xs text-muted-foreground",children:s.yours.length}),l("button",{type:"button",className:"ml-auto cursor-pointer text-xs font-semibold text-timeline-accent",onClick:()=>n("today"),children:"Open Tasks"})]}),s.yours.length===0?l("p",{className:"text-sm text-muted-foreground",children:"Nothing needs you."}):null,l("ul",{className:"divide-y divide-border-hairline",children:s.yours.map(u=>m("li",{className:"flex items-center gap-2.5 py-2",children:[l("button",{type:"button","aria-label":`Mark ${u.title} done`,onClick:()=>o(u),className:"size-4 shrink-0 cursor-pointer rounded-full border-[1.5px] border-foreground/35 hover:border-foreground/70"}),l("button",{type:"button",onClick:()=>n("today",u.key),className:"min-w-0 flex-1 cursor-pointer truncate text-left text-sm font-medium",children:u.title}),l(De,{origin:u.origin,assistant:t.assistant,size:14}),l(Sa,{task:u,now:r})]},u.id))})]}),a.length?m("section",{className:"space-y-1.5",children:[l("h2",{className:"text-sm font-semibold",children:"Next up today"}),a.map(u=>m("button",{type:"button",onClick:()=>n("today",u.task.key),className:"grid w-full cursor-pointer grid-cols-[4rem_1rem_minmax(0,1fr)] items-center gap-2 py-1 text-left text-sm",children:[l("span",{className:"text-right text-xs tabular-nums text-muted-foreground",children:Ee(u.at,s.zone)}),l(Ht,{glyph:jr(u.task),className:"size-3.5 text-timeline-accent"}),l("span",{className:"truncate",children:u.task.title})]},`${u.task.id}-${u.at}`))]}):null,m("p",{className:"border-t border-border-hairline pt-3 text-xs leading-relaxed text-muted-foreground",children:[t.assistant," is handling ",s.onIt.length," and waiting on ",s.waiting.length===1?"one reply":`${s.waiting.length} replies`,".",s.waiting[0]?.whenText?` Next check: ${s.waiting[0].title}, ${s.waiting[0].whenText}.`:""]})]})}function $s(e){let t=e?.nickname?.trim(),n=e?.name.trim();return t||(n&&n!=="Orbit"?n:"your moonlet")}function Is(){let e=J(),[t,n]=_(null),[r,o]=_(null),s=q(()=>{e.call("config.state",null).then(i=>{n(i),o(null)},i=>o(i instanceof Error?i.message:String(i)))},[e]);return K(s,[s]),ke("config",s),{rpc:e,state:t,error:r,refetch:s}}function DE(e,t){let n=URL.createObjectURL(new Blob([t],{type:"application/toml"})),r=document.createElement("a");r.href=n,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}function FE(e){let t=document.createElement("input");t.type="file",t.accept=".toml,text/plain",t.onchange=()=>{t.files?.[0]?.text().then(e)},t.click()}function zE({at:e,by:t}){return e?m("span",{className:"text-xs text-muted-foreground",children:["Last changed ",new Date(e).toLocaleString(),t?` by ${t}`:""]}):null}function Ia(){let{state:e}=Is(),t=$s(e?.prefs.identity);return t==="your moonlet"?"Your moonlet":t}var NO=256,AO=.85,CO=[["image/webp","webp"],["image/png","png"],["image/jpeg","jpg"]],lo=class extends Error{};function TO(e,t,n=NO){let r=Math.min(e,t);return{x:Math.floor((e-r)/2),y:Math.floor((t-r)/2),side:r,edge:Math.min(r,n)}}var Xm=e=>Math.ceil(e/1024);async function KE(e){let t=new Uint8Array(await e.arrayBuffer()),n="";for(let r=0;r<t.length;r+=32768)n+=String.fromCharCode(...t.subarray(r,r+32768));return btoa(n)}var XE={decode:e=>createImageBitmap(e,{imageOrientation:"from-image"}),encode:(e,t,n)=>new Promise((r,o)=>{let s=document.createElement("canvas");s.width=t.edge,s.height=t.edge;let i=s.getContext("2d");if(!i){o(new lo("This browser can't shrink pictures. Choose one of at most 128 KB."));return}n==="image/jpeg"&&(i.fillStyle="#fff",i.fillRect(0,0,t.edge,t.edge)),i.imageSmoothingQuality="high",i.drawImage(e,t.x,t.y,t.side,t.side,0,0,t.edge,t.edge),s.toBlob(a=>a?r(a):o(new lo("The picture couldn't be saved smaller.")),n,AO)})};async function BE(e,t){if(e.type==="image/svg+xml"||/\.svg$/i.test(e.name)){if(e.size>131072)throw new lo(`An SVG avatar is at most ${Xm(131072)} KB, and an SVG can't be shrunk (${e.name} is ${Xm(e.size)} KB).`);return{name:"avatar.svg",base64:await KE(e)}}let n;try{n=await t.decode(e)}catch{throw new lo(`${e.name} isn't a picture this browser can open. Choose a PNG, JPEG, WebP or SVG.`)}try{let r=TO(n.width,n.height);for(let[o,s]of CO){let i=await t.encode(n,r,o);if(i.type===o&&i.size>0&&i.size<=131072)return{name:`avatar.${s}`,base64:await KE(i)}}throw new lo(`${e.name} couldn't be made smaller than ${Xm(131072)} KB. Try a simpler picture.`)}finally{n.close()}}var RO=[["orbit","In your moonlet's conversation"],["work","On the conversations it starts"]],$O="image/png,image/jpeg,image/webp,image/svg+xml,.png,.jpg,.jpeg,.webp,.svg";function UE({avatar:e,onChange:t,shrink:n=r=>BE(r,XE)}){let r=J(),[o,s]=_(null),i=Y({}),a=(u,c)=>{s({which:u,text:"Shrinking the picture\u2026",failed:!1}),n(c).then(d=>r.call("config.avatarFromUpload",d)).then(d=>{if(d.url){let p=d.url;t(f=>({...f,[u]:p})),s(null)}else s({which:u,text:d.problem??"The picture was refused.",failed:!0})},d=>s({which:u,text:d instanceof Error?d.message:String(d),failed:!0}))};return l("div",{className:"flex flex-wrap gap-6",children:RO.map(([u,c])=>m("div",{className:"flex items-center gap-3",children:[l(oc,{url:e[u],label:c,size:48}),m("div",{className:"flex flex-col gap-1",children:[l("span",{className:"font-medium",children:c}),m("div",{className:"flex gap-2",children:[l("input",{ref:d=>{i.current[u]=d},type:"file",accept:$O,hidden:!0,"aria-label":`Picture for ${c}`,onChange:d=>{let p=d.currentTarget.files?.[0];d.currentTarget.value="",p&&a(u,p)}}),l(R,{size:"sm",variant:"secondary",disabled:o?.which===u&&!o.failed,onClick:()=>i.current[u]?.click(),children:e[u]?"Replace\u2026":"Choose\u2026"}),l(R,{size:"sm",variant:"ghost",disabled:!e[u],onClick:()=>{s(null),t(({[u]:d,...p})=>p)},children:"Clear"})]}),o?.which===u&&l("p",{role:o.failed?"alert":"status",className:o.failed?"text-xs text-destructive":"text-xs text-muted-foreground",children:o.text})]})]},u))})}function Ps(){let{rpc:e,state:t,error:n,refetch:r}=Is(),o=Y(null),s=Y(0),i=Y(Promise.resolve()),[a,u]=_(null),[c,d]=_(null);ot(()=>{t&&s.current===0&&(o.current={prefs:t.prefs,base:t.prefsBase})},[t]);let p=q(f=>(s.current+=1,i.current=i.current.then(async()=>{try{let h=o.current;if(!h)return;let g=f(h.prefs);if(JSON.stringify(g)===JSON.stringify(h.prefs))return;await e.call("config.savePrefs",{prefs:g,base:h.base});let x=await e.call("config.state",null);o.current={prefs:x.prefs,base:x.prefsBase},u(null),d(Date.now())}catch(h){u(h instanceof Error?h.message:String(h))}finally{s.current-=1,r()}}),i.current),[e,r]);return{rpc:e,state:t,error:n,refetch:r,save:p,problem:a,savedAt:c}}function Hu({problem:e,savedAt:t}){return e?l("p",{role:"alert",className:"text-xs text-destructive",children:e}):t===null?null:l("p",{role:"status",className:"text-xs text-muted-foreground",children:"Saved. Your moonlet uses it from now on."})}function Vu({label:e,value:t,onCommit:n,multiline:r=!1,rows:o=3,placeholder:s,className:i=""}){let[a,u]=_(t),c=Y(!1),d=Y(t);K(()=>{d.current=t,c.current||u(t)},[t]);let p=()=>{c.current=!1,!(a===t&&a===d.current)&&(d.current=a,n(a))};return r?l("textarea",{"aria-label":e,rows:o,placeholder:s,className:`w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm leading-relaxed outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 ${i}`,value:a,onFocus:()=>{c.current=!0},onChange:f=>u(f.target.value),onBlur:p}):l(le,{"aria-label":e,placeholder:s,className:`h-8 w-64 text-sm ${i}`,value:a,onFocus:()=>{c.current=!0},onChange:f=>u(f.target.value),onBlur:p,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()}})}function IO(e,t,n){let r={...e};return n.trim()||t==="name"?r[t]=n:delete r[t],r}function HE(){let{state:e,error:t,save:n,problem:r,savedAt:o}=Ps();if(t)return l("p",{className:"text-sm text-destructive",children:t});if(!e)return l("p",{className:"text-sm text-muted-foreground",children:"Loading\u2026"});let s=e.prefs.identity,i=$s(s),a=(u,c,d,p={})=>l(Ei,{label:c,description:d,controlPlacement:p.multiline?"below":"inline",children:l(Vu,{label:c,multiline:p.multiline,rows:2,value:s[u]??"",onCommit:f=>{n(h=>({...h,identity:IO(h.identity,u,f)}))}})});return m("div",{className:"space-y-10",children:[l(Hu,{problem:r,savedAt:o}),l(ct,{title:"Identity",description:`How ${i==="your moonlet"?"your moonlet":i} introduces itself in chat, commits and mail.`,children:m("div",{className:"space-y-5",children:[a("name","Name","Its formal name, on commits and as the sender in mail."),a("nickname","Nickname","What you call it day to day. Empty: the name."),a("pronouns","Pronouns",void 0),a("signature","Signature","One line under its sign-off in mail. Empty: the nickname, else the name."),a("bio","Bio","One or two sentences, for introductions.",{multiline:!0})]})}),l(ct,{title:"Pictures",description:"Shown beside its messages. PNG, JPEG or WebP is cropped square and shrunk to 256 pixels; an SVG may be up to 128 KB.",children:l(UE,{avatar:e.prefs.avatar,onChange:u=>{n(c=>({...c,avatar:u(c.avatar)}))}})}),l(ct,{title:"Accounts",description:"Its own accounts. Change the account itself first, then update it here. Without an email address it doesn't commit or send mail.",children:m("div",{className:"space-y-5",children:[a("email","Email address","Where it commits and sends mail from."),a("github","GitHub username",void 0)]})}),l(ct,{title:"Owner",children:a("owner","Works for",'Who it works for, by name. Empty: "your owner". Only you can change this.')})]})}var Os=e=>typeof e=="string"?e:e.text,VE=e=>typeof e=="string"?null:e.until,ZE=(e,t)=>Os(e)===Os(t)&&VE(e)===VE(t);function WE(e,t,n){let r=e[n];return r!==void 0&&ZE(r,t)?n:e.findIndex(o=>ZE(o,t))}function PO(e,t){return new Date(e).toLocaleString("en-US",{timeZone:t,weekday:"short",day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}function OO({r:e,n:t,zone:n,onChange:r,onRemove:o}){let s=J(),[i,a]=_(!1),[u,c]=_(""),[d,p]=_(null),f=typeof e=="string"?null:e.until,h=f!==null&&Date.parse(f)<=Date.now();return m("li",{className:"flex flex-col gap-2 py-2.5 text-sm first:pt-0 last:pb-0",children:[m("div",{className:"flex items-start gap-3",children:[l("span",{className:"w-5 shrink-0 pt-px text-right text-xs tabular-nums text-muted-foreground",children:t}),m("div",{className:"min-w-0 flex-1",children:[l("p",{className:h?"text-muted-foreground line-through":"text-foreground",children:Os(e)}),f!==null&&l("p",{className:`mt-0.5 text-xs ${h?"text-destructive":"text-muted-foreground"}`,children:`${h?"Lapsed":"Until"} ${PO(f,n)}`})]}),f!==null&&l(R,{size:"sm",variant:h?"secondary":"ghost",onClick:()=>a(!i),children:"Renew"}),l(R,{size:"sm",variant:"ghost",onClick:o,children:"Remove"})]}),i&&m("div",{className:"ml-8 flex flex-wrap items-center gap-2 text-xs",children:[l(le,{type:"datetime-local",className:"w-56",value:u,onChange:g=>c(g.target.value)}),m("span",{className:"text-muted-foreground",children:["in ",n]}),l(R,{size:"sm",variant:"secondary",disabled:!u,onClick:()=>{s.call("config.untilInstant",{at:u}).then(g=>{if(g.until===null)return p(g.problem);p(null),a(!1),r({text:Os(e),until:g.until})},g=>p(g instanceof Error?g.message:String(g)))},children:"Until then"}),l(R,{size:"sm",variant:"ghost",onClick:()=>{a(!1),r(Os(e))},children:"No end"}),d&&l("span",{className:"text-destructive",children:d})]})]})}function jE(){let{state:e,error:t,save:n,problem:r,savedAt:o}=Ps(),[s,i]=_("");if(t)return l("p",{className:"text-sm text-destructive",children:t});if(!e)return l("p",{className:"text-sm text-muted-foreground",children:"Loading\u2026"});let a=e.prefs.instructions,u=()=>{let c=s.trim();c&&(i(""),n(d=>({...d,instructions:[...d.instructions,c]})))};return m("div",{className:"space-y-10",children:[l(Hu,{problem:r,savedAt:o}),l(ct,{title:"Tone",description:"How it talks to you. {{owner}} stands for your name.",children:l(Vu,{label:"Tone and persona",multiline:!0,rows:6,value:e.prefs.tone,onCommit:c=>{n(d=>({...d,tone:c}))}})}),l(ct,{title:"Standing instructions",description:"Rules it always follows. When it adds one itself, you see it here.",children:m("div",{className:"space-y-4",children:[a.length===0?l("p",{className:"text-sm text-muted-foreground",children:"None yet."}):l("ol",{className:"divide-y divide-border",children:a.map((c,d)=>l(OO,{r:c,n:d+1,zone:e.zone,onChange:p=>{n(f=>{let h=WE(f.instructions,c,d);return{...f,instructions:f.instructions.map((g,x)=>x===h?p:g)}})},onRemove:()=>{n(p=>{let f=WE(p.instructions,c,d);return{...p,instructions:p.instructions.filter((h,g)=>g!==f)}})}},`${d}-${Os(c)}`))}),m("div",{className:"flex gap-2",children:[l(le,{"aria-label":"New instruction",placeholder:"Never book anything before 9am",value:s,onChange:c=>i(c.target.value),onKeyDown:c=>{c.key==="Enter"&&u()}}),l(R,{size:"sm",variant:"outline",disabled:!s.trim(),onClick:u,children:"Add"})]})]})})]})}function QE(){let e=0;return{async take(t){let n=++e,r=await t;return n===e?{current:!0,value:r}:{current:!1}},cancel(){e++}}}var qE=[{id:"you",title:"About you",lead:"Your moonlet works for you. Tell it who you are; it keeps the rest in memory as you go."},{id:"reach",title:"Reaching you",lead:"Your moonlet talks with you in its conversation in Moonlet. Say where else it should put things, and when to leave you alone."},{id:"touchpoints",title:"Your day",lead:'When your moonlet comes to you on its own. To change one later, just tell your moonlet ("move the morning digest to 8"), or change it in Settings \u2192 your moonlet \u2192 Daily rhythm.'},{id:"sign-ins",title:"Machine sign-ins",lead:"The keys your moonlet's machines sign in with. Both can wait: add them later in Settings, the 1Password key under Integrations and the Claude Code token under Providers."}],GE=["Text message (SMS)","Voice call","WhatsApp","Telegram","Signal","iMessage","Slack","Discord"],LO=[["mon","Monday"],["tue","Tuesday"],["wed","Wednesday"],["thu","Thursday"],["fri","Friday"],["sat","Saturday"],["sun","Sunday"]],Ls=e=>e instanceof Error?e.message:String(e);function Hm(){let e=J(),[t,n]=_(null),[r,o]=_(null),s=q(()=>{e.call("welcome.state",null).then(i=>{n(i),o(null)},i=>o(i instanceof Error?i.message:String(i)))},[e]);return K(s,[s]),ke("config",s),{rpc:e,state:t,error:r,refetch:s}}function Bm({label:e,hint:t,children:n}){return m("label",{className:"flex flex-col gap-1 text-sm",children:[l("span",{className:"font-medium",children:e}),n,t&&l("span",{className:"text-xs text-muted-foreground",children:t})]})}function on({label:e,hint:t,checked:n,onChange:r}){return m("label",{className:"flex items-start gap-2 text-sm",children:[l("input",{type:"checkbox",className:"mt-1",checked:n,onChange:o=>r(o.target.checked)}),m("span",{children:[e,t&&l("span",{className:"block text-xs text-muted-foreground",children:t})]})]})}function Vm(e,t,n,r){let[o,s]=_([]),[i,a]=_(!1),[u,c]=_(null),[d,p]=_(!1);return{save:g=>{p(!0),c(null),e.call("welcome.save",{step:t,values:g}).then(x=>{let b=(x.handover??[]).some(v=>v.state==="failed");s(x.lines),a(b),p(!1),n(),b||r()},x=>{c(Ls(x)),p(!1)})},retry:()=>{p(!0),c(null),e.call("welcome.handover",null).then(g=>{s(g.lines),a(g.handover.some(x=>x.state==="failed")),p(!1)},g=>{c(Ls(g)),p(!1)})},lines:o,failed:i,problem:u,busy:d}}function Wu({onBack:e,onSkip:t,onContinue:n,busy:r,problem:o,label:s="Save and continue",settings:i=!1}){return m("div",{className:"mt-6 flex flex-col gap-2",children:[o&&l("p",{className:"text-sm text-destructive",children:o}),m("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e&&l(R,{variant:"ghost",className:"mr-auto",onClick:e,children:"Back"}),!i&&l(R,{variant:"ghost",onClick:t,children:"Skip for now"}),l(R,{disabled:r,onClick:n,children:r?"Saving\u2026":i?"Save":s})]})]})}function Um(e){return[e.name,...[e.admin,e.country].filter(t=>!!t&&t!==e.name)].join(", ")}function MO({city:e,place:t,zone:n,rpc:r,onCity:o,onPlace:s}){let[i,a]=_(null),[u,c]=_(!1),[d,p]=_(null),[f,h]=_(!1),g=Lt(()=>QE(),[]),x=t!==void 0&&(e.trim()===t.name||(i?.includes(t)??!1));return K(()=>{let b=e.trim();if(!b||x)return;let v=setTimeout(()=>{c(!0),p(null),g.take(r.call("welcome.places",{query:b})).then(w=>{w.current&&(a(w.value.places),s(w.value.places[0]),h(!1),c(!1))},w=>{p(Ls(w)),c(!1)})},600);return()=>clearTimeout(v)},[e,x,r,s,g]),m(Bm,{label:"Where you live",hint:"A city. The weather in your morning digest, anything local, and your time zone come from it.",children:[l(le,{value:e,onChange:b=>{o(b.target.value),g.cancel(),a(null),h(!1),c(!1),t&&b.target.value.trim()!==t.name&&s(void 0)}}),u?l("span",{className:"text-xs text-muted-foreground",children:"Looking it up\u2026"}):d?m("span",{className:"text-xs text-destructive",children:[d,". Your moonlet keeps its time zone, ",n,"; change it in Settings \u2192 General if it's wrong."]}):t?m("span",{className:"text-xs text-muted-foreground",children:[Um(t)," \xB7 ",t.timezone,i&&i.length>1&&!f&&m(he,{children:[" \xB7 ",l("button",{type:"button",className:"underline",onClick:()=>h(!0),children:"Not this one?"})]})]}):e.trim()&&i&&i.length===0?m("span",{className:"text-xs text-muted-foreground",children:["No place of that name; your moonlet keeps the city as you wrote it and its time zone, ",n,"."]}):m("span",{className:"text-xs text-muted-foreground",children:["Time zone now: ",n,"."]}),f&&i&&l("select",{className:"h-9 rounded-md border border-input bg-background px-2 text-sm",value:t?i.indexOf(t):0,onChange:b=>{s(i[Number(b.target.value)]),h(!1)},children:i.map((b,v)=>m("option",{value:v,children:[Um(b)," \xB7 ",b.timezone]},`${b.latitude},${b.longitude}`))})]})}function DO({state:e,rpc:t,refetch:n,onDone:r,onSkip:o,onBack:s}){let[i,a]=_(e.record.you),{save:u,problem:c,busy:d}=Vm(t,"you",n,r),p=(h,g)=>a(x=>({...x,[h]:g.trim()?g:void 0})),f=q(h=>a(g=>({...g,place:h})),[]);return m(he,{children:[m("div",{className:"flex flex-col gap-4",children:[l(Bm,{label:"Your name",hint:"What your moonlet calls you. Without one it says \u201Cyour owner\u201D.",children:l(le,{autoFocus:!0,value:i.name??"",onChange:h=>p("name",h.target.value)})}),l(MO,{city:i.city??"",place:i.place,zone:e.zone,rpc:t,onCity:h=>p("city",h),onPlace:f}),l(Bm,{label:"Your email address",hint:"Where your moonlet mails you when you want that, and how it knows mail from you is yours.",children:l(le,{value:i.email??"",onChange:h=>p("email",h.target.value)})})]}),l(Wu,{onBack:s,onSkip:o,busy:d,problem:c,onContinue:()=>u({you:{...i.name?{name:i.name}:{},...i.city?{city:i.city}:{},...i.city&&i.place?{place:i.place}:{},...i.email?{email:i.email}:{}}})})]})}function Zm({settings:e=!1,state:t,rpc:n,refetch:r,onDone:o,onSkip:s,onBack:i}){let[a,u]=_(t.record.reach),[c,d]=_(a.quiet_from!==void 0),[p,f]=_(""),{save:h,problem:g,busy:x}=Vm(n,"reach",r,o),b=a.other??[],v=b.filter(y=>!GE.includes(y)),w=(y,T)=>u({...a,other:T?[...b.filter(N=>N!==y),y]:b.filter(N=>N!==y)}),C=()=>{let y=p.trim().slice(0,60);if(!y||b.some(T=>T.toLowerCase()===y.toLowerCase()))return f("");b.length>=10||(u({...a,other:[...b,y]}),f(""))};return m(he,{children:[m("div",{className:"flex flex-col gap-4",children:[l(on,{label:"Put decisions and anything waiting on me in my Moonlet inbox",hint:"One item each, with a link, in your Moonlet inbox; your moonlet still says a line in its conversation.",checked:a.inbox,onChange:y=>u({...a,inbox:y})}),l(on,{label:"Mail me the digests too",hint:t.record.you.email?`To ${t.record.you.email}, from your moonlet's own mailbox.`:"Needs your email address (About you) and a station with mail.",checked:a.mail,onChange:y=>u({...a,mail:y})}),l(on,{label:"Quiet hours",hint:"Nothing that can wait is sent between them (in your time zone); it comes after.",checked:c,onChange:d}),c&&m("div",{className:"ml-6 flex flex-wrap items-center gap-2 text-sm",children:[l("span",{children:"From"}),l(le,{type:"time",className:"w-32",value:a.quiet_from??"22:00",onChange:y=>u({...a,quiet_from:y.target.value})}),l("span",{children:"to"}),l(le,{type:"time",className:"w-32",value:a.quiet_to??"07:00",onChange:y=>u({...a,quiet_to:y.target.value})})]}),m("section",{className:"flex flex-col gap-2 rounded-md border p-3",children:[l("span",{className:"text-sm font-medium",children:"Other ways"}),l("span",{className:"text-xs text-muted-foreground",children:"How else you'd want your moonlet to reach you. None of these is connected yet: your moonlet reaches you in Moonlet, and by mail when you ask for it. It notes what you'd want, says so when it comes up, and never claims to have sent something a way it can't."}),l("div",{className:"grid grid-cols-2 gap-1",children:GE.map(y=>l(on,{label:y,checked:b.includes(y),onChange:T=>w(y,T)},y))}),v.length>0&&l("ul",{className:"flex flex-wrap gap-2 text-xs",children:v.map(y=>m("li",{className:"flex items-center gap-1 rounded-full border px-2 py-0.5",children:[y,l("button",{type:"button",className:"text-muted-foreground","aria-label":`Remove ${y}`,onClick:()=>w(y,!1),children:"\xD7"})]},y))}),m("div",{className:"flex items-center gap-2",children:[l(le,{className:"max-w-xs",placeholder:"Something else: Matrix, a pager, \u2026",value:p,onChange:y=>f(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),C())}}),l(R,{size:"sm",variant:"secondary",disabled:!p.trim()||b.length>=10,onClick:C,children:"Add"})]})]})]}),l(Wu,{settings:e,onBack:i,onSkip:s,busy:x,problem:g,onContinue:()=>h({reach:{inbox:a.inbox,mail:a.mail,...c?{quiet_from:a.quiet_from??"22:00",quiet_to:a.quiet_to??"07:00"}:{},other:b}})})]})}function Wm({settings:e=!1,state:t,rpc:n,refetch:r,onDone:o,onSkip:s,onBack:i}){let[a,u]=_(t.record.touchpoints),{save:c,problem:d,busy:p}=Vm(n,"touchpoints",r,o),f=h=>u({...a,morning:{...a.morning,...h}});return m(he,{children:[m("div",{className:"flex flex-col gap-3",children:[m("p",{className:"text-xs text-muted-foreground",children:["Times are in ",t.zone,". Each becomes a routine your moonlet keeps, and your moonlet changes or drops it when you ask."]}),m("section",{className:"flex flex-col gap-2 rounded-md border p-3",children:[m("div",{className:"flex items-center gap-3",children:[l(on,{label:"Morning digest",checked:a.morning.on,onChange:h=>f({on:h})}),l("span",{className:"text-sm",children:"at"}),l(le,{type:"time",className:"w-32",value:a.morning.at,onChange:h=>f({at:h.target.value})})]}),a.morning.on&&m("div",{className:"ml-6 flex flex-col gap-1",children:[l(on,{label:"Today's weather",hint:t.record.you.place?`In ${Um(t.record.you.place)}.`:t.record.you.city?`In ${t.record.you.city}.`:"Give your city under About you, or your moonlet asks once.",checked:a.morning.weather,onChange:h=>f({weather:h})}),l(on,{label:"What's on my calendar",checked:a.morning.calendar,onChange:h=>f({calendar:h})}),l(on,{label:"New mail waiting on me",checked:a.morning.mail,onChange:h=>f({mail:h})}),l(on,{label:"Unfinished tasks due today, and what's waiting on me",checked:a.morning.loops,onChange:h=>f({loops:h})})]})]}),m("section",{className:"flex flex-wrap items-center gap-3 rounded-md border p-3",children:[l(on,{label:"End of day wrap-up",hint:"What got done, what's waiting on you, what's first tomorrow.",checked:a.evening.on,onChange:h=>u({...a,evening:{...a.evening,on:h}})}),l("span",{className:"text-sm",children:"at"}),l(le,{type:"time",className:"w-32",value:a.evening.at,onChange:h=>u({...a,evening:{...a.evening,at:h.target.value}})})]}),m("section",{className:"flex flex-wrap items-center gap-3 rounded-md border p-3",children:[l(on,{label:"Weekly review",hint:"The week's outcomes, what stalled, next week's first things.",checked:a.weekly.on,onChange:h=>u({...a,weekly:{...a.weekly,on:h}})}),l("span",{className:"text-sm",children:"on"}),l("select",{className:"h-9 rounded-md border border-input bg-background px-2 text-sm",value:a.weekly.day,onChange:h=>u({...a,weekly:{...a.weekly,day:h.target.value}}),children:LO.map(([h,g])=>l("option",{value:h,children:g},h))}),l("span",{className:"text-sm",children:"at"}),l(le,{type:"time",className:"w-32",value:a.weekly.at,onChange:h=>u({...a,weekly:{...a.weekly,at:h.target.value}})})]})]}),l(Wu,{settings:e,onBack:i,onSkip:s,busy:p,problem:d,onContinue:()=>c({touchpoints:a})})]})}function YE({which:e,label:t,hint:n,stored:r,rpc:o,refetch:s}){let[i,a]=_(""),[u,c]=_(null),[d,p]=_(null),[f,h]=_(!1),g=b=>{p(null),o.call("welcome.secret",{which:e,value:b}).then(v=>{c(v.line),h((v.handover??[]).some(w=>w.state==="failed")),a(""),s()},v=>p(Ls(v)))},x=()=>{p(null),o.call("welcome.handover",null).then(b=>{c(b.lines.join(" ")),h(b.handover.some(v=>v.state==="failed"))},b=>p(Ls(b)))};return m("div",{className:"flex flex-col gap-1 rounded-md border p-3 text-sm",children:[m("div",{className:"flex items-center gap-2",children:[l("span",{className:"font-medium",children:t}),l("span",{className:V("text-xs",r?"text-muted-foreground":"text-destructive"),children:r?"stored":"not set"})]}),l("span",{className:"text-xs text-muted-foreground",children:n}),m("div",{className:"flex items-center gap-2",children:[l(le,{type:"password",className:"max-w-md",placeholder:r?"Paste a new one to replace it":"Paste it here",value:i,onChange:b=>a(b.target.value)}),l(R,{size:"sm",variant:"secondary",disabled:!i.trim(),onClick:()=>g(i),children:"Store"}),r&&l(R,{size:"sm",variant:"ghost",onClick:()=>g(null),children:"Clear"})]}),d?l("span",{className:"text-xs text-destructive",children:d}):u&&l("span",{className:V("text-xs",f?"text-destructive":"text-muted-foreground"),children:u}),f&&l("div",{children:l(R,{size:"sm",variant:"secondary",onClick:x,children:"Try again"})})]})}function FO({state:e,rpc:t,refetch:n,onDone:r,onBack:o}){let[s,i]=_(null),[a,u]=_(!1),c=()=>{u(!0),i(null),t.call("welcome.finish",null).then(()=>{u(!1),n(),r()},d=>{i(Ls(d)),u(!1)})};return m(he,{children:[m("div",{className:"flex flex-col gap-3",children:[l(YE,{which:"claude",label:"Claude Code key",hint:"What your moonlet uses to sign in to Claude on its machines. Run claude setup-token on your computer and paste what it prints here.",stored:e.secrets.claude,rpc:t,refetch:n}),l(YE,{which:"onepassword",label:"1Password key (optional)",hint:"Only if your moonlet's own logins live in 1Password: a key for a 1Password service account that can read only a vault named Orbit. Your moonlet's machine uses it to fetch those logins; your moonlet never sees it.",stored:e.secrets.onepassword,rpc:t,refetch:n}),l("p",{className:"text-xs text-muted-foreground",children:"Continuing tells your moonlet, in its conversation, what you saved and what you skipped. With no conversation yet, it's told once its conversation starts."})]}),l(Wu,{onBack:o,onSkip:c,busy:a,problem:s,label:"Continue",onContinue:c}),s&&l("div",{className:"mt-2 flex justify-end",children:l(R,{variant:"ghost",onClick:r,children:"Continue anyway"})})]})}function Zu(e){return function({onContinue:n,onBack:r}){let{rpc:o,state:s,error:i,refetch:a}=Hm();return i?m("div",{className:"flex flex-col items-start gap-3 text-sm",children:[l("p",{role:"alert",className:"text-destructive",children:i}),l(R,{onClick:n,children:"Continue"})]}):s?l(e,{state:s,rpc:o,refetch:a,onDone:n,onSkip:n,onBack:r}):l("p",{className:"text-sm text-muted-foreground",children:"Loading\u2026"})}}var JE={you:Zu(DO),reach:Zu(Zm),touchpoints:Zu(Wm),"sign-ins":Zu(FO)};function eN(){let{rpc:e,state:t,error:n,refetch:r}=Hm(),[o,s]=_("");if(n)return l("p",{role:"alert",children:n});if(!t)return l("p",{className:"text-sm text-muted-foreground",children:"Loading\u2026"});let i={state:t,rpc:e,refetch:r,onDone:()=>s("Saved."),onSkip:()=>{},onBack:null,settings:!0};return m("div",{className:"space-y-10",children:[l(ct,{title:"How it reaches you",description:"Where it puts what's waiting on you, and when it stays quiet.",children:l("section",{"aria-label":"How it reaches you",children:l(Zm,{...i})})}),l(ct,{title:"Daily rhythm",description:"Check-ins it sends you. Times are in your time zone.",children:l("section",{"aria-label":"Daily rhythm",children:l(Wm,{...i})})}),o&&l("p",{role:"status",className:"text-xs text-muted-foreground",children:o})]})}function tN(){let e=J(),t=q(async()=>({kinds:await e.call("userland.kinds",null),artifacts:await e.call("userland.list",{})}),[e]),[n,r]=_(null),[o,s]=_(null),i=Y(!1),[a,u]=_(!1),[c,d]=_(null),[p,f]=_(""),h=q(()=>{t().then(x=>{r(x),s(null)},x=>s(x instanceof Error?x.message:String(x)))},[t]);K(()=>{h();let x=setInterval(()=>{i.current||h()},3e3);return()=>clearInterval(x)},[h]);let g=async x=>{if(!i.current){i.current=!0,u(!0),s(null);try{await x(),f("Saved. Machine delivery may still be waiting."),d(null),r(await t())}catch(b){s(b instanceof Error?b.message:String(b))}finally{i.current=!1,u(!1)}}};return m(ct,{title:"What it taught itself",description:"Tools and notes it saved to help it work.",children:[m("div",{className:"flex flex-col divide-y divide-border text-sm",children:[o&&l("p",{role:"alert",className:"pb-2.5 text-destructive",children:o}),!n&&l("p",{className:"text-muted-foreground",children:"Loading\u2026"}),n?.kinds.map(x=>m("div",{className:"flex flex-wrap items-center gap-3 py-2.5 first:pt-0 last:pb-0",children:[m("span",{className:"flex-1",children:[x.title,x.waiting?" \xB7 Waiting for delivery":""]}),m(R,{disabled:a,size:"sm",onClick:()=>{g(()=>e.call("userland.setKind",{kind:x.id,off:!x.off,why:"Changed in Settings"}))},children:[x.off?"Turn on":"Turn off"," ",x.title]})]},x.id)),n?.artifacts.length===0&&l("p",{className:"py-2.5 text-muted-foreground first:pt-0 last:pb-0",children:"No saved items."}),n?.artifacts.map(x=>{let b=`${x.kind}/${x.name}`,v=x.switches.some(w=>w.holder==="owner");return m("div",{className:"flex flex-wrap items-center gap-2 py-2.5 first:pt-0 last:pb-0",children:[m("span",{className:"flex-1",children:[b," \xB7 ",x.state,x.kindOff?" \xB7 Kind turned off":""]}),m(R,{disabled:a,size:"sm",onClick:()=>{g(()=>v?e.call("userland.enable",{artifact:b,holder:"owner"}):e.call("userland.disable",{artifact:b,why:"Turned off in Settings"}))},children:[v?"Turn on":"Turn off"," ",x.name]}),x.retiredAt===null?m(R,{disabled:a,size:"sm",variant:"secondary",onClick:()=>{g(()=>e.call("userland.retire",{artifact:b,why:"Retired in Settings"}))},children:["Retire ",x.name]}):m(R,{disabled:a,size:"sm",variant:"secondary",onClick:()=>d(b),children:["Delete ",x.name,"\u2026"]}),x.switches.map(w=>m("span",{className:"w-full text-xs text-muted-foreground",children:[w.holder==="breaker"?"Automatic pause":w.holder==="orbit"?"Assistant pause":"Your pause",": ",w.why]},w.holder)),c===b&&m("div",{className:"flex flex-wrap items-center gap-2",children:[l("span",{children:"Delete this item and its saved versions? This cannot be undone."}),l(R,{disabled:a,size:"sm",variant:"destructive",onClick:()=>{g(()=>e.call("userland.purge",{artifact:b}))},children:"Delete permanently"}),l(R,{size:"sm",variant:"ghost",onClick:()=>d(null),children:"Cancel"})]})]},b)})]}),p&&l("p",{role:"status",className:"mt-2 text-xs text-muted-foreground",children:p})]})}function nN(){let{rpc:e,state:t,error:n,refetch:r}=Ps(),[o,s]=_(null),[i,a]=_(null),[u,c]=_(!1);if(n)return l("p",{className:"text-sm text-destructive",children:n});if(!t)return l("p",{className:"text-sm text-muted-foreground",children:"Loading\u2026"});let d=t.history.prefs,p=f=>a(f instanceof Error?f.message:String(f));return m("div",{className:"space-y-10",children:[i&&l("p",{role:"status",className:"text-xs text-muted-foreground",children:i}),l(ct,{title:"Changes",description:"Every saved version of its profile, personality and models, newest first, by you or by it.",children:d.length===0?l("p",{className:"text-sm text-muted-foreground",children:"No changes yet."}):l("ul",{className:"divide-y divide-border",children:d.map(f=>m("li",{className:"flex flex-col gap-2 py-2.5 text-sm first:pt-0 last:pb-0",children:[m("div",{className:"flex items-center gap-3",children:[l("span",{className:"w-44 shrink-0 text-xs tabular-nums text-muted-foreground",children:new Date(f.at).toLocaleString()}),l("span",{className:"min-w-0 flex-1 truncate text-foreground",children:f.by}),l(R,{size:"sm",variant:"ghost",onClick:()=>o?.id===f.id?s(null):void e.call("config.historyText",{id:f.id}).then(h=>s({id:f.id,text:h.text}),p),children:o?.id===f.id?"Hide":"View"})]}),o?.id===f.id&&l("pre",{className:"max-h-80 overflow-auto rounded-md border border-border bg-muted/30 p-3 text-xs whitespace-pre-wrap",children:o.text})]},f.id))})}),l(tN,{}),l(ct,{title:"Copy or start over",children:m("div",{className:"space-y-5",children:[l(Ei,{label:"Export or import",description:"Its profile, personality and models as one prefs.toml file.",children:m("div",{className:"flex items-center gap-2",children:[l(R,{size:"sm",variant:"outline",onClick:()=>{e.call("config.exportPrefs",null).then(f=>DE("prefs.toml",f.text),p)},children:"Export"}),l(R,{size:"sm",variant:"outline",onClick:()=>FE(f=>{e.call("config.importPrefs",{text:f,base:t.prefsBase}).then(()=>{a("Imported and saved."),r()},p)}),children:"Import\u2026"})]})}),l(Ei,{label:"Reset personality",description:"Tone and standing instructions back to a new install's. The profile and models stay, and today's versions stay in Changes.",children:u?m("div",{className:"flex items-center gap-2",children:[l(R,{size:"sm",variant:"destructive",onClick:()=>{e.call("config.resetPrefs",{base:t.prefsBase}).then(()=>{c(!1),a("The tone and standing instructions are back to the defaults."),r()},f=>{c(!1),p(f)})},children:"Reset"}),l(R,{size:"sm",variant:"ghost",onClick:()=>c(!1),children:"Cancel"})]}):l(R,{size:"sm",variant:"outline",onClick:()=>c(!0),children:"Reset\u2026"})})]})})]})}function rN(){let e=Ie(),t=Y(0),n=Y(!1),r=Y(!1),o=J(),[s,i]=_(null),[a,u]=_(!1),[c,d]=_(null),p=q(()=>{r.current=!0;let h=++t.current,g=!0;return o.call("events.state",null).then(x=>{g&&h===t.current&&(i(x),d(null))},x=>{g&&h===t.current&&(i(null),d(x instanceof Error?x.message:String(x)))}).finally(()=>{r.current=!1}),()=>{g=!1}},[o]);K(()=>{let h=p(),g=setInterval(()=>{!n.current&&!r.current&&(h(),h=p())},3e3);return()=>{h(),clearInterval(g)}},[p]);let f=a||s?.pending===!0;return m("section",{className:"flex flex-col gap-2","aria-label":"Event service",children:[m("div",{className:"flex items-center justify-between gap-4",children:[l("label",{id:"event-service-label",htmlFor:"event-service-switch",className:"text-sm font-medium",children:"Event service"}),l("button",{id:"event-service-switch",type:"button",role:"switch","aria-labelledby":"event-service-label","aria-describedby":"event-service-status","aria-checked":s?.active??!1,disabled:!s||f,className:"relative h-6 w-11 shrink-0 rounded-full border bg-muted transition-colors aria-checked:bg-primary disabled:cursor-wait disabled:opacity-60",onClick:async()=>{if(!(!s||f||n.current)){n.current=!0,t.current++,u(!0),d(null);try{i(await o.call("events.switch",{active:!s.active}))}catch(h){d(h instanceof Error?h.message:String(h))}finally{n.current=!1,u(!1)}}},children:l("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-background shadow transition-transform ${s?.active?"left-0.5 translate-x-5":"left-0.5"}`})})]}),l("p",{className:"text-sm text-muted-foreground",children:"Runs mail, notices and routine work on the station. Changing it asks for your approval."}),l("p",{id:"event-service-status",role:"status",className:"text-sm",children:f?"Waiting for your approval":s?`${s.active?"Running":"Stopped"} on the station`:"Reading station\u2026"}),s?.pending&&s.thread&&l("button",{type:"button",className:"text-left text-sm underline",onClick:()=>e.toThread(s.thread),children:"Open approval question"}),c&&l("p",{role:"alert",className:"text-sm text-destructive",children:c}),!c&&s?.message&&!f&&l("p",{className:"text-sm text-muted-foreground",children:s.message})]})}function oN(){let e=J(),[t,n]=_(!1),[r,o]=_(null);return m("section",{className:"flex flex-col gap-1 text-sm","aria-label":"First run",children:[l("p",{className:"text-muted-foreground",children:"Go through setup again, with your saved answers filled in. Each answer still saves where it lives here, and your moonlet's name and identity stay as they are."}),l("div",{children:l("button",{type:"button",className:"underline disabled:opacity-60",disabled:t,onClick:()=>{n(!0),o(null),e.call("welcome.reopen",null).then(()=>n(!1),s=>{o(s instanceof Error?s.message:String(s)),n(!1)})},children:t?"Opening setup\u2026":"Set up again"})}),r&&l("p",{role:"alert",className:"text-destructive",children:r})]})}var sN=["s3","gcs","azureblob","b2","drive","dropbox","onedrive","box","webdav","sftp","ftp","swift"];var zO={type:"s3",path:"",options:"",item:"",recipient:""};function KO(e){return e.match(/.{1,4}/g)?.join(" ")??e}function XO(e){let t={};for(let[n,r]of e.split(`