@hanzo/app 0.3.94 → 0.3.96

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 (110) hide show
  1. package/dist/Account.d.ts +9 -3
  2. package/dist/Account.js +142 -141
  3. package/dist/App.js +71 -37
  4. package/dist/Bar.js +1 -1
  5. package/dist/Betas.d.ts +1 -1
  6. package/dist/Betas.js +16 -22
  7. package/dist/Board.js +114 -48
  8. package/dist/CalScheduler.d.ts +1 -0
  9. package/dist/CalScheduler.js +223 -57
  10. package/dist/Chat.js +432 -153
  11. package/dist/Contacts.js +35 -31
  12. package/dist/ContextMenu.js +126 -42
  13. package/dist/Directory.js +1 -1
  14. package/dist/Drawer.js +1 -1
  15. package/dist/Drive.js +351 -119
  16. package/dist/Gate.js +156 -13
  17. package/dist/Home.js +31 -53
  18. package/dist/Inbox.js +29 -15
  19. package/dist/InlineRename.d.ts +6 -0
  20. package/dist/InlineRename.js +41 -0
  21. package/dist/Learning.js +132 -13
  22. package/dist/Market.js +13 -9
  23. package/dist/Meet.d.ts +5 -0
  24. package/dist/Meet.js +75 -51
  25. package/dist/MoreMenu.d.ts +19 -0
  26. package/dist/MoreMenu.js +33 -0
  27. package/dist/NeedMoreUsage.js +2 -2
  28. package/dist/OrgSwitcher.js +6 -2
  29. package/dist/PreferencesDialog.js +5 -2
  30. package/dist/Rail.d.ts +73 -7
  31. package/dist/Rail.js +372 -111
  32. package/dist/Recents.js +77 -24
  33. package/dist/RightPane.js +2 -2
  34. package/dist/Search.d.ts +13 -1
  35. package/dist/Search.js +366 -50
  36. package/dist/Setup.js +34 -5
  37. package/dist/Shared.js +12 -12
  38. package/dist/Shell.d.ts +10 -0
  39. package/dist/Shell.js +258 -158
  40. package/dist/Sidebar.d.ts +14 -3
  41. package/dist/Sidebar.js +411 -129
  42. package/dist/SkipLink.d.ts +8 -0
  43. package/dist/SkipLink.js +11 -0
  44. package/dist/Start.js +51 -52
  45. package/dist/Terminals.js +159 -11
  46. package/dist/ToBottom.js +1 -1
  47. package/dist/Upgrade.d.ts +8 -3
  48. package/dist/Upgrade.js +194 -103
  49. package/dist/Usage.d.ts +1 -1
  50. package/dist/Usage.js +186 -82
  51. package/dist/WalletPill.js +8 -2
  52. package/dist/Work.js +162 -53
  53. package/dist/archive.d.ts +8 -0
  54. package/dist/archive.js +16 -0
  55. package/dist/bots/Bots.js +16 -1
  56. package/dist/bots/ComputerDialog.js +53 -26
  57. package/dist/bots/ConnectorsDialog.js +34 -15
  58. package/dist/bots/Make.js +5 -1
  59. package/dist/bots/Panel.js +37 -31
  60. package/dist/bots/Roster.d.ts +4 -1
  61. package/dist/bots/Roster.js +71 -25
  62. package/dist/bots/Thread.js +54 -27
  63. package/dist/bots/face.js +9 -3
  64. package/dist/bots/grid.d.ts +36 -0
  65. package/dist/bots/grid.js +91 -0
  66. package/dist/bots/ink.d.ts +1 -1
  67. package/dist/bots/ink.js +1 -1
  68. package/dist/bots/kit.d.ts +9 -4
  69. package/dist/bots/kit.js +3 -2
  70. package/dist/chord.d.ts +13 -0
  71. package/dist/chord.js +30 -1
  72. package/dist/crew.js +47 -4
  73. package/dist/ground.d.ts +2 -2
  74. package/dist/ground.js +3 -3
  75. package/dist/help.d.ts +7 -3
  76. package/dist/help.js +19 -14
  77. package/dist/keys.d.ts +28 -0
  78. package/dist/keys.js +58 -0
  79. package/dist/lib/arrival.d.ts +5 -0
  80. package/dist/lib/arrival.js +10 -0
  81. package/dist/lib/betas.d.ts +2 -0
  82. package/dist/lib/betas.js +10 -0
  83. package/dist/lib/branch.d.ts +11 -0
  84. package/dist/lib/branch.js +11 -0
  85. package/dist/lib/chatPreferences.d.ts +1 -1
  86. package/dist/lib/chatPreferences.js +1 -1
  87. package/dist/lib/dev-mode.d.ts +18 -0
  88. package/dist/lib/dev-mode.js +102 -0
  89. package/dist/lib/durable.d.ts +1 -1
  90. package/dist/lib/durable.js +1 -1
  91. package/dist/lib/info-hint.d.ts +7 -0
  92. package/dist/lib/info-hint.js +8 -0
  93. package/dist/lib/model-picker.d.ts +2 -0
  94. package/dist/lib/model-picker.js +12 -0
  95. package/dist/lib/owners.d.ts +5 -0
  96. package/dist/lib/owners.js +15 -0
  97. package/dist/lib/pay.d.ts +2 -0
  98. package/dist/lib/pay.js +4 -0
  99. package/dist/lib/todo.d.ts +7 -1
  100. package/dist/lib/todo.js +41 -29
  101. package/dist/look.js +39 -8
  102. package/dist/rail-open.d.ts +9 -0
  103. package/dist/rail-open.js +34 -0
  104. package/dist/renaming.d.ts +10 -0
  105. package/dist/renaming.js +25 -0
  106. package/dist/seek.d.ts +6 -1
  107. package/dist/seek.js +13 -0
  108. package/dist/thread.d.ts +2 -1
  109. package/dist/thread.js +85 -44
  110. package/package.json +11 -11
package/dist/Rail.js CHANGED
@@ -1,60 +1,78 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- // The app's rail: its products as marks down the window's left edge, in one
4
- // order — Chat, Dev, Studio, Tabs, Library, Scheduled tasks, Customize — then
5
- // More (Team, on a host of its own, then the apps in beta this reader may open
6
- // and Betas, the list of every app in beta; none of it in Studio), and the
7
- // account at the foot. It
8
- // is how the app moves between its products; a phone's drawer holds it down its
9
- // start edge, as a laptop's window does, and its bar carries no switch of its
10
- // own. Every mark is @hanzo/build's `MARKS`, the one source the sidebars, the
11
- // bar, the palette and the landing pages draw from.
12
- //
13
- // Studio is the app's third mode (@hanzo/studio at /studio), each of the three
14
- // opened where the reader left it.
15
- //
16
- // Dev, Studio, Tabs and Team are products, named as they are in every
17
- // language; the rest of the rail's words go through `t`.
18
- //
19
- // A mark is a place, and a place owns the sidebar beside the rail: Chat its
20
- // conversations, Dev its own places (@hanzo/build `own`: New run, Projects,
21
- // Issues, Templates) and its runs, Studio its own; Library, Scheduled tasks and
22
- // Customize (@hanzo/build's Artifacts, Automations and Customize) each their
23
- // own (Sidebar.tsx); Settings is the site's pages at /settings, beside the app
24
- // (lib/host.ts `settings`). Nothing on the rail is listed inside Dev: one level
25
- // of the app a place, each lit while the reader is on it.
26
- //
27
- // It stands on the frame's floor, never cut as a pane (ground.ts): the rail and
28
- // the sidebar beside it are the window, and the content is the panel inset in
29
- // it.
30
- //
31
- // The sidebar's toggle leads it (`toggle`) where the host has no bar of its own:
32
- // a browser tab. A host that is a window draws the toggle in its bar beside Back
33
- // and Forward (App.tsx `bar`), and its rail starts with Chat. A phone has no
34
- // rail: its menu (Drawer.tsx) lists the places as rows (`rows`) under the mode's
35
- // own — Design, Studio, Tabs, then More, which Library, Scheduled tasks and
36
- // Customize lead there. Chat and Dev are the rail's marks beside them, and the
37
- // account is the menu's foot.
3
+ // Folded left navigation rail (52px icons-only, shown when the unified sidebar
4
+ // is folded, plus the compact phone drawer rail):
5
+ // - Shared `useNavEntries()` model keeps Hanzo's exact product names & order
6
+ // (`Chat`, `Dev`, `Design`, `Studio` if opened, `Library`, `Scheduled tasks`,
7
+ // `Customize`, `Tabs`, `Betas`, and every hosted app or beta the reader may open;
8
+ // Developer mode hides none of them) across both the unified Sidebar and the 52px folded Rail.
9
+ // - Strictly monochrome active chrome (`bg="$raised"`, `color="$ink"`).
10
+ // - Every `render="button"` element uses `onClick` (never `onPress`).
38
11
  import { useI18n } from '@hanzo/i18n/react';
39
- import { Bot, CircleHelp, Compass, Ellipsis, FlaskConical, PanelLeft, Settings, Sparkles, Users } from 'lucide-react';
12
+ import { Bot, CircleHelp, Compass, Ellipsis, FlaskConical, PanelLeft, PanelLeftOpen, Plus, Settings, Sparkles, Users, Workflow, } from 'lucide-react';
40
13
  import { useState } from 'react';
41
- import { Text, XStack, YStack } from '@hanzo/gui';
14
+ import { XStack, YStack, Text } from '@hanzo/gui';
42
15
  import { MARKS, route } from '@hanzo/build';
43
- import { DropdownMenu } from '@hanzo/ui';
44
- import { SidebarItem } from '@hanzo/ui/chat';
16
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@hanzo/ui';
17
+ import { MoreMenu } from './MoreMenu.js';
45
18
  import { BetasDialog, useBetas } from './Betas.js';
46
19
  import { out } from './help.js';
47
20
  import { BETAS } from './lib/betas.js';
48
21
  import { HOSTED_APPS } from './lib/hosted.js';
49
22
  import { Account } from './Account.js';
50
- import { HEAD, MARK, RAIL, TOUCH_HEAD } from './ground.js';
51
- import { app, hosted, WORKSPACE } from './lib/host.js';
23
+ import { useDevMode } from './lib/dev-mode.js';
24
+ import { usePref } from './pref.js';
25
+ import { HEAD, MARK, TOUCH_HEAD } from './ground.js';
26
+ import { apex, app, design, flow, hosted, studio, talk, TERMINALS, WORKSPACE } from './lib/host.js';
27
+ import { site } from './where.js';
52
28
  export { MARK };
29
+ export const RAIL_FOLDED = 52;
53
30
  /** A mark on a touch screen, px: a thumb's 44. */
54
31
  const TOUCH = 44;
32
+ /** Where the pinned apps are kept: on the account (`usePref`), under the key this browser has always used, so earlier pins stay. */
33
+ export const NAV_PINNED_KEY = 'hanzo.nav.pinned';
34
+ export const DEFAULT_PINNED_NAV = ['chat', 'dev', 'design', 'library', 'tabs'];
35
+ const CORE_NAV_SET = new Set(DEFAULT_PINNED_NAV);
36
+ /** The reader's own order, with all 5 core apps (Chat, Dev, Design, Library, Tabs) anchored at the top and never dropped into More. */
37
+ export function normalizePinnedNav(list) {
38
+ const ordered = [...new Set(list.filter(Boolean))];
39
+ return [...DEFAULT_PINNED_NAV.filter((id) => !ordered.includes(id)), ...ordered];
40
+ }
41
+ /** `list` with `id` pinned or unpinned; the core apps stay. */
42
+ export function toggledPinnedNav(list, id) {
43
+ if (!id || CORE_NAV_SET.has(id))
44
+ return normalizePinnedNav(list);
45
+ return normalizePinnedNav(list.includes(id) ? list.filter((item) => item !== id) : [...list, id]);
46
+ }
47
+ /** `list` with `sourceId` moved to where `targetId` stands. */
48
+ export function reorderedPinnedNav(list, sourceId, targetId) {
49
+ if (!sourceId || !targetId || sourceId === targetId)
50
+ return normalizePinnedNav(list);
51
+ const without = list.filter((id) => id !== sourceId);
52
+ const at = without.indexOf(targetId);
53
+ without.splice(at < 0 ? without.length : at, 0, sourceId);
54
+ return normalizePinnedNav(without);
55
+ }
56
+ /** `list` with `id` swapped with its neighbour one place up (-1) or down (1) among `visible`, the pins the reader sees (one may be hidden): the keyboard's way to the order a drag makes. */
57
+ export function shiftedPinnedNav(list, id, delta, visible = list) {
58
+ const next = normalizePinnedNav(list);
59
+ const other = visible[visible.indexOf(id) + delta];
60
+ const from = next.indexOf(id);
61
+ const to = other === undefined ? -1 : next.indexOf(other);
62
+ if (from < 0 || to < 0)
63
+ return next;
64
+ [next[from], next[to]] = [next[to], next[from]];
65
+ return next;
66
+ }
67
+ /** The pinned apps, a toggle for one, a reorder and a move, kept on the account. */
68
+ export function usePinnedNav() {
69
+ const [kept, keep] = usePref(NAV_PINNED_KEY, [...DEFAULT_PINNED_NAV]);
70
+ const pinned = normalizePinnedNav(Array.isArray(kept) ? kept : DEFAULT_PINNED_NAV);
71
+ return [pinned, (id) => keep(toggledPinnedNav(pinned, id)), (src, target) => keep(reorderedPinnedNav(pinned, src, target)), (id, delta, visible) => keep(shiftedPinnedNav(pinned, id, delta, visible))];
72
+ }
55
73
  /** The places the rail holds beside the products, by the builder address each opens. */
56
74
  export const RAISED = { library: '-/artifacts', scheduled: '-/automations', customize: '-/customize' };
57
- /** Which of them a builder address stands on, if any, and so takes the sidebar: an agent's page is Customize's, an automation Scheduled tasks'. */
75
+ /** Which of them a builder address stands on, if any, and so takes the sidebar. */
58
76
  export function raised(at) {
59
77
  if (at === null)
60
78
  return null;
@@ -67,81 +85,324 @@ export function raised(at) {
67
85
  return 'customize';
68
86
  return null;
69
87
  }
70
- /** One mark: an icon button named for where it goes (`label`, already in the reader's language), its name its tooltip, lit where the reader is. */
71
- export function Mark({ label, on = false, onPress, children, ...rest }) {
72
- return (_jsx(XStack, { render: "button", "aria-label": label, ...{ title: label }, "aria-current": on ? 'page' : undefined, onPress: onPress, width: MARK, height: MARK, rounded: 12, items: "center", justify: "center", shrink: 0, cursor: "pointer", opacity: on ? 1 : 0.7, bg: on ? '$edge' : 'transparent', hoverStyle: { bg: on ? '$edge' : '$hover', opacity: 1 }, pressStyle: { bg: '$raised' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' },
73
- // A thumb's 44px on a touch screen.
74
- $touchable: { width: TOUCH, height: TOUCH }, ...rest, children: children }));
75
- }
76
- /** A place as a phone's menu lists it (`label`, already in the reader's language): a row on the sidebar's pitch, a thumb's 44 on a touch screen, lit where the reader is. */
77
- function Row({ label, on = false, onPress, icon, ...rest }) {
78
- return (_jsx(SidebarItem, { rounded: "$4", minH: 31, py: 0, px: "$2", $touchable: { minH: 44 }, active: on, icon: icon ? (_jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: icon })) : null, onPress: onPress, onKeyDown: (e) => {
79
- if (!onPress || (e.key !== 'Enter' && e.key !== ' '))
80
- return;
81
- e.preventDefault?.();
82
- onPress();
83
- }, ...rest, children: _jsx(Text, { fontSize: "$3", color: on ? '$ink' : '$quiet', children: label }) }));
84
- }
85
- /** The sidebar's toggle: the same mark wherever a host draws it. Its icon is the sidebar at the start edge, mirrored right to left. */
86
- export function Toggle({ open, onPress, label }) {
88
+ export const fullNavUrl = (href) => {
89
+ if (/^https?:\/\//.test(href))
90
+ return href;
91
+ if (typeof window === 'undefined')
92
+ return href;
93
+ return new URL(site(href), window.location.href).href;
94
+ };
95
+ export function useNavEntries({ host, mode, at, inside = null, onChat, onDev, onDesign, onStudio, onTabs, go, pins, }) {
87
96
  const { t } = useI18n();
88
- return (_jsx(Mark, { label: label ?? t(open ? 'Close sidebar' : 'Open sidebar'), "data-slot": "sidebar-toggle", "aria-expanded": open, onPress: onPress, children: _jsx(PanelLeft, { size: 18, "aria-hidden": true, "data-i18n-mirror": true }) }));
89
- }
90
- export function Rail({ host, mode, at, open, toggle, inside = null, rows = false, onChat, onDev, onDesign, onStudio, onTabs, go, onOrg, }) {
91
- const { t, dir } = useI18n();
97
+ const [devMode] = useDevMode();
98
+ const [pinnedIds, togglePin] = pins;
99
+ const { open: opened } = useBetas();
92
100
  const anon = host.person === null;
93
101
  const here = mode === 'dev' ? raised(at) : null;
94
102
  const to = (p) => () => go(app(p));
95
- // The products on hosts of their own, behind More; on a phone the raised places lead it.
96
- // Studio offers no Team, so on a laptop it draws no More.
97
103
  const team = mode !== 'studio' && mode !== 'design';
98
- const { open: opened } = useBetas();
99
- const [betas, setBetas] = useState(false);
100
- // The apps in beta this reader may open, each where it lives; those that draw inside the app have marks of their own.
101
- const granted = BETAS.filter((b) => b.href && b.embed === undefined && b.id !== 'studio' && opened(b.id));
102
- const apps = HOSTED_APPS.filter((a) => opened(a.id));
103
- // A link out of the app, or a place in it.
104
+ const rawGranted = BETAS.filter((b) => b.href && b.embed === undefined && b.id !== 'studio' && b.id !== 'flow' && opened(b.id));
105
+ const rawApps = HOSTED_APPS.filter((a) => opened(a.id));
104
106
  const reach = (address) => (address.startsWith('/') ? go(address) : out(address));
105
- const rest = [
106
- ...(rows
107
- ? [
108
- { key: 'library', label: t('Library'), icon: _jsx(MARKS.library.icon, { size: 16, "aria-hidden": true }), onSelect: to(RAISED.library) },
109
- { key: 'scheduled', label: t('Scheduled tasks'), icon: _jsx(MARKS.scheduled.icon, { size: 16, "aria-hidden": true }), onSelect: to(RAISED.scheduled) },
110
- { key: 'customize', label: t('Customize'), icon: _jsx(MARKS.customize.icon, { size: 16, "aria-hidden": true }), onSelect: to(RAISED.customize) },
111
- ...(team ? [{ type: 'separator', key: 'raised' }] : []),
112
- ]
113
- : []),
114
- ...(team
115
- ? [
116
- { key: 'bot', label: 'Bot', icon: _jsx(Bot, { size: 16, "aria-hidden": true }), onSelect: () => out('https://hanzo.bot') },
117
- { key: 'team', label: 'Team', icon: _jsx(Users, { size: 16, "aria-hidden": true }), onSelect: () => out(WORKSPACE) },
118
- { key: 'market', label: t('Marketplace'), icon: _jsx(Compass, { size: 16, "aria-hidden": true }), onSelect: () => out('https://hanzo.market') },
119
- ...granted.map((b) => ({ key: `beta-${b.id}`, label: b.name, icon: _jsx(Sparkles, { size: 16, "aria-hidden": true }), onSelect: () => reach(b.href) })),
120
- ]
121
- : []),
107
+ const pinnedSet = new Set(pinnedIds);
108
+ // Everything Hanzo showed before stays reachable without Developer mode (unpinned ones sit in More).
109
+ const apps = rawApps;
110
+ const granted = rawGranted;
111
+ const localTeamHref = typeof window !== 'undefined' && !apex(window.location.hostname) ? '/home' : WORKSPACE;
112
+ const localBotsHref = typeof window !== 'undefined' && !apex(window.location.hostname) ? '/bots' : 'https://hanzo.bot';
113
+ const allEntries = [
114
+ {
115
+ id: 'chat',
116
+ slot: 'rail-chat',
117
+ label: t('Chat'),
118
+ href: talk(),
119
+ pinnable: false,
120
+ on: mode === 'chat',
121
+ icon: _jsx(MARKS.chat.icon, { size: 17, "aria-hidden": true }),
122
+ onPress: onChat,
123
+ },
124
+ {
125
+ id: 'dev',
126
+ slot: 'rail-dev',
127
+ label: 'Dev',
128
+ href: app(''),
129
+ pinnable: false,
130
+ on: mode === 'dev' && !here,
131
+ icon: _jsx(MARKS.dev.icon, { size: 17, "aria-hidden": true }),
132
+ onPress: onDev,
133
+ },
134
+ ...(anon
135
+ ? []
136
+ : [
137
+ {
138
+ id: 'design',
139
+ slot: 'rail-design',
140
+ label: 'Design',
141
+ href: design(''),
142
+ pinnable: false,
143
+ on: mode === 'design',
144
+ icon: _jsx(MARKS.design.icon, { size: 17, "aria-hidden": true }),
145
+ onPress: () => onDesign?.(),
146
+ },
147
+ ]),
148
+ {
149
+ id: 'library',
150
+ slot: 'rail-library',
151
+ label: t('Library'),
152
+ href: app(RAISED.library),
153
+ pinnable: false,
154
+ on: here === 'library',
155
+ icon: _jsx(MARKS.library.icon, { size: 17, "aria-hidden": true }),
156
+ onPress: to(RAISED.library),
157
+ },
158
+ ...(anon
159
+ ? []
160
+ : [
161
+ {
162
+ id: 'scheduled',
163
+ slot: 'rail-scheduled',
164
+ label: t('Scheduled tasks'),
165
+ href: app(RAISED.scheduled),
166
+ on: here === 'scheduled',
167
+ icon: _jsx(MARKS.scheduled.icon, { size: 17, "aria-hidden": true }),
168
+ onPress: to(RAISED.scheduled),
169
+ },
170
+ {
171
+ id: 'customize',
172
+ slot: 'rail-customize',
173
+ label: t('Customize'),
174
+ href: app(RAISED.customize),
175
+ on: here === 'customize',
176
+ icon: _jsx(MARKS.customize.icon, { size: 17, "aria-hidden": true }),
177
+ onPress: to(RAISED.customize),
178
+ },
179
+ ...(opened('studio')
180
+ ? [
181
+ {
182
+ id: 'studio',
183
+ slot: 'rail-studio',
184
+ label: 'Studio',
185
+ href: studio(''),
186
+ on: mode === 'studio',
187
+ icon: _jsx(MARKS.studio.icon, { size: 17, "aria-hidden": true }),
188
+ onPress: onStudio,
189
+ },
190
+ ]
191
+ : []),
192
+ ...(opened('flow') || mode === 'flow'
193
+ ? [
194
+ {
195
+ id: 'flow',
196
+ slot: 'rail-flow',
197
+ label: 'Flow',
198
+ href: flow(''),
199
+ on: mode === 'flow',
200
+ icon: _jsx(Workflow, { size: 17, "aria-hidden": true }),
201
+ onPress: () => go(flow('')),
202
+ },
203
+ ]
204
+ : []),
205
+ {
206
+ id: 'tabs',
207
+ slot: 'rail-tabs',
208
+ label: 'Tabs',
209
+ href: TERMINALS,
210
+ pinnable: false,
211
+ on: mode === 'tabs',
212
+ icon: _jsx(MARKS.tabs.icon, { size: 17, "aria-hidden": true }),
213
+ onPress: onTabs,
214
+ },
215
+ {
216
+ id: 'betas',
217
+ slot: 'rail-betas',
218
+ label: t('Betas'),
219
+ href: '/beta',
220
+ on: mode === 'beta',
221
+ icon: _jsx(FlaskConical, { size: 17, "aria-hidden": true }),
222
+ onPress: () => go('/beta'),
223
+ },
224
+ ...apps.map((a) => ({
225
+ id: `app-${a.id}`,
226
+ slot: `rail-app-${a.id}`,
227
+ label: a.name,
228
+ href: hosted(a.id),
229
+ on: inside === a.id,
230
+ icon: _jsx(a.icon, { size: 17, "aria-hidden": true }),
231
+ onPress: () => go(hosted(a.id)),
232
+ })),
233
+ ]),
122
234
  ];
235
+ const externalEntries = !anon && team
236
+ ? [
237
+ {
238
+ id: 'ext-team',
239
+ slot: 'rail-ext-team',
240
+ label: 'Team',
241
+ href: localTeamHref,
242
+ external: localTeamHref.startsWith('http'),
243
+ on: false,
244
+ icon: _jsx(Users, { size: 17, "aria-hidden": true }),
245
+ onPress: () => reach(localTeamHref),
246
+ },
247
+ {
248
+ id: 'ext-bots',
249
+ slot: 'rail-ext-bots',
250
+ label: 'Bot',
251
+ href: localBotsHref,
252
+ external: localBotsHref.startsWith('http'),
253
+ on: false,
254
+ icon: _jsx(Bot, { size: 17, "aria-hidden": true }),
255
+ onPress: () => reach(localBotsHref),
256
+ },
257
+ {
258
+ id: 'ext-market',
259
+ slot: 'rail-ext-market',
260
+ label: t('Marketplace'),
261
+ href: 'https://hanzo.market',
262
+ external: true,
263
+ on: false,
264
+ icon: _jsx(Compass, { size: 17, "aria-hidden": true }),
265
+ onPress: () => out('https://hanzo.market'),
266
+ },
267
+ ...granted.map((b) => ({
268
+ id: `beta-${b.id}`,
269
+ slot: `rail-beta-${b.id}`,
270
+ label: b.name,
271
+ href: b.href,
272
+ external: !b.href.startsWith('/'),
273
+ on: false,
274
+ icon: _jsx(Sparkles, { size: 17, "aria-hidden": true }),
275
+ onPress: () => reach(b.href),
276
+ })),
277
+ ]
278
+ : [];
279
+ const combinedById = new Map([...allEntries, ...externalEntries].map((item) => [item.id, item]));
280
+ // Anonymous visitors see the public trio (Chat, Dev, Library).
281
+ const pinnedEntries = anon
282
+ ? allEntries
283
+ : pinnedIds.map((id) => combinedById.get(id)).filter((item) => Boolean(item));
284
+ const shownInPrimary = new Set(pinnedEntries.map((item) => item.id));
285
+ const moreEntries = anon
286
+ ? []
287
+ : [
288
+ ...allEntries.filter((item) => !shownInPrimary.has(item.id)),
289
+ ...externalEntries.filter((item) => !shownInPrimary.has(item.id)),
290
+ ];
291
+ return {
292
+ anon,
293
+ devMode,
294
+ team,
295
+ here,
296
+ apps,
297
+ granted,
298
+ pinnedIds,
299
+ pinnedSet,
300
+ togglePin,
301
+ allEntries,
302
+ externalEntries,
303
+ pinnedEntries,
304
+ moreEntries,
305
+ shownInPrimary,
306
+ reach,
307
+ };
308
+ }
309
+ /** One mark: an icon button named for where it goes (`label`), with optional instant Tooltip when folded. */
310
+ export function Mark({ label, on = false, tooltip = false, onPress, onClick, children, ...rest }) {
311
+ const handleClick = onClick ?? onPress;
312
+ const button = (_jsx(XStack, { render: "button", "aria-label": label, ...(tooltip ? {} : { title: label }), "aria-current": on ? 'page' : undefined, onClick: handleClick, width: MARK, height: MARK, rounded: 12, items: "center", justify: "center", shrink: 0, cursor: "pointer", opacity: on ? 1 : 0.76, bg: on ? '$raised' : 'transparent', hoverStyle: { bg: on ? '$raised' : '$hover', opacity: 1 }, pressStyle: { bg: '$raised' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, $touchable: { width: TOUCH, height: TOUCH }, ...rest, children: children }));
313
+ if (!tooltip)
314
+ return button;
315
+ return (_jsxs(Tooltip, { placement: "right", offset: 8, children: [_jsx(TooltipTrigger, { asChild: true, children: button }), _jsx(TooltipContent, { maxW: 240, px: "$2.5", py: "$1.5", rounded: "$3", bg: "var(--popover)", borderWidth: 1, borderColor: "$edge", z: "var(--z-tooltip)", children: _jsx(Text, { fontFamily: "$body", fontSize: "$1", fontWeight: "500", color: "$ink", children: label }) })] }));
316
+ }
317
+ /** The sidebar's toggle: the same mark wherever a host draws it. */
318
+ export function Toggle({ open, onPress, label }) {
319
+ const { t } = useI18n();
320
+ return (_jsx(Mark, { label: label ?? t(open ? 'Close sidebar' : 'Open sidebar'), "data-slot": "sidebar-toggle", "aria-expanded": open, onClick: onPress, children: _jsx(PanelLeft, { size: 18, "aria-hidden": true, "data-i18n-mirror": true }) }));
321
+ }
322
+ export function Rail({ host, mode, at, open, toggle, onOpen, onNew, compact = false, inside = null, onChat, onDev, onDesign, onStudio, onTabs, go, onOrg, pins, }) {
323
+ const { t, dir } = useI18n();
324
+ const [betas, setBetas] = useState(false);
325
+ const [dragId, setDragId] = useState(null);
326
+ const [dropId, setDropId] = useState(null);
327
+ const nav = useNavEntries({
328
+ host,
329
+ mode,
330
+ at,
331
+ inside,
332
+ onChat,
333
+ onDev,
334
+ onDesign,
335
+ onStudio,
336
+ onTabs,
337
+ go,
338
+ pins,
339
+ });
340
+ const { anon, apps, pinnedEntries, allEntries, externalEntries, shownInPrimary, reach } = nav;
123
341
  const betasDialog = _jsx(BetasDialog, { open: betas, onOpenChange: setBetas, go: reach });
124
- if (rows)
125
- return (_jsxs(YStack, { "data-slot": "places", render: "nav", "aria-label": t('Products'), pt: "$2", shrink: 0, children: [_jsxs(YStack, { role: "list", gap: 2, children: [anon ? null : (_jsx(YStack, { role: "listitem", children: _jsx(Row, { label: "Design", on: mode === 'design', onPress: onDesign, "data-slot": "place-design", icon: _jsx(MARKS.design.icon, { size: 16, "aria-hidden": true }) }) })), !anon && opened('studio') ? (_jsx(YStack, { role: "listitem", children: _jsx(Row, { label: "Studio", on: mode === 'studio', onPress: onStudio, "data-slot": "place-studio", icon: _jsx(MARKS.studio.icon, { size: 16, "aria-hidden": true }) }) })) : null, anon ? null : (_jsx(YStack, { role: "listitem", children: _jsx(Row, { label: "Tabs", on: mode === 'tabs', onPress: onTabs, "data-slot": "place-tabs", icon: _jsx(MARKS.tabs.icon, { size: 16, "aria-hidden": true }) }) })), apps.map((a) => (_jsx(YStack, { role: "listitem", children: _jsx(Row, { label: a.name, on: inside === a.id, onPress: () => go(hosted(a.id)), "data-slot": `place-app-${a.id}`, icon: _jsx(a.icon, { size: 16, "aria-hidden": true }) }) }, a.id))), anon ? null : (_jsx(YStack, { role: "listitem", children: _jsx(DropdownMenu, { placement: "bottom-start", minWidth: 220, trigger: _jsx(Row, { label: t('More'), "data-slot": "place-more", "aria-haspopup": "menu", icon: _jsx(Ellipsis, { size: 16, "aria-hidden": true }) }), items: rest }) }))] }), betasDialog] }));
126
- return (_jsxs(YStack, { "data-slot": "rail", render: "nav", "aria-label": t('Products'), width: RAIL, flex: 1,
127
- // As tall as the window and no taller: its marks scroll inside it (below), never the page.
128
- minH: 0,
129
- // The first mark stands at the pane's top edge, one head row high (HEAD), and the last at its foot:
130
- // the frame and drawer already leave `--pane-gap` below, so pb=0 aligns the account hover box symmetrically
131
- // with the inner pane's bottom corner.
132
- pt: (HEAD - MARK) / 2 + 2, pb: 0, gap: 3, shrink: 0, items: "center", $touchable: { pt: (TOUCH_HEAD - TOUCH) / 2, pb: 0 }, children: [toggle ? (_jsx(YStack, { children: _jsx(Toggle, { open: open, onPress: toggle }) })) : null, _jsxs(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", items: "center", gap: 4, width: "100%", "$platform-web": { scrollbarWidth: 'none' }, children: [_jsx(Mark, { label: t('Chat'), on: mode === 'chat', onPress: onChat, "data-slot": "rail-chat", children: _jsx(MARKS.chat.icon, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: "Dev", on: mode === 'dev' && !here, onPress: onDev, "data-slot": "rail-dev", children: _jsx(MARKS.dev.icon, { size: 18, "aria-hidden": true }) }), anon ? null : (_jsx(Mark, { label: "Design", on: mode === 'design', onPress: onDesign, "data-slot": "rail-design", children: _jsx(MARKS.design.icon, { size: 18, "aria-hidden": true }) })), !anon && opened('studio') ? (_jsx(Mark, { label: "Studio", on: mode === 'studio', onPress: onStudio, "data-slot": "rail-studio", children: _jsx(MARKS.studio.icon, { size: 18, "aria-hidden": true }) })) : null, anon ? null : (_jsx(Mark, { label: "Tabs", on: mode === 'tabs', onPress: onTabs, "data-slot": "rail-tabs", children: _jsx(MARKS.tabs.icon, { size: 18, "aria-hidden": true }) })), apps.map((a) => (_jsx(Mark, { label: a.name, on: inside === a.id, onPress: () => go(hosted(a.id)), "data-slot": `rail-app-${a.id}`, children: _jsx(a.icon, { size: 18, "aria-hidden": true }) }, a.id))), _jsx(Mark, { label: t('Library'), on: here === 'library', onPress: to(RAISED.library), "data-slot": "rail-library", children: _jsx(MARKS.library.icon, { size: 18, "aria-hidden": true }) }), anon ? null : (_jsx(Mark, { label: t('Scheduled tasks'), on: here === 'scheduled', onPress: to(RAISED.scheduled), "data-slot": "rail-scheduled", children: _jsx(MARKS.scheduled.icon, { size: 18, "aria-hidden": true }) })), anon ? null : (_jsx(Mark, { label: t('Customize'), on: here === 'customize', onPress: to(RAISED.customize), "data-slot": "rail-customize", children: _jsx(MARKS.customize.icon, { size: 18, "aria-hidden": true }) })), anon ? null : (_jsx(Mark, { label: t('Betas'), on: mode === 'beta', onPress: () => go('/beta'), "data-slot": "rail-betas", children: _jsx(FlaskConical, { size: 18, "aria-hidden": true }) })), betasDialog, !anon && rest.length ? (_jsx(DropdownMenu
133
- // Toward the content: right of the rail, left of it right to left.
134
- , {
135
- // Toward the content: right of the rail, left of it right to left.
136
- placement: dir === 'rtl' ? 'left-start' : 'right-start', minWidth: 220, trigger: _jsx(XStack, { render: "button", "aria-label": t('More'), ...{ title: t('More') }, "data-slot": "rail-more", width: MARK, height: MARK, rounded: 12, items: "center", justify: "center", cursor: "pointer", opacity: 0.62, hoverStyle: { bg: '$hover', opacity: 1 }, pressStyle: { bg: '$raised' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, $touchable: { width: 44, height: 44 }, children: _jsx(Ellipsis, { size: 18, "aria-hidden": true }) }), items: rest })) : null] }), anon ? (_jsxs(YStack, { gap: 4, items: "center", children: [_jsx(Mark, { label: t('See plans and pricing'), "data-slot": "anon-pricing", onPress: () => {
137
- if (typeof window !== 'undefined')
138
- window.location.assign('/pricing');
139
- }, children: _jsx(Sparkles, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Help'), "data-slot": "anon-help", onPress: () => {
140
- if (typeof window !== 'undefined')
141
- window.open('https://docs.hanzo.ai', '_blank', 'noopener,noreferrer');
142
- }, children: _jsx(CircleHelp, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Settings'), "data-slot": "anon-settings", onPress: () => {
143
- if (typeof window !== 'undefined') {
144
- window.dispatchEvent(new CustomEvent('hanzo:anon-settings', { detail: { open: true } }));
145
- }
146
- }, children: _jsx(Settings, { size: 18, "aria-hidden": true }) })] })) : (_jsx(Account, { host: host, narrow: true, onOrg: onOrg }))] }));
342
+ const unpinnedActive = allEntries.filter((item) => !shownInPrimary.has(item.id) && item.on);
343
+ const visibleMarks = [...pinnedEntries, ...unpinnedActive];
344
+ const overflowBuiltIn = allEntries.filter((item) => !shownInPrimary.has(item.id) && !item.on);
345
+ const overflowExternal = externalEntries.filter((item) => !shownInPrimary.has(item.id));
346
+ const foldedEntries = [...overflowBuiltIn, ...overflowExternal];
347
+ const expandHandler = onOpen ?? toggle;
348
+ const newLabel = mode === 'dev' ? t('New run') : mode === 'design' ? t('New design') : t('New chat');
349
+ const handleNew = onNew ??
350
+ (() => {
351
+ if (mode === 'dev')
352
+ go(app(''));
353
+ else if (mode === 'design')
354
+ go(design(''));
355
+ else if (mode === 'studio')
356
+ go(studio(''));
357
+ else
358
+ go(talk());
359
+ });
360
+ return (_jsx(TooltipProvider, { delay: 90, children: _jsxs(YStack, { "data-slot": "rail", "data-expanded": "false", render: "nav", "aria-label": t('Products'), width: RAIL_FOLDED, flex: 1, minH: 0, pt: (HEAD - MARK) / 2 + 2, pb: 0, gap: 4, shrink: 0, items: "center", $touchable: { pt: (TOUCH_HEAD - TOUCH) / 2, pb: 0 }, children: [!compact && expandHandler ? (_jsx(Mark, { label: t('Open sidebar'), "data-slot": "rail-expand", tooltip: true, onClick: expandHandler, children: _jsx(PanelLeftOpen, { size: 18, "aria-hidden": true, "data-i18n-mirror": true }) })) : null, !compact && mode !== 'beta' && mode !== 'hosted' ? (_jsx(Mark, { label: newLabel, "data-slot": "rail-new", tooltip: true, onClick: handleNew, children: _jsx(Plus, { size: 18, "aria-hidden": true }) })) : null, _jsxs(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", items: "center", gap: 4, width: "100%", "$platform-web": { scrollbarWidth: 'none' }, children: [visibleMarks.map((item) => {
361
+ const isDragging = dragId === item.id;
362
+ const isDropTarget = dropId === item.id && dragId !== null && dragId !== item.id;
363
+ return (_jsx(YStack, { width: "100%", items: "center", opacity: isDragging ? 0.4 : 1, borderTopWidth: isDropTarget ? 2 : 0, borderColor: "var(--foreground)", pt: isDropTarget ? 2 : 0, "$platform-web": { cursor: isDragging ? 'grabbing' : 'grab' }, ...{
364
+ draggable: !anon,
365
+ onDragStart: (e) => {
366
+ setDragId(item.id);
367
+ e.dataTransfer?.setData('text/plain', item.id);
368
+ if (e.dataTransfer)
369
+ e.dataTransfer.effectAllowed = 'move';
370
+ },
371
+ onDragOver: (e) => {
372
+ if (!dragId || dragId === item.id)
373
+ return;
374
+ e.preventDefault();
375
+ if (e.dataTransfer)
376
+ e.dataTransfer.dropEffect = 'move';
377
+ if (dropId !== item.id)
378
+ setDropId(item.id);
379
+ },
380
+ onDragLeave: () => {
381
+ if (dropId === item.id)
382
+ setDropId(null);
383
+ },
384
+ onDrop: (e) => {
385
+ e.preventDefault();
386
+ const src = dragId || e.dataTransfer?.getData('text/plain');
387
+ if (src && src !== item.id)
388
+ pins[2](src, item.id);
389
+ setDragId(null);
390
+ setDropId(null);
391
+ },
392
+ onDragEnd: () => {
393
+ setDragId(null);
394
+ setDropId(null);
395
+ },
396
+ }, children: _jsx(Mark, { label: item.label, on: item.on, tooltip: true, onClick: item.onPress, "data-slot": item.slot, "data-nav-id": item.id, children: item.icon }) }, item.id));
397
+ }), !anon && foldedEntries.length > 0 ? (_jsx(MoreMenu, { placement: dir === 'rtl' ? 'left-start' : 'right-start', minWidth: 220, maxHeight: 420, entries: foldedEntries, onPin: nav.togglePin, t: t, trigger: _jsx(XStack, { render: "button", "aria-label": t('More'), ...{ title: t('More') }, "data-slot": "rail-more", width: MARK, height: MARK, rounded: 12, items: "center", justify: "center", cursor: "pointer", opacity: 0.68, hoverStyle: { bg: '$hover', opacity: 1 }, pressStyle: { bg: '$raised' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, $touchable: { width: TOUCH, height: TOUCH }, children: _jsx(Ellipsis, { size: 18, "aria-hidden": true }) }) })) : null, betasDialog] }), anon ? (_jsxs(YStack, { gap: 4, items: "center", pb: "$1", children: [_jsx(Mark, { label: t('See plans and pricing'), "data-slot": "anon-pricing", tooltip: true, onClick: () => {
398
+ if (typeof window !== 'undefined')
399
+ window.location.assign('/pricing');
400
+ }, children: _jsx(Sparkles, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Help'), "data-slot": "anon-help", tooltip: true, onClick: () => {
401
+ if (typeof window !== 'undefined')
402
+ window.open('https://docs.hanzo.ai', '_blank', 'noopener,noreferrer');
403
+ }, children: _jsx(CircleHelp, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Settings'), "data-slot": "anon-settings", tooltip: true, onClick: () => {
404
+ if (typeof window !== 'undefined') {
405
+ window.dispatchEvent(new CustomEvent('hanzo:anon-settings', { detail: { open: true } }));
406
+ }
407
+ }, children: _jsx(Settings, { size: 18, "aria-hidden": true }) })] })) : (_jsx(YStack, { width: "100%", items: "center", pt: "$1", children: _jsx(Account, { host: host, narrow: true, onOrg: onOrg }) }))] }) }));
147
408
  }