moi-computer 0.13.1-next.1 → 0.13.1-next.2

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 (195) hide show
  1. package/client/api/app-config.ts +12 -1
  2. package/client/api/http.ts +11 -1
  3. package/client/app/app-router.tsx +3 -2
  4. package/client/app/routes/home-route.tsx +1 -1
  5. package/client/app/routes/workspace-registration.tsx +68 -0
  6. package/client/app/routes/workspace-route.tsx +33 -6
  7. package/client/app/shell/sidebar-layout.tsx +10 -5
  8. package/client/components/shared/workspace-icon.tsx +8 -17
  9. package/client/features/account/account-test-utils.tsx +15 -9
  10. package/client/features/account/api.ts +6 -6
  11. package/client/features/account/profile-actions.ts +5 -7
  12. package/client/features/app-settings/settings-page.tsx +2 -1
  13. package/client/features/applets/api.ts +6 -6
  14. package/client/features/applets/applet-cache.ts +6 -5
  15. package/client/features/applets/applet-log.ts +2 -1
  16. package/client/features/applets/applet-runtime.ts +2 -1
  17. package/client/features/applets/use-applet.ts +73 -18
  18. package/client/features/applets/widget-shell.tsx +4 -2
  19. package/client/features/chat/applet-chat-intents.ts +5 -13
  20. package/client/features/chat/chat-popup.tsx +8 -4
  21. package/client/features/chat/chat-send.ts +2 -2
  22. package/client/features/chat/composer/model-order.ts +4 -4
  23. package/client/features/chat/composer/model-picker.tsx +12 -10
  24. package/client/features/chat/composer/use-workspace-composer-state.tsx +1 -1
  25. package/client/features/chat/sessions/api.ts +11 -28
  26. package/client/features/chat/sessions/use-selected-session.ts +18 -100
  27. package/client/features/chat/use-chat.ts +8 -12
  28. package/client/features/collab/members/api.ts +4 -10
  29. package/client/features/collab/members/hooks.ts +32 -38
  30. package/client/features/collab/members/store.ts +96 -71
  31. package/client/features/collab/members/types.ts +5 -3
  32. package/client/features/collab/presence/client.ts +2 -3
  33. package/client/features/collab/presence/hooks.tsx +1 -1
  34. package/client/features/collab/proxy-user.ts +1 -3
  35. package/client/features/collab/sharing/workspace-members.tsx +0 -8
  36. package/client/features/dev/chat-states-page.tsx +3 -1
  37. package/client/features/dev/harness-debug-page.tsx +7 -7
  38. package/client/features/dev/workspace-setup-mocks.ts +1 -1
  39. package/client/features/dev/workspace-setup-preview.tsx +6 -4
  40. package/client/features/harness/api.ts +13 -10
  41. package/client/features/harness/harness-login-panel.tsx +9 -5
  42. package/client/features/harness/harness-presentation.ts +4 -4
  43. package/client/features/harness/harness-selector.tsx +13 -13
  44. package/client/features/harness/use-harness-login.ts +5 -5
  45. package/client/features/home/api.ts +38 -2
  46. package/client/features/home/home-page.tsx +43 -13
  47. package/client/features/home/shared-workspaces.tsx +70 -0
  48. package/client/features/home/workspace-invitations.tsx +101 -0
  49. package/client/features/identity/host-api.ts +3 -2
  50. package/client/features/identity/store.ts +1 -7
  51. package/client/features/onboarding/agent-setup-step.tsx +8 -8
  52. package/client/features/onboarding/onboarding-page.tsx +3 -2
  53. package/client/features/onboarding/workspace-setup-step.tsx +1 -1
  54. package/client/features/overview/api.ts +3 -5
  55. package/client/features/overview/default/registry.tsx +1 -1
  56. package/client/features/overview/default/views-widget.tsx +2 -2
  57. package/client/features/overview/hidden-panel.tsx +7 -5
  58. package/client/features/overview/overview.tsx +18 -16
  59. package/client/features/overview/workspace-name.tsx +2 -2
  60. package/client/features/scratchpad/scratchpad.tsx +9 -7
  61. package/client/features/scratchpad/use-scratchpad-snapshot.tsx +13 -5
  62. package/client/features/views/api.ts +34 -16
  63. package/client/features/views/use-view-actions.ts +10 -20
  64. package/client/features/views/view-manager.tsx +1 -1
  65. package/client/features/views/view-submission.ts +2 -21
  66. package/client/features/workspace/add/api.ts +5 -4
  67. package/client/features/workspace/add/create-workspace-dialog.tsx +12 -9
  68. package/client/features/workspace/add/import-workspace-dialog.tsx +7 -7
  69. package/client/features/workspace/add/use-workspace-import.ts +10 -10
  70. package/client/features/workspace/add/workspace-agent-options.ts +21 -20
  71. package/client/features/workspace/add/workspace-agent-selector.tsx +11 -11
  72. package/client/features/workspace/api.ts +60 -13
  73. package/client/features/workspace/harness-transition.ts +7 -13
  74. package/client/features/workspace/remote.ts +25 -0
  75. package/client/features/workspace/settings/api.ts +7 -12
  76. package/client/features/workspace/settings/connectors-settings.tsx +3 -3
  77. package/client/features/workspace/settings/general-settings.tsx +8 -8
  78. package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
  79. package/client/features/workspace/setup/workspace-recovery-states.tsx +43 -14
  80. package/client/features/workspace/setup/workspace-setup.tsx +6 -6
  81. package/client/features/workspace/tab-resolution.ts +2 -2
  82. package/client/features/workspace/use-workspace-navigation.ts +7 -4
  83. package/client/features/workspace/workspace-content.tsx +22 -20
  84. package/client/features/workspace/workspace-frame.tsx +13 -26
  85. package/client/features/workspace/workspace-layout-context.tsx +45 -12
  86. package/client/features/workspace/workspace-menu.tsx +2 -2
  87. package/client/features/workspace/workspace-pane.tsx +22 -0
  88. package/client/features/workspace/workspace-pending-screen.tsx +1 -1
  89. package/client/features/workspace/workspace-preferences.ts +34 -0
  90. package/client/features/workspace/workspace-presentation.tsx +12 -16
  91. package/client/features/workspace/workspace-screen.tsx +2 -2
  92. package/client/features/workspace/workspace-state.ts +2 -1
  93. package/client/features/workspace/workspace-tabs.tsx +1 -1
  94. package/client/features/workspace/workspace-test-utils.ts +23 -0
  95. package/client/runtime/use-workspace-events.ts +14 -0
  96. package/client/runtime/workspace-events.ts +9 -9
  97. package/client/store/ui.ts +29 -9
  98. package/dist/chunk-44khk4sp.js +2 -0
  99. package/dist/chunk-ba6mz56s.js +72 -0
  100. package/dist/chunk-ec5ennpv.js +1 -0
  101. package/dist/chunk-ectsnw81.js +2 -0
  102. package/dist/chunk-en7w5ypg.js +1 -0
  103. package/dist/chunk-f695wcx5.js +5 -0
  104. package/dist/chunk-kffcah9w.css +1 -0
  105. package/dist/{chunk-th91xfnp.js → chunk-n0fawy9x.js} +1 -1
  106. package/dist/chunk-pdt9hxfw.js +2 -0
  107. package/dist/chunk-rmd0ctfx.js +546 -0
  108. package/dist/chunk-zv22wv0g.js +1 -0
  109. package/dist/index.html +1 -1
  110. package/lib/harness-instructions.ts +4 -4
  111. package/lib/harness-types.ts +13 -0
  112. package/lib/types.ts +34 -49
  113. package/lib/workspace-config.ts +48 -0
  114. package/lib/workspace-layout.ts +2 -4
  115. package/package.json +4 -2
  116. package/server/README.md +29 -27
  117. package/server/api/harnesses.ts +5 -5
  118. package/server/api/index.ts +170 -68
  119. package/server/applets/index.ts +15 -9
  120. package/server/applets/views.ts +2 -17
  121. package/server/applets/widgets.ts +3 -2
  122. package/server/cli/commands/config.ts +8 -20
  123. package/server/cli/commands/hermes.ts +2 -2
  124. package/server/cli/commands/init.ts +96 -53
  125. package/server/cli/commands/openclaw.ts +2 -2
  126. package/server/cli/commands/refresh.ts +10 -1
  127. package/server/cli/commands/remote.ts +228 -0
  128. package/server/cli/commands/skill.ts +4 -4
  129. package/server/cli/commands/tabs.ts +5 -12
  130. package/server/cli/control.ts +35 -4
  131. package/server/cli/index.ts +10 -6
  132. package/server/cli/remote-command.ts +77 -0
  133. package/server/cli/remote-control.ts +70 -0
  134. package/server/cli/remote-operations.ts +244 -0
  135. package/server/collab/config.ts +3 -3
  136. package/server/collab/skill/index.ts +3 -3
  137. package/server/control.ts +38 -11
  138. package/server/harness/acp/session.ts +4 -4
  139. package/server/harness/auth.ts +26 -31
  140. package/server/harness/claude-code/index.ts +1 -1
  141. package/server/harness/codex/discovery.ts +1 -1
  142. package/server/harness/codex/session.ts +1 -1
  143. package/server/harness/detect.ts +14 -19
  144. package/server/harness/executable.ts +10 -10
  145. package/server/harness/hermes/NOTES.md +2 -2
  146. package/server/harness/hermes/index.ts +1 -1
  147. package/server/harness/install.ts +11 -11
  148. package/server/harness/openclaw/index.ts +1 -1
  149. package/server/harness/registry.ts +7 -6
  150. package/server/harness/types.ts +4 -4
  151. package/server/onboarding/jobs.ts +1 -1
  152. package/server/operations/commands.ts +46 -0
  153. package/server/operations/files.ts +148 -0
  154. package/server/operations/server.ts +206 -0
  155. package/server/remote/agent.ts +103 -0
  156. package/server/remote/client.ts +665 -0
  157. package/server/remote/workspace.ts +34 -0
  158. package/server/scratchpad/document.ts +32 -12
  159. package/server/scratchpad/executor.ts +16 -7
  160. package/server/sessions/config.ts +8 -5
  161. package/server/sessions/pending-views.ts +16 -0
  162. package/server/sessions/view-sessions.ts +10 -12
  163. package/server/skills/locations.ts +4 -4
  164. package/server/skills/update.ts +11 -11
  165. package/server/skills/version.ts +7 -7
  166. package/server/skills/workspace.ts +13 -11
  167. package/server/web.ts +11 -8
  168. package/server/workspace-state/file.ts +2 -0
  169. package/server/workspace-state/index.ts +0 -4
  170. package/server/workspaces/api.ts +28 -0
  171. package/server/workspaces/change-harness.ts +15 -26
  172. package/server/workspaces/import.ts +4 -4
  173. package/server/workspaces/init.ts +15 -13
  174. package/server/workspaces/layout.ts +60 -66
  175. package/server/workspaces/registry.ts +43 -18
  176. package/server/workspaces/shared.ts +74 -0
  177. package/server/workspaces/tabs.ts +6 -12
  178. package/skill/SKILL.md +24 -4
  179. package/client/api/app-ui-keys.ts +0 -6
  180. package/client/features/chat/sessions/browser-tab-state.ts +0 -43
  181. package/client/features/collab/members/keys.ts +0 -6
  182. package/client/features/workspace/browser-tab-state.ts +0 -51
  183. package/client/features/workspace/layout-save.ts +0 -13
  184. package/dist/chunk-3smkkcfw.js +0 -546
  185. package/dist/chunk-47h9c2qy.js +0 -2
  186. package/dist/chunk-8qed2gqp.js +0 -75
  187. package/dist/chunk-8zy3vesm.js +0 -1
  188. package/dist/chunk-a47zy276.js +0 -2
  189. package/dist/chunk-g4c1nte9.css +0 -1
  190. package/dist/chunk-kcactdr4.js +0 -2
  191. package/dist/chunk-m8bhx6tw.js +0 -1
  192. package/dist/chunk-pf19zcrn.js +0 -2
  193. package/dist/chunk-ygzxah0e.js +0 -1
  194. package/lib/workspace-types.ts +0 -13
  195. package/server/workspace-state/legacy-migration.ts +0 -79
@@ -1,3 +1,5 @@
1
+ import { WorkspacePendingScreen } from './workspace-pending-screen'
2
+ import { WorkspaceOpenError, WorkspaceLoadingState } from './setup/workspace-recovery-states'
1
3
  import { type ReactNode, createContext, useCallback, useContext, useMemo, useRef } from 'react'
2
4
 
3
5
  import { useQueryClient } from '@tanstack/react-query'
@@ -9,13 +11,13 @@ import {
9
11
  } from '@/client/features/workspace/api'
10
12
  import { workspaceKeys } from '@/client/api/workspace-keys'
11
13
  import { useLatestRef } from '@/client/lib/use-latest-ref'
12
- import type { WorkspaceLayout, WorkspaceLayoutSave, WorkspaceType } from '@/lib/types'
14
+ import type { WorkspaceLayout, HarnessType } from '@/lib/types'
13
15
  import { createDefaultWorkspaceLayout } from '@/lib/workspace-layout'
14
16
 
15
- import { accumulateLayoutSave } from './layout-save'
17
+ import { useWorkspaceState } from './workspace-state'
16
18
 
17
19
  export type WorkspaceLayoutContextValue = {
18
- // The persisted layout (widget grid, layout mode, theme). Falls back to an
20
+ // Shared widget layout and theme. Falls back to an
19
21
  // empty default while the query is still loading.
20
22
  layout: WorkspaceLayout
21
23
  // Merge a partial update into the layout: updates the query cache immediately
@@ -27,10 +29,12 @@ export type WorkspaceLayoutContextValue = {
27
29
  // The agent backend (claude-code / openclaw …). Exposed here so descendants
28
30
  // can reuse the shared layout query instead of spawning another observer
29
31
  // that could refetch on mount and clobber an optimistic layout update.
30
- provider: WorkspaceType | null
32
+ harness: HarnessType | null
31
33
  // The workspace's registry id (the route param), so descendants can key
32
34
  // their own queries (e.g. the model picker) without prop-drilling.
33
35
  workspaceId: string
36
+ apiBase: string
37
+ isRemote: boolean
34
38
  isLoading: boolean
35
39
  }
36
40
 
@@ -55,7 +59,15 @@ export function useWorkspaceThemeSetting(): WorkspaceLayout['theme'] {
55
59
  // Strip the server-only metadata so what we PUT back (and expose as `layout`)
56
60
  // is just the persisted `WorkspaceLayout`.
57
61
  function stripMeta(data: WorkspaceLayoutResponse): WorkspaceLayout {
58
- const { cwd: _cwd, name: _name, provider: _provider, agentId: _agentId, ...layout } = data
62
+ const {
63
+ cwd: _cwd,
64
+ name: _name,
65
+ harness: _harness,
66
+ agentId: _agentId,
67
+ apiBase: _apiBase,
68
+ isRemote: _isRemote,
69
+ ...layout
70
+ } = data
59
71
  return layout
60
72
  }
61
73
 
@@ -70,12 +82,13 @@ export function WorkspaceLayoutProvider({ id, children }: WorkspaceLayoutProvide
70
82
  const qc = useQueryClient()
71
83
  const query = useWorkspaceLayout(id)
72
84
  const save = useSaveLayout(id)
85
+ const personal = useWorkspaceState(id)
73
86
 
74
87
  // `setLayout` must be referentially stable (it feeds effect deps in the grid
75
88
  // reconcile), so reach the latest mutate via a ref instead of closing over it.
76
89
  const saveRef = useLatestRef(save.mutate)
77
90
  const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
78
- const pendingSave = useRef<WorkspaceLayoutSave | null>(null)
91
+ const pendingSave = useRef<WorkspaceLayout | null>(null)
79
92
 
80
93
  const setLayout = useCallback(
81
94
  (update: Partial<WorkspaceLayout>) => {
@@ -87,10 +100,7 @@ export function WorkspaceLayoutProvider({ id, children }: WorkspaceLayoutProvide
87
100
  // Optimistic: the grid/theme reflects the change before the PUT lands.
88
101
  const next = { ...prev, ...update }
89
102
  qc.setQueryData<WorkspaceLayoutResponse>(key, next)
90
- pendingSave.current = {
91
- ...accumulateLayoutSave(stripMeta(next), update, pendingSave.current),
92
- harness: next.provider ?? 'claude-code'
93
- }
103
+ pendingSave.current = stripMeta(next)
94
104
 
95
105
  if (timer.current) clearTimeout(timer.current)
96
106
  // Persist the value captured at call time, NOT the cache at fire time: a
@@ -119,12 +129,35 @@ export function WorkspaceLayoutProvider({ id, children }: WorkspaceLayoutProvide
119
129
  setLayout,
120
130
  name: query.data?.name ?? null,
121
131
  cwd: query.data?.cwd ?? null,
122
- provider: query.data ? (query.data.provider ?? 'claude-code') : null,
132
+ harness: query.data ? (query.data.harness ?? 'claude-code') : null,
123
133
  workspaceId: id,
134
+ apiBase: query.data?.apiBase ?? '',
135
+ isRemote: query.data?.isRemote ?? false,
124
136
  isLoading: query.isLoading
125
137
  }),
126
138
  [query.data, query.isLoading, setLayout, id]
127
139
  )
128
140
 
129
- return <WorkspaceLayoutContext value={value}>{children}</WorkspaceLayoutContext>
141
+ return (
142
+ <WorkspaceLayoutContext value={value}>
143
+ {query.isPending || personal.isPending ? (
144
+ <WorkspacePendingScreen>
145
+ <WorkspaceLoadingState />
146
+ </WorkspacePendingScreen>
147
+ ) : (query.isError && !query.data) || (personal.isError && !personal.data) ? (
148
+ <WorkspacePendingScreen setupRequired>
149
+ <WorkspaceOpenError
150
+ error={query.error ?? personal.error!}
151
+ retrying={query.isFetching || personal.isFetching}
152
+ onRetry={() => {
153
+ void query.refetch()
154
+ void personal.refetch()
155
+ }}
156
+ />
157
+ </WorkspacePendingScreen>
158
+ ) : (
159
+ children
160
+ )}
161
+ </WorkspaceLayoutContext>
162
+ )
130
163
  }
@@ -21,7 +21,7 @@ type WorkspaceMenuProps = {
21
21
  }
22
22
 
23
23
  export function WorkspaceMenu({ onOpenTheme }: WorkspaceMenuProps) {
24
- const { layout, name, provider } = useWorkspaceLayoutCtx()
24
+ const { layout, name, harness } = useWorkspaceLayoutCtx()
25
25
  const [iconHovered, setIconHovered] = useState(false)
26
26
 
27
27
  return (
@@ -38,7 +38,7 @@ export function WorkspaceMenu({ onOpenTheme }: WorkspaceMenuProps) {
38
38
  ) : (
39
39
  <WorkspaceIcon
40
40
  icon={layout.icon}
41
- workspaceType={provider}
41
+ harness={harness}
42
42
  workspaceTheme={layout.theme}
43
43
  className="size-5 rounded-sm"
44
44
  />
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from 'react'
2
+ import { cn } from '@/client/lib/cn'
3
+ import type { LayoutMode } from '@/lib/types'
4
+
5
+ type WorkspacePaneProps = {
6
+ mode: LayoutMode
7
+ children: ReactNode
8
+ }
9
+
10
+ export function WorkspacePane({ mode, children }: WorkspacePaneProps) {
11
+ return (
12
+ <div
13
+ data-slot="workspace-pane"
14
+ className={cn(
15
+ '@container/workspace relative flex h-full min-h-0 min-w-0 flex-1 flex-col-reverse overflow-hidden bg-background shadow-md transition-[border-radius,background-color] duration-100 ease-out motion-reduce:transition-none',
16
+ mode === 'split' && 'rounded-xl'
17
+ )}
18
+ >
19
+ {children}
20
+ </div>
21
+ )
22
+ }
@@ -1,7 +1,7 @@
1
1
  import type { ReactNode } from 'react'
2
2
 
3
3
  import { ScreenShell } from '@/client/components/shared/screen-shell'
4
- import { WorkspacePane } from './workspace-frame'
4
+ import { WorkspacePane } from './workspace-pane'
5
5
 
6
6
  type WorkspacePendingScreenProps = {
7
7
  setupRequired?: boolean
@@ -0,0 +1,34 @@
1
+ import { useCallback, useMemo } from 'react'
2
+ import { useUiStore, defaultWorkspaceUi, type WorkspaceUi } from '@/client/store/ui'
3
+ import { normalizeWorkspaceTabs } from '@/lib/workspace-layout'
4
+ import type { WorkspaceTabsState } from '@/lib/types'
5
+ import { useWorkspaceLayoutCtx } from './workspace-layout-context'
6
+
7
+ // Per-browser preferences for one workspace, local or remote. See client/store/ui.ts.
8
+ export function useWorkspaceUi() {
9
+ const { workspaceId } = useWorkspaceLayoutCtx()
10
+ const saved = useUiStore(state => state.workspaces[workspaceId])
11
+ // Entries saved before a field existed fall back to its default.
12
+ const ui = useMemo(() => ({ ...defaultWorkspaceUi, ...saved }), [saved])
13
+ const setWorkspaceUi = useUiStore(state => state.setWorkspaceUi)
14
+ const save = useCallback(
15
+ (patch: Partial<WorkspaceUi>) => setWorkspaceUi(workspaceId, patch),
16
+ [workspaceId, setWorkspaceUi]
17
+ )
18
+ return [ui, save] as const
19
+ }
20
+
21
+ export function useWorkspaceTabs() {
22
+ const { workspaceId } = useWorkspaceLayoutCtx()
23
+ const tabs = useUiStore(state => state.workspaces[workspaceId]?.tabs ?? defaultWorkspaceUi.tabs)
24
+ const setWorkspaceUi = useUiStore(state => state.setWorkspaceUi)
25
+ const setTabs = useCallback(
26
+ (tabs: WorkspaceTabsState) => {
27
+ const next = normalizeWorkspaceTabs(tabs)
28
+ setWorkspaceUi(workspaceId, { tabs: next })
29
+ return next
30
+ },
31
+ [workspaceId, setWorkspaceUi]
32
+ )
33
+ return [tabs, setTabs] as const
34
+ }
@@ -1,25 +1,21 @@
1
- import { workspaceProviderIcon } from '@/client/components/shared/workspace-icon'
2
- import type { DiscoveredWorkspace, WorkspaceEntry, WorkspaceType } from '@/lib/types'
1
+ import { harnessIcon } from '@/client/components/shared/workspace-icon'
2
+ import type { DiscoveredWorkspace, WorkspaceEntry, HarnessType } from '@/lib/types'
3
3
 
4
- import { harnessLabel as workspaceTypeLabel } from '@/client/features/harness/harness-presentation'
5
- export {
6
- harnessLabel as workspaceTypeLabel,
7
- harnessDescription as workspaceTypeDescription
8
- } from '@/client/features/harness/harness-presentation'
4
+ import { harnessLabel } from '@/client/features/harness/harness-presentation'
9
5
 
10
6
  type WorkspaceAgentIconsProps = {
11
- types: WorkspaceType[]
7
+ harnesses: HarnessType[]
12
8
  }
13
9
 
14
- export function WorkspaceAgentIcons({ types }: WorkspaceAgentIconsProps) {
15
- const label = types.map(type => workspaceTypeLabel[type]).join(', ')
10
+ export function WorkspaceAgentIcons({ harnesses }: WorkspaceAgentIconsProps) {
11
+ const label = harnesses.map(harness => harnessLabel[harness]).join(', ')
16
12
 
17
13
  return (
18
14
  <span role="img" aria-label={label} className="inline-flex shrink-0 items-center -space-x-0.5">
19
- {types.map(type => (
15
+ {harnesses.map(harness => (
20
16
  <img
21
- key={type}
22
- src={workspaceProviderIcon[type]}
17
+ key={harness}
18
+ src={harnessIcon[harness]}
23
19
  alt=""
24
20
  className="size-4 shrink-0 rounded-full bg-muted ring-2 ring-muted"
25
21
  />
@@ -31,9 +27,9 @@ export function WorkspaceAgentIcons({ types }: WorkspaceAgentIconsProps) {
31
27
  type WorkspaceDisplaySource = WorkspaceEntry | DiscoveredWorkspace
32
28
 
33
29
  export function workspaceDisplayName(workspace: WorkspaceDisplaySource): string {
34
- if ('types' in workspace) return workspace.path.split('/').pop() || workspace.path
30
+ if ('harnesses' in workspace) return workspace.path.split('/').pop() || workspace.path
35
31
  if (workspace.name) return workspace.name
36
- if (workspace.type === 'openclaw') return workspace.agentId ?? 'OpenClaw agent'
37
- if (workspace.type === 'hermes') return workspace.agentId ?? 'Hermes agent'
32
+ if (workspace.harness === 'openclaw') return workspace.agentId ?? 'OpenClaw agent'
33
+ if (workspace.harness === 'hermes') return workspace.agentId ?? 'Hermes agent'
38
34
  return workspace.path.split('/').pop() || workspace.path
39
35
  }
@@ -12,11 +12,11 @@ type WorkspaceScreenProps = {
12
12
  }
13
13
 
14
14
  export function WorkspaceScreen({ contentPending, widgets, views }: WorkspaceScreenProps) {
15
- const { layout, workspaceId, name, provider } = useWorkspaceLayoutCtx()
15
+ const { layout, workspaceId, name, harness } = useWorkspaceLayoutCtx()
16
16
  const { content, ready, setupRequired } = useWorkspaceSetup(workspaceId, contentPending, {
17
17
  name: name ?? 'Workspace',
18
18
  icon: layout.icon,
19
- workspaceType: provider,
19
+ harness: harness,
20
20
  workspaceTheme: layout.theme
21
21
  })
22
22
 
@@ -6,7 +6,7 @@ import { toast } from '@/client/components/ui/toast'
6
6
  import { useWorkspaceEvent } from '@/client/runtime/use-workspace-events'
7
7
  import type { WorkspaceState } from '@/lib/types'
8
8
 
9
- // Per-user chat state for one workspace: pin, the chat each tab shows, chat
9
+ // Personal state for one workspace: tabs, pin, selected chats, chat
10
10
  // settings and fork history, and views being built. One cache, kept current by
11
11
  // write replies and `state:changed` events instead of refetches.
12
12
 
@@ -46,6 +46,7 @@ export function workspaceStateOptions(queryClient: QueryClient, workspaceId: str
46
46
  // Events keep the cache current, so new observers never refetch. A focus
47
47
  // refetch heals anything missed while the socket was down.
48
48
  staleTime: 0,
49
+ retry: false,
49
50
  gcTime: 5 * 60_000,
50
51
  refetchOnMount: false,
51
52
  refetchOnWindowFocus: true
@@ -226,7 +226,7 @@ export function WorkspaceTabs({
226
226
  />
227
227
  </div>
228
228
  <div className="shrink-0">
229
- <CreateTabMenu items={createItems} />
229
+ {createItems.length > 0 && <CreateTabMenu items={createItems} />}
230
230
  </div>
231
231
  </div>
232
232
  )
@@ -0,0 +1,23 @@
1
+ import { queryClient as appQueryClient } from '@/client/api/query-client'
2
+ import { workspaceKeys } from '@/client/api/workspace-keys'
3
+ import type { QueryClient } from '@tanstack/react-query'
4
+ import { createDefaultWorkspaceLayout } from '@/lib/workspace-layout'
5
+ import { workspaceApiBase, type RemoteWorkspaceTarget } from '@/lib/workspace-config'
6
+ import type { WorkspaceLayoutResponse } from '@/lib/types'
7
+
8
+ // Seed the info response for tests that mount a consumer without the workspace loader.
9
+ export function seedWorkspaceInfo(
10
+ id: string,
11
+ remote?: RemoteWorkspaceTarget,
12
+ client: QueryClient = appQueryClient
13
+ ): WorkspaceLayoutResponse {
14
+ const info: WorkspaceLayoutResponse = {
15
+ ...createDefaultWorkspaceLayout(),
16
+ name: id,
17
+ cwd: `/workspaces/${id}`,
18
+ apiBase: workspaceApiBase(remote?.workspace_id ?? id, remote?.user_id),
19
+ isRemote: !!remote
20
+ }
21
+ client.setQueryData(workspaceKeys.layout(id), info)
22
+ return info
23
+ }
@@ -16,6 +16,20 @@ export function useWorkspaceEvent(handler: WorkspaceEventHandler) {
16
16
  useEffect(() => events?.subscribe(event => handlerRef.current(event)), [events, handlerRef])
17
17
  }
18
18
 
19
+ // Listen to events for one workspace. Events that name no workspace (such as
20
+ // `moi refresh`) reach every open workspace.
21
+ export function useWorkspaceScopedEvent(workspaceId: string, handler: WorkspaceEventHandler) {
22
+ useWorkspaceEvent(event => {
23
+ if (
24
+ 'workspaceId' in event &&
25
+ event.workspaceId !== undefined &&
26
+ event.workspaceId !== workspaceId
27
+ )
28
+ return
29
+ handler(event)
30
+ })
31
+ }
32
+
19
33
  // This hook owns presence for the displayed workspace, including reconnects.
20
34
  // Requests received after a workspace switch never act on the new workspace.
21
35
  export function useNavigationClient(
@@ -5,7 +5,7 @@ import type {
5
5
  HarnessAvailability,
6
6
  HarnessStatus,
7
7
  WidgetInfo,
8
- WorkspaceType,
8
+ HarnessType,
9
9
  WorkspaceState
10
10
  } from '@/lib/types'
11
11
 
@@ -13,16 +13,16 @@ export type WorkspaceEvent =
13
13
  | { type: 'connection:opened' }
14
14
  | {
15
15
  type: 'harness-status:changed'
16
- harness: WorkspaceType
16
+ harness: HarnessType
17
17
  status: HarnessStatus
18
18
  }
19
- | { type: 'workspace-harness:switched'; workspaceId: string; harness: WorkspaceType }
20
- | { type: 'widget:updated'; name: string }
21
- | { type: 'widget-layout:updated'; widgets: WidgetInfo[] }
19
+ | { type: 'workspace-harness:switched'; workspaceId: string; harness: HarnessType }
20
+ | { type: 'widget:updated'; workspaceId?: string; name: string }
21
+ | { type: 'widget-layout:updated'; workspaceId: string; widgets: WidgetInfo[] }
22
22
  // `moi refresh` — cache-bust and re-fetch applets without a rebuild. `only`
23
23
  // narrows to one kind; absent means both widgets and views.
24
- | { type: 'applets:refresh'; only?: 'widgets' | 'views' }
25
- | { type: 'view:updated'; name: string }
24
+ | { type: 'applets:refresh'; workspaceId?: string; only?: 'widgets' | 'views' }
25
+ | { type: 'view:updated'; workspaceId?: string; name: string }
26
26
  | { type: 'view-layout:updated'; workspaceId: string; views: CompiledView[] }
27
27
  | { type: 'view:deleted'; workspaceId: string; name: string }
28
28
  // A workspace's chat state changed (pin, selection, chat settings, views
@@ -31,8 +31,8 @@ export type WorkspaceEvent =
31
31
  // `origin` on an event is the browser tab whose write caused it (absent for
32
32
  // CLI and agent changes), so that tab can skip its own echo. See
33
33
  // client/lib/browser-tab-id.ts.
34
- | { type: 'theme:updated'; origin?: string }
35
- | { type: 'workspace:updated'; origin?: string }
34
+ | { type: 'theme:updated'; workspaceId: string; origin?: string }
35
+ | { type: 'workspace:updated'; workspaceId: string; origin?: string }
36
36
  // The registry list changed (reorder, create) without touching any open
37
37
  // workspace's layout — clients refetch just the sidebar list.
38
38
  | { type: 'workspaces-list:updated'; origin?: string }
@@ -1,35 +1,57 @@
1
+ import type { LayoutMode, WorkspaceTabsState } from '@/lib/types'
2
+ import { createDefaultWorkspaceTabs } from '@/lib/workspace-layout'
1
3
  import { create } from 'zustand'
2
4
  import { createJSONStorage, persist } from 'zustand/middleware'
3
5
  import type { StateStorage } from 'zustand/middleware'
4
6
 
5
7
  // Per-browser UI preferences and onboarding markers, persisted to localStorage
6
8
  // so they survive reloads. Server-backed per-user app state belongs in DATA_DIR.
9
+ export type WorkspaceUi = {
10
+ // Open tabs and the tab a bare `/workspace/:id` lands on. Each window follows
11
+ // its own URL; the last window to change tabs decides what is saved.
12
+ tabs: WorkspaceTabsState
13
+ layoutMode: LayoutMode
14
+ dockedChatWidth: number
15
+ popupChatWidth: number
16
+ }
17
+
18
+ export const defaultWorkspaceUi: WorkspaceUi = {
19
+ tabs: createDefaultWorkspaceTabs(),
20
+ layoutMode: 'split',
21
+ dockedChatWidth: 360,
22
+ popupChatWidth: 440
23
+ }
24
+
7
25
  type UiStore = {
26
+ workspaces: Record<string, WorkspaceUi>
27
+ setWorkspaceUi: (workspaceId: string, patch: Partial<WorkspaceUi>) => void
8
28
  discoveredWorkspacesOpen: boolean
9
29
  hasSentMessageFromMoi: boolean
10
30
  workspaceIdsPendingAnalysis: string[]
11
31
  composerDrafts: Record<string, string>
12
- dockedChatWidth: number
13
- popupChatWidth: number
14
32
  setDiscoveredWorkspacesOpen: (open: boolean) => void
15
33
  markWorkspacePendingAnalysis: (workspaceId: string) => void
16
34
  markMessageSentFromMoi: (workspaceId: string) => void
17
35
  setComposerDraft: (key: string, value: string | null) => void
18
36
  moveComposerDraft: (from: string, to: string) => void
19
- setDockedChatWidth: (width: number) => void
20
- setPopupChatWidth: (width: number) => void
21
37
  }
22
38
 
23
39
  export const createUiStore = (storage?: StateStorage) =>
24
40
  create<UiStore>()(
25
41
  persist(
26
42
  set => ({
43
+ workspaces: {},
44
+ setWorkspaceUi: (workspaceId, patch) =>
45
+ set(state => ({
46
+ workspaces: {
47
+ ...state.workspaces,
48
+ [workspaceId]: { ...defaultWorkspaceUi, ...state.workspaces[workspaceId], ...patch }
49
+ }
50
+ })),
27
51
  discoveredWorkspacesOpen: true,
28
52
  hasSentMessageFromMoi: false,
29
53
  workspaceIdsPendingAnalysis: [],
30
54
  composerDrafts: {},
31
- dockedChatWidth: 360,
32
- popupChatWidth: 440,
33
55
  setDiscoveredWorkspacesOpen: open => set({ discoveredWorkspacesOpen: open }),
34
56
  markWorkspacePendingAnalysis: workspaceId =>
35
57
  set(state => {
@@ -65,9 +87,7 @@ export const createUiStore = (storage?: StateStorage) =>
65
87
  composerDrafts[to] ??= composerDrafts[from]
66
88
  delete composerDrafts[from]
67
89
  return { composerDrafts }
68
- }),
69
- setDockedChatWidth: width => set({ dockedChatWidth: width }),
70
- setPopupChatWidth: width => set({ popupChatWidth: width })
90
+ })
71
91
  }),
72
92
  {
73
93
  name: 'moi:ui',
@@ -0,0 +1,2 @@
1
+ var lt=Object.create;var{getPrototypeOf:dt,defineProperty:rr,getOwnPropertyNames:pt}=Object;var fr=Object.prototype.hasOwnProperty;function ht(r){return this[r]}var gt,ut,e=(r,t,a)=>{var o=r!=null&&typeof r==="object";if(o){var i=t?gt??=new WeakMap:ut??=new WeakMap,c=i.get(r);if(c)return c}a=r!=null?lt(dt(r)):{};let d=t||!r||!r.__esModule||!fr.call(r,"default")?rr(a,"default",{value:r,enumerable:!0}):a;if(r&&typeof r==="object"||typeof r==="function"){for(let n of pt(r))if(!fr.call(d,n))rr(d,n,{get:ht.bind(r,n),enumerable:!0})}if(o)i.set(r,d);return d};var I=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var mt=(r)=>r;function ft(r,t){this[r]=mt.bind(null,t)}var Ft=(r,t)=>{for(var a in t)rr(r,a,{get:t[a],enumerable:!0,configurable:!0,set:ft.bind(t,a)})};var tn=((r)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,a)=>(typeof require<"u"?require:t)[a]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var xr,tr,F,Fe=(r,t)=>{for(var[a,o,i]of xr||[])for(var c=[r],d=globalThis,n=d.document,s,p,g,h,u;p=c.pop();)if(!tr[p]&&(g=o[p])){tr[p]=1;for(h=1;h<g.length;h++)c.push(i[g[h]]);if(!t&&p!==r&&(s=n&&n.head)){if(F===void 0)F=(h=n.querySelector("meta[property=csp-nonce]"))&&(h.nonce||h.getAttribute("nonce"))||"";if(u=n.createElement("link"),u.rel="modulepreload",u.crossOrigin="",F)u.nonce=F;u.href=new d.URL(g[0],a),s.appendChild(u)}}},xt=(r,t,a,o)=>{for(var i={},c=0;c<t.length;c++)i[t[c]]=a[c];(xr||=[]).push([r,i,t]),tr||={},Fe(t[o],1)};xt(import.meta.url,["44khk4sp","ba6mz56s","en7w5ypg","ec5ennpv","nf2wkvf9","rmd0ctfx","f695wcx5","ectsnw81","pdt9hxfw","zv22wv0g","n0fawy9x"],[["/chunk-44khk4sp.js"],["/chunk-ba6mz56s.js",6,0,7,8],["/chunk-en7w5ypg.js",7],["/chunk-ec5ennpv.js",0,8],["/chunk-nf2wkvf9.js"],["/chunk-rmd0ctfx.js",6,7,0,10,8],["/chunk-f695wcx5.js",0,7,8],["/chunk-ectsnw81.js",0,8],["/chunk-pdt9hxfw.js"],["/chunk-zv22wv0g.js",10],["/chunk-n0fawy9x.js"]],0);
2
+ if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);var A=["pink","orange","amber","lime","emerald","cyan","blue","violet"];function Q(r){return typeof r==="string"&&A.includes(r)}function Jr(r){let t=2166136261;for(let a=0;a<r.length;a++)t^=r.charCodeAt(a),t=Math.imul(t,16777619);return A[(t>>>0)%A.length]??A[0]}var rn=1;var yt=8192,kt=320;function Be(r){return typeof r==="object"&&r!==null&&!Array.isArray(r)}function L(r,t=256){return typeof r==="string"&&r.length>0&&!r.includes("\x00")&&new TextEncoder().encode(r).length<=t}function yr(r){return Be(r)&&L(r.id,240)&&r.id.trim().length>0&&(r.name===void 0||L(r.name)&&r.name.trim().length>0)&&Q(r.color)&&(r.avatar===void 0||L(r.avatar,yt))&&(r.email===void 0||L(r.email,kt))}function N(r,t){return typeof r==="string"&&r.length<=t&&!r.includes("\x00")}function zt(r){if(!N(r,2048))return!1;try{return["http:","https:"].includes(new URL(r).protocol)}catch{return!1}}function nt(r){if(!Be(r)||!N(r.id,240)||!r.id.trim()||r.id!==r.id.trim()||!N(r.name,256)||r.avatar!==void 0&&!zt(r.avatar))throw Error("Invalid identity");let t={id:r.id,name:r.name,...r.avatar!==void 0?{avatar:r.avatar}:{}};if(r.type==="agent")return{...t,type:"agent"};if(r.type==="user"&&N(r.email,320)&&typeof r.isAnonymous==="boolean")return{...t,type:"user",email:r.email,isAnonymous:r.isAnonymous};throw Error("Invalid identity")}var ze=(r)=>`${r.type}:${r.id}`,bt=(r)=>r.type==="agent"?`agent:${r.id}`:r.id;var W,kr=0,zr=0,ar=new Set,Te=()=>W,br=()=>zr,ce=()=>kr;function Qr(r){return ar.add(r),()=>{ar.delete(r)}}function vt(r){let t=r===null?null:nt(r);if((W&&ze(W))!==(t&&ze(t)))kr++;zr++,W=t,ar.forEach((o)=>o())}var _t=["Curious Kiwi","Cheerful Cherry","Sleepy Peach","Excited Banana","Cosmic Mango","Velvet Lemon","Electric Plum","Wandering Pear","Dramatic Papaya","Suspicious Pineapple","Confused Coconut","Sneaky Tangerine","Gentle Fig","Quiet Apricot","Mellow Melon","Dreamy Guava"];function _r(r,t){let a=r.filter((o)=>o!==t);return a[Math.floor(Math.random()*a.length)]??r[0]}function Ct(r){return{name:_r(_t,r?.name),color:_r(A,r?.color)}}function Et(r,t){let a=t.name.trim();return{id:r,...a?{name:a}:{},color:t.color}}function Cr(){return Et(`local-${crypto.randomUUID().slice(0,8)}`,Ct())}var ir="moi:local-profile",_,E,D=new Set;function nr(r,t){return JSON.stringify(r)===JSON.stringify(t)}function P(r){if(!r||typeof r.id!=="string"||!r.id.trim())throw Error("A user profile needs an id.");if(r.name!==void 0&&typeof r.name!=="string")throw Error("A user profile name must be a string when provided.");if(r.color!==void 0&&!Q(r.color))throw Error("A user profile color must be one of the user palette names.");let t=r.id.trim(),a=r.name?.trim(),o={id:t,...a?{name:a}:{},color:r.color??Jr(t),...r.avatar!==void 0?{avatar:r.avatar}:{},...r.email!==void 0?{email:r.email}:{}};if(!yr(o))throw Error("Invalid user profile.");return Object.freeze(o)}var or,Er;function pe(){let r=Te();if(r===void 0)return _;if(r!==Er){Er=r;let t=!r||r.type==="user"&&r.isAnonymous?void 0:P({id:bt(r),name:r.name||void 0,avatar:r.avatar,email:r.type==="user"?r.email||void 0:void 0});if(!nr(or,t))or=t}return or}function wt(r){let t=pe(),a=ve(),o=()=>{let c=pe(),d=ve();if(t===c&&a===d)return;t=c,a=d,r()};D.add(o);let i=Qr(o);return()=>{D.delete(o),i()}}function ve(){return Te()!==void 0?"external":E}function on({provider:r,profile:t}){if(ve()==="external")return;if(r===void 0){if(E===void 0||E==="local")return;E=void 0,_=void 0}else{let a=t===void 0?void 0:P(t);if(E===r&&nr(_,a))return;E=r,_=a}D.forEach((a)=>a())}function At(){try{localStorage.setItem(ir,JSON.stringify(_))}catch{}}function eo(r){if(ve()!==void 0&&ve()!=="local")return;let t=P(r);E="local",_=t,At(),D.forEach((a)=>a())}function Ar(r,t){if(!r||!t||t.provider!==void 0||ve()!==void 0)return;try{let a=localStorage.getItem(ir);if(a){eo(JSON.parse(a));return}}catch{}eo(Cr())}function Sr(r){if(r.key!==ir||!r.newValue||ve()!=="local")return;try{let t=P(JSON.parse(r.newValue));if(nr(t,_))return;_=t,D.forEach((a)=>a())}catch{}}function Pr(){return window.addEventListener("storage",Sr),()=>window.removeEventListener("storage",Sr)}var Pt={setTimeout:(r,t)=>setTimeout(r,t),clearTimeout:(r)=>clearTimeout(r),setInterval:(r,t)=>setInterval(r,t),clearInterval:(r)=>clearInterval(r)},jt=class{#r=Pt;#t=!1;setTimeoutProvider(r){this.#r=r}setTimeout(r,t){return this.#r.setTimeout(r,t)}clearTimeout(r){this.#r.clearTimeout(r)}setInterval(r,t){return this.#r.setInterval(r,t)}clearInterval(r){this.#r.clearInterval(r)}},He=new jt;function jr(r){setTimeout(r,0)}var cr=typeof window>"u"||"Deno"in globalThis;function H(){}function Ir(r,t){return typeof r==="function"?r(t):r}function to(r){return typeof r==="number"&&r>=0&&r!==1/0}function ro(r,t){return Math.max(r+(t||0)-Date.now(),0)}function U(r,t){return typeof r==="function"?r(t):r}function Zt(r,t){let{type:a="all",exact:o,fetchStatus:i,predicate:c,queryKey:d,stale:n}=r;if(d){if(o){if(t.queryHash!==R(d,t.options))return!1}else if(!C(t.queryKey,d))return!1}if(a!=="all"){let s=t.isActive();if(a==="active"&&!s)return!1;if(a==="inactive"&&s)return!1}if(typeof n==="boolean"&&t.isStale()!==n)return!1;if(i&&i!==t.state.fetchStatus)return!1;if(c&&!c(t))return!1;return!0}function B(r,t){let{exact:a,status:o,predicate:i,mutationKey:c}=r;if(c){if(!t.options.mutationKey)return!1;if(a){if(Ue(t.options.mutationKey)!==Ue(c))return!1}else if(!C(t.options.mutationKey,c))return!1}if(o&&t.state.status!==o)return!1;if(i&&!i(t))return!1;return!0}function R(r,t){return(t?.queryKeyHashFn||Ue)(r)}function Ue(r){return JSON.stringify(r,(t,a)=>sr(a)?Object.keys(a).sort().reduce((o,i)=>(o[i]=a[i],o),{}):a)}function C(r,t){if(r===t)return!0;if(typeof r!==typeof t)return!1;if(r&&t&&typeof r==="object"&&typeof t==="object"){if(Array.isArray(r)&&Array.isArray(t)){for(let o=0;o<t.length;o++)if(!C(r[o],t[o]))return!1;return!0}let a=Object.keys(t);for(let o of a)if(!C(r[o],t[o]))return!1;return!0}return!1}var Mt=Object.prototype.hasOwnProperty;function We(r,t,a=0){if(r===t)return r;if(a>500)return t;let o=Mr(r)&&Mr(t);if(!o&&!(sr(r)&&sr(t)))return t;let i=(o?r:Object.keys(r)).length,c=o?t:Object.keys(t),d=c.length,n=o?Array(d):{},s=0;for(let p=0;p<d;p++){let g=o?p:c[p],h=r[g],u=t[g];if(h===u){if(n[g]=h,o?p<i:Mt.call(r,g))s++;continue}if(h===null||u===null||typeof h!=="object"||typeof u!=="object"){n[g]=u;continue}let y=We(h,u,a+1);if(n[g]=y,y===h)s++}return i===d&&s===i?r:n}function St(r,t){if(!t||Object.keys(r).length!==Object.keys(t).length)return!1;for(let a in r)if(r[a]!==t[a])return!1;return!0}function Mr(r){return Array.isArray(r)&&r.length===Object.keys(r).length}function sr(r){if(!Or(r))return!1;let t=r.constructor;if(t===void 0)return!0;let a=t.prototype;if(!Or(a))return!1;if(!a.hasOwnProperty("isPrototypeOf"))return!1;if(Object.getPrototypeOf(r)!==Object.prototype)return!1;return!0}function Or(r){return Object.prototype.toString.call(r)==="[object Object]"}function qr(r){return new Promise((t)=>{He.setTimeout(t,r)})}function vr(r,t,a){if(typeof a.structuralSharing==="function")return a.structuralSharing(r,t);else if(a.structuralSharing!==!1)return We(r,t);return t}function Dr(r,t,a=0){let o=[...r,t];return a&&o.length>a?o.slice(1):o}function Ur(r,t,a=0){let o=[t,...r];return a&&o.length>a?o.slice(0,-1):o}var j=Symbol();function K(r,t){if(!r.queryFn&&t?.initialPromise)return()=>t.initialPromise;if(!r.queryFn||r.queryFn===j)return()=>Promise.reject(Error(`Missing queryFn: '${r.queryHash}'`));return r.queryFn}function Jt(r,t){if(typeof r==="function")return r(...t);return!!r}function Rr(r,t,a){let o=!1,i;return Object.defineProperty(r,"signal",{enumerable:!0,get:()=>{if(i??=t(),o)return i;if(o=!0,i.aborted)a();else i.addEventListener("abort",a,{once:!0});return i}}),r}var Ot=()=>cr,Qt=()=>Ot();var ge=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(r){return this.listeners.add(r),this.onSubscribe(),()=>{this.listeners.delete(r),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var It=class extends ge{#r;#t;#a;constructor(){super();this.#a=(r)=>{if(typeof window<"u"&&window.addEventListener){let t=()=>r();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){if(!this.#t)this.setEventListener(this.#a)}onUnsubscribe(){if(!this.hasListeners())this.#t?.(),this.#t=void 0}setEventListener(r){this.#a=r,this.#t?.(),this.#t=r((t)=>{if(typeof t==="boolean")this.setFocused(t);else this.onFocus()})}setFocused(r){if(this.#r!==r)this.#r=r,this.onFocus()}onFocus(){let r=this.isFocused();this.listeners.forEach((t)=>{t(r)})}isFocused(){if(typeof this.#r==="boolean")return this.#r;return globalThis.document?.visibilityState!=="hidden"}},er=new It;var Tr=jr;function qt(){let r=[],t=0,a=(n)=>{n()},o=(n)=>{n()},i=Tr,c=(n)=>{if(t)r.push(n);else i(()=>{a(n)})},d=()=>{let n=r;if(r=[],n.length)i(()=>{o(()=>{n.forEach((s)=>{a(s)})})})};return{batch:(n)=>{let s;t++;try{s=n()}finally{if(t--,!t)d()}return s},batchCalls:(n)=>(...s)=>{c(()=>{n(...s)})},schedule:c,setNotifyFunction:(n)=>{a=n},setBatchNotifyFunction:(n)=>{o=n},setScheduler:(n)=>{i=n}}}var M=qt();var Dt=class extends ge{#r=!0;#t;#a;constructor(){super();this.#a=(r)=>{if(typeof window<"u"&&window.addEventListener){let t=()=>r(!0),a=()=>r(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",a)}}}}onSubscribe(){if(!this.#t)this.setEventListener(this.#a)}onUnsubscribe(){if(!this.hasListeners())this.#t?.(),this.#t=void 0}setEventListener(r){this.#a=r,this.#t?.(),this.#t=r(this.setOnline.bind(this))}setOnline(r){if(this.#r!==r)this.#r=r,this.listeners.forEach((t)=>{t(r)})}isOnline(){return this.#r}},O=new Dt;function Ut(r){return Math.min(1000*2**r,30000)}function lr(r){return(r??"online")==="online"?O.isOnline():!0}var V=class extends Error{constructor(r){super("CancelledError");this.revert=r?.revert,this.silent=r?.silent}};function Y(r){let t=!1,a=0,o,i="pending",c,d,n=new Promise((v,f)=>{c=v,d=f});n.catch(H);let s=()=>i!=="pending",p=(v)=>{if(!s()){let f=new V(v);m(f),r.onCancel?.(f)}},g=()=>{t=!0},h=()=>{t=!1},u=()=>er.isFocused()&&(r.networkMode==="always"||O.isOnline())&&r.canRun(),y=()=>lr(r.networkMode)&&r.canRun(),w=(v)=>{if(!s())o?.(),i="resolved",c(v)},m=(v)=>{if(!s())o?.(),i="rejected",d(v)},k=()=>new Promise((v)=>{o=(f)=>{if(s()||u())v(f)},r.onPause?.()}).then(()=>{if(o=void 0,!s())r.onContinue?.()}),T=()=>{if(s())return;let v,f=a===0?r.initialPromise:void 0;try{v=f??r.fn()}catch(b){v=Promise.reject(b)}Promise.resolve(v).then(w).catch((b)=>{if(s())return;let z=r.retry??(Qt()?0:3),S=r.retryDelay??Ut,st=typeof S==="function"?S(a,b):S,ct=z===!0||typeof z==="number"&&a<z||typeof z==="function"&&z(a,b);if(t||!ct){m(b);return}a++,r.onFail?.(a,b),qr(st).then(()=>u()?void 0:k()).then(()=>{if(t)m(b);else T()})})};return{promise:n,status:()=>i,cancel:p,continue:()=>(o?.(),n),cancelRetry:g,continueRetry:h,canStart:y,start:()=>{if(y())T();else k().then(T);return n}}}var X=class{#r;destroy(){this.clearGcTimeout()}scheduleGc(){if(this.clearGcTimeout(),to(this.gcTime))this.#r=He.setTimeout(()=>{this.optionalRemove()},this.gcTime)}updateGcTime(r){this.gcTime=Math.max(this.gcTime||0,r??(Qt()?1/0:300000))}clearGcTimeout(){if(this.#r!==void 0)He.clearTimeout(this.#r),this.#r=void 0}};function Lr(r){return{onFetch:(t,a)=>{let o=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,c=t.state.data?.pages||[],d=t.state.data?.pageParams||[],n={pages:[],pageParams:[]},s=0,p=async()=>{let g=!1,h=(w)=>{Rr(w,()=>t.signal,()=>g=!0)},u=K(t.options,t.fetchOptions),y=async(w,m,k)=>{if(g)return Promise.reject(t.signal.reason);if(m==null&&w.pages.length)return Promise.resolve(w);let v=(()=>{let S={client:t.client,queryKey:t.queryKey,pageParam:m,direction:k?"backward":"forward",meta:t.options.meta};return h(S),S})(),f=await u(v),{maxPages:b}=t.options,z=k?Ur:Dr;return{pages:z(w.pages,f,b),pageParams:z(w.pageParams,m,b)}};if(i&&c.length){let w=i==="backward",m=w?Rt:Fr,k={pages:c,pageParams:d};n=await y(k,m(o,k),w)}else{let w=r??c.length;do{let m=s===0?d[0]??o.initialPageParam:Fr(o,n);if(s>0&&m==null)break;n=await y(n,m),s++}while(s<w)}return n};if(t.options.persister)t.fetchFn=()=>t.options.persister?.(p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},a);else t.fetchFn=p}}}function Fr(r,{pages:t,pageParams:a}){let o=t.length-1;return t.length>0?r.getNextPageParam(t[o],t,a[o],a):void 0}function Rt(r,{pages:t,pageParams:a}){return t.length>0?r.getPreviousPageParam?.(t[0],t,a[0],a):void 0}var Br=class extends X{#r;#t;#a;#o;#i;#e;#c;#n;constructor(r){super();this.#n=!1,this.#c=r.defaultOptions,this.setOptions(r.options),this.observers=[],this.#i=r.client,this.#o=this.#i.getQueryCache(),this.queryKey=r.queryKey,this.queryHash=r.queryHash,this.#t=Wr(this.options),this.state=r.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#r}get promise(){return this.#e?.promise}setOptions(r){if(this.options={...this.#c,...r},r?._type)this.#r=r._type;if(this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let t=Wr(this.options);if(t.data!==void 0)this.setState(Nr(t.data,t.dataUpdatedAt)),this.#t=t}}optionalRemove(){if(!this.observers.length&&this.state.fetchStatus==="idle")this.#o.remove(this)}setData(r,t){let a=vr(this.state.data,r,this.options);return this.#s({data:a,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),a}setState(r){this.#s({type:"setState",state:r})}cancel(r){let t=this.#e?.promise;return this.#e?.cancel(r),t?t.then(H).catch(H):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some((r)=>U(r.options.enabled,this)!==!1)}isDisabled(){if(this.getObserversCount()>0)return!this.isActive();return this.options.queryFn===j||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){if(this.getObserversCount()>0)return this.observers.some((r)=>U(r.options.staleTime,this)==="static");return!1}isStale(){if(this.getObserversCount()>0)return this.observers.some((r)=>r.getCurrentResult().isStale);return this.state.data===void 0||this.state.isInvalidated}isStaleByTime(r=0){if(this.state.data===void 0)return!0;if(r==="static")return!1;if(this.state.isInvalidated)return!0;return!ro(this.state.dataUpdatedAt,r)}onFocus(){this.observers.find((r)=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#e?.continue()}onOnline(){this.observers.find((r)=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#e?.continue()}addObserver(r){if(!this.observers.includes(r))this.observers.push(r),this.clearGcTimeout(),this.#o.notify({type:"observerAdded",query:this,observer:r})}removeObserver(r){let t=this.observers.indexOf(r);if(t!==-1){if(this.observers.splice(t,1),!this.observers.length){if(this.#e)if(this.#n||this.state.fetchStatus==="paused"&&this.state.status==="pending")this.#e.cancel({revert:!0});else this.#e.cancelRetry();this.scheduleGc()}this.#o.notify({type:"observerRemoved",query:this,observer:r})}}getObserversCount(){return this.observers.length}invalidate(){if(!this.state.isInvalidated)this.#s({type:"invalidate"})}async fetch(r,t){if(this.state.fetchStatus!=="idle"&&this.#e?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#e)return this.#e.continueRetry(),this.#e.promise}if(r)this.setOptions(r);if(!this.options.queryFn){let s=this.observers.find((p)=>p.options.queryFn);if(s)this.setOptions(s.options)}let a=new AbortController,o=(s)=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#n=!0,a.signal)})},i=()=>{let s=K(this.options,t),g=(()=>{let h={client:this.#i,queryKey:this.queryKey,meta:this.meta};return o(h),h})();if(this.#n=!1,this.options.persister)return this.options.persister(s,g,this);return s(g)},d=(()=>{let s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return o(s),s})();if((this.#r==="infinite"?Lr(this.options.pages):this.options.behavior)?.onFetch(d,this),this.#a=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==d.fetchOptions?.meta)this.#s({type:"fetch",meta:d.fetchOptions?.meta});let n=this.#e=Y({initialPromise:t?.initialPromise,fn:d.fetchFn,onCancel:(s)=>{if(s instanceof V&&s.revert)this.setState({...this.#a,fetchStatus:"idle"});a.abort()},onFail:(s,p)=>{this.#s({type:"failed",failureCount:s,error:p})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode,canRun:()=>!0});try{let s=await n.start();if(s===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(s),this.#o.config.onSuccess?.(s,this),this.#o.config.onSettled?.(s,this.state.error,this),s}catch(s){if(s instanceof V){if(s.silent)return this.#e.promise;else if(s.revert){if(this.state.data===void 0)throw s;return this.state.data}}throw this.#s({type:"error",error:s}),this.#o.config.onError?.(s,this),this.#o.config.onSettled?.(this.state.data,s,this),s}finally{if(this.#e===n)this.#e=void 0;this.scheduleGc()}}#s(r){let t=(a)=>{switch(r.type){case"failed":return{...a,fetchFailureCount:r.failureCount,fetchFailureReason:r.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":return{...a,..._o(a.data,this.options),fetchMeta:r.meta??null};case"success":let o={...a,...Nr(r.data,r.dataUpdatedAt),dataUpdateCount:a.dataUpdateCount+1,...!r.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#a=r.manual?o:void 0,o;case"error":let i=r.error;return{...a,error:i,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...r.state}}};this.state=t(this.state),M.batch(()=>{this.observers.slice().forEach((a)=>{a.onQueryUpdate()}),this.#o.notify({query:this,type:"updated",action:r})})}};function _o(r,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:lr(t.networkMode)?"fetching":"paused",...r===void 0&&{error:null,status:"pending"}}}function Nr(r,t){return{data:r,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Wr(r){let t=typeof r.initialData==="function"?r.initialData():r.initialData,a=t!==void 0,o=a?typeof r.initialDataUpdatedAt==="function"?r.initialDataUpdatedAt():r.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:a?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:a?"success":"pending",fetchStatus:"idle"}}var Hr=class extends X{#r;#t;#a;#o;constructor(r){super();this.#r=r.client,this.mutationId=r.mutationId,this.#a=r.mutationCache,this.#t=[],this.state=r.state||Mo(),this.setOptions(r.options),this.scheduleGc()}setOptions(r){this.options=r,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(r){if(!this.#t.includes(r))this.#t.push(r),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",mutation:this,observer:r})}removeObserver(r){this.#t=this.#t.filter((t)=>t!==r),this.scheduleGc(),this.#a.notify({type:"observerRemoved",mutation:this,observer:r})}optionalRemove(){if(!this.#t.length)if(this.state.status==="pending")this.scheduleGc();else this.#a.remove(this)}continue(){return this.#o?.continue()??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(r){let t=()=>{this.#i({type:"continue"})},a={client:this.#r,meta:this.options.meta,mutationKey:this.options.mutationKey},o=this.#o=Y({fn:()=>{if(!this.options.mutationFn)return Promise.reject(Error("No mutationFn found"));return this.options.mutationFn(r,a)},onFail:(d,n)=>{this.#i({type:"failed",failureCount:d,error:n})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#a.canRun(this)}),i=this.state.status==="pending",c=!o.canStart();try{if(i)t();else{if(this.#i({type:"pending",variables:r,isPaused:c}),this.#a.config.onMutate)await this.#a.config.onMutate(r,this,a);let n=await this.options.onMutate?.(r,a);if(n!==this.state.context)this.#i({type:"pending",context:n,variables:r,isPaused:c})}let d=await o.start();return await this.#a.config.onSuccess?.(d,r,this.state.context,this,a),await this.options.onSuccess?.(d,r,this.state.context,a),await this.#a.config.onSettled?.(d,null,this.state.variables,this.state.context,this,a),await this.options.onSettled?.(d,null,r,this.state.context,a),this.#i({type:"success",data:d}),d}catch(d){try{await this.#a.config.onError?.(d,r,this.state.context,this,a)}catch(n){Promise.reject(n)}try{await this.options.onError?.(d,r,this.state.context,a)}catch(n){Promise.reject(n)}try{await this.#a.config.onSettled?.(void 0,d,this.state.variables,this.state.context,this,a)}catch(n){Promise.reject(n)}try{await this.options.onSettled?.(void 0,d,r,this.state.context,a)}catch(n){Promise.reject(n)}throw this.#i({type:"error",error:d}),d}finally{if(this.#o===o)this.#o=void 0;this.#a.runNext(this)}}#i(r){let t=(a)=>{switch(r.type){case"failed":return{...a,failureCount:r.failureCount,failureReason:r.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};case"pending":return{...a,context:r.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:r.isPaused,status:"pending",variables:r.variables,submittedAt:Date.now()};case"success":return{...a,data:r.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:r.error,failureCount:a.failureCount+1,failureReason:r.error,isPaused:!1,status:"error"}}};this.state=t(this.state),M.batch(()=>{this.#t.forEach((a)=>{a.onMutationUpdate(r)}),this.#a.notify({mutation:this,type:"updated",action:r})})}};function Mo(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Kr=class extends ge{#r;#t;#a;constructor(r={}){super();this.config=r,this.#r=new Set,this.#t=new Map,this.#a=0}build(r,t,a){let o=new Hr({client:r,mutationCache:this,mutationId:++this.#a,options:r.defaultMutationOptions(t),state:a});return this.add(o),o}add(r){this.#r.add(r);let t=J(r);if(typeof t==="string"){let a=this.#t.get(t);if(a)a.push(r);else this.#t.set(t,[r])}this.notify({type:"added",mutation:r})}remove(r){if(this.#r.delete(r)){let t=J(r);if(typeof t==="string"){let a=this.#t.get(t);if(a){if(a.length>1){let o=a.indexOf(r);if(o!==-1)a.splice(o,1)}else if(a[0]===r)this.#t.delete(t)}}}this.notify({type:"removed",mutation:r})}canRun(r){let t=J(r);if(typeof t==="string"){let a=this.#t.get(t)?.find((o)=>o.state.status==="pending");return!a||a===r}else return!0}runNext(r){let t=J(r);if(typeof t==="string")return this.#t.get(t)?.find((a)=>a!==r&&a.state.isPaused)?.continue()??Promise.resolve();else return Promise.resolve()}clear(){M.batch(()=>{this.#r.forEach((r)=>{this.notify({type:"removed",mutation:r})}),this.#r.clear(),this.#t.clear()})}getAll(){return Array.from(this.#r)}find(r){let t={exact:!0,...r};return this.getAll().find((a)=>B(t,a))}findAll(r={}){return this.getAll().filter((t)=>B(r,t))}notify(r){M.batch(()=>{this.listeners.forEach((t)=>{t(r)})})}resumePausedMutations(){let r=this.getAll().filter((t)=>t.state.isPaused);return M.batch(()=>Promise.all(r.map((t)=>t.continue().catch(H))))}};function J(r){return r.options.scope?.id}var Vr=class extends ge{#r;constructor(r={}){super();this.config=r,this.#r=new Map}build(r,t,a){let o=t.queryKey,i=t.queryHash??R(o,t),c=this.get(i);if(!c)c=new Br({client:r,queryKey:o,queryHash:i,options:r.defaultQueryOptions(t),state:a,defaultOptions:r.getQueryDefaults(o)}),this.add(c);return c}add(r){if(!this.#r.has(r.queryHash))this.#r.set(r.queryHash,r),this.notify({type:"added",query:r})}remove(r){let t=this.#r.get(r.queryHash);if(t){if(r.destroy(),t===r)this.#r.delete(r.queryHash);this.notify({type:"removed",query:r})}}clear(){M.batch(()=>{this.getAll().forEach((r)=>{this.remove(r)})})}get(r){return this.#r.get(r)}getAll(){return[...this.#r.values()]}find(r){let t={exact:!0,...r};return this.getAll().find((a)=>Zt(t,a))}findAll(r={}){let t=this.getAll();return Object.keys(r).length>0?t.filter((a)=>Zt(r,a)):t}notify(r){M.batch(()=>{this.listeners.forEach((t)=>{t(r)})})}onFocus(){M.batch(()=>{this.getAll().forEach((r)=>{r.onFocus()})})}onOnline(){M.batch(()=>{this.getAll().forEach((r)=>{r.onOnline()})})}};var dr=class{#r;#t;#a;#o;#i;#e;#c;#n;constructor(r={}){this.#r=r.queryCache||new Vr,this.#t=r.mutationCache||new Kr,this.#a=r.defaultOptions||{},this.#o=new Map,this.#i=new Map,this.#e=0}mount(){if(this.#e++,this.#e!==1)return;this.#c=er.subscribe(async(r)=>{if(r)await this.resumePausedMutations(),this.#r.onFocus()}),this.#n=O.subscribe(async(r)=>{if(r)await this.resumePausedMutations(),this.#r.onOnline()})}unmount(){if(this.#e--,this.#e!==0)return;this.#c?.(),this.#c=void 0,this.#n?.(),this.#n=void 0}isFetching(r){return this.#r.findAll({...r,fetchStatus:"fetching"}).length}isMutating(r){return this.#t.findAll({...r,status:"pending"}).length}getQueryData(r){let t=this.defaultQueryOptions({queryKey:r});return this.#r.get(t.queryHash)?.state.data}ensureQueryData(r){let t=this.defaultQueryOptions(r),a=this.#r.build(this,t),o=a.state.data;if(o===void 0)return this.fetchQuery(r);if(r.revalidateIfStale&&a.isStaleByTime(U(t.staleTime,a)))this.prefetchQuery(t);return Promise.resolve(o)}getQueriesData(r){return this.#r.findAll(r).map(({queryKey:t,state:a})=>[t,a.data])}setQueryData(r,t,a){let o=this.defaultQueryOptions({queryKey:r}),i=this.#r.get(o.queryHash)?.state.data,c=Ir(t,i);if(c===void 0)return;return this.#r.build(this,o).setData(c,{...a,manual:!0})}setQueriesData(r,t,a){return M.batch(()=>this.#r.findAll(r).map(({queryKey:o})=>[o,this.setQueryData(o,t,a)]))}getQueryState(r){let t=this.defaultQueryOptions({queryKey:r});return this.#r.get(t.queryHash)?.state}removeQueries(r){let t=this.#r;M.batch(()=>{t.findAll(r).forEach((a)=>{t.remove(a)})})}resetQueries(r,t){let a=this.#r;return M.batch(()=>{let o=a.findAll(r),i=new Set(o);return o.forEach((c)=>{c.reset()}),this.refetchQueries({type:"active",predicate:(c)=>i.has(c)},t)})}cancelQueries(r,t={}){let a={revert:!0,...t},o=M.batch(()=>this.#r.findAll(r).map((i)=>i.cancel(a)));return Promise.all(o).then(H).catch(H)}invalidateQueries(r,t={}){return M.batch(()=>{if(this.#r.findAll(r).forEach((a)=>{a.invalidate()}),r?.refetchType==="none")return Promise.resolve();return this.refetchQueries({...r,type:r?.refetchType??r?.type??"active"},t)})}refetchQueries(r,t={}){let a={...t,cancelRefetch:t.cancelRefetch??!0},o=M.batch(()=>this.#r.findAll(r).filter((i)=>!i.isDisabled()&&!i.isStatic()).map((i)=>{let c=i.fetch(void 0,a);if(!a.throwOnError)c=c.catch(H);return i.state.fetchStatus==="paused"?Promise.resolve():c}));return Promise.all(o).then(H)}async query(r){let t=this.defaultQueryOptions(r);if(t.retry===void 0)t.retry=!1;let a=this.#r.build(this,t),o=a.isStaleByTime(U(t.staleTime,a))?await a.fetch(t):a.state.data,i=t.select;if(i)return i(o);return o}fetchQuery(r){let t=this.defaultQueryOptions(r);if(t.retry===void 0)t.retry=!1;let a=this.#r.build(this,t);return a.isStaleByTime(U(t.staleTime,a))?a.fetch(t):Promise.resolve(a.state.data)}prefetchQuery(r){return this.fetchQuery(r).then(H).catch(H)}infiniteQuery(r){return r._type="infinite",this.query(r)}fetchInfiniteQuery(r){return r._type="infinite",this.fetchQuery(r)}prefetchInfiniteQuery(r){return this.fetchInfiniteQuery(r).then(H).catch(H)}ensureInfiniteQueryData(r){return r._type="infinite",this.ensureQueryData(r)}resumePausedMutations(){if(O.isOnline())return this.#t.resumePausedMutations();return Promise.resolve()}getQueryCache(){return this.#r}getMutationCache(){return this.#t}getDefaultOptions(){return this.#a}setDefaultOptions(r){this.#a=r}setQueryDefaults(r,t){this.#o.set(Ue(r),{queryKey:r,defaultOptions:t})}getQueryDefaults(r){let t=[...this.#o.values()],a={};return t.forEach((o)=>{if(C(r,o.queryKey))Object.assign(a,o.defaultOptions)}),a}setMutationDefaults(r,t){this.#i.set(Ue(r),{mutationKey:r,defaultOptions:t})}getMutationDefaults(r){let t=[...this.#i.values()],a={};return t.forEach((o)=>{if(C(r,o.mutationKey))Object.assign(a,o.defaultOptions)}),a}defaultQueryOptions(r){if(r._defaulted)return r;let t={...this.#a.queries,...this.getQueryDefaults(r.queryKey),...r,_defaulted:!0};if(!t.queryHash)t.queryHash=R(t.queryKey,t);if(t.refetchOnReconnect===void 0)t.refetchOnReconnect=t.networkMode!=="always";if(t.throwOnError===void 0)t.throwOnError=!!t.suspense;if(!t.networkMode&&t.persister)t.networkMode="offlineFirst";if(t.queryFn===j)t.enabled=!1;return t}defaultMutationOptions(r){if(r?._defaulted)return r;return{...this.#a.mutations,...r?.mutationKey&&this.getMutationDefaults(r.mutationKey),...r,_defaulted:!0}}clear(){this.#r.clear(),this.#t.clear()}};var it=new dr;var l={all:["workspaces"],discover:["workspaces","discover"],previews:["workspaces","previews"],layout:(r)=>["workspaces","layout",r],widgets:(r)=>["workspaces","widgets",r],appletThumbnails:(r)=>["workspaces","applet-thumbnails",r],views:(r)=>["workspaces","views",r],sessions:(r)=>["workspaces","sessions",r],events:(r,t)=>["workspaces","events",r,t],state:(r)=>["workspaces","state",r],mcp:(r)=>["workspaces","mcp",r],harness:(r)=>["workspaces","harness",r],skills:(r)=>["workspaces","skills",r],env:(r)=>["workspaces","env",r]};var pr=(r,t)=>t.getQueryData(l.layout(r));function Bt(r,t=it){return pr(r,t)?.isRemote??!1}function ie(r,t=it){let a=pr(r,t)?.apiBase;if(!a)throw Error("Workspace identity is not loaded");return a}function hr(r,t=it){let a=pr(r,t)?.apiBase;return a?decodeURIComponent(a.slice(16)):r}function gr(r){if(!Be(r)||!Array.isArray(r.members)||!Array.isArray(r.invitations))throw Error("Invalid workspace members");let t=r.members.map((o)=>{let i=nt(o);if(Be(o)&&o.membershipId!==void 0){if(typeof o.membershipId!=="string"||!o.membershipId||o.membershipId.length>240)throw Error("Invalid membership id");return{...i,membershipId:o.membershipId}}return i}),a=r.invitations.map((o)=>{if(!Be(o)||typeof o.id!=="string"||!o.id||typeof o.email!=="string"||!o.email||typeof o.expiresAt!=="string"||!Number.isFinite(Date.parse(o.expiresAt)))throw Error("Invalid invitation");return{id:o.id,email:o.email,expiresAt:o.expiresAt}});if(new Set(t.map(ze)).size!==t.length||new Set(a.map((o)=>o.id)).size!==a.length)throw Error("Duplicate workspace member or invitation");return{members:t,invitations:a}}function G(r){if(!/^(?:[A-Za-z0-9_-]{1,64}:)?[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(r))throw Error("Invalid workspace id");return r}var ur;function x(){let r=ce();if(ur?.accountGeneration!==r)ur={accountGeneration:r,lists:new Map,complete:!1};return ur}var Xr=0,mr=new Set;function q(){Xr++,mr.forEach((r)=>r())}var Gr=()=>Xr,$r=new WeakMap,Tt={members:[],invitations:[]},Yr=new WeakMap;function Zr(r){if(!x().complete)return;if(r.includes(":"))return Tt;let t=Te();if(t?.type!=="user"||t.isAnonymous)return;let a=$r.get(t);if(!a)a={members:[t],invitations:[]},$r.set(t,a);return a}function Z(r,t){let{lists:a}=x();a.set(r,We(a.get(r),t))}function rt(r,t){Z(G(r),gr(t)),q()}function tt(r){if(!Array.isArray(r))throw Error("Invalid workspace members");let t=r.map((i)=>[G(i.id),gr(i)]),a=new Set(t.map(([i])=>i));if(a.size!==t.length)throw Error("Duplicate workspace id");let{lists:o}=x();for(let i of o.keys())if(!a.has(i))o.delete(i);for(let[i,c]of t)Z(i,c);x().complete=!0,q()}function at(r){x().lists.delete(G(r)),q()}function et(){x().lists.clear(),q()}function nn(r,t){let a=hr(r),o=x().lists.get(a)??Zr(a),i=o&&t(o);if(!i)return;Z(a,i),q()}function sn(r){let t=ze(r);for(let[a,o]of x().lists)Z(a,{...o,members:o.members.map((i)=>ze(i)===t?{...r,...i.membershipId&&{membershipId:i.membershipId}}:i)});q()}function Do(r){let t=hr(r);return x().lists.get(t)??Zr(t)}function an(r){let t=Do(r);if(!t)return;let a=Yr.get(t);if(!a)a=t.members.map((o)=>P({id:bt(o),name:o.name||void 0,avatar:o.avatar,email:o.type==="user"?o.email||void 0:void 0})),Yr.set(t,a);return a}function wr(r){mr.add(r);let t=it.getQueryCache().subscribe((a)=>{let[o,i]=a.query.queryKey;if(o===l.all[0]&&i==="layout")r()});return()=>{mr.delete(r),t()}}function ot(){if(typeof window>"u")return;let r=window;r.moi??={},r.moi.identity={set:vt,getRevision:br},r.moi.workspaceMembers={set:rt,setAll:tt,remove:at,clear:et,getRevision:Gr}}ot();Pr();async function Lt(r){let[{mount:t},a,o]=await Promise.all([(Fe("ba6mz56s"),import("/chunk-ba6mz56s.js")),(Fe("en7w5ypg"),import("/chunk-en7w5ypg.js")).then((i)=>i.loadAppConfig()),(Fe("ec5ennpv"),import("/chunk-ec5ennpv.js")).then((i)=>i.loadProxyUser())]);Ar(a?.environment==="local"&&!a.demo,o),t(r)}globalThis.__init=Lt;export{e,I,Ft,tn,Fe,Jr,rn,Be,nt,ze,bt,Te,br,ce,Qr,vt,pe,wt,ve,on,eo,He,H,to,ro,U,Zt,Ue,We,St,vr,Jt,Qt,ge,er,M,_o,Mo,it,l,Bt,ie,nn,sn,Do,an,wr};