ai-ax 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,7 @@ interface Item {
26
26
  color?: string;
27
27
  desc?: string;
28
28
  top?: boolean;
29
+ disabled?: boolean;
29
30
  }
30
31
  interface Point {
31
32
  x: number;
@@ -55,25 +56,21 @@ interface Storage {
55
56
  text: string;
56
57
  }
57
58
  //#endregion
58
- //#region src/client/ui/share/pop.d.ts
59
+ //#region src/client/ui/share/client.d.ts
59
60
  interface PopProps {
60
- items: Item[];
61
+ items?: Item[];
61
62
  value?: string;
62
- pick: (item: Item) => void;
63
+ pick?: (item: Item) => void;
63
64
  align?: 'left' | 'right';
64
65
  cls?: string;
65
66
  point?: Point | null;
66
- check: string;
67
+ check?: string;
68
+ children?: ReactNode;
67
69
  }
68
- declare const Pop: ({ cls, items, value, pick, style, check }: {
69
- cls: string;
70
- items: Item[];
71
- value?: string;
72
- pick: (m: Item) => void;
70
+ declare const Pop: ({ cls, items, value, pick, style, check, children }: PopProps & {
73
71
  style?: any;
74
- check: string;
75
72
  }) => import("react").JSX.Element;
76
- declare const Drop: ({ items, value, pick, align, cls, point, check }: PopProps) => import("react").JSX.Element;
73
+ declare const Drop: ({ items, value, pick, align, cls, point, check, children }: PopProps) => import("react").JSX.Element;
77
74
  //#endregion
78
75
  //#region src/client/ui/share/place.d.ts
79
76
  declare const place: (anchorEl?: Element | null, boxEl?: Element | null, input?: PlaceInput) => Placed | null;
@@ -127,19 +124,19 @@ interface Dropped {
127
124
  //#region src/client/ui/gesture/drop/drop.d.ts
128
125
  declare const createFileDrop: (zone: string, onDrop: (items: Dropped[], drop: string) => void, canDrop?: () => boolean) => (el: Element | null) => void;
129
126
  //#endregion
130
- //#region src/client/ui/gesture/utils.d.ts
127
+ //#region src/client/ui/gesture/utils/utils.d.ts
131
128
  declare const vec2: (x?: number, y?: number, out?: any[] | Float32Array<ArrayBuffer>) => Vec2;
132
129
  type Vec2 = [x: number, y: number];
133
130
  //#endregion
134
- //#region src/client/ui/gesture/drag.d.ts
131
+ //#region src/client/ui/gesture/utils/drag.d.ts
135
132
  declare const dragEvent: <El extends Element = Element>(onDrag?: () => void, canStart?: (event: Event) => boolean) => any;
136
133
  type DragState = ReturnType<typeof dragEvent>;
137
134
  //#endregion
138
- //#region src/client/ui/gesture/drop.d.ts
135
+ //#region src/client/ui/gesture/utils/drop.d.ts
139
136
  declare const dropEvent: <El extends Element = Element>(onDrop?: () => void, canStart?: (event: DragEvent) => boolean) => any;
140
137
  type DropState = ReturnType<typeof dropEvent>;
141
138
  //#endregion
142
- //#region src/client/ui/gesture/over/hit.d.ts
139
+ //#region src/client/ui/gesture/over/utils.d.ts
143
140
  type Skip = (el: Element, drop: string) => boolean;
144
141
  //#endregion
145
142
  //#region src/client/ui/gesture/over/over.d.ts
@@ -163,197 +160,38 @@ type Ghost = ReturnType<typeof createGhost>;
163
160
  declare const createGrab: (id: string, zone: string, ghost: Ghost, over: Over, done: (drop: string) => void) => (el: Element | null) => undefined;
164
161
  type Grab = ReturnType<typeof createGrab>;
165
162
  //#endregion
166
- //#region src/client/ui/chat/index.d.ts
167
- declare const AiChatButton: () => import("react").JSX.Element;
168
- declare const AiChat: () => import("react").JSX.Element | null;
169
- //#endregion
170
- //#region src/client/ui/chat/clicks.d.ts
171
- declare const openChat: () => void;
172
- declare const closeChat: () => void;
173
- declare const toggleChat: () => void;
174
- //#endregion
175
- //#region src/client/ui/chat/types.d.ts
176
- interface ChatTool {
177
- icon?: string;
178
- label: string;
179
- }
180
- interface ChatMsg {
181
- role: 'agent' | 'user';
182
- text: string;
183
- tools?: ChatTool[];
184
- }
185
- interface ChatPrompt {
186
- icon?: string;
187
- color?: string;
163
+ //#region src/client/ui/shell/atoms/chips.d.ts
164
+ interface ChipDef {
165
+ id: string;
188
166
  label: string;
189
- prompt?: string;
190
- }
191
- interface ChatHello {
192
- greet: string;
193
- title: string;
194
- desc: string;
195
- prompts: ChatPrompt[];
167
+ fixed?: boolean;
196
168
  }
197
- interface ChatMenu {
198
- useOpen: () => string;
169
+ interface ChipsProps {
170
+ chips: ChipDef[];
171
+ values: Record<string, string>;
172
+ menus: Record<string, Item[]>;
173
+ menu: string;
199
174
  flip: (id: string) => (e: any) => void;
200
- close: () => void;
201
- }
202
- interface ChatCommand {
203
- name: string;
204
- desc: string;
205
- label?: string;
206
- run: () => any;
207
- }
208
- interface ChatStreamTool {
209
- server: string;
210
- name: string;
211
- }
212
- interface ChatStreamItem {
213
- text: string;
214
- tools: ChatStreamTool[];
215
- error?: boolean;
216
- }
217
- interface ChatStreamSend {
218
- prompt: string;
219
- path?: string;
220
- model?: string;
221
- messages?: any[];
222
- headers?: Record<string, string>;
223
- }
224
- interface ChatStreamUpdate {
225
- items: ChatStreamItem[];
226
- delta: string;
227
- raw: string;
228
- }
229
- interface ChatStream {
230
- parse: (raw: string) => ChatStreamItem[];
231
- send: (input: ChatStreamSend, update?: (u: ChatStreamUpdate) => void) => Promise<ChatStreamItem[]>;
232
- }
233
- interface ChatConfig {
234
- send: (input: {
235
- prompt: string;
236
- }) => Promise<string>;
237
- stream: ChatStream;
238
- icon: string;
239
- path: string;
240
- headers: Record<string, string>;
241
- hello: () => ChatHello;
242
- menu: ChatMenu;
243
- commands: () => ChatCommand[];
244
- hints: (msgs: ChatMsg[]) => ChatCommand[];
245
- }
246
- //#endregion
247
- //#region src/client/ui/chat/config.d.ts
248
- declare const config: ChatConfig;
249
- declare const configure: (next: Partial<ChatConfig>) => undefined;
250
- //#endregion
251
- //#region src/client/ui/chat/stream.d.ts
252
- declare const toMsg: (it: ChatStreamItem) => ChatMsg;
253
- declare const restoreChat: (talks: {
254
- prompt: string;
255
- reply: string;
256
- tools: string[];
257
- }[]) => void;
258
- declare const runChat: (prompt: string) => Promise<string>;
259
- //#endregion
260
- //#region src/client/ui/chat/utils/commands/types.d.ts
261
- interface Command {
262
- name: string;
263
- desc: string;
264
- label?: string;
265
- run: () => any;
266
- }
267
- interface Habit {
268
- name: string;
269
- part: number;
270
- after: string;
271
- count: number;
272
- }
273
- interface CommandConfig {
274
- store: {
275
- list: () => Promise<Habit[]>;
276
- save: (habit: {
277
- name: string;
278
- part: number;
279
- after: string;
280
- }) => any;
281
- };
282
- deck: Command[];
283
- greet: {
284
- greet: string;
285
- title: string;
286
- desc: string;
287
- };
288
- starters: () => string[];
289
- pinned: () => string[];
290
- hinted: (msgs: any[]) => string[];
291
- }
292
- //#endregion
293
- //#region src/client/ui/chat/utils/commands/index.d.ts
294
- declare const createCommands: (config: CommandConfig) => {
295
- commands: () => Command[];
296
- hello: () => {
297
- greet: string;
298
- title: string;
299
- desc: string;
300
- prompts: {
301
- label: string;
302
- prompt: string;
175
+ pick: (chip: string, value: string) => (m: Item) => void;
176
+ clear: (chip: string) => (e: any) => void;
177
+ lead?: ReactNode;
178
+ view?: {
179
+ items: {
180
+ id: string;
181
+ icon: string;
303
182
  }[];
183
+ value: string;
184
+ pick: (id: string) => void;
185
+ };
186
+ search?: {
187
+ value: string;
188
+ set: (value: string) => void;
189
+ placeholder: string;
304
190
  };
305
- hints: (msgs: any[]) => Command[];
306
- prime: () => Promise<void>;
307
- };
308
- //#endregion
309
- //#region src/client/ui/chat/utils/history/types.d.ts
310
- interface HistoryTalk {
311
- prompt: string;
312
- reply: string;
313
- tools: string[];
314
- }
315
- interface HistoryStore {
316
- list: () => Promise<any[]>;
317
- load: (chatId: string) => Promise<{
318
- talks: any[];
319
- tools: any[];
320
- }>;
321
- save: (chatId: string, body: any) => any;
322
- }
323
- interface HistoryConfig {
324
- store: HistoryStore;
325
- show: (talks: HistoryTalk[]) => void;
326
191
  }
192
+ declare const Chips: ({ chips, values, menus, menu, flip, pick, clear, lead, view, search }: ChipsProps) => import("react").JSX.Element;
327
193
  //#endregion
328
- //#region src/client/ui/chat/utils/history/index.d.ts
329
- declare const createHistory: (config: HistoryConfig) => {
330
- wrap: <T extends {
331
- send: any;
332
- }>(base: T) => T;
333
- reset: () => void;
334
- load: (id: string) => Promise<void>;
335
- list: () => Promise<any[]>;
336
- };
337
- type History = ReturnType<typeof createHistory>;
338
- //#endregion
339
- //#region src/client/ui/chat/utils/markdown.d.ts
340
- declare const markdown: {
341
- render: (text: string) => string;
342
- plain: (text: string) => string;
343
- };
344
- //#endregion
345
- //#region src/client/ui/chat/state.d.ts
346
- declare const isChatBusy: () => boolean;
347
- declare const useChatBusy: () => boolean;
348
- //#endregion
349
- //#region src/client/ui/chat/const.d.ts
350
- declare const models: {
351
- id: string;
352
- label: string;
353
- desc: string;
354
- }[];
355
- //#endregion
356
- //#region src/client/ui/shell/band.d.ts
194
+ //#region src/client/ui/shell/atoms/band.d.ts
357
195
  interface CardItem extends Item {
358
196
  menu?: boolean;
359
197
  }
@@ -372,21 +210,7 @@ declare const Strip: ({ count, min, cls, children }: {
372
210
  declare const Cards: ({ cards, click, popup, count }: BandProps) => import("react").JSX.Element;
373
211
  declare const Band: (props: BandProps) => import("react").JSX.Element;
374
212
  //#endregion
375
- //#region src/client/ui/shell/app.d.ts
376
- interface AppProps {
377
- drawer: boolean;
378
- close: () => void;
379
- dropRef?: any;
380
- children: ReactNode;
381
- }
382
- declare const Frame: ({ drawer, close, dropRef, children }: AppProps) => import("react").JSX.Element;
383
- declare const Main: ({ drop, from, children }: {
384
- drop?: string;
385
- from?: string;
386
- children: ReactNode;
387
- }) => import("react").JSX.Element;
388
- //#endregion
389
- //#region src/client/ui/shell/head.d.ts
213
+ //#region src/client/ui/shell/atoms/head.d.ts
390
214
  interface SpHeadProps {
391
215
  icon: string;
392
216
  color: string;
@@ -400,6 +224,8 @@ interface MainHeadProps {
400
224
  open: () => void;
401
225
  title: ReactNode;
402
226
  back?: () => void;
227
+ undo?: () => void;
228
+ redo?: () => void;
403
229
  expand?: {
404
230
  label: string;
405
231
  icon: string;
@@ -409,13 +235,13 @@ interface MainHeadProps {
409
235
  actions: ReactNode;
410
236
  }
411
237
  declare const SpHead: ({ icon, color, label, home, actions, drawer }: SpHeadProps) => import("react").JSX.Element;
412
- declare const MainHead: ({ bar, open, title, back, expand, actions }: MainHeadProps) => import("react").JSX.Element;
413
238
  declare const HeadBtn: ({ icon, size, click, children }: {
414
239
  icon: string;
415
240
  size?: number;
416
241
  click: (e: any) => void;
417
242
  children?: ReactNode;
418
243
  }) => import("react").JSX.Element;
244
+ declare const MainHead: ({ bar, open, title, back, undo, redo, expand, actions }: MainHeadProps) => import("react").JSX.Element;
419
245
  declare const SpBtn: ({ icon, size, click, children }: {
420
246
  icon: string;
421
247
  size?: number;
@@ -424,55 +250,6 @@ declare const SpBtn: ({ icon, size, click, children }: {
424
250
  }) => import("react").JSX.Element;
425
251
  declare const MoreIcon: string;
426
252
  //#endregion
427
- //#region src/client/ui/shell/side.d.ts
428
- interface BrandProps {
429
- icon: string;
430
- color: string;
431
- label: string;
432
- click: () => void;
433
- }
434
- interface SideProps {
435
- brand: BrandProps;
436
- bar: boolean;
437
- drawer: boolean;
438
- fold: () => void;
439
- close: () => void;
440
- press: (e: any) => void;
441
- storage: Storage;
442
- upgrade: () => void;
443
- menu?: ReactNode;
444
- more: (e: any) => void;
445
- children: ReactNode;
446
- }
447
- declare const Brand: ({ icon, color, label, click }: BrandProps) => import("react").JSX.Element;
448
- declare const Storage_: ({ storage, upgrade, menu, more }: Pick<SideProps, 'storage' | 'upgrade' | 'menu' | 'more'>) => import("react").JSX.Element;
449
- declare const Side: ({ brand, bar, drawer, fold, close, press, storage, upgrade, menu, more, children }: SideProps) => import("react").JSX.Element;
450
- //#endregion
451
- //#region src/client/ui/shell/row.d.ts
452
- interface RowProps {
453
- depth?: number;
454
- on?: boolean;
455
- open?: boolean;
456
- turn?: (e: any) => void;
457
- icon: string;
458
- color?: string;
459
- label: ReactNode;
460
- drop?: string;
461
- mark?: string;
462
- from?: string;
463
- click?: (e: any) => void;
464
- dclick?: (e: any) => void;
465
- rclick?: (e: any) => void;
466
- dragRef?: any;
467
- children?: ReactNode;
468
- }
469
- declare const rowCls: (on: boolean) => string;
470
- declare const Fold: ({ open, turn }: {
471
- open?: boolean;
472
- turn?: (e: any) => void;
473
- }) => import("react").JSX.Element;
474
- declare const Row: ({ depth, on, open, turn, icon, color, label, drop, mark, from, click, dclick, rclick, dragRef, children }: RowProps) => import("react").JSX.Element;
475
- //#endregion
476
253
  //#region src/client/ui/drive/types.d.ts
477
254
  interface Obj {
478
255
  path: string;
@@ -498,27 +275,30 @@ interface DriveConfig {
498
275
  base: string;
499
276
  trash: string;
500
277
  editors: string[];
278
+ self: string;
501
279
  }
502
280
  //#endregion
503
- //#region src/client/ui/shell/tree.d.ts
504
- interface TreeProps {
505
- files: Entry[];
506
- parent: string;
507
- depth: number;
508
- expand: string[];
509
- active: string;
281
+ //#region src/client/ui/shell/atoms/list.d.ts
282
+ interface ListProps {
283
+ rows: Entry[];
510
284
  kinds: Record<string, {
511
285
  icon: string;
512
286
  color: string;
513
287
  }>;
514
- fold: (id: string) => (e: any) => void;
515
- enter: (id: string) => (e: any) => void;
288
+ menu: string;
289
+ point: Point | null;
290
+ flip: (id: string) => (e: any) => void;
291
+ context: (id: string) => (e: any) => void;
516
292
  open: (e: Entry) => (ev: any) => void;
517
- menu: (e: Entry) => ReactNode;
518
- rclick: (e: Entry) => (ev: any) => void;
293
+ pick: (e: Entry) => (m: Item) => void;
519
294
  drag: (id: string, zone?: string) => any;
520
295
  }
521
- declare const DriveTree: (props: TreeProps) => any;
296
+ declare const emptyLabel = "ファイルがありません";
297
+ declare const Tile: ({ e, kinds }: {
298
+ e: Entry;
299
+ kinds: ListProps['kinds'];
300
+ }) => import("react").JSX.Element;
301
+ declare const FileList: ({ rows, kinds, menu, point, flip, context, open, pick, drag }: ListProps) => import("react").JSX.Element;
522
302
  //#endregion
523
303
  //#region src/client/ui/shell/clicks.d.ts
524
304
  declare const openDrawer: (e: any) => void;
@@ -526,7 +306,246 @@ declare const closeDrawer: () => void;
526
306
  declare const atPoint: (e: any) => void;
527
307
  declare const noPoint: () => void;
528
308
  //#endregion
529
- //#region src/client/ui/shell/state.d.ts
309
+ //#region src/client/ui/shell/shell.d.ts
310
+ interface ShellNames {
311
+ menu: string;
312
+ setMenu: string;
313
+ open: string;
314
+ }
315
+ interface Intent {
316
+ name: string;
317
+ input?: object;
318
+ }
319
+ interface ShellInput {
320
+ names?: Partial<ShellNames>;
321
+ onClose?: () => void;
322
+ create?: string;
323
+ createId?: string;
324
+ intents?: Record<string, Intent>;
325
+ insert?: (m: Item) => void;
326
+ fallback?: (m: Item) => Intent | undefined;
327
+ onPage?: (m: Item) => boolean;
328
+ }
329
+ declare const createShell: (ai: any, input?: ShellInput) => {
330
+ closeShell: () => void;
331
+ press: (e: any) => void;
332
+ flip: (id: string) => (e: any) => void;
333
+ context: (id: string) => (e: any) => void;
334
+ foldTree: (path: string) => (e: any) => void;
335
+ treeClick: (path: string) => () => void;
336
+ goMode: (mode: string) => () => void;
337
+ openFile: (e: Entry) => (ev: any) => undefined;
338
+ pickFile: (e: Entry) => () => void;
339
+ askName: (current: string) => string | null;
340
+ pickHome: (m: Item) => undefined;
341
+ pickRow: (e: Entry) => (m: Item) => undefined;
342
+ pickStorage: (m: Item) => undefined;
343
+ pickInsert: (m: Item) => void;
344
+ pickCard: (c: Item & {
345
+ menu?: boolean;
346
+ }) => (e: any) => void;
347
+ pickPage: (m: Item) => undefined;
348
+ flipSetting: (id: string) => undefined;
349
+ pickChip: (chip: string, value: string) => (m: Item) => void;
350
+ clearChip: (chip: string) => (e: any) => void;
351
+ openDrawer: typeof openDrawer;
352
+ grab: (id: string, zone?: string) => (el: Element | null) => undefined;
353
+ drop: (el: Element | null) => void;
354
+ target: () => string;
355
+ isFolderMode: () => boolean;
356
+ };
357
+ type Shell = ReturnType<typeof createShell>;
358
+ //#endregion
359
+ //#region src/client/ui/shell/types.d.ts
360
+ interface NavLink {
361
+ id: string;
362
+ icon: string;
363
+ label: string;
364
+ tree?: string;
365
+ drop?: string;
366
+ from?: string;
367
+ menu?: string;
368
+ }
369
+ interface Kind {
370
+ icon: string;
371
+ color: string;
372
+ }
373
+ interface Expand {
374
+ label: string;
375
+ icon: string;
376
+ on: boolean;
377
+ click: () => void;
378
+ }
379
+ interface ShellSpec {
380
+ ai: any;
381
+ shell: Shell;
382
+ brand: {
383
+ icon: string;
384
+ color: string;
385
+ label: string;
386
+ };
387
+ kinds: Record<string, Kind>;
388
+ links: NavLink[];
389
+ service: string;
390
+ file: string;
391
+ fallback: () => string;
392
+ bandCards: Item[];
393
+ bandModes?: string[];
394
+ bandLabel: string;
395
+ titles: Record<string, string>;
396
+ helpLines: string[];
397
+ user: ReactNode;
398
+ popup: () => ReactNode;
399
+ leaf: () => ReactNode;
400
+ editor: () => ReactNode;
401
+ title: () => ReactNode;
402
+ cover?: () => ReactNode;
403
+ expand?: () => Expand;
404
+ history?: boolean;
405
+ extra?: () => ReactNode;
406
+ }
407
+ //#endregion
408
+ //#region src/client/ui/shell/atoms/layout.d.ts
409
+ declare const Layout: ({ spec, close, children }: {
410
+ spec: ShellSpec;
411
+ close?: () => void;
412
+ children?: ReactNode;
413
+ }) => import("react").JSX.Element;
414
+ declare const ItemsPopup: ({ items, pick }: {
415
+ items: any[];
416
+ pick: (m: any) => void;
417
+ }) => import("react").JSX.Element;
418
+ //#endregion
419
+ //#region src/client/ui/shell/atoms/links.d.ts
420
+ declare const TreeMore: ({ spec, e, zone }: {
421
+ spec: ShellSpec;
422
+ e: Entry;
423
+ zone?: string;
424
+ }) => import("react").JSX.Element;
425
+ declare const SideBar: ({ spec, drawer, upgrade }: {
426
+ spec: ShellSpec;
427
+ drawer: boolean;
428
+ upgrade: () => void;
429
+ }) => import("react").JSX.Element;
430
+ //#endregion
431
+ //#region src/client/ui/shell/atoms/main.d.ts
432
+ interface AppProps {
433
+ drawer: boolean;
434
+ close: () => void;
435
+ dropRef?: any;
436
+ children: ReactNode;
437
+ }
438
+ declare const Frame: ({ drawer, close, dropRef, children }: AppProps) => import("react").JSX.Element;
439
+ declare const Main: ({ drop, from, children }: {
440
+ drop?: string;
441
+ from?: string;
442
+ children: ReactNode;
443
+ }) => import("react").JSX.Element;
444
+ //#endregion
445
+ //#region src/client/ui/shell/atoms/page.d.ts
446
+ interface SettingsProps {
447
+ value: Record<string, boolean>;
448
+ flip: (id: string) => void;
449
+ }
450
+ declare const SettingsPage: ({ value, flip }: SettingsProps) => import("react").JSX.Element;
451
+ declare const HelpPage: ({ lines }: {
452
+ lines: string[];
453
+ }) => import("react").JSX.Element;
454
+ declare const ShortcutsPage: () => import("react").JSX.Element;
455
+ declare const Pages: ({ mode, lines, value, flip }: {
456
+ mode: string;
457
+ lines: string[];
458
+ } & SettingsProps) => import("react").JSX.Element | null;
459
+ //#endregion
460
+ //#region src/client/ui/shell/atoms/row.d.ts
461
+ interface RowProps {
462
+ depth?: number;
463
+ on?: boolean;
464
+ open?: boolean;
465
+ turn?: (e: any) => void;
466
+ icon: string;
467
+ color?: string;
468
+ label: ReactNode;
469
+ drop?: string;
470
+ mark?: string;
471
+ from?: string;
472
+ click?: (e: any) => void;
473
+ dclick?: (e: any) => void;
474
+ rclick?: (e: any) => void;
475
+ dragRef?: any;
476
+ children?: ReactNode;
477
+ }
478
+ interface RowBtnProps {
479
+ icon: string;
480
+ size?: number;
481
+ cls?: string;
482
+ click: (e: any) => void;
483
+ children?: ReactNode;
484
+ }
485
+ declare const rowCls: (on: boolean) => string;
486
+ declare const Fold: ({ open, turn }: {
487
+ open?: boolean;
488
+ turn?: (e: any) => void;
489
+ }) => import("react").JSX.Element;
490
+ declare const Row: ({ depth, on, open, turn, icon, color, label, drop, mark, from, click, dclick, rclick, dragRef, children }: RowProps) => import("react").JSX.Element;
491
+ declare const RowBtn: ({ icon, size, cls, click, children }: RowBtnProps) => import("react").JSX.Element;
492
+ declare const Caret: (props: Omit<RowBtnProps, 'icon'>) => import("react").JSX.Element;
493
+ declare const More: (props: Omit<RowBtnProps, 'icon'>) => import("react").JSX.Element;
494
+ //#endregion
495
+ //#region src/client/ui/shell/atoms/side.d.ts
496
+ interface BrandProps {
497
+ icon: string;
498
+ color: string;
499
+ label: string;
500
+ click: () => void;
501
+ }
502
+ interface SideProps {
503
+ brand: BrandProps;
504
+ bar: boolean;
505
+ drawer: boolean;
506
+ fold: () => void;
507
+ close: () => void;
508
+ press: (e: any) => void;
509
+ storage: Storage;
510
+ upgrade: () => void;
511
+ menu?: ReactNode;
512
+ more: (e: any) => void;
513
+ children: ReactNode;
514
+ }
515
+ declare const Brand: ({ icon, color, label, click }: BrandProps) => import("react").JSX.Element;
516
+ declare const Storage_: ({ storage, upgrade, menu, more }: Pick<SideProps, 'storage' | 'upgrade' | 'menu' | 'more'>) => import("react").JSX.Element;
517
+ declare const Side: ({ brand, bar, drawer, fold, close, press, storage, upgrade, menu, more, children }: SideProps) => import("react").JSX.Element;
518
+ //#endregion
519
+ //#region src/client/ui/shell/atoms/tree.d.ts
520
+ interface TreeProps {
521
+ files: Entry[];
522
+ parent: string;
523
+ depth: number;
524
+ expand: string[];
525
+ active: string;
526
+ kinds: Record<string, {
527
+ icon: string;
528
+ color: string;
529
+ }>;
530
+ fold: (id: string) => (e: any) => void;
531
+ enter: (id: string) => (e: any) => void;
532
+ file?: (e: Entry) => (ev: any) => void;
533
+ open: (e: Entry) => (ev: any) => void;
534
+ menu: (e: Entry) => ReactNode;
535
+ rclick: (e: Entry) => (ev: any) => void;
536
+ drag: (id: string, zone?: string) => any;
537
+ }
538
+ declare const DriveTree: (props: TreeProps) => any;
539
+ //#endregion
540
+ //#region src/client/ui/shell/atoms.d.ts
541
+ declare const drawerAtom: {
542
+ value: boolean;
543
+ listeners: Set<(v: boolean) => void>;
544
+ };
545
+ declare const pointAtom: {
546
+ value: Point | null;
547
+ listeners: Set<(v: Point | null) => void>;
548
+ };
530
549
  declare const isDrawerOpen: () => boolean;
531
550
  declare const useDrawer: () => boolean;
532
551
  declare const usePoint: () => Point | null;
@@ -536,10 +555,38 @@ declare const storageName = "STORAGE";
536
555
  declare const upgradeLabel = "アップグレード";
537
556
  declare const upgradeUrl = "https://stripe.com";
538
557
  declare const emptyTrashAsk = "ゴミ箱を空にしますか?中のアイテムは完全に削除されます";
558
+ declare const folderAsk = "新しいフォルダ";
559
+ declare const folderDefault = "無題のフォルダ";
560
+ declare const renameAsk = "名前を変更";
561
+ declare const rootTitle = "All files";
562
+ declare const unpinLabel = "ピン留めを解除";
539
563
  declare const storageMenu: Item[];
540
564
  declare const pageMenu: Item[];
541
565
  declare const spMenu: Item[];
566
+ declare const bandIcon: string;
542
567
  declare const moreItems: (on: boolean, label: string, items: Item[]) => Item[];
568
+ declare const homeMenu: Item[];
569
+ declare const treeFolderMenu: Item[];
570
+ declare const treeFileMenu: Item[];
571
+ declare const trashMenu: Item[];
572
+ declare const pinLabel: (e: Entry) => (m: Item) => Item;
573
+ declare const treeMenuOf: (e: Entry) => Item[];
574
+ interface LeafInput {
575
+ extra?: Item[];
576
+ pinned?: boolean;
577
+ copy?: boolean;
578
+ pin?: boolean;
579
+ }
580
+ declare const leafMenu: ({ extra, pinned, copy, pin }?: LeafInput) => Item[];
581
+ declare const settingRows: Item[];
582
+ declare const shortcutRows: {
583
+ keys: string;
584
+ label: string;
585
+ }[];
586
+ declare const pageTitles: Record<string, string>;
587
+ declare const pageModes: string[];
588
+ declare const infoOf: (e: Entry) => string;
589
+ declare const titleOf: (folder: string) => string;
543
590
  //#endregion
544
591
  //#region src/client/ui/shell/icons.d.ts
545
592
  declare const icons: {
@@ -586,6 +633,11 @@ declare const configure$1: (next: Partial<DriveConfig>) => undefined;
586
633
  //#endregion
587
634
  //#region src/client/ui/drive/client.d.ts
588
635
  declare const url: (path: string) => string;
636
+ declare const openPath: () => string;
637
+ declare const editorUrl: (kind: string, id: string) => string;
638
+ declare const openEntry: ({ id }: {
639
+ id: string;
640
+ }, ai: any) => string;
589
641
  declare const r2: {
590
642
  list(prefix?: string): Promise<Obj[]>;
591
643
  get(path: string): Promise<Response>;
@@ -620,6 +672,7 @@ declare const crumbSegs: (path: string) => {
620
672
  name: string;
621
673
  path: string;
622
674
  }[];
675
+ declare const modeRows: (files: Entry[], mode: string, folder: string, service: string) => Entry[];
623
676
  declare const usedOf: (files: Entry[]) => number;
624
677
  //#endregion
625
678
  //#region src/client/ui/drive/acts.d.ts
@@ -647,5 +700,249 @@ declare const renameFile: ({ id, name }: {
647
700
  }, ai: any) => Promise<string>;
648
701
  declare const emptyTrash: (_input: any, ai: any) => Promise<string>;
649
702
  declare const usedBytes: (ai: any) => number;
703
+ declare const createFile: ({ kind, name, parent }: {
704
+ kind: string;
705
+ name?: string;
706
+ parent?: string;
707
+ }, ai: any) => Promise<Entry>;
708
+ declare const togglePin: ({ id }: {
709
+ id: string;
710
+ }, ai: any) => string;
711
+ //#endregion
712
+ //#region src/client/ui/drive/pick.d.ts
713
+ interface Uploaded {
714
+ folder: string;
715
+ count: number;
716
+ }
717
+ declare const uploadFiles: ({ parent }: {
718
+ parent?: string;
719
+ }, ai: any) => Promise<string>;
720
+ declare const uploadFolder: ({ parent }: {
721
+ parent?: string;
722
+ }, ai: any) => Promise<Uploaded | string>;
723
+ declare const downloadFile: ({ id }: {
724
+ id: string;
725
+ }, ai: any) => Promise<string>;
726
+ //#endregion
727
+ //#region src/client/ui/drive/intent.d.ts
728
+ declare const gotoFile: (path: string, name?: string, input?: any) => void;
729
+ declare const runIntent: (ai: any) => Promise<string>;
730
+ //#endregion
731
+ //#region src/client/ui/drive/boot.d.ts
732
+ interface BootInput {
733
+ lobby: string;
734
+ wire?: (file: string) => void;
735
+ synced?: () => Promise<any> | void;
736
+ }
737
+ interface BootRoute {
738
+ file: string;
739
+ room?: string;
740
+ path?: string;
741
+ synced: () => Promise<void>;
742
+ }
743
+ declare const bootShell: (ai: any, { lobby, wire, synced }: BootInput) => BootRoute;
744
+ //#endregion
745
+ //#region src/client/ui/drive/route.d.ts
746
+ interface Route {
747
+ path: string;
748
+ mode: string;
749
+ folder: boolean;
750
+ query: boolean;
751
+ }
752
+ declare const readRoute: () => Route;
753
+ declare const fileOf: (route: Route) => string;
754
+ declare const applyRoute: (ai: any, route: Route) => undefined;
755
+ declare const urlOf: (ai: any, file: string) => string;
756
+ declare const watchUrl: (ai: any, file: string) => void;
757
+ //#endregion
758
+ //#region src/client/ui/chat/client.d.ts
759
+ declare const AiChatButton: () => import("react").JSX.Element;
760
+ declare const AiChat: () => import("react").JSX.Element | null;
761
+ //#endregion
762
+ //#region src/client/ui/chat/clicks.d.ts
763
+ declare const openChat: () => void;
764
+ declare const closeChat: () => void;
765
+ declare const toggleChat: () => void;
766
+ //#endregion
767
+ //#region src/client/ui/chat/types.d.ts
768
+ interface ChatTool {
769
+ icon?: string;
770
+ label: string;
771
+ }
772
+ interface ChatMsg {
773
+ role: 'agent' | 'user';
774
+ text: string;
775
+ tools?: ChatTool[];
776
+ }
777
+ interface ChatPrompt {
778
+ icon?: string;
779
+ color?: string;
780
+ label: string;
781
+ prompt?: string;
782
+ }
783
+ interface ChatHello {
784
+ greet: string;
785
+ title: string;
786
+ desc: string;
787
+ prompts: ChatPrompt[];
788
+ }
789
+ interface ChatMenu {
790
+ useOpen: () => string;
791
+ flip: (id: string) => (e: any) => void;
792
+ close: () => void;
793
+ }
794
+ interface ChatCommand {
795
+ name: string;
796
+ desc: string;
797
+ label?: string;
798
+ run: () => any;
799
+ }
800
+ interface ChatStreamTool {
801
+ server: string;
802
+ name: string;
803
+ }
804
+ interface ChatStreamItem {
805
+ text: string;
806
+ tools: ChatStreamTool[];
807
+ error?: boolean;
808
+ }
809
+ interface ChatStreamSend {
810
+ prompt: string;
811
+ path?: string;
812
+ model?: string;
813
+ messages?: any[];
814
+ headers?: Record<string, string>;
815
+ }
816
+ interface ChatStreamUpdate {
817
+ items: ChatStreamItem[];
818
+ delta: string;
819
+ raw: string;
820
+ }
821
+ interface ChatStream {
822
+ parse: (raw: string) => ChatStreamItem[];
823
+ send: (input: ChatStreamSend, update?: (u: ChatStreamUpdate) => void) => Promise<ChatStreamItem[]>;
824
+ }
825
+ interface ChatConfig {
826
+ send: (input: {
827
+ prompt: string;
828
+ }) => Promise<string>;
829
+ stream: ChatStream;
830
+ icon: string;
831
+ path: string;
832
+ headers: Record<string, string>;
833
+ hello: () => ChatHello;
834
+ menu: ChatMenu;
835
+ commands: () => ChatCommand[];
836
+ hints: (msgs: ChatMsg[]) => ChatCommand[];
837
+ }
838
+ //#endregion
839
+ //#region src/client/ui/chat/config.d.ts
840
+ declare const config: ChatConfig;
841
+ declare const configure: (next: Partial<ChatConfig>) => undefined;
842
+ //#endregion
843
+ //#region src/client/ui/chat/stream.d.ts
844
+ declare const toMsg: (it: ChatStreamItem) => ChatMsg;
845
+ declare const restoreChat: (talks: {
846
+ prompt: string;
847
+ reply: string;
848
+ tools: string[];
849
+ }[]) => void;
850
+ declare const runChat: (prompt: string) => Promise<string>;
851
+ //#endregion
852
+ //#region src/client/ui/chat/utils/commands/types.d.ts
853
+ interface Command {
854
+ name: string;
855
+ desc: string;
856
+ label?: string;
857
+ run: () => any;
858
+ }
859
+ interface Habit {
860
+ name: string;
861
+ part: number;
862
+ after: string;
863
+ count: number;
864
+ }
865
+ interface CommandConfig {
866
+ store: {
867
+ list: () => Promise<Habit[]>;
868
+ save: (habit: {
869
+ name: string;
870
+ part: number;
871
+ after: string;
872
+ }) => any;
873
+ };
874
+ deck: Command[];
875
+ greet: {
876
+ greet: string;
877
+ title: string;
878
+ desc: string;
879
+ };
880
+ starters: () => string[];
881
+ pinned: () => string[];
882
+ hinted: (msgs: any[]) => string[];
883
+ }
884
+ //#endregion
885
+ //#region src/client/ui/chat/utils/commands/index.d.ts
886
+ declare const createCommands: (config: CommandConfig) => {
887
+ commands: () => Command[];
888
+ hello: () => {
889
+ greet: string;
890
+ title: string;
891
+ desc: string;
892
+ prompts: {
893
+ label: string;
894
+ prompt: string;
895
+ }[];
896
+ };
897
+ hints: (msgs: any[]) => Command[];
898
+ prime: () => Promise<void>;
899
+ };
900
+ //#endregion
901
+ //#region src/client/ui/chat/utils/history/types.d.ts
902
+ interface HistoryTalk {
903
+ prompt: string;
904
+ reply: string;
905
+ tools: string[];
906
+ }
907
+ interface HistoryStore {
908
+ list: () => Promise<any[]>;
909
+ load: (chatId: string) => Promise<{
910
+ talks: any[];
911
+ tools: any[];
912
+ }>;
913
+ save: (chatId: string, body: any) => any;
914
+ }
915
+ interface HistoryConfig {
916
+ store: HistoryStore;
917
+ show: (talks: HistoryTalk[]) => void;
918
+ }
919
+ //#endregion
920
+ //#region src/client/ui/chat/utils/history/index.d.ts
921
+ declare const createHistory: (config: HistoryConfig) => {
922
+ wrap: <T extends {
923
+ send: any;
924
+ }>(base: T) => T;
925
+ reset: () => void;
926
+ load: (id: string) => Promise<void>;
927
+ list: () => Promise<any[]>;
928
+ };
929
+ type History = ReturnType<typeof createHistory>;
930
+ //#endregion
931
+ //#region src/client/ui/chat/utils/markdown.d.ts
932
+ declare const markdown: {
933
+ render: (text: string) => string;
934
+ plain: (text: string) => string;
935
+ };
936
+ //#endregion
937
+ //#region src/client/ui/chat/atoms.d.ts
938
+ declare const isChatBusy: () => boolean;
939
+ declare const useChatBusy: () => boolean;
940
+ //#endregion
941
+ //#region src/client/ui/chat/const.d.ts
942
+ declare const models: {
943
+ id: string;
944
+ label: string;
945
+ desc: string;
946
+ }[];
650
947
  //#endregion
651
- export { AiChat, AiChatButton, type AppProps, Band, type BandProps, Brand, type BrandProps, type CardItem, Cards, type ChatCommand, type ChatConfig, type ChatHello, type ChatMsg, type ChatPrompt, type ChatTool, type Command, type CommandConfig, type DragState, type DriveConfig, DriveTree, Drop, type DropState, type Dropped, type Entry, Fold, Frame, GB, type Grab, type Habit, HeadBtn, type History, type HistoryConfig, type HistoryStore, type HistoryTalk, Icon, type Item, KB, MB, Main, MainHead, type MainHeadProps, MoreIcon, type Obj, type Over, type PlaceInput, type Placed, type Point, Pop, Row, type RowProps, SP_BREAK, type Service, Side, type SideProps, type Skip, Slot, SpBtn, SpHead, type SpHeadProps, type Storage, Storage_ as StorageBox, Strip, type TreeProps, ago, ancestors, atPoint, band, blue, config as chatConfig, closeChat, closeDrawer, configure as configureChat, configure$1 as configureDrive, createCommands, createFileDrag, createFileDrop, createHistory, createOver, crumbSegs, dragEvent, config$1 as driveConfig, dropEvent, edge, emptyTrash, emptyTrashAsk, entryOf, extOf, fill, folderRows, freeName, grid, icons, idOf, ink, isChatBusy, isDrawerOpen, isFolder, kindOf, kindRows, line, markdown, mirrorFile, mkdirp, models, moreItems, moveFile, mute, noPoint, openChat, openDrawer, pageMenu, pale, parentOf, pathname, place, prev, quota, r2, recentRows, removeFile, renameFile, restoreChat, restoreFile, rowCls, runChat, saveFile, side, sizeOf, spMenu, stamp, stop, storageMenu, storageName, storageRows, storeFiles, syncFiles, toMsg, toggleChat, trashRows, treeOf, unique, upgradeLabel, upgradeUrl, uploadAlert, uploadMax, url, usageOf, useChatBusy, useDrawer, usePoint, usedBytes, usedOf, vec2 };
948
+ export { AiChat, AiChatButton, AppProps, Band, BandProps, type BootInput, type BootRoute, Brand, BrandProps, CardItem, Cards, Caret, type ChatCommand, type ChatConfig, type ChatHello, type ChatMsg, type ChatPrompt, type ChatTool, ChipDef, Chips, ChipsProps, type Command, type CommandConfig, type DragState, type DriveConfig, DriveTree, Drop, type DropState, type Dropped, type Entry, type Expand, FileList, Fold, Frame, GB, type Grab, type Habit, HeadBtn, HelpPage, type History, type HistoryConfig, type HistoryStore, type HistoryTalk, Icon, Intent, type Item, ItemsPopup, KB, type Kind, Layout, LeafInput, ListProps, MB, Main, MainHead, MainHeadProps, More, MoreIcon, type NavLink, type Obj, type Over, Pages, type PlaceInput, type Placed, type Point, Pop, type Route, Row, RowBtn, RowBtnProps, RowProps, SP_BREAK, type Service, SettingsPage, SettingsProps, Shell, ShellInput, ShellNames, type ShellSpec, ShortcutsPage, Side, SideBar, SideProps, type Skip, Slot, SpBtn, SpHead, SpHeadProps, type Storage, Storage_, Strip, Tile, TreeMore, TreeProps, type Uploaded, ago, ancestors, applyRoute, atPoint, band, bandIcon, blue, bootShell, config as chatConfig, closeChat, closeDrawer, configure as configureChat, configure$1 as configureDrive, createCommands, createFile, createFileDrag, createFileDrop, createHistory, createOver, createShell, crumbSegs, downloadFile, dragEvent, drawerAtom, config$1 as driveConfig, dropEvent, edge, editorUrl, emptyLabel, emptyTrash, emptyTrashAsk, entryOf, extOf, fileOf, fill, folderAsk, folderDefault, folderRows, freeName, gotoFile, grid, homeMenu, icons, idOf, infoOf, ink, isChatBusy, isDrawerOpen, isFolder, kindOf, kindRows, leafMenu, line, markdown, mirrorFile, mkdirp, modeRows, models, moreItems, moveFile, mute, noPoint, openChat, openDrawer, openEntry, openPath, pageMenu, pageModes, pageTitles, pale, parentOf, pathname, pinLabel, place, pointAtom, prev, quota, r2, readRoute, recentRows, removeFile, renameAsk, renameFile, restoreChat, restoreFile, rootTitle, rowCls, runChat, runIntent, saveFile, settingRows, shortcutRows, side, sizeOf, spMenu, stamp, stop, storageMenu, storageName, storageRows, storeFiles, syncFiles, titleOf, toMsg, toggleChat, togglePin, trashMenu, trashRows, treeFileMenu, treeFolderMenu, treeMenuOf, treeOf, unique, unpinLabel, upgradeLabel, upgradeUrl, uploadAlert, uploadFiles, uploadFolder, uploadMax, url, urlOf, usageOf, useChatBusy, useDrawer, usePoint, usedBytes, usedOf, vec2, watchUrl };
package/dist/client/ui.js CHANGED
@@ -1,7 +1,7 @@
1
- import{atom as e,setAtom as t,useAtomValue as n}from"./react.js";import{useEffect as r,useLayoutEffect as i,useRef as a,useState as o}from"react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import u from"@material-symbols/svg-400/outlined/support_agent.svg?raw";import d from"@material-symbols/svg-400/outlined/drag_indicator.svg?raw";import f,{default as p}from"@material-symbols/svg-400/outlined/close.svg?raw";import m,{default as h}from"@material-symbols/svg-400/outlined/search.svg?raw";import ee from"@material-symbols/svg-400/outlined/mic.svg?raw";import te from"@material-symbols/svg-400/outlined/send.svg?raw";import ne from"@material-symbols/svg-400/outlined/stop_circle.svg?raw";import re from"@material-symbols/svg-400/outlined/graphic_eq.svg?raw";import ie from"@material-symbols/svg-400/outlined/attach_file_add.svg?raw";import ae from"@material-symbols/svg-400/outlined/keyboard_arrow_down.svg?raw";import oe from"@material-symbols/svg-400/outlined/more_horiz.svg?raw";import se,{default as ce}from"@material-symbols/svg-400/outlined/check.svg?raw";import le from"markdown-it";import ue from"@material-symbols/svg-400/outlined/add.svg?raw";import de from"@material-symbols/svg-400/outlined/arrow_back.svg?raw";import fe from"@material-symbols/svg-400/outlined/arrow_drop_down.svg?raw";import pe from"@material-symbols/svg-400/outlined/chevron_right.svg?raw";import me from"@material-symbols/svg-400/outlined/cloud.svg?raw";import he from"@material-symbols/svg-400/outlined/delete.svg?raw";import ge from"@material-symbols/svg-400/outlined/folder.svg?raw";import _e from"@material-symbols/svg-400/outlined/home.svg?raw";import ve from"@material-symbols/svg-400/outlined/keep.svg?raw";import ye from"@material-symbols/svg-400/outlined/keep-fill.svg?raw";import be from"@material-symbols/svg-400/outlined/left_panel_close.svg?raw";import xe from"@material-symbols/svg-400/outlined/left_panel_open.svg?raw";import Se from"@material-symbols/svg-400/outlined/menu.svg?raw";import Ce from"@material-symbols/svg-400/outlined/more_vert.svg?raw";import we from"@material-symbols/svg-400/outlined/redo.svg?raw";import Te from"@material-symbols/svg-400/outlined/schedule.svg?raw";import Ee from"@material-symbols/svg-400/outlined/settings.svg?raw";import De from"@material-symbols/svg-400/outlined/help.svg?raw";import Oe from"@material-symbols/svg-400/outlined/keyboard.svg?raw";import ke from"@material-symbols/svg-400/outlined/sync.svg?raw";import Ae from"@material-symbols/svg-400/outlined/undo.svg?raw";import je from"@material-symbols/svg-400/outlined/unfold_more.svg?raw";import Me from"@material-symbols/svg-400/outlined/visibility_off.svg?raw";import Ne from"@material-symbols/svg-400/outlined/create_new_folder.svg?raw";import Pe from"@material-symbols/svg-400/outlined/upload_file.svg?raw";import Fe from"@material-symbols/svg-400/outlined/drive_folder_upload.svg?raw";import Ie from"@material-symbols/svg-400/outlined/edit.svg?raw";import Le from"@material-symbols/svg-400/outlined/download.svg?raw";import Re from"@material-symbols/svg-400/outlined/info.svg?raw";import ze from"@material-symbols/svg-400/outlined/open_in_new.svg?raw";import Be from"@material-symbols/svg-400/outlined/restore_from_trash.svg?raw";import Ve from"@material-symbols/svg-400/outlined/description.svg?raw";const g=({name:e,size:t=20,color:n,className:r=``})=>c(`span`,{className:`inline-block shrink-0 [&>svg]:h-full [&>svg]:w-full [&>svg]:fill-current ${r}`,style:{width:t,height:t,color:n},dangerouslySetInnerHTML:{__html:e}}),He=e=>e.stopPropagation(),Ue=e=>e.preventDefault(),We=({show:e,children:t})=>e?c(s,{children:t}):null,Ge=(e,t,n={})=>{let{align:r=`right`,point:i=null,gap:a=4,margin:o=8}=n,s=e?.getBoundingClientRect(),c=t?.getBoundingClientRect(),l=i?{left:i.x,right:i.x,top:i.y,bottom:i.y}:s;if(!l||!c)return null;let u=window.innerWidth,d=window.innerHeight,f=Math.min(c.height,d-o*2),p=i||r===`left`?l.left:l.right-c.width,m=Math.min(Math.max(o,p),Math.max(o,u-c.width-o)),h=l.bottom+a;return{x:m,y:h+f>d-o?Math.max(o,l.top-f-a):h,h:f}},Ke=({m:e,value:t,check:n})=>l(s,{children:[l(`span`,{className:`flex min-w-0 flex-1 flex-col items-start`,children:[c(`span`,{className:`truncate`,children:e.label}),c(`span`,{className:`truncate text-[12px] text-mute`,children:e.desc})]}),t===e.id&&c(g,{name:n,size:18,color:`#4185f4`})]}),qe=({m:e,value:t,check:n})=>l(s,{children:[t===e.id&&c(g,{name:n,size:18}),t!==e.id&&e.icon&&c(g,{name:e.icon,size:18,color:e.color,className:e.color?``:`text-mute`}),t!==e.id&&!e.icon&&c(`span`,{className:`w-[18px] shrink-0`}),c(`span`,{className:`truncate`,children:e.label})]}),Je=({cls:e,items:t,value:n,pick:r,style:i,check:a})=>c(`div`,{className:`absolute z-50 rounded-xl border border-line bg-white py-2 shadow-[0_8px_24px_rgba(0,0,0,0.12)] ${e}`,style:i,onClick:He,children:t.map(e=>c(`div`,{className:e.top?`mt-2 border-t border-line pt-2`:``,children:c(`button`,{onClick:()=>r(e),className:`flex w-full items-center gap-3 px-4 text-left hover:bg-pale ${e.desc?`py-2`:`h-11`}`,children:e.desc?c(Ke,{m:e,value:n,check:a}):c(qe,{m:e,value:n,check:a})})},e.id))}),Ye=({items:e,value:t,pick:n,align:r=`right`,cls:u=`w-72`,point:d,check:f})=>{let p=a(null),m=a(null),[h,ee]=o(null);return i(()=>ee(Ge(p.current?.parentElement,m.current?.firstElementChild,{align:r,point:d})),[]),l(s,{children:[c(`span`,{ref:p,className:`absolute h-0 w-0`}),c(`div`,{ref:m,className:`fixed z-50`,style:h?{left:h.x,top:h.y}:{left:0,top:0,visibility:`hidden`},children:c(Je,{cls:`left-0 top-0 overflow-y-auto ${u}`,style:{maxHeight:h?.h??window.innerHeight-16},items:e,value:t,pick:n,check:f})})]})},Xe=`#1f1f21`,Ze=`#8b8b8b`,Qe=`#ececec`,$e=`#d9d9d9`,et=`#fafafa`,tt=`#f1f1f1`,nt=`#202020`,rt=`#4185f4`,_={row:36,indent:20,slot:20,icon:20,gap:8,brand:22,width:233},it={card:200,suggest:264},at=15360,ot=104857600,st=`ファイルサイズが大きすぎます (上限 100 MB)`,ct=768,lt=1073741824,ut=1048576,dt=1024,ft=e=>String(e).padStart(2,`0`),pt=e=>{let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${t.getHours()}:${ft(t.getMinutes())}`:t.getFullYear()===n.getFullYear()?`${t.getMonth()+1}月${t.getDate()}日`:`${t.getFullYear()}/${ft(t.getMonth()+1)}/${ft(t.getDate())}`},mt=e=>e>=1048576?`${(e/ut).toFixed(1)} MB`:e>=1024?`${Math.round(e/dt)} KB`:`${e} B`,ht=e=>e>=1073741824?`${(e/lt).toFixed(2)} GB`:`${Math.round(e/ut)} MB`,gt=e=>{let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?`たった今`:t<3600?`${Math.floor(t/60)} 分前`:t<86400?`${Math.floor(t/3600)} 時間前`:`${Math.floor(t/86400)} 日前`},_t=(e,t)=>{if(!t.has(e))return e;let n=e.lastIndexOf(`.`),r=n>0?e.slice(0,n):e,i=n>0?e.slice(n):``,a=1;for(;t.has(`${r}(${a})${i}`);)a++;return`${r}(${a})${i}`},vt={position:`fixed`,left:`0`,top:`0`,zIndex:`60`,overflow:`hidden`,pointerEvents:`none`,background:`#fff`,transition:`width 0.16s ease, height 0.16s ease, left 0.16s ease, top 0.16s ease`},yt={width:`100%`,height:`100%`},bt={width:`264px`,height:`62px`,borderRadius:`12px`,boxShadow:`0 8px 24px rgba(0, 0, 0, 0.12)`},xt={display:`flex`,alignItems:`center`,padding:`12px`,border:`1px solid ${$e}`,borderRadius:`12px`,background:`#fff`},v=(e,t)=>Object.assign(e.style,t),St=()=>{let e=null,t=0,n=0;return{start(r,i,a){if(!r||e)return;let o=r.getBoundingClientRect(),s=r.cloneNode(!0);t=i??o.left,n=a??o.top,e=document.createElement(`div`),v(e,vt),v(s,yt),e.appendChild(s),e.style.left=`${o.left}px`,e.style.top=`${o.top}px`,e.style.width=`${o.width}px`,e.style.height=`${o.height}px`,document.body.appendChild(e),requestAnimationFrame(()=>{e&&(v(e,bt),v(s,xt),s.querySelectorAll(`[data-ghost-hide]`).forEach(e=>v(e,{display:`none`})),e.style.left=`${t}px`,e.style.top=`${n}px`)})},move(r,i){e&&(e.style.transform=`translate(${r-t}px, ${i-n}px)`)},end(){e?.remove(),e=null}}},Ct=(e,t)=>{let n=e.getAttribute(`data-drop-from`);return n===null||n.split(` `).includes(t)},wt=(e,t,n,r)=>{let i=document.elementFromPoint(e,t),a=i?.closest(`[data-drop]`),o=a?.getAttribute(`data-drop`);return!i||!a||typeof o!=`string`||!Ct(a,n)||r(i,o)?null:a},Tt=e=>{let t=e.closest(`[data-drop-scope]`)??document,n=Array.from(t.querySelectorAll(`[data-drop-mark="${CSS.escape(e.getAttribute(`data-drop`))}"]`));return n.length>0?n:e.hasAttribute(`data-drop-scope`)?[]:[e]},Et=[`outline-2`,`-outline-offset-2`,`rounded-lg`,`outline-ink`],Dt=()=>{let e=``,t=()=>!1,n=null,r=[];return{begin(n,r=()=>!1){e=n,t=r},move(i,a){let o=wt(i,a,e,t);o!==n&&(r.forEach(e=>e.classList.remove(...Et)),n=o,r=o?Tt(o):[],r.forEach(e=>e.classList.add(...Et)))},read(){return n?.getAttribute(`data-drop`)??null},end(){r.forEach(e=>e.classList.remove(...Et)),r=[],n=null}}},Ot=typeof Float32Array<`u`?Float32Array:Array,y=(e=0,t=0,n=new Ot(2))=>(n[0]=e,n[1]=t,n),kt=(e,t,n=y())=>(n[0]=e[0]+t[0],n[1]=e[1]+t[1],n),At=(e,t,n=y())=>(n[0]=e[0]-t[0],n[1]=e[1]-t[1],n),jt=(e,t=y())=>(t[0]=e[0],t[1]=e[1],t),b=typeof window<`u`&&!!window.document&&!!window.document.createElement,Mt=()=>b&&`ontouchstart`in window,Nt=()=>Mt()||b&&window.navigator.maxTouchPoints>1,Pt=()=>b&&`onpointerdown`in window,Ft=()=>b&&`exitPointerLock`in window.document,It=()=>{try{return`constructor`in GestureEvent}catch{return!1}},x={isBrowser:b,get gesture(){return x._gesture??=It()},get touch(){return x._touch??=Mt()},get touchscreen(){return x._touchscreen??=Nt()},get pointer(){return x._pointer??=Pt()},get pointerLock(){return x._pointerLock??=Ft()}},Lt=(e=!1)=>e&&x.pointerLock?`mouse`:x.pointer?`pointer`:x.touch?`touch`:`mouse`,Rt=(e,t,n)=>{if(t!==`touch`)return y(e.clientX,e.clientY,n);let[r]=e.changedTouches;return y(r.clientX,r.clientY,n)},zt={touch:{start:`touchstart`,move:`touchmove`,end:`touchend`,up:`touchcancel`},pointer:{start:`pointerdown`,move:`pointermove`,end:`pointerup`,up:`pointercancel`},mouse:{start:`mousedown`,move:`mousemove`,end:`mouseup`,up:`mousecancel`}};let S=null;const Bt=(e,t=()=>!0)=>{let n=()=>{y(0,0,r.value),y(0,0,r._value),y(0,0,r.delta),y(0,0,r.movement)},r={_active:!1,active:!1,pointerId:null,device:Lt(),_value:y(0,0),value:y(0,0),delta:y(0,0),offset:y(0,0),movement:y(0,0),target:null,event:null,memo:{},isDragStart:!1,isDragging:!1,isDragEnd:!1,drag:()=>{let t=r._active;r.isDragStart=r.active&&!t,r.isDragging=r.active&&t,r.isDragEnd=!r.active&&t,e?.(),r._active=r.active},dragStart:e=>{r.active||S&&S!==r||t(e)&&(e.stopPropagation(),S=r,r.pointerId=e.pointerId??null,r.event=e,r._active=!1,r.active=!0,n(),Rt(e,r.device,r.value),r.target.setPointerCapture&&`pointerId`in e&&r.target.setPointerCapture(e.pointerId),r.drag(r))},dragging:e=>{r.event=e,!(r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId)&&(r.active&&e.cancelable&&e.preventDefault(),r.active&&e.stopPropagation(),jt(r.value,r._value),Rt(e,r.device,r.value),r.active&&(At(r.value,r._value,r.delta),kt(r.offset,r.delta,r.offset),kt(r.movement,r.delta,r.movement)),r.drag(r))},dragEnd:e=>{r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId||(S===r&&(S=null),r.event=e,r.active=!1,n(),r.pointerId=null,r.target.releasePointerCapture&&`pointerId`in e&&r.target.releasePointerCapture(e.pointerId),r.drag(r))},mount:e=>{r.target=e;let{start:t,move:n,end:i,up:a}=zt[r.device];e.addEventListener(t,r.dragStart),e.addEventListener(n,r.dragging,{passive:!1}),e.addEventListener(i,r.dragEnd),e.addEventListener(a,r.dragEnd)},clean:()=>{let e=r.target;if(!e)return;let{start:t,move:n,end:i,up:a}=zt[r.device];e.removeEventListener(t,r.dragStart),e.removeEventListener(n,r.dragging),e.removeEventListener(i,r.dragEnd),e.removeEventListener(a,r.dragEnd),S===r&&(S=null)},ref:e=>{e?r.mount(e):r.clean(null)}};return r},Vt=[`select-none`,`cursor-grabbing`],Ht=e=>{e.preventDefault(),e.stopPropagation()},Ut=(e,t,n,r,i)=>{let a=()=>{u.memo.moved=!0,navigator.vibrate?.(15),document.body.classList.add(...Vt),n.start(u.target,u.value[0],u.value[1]),r.begin(t,(t,n)=>u.target.contains(t)||n===e||n.startsWith(`${e}/`))},o=()=>{clearTimeout(u.memo.timer),u.memo.moved=!1,u.memo.touch=u.event?.pointerType===`touch`,u.memo.touch&&(u.memo.timer=setTimeout(()=>{u.active&&a()},300))},s=()=>{let e=Math.hypot(u.movement[0],u.movement[1])>8;if(u.memo.touch&&!u.memo.moved){e&&clearTimeout(u.memo.timer);return}!u.memo.moved&&!e||(u.memo.moved||a(),n.move(u.value[0],u.value[1]),r.move(u.value[0],u.value[1]))},c=()=>{let e=u.memo.moved?r.read():null;r.end(),n.end(),document.body.classList.remove(...Vt),u.memo.moved&&(window.addEventListener(`click`,Ht,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,Ht,{capture:!0}),0)),e!==null&&i(e)},l=e=>{if(u.active){if(e.type===`contextmenu`&&u.memo.touch)return Ht(e);u.memo.moved&&e.preventDefault()}},u=Bt(()=>{u.isDragStart&&o(),u.isDragging&&s(),u.isDragEnd&&c()},e=>e.button===0&&!e.target?.closest?.(`button, a, input, label`));return e=>{if(!e){clearTimeout(u.memo.timer),u.clean();return}u.mount(e),e.addEventListener(`contextmenu`,l),e.addEventListener(`touchmove`,l,{passive:!1})}},Wt=e=>{let t=St(),n=Dt(),r=new Map;return(i,a=``)=>{let o=`${a}:${i}`;return r.has(o)||r.set(o,Ut(i,a,t,n,t=>e(i,t))),r.get(o)}},Gt={start:`dragenter`,move:`dragover`,leave:`dragleave`,end:`drop`},Kt=(e,t=()=>!0)=>{let n={_active:!1,active:!1,depth:0,value:y(0,0),target:null,event:null,memo:{},isDropStart:!1,isDropping:!1,isDropEnd:!1,drop:()=>{let t=n._active;n.isDropStart=n.active&&!t,n.isDropping=n.active&&t,n.isDropEnd=!n.active&&t,e?.(),n._active=n.active},dropStart:e=>{n.depth++,!n.active&&t(e)&&(e.preventDefault(),n.event=e,n._active=!1,n.active=!0,y(e.clientX,e.clientY,n.value),n.drop(n))},dropping:e=>{n.active&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),n.event=e,y(e.clientX,e.clientY,n.value),n.drop(n))},dropLeave:e=>{n.depth>0&&n.depth--,!(n.depth>0||!n.active)&&(n.event=e,n.active=!1,n.drop(n))},dropEnd:e=>{n.depth=0,n.active&&(e.preventDefault(),n.event=e,n.active=!1,y(e.clientX,e.clientY,n.value),n.drop(n))},mount:e=>{n.target=e;let{start:t,move:r,leave:i,end:a}=Gt;e.addEventListener(t,n.dropStart),e.addEventListener(r,n.dropping),e.addEventListener(i,n.dropLeave),e.addEventListener(a,n.dropEnd)},clean:()=>{let e=n.target;if(!e)return;let{start:t,move:r,leave:i,end:a}=Gt;e.removeEventListener(t,n.dropStart),e.removeEventListener(r,n.dropping),e.removeEventListener(i,n.dropLeave),e.removeEventListener(a,n.dropEnd),n.depth=0,n.active=!1},ref:e=>{if(e)return void n.mount(e);n.clean()}};return n},qt=e=>!!e.dataTransfer?.types.includes(`Files`),Jt=e=>new Promise(t=>e.readEntries(t)),Yt=async e=>{let t=e.createReader(),n=[],r=await Jt(t);for(;r.length>0;)n.push(...r),r=await Jt(t);return n},Xt=e=>new Promise(t=>e.file(t)),Zt=async(e,t,n)=>{let r=t===``?e.name:`${t}/${e.name}`;if(e.isFile)return void n.push({path:r,file:await Xt(e)});n.push({path:r,file:null});for(let t of await Yt(e))await Zt(t,r,n)},Qt=async e=>{let t=Array.from(e?.items??[]).map(e=>e.webkitGetAsEntry()).filter(e=>!!e),n=[];for(let e of t)await Zt(e,``,n);return n},$t=(e,t,n=()=>!0)=>{let r=Dt(),i=()=>r.begin(e,()=>!n()),a=()=>r.move(s.value[0],s.value[1]),o=()=>{let e=s.event.type===`drop`?r.read():null;r.end(),e!==null&&Qt(s.event.dataTransfer).then(n=>t(n,e))},s=Kt(()=>{s.isDropStart&&i(),s.isDropping&&a(),s.isDropEnd&&o()},qt);return s.ref},C={ask:`Ask me anything...`,brand:`Claude`,voice:`音声モード`,file:`ファイル`},w=[{id:`claude-fable-5`,label:`Fable 5`,desc:`最も困難な課題に`},{id:`claude-opus-5`,label:`Opus 5`,desc:`複雑なタスク向け`},{id:`claude-sonnet-5`,label:`Sonnet 5`,desc:`日常のタスクに最適`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`,desc:`素早い回答に最適`}],T={w:376,left:12,top:12,bottom:16,minH:180},E=e(``),D={send:async()=>``,stream:{parse:()=>[],send:async()=>[]},icon:``,path:``,headers:{},hello:()=>({greet:``,title:``,desc:``,prompts:[]}),commands:()=>[],hints:()=>[],menu:{useOpen:()=>n(E),flip:e=>n=>{n.stopPropagation(),t(E,E.value===e?``:e)},close:()=>t(E,``)}},en=e=>void Object.assign(D,e),tn=(e,t=20,n=6)=>{let r=a(null);return i(()=>{let e=r.current;if(!e)return;e.style.height=`${t}px`;let i=Math.max(1,Math.round(e.scrollHeight/t));e.style.height=`${Math.min(i,n)*t}px`},[e]),r},nn=(()=>{let e=new le({linkify:!0,breaks:!0}),t=t=>e.render(t);return{render:t,plain:e=>{let n=document.createElement(`div`);return n.innerHTML=t(e),n.textContent?.trim()??``}}})(),O=e(!1),k=e([]),A=e(``),j=e([0,0]),rn=e(w[0].id),M=e(!1),N=e(!1),P=e(!1);let F=null;const an=()=>{let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(!e)return null;let n=new e;return n.lang=`ja-JP`,n.continuous=!0,n.interimResults=!1,n.onresult=e=>{let n=``;for(let t=e.resultIndex;t<e.results.length;t++)e.results[t].isFinal&&(n+=e.results[t][0].transcript);n!==``&&t(A,A.value+n)},n.onend=()=>t(P,!1),n},on=()=>{if(P.value)return void F?.stop();F??=an(),F&&(F.start(),t(P,!0))};let I=[0,0,28,28];const sn=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n)),cn=()=>{let[e,t]=j.value,n=L.target.getBoundingClientRect();I=[n.left-e,n.top-t,n.width,n.height]},ln=()=>{let e=sn(L.offset[0],-I[0],window.innerWidth-I[2]-I[0]),n=sn(L.offset[1],-I[1],window.innerHeight-I[3]-I[1]);y(e,n,L.offset),t(j,[e,n])},L=Bt(()=>{L.isDragStart&&cn(),ln()}),un=()=>{y(0,0,L.offset),t(j,[0,0])},dn=()=>{let e=L.target;!e||!e.isConnected||(cn(),ln())},fn=()=>{r(()=>(dn(),window.addEventListener(`resize`,dn),()=>window.removeEventListener(`resize`,dn)),[])},pn=e=>`calc(max(${T.left}px, 100vw - ${T.w+T.left}px) + ${e}px)`,mn=e=>T.top+e,hn=e=>`max(${T.minH}px, min(calc(100dvh - ${T.top+T.left}px), calc(100dvh - ${T.top+T.bottom+e}px)))`,R=e(null),z=e(0),gn=(e,t)=>{if(t)return t;if(!e.startsWith(`/`))return[];let n=e.slice(1).trim().toLowerCase();return D.commands().filter(e=>e.name.toLowerCase().startsWith(n))},B=()=>{t(R,null),t(z,0)},V=async e=>{t(A,``),B();let n=await e.run();Array.isArray(n)&&t(R,n)},_n=e=>{if(!e.startsWith(`/`))return;let t=e.slice(1).trim().toLowerCase();return D.commands().find(e=>e.name.toLowerCase()===t)??gn(e,null)[0]},vn=e=>{if(e.nativeEvent?.isComposing)return!1;let n=gn(A.value,R.value);if(n.length===0)return!1;let r=z.value%n.length;return e.key===`ArrowDown`?(e.preventDefault(),t(z,(r+1)%n.length),!0):e.key===`ArrowUp`?(e.preventDefault(),t(z,(r-1+n.length)%n.length),!0):e.key===`Escape`?(e.preventDefault(),t(A,``),B(),!0):e.key===`Enter`&&(e.preventDefault(),V(n[r]),!0)},yn=(()=>{let e=e=>e.replace(/[^0-9A-Za-zぁ-んァ-ヴー一-龠々\s]/g,` `).replace(/\s+/g,` `).trim(),t=e=>{let t=document.createElement(`div`);return t.innerHTML=nn.render(e),t.querySelectorAll(`pre`).forEach(e=>e.remove()),t.textContent??``};return{lines:n=>t(n).split(`
2
- `).map(e).filter(e=>e!==``)}})();let H=0,bn=[];const xn=[`Kyoko`,`O-Ren`,`Nanami`,`Ayumi`,`Haruka`,`Sayaka`,`Samantha`,`Zira`,`Aria`,`Jenny`,`Ava`,`Sonia`,`Google 日本語`,`Google US English`],Sn=[`Otoya`,`Ichiro`,`Keita`,`David`,`Mark`,`Guy`,`Alex`,`Daniel`,`Fred`,`Andrew`,`Brian`],Cn=()=>bn=speechSynthesis.getVoices(),wn=e=>{bn.length===0&&Cn();let t=bn.filter(t=>t.lang.replace(`_`,`-`).startsWith(e.slice(0,2)));return t.find(e=>xn.some(t=>e.name.includes(t)))??t.find(e=>!Sn.some(t=>e.name.includes(t)))??t[0]??null},Tn=e=>{(e.match(/[A-Za-z][0-9A-Za-z]*(?: (?:[0-9]+ )*[A-Za-z][0-9A-Za-z]*)*|(?:(?![A-Za-z]).)+/g)??[]).forEach(e=>{if(e.trim()===``)return;let t=new SpeechSynthesisUtterance(e);t.lang=/^[A-Za-z]/.test(e)?`en-US`:`ja-JP`,t.voice=wn(t.lang),speechSynthesis.speak(t)})};speechSynthesis.addEventListener(`voiceschanged`,Cn);const En=e=>{if(!N.value)return;let t=e.split(`
1
+ import{atom as e,setAtom as t,useAtomValue as n,useClient as r}from"./react.js";import{useEffect as i,useLayoutEffect as a,useRef as o,useState as s}from"react";import{Fragment as c,jsx as l,jsxs as u}from"react/jsx-runtime";import d from"@material-symbols/svg-400/outlined/add.svg?raw";import f from"@material-symbols/svg-400/outlined/arrow_back.svg?raw";import p from"@material-symbols/svg-400/outlined/arrow_drop_down.svg?raw";import m,{default as h}from"@material-symbols/svg-400/outlined/check.svg?raw";import g from"@material-symbols/svg-400/outlined/chevron_right.svg?raw";import _,{default as ee}from"@material-symbols/svg-400/outlined/close.svg?raw";import te from"@material-symbols/svg-400/outlined/cloud.svg?raw";import ne from"@material-symbols/svg-400/outlined/delete.svg?raw";import re from"@material-symbols/svg-400/outlined/folder.svg?raw";import ie from"@material-symbols/svg-400/outlined/home.svg?raw";import ae from"@material-symbols/svg-400/outlined/keep.svg?raw";import oe from"@material-symbols/svg-400/outlined/keep-fill.svg?raw";import se from"@material-symbols/svg-400/outlined/left_panel_close.svg?raw";import ce from"@material-symbols/svg-400/outlined/left_panel_open.svg?raw";import le from"@material-symbols/svg-400/outlined/menu.svg?raw";import ue from"@material-symbols/svg-400/outlined/more_vert.svg?raw";import de from"@material-symbols/svg-400/outlined/redo.svg?raw";import fe from"@material-symbols/svg-400/outlined/schedule.svg?raw";import pe,{default as me}from"@material-symbols/svg-400/outlined/search.svg?raw";import he from"@material-symbols/svg-400/outlined/settings.svg?raw";import ge from"@material-symbols/svg-400/outlined/help.svg?raw";import _e from"@material-symbols/svg-400/outlined/keyboard.svg?raw";import ve from"@material-symbols/svg-400/outlined/sync.svg?raw";import ye from"@material-symbols/svg-400/outlined/undo.svg?raw";import be from"@material-symbols/svg-400/outlined/unfold_more.svg?raw";import xe from"@material-symbols/svg-400/outlined/visibility_off.svg?raw";import Se from"@material-symbols/svg-400/outlined/create_new_folder.svg?raw";import Ce from"@material-symbols/svg-400/outlined/upload_file.svg?raw";import we from"@material-symbols/svg-400/outlined/drive_folder_upload.svg?raw";import Te from"@material-symbols/svg-400/outlined/edit.svg?raw";import Ee from"@material-symbols/svg-400/outlined/download.svg?raw";import De from"@material-symbols/svg-400/outlined/info.svg?raw";import Oe from"@material-symbols/svg-400/outlined/open_in_new.svg?raw";import ke from"@material-symbols/svg-400/outlined/restore_from_trash.svg?raw";import Ae from"@material-symbols/svg-400/outlined/description.svg?raw";import je from"@material-symbols/svg-400/outlined/support_agent.svg?raw";import Me from"@material-symbols/svg-400/outlined/drag_indicator.svg?raw";import Ne from"@material-symbols/svg-400/outlined/mic.svg?raw";import Pe from"@material-symbols/svg-400/outlined/send.svg?raw";import Fe from"@material-symbols/svg-400/outlined/stop_circle.svg?raw";import Ie from"@material-symbols/svg-400/outlined/graphic_eq.svg?raw";import Le from"@material-symbols/svg-400/outlined/attach_file_add.svg?raw";import Re from"@material-symbols/svg-400/outlined/keyboard_arrow_down.svg?raw";import ze from"@material-symbols/svg-400/outlined/more_horiz.svg?raw";import Be from"markdown-it";const v=({name:e,size:t=20,color:n,className:r=``})=>l(`span`,{className:`inline-block shrink-0 [&>svg]:h-full [&>svg]:w-full [&>svg]:fill-current ${r}`,style:{width:t,height:t,color:n},dangerouslySetInnerHTML:{__html:e}}),y=e=>e.stopPropagation(),Ve=e=>e.preventDefault(),He=({show:e,children:t})=>e?l(c,{children:t}):null,Ue=(e,t,n={})=>{let{align:r=`right`,point:i=null,gap:a=4,margin:o=8}=n,s=e?.getBoundingClientRect(),c=t?.getBoundingClientRect(),l=i?{left:i.x,right:i.x,top:i.y,bottom:i.y}:s;if(!l||!c)return null;let u=window.innerWidth,d=window.innerHeight,f=Math.min(c.height,d-o*2),p=i||r===`left`?l.left:l.right-c.width,m=Math.min(Math.max(o,p),Math.max(o,u-c.width-o)),h=l.bottom+a;return{x:m,y:h+f>d-o?Math.max(o,l.top-f-a):h,h:f}},We=({m:e,value:t,check:n})=>u(c,{children:[u(`span`,{className:`flex min-w-0 flex-1 flex-col items-start`,children:[l(`span`,{className:`truncate`,children:e.label}),l(`span`,{className:`truncate text-[12px] text-mute`,children:e.desc})]}),t===e.id&&l(v,{name:n,size:18,color:`#4185f4`})]}),Ge=({m:e,value:t,check:n})=>u(c,{children:[t===e.id&&l(v,{name:n,size:18}),t!==e.id&&e.icon&&l(v,{name:e.icon,size:18,color:e.color,className:e.color?``:`text-mute`}),t!==e.id&&!e.icon&&l(`span`,{className:`w-[18px] shrink-0`}),l(`span`,{className:`truncate`,children:e.label})]}),Ke=({cls:e=``,items:t=[],value:n,pick:r,style:i,check:a=``,children:o})=>l(`div`,{className:`absolute z-50 rounded-xl border border-line bg-white py-2 shadow-[0_8px_24px_rgba(0,0,0,0.12)] ${e}`,style:i,onClick:y,children:o??t.map(e=>l(`div`,{className:e.top?`mt-2 border-t border-line pt-2`:``,children:l(`button`,{disabled:e.disabled,onClick:()=>r?.(e),className:`flex w-full items-center gap-3 px-4 text-left hover:bg-pale disabled:pointer-events-none disabled:opacity-40 ${e.desc?`py-2`:`h-11`}`,children:e.desc?l(We,{m:e,value:n,check:a}):l(Ge,{m:e,value:n,check:a})})},e.id))}),b=({items:e,value:t,pick:n,align:r=`right`,cls:i=`w-72`,point:d,check:f,children:p})=>{let m=o(null),h=o(null),[g,_]=s(null);return a(()=>_(Ue(m.current?.parentElement,h.current?.firstElementChild,{align:r,point:d})),[]),u(c,{children:[l(`span`,{ref:m,className:`absolute h-0 w-0`}),l(`div`,{ref:h,className:`fixed z-50`,style:g?{left:g.x,top:g.y}:{left:0,top:0,visibility:`hidden`},children:l(Ke,{cls:`left-0 top-0 overflow-y-auto ${i}`,style:{maxHeight:g?.h??window.innerHeight-16},items:e,value:t,pick:n,check:f,children:p})})]})},qe=`#1f1f21`,Je=`#8b8b8b`,Ye=`#ececec`,Xe=`#d9d9d9`,Ze=`#fafafa`,Qe=`#f1f1f1`,$e=`#202020`,et=`#4185f4`,x={row:36,indent:20,slot:20,icon:20,gap:8,brand:22,width:233},tt={card:200,suggest:264},nt=15360,rt=104857600,it=`ファイルサイズが大きすぎます (上限 100 MB)`,at=768,ot=1073741824,st=1048576,ct=1024,lt=e=>String(e).padStart(2,`0`),ut=e=>{let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${t.getHours()}:${lt(t.getMinutes())}`:t.getFullYear()===n.getFullYear()?`${t.getMonth()+1}月${t.getDate()}日`:`${t.getFullYear()}/${lt(t.getMonth()+1)}/${lt(t.getDate())}`},dt=e=>e>=1048576?`${(e/st).toFixed(1)} MB`:e>=1024?`${Math.round(e/ct)} KB`:`${e} B`,ft=e=>e>=1073741824?`${(e/ot).toFixed(2)} GB`:`${Math.round(e/st)} MB`,pt=e=>{let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?`たった今`:t<3600?`${Math.floor(t/60)} 分前`:t<86400?`${Math.floor(t/3600)} 時間前`:`${Math.floor(t/86400)} 日前`},mt=(e,t)=>{if(!t.has(e))return e;let n=e.lastIndexOf(`.`),r=n>0?e.slice(0,n):e,i=n>0?e.slice(n):``,a=1;for(;t.has(`${r}(${a})${i}`);)a++;return`${r}(${a})${i}`},ht={position:`fixed`,left:`0`,top:`0`,zIndex:`60`,overflow:`hidden`,pointerEvents:`none`,background:`#fff`,transition:`width 0.16s ease, height 0.16s ease, left 0.16s ease, top 0.16s ease`},gt={width:`100%`,height:`100%`},_t={width:`264px`,height:`62px`,borderRadius:`12px`,boxShadow:`0 8px 24px rgba(0, 0, 0, 0.12)`},vt={display:`flex`,alignItems:`center`,padding:`12px`,border:`1px solid ${Xe}`,borderRadius:`12px`,background:`#fff`},S=(e,t)=>Object.assign(e.style,t),yt=()=>{let e=null,t=0,n=0;return{start(r,i,a){if(!r||e)return;let o=r.getBoundingClientRect(),s=r.cloneNode(!0);t=i??o.left,n=a??o.top,e=document.createElement(`div`),S(e,ht),S(s,gt),e.appendChild(s),e.style.left=`${o.left}px`,e.style.top=`${o.top}px`,e.style.width=`${o.width}px`,e.style.height=`${o.height}px`,document.body.appendChild(e),requestAnimationFrame(()=>{e&&(S(e,_t),S(s,vt),s.querySelectorAll(`[data-ghost-hide]`).forEach(e=>S(e,{display:`none`})),e.style.left=`${t}px`,e.style.top=`${n}px`)})},move(r,i){e&&(e.style.transform=`translate(${r-t}px, ${i-n}px)`)},end(){e?.remove(),e=null}}},bt=(e,t)=>{let n=e.getAttribute(`data-drop-from`);return n===null||n.split(` `).includes(t)},xt=(e,t,n,r)=>{let i=document.elementFromPoint(e,t),a=i?.closest(`[data-drop]`),o=a?.getAttribute(`data-drop`);return!i||!a||typeof o!=`string`||!bt(a,n)||r(i,o)?null:a},St=e=>{let t=e.closest(`[data-drop-scope]`)??document,n=Array.from(t.querySelectorAll(`[data-drop-mark="${CSS.escape(e.getAttribute(`data-drop`))}"]`));return n.length>0?n:e.hasAttribute(`data-drop-scope`)?[]:[e]},Ct=[`outline-2`,`-outline-offset-2`,`rounded-lg`,`outline-ink`],wt=()=>{let e=``,t=()=>!1,n=null,r=[];return{begin(n,r=()=>!1){e=n,t=r},move(i,a){let o=xt(i,a,e,t);o!==n&&(r.forEach(e=>e.classList.remove(...Ct)),n=o,r=o?St(o):[],r.forEach(e=>e.classList.add(...Ct)))},read(){return n?.getAttribute(`data-drop`)??null},end(){r.forEach(e=>e.classList.remove(...Ct)),r=[],n=null}}},Tt=typeof Float32Array<`u`?Float32Array:Array,C=(e=0,t=0,n=new Tt(2))=>(n[0]=e,n[1]=t,n),Et=(e,t,n=C())=>(n[0]=e[0]+t[0],n[1]=e[1]+t[1],n),Dt=(e,t,n=C())=>(n[0]=e[0]-t[0],n[1]=e[1]-t[1],n),Ot=(e,t=C())=>(t[0]=e[0],t[1]=e[1],t),w=typeof window<`u`&&!!window.document&&!!window.document.createElement,kt=()=>w&&`ontouchstart`in window,At=()=>kt()||w&&window.navigator.maxTouchPoints>1,jt=()=>w&&`onpointerdown`in window,Mt=()=>w&&`exitPointerLock`in window.document,Nt=()=>{try{return`constructor`in GestureEvent}catch{return!1}},T={isBrowser:w,get gesture(){return T._gesture??=Nt()},get touch(){return T._touch??=kt()},get touchscreen(){return T._touchscreen??=At()},get pointer(){return T._pointer??=jt()},get pointerLock(){return T._pointerLock??=Mt()}},Pt=(e=!1)=>e&&T.pointerLock?`mouse`:T.pointer?`pointer`:T.touch?`touch`:`mouse`,Ft=(e,t,n)=>{if(t!==`touch`)return C(e.clientX,e.clientY,n);let[r]=e.changedTouches;return C(r.clientX,r.clientY,n)},It={touch:{start:`touchstart`,move:`touchmove`,end:`touchend`,up:`touchcancel`},pointer:{start:`pointerdown`,move:`pointermove`,end:`pointerup`,up:`pointercancel`},mouse:{start:`mousedown`,move:`mousemove`,end:`mouseup`,up:`mousecancel`}};let E=null;const Lt=(e,t=()=>!0)=>{let n=()=>{C(0,0,r.value),C(0,0,r._value),C(0,0,r.delta),C(0,0,r.movement)},r={_active:!1,active:!1,pointerId:null,device:Pt(),_value:C(0,0),value:C(0,0),delta:C(0,0),offset:C(0,0),movement:C(0,0),target:null,event:null,memo:{},isDragStart:!1,isDragging:!1,isDragEnd:!1,drag:()=>{let t=r._active;r.isDragStart=r.active&&!t,r.isDragging=r.active&&t,r.isDragEnd=!r.active&&t,e?.(),r._active=r.active},dragStart:e=>{r.active||E&&E!==r||t(e)&&(e.stopPropagation(),E=r,r.pointerId=e.pointerId??null,r.event=e,r._active=!1,r.active=!0,n(),Ft(e,r.device,r.value),r.target.setPointerCapture&&`pointerId`in e&&r.target.setPointerCapture(e.pointerId),r.drag(r))},dragging:e=>{r.event=e,!(r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId)&&(r.active&&e.cancelable&&e.preventDefault(),r.active&&e.stopPropagation(),Ot(r.value,r._value),Ft(e,r.device,r.value),r.active&&(Dt(r.value,r._value,r.delta),Et(r.offset,r.delta,r.offset),Et(r.movement,r.delta,r.movement)),r.drag(r))},dragEnd:e=>{r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId||(E===r&&(E=null),r.event=e,r.active=!1,n(),r.pointerId=null,r.target.releasePointerCapture&&`pointerId`in e&&r.target.releasePointerCapture(e.pointerId),r.drag(r))},mount:e=>{r.target=e;let{start:t,move:n,end:i,up:a}=It[r.device];e.addEventListener(t,r.dragStart),e.addEventListener(n,r.dragging,{passive:!1}),e.addEventListener(i,r.dragEnd),e.addEventListener(a,r.dragEnd)},clean:()=>{let e=r.target;if(!e)return;let{start:t,move:n,end:i,up:a}=It[r.device];e.removeEventListener(t,r.dragStart),e.removeEventListener(n,r.dragging),e.removeEventListener(i,r.dragEnd),e.removeEventListener(a,r.dragEnd),E===r&&(E=null)},ref:e=>{e?r.mount(e):r.clean(null)}};return r},Rt=[`select-none`,`cursor-grabbing`],zt=e=>{e.preventDefault(),e.stopPropagation()},Bt=(e,t,n,r,i)=>{let a=()=>{u.memo.moved=!0,navigator.vibrate?.(15),document.body.classList.add(...Rt),n.start(u.target,u.value[0],u.value[1]),r.begin(t,(t,n)=>u.target.contains(t)||n===e||n.startsWith(`${e}/`))},o=()=>{clearTimeout(u.memo.timer),u.memo.moved=!1,u.memo.touch=u.event?.pointerType===`touch`,u.memo.touch&&(u.memo.timer=setTimeout(()=>{u.active&&a()},300))},s=()=>{let e=Math.hypot(u.movement[0],u.movement[1])>8;if(u.memo.touch&&!u.memo.moved){e&&clearTimeout(u.memo.timer);return}!u.memo.moved&&!e||(u.memo.moved||a(),n.move(u.value[0],u.value[1]),r.move(u.value[0],u.value[1]))},c=()=>{let e=u.memo.moved?r.read():null;r.end(),n.end(),document.body.classList.remove(...Rt),u.memo.moved&&(window.addEventListener(`click`,zt,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,zt,{capture:!0}),0)),e!==null&&i(e)},l=e=>{if(u.active){if(e.type===`contextmenu`&&u.memo.touch)return zt(e);u.memo.moved&&e.preventDefault()}},u=Lt(()=>{u.isDragStart&&o(),u.isDragging&&s(),u.isDragEnd&&c()},e=>e.button===0&&!e.target?.closest?.(`button, a, input, label`));return e=>{if(!e){clearTimeout(u.memo.timer),u.clean();return}u.mount(e),e.addEventListener(`contextmenu`,l),e.addEventListener(`touchmove`,l,{passive:!1})}},Vt=e=>{let t=yt(),n=wt(),r=new Map;return(i,a=``)=>{let o=`${a}:${i}`;return r.has(o)||r.set(o,Bt(i,a,t,n,t=>e(i,t))),r.get(o)}},Ht={start:`dragenter`,move:`dragover`,leave:`dragleave`,end:`drop`},Ut=(e,t=()=>!0)=>{let n={_active:!1,active:!1,depth:0,value:C(0,0),target:null,event:null,memo:{},isDropStart:!1,isDropping:!1,isDropEnd:!1,drop:()=>{let t=n._active;n.isDropStart=n.active&&!t,n.isDropping=n.active&&t,n.isDropEnd=!n.active&&t,e?.(),n._active=n.active},dropStart:e=>{n.depth++,!n.active&&t(e)&&(e.preventDefault(),n.event=e,n._active=!1,n.active=!0,C(e.clientX,e.clientY,n.value),n.drop(n))},dropping:e=>{n.active&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),n.event=e,C(e.clientX,e.clientY,n.value),n.drop(n))},dropLeave:e=>{n.depth>0&&n.depth--,!(n.depth>0||!n.active)&&(n.event=e,n.active=!1,n.drop(n))},dropEnd:e=>{n.depth=0,n.active&&(e.preventDefault(),n.event=e,n.active=!1,C(e.clientX,e.clientY,n.value),n.drop(n))},mount:e=>{n.target=e;let{start:t,move:r,leave:i,end:a}=Ht;e.addEventListener(t,n.dropStart),e.addEventListener(r,n.dropping),e.addEventListener(i,n.dropLeave),e.addEventListener(a,n.dropEnd)},clean:()=>{let e=n.target;if(!e)return;let{start:t,move:r,leave:i,end:a}=Ht;e.removeEventListener(t,n.dropStart),e.removeEventListener(r,n.dropping),e.removeEventListener(i,n.dropLeave),e.removeEventListener(a,n.dropEnd),n.depth=0,n.active=!1},ref:e=>{if(e)return void n.mount(e);n.clean()}};return n},Wt=e=>!!e.dataTransfer?.types.includes(`Files`),Gt=e=>new Promise(t=>e.readEntries(t)),Kt=async e=>{let t=e.createReader(),n=[],r=await Gt(t);for(;r.length>0;)n.push(...r),r=await Gt(t);return n},qt=e=>new Promise(t=>e.file(t)),Jt=async(e,t,n)=>{let r=t===``?e.name:`${t}/${e.name}`;if(e.isFile)return void n.push({path:r,file:await qt(e)});n.push({path:r,file:null});for(let t of await Kt(e))await Jt(t,r,n)},Yt=async e=>{let t=Array.from(e?.items??[]).map(e=>e.webkitGetAsEntry()).filter(e=>!!e),n=[];for(let e of t)await Jt(e,``,n);return n},Xt=(e,t,n=()=>!0)=>{let r=wt(),i=()=>r.begin(e,()=>!n()),a=()=>r.move(s.value[0],s.value[1]),o=()=>{let e=s.event.type===`drop`?r.read():null;r.end(),e!==null&&Yt(s.event.dataTransfer).then(n=>t(n,e))},s=Ut(()=>{s.isDropStart&&i(),s.isDropping&&a(),s.isDropEnd&&o()},Wt);return s.ref},D={add:d,arrowBack:f,arrowDropDown:p,check:m,chevronRight:g,closeIcon:_,cloud:te,deleteIcon:ne,folder:re,home:ie,keep:ae,keepFill:oe,leftPanelClose:se,leftPanelOpen:ce,menuIcon:le,moreVert:ue,redoIcon:de,schedule:fe,searchIcon:pe,settings:he,help:ge,keyboard:_e,sync:ve,undoIcon:ye,unfoldMore:be,visibilityOff:xe,createNewFolder:Se,uploadFile:Ce,driveFolderUpload:we,edit:Te,download:Ee,info:De,openInNew:Oe,restoreFromTrash:ke,description:Ae},Zt=({cls:e,search:t})=>u(`label`,{className:`h-8 items-center gap-2 rounded-lg border border-edge px-2 ${e}`,children:[l(v,{name:D.searchIcon,size:18,className:`text-mute`}),l(`input`,{value:t.value,onChange:e=>t.set(e.target.value),placeholder:t.placeholder,className:`min-w-0 flex-1 bg-transparent outline-none placeholder:text-xs placeholder:text-mute`})]}),Qt=({view:e})=>l(`div`,{className:`ml-auto flex h-8 shrink-0 overflow-hidden rounded-full border border-edge`,children:e.items.map((t,n)=>u(`button`,{onClick:()=>e.pick(t.id),className:`flex w-14 cursor-pointer items-center justify-center gap-1 ${n>0?`border-l border-edge`:``} ${e.value===t.id?`bg-band text-ink`:`text-mute hover:bg-pale`}`,children:[e.value===t.id&&l(v,{name:D.check,size:14}),l(v,{name:t.icon,size:18})]},t.id))}),$t=({chips:e,values:t,menus:n,menu:r,flip:i,pick:a,clear:o,lead:s,view:c,search:d})=>u(`div`,{className:`shrink-0 pt-3`,children:[d&&l(Zt,{cls:`flex md:hidden`,search:d}),u(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 md:mt-0`,children:[s,e.map(e=>{let s=t[e.id]??``,c=n[e.id]??[],d=s===``?e.label:c.find(e=>e.id===s)?.label??s,f=s===``||e.fixed;return u(`div`,{className:`relative flex items-center`,children:[u(`button`,{onClick:i(e.id),className:`flex h-8 cursor-pointer items-center gap-1 rounded-lg px-3 text-[12px] ${f?`border border-edge text-mute hover:bg-pale`:`bg-band text-ink`}`,children:[d,l(v,{name:D.arrowDropDown,size:18})]}),!f&&l(`button`,{onClick:o(e.id),className:`ml-1 flex h-6 w-6 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band`,children:l(v,{name:D.closeIcon,size:16})}),r===e.id&&l(b,{align:`left`,cls:`w-56`,items:c,value:s,pick:a(e.id,s),check:D.check})]},e.id)}),c&&l(Qt,{view:c}),d&&l(Zt,{cls:`ml-auto hidden w-64 md:flex`,search:d})]})]}),en=({count:e,min:t,cls:n=``,children:r})=>l(`div`,{className:`grid gap-4 overflow-x-auto ${n}`,style:{gridTemplateColumns:`repeat(${e}, minmax(${t}px, 1fr))`},children:r}),tn=({c:e,click:t})=>u(`button`,{onClick:t,className:`relative flex h-full w-full cursor-pointer flex-col items-start rounded-xl border border-edge bg-white p-3 text-left hover:bg-pale`,children:[l(`span`,{className:`flex h-[30px] w-[30px] items-center justify-center rounded-md bg-band`,children:l(v,{name:e.icon??``,size:18,color:e.color})}),l(v,{name:D.add,size:16,className:`absolute right-3 top-3 text-mute`}),l(`span`,{className:`mt-2 w-full truncate text-[14px] leading-[17px]`,children:e.label})]}),nn=({c:e,click:t})=>u(`button`,{onClick:t,className:`flex h-12 w-full cursor-pointer items-center gap-3 rounded-xl border border-edge bg-white px-4 text-left hover:bg-pale`,children:[l(v,{name:e.icon??``,size:18,color:e.color}),l(`span`,{className:`truncate`,children:e.label}),l(v,{name:D.add,size:16,className:`ml-auto shrink-0 text-mute`})]}),rn=({cards:e,click:t,popup:n,count:r=4})=>u(c,{children:[l(en,{count:r,min:tt.card,cls:`hidden md:grid`,children:e.map(e=>u(`div`,{className:`relative`,children:[l(tn,{c:e,click:t(e)}),n(e)]},e.id))}),l(`div`,{className:`flex flex-col gap-2 md:hidden`,children:e.map(e=>u(`div`,{className:`relative`,children:[l(nn,{c:e,click:t(e)}),n(e)]},e.id))})]}),an=e=>l(`section`,{className:`relative shrink-0 px-4 pt-3 md:pl-7 md:pr-9`,children:l(rn,{...e})}),on=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,sn=`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,cn=({icon:e,color:t,label:n,home:r,actions:i,drawer:a})=>u(`header`,{className:`fixed inset-x-0 top-0 z-20 flex h-14 items-center gap-1 bg-white pl-4 pr-3 md:hidden`,children:[u(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[l(v,{name:e,size:24,color:t}),l(`span`,{className:`truncate text-sm font-bold`,children:n})]}),u(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[i,l(`button`,{onClick:a,className:on,children:l(v,{name:D.menuIcon,size:22})})]})]}),ln=({icon:e,size:t=20,click:n,children:r})=>u(`span`,{className:`relative hidden md:flex`,children:[l(`button`,{onClick:n,className:sn,children:l(v,{name:e,size:t})}),r]}),un=({bar:e,open:t,title:n,back:r,undo:i,redo:a,expand:o,actions:s})=>u(`div`,{className:`mt-2.5 flex h-8 shrink-0 items-center gap-2 px-4 md:pl-7 md:pr-9`,children:[!e&&l(`button`,{onClick:t,className:`${sn} hidden md:flex`,children:l(v,{name:D.leftPanelOpen,size:20})}),!r&&l(`h1`,{className:`min-w-0 truncate font-bold`,children:n}),r&&u(`button`,{onClick:r,className:`flex min-w-0 cursor-pointer items-center gap-2 font-bold`,children:[l(v,{name:D.arrowBack,size:20,className:`text-mute`}),l(`span`,{className:`truncate`,children:n})]}),u(`div`,{className:`relative ml-auto flex shrink-0 items-center gap-1`,children:[i&&l(ln,{icon:D.undoIcon,click:i}),a&&l(ln,{icon:D.redoIcon,click:a}),o&&u(`button`,{onClick:o.click,className:`flex h-8 cursor-pointer items-center gap-1 rounded-lg px-2 hover:bg-band ${o.on?`text-ink`:`text-mute`}`,children:[l(`span`,{className:`hidden md:inline`,children:o.label}),l(v,{name:o.icon||D.unfoldMore,size:18})]}),s]})]}),dn=({icon:e,size:t=20,click:n,children:r})=>u(`span`,{className:`relative flex`,children:[l(`button`,{onClick:n,className:on,children:l(v,{name:e,size:t})}),r]}),fn=D.moreVert,pn=e=>`flex w-full cursor-pointer items-center rounded-lg text-left text-[14px] text-mute ${e?`bg-band`:`hover:bg-band`}`,mn=({open:e,turn:t})=>t?l(`button`,{onClick:t,className:`flex shrink-0 items-center justify-center`,style:{width:x.slot,height:x.slot},children:l(v,{name:D.chevronRight,size:x.slot,className:e?`rotate-90`:``})}):l(`span`,{className:`shrink-0`,style:{width:x.slot}}),O=({depth:e=0,on:t=!1,open:n,turn:r,icon:i,color:a,label:o,drop:s,mark:c,from:d,click:f,dclick:p,rclick:m,dragRef:h,children:g})=>u(`div`,{ref:h,"data-drop":s,"data-drop-mark":c,"data-drop-from":d,onClick:e=>(f?.(e),r?.(e)),onDoubleClick:p,onContextMenu:m,className:pn(t),style:{height:x.row,paddingLeft:e*x.indent},children:[l(mn,{open:n,turn:r}),l(v,{name:i,size:x.icon,color:a}),l(`span`,{className:`min-w-0 flex-1 truncate ${t?`text-ink`:``}`,style:{marginLeft:x.gap},children:o}),g]}),hn=({icon:e,size:t=16,cls:n=`hidden md:flex`,click:r,children:i})=>u(`span`,{"data-ghost-hide":``,className:`relative shrink-0 ${n}`,children:[l(`button`,{onClick:r,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-full hover:bg-line`,children:l(v,{name:e,size:t})}),i]}),gn=e=>l(hn,{icon:D.arrowDropDown,size:18,...e}),_n=e=>l(hn,{icon:D.moreVert,size:16,...e}),vn=`STORAGE`,yn=`アップグレード`,bn=`https://stripe.com`,xn=`ゴミ箱を空にしますか?中のアイテムは完全に削除されます`,Sn=`新しいフォルダ`,Cn=`無題のフォルダ`,wn=`名前を変更`,Tn=`All files`,En=`ピン留めを解除`,Dn=[{id:`manage`,icon:D.cloud,label:`保存容量を管理`},{id:`empty`,icon:D.deleteIcon,label:`ゴミ箱を空にする`},{id:`refresh`,icon:D.sync,label:`使用状況を更新`}],On=[{id:`undo`,icon:D.undoIcon,label:`直前の操作を元に戻す`},{id:`redo`,icon:D.redoIcon,label:`最後に元に戻した操作をやり直す`},{id:`settings`,icon:D.settings,label:`設定`,top:!0},{id:`help`,icon:D.help,label:`ヘルプ`},{id:`shortcuts`,icon:D.keyboard,label:`キーボードショートカット`}],kn=On,An=D.visibilityOff,jn=(e,t,n)=>[{id:`band`,icon:An,label:e?`すべての${t}を非表示`:`すべての${t}を表示`},...n.map((e,t)=>t===0?{...e,top:!0}:e)],Mn=[{id:`folder`,icon:D.createNewFolder,label:`新しいフォルダ`},{id:`upload`,icon:D.uploadFile,label:`ファイルのアップロード`,top:!0},{id:`upload-folder`,icon:D.driveFolderUpload,label:`フォルダのアップロード`}],Nn=[{id:`rename`,icon:D.edit,label:`名前を変更`},{id:`folder`,icon:D.createNewFolder,label:`新しいフォルダ`},{id:`upload`,icon:D.uploadFile,label:`ファイルのアップロード`,top:!0},{id:`upload-folder`,icon:D.driveFolderUpload,label:`フォルダのアップロード`},{id:`info`,icon:D.info,label:`フォルダ情報`,top:!0},{id:`remove`,icon:D.deleteIcon,label:`ゴミ箱に移動`}],Pn=[{id:`rename`,icon:D.edit,label:`名前を変更`},{id:`download`,icon:D.download,label:`ダウンロード`},{id:`info`,icon:D.info,label:`ファイル情報`,top:!0},{id:`remove`,icon:D.deleteIcon,label:`ゴミ箱に移動`},{id:`pin`,icon:D.keep,label:`ピン留めする`}],Fn=[{id:`purge`,icon:D.deleteIcon,label:`完全に削除`},{id:`restore`,icon:D.restoreFromTrash,label:`復元`}],In=e=>t=>t.id===`pin`&&e.pinned?{...t,label:En}:t,Ln=e=>e.trashed?Fn:e.kind.startsWith(`folder`)?Nn:Pn.map(In(e)),Rn=({extra:e=[],pinned:t=!1,copy:n=!0,pin:r=!0}={})=>[{id:`rename`,icon:D.edit,label:`名前を変更`},...n?[{id:`copy`,icon:D.description,label:`コピーを作成`}]:[],...e,...r?[{id:`pin`,icon:t?D.keepFill:D.keep,label:t?En:`ピン留めする`}]:[],{id:`remove`,icon:D.deleteIcon,label:`ゴミ箱に移動`,top:!0}],zn=[{id:`band`,label:`テンプレートを表示`},{id:`bar`,label:`left bar を表示`}],Bn=[{keys:`↑ ↓`,label:`一覧の行を移動`},{keys:`Enter`,label:`ファイルを開く`},{keys:`Mod + Z`,label:`元に戻す`},{keys:`Mod + Shift + Z`,label:`やり直す`},{keys:`Delete`,label:`ゴミ箱に移動`}],k={settings:`設定`,help:`ヘルプ`,shortcuts:`キーボードショートカット`},Vn=Object.keys(k),Hn=e=>`${e.name}\n場所: /${e.parent}\n種類: ${e.kind}\nサイズ: ${e.size}\n更新: ${e.date}`,Un=e=>e===``?Tn:e.split(`/`).pop()??`All files`,Wn=`ファイルがありません`,Gn=e=>e.kind.startsWith(`folder`)&&!e.trashed?e.id:void 0,Kn=({e,kinds:t})=>{let n=t[e.kind]??t.file;return l(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-band`,children:l(v,{name:n.icon,size:20,color:n.color})})},qn=({rows:e,kinds:t,menu:n,point:r,flip:i,context:a,open:o,pick:s,drag:c})=>e.length===0?l(`p`,{className:`px-4 pt-8 text-mute md:px-7`,children:Wn}):l(`div`,{className:`flex flex-1 flex-col px-4 pb-10 md:pl-7 md:pr-9`,children:l(`div`,{className:`mt-3`,children:e.map(e=>u(`div`,{ref:e.trashed?void 0:c(e.id,`list`),"data-drop":Gn(e),"data-drop-mark":Gn(e),onDoubleClick:o(e),onContextMenu:a(`row:${e.id}`),className:`flex cursor-pointer items-center gap-3 border-b border-line py-3 pl-2.5 pr-1 hover:bg-pale`,children:[l(Kn,{e,kinds:t}),u(`span`,{className:`flex min-w-0 flex-1 items-center gap-1 truncate text-[14px]`,children:[e.name,e.pinned&&l(v,{name:D.keepFill,size:14,className:`shrink-0 text-mute`})]}),l(`span`,{className:`hidden shrink-0 text-mute md:inline`,children:e.size}),l(`span`,{className:`hidden shrink-0 text-mute md:inline`,children:e.date}),l(_n,{cls:`flex`,click:i(`row:${e.id}`),children:n===`row:${e.id}`&&l(b,{point:r,items:Ln(e),pick:s(e),check:D.check})})]},e.id))})}),Jn={ask:`Ask me anything...`,brand:`Claude`,voice:`音声モード`,file:`ファイル`},A=[{id:`claude-fable-5`,label:`Fable 5`,desc:`最も困難な課題に`},{id:`claude-opus-5`,label:`Opus 5`,desc:`複雑なタスク向け`},{id:`claude-sonnet-5`,label:`Sonnet 5`,desc:`日常のタスクに最適`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`,desc:`素早い回答に最適`}],j={w:376,left:12,top:12,bottom:16,minH:180},M=e(``),N={send:async()=>``,stream:{parse:()=>[],send:async()=>[]},icon:``,path:``,headers:{},hello:()=>({greet:``,title:``,desc:``,prompts:[]}),commands:()=>[],hints:()=>[],menu:{useOpen:()=>n(M),flip:e=>n=>{n.stopPropagation(),t(M,M.value===e?``:e)},close:()=>t(M,``)}},Yn=e=>void Object.assign(N,e),Xn=(e,t=20,n=6)=>{let r=o(null);return a(()=>{let e=r.current;if(!e)return;e.style.height=`${t}px`;let i=Math.max(1,Math.round(e.scrollHeight/t));e.style.height=`${Math.min(i,n)*t}px`},[e]),r},Zn=(()=>{let e=new Be({linkify:!0,breaks:!0}),t=t=>e.render(t);return{render:t,plain:e=>{let n=document.createElement(`div`);return n.innerHTML=t(e),n.textContent?.trim()??``}}})(),P=e(!1),F=e([]),I=e(``),Qn=e([0,0]),$n=e(A[0].id),L=e(!1),R=e(!1),er=()=>L.value,tr=()=>n(L),nr=e(!1);let rr=null;const ir=()=>{let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(!e)return null;let n=new e;return n.lang=`ja-JP`,n.continuous=!0,n.interimResults=!1,n.onresult=e=>{let n=``;for(let t=e.resultIndex;t<e.results.length;t++)e.results[t].isFinal&&(n+=e.results[t][0].transcript);n!==``&&t(I,I.value+n)},n.onend=()=>t(nr,!1),n},ar=()=>{if(nr.value)return void rr?.stop();rr??=ir(),rr&&(rr.start(),t(nr,!0))};let z=[0,0,28,28];const or=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n)),sr=()=>{let[e,t]=Qn.value,n=B.target.getBoundingClientRect();z=[n.left-e,n.top-t,n.width,n.height]},cr=()=>{let e=or(B.offset[0],-z[0],window.innerWidth-z[2]-z[0]),n=or(B.offset[1],-z[1],window.innerHeight-z[3]-z[1]);C(e,n,B.offset),t(Qn,[e,n])},B=Lt(()=>{B.isDragStart&&sr(),cr()}),lr=()=>{C(0,0,B.offset),t(Qn,[0,0])},ur=()=>{let e=B.target;!e||!e.isConnected||(sr(),cr())},dr=()=>{i(()=>(ur(),window.addEventListener(`resize`,ur),()=>window.removeEventListener(`resize`,ur)),[])},fr=e=>`calc(max(${j.left}px, 100vw - ${j.w+j.left}px) + ${e}px)`,pr=e=>j.top+e,mr=e=>`max(${j.minH}px, min(calc(100dvh - ${j.top+j.left}px), calc(100dvh - ${j.top+j.bottom+e}px)))`,hr=e(null),V=e(0),gr=(e,t)=>{if(t)return t;if(!e.startsWith(`/`))return[];let n=e.slice(1).trim().toLowerCase();return N.commands().filter(e=>e.name.toLowerCase().startsWith(n))},_r=()=>{t(hr,null),t(V,0)},H=async e=>{t(I,``),_r();let n=await e.run();Array.isArray(n)&&t(hr,n)},vr=e=>{if(!e.startsWith(`/`))return;let t=e.slice(1).trim().toLowerCase();return N.commands().find(e=>e.name.toLowerCase()===t)??gr(e,null)[0]},yr=e=>{if(e.nativeEvent?.isComposing)return!1;let n=gr(I.value,hr.value);if(n.length===0)return!1;let r=V.value%n.length;return e.key===`ArrowDown`?(e.preventDefault(),t(V,(r+1)%n.length),!0):e.key===`ArrowUp`?(e.preventDefault(),t(V,(r-1+n.length)%n.length),!0):e.key===`Escape`?(e.preventDefault(),t(I,``),_r(),!0):e.key===`Enter`&&(e.preventDefault(),H(n[r]),!0)},br=(()=>{let e=e=>e.replace(/[^0-9A-Za-zぁ-んァ-ヴー一-龠々\s]/g,` `).replace(/\s+/g,` `).trim(),t=e=>{let t=document.createElement(`div`);return t.innerHTML=Zn.render(e),t.querySelectorAll(`pre`).forEach(e=>e.remove()),t.textContent??``};return{lines:n=>t(n).split(`
2
+ `).map(e).filter(e=>e!==``)}})();let U=0,xr=[];const Sr=[`Kyoko`,`O-Ren`,`Nanami`,`Ayumi`,`Haruka`,`Sayaka`,`Samantha`,`Zira`,`Aria`,`Jenny`,`Ava`,`Sonia`,`Google 日本語`,`Google US English`],Cr=[`Otoya`,`Ichiro`,`Keita`,`David`,`Mark`,`Guy`,`Alex`,`Daniel`,`Fred`,`Andrew`,`Brian`],wr=()=>xr=speechSynthesis.getVoices(),Tr=e=>{xr.length===0&&wr();let t=xr.filter(t=>t.lang.replace(`_`,`-`).startsWith(e.slice(0,2)));return t.find(e=>Sr.some(t=>e.name.includes(t)))??t.find(e=>!Cr.some(t=>e.name.includes(t)))??t[0]??null},Er=e=>{(e.match(/[A-Za-z][0-9A-Za-z]*(?: (?:[0-9]+ )*[A-Za-z][0-9A-Za-z]*)*|(?:(?![A-Za-z]).)+/g)??[]).forEach(e=>{if(e.trim()===``)return;let t=new SpeechSynthesisUtterance(e);t.lang=/^[A-Za-z]/.test(e)?`en-US`:`ja-JP`,t.voice=Tr(t.lang),speechSynthesis.speak(t)})};speechSynthesis.addEventListener(`voiceschanged`,wr);const Dr=e=>{if(!R.value)return;let t=e.split(`
3
3
  `).slice(0,-1).join(`
4
- `),n=yn.lines(t);n.slice(H).forEach(Tn),H=n.length},Dn=e=>{N.value&&yn.lines(e).slice(H).forEach(Tn),H=0},On=()=>{H=0,speechSynthesis.cancel()},kn=()=>t(O,!0),An=()=>{un(),On(),B(),t(O,!1)},jn=()=>{if(O.value)return An();kn()},Mn=e=>{B(),t(A,e.target.value)},Nn=()=>{let e=A.value.trim();if(e===``||M.value)return;let n=_n(e);if(n)return void V(n);t(A,``),D.send({prompt:e})},Pn=e=>{vn(e)||e.key!==`Enter`||e.nativeEvent?.isComposing||e.shiftKey||(e.preventDefault(),Nn())},Fn=e=>()=>{let t=_n(e);if(t)return void V(t);D.send({prompt:e})},In=()=>{N.value&&On(),t(N,!N.value)},Ln=e=>{D.menu.close(),t(rn,e.id)},Rn=()=>l(`div`,{className:`flex shrink-0 items-start justify-between px-2`,children:[c(g,{name:u,size:50,className:`text-mute`}),l(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{ref:L.ref,className:`flex h-7 w-7 cursor-grab touch-none select-none items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink active:cursor-grabbing`,children:c(g,{name:d,size:20})}),c(`button`,{onClick:An,className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,children:c(g,{name:p,size:20})})]})]}),zn=()=>{let e=D.hello();return l(`div`,{className:`flex h-full flex-col items-center justify-center px-3 text-center`,children:[c(g,{name:u,size:56,className:`mb-5 text-mute`}),c(`p`,{className:`text-mute`,children:e.greet}),c(`p`,{className:`mt-1 font-bold leading-[26px]`,children:e.title}),c(`p`,{className:`mt-3 text-mute`,children:e.desc}),c(`div`,{className:`-mx-6 mt-6 flex flex-wrap justify-center gap-1.5`,children:e.prompts.map(e=>l(`button`,{onClick:Fn(e.prompt??e.label),className:`flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-full border border-edge bg-white px-2.5 py-1 text-[12px] leading-[16px] hover:bg-pale`,children:[e.icon&&c(g,{name:e.icon,size:14,color:e.color}),e.label]},e.label))})]})},Bn=({t:e})=>l(`div`,{className:`-mt-4 ml-3 flex max-w-full items-center rounded-lg border border-edge bg-band p-2`,children:[e.icon&&c(g,{name:e.icon,size:16}),c(`span`,{className:`mx-2 truncate text-[12px]`,children:e.label}),c(`button`,{className:`hidden ml-1 flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-line`,children:c(g,{name:oe,size:16})})]}),Vn=({m:e})=>l(`div`,{className:`mr-7 flex flex-col items-start ${e.tools?.length?`mb-6`:``}`,children:[c(`div`,{className:`chat-md w-full rounded-xl border border-edge bg-white p-3 ${e.tools?.length?`pb-5`:``}`,dangerouslySetInnerHTML:{__html:nn.render(e.text)}}),e.tools?.map((e,t)=>c(Bn,{t:e},t))]}),Hn=({m:e})=>c(`div`,{className:`ml-7 min-w-0 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-2xl border border-edge bg-band p-3`,children:e.text}),Un=()=>c(`div`,{className:`flex w-fit items-center rounded-lg border border-edge bg-white px-2 py-1 text-mute`,children:c(g,{name:oe,size:20,className:`animate-pulse`})}),Wn=()=>{let e=n(k),t=n(M),i=a(null);return r(()=>void i.current?.scrollTo(0,9e9),[e]),c(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:l(`div`,{ref:i,className:`flex h-full flex-col gap-5 overflow-y-auto px-2 pb-4 pt-10 text-[14px] leading-[22px]`,children:[e.length===0&&c(zn,{}),e.map((e,t)=>e.role===`user`?c(Hn,{m:e},t):c(Vn,{m:e},t)),t&&e[e.length-1]?.role===`user`&&c(Un,{})]})})},Gn=()=>{let e=n(A);return n(P)?c(`button`,{onClick:on,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-[#EA4335]`,children:c(g,{name:ne,size:20})}):e.trim()===``?c(`button`,{onClick:on,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-mute hover:text-ink`,children:c(g,{name:ee,size:20})}):c(`button`,{onClick:Nn,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-ink hover:text-[#4185F4]`,children:c(g,{name:te,size:20})})},Kn=()=>{let e=n(A),t=n(R),r=n(z),i=gn(e,t);return i.length===0?null:c(`div`,{className:`absolute inset-x-0 bottom-full z-10 mb-2 max-h-56 overflow-y-auto rounded-xl border border-edge bg-white py-1 shadow-[0_8px_24px_rgba(0,0,0,0.12)]`,children:i.map((e,n)=>l(`button`,{onClick:()=>void V(e),className:`flex w-full cursor-pointer items-center gap-3 px-3 py-1.5 text-left text-[12px] leading-[16px] ${n===r%i.length?`bg-band`:`hover:bg-pale`}`,children:[c(`span`,{className:`shrink-0 font-bold`,children:t?e.label??e.name:`/${e.name}`}),c(`span`,{className:`min-w-0 flex-1 truncate text-right text-mute`,children:e.desc})]},`${e.name}-${n}`))})},qn=()=>{let e=n(k),t=n(M)?[]:D.hints(e);return t.length===0?null:c(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1.5 pb-2`,children:t.map(e=>c(`button`,{onClick:()=>void V(e),className:`cursor-pointer rounded-full border border-edge bg-white px-2.5 py-1 text-[12px] leading-[16px] hover:bg-pale`,children:e.label??e.name},e.name))})},Jn=()=>{let e=n(A),t=n(rn),r=n(N),i=D.menu.useOpen(),a=tn(e),o=w.find(e=>e.id===t)??w[0];return l(`div`,{className:`relative shrink-0 rounded-xl border border-edge`,children:[c(Kn,{}),l(`label`,{className:`flex items-start gap-2 px-3 pb-7 pt-3`,children:[c(g,{name:h,size:20,className:`text-mute`}),c(`textarea`,{ref:a,rows:1,value:e,onChange:Mn,onKeyDown:Pn,placeholder:C.ask,className:`min-w-0 flex-1 resize-none overflow-y-auto bg-transparent text-[14px] leading-[20px] outline-none placeholder:text-mute`}),c(Gn,{})]}),l(`div`,{className:`flex h-9 items-center border-t border-line px-3 text-[12px]`,children:[l(`span`,{className:`relative flex`,children:[l(`button`,{onClick:D.menu.flip(`chat-model`),className:`flex cursor-pointer items-center gap-1`,children:[C.brand,` `,o.label,c(g,{name:ae,size:16,className:`text-mute`})]}),i===`chat-model`&&c(Ye,{align:`left`,cls:`w-64`,items:w,value:t,pick:Ln,check:ce})]}),l(`div`,{className:`ml-auto flex items-center gap-3`,children:[l(`button`,{onClick:In,className:`flex cursor-pointer items-center gap-1 ${r?`text-[#4185F4]`:``}`,children:[c(g,{name:re,size:18}),C.voice]}),l(`button`,{className:`flex cursor-pointer items-center gap-1`,children:[c(g,{name:ie,size:18}),C.file]})]})]})]})},Yn=()=>c(`button`,{onClick:jn,className:`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,children:c(g,{name:u,size:22})}),Xn=()=>{fn();let[e,t]=n(j);return l(`div`,{className:`fixed z-50 flex w-[376px] max-w-[calc(100vw-24px)] flex-col rounded-2xl border border-line bg-white p-3 text-ink shadow-[0_8px_24px_rgba(0,0,0,0.12)]`,style:{left:pn(e),top:mn(t),height:hn(t)},children:[c(Rn,{}),c(Wn,{}),c(qn,{}),c(Jn,{})]})},Zn=()=>n(O)?c(Xn,{}):null,Qn=e=>({role:`agent`,text:e.text,tools:e.tools.map(e=>({icon:D.icon,label:`${e.server?`${e.server} - `:``}${e.name} (MCP)`}))}),$n=e=>t(k,e.flatMap(e=>[{role:`user`,text:e.prompt},Qn({text:e.reply,tools:e.tools.map(e=>({server:``,name:e}))})])),er=e=>e.map(e=>e.tools.length?`${e.text}\n`:e.text).join(`
5
- `),tr=async e=>{if(M.value)return`busy: previous chat is still running`;let n=[...k.value,{role:`user`,text:e}];On(),t(k,n),t(M,!0);let r=await D.stream.send({prompt:e,path:D.path,model:rn.value,headers:D.headers},e=>{t(k,[...n,...e.items.map(Qn)]),En(er(e.items))});return Dn(er(r)),t(M,!1),`chat sent: ${e}`},nr=e=>{let t=[],n=``,r=[],i=()=>Math.floor(new Date().getHours()/6),a=r=>{let a=i(),o=n,s=t.find(e=>e.name===r&&e.part===a&&e.after===o);s&&(s.count+=1),s||t.push({name:r,part:a,after:o,count:1}),n=r,e.store.save({name:r,part:a,after:o})},o=e=>t.reduce((t,r)=>r.name===e?t+r.count*(r.part===i()?2:1)*(r.after===n?2:1):t,0),s=e=>[...e].sort((e,t)=>o(t.name)-o(e.name)),c=()=>(r.length===0&&(r=e.deck.map(e=>({...e,run:()=>(a(e.name),e.run())}))),s(r));return{commands:c,hello:()=>{let t=c(),n=t.filter(t=>e.starters().includes(t.name)),r=[...new Set([...e.pinned(),...n.map(e=>e.name)])].flatMap(e=>t.filter(t=>t.name===e));return{...e.greet,prompts:r.map(e=>({label:e.label??e.name,prompt:`/${e.name}`}))}},hints:t=>e.hinted(t).flatMap(e=>c().filter(t=>t.name===e)),prime:async()=>{t=await e.store.list()}}},rr=(e,t)=>e.map((n,r)=>{let i=e[r+1]?.seq??1/0;return{...n,names:t.filter(e=>e.seq>n.seq&&e.seq<i).map(e=>e.name)}}),ir=e=>e.replace(/\s+/g,` `).trim().slice(0,40),ar=e=>{let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?`たった今`:t<3600?`${Math.floor(t/60)} 分前`:t<86400?`${Math.floor(t/3600)} 時間前`:`${Math.floor(t/86400)} 日前`},or=e=>{let t=crypto.randomUUID(),n=0,r=[],i=()=>{t=crypto.randomUUID(),n=0,r=[],e.show([])},a=async()=>(await e.store.list()).map(e=>({...e,when:ar(e.updatedAt)})),o=async i=>{let a=await e.store.load(i),o=rr(a.talks,a.tools).map(e=>({prompt:e.prompt,reply:e.reply,tools:e.names}));t=i,n=[...a.talks,...a.tools].reduce((e,t)=>Math.max(e,t.seq),0),r=o.flatMap(e=>[{role:`user`,content:e.prompt},{role:`assistant`,content:e.reply}]),e.show(o)},s=(i,a,o=``)=>{let s=a.filter(e=>!e.error),c=s.map(e=>e.text).filter(e=>e!==``).join(`
4
+ `),n=br.lines(t);n.slice(U).forEach(Er),U=n.length},Or=e=>{R.value&&br.lines(e).slice(U).forEach(Er),U=0},kr=()=>{U=0,speechSynthesis.cancel()},Ar=()=>t(P,!0),jr=()=>{lr(),kr(),_r(),t(P,!1)},Mr=()=>{if(P.value)return jr();Ar()},Nr=e=>{_r(),t(I,e.target.value)},Pr=()=>{let e=I.value.trim();if(e===``||L.value)return;let n=vr(e);if(n)return void H(n);t(I,``),N.send({prompt:e})},Fr=e=>{yr(e)||e.key!==`Enter`||e.nativeEvent?.isComposing||e.shiftKey||(e.preventDefault(),Pr())},Ir=e=>()=>{let t=vr(e);if(t)return void H(t);N.send({prompt:e})},Lr=()=>{R.value&&kr(),t(R,!R.value)},Rr=e=>{N.menu.close(),t($n,e.id)},zr=()=>u(`div`,{className:`flex shrink-0 items-start justify-between px-2`,children:[l(v,{name:je,size:50,className:`text-mute`}),u(`div`,{className:`flex items-center gap-2`,children:[l(`button`,{ref:B.ref,className:`flex h-7 w-7 cursor-grab touch-none select-none items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink active:cursor-grabbing`,children:l(v,{name:Me,size:20})}),l(`button`,{onClick:jr,className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,children:l(v,{name:ee,size:20})})]})]}),Br=()=>{let e=N.hello();return u(`div`,{className:`flex h-full flex-col items-center justify-center px-3 text-center`,children:[l(v,{name:je,size:56,className:`mb-5 text-mute`}),l(`p`,{className:`text-mute`,children:e.greet}),l(`p`,{className:`mt-1 font-bold leading-[26px]`,children:e.title}),l(`p`,{className:`mt-3 text-mute`,children:e.desc}),l(`div`,{className:`-mx-6 mt-6 flex flex-wrap justify-center gap-1.5`,children:e.prompts.map(e=>u(`button`,{onClick:Ir(e.prompt??e.label),className:`flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-full border border-edge bg-white px-2.5 py-1 text-[12px] leading-[16px] hover:bg-pale`,children:[e.icon&&l(v,{name:e.icon,size:14,color:e.color}),e.label]},e.label))})]})},Vr=({t:e})=>u(`div`,{className:`-mt-4 ml-3 flex max-w-full items-center rounded-lg border border-edge bg-band p-2`,children:[e.icon&&l(v,{name:e.icon,size:16}),l(`span`,{className:`mx-2 truncate text-[12px]`,children:e.label}),l(`button`,{className:`hidden ml-1 flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-line`,children:l(v,{name:ze,size:16})})]}),Hr=({m:e})=>u(`div`,{className:`mr-7 flex flex-col items-start ${e.tools?.length?`mb-6`:``}`,children:[l(`div`,{className:`chat-md w-full rounded-xl border border-edge bg-white p-3 ${e.tools?.length?`pb-5`:``}`,dangerouslySetInnerHTML:{__html:Zn.render(e.text)}}),e.tools?.map((e,t)=>l(Vr,{t:e},t))]}),Ur=({m:e})=>l(`div`,{className:`ml-7 min-w-0 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-2xl border border-edge bg-band p-3`,children:e.text}),Wr=()=>l(`div`,{className:`flex w-fit items-center rounded-lg border border-edge bg-white px-2 py-1 text-mute`,children:l(v,{name:ze,size:20,className:`animate-pulse`})}),Gr=()=>{let e=n(F),t=n(L),r=o(null);return i(()=>void r.current?.scrollTo(0,9e9),[e]),l(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:u(`div`,{ref:r,className:`flex h-full flex-col gap-5 overflow-y-auto px-2 pb-4 pt-10 text-[14px] leading-[22px]`,children:[e.length===0&&l(Br,{}),e.map((e,t)=>e.role===`user`?l(Ur,{m:e},t):l(Hr,{m:e},t)),t&&e[e.length-1]?.role===`user`&&l(Wr,{})]})})},Kr=()=>{let e=n(I);return n(nr)?l(`button`,{onClick:ar,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-[#EA4335]`,children:l(v,{name:Fe,size:20})}):e.trim()===``?l(`button`,{onClick:ar,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-mute hover:text-ink`,children:l(v,{name:Ne,size:20})}):l(`button`,{onClick:Pr,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-ink hover:text-[#4185F4]`,children:l(v,{name:Pe,size:20})})},qr=()=>{let e=n(I),t=n(hr),r=n(V),i=gr(e,t);return i.length===0?null:l(`div`,{className:`absolute inset-x-0 bottom-full z-10 mb-2 max-h-56 overflow-y-auto rounded-xl border border-edge bg-white py-1 shadow-[0_8px_24px_rgba(0,0,0,0.12)]`,children:i.map((e,n)=>u(`button`,{onClick:()=>void H(e),className:`flex w-full cursor-pointer items-center gap-3 px-3 py-1.5 text-left text-[12px] leading-[16px] ${n===r%i.length?`bg-band`:`hover:bg-pale`}`,children:[l(`span`,{className:`shrink-0 font-bold`,children:t?e.label??e.name:`/${e.name}`}),l(`span`,{className:`min-w-0 flex-1 truncate text-right text-mute`,children:e.desc})]},`${e.name}-${n}`))})},Jr=()=>{let e=n(F),t=n(L)?[]:N.hints(e);return t.length===0?null:l(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1.5 pb-2`,children:t.map(e=>l(`button`,{onClick:()=>void H(e),className:`cursor-pointer rounded-full border border-edge bg-white px-2.5 py-1 text-[12px] leading-[16px] hover:bg-pale`,children:e.label??e.name},e.name))})},Yr=()=>{let e=n(I),t=n($n),r=n(R),i=N.menu.useOpen(),a=Xn(e),o=A.find(e=>e.id===t)??A[0];return u(`div`,{className:`relative shrink-0 rounded-xl border border-edge`,children:[l(qr,{}),u(`label`,{className:`flex items-start gap-2 px-3 pb-7 pt-3`,children:[l(v,{name:me,size:20,className:`text-mute`}),l(`textarea`,{ref:a,rows:1,value:e,onChange:Nr,onKeyDown:Fr,placeholder:Jn.ask,className:`min-w-0 flex-1 resize-none overflow-y-auto bg-transparent text-[14px] leading-[20px] outline-none placeholder:text-mute`}),l(Kr,{})]}),u(`div`,{className:`flex h-9 items-center border-t border-line px-3 text-[12px]`,children:[u(`span`,{className:`relative flex`,children:[u(`button`,{onClick:N.menu.flip(`chat-model`),className:`flex cursor-pointer items-center gap-1`,children:[Jn.brand,` `,o.label,l(v,{name:Re,size:16,className:`text-mute`})]}),i===`chat-model`&&l(b,{align:`left`,cls:`w-64`,items:A,value:t,pick:Rr,check:h})]}),u(`div`,{className:`ml-auto flex items-center gap-3`,children:[u(`button`,{onClick:Lr,className:`flex cursor-pointer items-center gap-1 ${r?`text-[#4185F4]`:``}`,children:[l(v,{name:Ie,size:18}),Jn.voice]}),u(`button`,{className:`flex cursor-pointer items-center gap-1`,children:[l(v,{name:Le,size:18}),Jn.file]})]})]})]})},Xr=()=>l(`button`,{onClick:Mr,className:`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,children:l(v,{name:je,size:22})}),Zr=()=>{dr();let[e,t]=n(Qn);return u(`div`,{className:`fixed z-50 flex w-[376px] max-w-[calc(100vw-24px)] flex-col rounded-2xl border border-line bg-white p-3 text-ink shadow-[0_8px_24px_rgba(0,0,0,0.12)]`,style:{left:fr(e),top:pr(t),height:mr(t)},children:[l(zr,{}),l(Gr,{}),l(Jr,{}),l(Yr,{})]})},Qr=()=>n(P)?l(Zr,{}):null,$r=({drawer:e,close:t,dropRef:n,children:r})=>u(`div`,{ref:n,onClick:t,className:`flex h-dvh overflow-hidden bg-white font-medium text-ink`,children:[e&&l(`div`,{className:`fixed inset-0 z-30 bg-black/30 md:hidden`,onClick:t}),r]}),ei=({drop:e,from:t,children:n})=>l(`main`,{"data-drop":e,"data-drop-from":t,"data-drop-scope":``,className:`flex min-w-0 flex-1 flex-col overflow-y-auto pt-14 md:pt-0`,children:n}),ti=({title:e,children:t})=>u(`div`,{className:`flex flex-1 flex-col gap-4 px-4 pb-10 pt-6 md:pl-7 md:pr-9`,children:[l(`h2`,{className:`font-bold`,children:e}),t]}),ni=({value:e,flip:t})=>l(ti,{title:k.settings,children:zn.map(n=>u(`button`,{onClick:()=>t(n.id),className:`flex h-11 w-full max-w-xl cursor-pointer items-center justify-between rounded-xl border border-edge px-4 hover:bg-pale`,children:[l(`span`,{children:n.label}),l(`span`,{className:`flex h-[18px] w-[18px] items-center justify-center rounded-md border ${e[n.id]?`border-ink bg-ink text-white`:`border-edge bg-white`}`,children:e[n.id]&&l(v,{name:D.check,size:14})})]},n.id))}),ri=({lines:e})=>l(ti,{title:k.help,children:e.map(e=>l(`p`,{className:`max-w-2xl leading-7 text-mute`,children:e},e))}),ii=()=>l(ti,{title:k.shortcuts,children:Bn.map(e=>u(`div`,{className:`flex h-11 max-w-xl items-center justify-between border-b border-line`,children:[l(`span`,{className:`text-mute`,children:e.label}),l(`span`,{className:`rounded-md bg-band px-2 py-1 text-[12px]`,children:e.keys})]},e.keys))}),ai=({mode:e,lines:t,value:n,flip:r})=>e===`settings`?l(ni,{value:n,flip:r}):e===`help`?l(ri,{lines:t}):e===`shortcuts`?l(ii,{}):null,oi=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,si=({icon:e,color:t,label:n,click:r})=>u(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[l(v,{name:e,size:24,color:t}),l(`span`,{className:`truncate text-sm font-bold`,children:n})]}),ci=({storage:e,upgrade:t,menu:n,more:r})=>u(`div`,{className:`relative shrink-0 border-t border-line px-4 pb-4 pt-3`,children:[u(`div`,{className:`flex h-6 items-center gap-2 text-mute`,children:[l(v,{name:D.cloud,size:18}),l(`span`,{className:`tracking-wider`,children:vn}),u(`span`,{className:`relative ml-auto flex`,children:[l(`button`,{onClick:r,className:`flex h-6 w-6 items-center justify-center rounded-full text-mute hover:bg-band`,children:l(v,{name:D.moreVert,size:16})}),n]})]}),l(`div`,{className:`mt-1.5 h-2 overflow-hidden rounded-full bg-line`,children:l(`div`,{className:`h-full rounded-full bg-fill`,style:{width:`${Math.min(100,e.used/e.total*100)}%`}})}),l(`p`,{className:`mt-1.5`,children:e.text}),l(`button`,{onClick:t,className:`mt-2.5 h-9 w-full cursor-pointer rounded-full border border-ink font-bold hover:bg-band`,children:yn})]}),li=({brand:e,bar:t,drawer:n,fold:r,close:i,press:a,storage:o,upgrade:s,menu:c,more:d,children:f})=>u(`nav`,{"data-drop-scope":``,onClick:a,className:`fixed inset-y-0 left-0 z-40 flex shrink-0 flex-col border-r border-line bg-pale transition-transform md:static md:translate-x-0 ${n?`translate-x-0`:`-translate-x-full`} ${t?``:`md:hidden`}`,style:{width:x.width},children:[u(`div`,{className:`flex h-15 shrink-0 items-center gap-1 pr-2 text-[14px]`,style:{paddingLeft:x.brand},children:[l(si,{...e}),l(`button`,{onClick:r,className:`${oi} hidden md:flex`,children:l(v,{name:D.leftPanelClose,size:20})}),l(`button`,{onClick:i,className:`${oi} md:hidden`,children:l(v,{name:D.leftPanelClose,size:20})})]}),l(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-4`,children:f}),l(ci,{storage:o,upgrade:s,menu:c,more:d})]}),W={base:`/api/v1/storage`,trash:`.trash`,editors:[],self:``},ui=e=>void Object.assign(W,e),G=e=>e.kind.startsWith(`folder`),di=(e,t)=>e.name.localeCompare(t.name),fi=(e,t)=>t.iso.localeCompare(e.iso),pi=(e,t)=>{let n=e.filter(e=>e.parent===t&&!e.trashed);return[...n.filter(G).sort(di),...n.filter(e=>!G(e)).sort(di)]},mi=(e,t)=>e.filter(e=>!e.trashed&&e.kind===t).sort(fi),hi=e=>e.filter(e=>!e.trashed&&!G(e)).sort(fi).slice(0,12),gi=e=>e.filter(e=>e.trashed),_i=e=>e.filter(e=>!e.trashed&&!G(e)).sort((e,t)=>t.bytes-e.bytes),vi=(e,t)=>e.filter(e=>!e.trashed&&e.parent===t),yi=e=>{let t=e.split(`/`).filter(Boolean);return t.map((e,n)=>({name:n===0&&e===W.trash?`ゴミ箱`:e,path:t.slice(0,n+1).join(`/`)}))},bi=(e,t,n,r)=>t===`trash`?gi(e):t===`recent`?hi(e):t===`storage`?_i(e):t===r?mi(e,r):vi(e,n),xi=e=>e.filter(e=>!G(e)).reduce((e,t)=>e+t.bytes,0),Si=e=>{let{files:t,parent:n,depth:r,expand:i,active:a,kinds:o,fold:s,enter:d,file:f,open:p,menu:m,rclick:h,drag:g}=e;return l(c,{children:pi(t,n).map(t=>{let n=(o[t.kind]??o.file).icon;return G(t)?u(`div`,{children:[l(O,{depth:r,on:a===t.id,open:i.includes(t.id),turn:s(t.id),icon:o.folder.icon,label:t.name,drop:t.id,mark:t.id,click:d(t.id),rclick:h(t),dragRef:g(t.id,`tree`),children:m(t)}),i.includes(t.id)&&l(Si,{...e,parent:t.id,depth:r+1})]},t.id):l(O,{depth:r,icon:n,label:t.name,drop:t.parent,click:f?f(t):d(t.parent),dclick:p(t),rclick:h(t),dragRef:g(t.id,`tree`),children:m(t)},t.id)})})},K=e(!1),Ci=e(null),wi=()=>K.value,Ti=()=>n(K),Ei=()=>n(Ci),Di=e=>e.split(`/`).filter(Boolean).map(encodeURIComponent).join(`/`),Oi=(e,t=``,n={})=>{let r=t?`?do=${encodeURIComponent(t)}&arg=${encodeURIComponent(JSON.stringify(n))}`:``;location.href=`/${Di(e)}${r}`},ki=async e=>{let t=new URLSearchParams(location.search),n=t.get(`do`)??``;if(n===``)return``;let r=JSON.parse(t.get(`arg`)||`{}`);return history.replaceState(null,``,location.pathname+location.hash),typeof e[n]==`function`?(await e[n](r),n):`unknown intent: ${n}`},Ai=(e,t)=>e.name.localeCompare(t.name),ji=({spec:e,e:t,zone:n=`tree`})=>{let{shellMenu:i}=r(e.ai),a=Ei();return l(_n,{click:e.shell.flip(`${n}:${t.id}`),children:i===`${n}:${t.id}`&&l(b,{point:a,items:Ln(t),pick:e.shell.pickRow(t),check:D.check})})},Mi=({spec:e,id:t})=>{let{shellMenu:n}=r(e.ai);return u(gn,{click:e.shell.flip(t),children:[n===t&&t===`root`&&l(b,{items:Mn,pick:e.shell.pickHome,check:D.check}),n===t&&t!==`root`&&e.popup()]})},Ni=({spec:e})=>{let{mode:t,expand:n}=r(e.ai),i=e.ai.scan(`files/`).filter(t=>!t.trashed&&t.kind===e.service).sort(Ai),a=n.includes(`.open`),o=t=>t.id===e.file;return u(c,{children:[e.file===``&&u(`div`,{children:[l(O,{depth:1,on:t===`edit`,open:a,turn:e.shell.foldTree(`.open`),icon:e.kinds.folder.icon,label:e.fallback(),click:e.shell.goMode(`edit`)}),a&&e.leaf()]}),i.map(n=>u(`div`,{children:[l(O,{depth:1,on:t===`edit`&&o(n),open:o(n)&&a,turn:o(n)?e.shell.foldTree(`.open`):void 0,icon:e.kinds.folder.icon,label:n.name,click:o(n)?e.shell.goMode(`edit`):()=>Oi(n.id),dclick:e.shell.openFile(n),rclick:e.shell.context(`${e.service}:${n.id}`),dragRef:e.shell.grab(n.id,`tree`),children:l(ji,{spec:e,e:n,zone:e.service})}),o(n)&&a&&e.leaf()]},n.id))]})},Pi=({spec:e})=>{let{mode:t,folder:n,expand:i}=r(e.ai),a=e.ai.scan(`files/`),o=e.shell;return l(c,{children:e.links.map(r=>u(`div`,{children:[l(O,{on:r.id===``?t===``&&n===``:t===r.id,open:!!r.tree&&i.includes(r.tree),turn:r.tree?o.foldTree(r.tree):void 0,icon:r.icon,label:r.label,drop:r.drop,mark:r.drop,from:r.from,click:r.id===``?o.treeClick(``):o.goMode(r.id),children:r.menu&&l(Mi,{spec:e,id:r.menu})}),r.tree===`.home`&&i.includes(r.tree)&&l(Si,{files:a,parent:``,depth:1,expand:i,active:t===``?n:``,kinds:e.kinds,fold:o.foldTree,enter:o.treeClick,file:o.pickFile,open:o.openFile,rclick:e=>o.context(`tree:${e.id}`),menu:t=>l(ji,{spec:e,e:t}),drag:o.grab}),r.tree&&r.tree!==`.home`&&i.includes(r.tree)&&l(Ni,{spec:e})]},r.id))})},Fi=({spec:e,drawer:t,upgrade:n})=>{let{bar:i,storage:a,shellMenu:o}=r(e.ai),s=e.shell;return l(li,{brand:{...e.brand,click:s.treeClick(``)},bar:i,drawer:t,fold:()=>void e.ai.toggle_bar(),close:s.closeShell,press:s.press,storage:a,upgrade:n,more:s.flip(`storage`),menu:o===`storage`?l(b,{items:Dn,pick:s.pickStorage,check:D.check}):null,children:l(Pi,{spec:e})})},Ii=()=>window.open(bn,`_blank`),Li=({spec:e})=>{let{shellMenu:t,band:n}=r(e.ai);return u(c,{children:[e.extra?.(),l(ln,{icon:fn,click:e.shell.flip(`more`),children:t===`more`&&l(b,{cls:`w-80`,items:jn(n,e.bandLabel,On),pick:e.shell.pickPage,check:D.check})}),l(`span`,{className:`hidden md:flex`,children:l(Xr,{})}),l(`span`,{className:`hidden md:flex`,children:e.user})]})},Ri=({spec:e})=>{let{mode:t,folder:n}=r(e.ai);return t===`edit`?l(c,{children:e.title()}):t===``?l(c,{children:Un(n)}):l(c,{children:e.titles[t]??k[t]??Un(``)})},zi=({spec:e})=>{let{bar:t}=r(e.ai),n=e.history?{undo:()=>void e.ai.undo({}),redo:()=>void e.ai.redo({})}:{};return l(un,{bar:t,open:()=>void e.ai.toggle_bar(),title:l(Ri,{spec:e}),...n,expand:e.expand?.(),actions:l(Li,{spec:e})})},Bi=({spec:e})=>{let{shellMenu:t,band:n}=r(e.ai);return l(cn,{...e.brand,home:e.shell.treeClick(``),drawer:e.shell.openDrawer,actions:u(c,{children:[l(Xr,{}),l(dn,{icon:fn,click:e.shell.flip(`sp-more`),children:t===`sp-more`&&l(b,{items:jn(n,e.bandLabel,kn),pick:e.shell.pickPage,check:D.check})}),e.user]})})},Vi=({spec:e})=>{let{band:t,mode:n,shellMenu:i}=r(e.ai);return!t||!(e.bandModes??[`edit`,``,e.service]).includes(n)?null:l(an,{cards:e.bandCards,click:e.shell.pickCard,popup:t=>t.id===`new`&&i===`create`?e.popup():null})},Hi=({spec:e})=>{let{mode:t,folder:n,shellMenu:i}=r(e.ai),a=Ei(),o=e.shell;return l(qn,{rows:bi(e.ai.scan(`files/`),t,n,e.service),kinds:e.kinds,menu:i,point:a,flip:o.flip,context:o.context,open:o.openFile,pick:o.pickRow,drag:o.grab})},Ui=({spec:e})=>{let{mode:t,folder:n,band:i,bar:a}=r(e.ai),o=e.cover?.();if(o)return l(ei,{children:o});let s=Vn.includes(t);return u(ei,{drop:t===``?n:void 0,from:`tree os`,children:[l(zi,{spec:e}),s&&l(ai,{mode:t,lines:e.helpLines,value:{band:i,bar:a},flip:e.shell.flipSetting}),!s&&l(Vi,{spec:e}),t===`edit`&&e.editor(),!s&&t!==`edit`&&l(Hi,{spec:e})]})},Wi=({spec:e,close:t,children:n})=>{let r=Ti();return u($r,{drawer:r,close:t??e.shell.closeShell,dropRef:e.shell.drop,children:[l(Bi,{spec:e}),l(Fi,{spec:e,drawer:r,upgrade:Ii}),l(Ui,{spec:e}),l(Qr,{}),n]})},Gi=({items:e,pick:t})=>l(b,{align:`left`,items:e,pick:t,check:D.check}),Ki=e=>{e.stopPropagation(),t(K,!0)},qi=()=>t(K,!1),Ji=e=>t(Ci,{x:e.clientX,y:e.clientY}),Yi=()=>t(Ci,null),Xi=e=>e.split(`/`).filter(Boolean).map(encodeURIComponent).join(`/`),Zi=(e,t)=>e.then(e=>e.ok?e.json():t).catch(()=>t),q=e=>`${W.base}/${Xi(e)}`,Qi=()=>location.pathname.split(`/`).filter(Boolean).map(decodeURIComponent).join(`/`),$i=(e,t)=>{if(e===W.self)return`${location.origin}/${Xi(t)}`;let n=location.host.replace(RegExp(`^${W.self}(?=[.-])`),e);return`${n===location.host?`https://${e}.glre.dev`:`https://${n}`}/${Xi(t)}`},ea=({id:e},t)=>{let n=t[`files/${e}`];return n?n.kind.startsWith(`folder`)?`folder cannot be opened: ${e}`:(window.open(W.editors.includes(n.kind)?$i(n.kind,e):q(e),`_blank`),`opened ${n.name} in new tab`):`not found: ${e}`},J={list(e=``){return Zi(fetch(`${W.base}?prefix=${encodeURIComponent(e)}`),[])},get(e){return fetch(q(e))},put(e,t,n={}){let r=`?kind=${encodeURIComponent(n.kind??``)}&site=${encodeURIComponent(n.site??``)}`;return Zi(fetch(q(e)+r,{method:`POST`,headers:n.type?{"Content-Type":n.type}:void 0,body:t}),{path:e,size:0,date:new Date().toISOString()})},move(e,t){return fetch(`${q(e)}?to=${encodeURIComponent(t)}`,{method:`PUT`})},remove(e){return fetch(q(e),{method:`DELETE`})}},Y=(e,t)=>t===``?e:`${t}/${e}`,ta=e=>e.split(`/`).slice(0,-1).join(`/`),na=e=>e.path.endsWith(`/`)?e.path.slice(0,-1):e.path,ra=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`)).filter(e=>e!==W.trash),ia=e=>e.includes(`.`)?(e.split(`.`).pop()??``).toLowerCase():``,aa=e=>{let t=ia(e);return t===`pdf`?`pdf`:t===`mp4`||t===`mov`||t===`webm`?`mp4`:t===`jpg`||t===`jpeg`||t===`png`||t===`gif`?`jpg`:t===`xlsx`||t===`xls`||t===`csv`?`xlsx`:`file`},oa=(e,t)=>{let n=na(e),r=n.startsWith(`${W.trash}/`),i=r?n.slice(W.trash.length+1):n,a=i.split(`/`).pop(),o=e.kind??t?.kind??(e.path.endsWith(`/`)?`folder`:aa(a)),s=o.startsWith(`folder`)?`—`:dt(e.size);return{owner:`自分`,...t,id:n,name:a,kind:o,date:ut(e.date),iso:e.date,size:s,bytes:e.size,parent:ta(i),trashed:r}},X=(e,t,n,r=!1)=>mt(e,new Set(t.filter(e=>e.parent===n&&!!e.trashed===r).map(e=>e.name))),Z=e=>e.scan(`files/`),Q=(e,t)=>{let n=oa(t,e[`files/${na(t)}`]);return e[`files/${n.id}`]=n,ra(n.id).forEach(n=>{e[`files/${n}`]||(e[`files/${n}`]=oa({path:`${n}/`,size:0,date:t.date}))}),n},sa=async(e,t,n,r,i,a)=>{let o=X(n.replace(/^\.+/,``)||`無題のファイル`,Z(e),r),s=Y(o,r),c={path:t.startsWith(`folder`)?`${s}/`:s,size:i?.size??0,date:new Date().toISOString(),kind:t};return Q(e,c),Q(e,await J.put(c.path,i,{kind:t,site:a,type:i?.type}))},ca=async(e,t,n=``)=>{let r=n;for(let n of t.split(`/`).filter(Boolean)){let t=e[`files/${Y(n,r)}`];r=t?.kind.startsWith(`folder`)?t.id:(await sa(e,`folder`,n,r,``)).id}return r},$=async(e,t,n)=>{for(let{path:r,file:i}of t){let t=r.split(`/`).filter(Boolean),a=t.pop(),o=await ca(e,t.join(`/`),n);i||await ca(e,a,o),i&&await sa(e,aa(a),a,o,i)}},la=async(e,t)=>{let n=await J.list(),r=new Set;for(let e of n){let n=Q(t,e);r.add(n.id),ra(n.id).forEach(e=>r.add(e))}Z(t).forEach(e=>!r.has(e.id)&&delete t[`files/${e.id}`]);let i=n.reduce((e,t)=>e+t.size,0);return t.storage={used:i/1048576,total:nt,text:`15 GB 中 ${ft(i)} を使用`},`synced ${n.length} objects`},ua=async({id:e,dir:t},n)=>{let r=n[`files/${e}`];if(!r||r.trashed)return`not found: ${e}`;if(r.parent===t)return`already in ${t===``?`root`:t}`;if(r.kind.startsWith(`folder`)&&(t===e||t.startsWith(`${e}/`)))return`cannot move ${r.name} into itself`;let i=X(r.name,Z(n),t),a=Y(i,t);return await J.move(e,a),delete n[`files/${e}`],n[`files/${a}`]={...r,id:a,name:i,parent:t},Z(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:a+t.id.slice(e.length),parent:a+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`moved ${i} to ${t===``?`root`:t}`},da=async({id:e},t)=>{let n=t[`files/${e}`];if(!n)return`not found: ${e}`;if(n.trashed)return delete t[`files/${e}`],Z(t).forEach(n=>n.id.startsWith(`${e}/`)&&delete t[`files/${n.id}`]),await J.remove(e),`deleted ${n.name}`;let r=X(n.name,Z(t),n.parent,!0),i=Y(r,n.parent);return await J.move(e,`${W.trash}/${i}`),delete t[`files/${e}`],t[`files/${W.trash}/${i}`]={...n,id:`${W.trash}/${i}`,name:r,trashed:!0},Z(t).forEach(n=>{if(!n.id.startsWith(`${e}/`))return;delete t[`files/${n.id}`];let r={...n,id:`${W.trash}/${i}${n.id.slice(e.length)}`,parent:i+n.parent.slice(e.length),trashed:!0};t[`files/${r.id}`]=r}),`trashed ${n.name}`},fa=async({id:e},t)=>{let n=t[`files/${e}`];if(!n?.trashed)return`not trashed: ${e}`;let r=await ca(t,n.parent),i=X(n.name,Z(t),r),a=Y(i,r);await J.move(e,a),delete t[`files/${e}`];let o={...n,id:a,name:i,parent:r};return delete o.trashed,t[`files/${a}`]=o,`restored ${i}`},pa=async({id:e,name:t},n)=>{let r=n[`files/${e}`];if(!r)return`not found: ${e}`;let i=t.replace(/^\.+/,``)||r.name,a=X(i,Z(n),r.parent),o=Y(a,r.parent);return await J.move(e,o),delete n[`files/${e}`],n[`files/${o}`]={...r,id:o,name:a},Z(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:o+t.id.slice(e.length),parent:o+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`renamed to ${a}`},ma=async(e,t)=>{let n=Z(t).filter(e=>e.trashed);n.forEach(e=>delete t[`files/${e.id}`]);let r=await J.list(`${W.trash}/`);return await Promise.all(r.map(e=>J.remove(e.path))),`emptied ${n.length} items`},ha=e=>xi(Z(e)),ga=({kind:e,name:t,parent:n},r)=>{let i=n??(r.mode===``?r.folder:``);return sa(r,e,t??`無題のファイル`,i,``,W.editors.includes(e)?crypto.randomUUID():void 0)},_a=({id:e},t)=>{let n=t[`files/${e}`];return n?(t[`files/${e}`]={...n,pinned:!n.pinned},`${n.name} pinned: ${!n.pinned}`):`not found: ${e}`},va={menu:`shellMenu`,setMenu:`set_shell_menu`,open:`open_entry`},ya=e=>!!e.target?.closest?.(`button, a, input, label`),ba=(e,t={})=>{let n={...va,...t.names},r=()=>e[n.menu],i=t=>e[n.setMenu]({id:t}),a=()=>e.mode===``&&e.folder!==``,o=()=>a()?e.folder:``,s=()=>{r()!==``&&i(``),wi()&&qi(),t.onClose?.()},c=e=>{y(e),r()!==``&&i(``),t.onClose?.()},l=e=>n=>{y(n),Yi(),t.onClose?.(),i(r()===e?``:e)},u=e=>t=>{t.preventDefault(),y(t),Ji(t),i(e)},d=t=>n=>{y(n),e.toggle_tree({path:t})},f=t=>()=>{s(),e.open_folder({path:t})},p=t=>()=>{s(),e.set_mode({mode:t})},m=t=>r=>{if(!(ya(r)||t.trashed)){if(t.kind.startsWith(`folder`))return void e.open_folder({path:t.id});e[n.open]({id:t.id})}},h=t=>()=>{if(s(),t.kind===W.self)return Oi(t.id);e.open_folder({path:t.parent})},g=e=>window.prompt(wn,e),_=async(t,n)=>{let r=window.prompt(Sn,Cn);if(!r)return;let i=await e.create_file({kind:`folder`,name:r,parent:t});n&&e.open_folder({path:i.id})},ee=async(t,n)=>{await e.upload_file({parent:t}),n&&!a()&&e.open_folder({path:``})},te=async(t,n)=>{let r=await e.upload_folder({parent:t});n&&typeof r==`object`&&e.open_folder({path:r.folder})},ne=e=>{if(s(),e.id===`folder`)return void _(o(),!0);if(e.id===`upload`)return void ee(o(),!0);if(e.id===`upload-folder`)return void te(o(),!0)},re=t=>r=>{if(s(),r.id===`open`)return void e[n.open]({id:t.id});if(r.id===`rename`)return void ie(t);if(r.id===`folder`)return void _(t.id,!1);if(r.id===`upload`)return void ee(t.id,!1);if(r.id===`upload-folder`)return void te(t.id,!1);if(r.id===`download`)return void e.download_file({id:t.id});if(r.id===`info`)return void window.alert(Hn(t));if(r.id===`pin`)return void e.toggle_pin({id:t.id});if(r.id===`remove`||r.id===`purge`)return void e.remove_file({id:t.id});if(r.id===`restore`)return void e.restore_file({id:t.id})},ie=t=>{let n=window.prompt(wn,t.name);n&&e.rename_file({id:t.id,name:n})},ae=t=>{if(s(),t.id===`manage`)return void e.set_mode({mode:`storage`});if(t.id===`empty`)return void e.empty_trash({});if(t.id===`refresh`)return void e.sync_files({})},oe=n=>{if(s(),!t.create)return t.insert?.(n);if(n.id===t.createId)return void e[t.create]({parent:o()});if(e.mode===`edit`)return t.insert?.(n);let r=t.intents?.[n.id]??t.fallback?.(n);e[t.create]({parent:o(),then:r?.name,input:r?.input})},se=e=>t=>{if(e.menu||e.id===`new`)return l(`create`)(t);oe(e)},ce=n=>{if(s(),!t.onPage?.(n)){if(n.id===`band`)return void e.toggle_band();if(n.id===`undo`)return void e.undo({});if(n.id===`redo`)return void e.redo({});e.set_mode({mode:n.id})}},le=t=>t===`band`?void e.toggle_band():void e.toggle_bar(),ue=(t,n)=>r=>{s(),e.set_chip({chip:t,value:r.id===n?``:r.id})},de=t=>n=>{y(n),e.set_chip({chip:t,value:``})},fe=Vt((t,n)=>{if(!t.startsWith(`${W.trash}/`)){if(n===W.trash)return void e.remove_file({id:t});e.move_file({id:t,dir:n})}}),pe=Xt(`os`,async(t,n)=>{if(t.some(e=>(e.file?.size??0)>104857600))return void window.alert(it);await $(e,t,n),e.sync_files({})},()=>e.mode!==`trash`);return{closeShell:s,press:c,flip:l,context:u,foldTree:d,treeClick:f,goMode:p,openFile:m,pickFile:h,askName:g,pickHome:ne,pickRow:re,pickStorage:ae,pickInsert:oe,pickCard:se,pickPage:ce,flipSetting:le,pickChip:ue,clearChip:de,openDrawer:Ki,grab:fe,drop:pe,target:o,isFolderMode:a}},xa=e=>new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.multiple=!0,n.webkitdirectory=e,n.oncancel=()=>t([]),n.onchange=()=>t(Array.from(n.files??[])),n.click()}),Sa=(e,t)=>{let n=document.createElement(`a`);n.href=q(e),n.download=t,document.body.appendChild(n),n.click(),n.remove()},Ca=e=>new Promise(t=>setTimeout(t,e)),wa=async({parent:e=``},t)=>{let n=await xa(!1);return n.length===0?`upload canceled`:(await $(t,n.map(e=>({path:e.name,file:e})),e),`uploaded ${n.map(e=>e.name).join(`, `)} into ${e===``?`root`:e}`)},Ta=async({parent:e=``},t)=>{let n=await xa(!0);if(n.length===0)return`upload canceled`;let r=n.map(e=>({path:e.webkitRelativePath||e.name,file:e}));await $(t,r,e);let i=r[0].path.split(`/`);return{folder:i.length>1?Y(i[0],e):e,count:n.length}},Ea=async({id:e},t)=>{let n=t[`files/${e}`];if(e!==``&&!n)return`not found: ${e}`;if(n&&!n.kind.startsWith(`folder`))return Sa(n.id,n.name),`downloaded ${n.name}`;let r=t.scan(`files/`).filter(t=>(e===``||t.id.startsWith(`${e}/`))&&!t.kind.startsWith(`folder`)&&!t.trashed);for(let e of r)Sa(e.id,e.name),await Ca(300);return`downloaded ${r.length} files`},Da=e=>e.split(`/`).filter(Boolean).map(encodeURIComponent).join(`/`),Oa=()=>{let e=new URLSearchParams(location.search),t=Qi(),n=t!==``&&location.pathname.endsWith(`/`),r=e.get(`q`)??``;return{path:t,mode:r===`home`?``:r,folder:n,query:e.has(`q`)}},ka=e=>e.folder?``:e.path,Aa=(e,t)=>{if(t.folder)return void e.open_folder({path:t.path});if(t.query)return void e.set_mode({mode:t.mode})},ja=(e,t)=>e.mode===`edit`?`/${Da(t)}`:e.mode===``?e.folder===``?`/?q=home`:`/${Da(e.folder)}/`:`/?q=${encodeURIComponent(e.mode)}`,Ma=(e,t)=>{let n=``;e.data().observe(()=>{let r=ja(e,t);r!==n&&(n=r,location.pathname+location.search!==r&&history.pushState(null,``,r+location.hash))}),window.addEventListener(`popstate`,()=>Aa(e,Oa()))},Na=(e,{lobby:t,wire:n,synced:r})=>{let i=Oa(),a=ka(i),o=async()=>{await e.sync_files({}),Aa(e,i),await r?.(),ki(e)};return n?.(a),Ma(e,a),a===``?{file:a,room:t,synced:o}:{file:a,path:a,synced:o}},Pa=e=>({role:`agent`,text:e.text,tools:e.tools.map(e=>({icon:N.icon,label:`${e.server?`${e.server} - `:``}${e.name} (MCP)`}))}),Fa=e=>t(F,e.flatMap(e=>[{role:`user`,text:e.prompt},Pa({text:e.reply,tools:e.tools.map(e=>({server:``,name:e}))})])),Ia=e=>e.map(e=>e.tools.length?`${e.text}\n`:e.text).join(`
5
+ `),La=async e=>{if(L.value)return`busy: previous chat is still running`;let n=[...F.value,{role:`user`,text:e}];kr(),t(F,n),t(L,!0);let r=await N.stream.send({prompt:e,path:N.path,model:$n.value,headers:N.headers},e=>{t(F,[...n,...e.items.map(Pa)]),Dr(Ia(e.items))});return Or(Ia(r)),t(L,!1),`chat sent: ${e}`},Ra=e=>{let t=[],n=``,r=[],i=()=>Math.floor(new Date().getHours()/6),a=r=>{let a=i(),o=n,s=t.find(e=>e.name===r&&e.part===a&&e.after===o);s&&(s.count+=1),s||t.push({name:r,part:a,after:o,count:1}),n=r,e.store.save({name:r,part:a,after:o})},o=e=>t.reduce((t,r)=>r.name===e?t+r.count*(r.part===i()?2:1)*(r.after===n?2:1):t,0),s=e=>[...e].sort((e,t)=>o(t.name)-o(e.name)),c=()=>(r.length===0&&(r=e.deck.map(e=>({...e,run:()=>(a(e.name),e.run())}))),s(r));return{commands:c,hello:()=>{let t=c(),n=t.filter(t=>e.starters().includes(t.name)),r=[...new Set([...e.pinned(),...n.map(e=>e.name)])].flatMap(e=>t.filter(t=>t.name===e));return{...e.greet,prompts:r.map(e=>({label:e.label??e.name,prompt:`/${e.name}`}))}},hints:t=>e.hinted(t).flatMap(e=>c().filter(t=>t.name===e)),prime:async()=>{t=await e.store.list()}}},za=(e,t)=>e.map((n,r)=>{let i=e[r+1]?.seq??1/0;return{...n,names:t.filter(e=>e.seq>n.seq&&e.seq<i).map(e=>e.name)}}),Ba=e=>e.replace(/\s+/g,` `).trim().slice(0,40),Va=e=>{let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?`たった今`:t<3600?`${Math.floor(t/60)} 分前`:t<86400?`${Math.floor(t/3600)} 時間前`:`${Math.floor(t/86400)} 日前`},Ha=e=>{let t=crypto.randomUUID(),n=0,r=[],i=()=>{t=crypto.randomUUID(),n=0,r=[],e.show([])},a=async()=>(await e.store.list()).map(e=>({...e,when:Va(e.updatedAt)})),o=async i=>{let a=await e.store.load(i),o=za(a.talks,a.tools).map(e=>({prompt:e.prompt,reply:e.reply,tools:e.names}));t=i,n=[...a.talks,...a.tools].reduce((e,t)=>Math.max(e,t.seq),0),r=o.flatMap(e=>[{role:`user`,content:e.prompt},{role:`assistant`,content:e.reply}]),e.show(o)},s=(i,a,o=``)=>{let s=a.filter(e=>!e.error),c=s.map(e=>e.text).filter(e=>e!==``).join(`
6
6
 
7
- `);if(c===``)return;let l=s.flatMap(e=>e.tools.map(e=>e.name));r=[...r,{role:`user`,content:i},{role:`assistant`,content:c}];let u=n+1;n=u+l.length,e.store.save(t,{title:ir(i),seq:u,prompt:i,reply:c,model:o,tools:l.map((e,t)=>({seq:u+1+t,name:e}))})};return{wrap:e=>({...e,send:async(t,n)=>{let i=await e.send({...t,messages:r.slice(-40)},n);return s(t.prompt,i,t.model),i}}),reset:i,load:o,list:a}},sr=()=>M.value,cr=()=>n(M),U={add:ue,arrowBack:de,arrowDropDown:fe,check:se,chevronRight:pe,closeIcon:f,cloud:me,deleteIcon:he,folder:ge,home:_e,keep:ve,keepFill:ye,leftPanelClose:be,leftPanelOpen:xe,menuIcon:Se,moreVert:Ce,redoIcon:we,schedule:Te,searchIcon:m,settings:Ee,help:De,keyboard:Oe,sync:ke,undoIcon:Ae,unfoldMore:je,visibilityOff:Me,createNewFolder:Ne,uploadFile:Pe,driveFolderUpload:Fe,edit:Ie,download:Le,info:Re,openInNew:ze,restoreFromTrash:Be,description:Ve},lr=({count:e,min:t,cls:n=``,children:r})=>c(`div`,{className:`grid gap-4 overflow-x-auto ${n}`,style:{gridTemplateColumns:`repeat(${e}, minmax(${t}px, 1fr))`},children:r}),ur=({c:e,click:t})=>l(`button`,{onClick:t,className:`relative flex h-full w-full cursor-pointer flex-col items-start rounded-xl border border-edge bg-white p-3 text-left hover:bg-pale`,children:[c(`span`,{className:`flex h-[30px] w-[30px] items-center justify-center rounded-md bg-band`,children:c(g,{name:e.icon??``,size:18,color:e.color})}),c(g,{name:U.add,size:16,className:`absolute right-3 top-3 text-mute`}),c(`span`,{className:`mt-2 w-full truncate text-[14px] leading-[17px]`,children:e.label})]}),dr=({c:e,click:t})=>l(`button`,{onClick:t,className:`flex h-12 w-full cursor-pointer items-center gap-3 rounded-xl border border-edge bg-white px-4 text-left hover:bg-pale`,children:[c(g,{name:e.icon??``,size:18,color:e.color}),c(`span`,{className:`truncate`,children:e.label}),c(g,{name:U.add,size:16,className:`ml-auto shrink-0 text-mute`})]}),fr=({cards:e,click:t,popup:n,count:r=4})=>l(s,{children:[c(lr,{count:r,min:it.card,cls:`hidden md:grid`,children:e.map(e=>l(`div`,{className:`relative`,children:[c(ur,{c:e,click:t(e)}),n(e)]},e.id))}),c(`div`,{className:`flex flex-col gap-2 md:hidden`,children:e.map(e=>l(`div`,{className:`relative`,children:[c(dr,{c:e,click:t(e)}),n(e)]},e.id))})]}),pr=e=>c(`section`,{className:`relative shrink-0 px-4 pt-3 md:pl-7 md:pr-9`,children:c(fr,{...e})}),mr=({drawer:e,close:t,dropRef:n,children:r})=>l(`div`,{ref:n,onClick:t,className:`flex h-dvh overflow-hidden bg-white font-medium text-ink`,children:[e&&c(`div`,{className:`fixed inset-0 z-30 bg-black/30 md:hidden`,onClick:t}),r]}),hr=({drop:e,from:t,children:n})=>c(`main`,{"data-drop":e,"data-drop-from":t,"data-drop-scope":``,className:`flex min-w-0 flex-1 flex-col overflow-y-auto pt-14 md:pt-0`,children:n}),gr=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,_r=`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,vr=({icon:e,color:t,label:n,home:r,actions:i,drawer:a})=>l(`header`,{className:`fixed inset-x-0 top-0 z-20 flex h-14 items-center gap-1 bg-white pl-4 pr-3 md:hidden`,children:[l(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[c(g,{name:e,size:24,color:t}),c(`span`,{className:`truncate text-sm font-bold`,children:n})]}),l(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[i,c(`button`,{onClick:a,className:gr,children:c(g,{name:U.menuIcon,size:22})})]})]}),yr=({bar:e,open:t,title:n,back:r,expand:i,actions:a})=>l(`div`,{className:`mt-2.5 flex h-8 shrink-0 items-center gap-2 px-4 md:pl-7 md:pr-9`,children:[!e&&c(`button`,{onClick:t,className:`${_r} hidden md:flex`,children:c(g,{name:U.leftPanelOpen,size:20})}),!r&&c(`h1`,{className:`min-w-0 truncate font-bold`,children:n}),r&&l(`button`,{onClick:r,className:`flex min-w-0 cursor-pointer items-center gap-2 font-bold`,children:[c(g,{name:U.arrowBack,size:20,className:`text-mute`}),c(`span`,{className:`truncate`,children:n})]}),l(`div`,{className:`relative ml-auto flex shrink-0 items-center gap-1`,children:[i&&l(`button`,{onClick:i.click,className:`flex h-8 cursor-pointer items-center gap-1 rounded-lg px-2 hover:bg-band ${i.on?`text-ink`:`text-mute`}`,children:[c(`span`,{className:`hidden md:inline`,children:i.label}),c(g,{name:i.icon||U.unfoldMore,size:18})]}),a]})]}),br=({icon:e,size:t=20,click:n,children:r})=>l(`span`,{className:`relative hidden md:flex`,children:[c(`button`,{onClick:n,className:_r,children:c(g,{name:e,size:t})}),r]}),xr=({icon:e,size:t=20,click:n,children:r})=>l(`span`,{className:`relative flex`,children:[c(`button`,{onClick:n,className:gr,children:c(g,{name:e,size:t})}),r]}),Sr=U.moreVert,Cr=`STORAGE`,wr=`アップグレード`,Tr=`https://stripe.com`,Er=`ゴミ箱を空にしますか?中のアイテムは完全に削除されます`,Dr=[{id:`manage`,icon:U.cloud,label:`保存容量を管理`},{id:`empty`,icon:U.deleteIcon,label:`ゴミ箱を空にする`},{id:`refresh`,icon:U.sync,label:`使用状況を更新`}],Or=[{id:`undo`,icon:U.undoIcon,label:`直前の操作を元に戻す`},{id:`redo`,icon:U.redoIcon,label:`最後に元に戻した操作をやり直す`},{id:`settings`,icon:U.settings,label:`設定`,top:!0},{id:`help`,icon:U.help,label:`ヘルプ`},{id:`shortcuts`,icon:U.keyboard,label:`キーボードショートカット`}],kr=Or.slice(2).map(e=>({...e,top:!1})),Ar=U.visibilityOff,jr=(e,t,n)=>[{id:`band`,icon:Ar,label:e?`すべての${t}を非表示`:`すべての${t}を表示`},...n.map((e,t)=>t===0?{...e,top:!0}:e)],Mr=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,Nr=({icon:e,color:t,label:n,click:r})=>l(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[c(g,{name:e,size:24,color:t}),c(`span`,{className:`truncate text-sm font-bold`,children:n})]}),Pr=({storage:e,upgrade:t,menu:n,more:r})=>l(`div`,{className:`relative shrink-0 border-t border-line px-4 pb-4 pt-3`,children:[l(`div`,{className:`flex h-6 items-center gap-2 text-mute`,children:[c(g,{name:U.cloud,size:18}),c(`span`,{className:`tracking-wider`,children:Cr}),l(`span`,{className:`relative ml-auto flex`,children:[c(`button`,{onClick:r,className:`flex h-6 w-6 items-center justify-center rounded-full text-mute hover:bg-band`,children:c(g,{name:U.moreVert,size:16})}),n]})]}),c(`div`,{className:`mt-1.5 h-2 overflow-hidden rounded-full bg-line`,children:c(`div`,{className:`h-full rounded-full bg-fill`,style:{width:`${Math.min(100,e.used/e.total*100)}%`}})}),c(`p`,{className:`mt-1.5`,children:e.text}),c(`button`,{onClick:t,className:`mt-2.5 h-9 w-full cursor-pointer rounded-full border border-ink font-bold hover:bg-band`,children:wr})]}),Fr=({brand:e,bar:t,drawer:n,fold:r,close:i,press:a,storage:o,upgrade:s,menu:u,more:d,children:f})=>l(`nav`,{"data-drop-scope":``,onClick:a,className:`fixed inset-y-0 left-0 z-40 flex shrink-0 flex-col border-r border-line bg-pale transition-transform md:static md:translate-x-0 ${n?`translate-x-0`:`-translate-x-full`} ${t?``:`md:hidden`}`,style:{width:_.width},children:[l(`div`,{className:`flex h-15 shrink-0 items-center gap-1 pr-2 text-[14px]`,style:{paddingLeft:_.brand},children:[c(Nr,{...e}),c(`button`,{onClick:r,className:`${Mr} hidden md:flex`,children:c(g,{name:U.leftPanelClose,size:20})}),c(`button`,{onClick:i,className:`${Mr} md:hidden`,children:c(g,{name:U.leftPanelClose,size:20})})]}),c(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-4`,children:f}),c(Pr,{storage:o,upgrade:s,menu:u,more:d})]}),Ir=e=>`flex w-full cursor-pointer items-center rounded-lg text-left text-[14px] text-mute ${e?`bg-band`:`hover:bg-band`}`,Lr=({open:e,turn:t})=>t?c(`button`,{onClick:t,className:`flex shrink-0 items-center justify-center`,style:{width:_.slot,height:_.slot},children:c(g,{name:U.chevronRight,size:_.slot,className:e?`rotate-90`:``})}):c(`span`,{className:`shrink-0`,style:{width:_.slot}}),Rr=({depth:e=0,on:t=!1,open:n,turn:r,icon:i,color:a,label:o,drop:s,mark:u,from:d,click:f,dclick:p,rclick:m,dragRef:h,children:ee})=>l(`div`,{ref:h,"data-drop":s,"data-drop-mark":u,"data-drop-from":d,onClick:e=>(f?.(e),r?.(e)),onDoubleClick:p,onContextMenu:m,className:Ir(t),style:{height:_.row,paddingLeft:e*_.indent},children:[c(Lr,{open:n,turn:r}),c(g,{name:i,size:_.icon,color:a}),c(`span`,{className:`min-w-0 flex-1 truncate ${t?`text-ink`:``}`,style:{marginLeft:_.gap},children:o}),ee]}),W={base:`/api/v1/storage`,trash:`.trash`,editors:[]},zr=e=>void Object.assign(W,e),G=e=>e.kind.startsWith(`folder`),Br=(e,t)=>e.name.localeCompare(t.name),Vr=(e,t)=>t.iso.localeCompare(e.iso),Hr=(e,t)=>{let n=e.filter(e=>e.parent===t&&!e.trashed);return[...n.filter(G).sort(Br),...n.filter(e=>!G(e)).sort(Br)]},Ur=(e,t)=>e.filter(e=>!e.trashed&&e.kind===t).sort(Vr),Wr=e=>e.filter(e=>!e.trashed&&!G(e)).sort(Vr).slice(0,12),Gr=e=>e.filter(e=>e.trashed),Kr=e=>e.filter(e=>!e.trashed&&!G(e)).sort((e,t)=>t.bytes-e.bytes),qr=(e,t)=>e.filter(e=>!e.trashed&&e.parent===t),Jr=e=>{let t=e.split(`/`).filter(Boolean);return t.map((e,n)=>({name:n===0&&e===W.trash?`ゴミ箱`:e,path:t.slice(0,n+1).join(`/`)}))},Yr=e=>e.filter(e=>!G(e)).reduce((e,t)=>e+t.bytes,0),Xr=e=>{let{files:t,parent:n,depth:r,expand:i,active:a,kinds:o,fold:u,enter:d,open:f,menu:p,rclick:m,drag:h}=e;return c(s,{children:Hr(t,n).map(t=>{let n=(o[t.kind]??o.file).icon;return G(t)?l(`div`,{children:[c(Rr,{depth:r,on:a===t.id,open:i.includes(t.id),turn:u(t.id),icon:o.folder.icon,label:t.name,drop:t.id,mark:t.id,click:d(t.id),rclick:m(t),dragRef:h(t.id,`tree`),children:p(t)}),i.includes(t.id)&&c(Xr,{...e,parent:t.id,depth:r+1})]},t.id):c(Rr,{depth:r,icon:n,label:t.name,drop:t.parent,click:d(t.parent),dclick:f(t),rclick:m(t),dragRef:h(t.id,`tree`),children:p(t)},t.id)})})},K=e(!1),Zr=e(null),Qr=e=>{e.stopPropagation(),t(K,!0)},$r=()=>t(K,!1),ei=e=>t(Zr,{x:e.clientX,y:e.clientY}),ti=()=>t(Zr,null),ni=()=>K.value,ri=()=>n(K),ii=()=>n(Zr),ai=e=>e.split(`/`).map(encodeURIComponent).join(`/`),oi=(e,t)=>e.then(e=>e.ok?e.json():t).catch(()=>t),q=e=>`${W.base}/${ai(e)}`,J={list(e=``){return oi(fetch(`${W.base}?prefix=${encodeURIComponent(e)}`),[])},get(e){return fetch(q(e))},put(e,t,n={}){let r=`?kind=${encodeURIComponent(n.kind??``)}&site=${encodeURIComponent(n.site??``)}`;return oi(fetch(q(e)+r,{method:`POST`,headers:n.type?{"Content-Type":n.type}:void 0,body:t}),{path:e,size:0,date:new Date().toISOString()})},move(e,t){return fetch(`${q(e)}?to=${encodeURIComponent(t)}`,{method:`PUT`})},remove(e){return fetch(q(e),{method:`DELETE`})}},Y=(e,t)=>t===``?e:`${t}/${e}`,si=e=>e.split(`/`).slice(0,-1).join(`/`),ci=e=>e.path.endsWith(`/`)?e.path.slice(0,-1):e.path,li=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`)).filter(e=>e!==W.trash),ui=e=>e.includes(`.`)?(e.split(`.`).pop()??``).toLowerCase():``,di=e=>{let t=ui(e);return t===`pdf`?`pdf`:t===`mp4`||t===`mov`||t===`webm`?`mp4`:t===`jpg`||t===`jpeg`||t===`png`||t===`gif`?`jpg`:t===`xlsx`||t===`xls`||t===`csv`?`xlsx`:`file`},fi=(e,t)=>{let n=ci(e),r=n.startsWith(`${W.trash}/`),i=r?n.slice(W.trash.length+1):n,a=i.split(`/`).pop(),o=e.kind??t?.kind??(e.path.endsWith(`/`)?`folder`:di(a)),s=o.startsWith(`folder`)?`—`:mt(e.size);return{owner:`自分`,...t,id:n,name:a,kind:o,date:pt(e.date),iso:e.date,size:s,bytes:e.size,parent:si(i),trashed:r}},X=(e,t,n,r=!1)=>_t(e,new Set(t.filter(e=>e.parent===n&&!!e.trashed===r).map(e=>e.name))),Z=e=>e.scan(`files/`),Q=(e,t)=>{let n=fi(t,e[`files/${ci(t)}`]);return e[`files/${n.id}`]=n,li(n.id).forEach(n=>{e[`files/${n}`]||(e[`files/${n}`]=fi({path:`${n}/`,size:0,date:t.date}))}),n},pi=async(e,t,n,r,i,a)=>{let o=X(n.replace(/^\.+/,``)||`無題のファイル`,Z(e),r),s=Y(o,r),c={path:t.startsWith(`folder`)?`${s}/`:s,size:i?.size??0,date:new Date().toISOString(),kind:t};return Q(e,c),Q(e,await J.put(c.path,i,{kind:t,site:a,type:i?.type}))},$=async(e,t,n=``)=>{let r=n;for(let n of t.split(`/`).filter(Boolean)){let t=e[`files/${Y(n,r)}`];r=t?.kind.startsWith(`folder`)?t.id:(await pi(e,`folder`,n,r,``)).id}return r},mi=async(e,t,n)=>{for(let{path:r,file:i}of t){let t=r.split(`/`).filter(Boolean),a=t.pop(),o=await $(e,t.join(`/`),n);i||await $(e,a,o),i&&await pi(e,di(a),a,o,i)}},hi=async(e,t)=>{let n=await J.list(),r=new Set;for(let e of n){let n=Q(t,e);r.add(n.id),li(n.id).forEach(e=>r.add(e))}Z(t).forEach(e=>!r.has(e.id)&&delete t[`files/${e.id}`]);let i=n.reduce((e,t)=>e+t.size,0);return t.storage={used:i/1048576,total:at,text:`15 GB 中 ${ht(i)} を使用`},`synced ${n.length} objects`},gi=async({id:e,dir:t},n)=>{let r=n[`files/${e}`];if(!r||r.trashed)return`not found: ${e}`;if(r.parent===t)return`already in ${t===``?`root`:t}`;if(r.kind.startsWith(`folder`)&&(t===e||t.startsWith(`${e}/`)))return`cannot move ${r.name} into itself`;let i=X(r.name,Z(n),t),a=Y(i,t);return await J.move(e,a),delete n[`files/${e}`],n[`files/${a}`]={...r,id:a,name:i,parent:t},Z(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:a+t.id.slice(e.length),parent:a+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`moved ${i} to ${t===``?`root`:t}`},_i=async({id:e},t)=>{let n=t[`files/${e}`];if(!n)return`not found: ${e}`;if(n.trashed)return delete t[`files/${e}`],Z(t).forEach(n=>n.id.startsWith(`${e}/`)&&delete t[`files/${n.id}`]),await J.remove(e),`deleted ${n.name}`;let r=X(n.name,Z(t),n.parent,!0),i=Y(r,n.parent);return await J.move(e,`${W.trash}/${i}`),delete t[`files/${e}`],t[`files/${W.trash}/${i}`]={...n,id:`${W.trash}/${i}`,name:r,trashed:!0},Z(t).forEach(n=>{if(!n.id.startsWith(`${e}/`))return;delete t[`files/${n.id}`];let r={...n,id:`${W.trash}/${i}${n.id.slice(e.length)}`,parent:i+n.parent.slice(e.length),trashed:!0};t[`files/${r.id}`]=r}),`trashed ${n.name}`},vi=async({id:e},t)=>{let n=t[`files/${e}`];if(!n?.trashed)return`not trashed: ${e}`;let r=await $(t,n.parent),i=X(n.name,Z(t),r),a=Y(i,r);await J.move(e,a),delete t[`files/${e}`];let o={...n,id:a,name:i,parent:r};return delete o.trashed,t[`files/${a}`]=o,`restored ${i}`},yi=async({id:e,name:t},n)=>{let r=n[`files/${e}`];if(!r)return`not found: ${e}`;let i=t.replace(/^\.+/,``)||r.name,a=X(i,Z(n),r.parent),o=Y(a,r.parent);return await J.move(e,o),delete n[`files/${e}`],n[`files/${o}`]={...r,id:o,name:a},Z(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:o+t.id.slice(e.length),parent:o+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`renamed to ${a}`},bi=async(e,t)=>{let n=Z(t).filter(e=>e.trashed);n.forEach(e=>delete t[`files/${e.id}`]);let r=await J.list(`${W.trash}/`);return await Promise.all(r.map(e=>J.remove(e.path))),`emptied ${n.length} items`},xi=e=>Yr(Z(e));export{Zn as AiChat,Yn as AiChatButton,pr as Band,Nr as Brand,fr as Cards,Xr as DriveTree,Ye as Drop,Lr as Fold,mr as Frame,lt as GB,br as HeadBtn,g as Icon,dt as KB,ut as MB,hr as Main,yr as MainHead,Sr as MoreIcon,Je as Pop,Rr as Row,ct as SP_BREAK,Fr as Side,We as Slot,xr as SpBtn,vr as SpHead,Pr as StorageBox,lr as Strip,gt as ago,li as ancestors,ei as atPoint,tt as band,rt as blue,D as chatConfig,An as closeChat,$r as closeDrawer,en as configureChat,zr as configureDrive,nr as createCommands,Wt as createFileDrag,$t as createFileDrop,or as createHistory,Dt as createOver,Jr as crumbSegs,Bt as dragEvent,W as driveConfig,Kt as dropEvent,$e as edge,bi as emptyTrash,Er as emptyTrashAsk,fi as entryOf,ui as extOf,nt as fill,qr as folderRows,X as freeName,it as grid,U as icons,ci as idOf,Xe as ink,sr as isChatBusy,ni as isDrawerOpen,G as isFolder,di as kindOf,Ur as kindRows,Qe as line,nn as markdown,Q as mirrorFile,$ as mkdirp,w as models,jr as moreItems,gi as moveFile,Ze as mute,ti as noPoint,kn as openChat,Qr as openDrawer,Or as pageMenu,et as pale,si as parentOf,Y as pathname,Ge as place,Ue as prev,at as quota,J as r2,Wr as recentRows,_i as removeFile,yi as renameFile,$n as restoreChat,vi as restoreFile,Ir as rowCls,tr as runChat,pi as saveFile,_ as side,mt as sizeOf,kr as spMenu,pt as stamp,He as stop,Dr as storageMenu,Cr as storageName,Kr as storageRows,mi as storeFiles,hi as syncFiles,Qn as toMsg,jn as toggleChat,Gr as trashRows,Hr as treeOf,_t as unique,wr as upgradeLabel,Tr as upgradeUrl,st as uploadAlert,ot as uploadMax,q as url,ht as usageOf,cr as useChatBusy,ri as useDrawer,ii as usePoint,xi as usedBytes,Yr as usedOf,y as vec2};
7
+ `);if(c===``)return;let l=s.flatMap(e=>e.tools.map(e=>e.name));r=[...r,{role:`user`,content:i},{role:`assistant`,content:c}];let u=n+1;n=u+l.length,e.store.save(t,{title:Ba(i),seq:u,prompt:i,reply:c,model:o,tools:l.map((e,t)=>({seq:u+1+t,name:e}))})};return{wrap:e=>({...e,send:async(t,n)=>{let i=await e.send({...t,messages:r.slice(-40)},n);return s(t.prompt,i,t.model),i}}),reset:i,load:o,list:a}};export{Qr as AiChat,Xr as AiChatButton,an as Band,si as Brand,rn as Cards,gn as Caret,$t as Chips,Si as DriveTree,b as Drop,qn as FileList,mn as Fold,$r as Frame,ot as GB,ln as HeadBtn,ri as HelpPage,v as Icon,Gi as ItemsPopup,ct as KB,Wi as Layout,st as MB,ei as Main,un as MainHead,_n as More,fn as MoreIcon,ai as Pages,Ke as Pop,O as Row,hn as RowBtn,at as SP_BREAK,ni as SettingsPage,ii as ShortcutsPage,li as Side,Fi as SideBar,He as Slot,dn as SpBtn,cn as SpHead,ci as Storage_,en as Strip,Kn as Tile,ji as TreeMore,pt as ago,ra as ancestors,Aa as applyRoute,Ji as atPoint,Qe as band,An as bandIcon,et as blue,Na as bootShell,N as chatConfig,jr as closeChat,qi as closeDrawer,Yn as configureChat,ui as configureDrive,Ra as createCommands,ga as createFile,Vt as createFileDrag,Xt as createFileDrop,Ha as createHistory,wt as createOver,ba as createShell,yi as crumbSegs,Ea as downloadFile,Lt as dragEvent,K as drawerAtom,W as driveConfig,Ut as dropEvent,Xe as edge,$i as editorUrl,Wn as emptyLabel,ma as emptyTrash,xn as emptyTrashAsk,oa as entryOf,ia as extOf,ka as fileOf,$e as fill,Sn as folderAsk,Cn as folderDefault,vi as folderRows,X as freeName,Oi as gotoFile,tt as grid,Mn as homeMenu,D as icons,na as idOf,Hn as infoOf,qe as ink,er as isChatBusy,wi as isDrawerOpen,G as isFolder,aa as kindOf,mi as kindRows,Rn as leafMenu,Ye as line,Zn as markdown,Q as mirrorFile,ca as mkdirp,bi as modeRows,A as models,jn as moreItems,ua as moveFile,Je as mute,Yi as noPoint,Ar as openChat,Ki as openDrawer,ea as openEntry,Qi as openPath,On as pageMenu,Vn as pageModes,k as pageTitles,Ze as pale,ta as parentOf,Y as pathname,In as pinLabel,Ue as place,Ci as pointAtom,Ve as prev,nt as quota,J as r2,Oa as readRoute,hi as recentRows,da as removeFile,wn as renameAsk,pa as renameFile,Fa as restoreChat,fa as restoreFile,Tn as rootTitle,pn as rowCls,La as runChat,ki as runIntent,sa as saveFile,zn as settingRows,Bn as shortcutRows,x as side,dt as sizeOf,kn as spMenu,ut as stamp,y as stop,Dn as storageMenu,vn as storageName,_i as storageRows,$ as storeFiles,la as syncFiles,Un as titleOf,Pa as toMsg,Mr as toggleChat,_a as togglePin,Fn as trashMenu,gi as trashRows,Pn as treeFileMenu,Nn as treeFolderMenu,Ln as treeMenuOf,pi as treeOf,mt as unique,En as unpinLabel,yn as upgradeLabel,bn as upgradeUrl,it as uploadAlert,wa as uploadFiles,Ta as uploadFolder,rt as uploadMax,q as url,ja as urlOf,ft as usageOf,tr as useChatBusy,Ti as useDrawer,Ei as usePoint,ha as usedBytes,xi as usedOf,C as vec2,Ma as watchUrl};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ai-ax",
3
3
  "author": "tseijp",
4
- "version": "0.9.0",
4
+ "version": "0.11.0",
5
5
  "license": "MIT",
6
6
  "description": "AI Agent Experience (AI/AX) library for Hono + Cloudflare. One act surface for both human UI/UX and LLM MCP tools, with authentication, authorization, realtime sync and Claude API relay.",
7
7
  "keywords": [