@yuriai/web 0.1.1 → 0.1.2-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/assets/{AgentAvatar-qhOvrIl0.js → AgentAvatar-1UO8KpCd.js} +1 -1
  2. package/dist/assets/{AssistantView-D2r09Ok2.js → AssistantView-CdO4imc6.js} +3 -3
  3. package/dist/assets/{DiagramView-KtsvYuvL.js → DiagramView-ALA0pyKm.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-BWusb8te.js → FadeInOnReveal-BsRKluhI.js} +1 -1
  5. package/dist/assets/{Icon-Cu3waV3-.js → Icon-jsQQXouE.js} +1 -1
  6. package/dist/assets/{ImageLoadingPlaceholder-DrL-lXR9.js → ImageLoadingPlaceholder-BPp8BN0a.js} +1 -1
  7. package/dist/assets/{LoadingImage-B5xiKJjg.js → LoadingImage-DvtPqFRw.js} +1 -1
  8. package/dist/assets/MarkdownRenderer-QKxUWu_S.js +2 -0
  9. package/dist/assets/{MarkdownRendererImpl-DXU28IKm.js → MarkdownRendererImpl-XEO441ER.js} +1 -1
  10. package/dist/assets/{MarkstreamRendererImpl-B98l37eW.js → MarkstreamRendererImpl-C_-nyQrd.js} +1 -1
  11. package/dist/assets/{MobileDetailNavigation-C46HZ6sn.js → MobileDetailNavigation-nJl1j85R.js} +1 -1
  12. package/dist/assets/{MobileShareBridge-eb09vuom.js → MobileShareBridge-DZ-a1-hd.js} +1 -1
  13. package/dist/assets/MobileTabPageHeader-sOgdUSiO.js +2 -0
  14. package/dist/assets/{MultiRunWindow-rrRwrulk.js → MultiRunWindow-D5HKvioh.js} +1 -1
  15. package/dist/assets/{OnboardingScreen-nFqZeY1W.js → OnboardingScreen-DTr_WxYY.js} +1 -1
  16. package/dist/assets/{OverlayScrollbar-BTOeKIbZ.js → OverlayScrollbar-C4VUlRzo.js} +1 -1
  17. package/dist/assets/{SettingsView-Da5ZoxCQ.js → SettingsView-ulmuNYxi.js} +1 -1
  18. package/dist/assets/{SettingsWindow-CgWt5Wov.js → SettingsWindow-C6iznJxw.js} +1 -1
  19. package/dist/assets/{TerminalView-8P_uaaYH.js → TerminalView-CWZCDRxs.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-DDt_LRZ8.js → ToolOutputDialog-DAwoBF6c.js} +1 -1
  21. package/dist/assets/{appThemeRegistry-CVoahv_s.js → appThemeRegistry-Cxk6QddU.js} +1 -1
  22. package/dist/assets/{button-BBAlbKlC.js → button-C3292Ee6.js} +1 -1
  23. package/dist/assets/{collapsible-ioYeSDPc.js → collapsible-B0yvtXQR.js} +1 -1
  24. package/dist/assets/{diagram-D1NN9faA.js → diagram-Ddq5F6R_.js} +1 -1
  25. package/dist/assets/{dialog-CmHz28bS.js → dialog-DrgcVFLG.js} +1 -1
  26. package/dist/assets/{dropdown-menu.styles-C1ZHIuRb.js → dropdown-menu.styles-CeLR2UTs.js} +1 -1
  27. package/dist/assets/{es-B-bIZJl8.js → es-D0ZhEIQm.js} +1 -1
  28. package/dist/assets/{fileMentionTouchSelection-DeRoQoun.js → fileMentionTouchSelection-COw28yPf.js} +1 -1
  29. package/dist/assets/{fr-C-jelb-3.js → fr-Cx3Hkjq_.js} +1 -1
  30. package/dist/assets/{gitApi-DOLBq3YG.js → gitApi-D0t8KXsn.js} +1 -1
  31. package/dist/assets/{input-WOD4auFc.js → input-DaOOTCQd.js} +1 -1
  32. package/dist/assets/{insertionBoundaries-D3WwSv5D.js → insertionBoundaries-UMFkRmkG.js} +1 -1
  33. package/dist/assets/{ja-xvM42AA5.js → ja-BRvZxcKF.js} +1 -1
  34. package/dist/assets/{ko-B-GZkDg7.js → ko-HRfDZwXS.js} +1 -1
  35. package/dist/assets/{main-BOxiEPS4.js → main-B_h17HmQ.js} +2 -2
  36. package/dist/assets/{main-B-FsHx13.js → main-DZSusaPd.js} +14 -14
  37. package/dist/assets/{markdownHeightCache-5CpnnSmS.js → markdownHeightCache-BwSTMSRn.js} +1 -1
  38. package/dist/assets/{mcpQueries-CFY_rtuA.js → mcpQueries-CCU0buGG.js} +1 -1
  39. package/dist/assets/{miniChat-g5J8Degc.js → miniChat-B1i0B5Ml.js} +2 -2
  40. package/dist/assets/{mobile-DHjWMGCC.js → mobile-C-PKN6lA.js} +2 -2
  41. package/dist/assets/{mobileBackNavigation-BbBhDobV.js → mobileBackNavigation-CBPY3q34.js} +1 -1
  42. package/dist/assets/{multirun-Co29dOXB.js → multirun-BTBDMVOl.js} +1 -1
  43. package/dist/assets/{pl-D8UVHcSw.js → pl-CxLc1wGT.js} +1 -1
  44. package/dist/assets/{projectMeta-8wYzdBk7.js → projectMeta---vfnScT.js} +1 -1
  45. package/dist/assets/{pt-BR-Bb_wdffU.js → pt-BR-D4Lpwv4-.js} +1 -1
  46. package/dist/assets/renderElectronMiniChatApp-CBZ5TGG8.js +2 -0
  47. package/dist/assets/{renderMobileApp-BtiK86q8.js → renderMobileApp-DaFhnxuq.js} +5 -5
  48. package/dist/assets/{runtimeConfig-n9quMf6C.js → runtimeConfig-DTzs5NCT.js} +1 -1
  49. package/dist/assets/{runtimeEndpointReset-N3IM5F3l.js → runtimeEndpointReset-CBcDor5H.js} +6 -6
  50. package/dist/assets/{scheduledTaskNavigation-DZPYi_hq.js → scheduledTaskNavigation-C6UYwVbD.js} +1 -1
  51. package/dist/assets/{sessionChangeSummary-D1Kx571Z.js → sessionChangeSummary-DTa1NhbK.js} +1 -1
  52. package/dist/assets/{sessionLookup-BXZQW9JF.js → sessionLookup-xGVDWmBL.js} +1 -1
  53. package/dist/assets/{sortable-tabs-strip-UuiXdRGu.js → sortable-tabs-strip-BMrSDJob.js} +1 -1
  54. package/dist/assets/{speechSettingsQueries-Bz_O_kOx.js → speechSettingsQueries-Chq_vO6e.js} +1 -1
  55. package/dist/assets/src-BEVRKYT8.css +2 -0
  56. package/dist/assets/{store-BYkfys9K.js → store-CZu30-QE.js} +2 -2
  57. package/dist/assets/{textarea-DI4wL4i7.js → textarea-BcA4uouw.js} +1 -1
  58. package/dist/assets/{tooltip-yKi3siRK.js → tooltip-DGUZtHif.js} +1 -1
  59. package/dist/assets/{uk-cyouy6KD.js → uk-BdjdFLjV.js} +1 -1
  60. package/dist/assets/{useAppFontEffects-DkwXqB_-.js → useAppFontEffects-CzYFu1JQ.js} +6 -6
  61. package/dist/assets/{useDesktopWindowControlsLayout-B8GLew3c.js → useDesktopWindowControlsLayout-DML3uW6M.js} +1 -1
  62. package/dist/assets/{useEffectiveDirectory-DvLwhDG7.js → useEffectiveDirectory-CYhf9ITQ.js} +1 -1
  63. package/dist/assets/{useMobileNavigationStore-CyTqHrGP.js → useMobileNavigationStore-DvSdigrK.js} +6 -6
  64. package/dist/assets/{useWorkerHighlightedLines-YWw7-fgl.js → useWorkerHighlightedLines-BThWzx-h.js} +1 -1
  65. package/dist/assets/{zh-CN-DZ7CIU-k.js → zh-CN-BIC0OlRu.js} +1 -1
  66. package/dist/assets/{zh-TW-km9L-3oj.js → zh-TW-Bavvf14t.js} +1 -1
  67. package/dist/index.html +3 -3
  68. package/dist/mini-chat.html +3 -3
  69. package/dist/mobile.html +3 -3
  70. package/package.json +1 -1
  71. package/server/lib/content-search/DOCUMENTATION.md +10 -6
  72. package/server/lib/content-search/runtime.js +0 -4
  73. package/server/lib/content-search/runtime.test.js +47 -0
  74. package/server/lib/content-search/service.js +1 -2
  75. package/server/lib/content-search/service.test.js +3 -1
  76. package/dist/assets/MarkdownRenderer-BsYm51S5.js +0 -2
  77. package/dist/assets/MobileTabPageHeader--zhPlGIv.js +0 -2
  78. package/dist/assets/renderElectronMiniChatApp-DTJeYDVZ.js +0 -2
  79. package/dist/assets/src-D1qF7lK_.css +0 -2
package/dist/index.html CHANGED
@@ -552,7 +552,7 @@
552
552
  opacity: 0.72;
553
553
  }
554
554
  </style>
555
- <script type="module" crossorigin src="/assets/main-BOxiEPS4.js"></script>
555
+ <script type="module" crossorigin src="/assets/main-B_h17HmQ.js"></script>
556
556
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
557
557
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
558
558
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -577,8 +577,8 @@
577
577
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
578
578
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
579
579
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-KNLHDj7G.js">
580
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-n9quMf6C.js">
581
- <link rel="stylesheet" crossorigin href="/assets/src-D1qF7lK_.css">
580
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-DTzs5NCT.js">
581
+ <link rel="stylesheet" crossorigin href="/assets/src-BEVRKYT8.css">
582
582
  </head>
583
583
  <body class="h-full bg-background text-foreground">
584
584
  <!-- Keep the startup layer outside #root. React replaces every child of
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-g5J8Degc.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-B1i0B5Ml.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -99,8 +99,8 @@
99
99
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
100
100
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
101
101
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-KNLHDj7G.js">
102
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-n9quMf6C.js">
103
- <link rel="stylesheet" crossorigin href="/assets/src-D1qF7lK_.css">
102
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-DTzs5NCT.js">
103
+ <link rel="stylesheet" crossorigin href="/assets/src-BEVRKYT8.css">
104
104
  </head>
105
105
  <body class="h-full bg-background text-foreground">
106
106
  <div id="root" class="h-full">
package/dist/mobile.html CHANGED
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-DHjWMGCC.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-C-PKN6lA.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -88,8 +88,8 @@
88
88
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
89
89
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
90
90
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-KNLHDj7G.js">
91
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-n9quMf6C.js">
92
- <link rel="stylesheet" crossorigin href="/assets/src-D1qF7lK_.css">
91
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-DTzs5NCT.js">
92
+ <link rel="stylesheet" crossorigin href="/assets/src-BEVRKYT8.css">
93
93
  </head>
94
94
  <body class="h-full bg-background text-foreground">
95
95
  <div id="root" class="h-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuriai/web",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-beta.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -30,8 +30,9 @@ timestamps, not installation/version timestamps or browser onboarding flags.
30
30
  An absent completion marker requires initialization. Every startup still walks
31
31
  the authoritative complete OpenCode catalog and compares each recent session's
32
32
  updated time and indexed boundary; a prior global completion never bypasses
33
- that check. Missing, stale, or insufficient-coverage checkpoints reopen the same
34
- initialization step. Already verified unchanged sessions are reused, including
33
+ that check. Missing, stale, or insufficient-coverage checkpoints are refreshed in
34
+ the background after the first successful initialization, without clearing its
35
+ completion marker or reopening onboarding. Already verified unchanged sessions are reused, including
35
36
  sessions with no searchable text. Each session now commits an `indexed_at`
36
37
  completion timestamp atomically with its projection, source update time and
37
38
  coverage boundary. Existing databases gain this nullable column and the coverage
@@ -41,8 +42,9 @@ thirty-day boundary: a historical coverage claim alone cannot certify that a
41
42
  pre-upgrade partial projection was complete. Successful new checkpoints survive
42
43
  retries; subsequent scans reuse them normally.
43
44
 
44
- The start timestamp survives partial failures and restarts. Completion and the
45
- verified boundary advance only after the whole catalog and required message
45
+ The first start and completion timestamps survive incremental updates, partial
46
+ failures and restarts. Initial completion is recorded and the verified boundary
47
+ advances only after the whole catalog and required message
46
48
  pages succeed, SQLite writes and pruning succeed, and no dirty event remains.
47
49
  Partial/error passes retain the last verified boundary and keep completion null
48
50
  for unfinished initialization; successful sessions resume from their committed
@@ -54,8 +56,10 @@ coverage (for example after a system-clock correction).
54
56
  The status response adds `initializationRequired` and these durable timestamps.
55
57
  `updatedAt` remains the current process's latest completed pass, including partial
56
58
  passes; clients must not confuse it with successful durable completion. A warm
57
- startup may be `pending` with `initializationRequired: false` until verification
58
- discovers a gap. No UI-triggered import or OpenCode database conversion is needed:
59
+ startup may be `pending` with `initializationRequired: false`; discovered gaps
60
+ remain background work. `initializationRequired` indicates unfinished first-time
61
+ initialization, not whether the latest incremental pass has caught up. No
62
+ UI-triggered import or OpenCode database conversion is needed:
59
63
  the existing readiness gate waits for OpenCode's migration, then native V2
60
64
  session/message APIs supply the history directly.
61
65
 
@@ -55,9 +55,6 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
55
55
  state.completed = 0;
56
56
  const recentIDs = new Set(sessions.map((session) => session.id));
57
57
  for (const id of pendingDirty) if (!recentIDs.has(id)) dirty.delete(id);
58
- if (sessions.some((session) => dirty.has(session.id) || service.updated(runtime, session.id, state.since) !== session.time.updated)) {
59
- service.beginInitialization(runtime, now());
60
- }
61
58
  if (service.coverage(runtime).indexCompletedAt === null) state.phase = 'indexing';
62
59
  let index = 0;
63
60
  const worker = async () => {
@@ -101,7 +98,6 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
101
98
  service.prune(runtime, state.since, ids);
102
99
  state.phase = state.failed ? 'partial' : 'ready';
103
100
  state.updatedAt = now();
104
- if (dirty.size) service.beginInitialization(runtime, state.updatedAt);
105
101
  if (!state.failed && !dirty.size) service.completeInitialization(runtime, state.since, state.updatedAt);
106
102
  }
107
103
  })().catch(() => {
@@ -38,6 +38,53 @@ test('persists initialization times only after all thirty-day history is covered
38
38
  await runtime.stop(); service.close();
39
39
  });
40
40
 
41
+ test('completed initialization survives incremental refresh, failure, restart and dirty events', async () => {
42
+ const service = createContentSearchService({ dbPath: ':memory:' });
43
+ let clock = 1000;
44
+ let version = 1;
45
+ let fail = false;
46
+ let duringRead;
47
+ const dependencies = { service, getRuntimeKey: () => 'host', now: () => clock,
48
+ listSessions: async () => ({ data: [{ id: 's', time: { updated: version } }] }),
49
+ listMessages: async () => {
50
+ duringRead = runtime.status();
51
+ if (fail) throw new Error('offline');
52
+ if (version === 3) runtime.observe({ payload: { type: 'session.updated', properties: { id: 's' } } });
53
+ return { data: [{ type: 'user', id: 'm', sessionID: 's', time: { created: 900 }, text: `version${version}` }] };
54
+ },
55
+ };
56
+ let runtime = createContentSearchRuntime(dependencies);
57
+ try {
58
+ await runtime.sync();
59
+ const initialized = service.coverage('host');
60
+ version = 2; clock = 2000; fail = true;
61
+ await runtime.sync();
62
+ expect(duringRead.initializationRequired).toBe(false);
63
+ expect(runtime.status()).toMatchObject({ phase: 'partial', initializationRequired: false });
64
+ expect(service.coverage('host')).toEqual(initialized);
65
+ expect(service.search('host', 'version1')).toHaveLength(1);
66
+ await runtime.stop();
67
+ runtime = createContentSearchRuntime(dependencies);
68
+ expect(runtime.status().initializationRequired).toBe(false);
69
+ fail = false;
70
+ await runtime.sync();
71
+ expect(duringRead.initializationRequired).toBe(false);
72
+ expect(service.coverage('host')).toMatchObject({ indexStartedAt: 1000, indexCompletedAt: 1000, verifiedAt: 2000 });
73
+ expect(service.search('host', 'version2')).toHaveLength(1);
74
+ version = 3; clock = 3000;
75
+ await runtime.sync();
76
+ expect(runtime.status().initializationRequired).toBe(false);
77
+ expect(service.coverage('host')).toMatchObject({ indexCompletedAt: 1000, verifiedAt: 2000 });
78
+ version = 4; clock = 4000;
79
+ await runtime.sync();
80
+ expect(service.coverage('host')).toMatchObject({ indexCompletedAt: 1000, verifiedAt: 4000 });
81
+ expect(service.search('host', 'version4')).toHaveLength(1);
82
+ } finally {
83
+ await runtime.stop();
84
+ service.close();
85
+ }
86
+ });
87
+
41
88
  test('expired rows cannot leave a checkpoint claiming coverage that was pruned', async () => {
42
89
  const service = createContentSearchService({ dbPath: ':memory:' });
43
90
  service.replaceSession('host', { id: 's', time: { updated: 10 } }, [], 1);
@@ -48,8 +48,7 @@ export function createContentSearchService({ dbPath }) {
48
48
  },
49
49
  beginInitialization(runtime, timestamp) {
50
50
  db.prepare(`INSERT INTO search_coverage(runtime,started_at) VALUES(?,?)
51
- ON CONFLICT(runtime) DO UPDATE SET started_at=excluded.started_at, completed_at=NULL
52
- WHERE search_coverage.completed_at IS NOT NULL`).run(runtime, timestamp);
51
+ ON CONFLICT(runtime) DO NOTHING`).run(runtime, timestamp);
53
52
  },
54
53
  completeInitialization(runtime, since, timestamp) {
55
54
  db.prepare(`UPDATE search_coverage SET completed_at=COALESCE(completed_at,?), since=?, verified_at=? WHERE runtime=?`)
@@ -54,7 +54,9 @@ test.each([false, true])('upgrades old checkpoints (existing boundary: %s) witho
54
54
  expect(service.updated('host', 's', 0)).toBe(50);
55
55
  expect(service.coverage('other').indexCompletedAt).toBeNull();
56
56
  service.beginInitialization('host', 300);
57
- expect(service.coverage('host')).toMatchObject({ indexStartedAt: 300, indexCompletedAt: null, verifiedAt: 200 });
57
+ service.close();
58
+ service = createContentSearchService({ dbPath });
59
+ expect(service.coverage('host')).toEqual({ indexStartedAt: 100, indexCompletedAt: 200, coveredSince: 0, verifiedAt: 200 });
58
60
  } finally {
59
61
  service?.close();
60
62
  fs.rmSync(directory, { recursive: true, force: true });
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-B98l37eW.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-NMQx_cnG.js","assets/runtime-switch-CAZiOV2G.js","assets/runtime-auth-ef9W7A43.js","assets/vendor-zustand-o69pgTEK.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/vendor-react-BP2cRVqX.js","assets/runtime-file-resource-C1k5nbWb.js","assets/queryRuntime-DKGLQtb9.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/vendor-markstream-react-Bm0cO70Z.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-BBAlbKlC.js","assets/persistence-Dzooc9Xg.js","assets/vendor-pathe-vBmvQE8f.js","assets/store-BYkfys9K.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useMobileNavigationStore-CyTqHrGP.js","assets/platform-7bX6qtBV.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/vendor-sonner-ZS8XIOVl.js","assets/useAssistantUIStore-D7JZlg_Q.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/useThemeSystem-8jhE4Zyk.js","assets/tooltip-yKi3siRK.js","assets/image-loading-CVq5GLEY.js","assets/image-loading-D9Z_BASK.css","assets/url-Be8VCT8M.js","assets/useEffectiveDirectory-DvLwhDG7.js","assets/LoadingImage-B5xiKJjg.js","assets/ImageLoadingPlaceholder-DrL-lXR9.js","assets/markdownHeightCache-5CpnnSmS.js","assets/dualLimitLru-D8Sphgua.js","assets/MarkdownRendererImpl-DXU28IKm.js","assets/vendor-katex-DNVSTX6g.js","assets/markdown-worker-CkO3sT4Y.js","assets/FadeInOnReveal-BWusb8te.js","assets/markdownTheme-DHoKvD6O.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/MarkstreamRendererImpl-BiiiaYh1.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-o69pgTEK.js";import{it as n,rt as r}from"./vendor-base-ui-CdzJ6My_.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as o}from"./button-BBAlbKlC.js";import{t as s}from"./useEffectiveDirectory-DvLwhDG7.js";import{i as c,n as l,t as u}from"./markdownHeightCache-5CpnnSmS.js";var d=i(),f=e(n(),1),p=`yuri:chunk-import-reload`,m=250,h=3e4,g=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function _(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function v(e){let t=_(e);return g.some(e=>e.test(t))}function y(e){return`0.1.1:${_(e).slice(0,500)}`}function b(e){if(typeof window>`u`)return;let t=Date.now(),n=y(e),r=null;try{let e=window.sessionStorage.getItem(p);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<h)){try{window.sessionStorage.setItem(p,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:_(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function x(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!v(e)||t>=n)break;await new Promise(e=>setTimeout(e,m*(t+1)))}throw v(r)&&b(r),r}var S=e=>(0,f.lazy)(()=>x(e)),C=(e,t)=>!!t?.toLowerCase().startsWith(`video/`)||/^data:video\//i.test(e)||/\.(?:mp4|m4v|webm|mov|ogv|ogg)(?:[?#]|$)/i.test(e),w=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},T=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},E=`yuri:markstream-react`,D=e=>w(E,e),O=t(e=>({markstreamReactEnabled:D(),setMarkstreamReactEnabled:t=>{T(E,t),e({markstreamReactEnabled:t})}})),k=null,A=()=>(k??=a(()=>import(`./MarkstreamRendererImpl-B98l37eW.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65])).catch(e=>{throw k=null,e}),k),j=()=>{A().catch(()=>void 0)},M=null,N=()=>(M??=a(()=>import(`./MarkdownRendererImpl-DXU28IKm.js`).then(e=>e.n),__vite__mapDeps([45,1,4,5,11,12,23,6,2,7,8,3,9,24,29,30,10,13,14,46,19,20,21,22,25,26,27,28,31,32,33,34,44,35,37,38,39,47,40,48,43,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64])).catch(e=>{throw M=null,e}),M),P=()=>{N().catch(()=>void 0),D()&&j()},F=class extends f.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},I=f.createContext(!0),L=()=>f.useContext(I),R=r(),z=S(()=>N().then(e=>({default:e.MarkdownRenderer}))),B=S(()=>A().then(e=>({default:e.MarkstreamRenderer}))),V=S(()=>N().then(e=>({default:e.SimpleMarkdownRenderer}))),H=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,U=e=>{let t=(0,d.c)(15),n=O(K),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?l(u(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let s=a,f;t[5]!==e.className||t[6]!==e.variant?(f=o(`relative break-words w-full min-w-0`,H(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=f):f=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==s?(p=(0,R.jsx)(c,{animated:e.animated,content:r,reservedHeight:s}),t[8]=r,t[9]=e.animated,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,R.jsx)(`div`,{className:f,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m},W=e=>{let t=(0,d.c)(13),n=L(),r=O(q);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(z,{...e})}),t[2]=e,t[3]=i);let a=i,o;t[4]!==a||t[5]!==r||t[6]!==e?(o=r?(0,R.jsx)(F,{fallback:a,children:(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(B,{...e})})}):a,t[4]=a,t[5]=r,t[6]=e,t[7]=o):o=t[7];let c=o,l;t[8]===e?l=t[9]:(l=t=>{if(!e.onShowPopup||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null,r=n?.getAttribute(`href`);if(!r||!C(r))return;t.preventDefault(),t.stopPropagation();let i=n?.textContent?.trim()||r.split(/[/?#]/).filter(Boolean).pop()||r;e.onShowPopup({open:!0,title:i,content:``,video:{url:r,filename:i,directory:s()??``}})},t[8]=e,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,R.jsx)(`div`,{className:`contents`,onClickCapture:l,children:c}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},G=e=>{let t=(0,d.c)(4);if(!L()){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e}),children:(0,R.jsx)(V,{...e})}),t[2]=e,t[3]=n),n};function K(e){return e.markstreamReactEnabled}function q(e){return e.markstreamReactEnabled}export{C as a,P as i,G as n,S as o,I as r,W as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,o as r}from"./runtime-switch-CAZiOV2G.js";import{a as i,o as a,r as o,s,t as c,u as l}from"./queryRuntime-DKGLQtb9.js";import{$t as u,Bt as d,an as f,d as p,en as m,et as h,gn as g,i as _,in as v,on as y,rn as b,tn as x,tt as S,zt as C}from"./persistence-Dzooc9Xg.js";import{a as w,i as T,r as E}from"./vendor-zustand-o69pgTEK.js";import{it as D,nt as O,rt as k}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as A,Nt as j,Vt as M,n as N,t as P}from"./platform-7bX6qtBV.js";import{b as F,n as I}from"./useUIStore-NMQx_cnG.js";import{n as L}from"./vendor-react-BP2cRVqX.js";import{o as R}from"./vendor-tanstack-react-query-CdqCAt40.js";import{o as z}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as ee}from"./types-BuiqMmh_.js";import{$ as te,A as ne,B,G as re,H as V,J as ie,L as ae,P as oe,T as se,U as ce,W as le,X as ue,Y as de,a as fe,at as H,dt as pe,f as me,ft as he,g as ge,l as _e,pt as ve,st as ye,z as U}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{c as be,o as W,r as xe}from"./vendor-codemirror-lang-angular-DXOgWEVj.js";import{n as Se,r as Ce}from"./vendor-codemirror-lang-json-mLulNbwB.js";import{n as we}from"./vendor-codemirror-lang-markdown-CV1IO6Qs.js";import{n as Te}from"./vendor-codemirror-lang-python-YM2WVLHF.js";import{O as Ee}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{n as De}from"./vendor-reactuses-core-BpfIZ1tg.js";import{a as Oe,d as ke,f as G,p as Ae,r as K,t as q}from"./button-BBAlbKlC.js";import{Pr as je,Rr as J,bi as Me,d as Ne,er as Pe,fo as Fe,hi as Ie,ir as Le,jr as Re,nr as ze,or as Be,rr as Ve,so as He,sr as Ue,vn as We,wr as Ge}from"./useMobileNavigationStore-CyTqHrGP.js";import{n as Ke}from"./useThemeSystem-8jhE4Zyk.js";import{n as Y}from"./Icon-Cu3waV3-.js";import{a as qe,n as Je,o as Ye,r as Xe,t as Ze}from"./dialog-CmHz28bS.js";import{L as Qe,_ as $e,b as et,c as tt,n as nt,s as rt,u as it}from"./gitApi-DOLBq3YG.js";import{A as at,_ as ot,a as st,b as ct,c as lt,h as ut,m as dt,n as ft,r as pt,t as mt,x as ht}from"./projectMeta-8wYzdBk7.js";import{t as gt}from"./input-WOD4auFc.js";import{i as _t,n as vt,t as yt}from"./tooltip-yKi3siRK.js";import{$t as bt,F as xt,G as St,Gt as Ct,J as wt,Jt as Tt,Kt as Et,M as Dt,P as Ot,U as kt,W as At,Xt as jt,Yt as Mt,a as Nt,in as Pt,it as Ft,k as It,q as Lt,qt as Rt,rt as zt,ut as Bt,v as Vt}from"./speechSettingsQueries-Bz_O_kOx.js";import{i as Ht,n as Ut}from"./OverlayScrollbar-BTOeKIbZ.js";import{n as Wt,t as Gt}from"./textarea-DI4wL4i7.js";import{n as Kt}from"./MarkdownRenderer-BsYm51S5.js";import{a as qt}from"./url-Be8VCT8M.js";import{r as Jt}from"./markdown-worker-CkO3sT4Y.js";import{i as Yt,n as Xt,o as Zt}from"./mcpQueries-CFY_rtuA.js";import{n as Qt,r as $t,t as en}from"./collapsible-ioYeSDPc.js";import{a as tn,d as nn,o as rn,s as an}from"./vendor-codemirror-commands-B8KrBQ9B.js";import{a as on,c as sn,i as cn,o as ln,r as un,s as dn}from"./vendor-codemirror-search-ZqtrPLjU.js";import{n as fn,t as pn}from"./vendor-replit-codemirror-vim-DDj0dSVY.js";import{t as mn}from"./vendor-codemirror-language-data-Ctd4WxgW.js";import{i as hn,n as gn,r as _n,t as vn}from"./projectActions-BX0cjZoq.js";var yn=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],bn=e=>[...yn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],X=L(),Z=k();function xn(e){let t=(0,X.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),r=(0,Z.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`0.5`,fillRule:`evenodd`,viewBox:`-0.5 -0.5 25 25`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var Sn={},Cn=(e,t=n())=>JSON.stringify([t,Xt(e)]),wn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},Tn=e=>{let t=Xt(e);return t?j.getScopedApiClient(t):j.getApiClient()},En=e=>e?{location:{directory:e}}:void 0,Dn=e=>Xt(e===void 0?A.getState().currentDirectory:e),On=w()(E((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=Cn(Dn(e));return t().diagnosticsByDirectory[n]??Sn},clearDiagnostic:(t,n,r)=>{let i=Cn(Dn(n),r);e(e=>({diagnosticsByDirectory:wn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let a=Dn(r),o=n(),s=Cn(a,o),c=Tn(a);try{await c.mcp.connect({server:t,...En(a)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[s]:{...e.diagnosticsByDirectory[s]??{},[t]:{status:`failed`,error:r}}}})),n}await Zt(i,a,o),e(e=>({diagnosticsByDirectory:wn(e.diagnosticsByDirectory,s,t)}))},disconnect:async(t,r)=>{let a=Dn(r),o=n(),s=Cn(a,o);await Tn(a).mcp.disconnect({server:t,...En(a)}),await Zt(i,a,o),e(e=>({diagnosticsByDirectory:wn(e.diagnosticsByDirectory,s,t)}))},startAuth:async(e,t)=>{throw M(`mcp.auth`)},completeAuth:async(e,t,n)=>{throw M(`mcp.auth`)},clearAuth:async(e,t)=>{throw M(`mcp.auth`)},testConnection:async(t,r)=>{let a=Dn(r),o=n(),s=Cn(a,o),c=Tn(a),l=Yt(i,a,o)[t]?.status===`connected`,u,d;try{await c.mcp.connect({server:t,...En(a)})}catch(n){u=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[s]:{...e.diagnosticsByDirectory[s]??{},[t]:{status:`failed`,error:u??`Connection failed`}}}}))}let f=(await Zt(i,a,o))[t],p=f;if(!l&&f?.status===`connected`){try{await c.mcp.disconnect({server:t,...En(a)})}catch(e){d=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await Zt(i,a,o)}return u||e(e=>({diagnosticsByDirectory:wn(e.diagnosticsByDirectory,s,t)})),{status:p??Yt(i,a,o)[t],error:u,warning:d}}}))),Q=e(D(),1),kn=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,An=()=>kn(`0.1.1`),jn=(e,t)=>kn(t)||kn(e),Mn=(e,t)=>{let n=kn(e);return n?typeof t!=`number`||!Number.isFinite(t)?n:`${n} (${t})`:null},Nn=async()=>{let e=An();if(!N())return e;try{let{App:t}=await z(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return jn((await t.getInfo()).version,e)}catch{return e}},Pn=async()=>{if(!N())return null;try{let{App:e}=await z(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),t=await e.getInfo(),n=typeof t.build==`string`?t.build.trim():``;if(n.length===0)return null;let r=Number.parseInt(n,10);return Number.isFinite(r)?r:null}catch{return null}},Fn=`https://yuri-updates.xiaobe.top/v1/update/check`,In=`https://yuri-origin.xiaobe.top/v1/update/check`,Ln=`https://github.com/yee94/yuri/releases/latest`,Rn=`https://github.com/yee94/yuri/releases`,zn=`https://testflight.apple.com/join/pN5SSHeg`,Bn=1e4;function Vn(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function Hn(e,t){let n=Vn(e),r=Vn(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function Un(){return[Fn,In]}function Wn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Gn(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function Kn(e,t,n,r){try{if(N())try{let{CapacitorHttp:r}=await z(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,url:typeof o.url==`string`?o.url:e,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,url:i.url,json:()=>i.json()}}catch{return null}}function qn(e,t){return e===`ios`?zn:`${Rn}/download/v${t}/app-release.apk`}function Jn(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Hn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Rn}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():qn(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function Yn(e,t,n,r){let i=await Kn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Gn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Jn(a,t.currentVersion,t.platform)}async function Xn(e,t,n,r){let i=await Kn(Ln,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:Ln,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=Hn(s,e),l=`${Rn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:qn(t,s)}}async function Zn(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=Un(),a=r()+Bn;for(let[t,o]of i.entries()){let s=Wn(a,i.length-t+1,r);if(s===null)break;let c=await Yn(o,e,s,n);if(c)return c}let o=Wn(a,1,r);if(o!==null){let r=await Xn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Qn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Ut();return e}catch{return`unknown`}}function $n(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function er(){let e=P();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function tr(e){let t=I.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Qn()),n.set(`arch`,$n()),n.set(`platform`,er()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,u()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function nr(e,t){let n=t??`unknown`;try{let r=tr(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let a=await l(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=null;try{o=await a.json()}catch{o=null}if(!a.ok)return{available:!1,currentVersion:n,error:typeof o?.error==`string`&&o.error.trim().length>0?o.error.trim():`Server responded with ${a.status}`};if(!o)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let s=typeof o.error==`string`&&o.error.trim().length>0?o.error.trim():void 0;return{available:o.available===!0,version:typeof o.version==`string`?o.version:void 0,currentVersion:typeof o.currentVersion==`string`?o.currentVersion:n,body:typeof o.body==`string`?o.body:void 0,releaseUrl:typeof o.releaseUrl==`string`?o.releaseUrl:void 0,downloadUrl:typeof o.downloadUrl==`string`?o.downloadUrl:void 0,nextSuggestedCheckInSec:typeof o.nextSuggestedCheckInSec==`number`&&Number.isFinite(o.nextSuggestedCheckInSec)?o.nextSuggestedCheckInSec:void 0,packageManager:typeof o.packageManager==`string`?o.packageManager:void 0,updateCommand:typeof o.updateCommand==`string`?o.updateCommand:void 0,error:s}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function rr(){return N()?`mobile`:x()?`desktop`:b()?`vscode`:v()?`web`:null}var ir={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null};function ar(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};return e.primaryAction===`apply_ota`&&e.ota.bundle?e.ota.bundle.releaseVersion===t?{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}:{available:!0,otaPhase:`available`,info:{available:!0,version:e.ota.bundle.releaseVersion,currentVersion:t,downloadUrl:e.ota.bundle.url,nextSuggestedCheckInSec:e.nextCheckInSec,inAppApply:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:e.primaryAction===`install_native_required`?{available:e.native.state===`required`||e.native.state===`available`,otaPhase:`idle`,info:{available:e.native.state===`required`||e.native.state===`available`,version:e.native.version,currentVersion:t,downloadUrl:e.native.installUrl,nextSuggestedCheckInSec:e.nextCheckInSec,manualUpdate:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var or=0,sr=w()((e,t)=>({...ir,checkForUpdates:async()=>{let n=rr();if(!n)return null;let r=++or;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=I.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await C(n);if(r!==or||I.getState().otaChannelOverride!==n)return null;let a=i?.downloaded===!0;return e({checking:!1,available:i?.available??!1,downloaded:a,...a?{downloading:!1,progress:null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:a?`pending_restart`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await nr(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await nr(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await Nn()??`unknown`,r=N()?s()?.mobileUpdates:void 0,o=I.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==o;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let a=await r.checkForOtaUpdate(o===`beta`||o===`stable`?{channelOverride:o}:void 0),s=ar(a,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==a.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:a.nextCheckInSec,otaDecision:a,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:o,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),a.nextCheckInSec}catch(t){if(!(t instanceof ee)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:o}),null}}return i=await Zn({currentVersion:n,platform:er()===`ios`?`ios`:`android`,deviceClass:Qn(),arch:$n(),reportUsage:I.getState().reportUsage}),a=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(i){return r===or&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:a,downloaded:o}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(a||o)return;let t=s()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=I.getState().otaChannelOverride,r=await C(n);if(n!==I.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await d(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!x())return()=>{};let n=[],r=await f(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await y(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=s()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await g())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{t().otaPhase!==`pending_restart`&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(ir)}})),cr=`https://github.com/yee94/yuri/releases`;function lr(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(Ae(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function ur(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function dr(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function fr(e,t){let n=e.split(`.`).map(e=>Number.parseInt(e,10)),r=t.split(`.`).map(e=>Number.parseInt(e,10));for(let e=0;e<3;e+=1){let t=Number.isFinite(n[e])?n[e]:0,i=Number.isFinite(r[e])?r[e]:0;if(t!==i)return i-t}return 0}function pr(e){let t=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({version:r[1]??``,date:r[2]??``,start:r.index});return n.length===0?[]:n.map((t,r)=>{let i=n[r+1]?.start??e.length,a=e.slice(t.start,i).trim();return{version:t.version,date:t.date,start:t.start,end:i,raw:a}})}var mr=2e3,hr=6e5;async function gr(){try{let e=await l(`/api/yuri/update-install`,{method:`POST`,headers:{"Content-Type":`application/json`}});return e.ok?{success:!0,autoRestart:(await e.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await e.json().catch(()=>({}))).error||`Server error: ${e.status}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function _r(){try{return(await l(`/health`,{method:`GET`,headers:{Accept:`application/json`}})).ok}catch{return!1}}async function vr(e,t=Math.ceil(hr/mr),n=mr){for(let r=0;r<t;r++){try{let t=await l(`/api/yuri/update-check`,{method:`GET`,headers:{Accept:`application/json`}});if(t.ok){let n=await t.json().catch(()=>null);if(n&&n.available===!1||n&&typeof n.currentVersion==`string`&&typeof e==`string`&&n.currentVersion!==e)return!0}else if((t.status===401||t.status===403)&&await _r())return!0}catch{}await new Promise(e=>setTimeout(e,n))}return!1}var yr=({open:e,onOpenChange:t,info:n,downloading:r,downloaded:i,progress:a,error:o,onDownload:s,onRestart:c,runtimeType:l=`desktop`})=>{let{t:u}=G(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`idle`),[h,g]=(0,Q.useState)(null),_=sr(e=>e.otaDownloadSkipped),v=n?.releaseUrl||(n?.version?`${cr}/tag/v${n.version}`:cr),y=n?.downloadUrl,b=a?.total?Math.round(a.downloaded/a.total*100):0,x=l===`web`,S=l===`mobile`,C=S&&n?.manualUpdate===!0&&!!y,w=S&&n?.inAppApply===!0,T=l===`desktop`&&n?.manualUpdate===!0,E=n?.updateCommand||`yuri update`,D=De(e=>{!e&&w&&i&&sr.getState().dismiss(),t(e)}),O=De(()=>{sr.getState().dismiss(),t(!1)});(0,Q.useEffect)(()=>{e||(m(`idle`),g(null))},[e]);let k=async()=>{(await ke(E)).ok&&(f(!0),setTimeout(()=>f(!1),2e3))},A=(0,Q.useCallback)(async e=>{await qt(e)},[]),j=(0,Q.useCallback)(async()=>{m(`updating`),g(null);let e=await gr();if(!e.success){m(`error`),g(e.error||u(`updateDialog.error.updateFailed`));return}e.autoRestart&&(m(`restarting`),await new Promise(e=>setTimeout(e,2e3))),m(`reconnecting`),await vr(n?.currentVersion)?window.location.reload():(m(`error`),g(u(`updateDialog.error.takingLonger`)))},[n?.currentVersion,u]),M=(0,Q.useCallback)(()=>{y&&A(y)},[A,y]),N=p!==`idle`&&p!==`error`,P=(0,Q.useMemo)(()=>{if(!n?.body)return null;let e=n.body.trim();if(!e)return null;let t=pr(e);if(t.length===0)return{kind:`raw`,title:u(`updateDialog.changelog.title`),content:dr(e)};let r=[...t].sort((e,t)=>fr(e.version,t.version));return{kind:`sections`,title:u(`updateDialog.changelog.title`),sections:r.map(t=>({version:t.version,dateLabel:lr(t.date),content:dr(ur(t.raw)||e)}))}},[n?.body,u]);return(0,Z.jsx)(Ze,{open:e,onOpenChange:N?void 0:D,children:(0,Z.jsxs)(Je,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[(0,Z.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[(0,Z.jsxs)(Ye,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Y,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:u(p===`restarting`||p===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`)})]}),(n?.currentVersion||n?.version)&&(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[n?.currentVersion&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/75`,children:n.currentVersion}),n?.currentVersion&&n?.version&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),n?.version&&(0,Z.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:n.version})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[x&&N&&(0,Z.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Z.jsxs)(`div`,{className:`typography-ui-label text-foreground`,children:[p===`updating`&&u(`updateDialog.status.installingUpdate`),p===`restarting`&&u(`updateDialog.status.serverRestarting`),p===`reconnecting`&&u(`updateDialog.status.waitingForServer`)]})]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`updateDialog.status.autoReloadHint`)})]}),P&&!N&&(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Z.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:P.title})]}),(0,Z.jsx)(Wt,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:P.kind===`raw`?(0,Z.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Kt,{content:P.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:P.sections.map(e=>(0,Z.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Z.jsxs)(`span`,{className:`rounded-md bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[11px] font-medium leading-4 text-[var(--primary-base)] tabular-nums sm:text-xs`,children:[`v`,e.version]}),(0,Z.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Z.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Kt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),x&&p===`error`&&(0,Z.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(Y,{name:`terminal`,className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]`,children:[(0,Z.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:E}),(0,Z.jsx)(`button`,{onClick:k,className:K(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,d&&`text-[var(--status-success)]`),title:u(d?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:d?(0,Z.jsx)(Y,{name:`check`,className:`h-4 w-4`}):(0,Z.jsx)(Y,{name:`clipboard`,className:`h-4 w-4`})})]})]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:u(`updateDialog.status.downloadingPayload`)}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[b,`%`]})]}),(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${b}%`}})})]}),(o||h)&&(0,Z.jsx)(`div`,{className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Z.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:o||h})})]}),w&&i&&_&&(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-3 py-2.5 text-sm text-[var(--status-success)]`,children:[(0,Z.jsx)(Y,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.status.otaBundleReused`)})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[!S||C?(0,Z.jsxs)(`a`,{href:S?y:v,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),`GitHub`]}):(0,Z.jsx)(`span`,{}),(0,Z.jsxs)(`div`,{className:`flex-1 flex justify-end`,children:[!x&&(!S||w)&&!T&&!i&&!r&&(0,Z.jsxs)(q,{onClick:s,size:`default`,children:[(0,Z.jsx)(Y,{name:`download`,className:`h-4 w-4`}),u(w?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`)]}),!x&&!S&&T&&!i&&!r&&(0,Z.jsxs)(q,{onClick:()=>void A(v),size:`default`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.downloading`)]}),!x&&(!S||w)&&i&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Z.jsx)(q,{onClick:O,variant:`ghost`,size:`default`,children:u(`updateDialog.actions.later`)}),(0,Z.jsxs)(q,{onClick:c,size:`default`,children:[(0,Z.jsx)(Y,{name:`restart`,className:`h-4 w-4`}),u(`updateDialog.actions.restartToUpdate`)]})]}),S&&!w&&C&&(0,Z.jsxs)(q,{onClick:M,size:`default`,children:[(0,Z.jsx)(Y,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),x&&!N&&(0,Z.jsxs)(q,{onClick:j,size:`default`,children:[(0,Z.jsx)(Y,{name:`download`,className:`h-4 w-4`}),u(`updateDialog.actions.updateNow`)]}),x&&N&&(0,Z.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Z.jsx)(Y,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.updating`)]})]})]})]})})},br=e(O(),1);function xr(e){let t=(0,X.c)(20),{label:n,children:r,description:i,itemId:a,ariaLabel:o,className:s,cardClassName:c,cardId:l}=e,u=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,d;t[0]===s?d=t[1]:(d=K(`yuri-settings-group`,s),t[0]=s,t[1]=d);let f;t[2]!==n||t[3]!==u?(f=n?(0,Z.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":u,children:n}):null,t[2]=n,t[3]=u,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=K(`yuri-settings-group-card`,c),t[5]=c,t[6]=p);let m;t[7]!==l||t[8]!==r||t[9]!==a||t[10]!==p?(m=(0,Z.jsx)(`div`,{id:l,"data-settings-item":a,className:p,children:r}),t[7]=l,t[8]=r,t[9]=a,t[10]=p,t[11]=m):m=t[11];let h;t[12]===i?h=t[13]:(h=i?(0,Z.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:i}):null,t[12]=i,t[13]=h);let g;return t[14]!==o||t[15]!==d||t[16]!==f||t[17]!==m||t[18]!==h?(g=(0,Z.jsxs)(`section`,{className:d,"aria-label":o,children:[f,m,h]}),t[14]=o,t[15]=d,t[16]=f,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function Sr(e){let t=(0,X.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,Z.jsx)(Cr,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,Z.jsx)(xr,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function Cr(e){let t=(0,X.c)(22),{label:n,children:r,description:i,itemId:a,className:o,copyClassName:s,controlClassName:c}=e,l;t[0]===o?l=t[1]:(l=K(`yuri-settings-group-row yuri-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=K(`yuri-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Z.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=d);let f;t[6]===i?f=t[7]:(f=i?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=f);let p;t[8]!==u||t[9]!==d||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:u,children:[d,f]}),t[8]=u,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=K(`yuri-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Z.jsx)(`div`,{"data-settings-value":``,className:m,children:r}),t[14]=r,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==a||t[18]!==l||t[19]!==p||t[20]!==h?(g=(0,Z.jsxs)(`div`,{"data-settings-item":a,className:l,children:[p,h]}),t[17]=a,t[18]=l,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}function wr(e){let t=(0,X.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=Tr,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=K(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let b;t[10]===i?b=t[11]:(b=(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=b);let x;t[12]===o?x=t[13]:(x=o?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=x);let S;t[14]!==x||t[15]!==b?(S=(0,Z.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[b,x]}),t[14]=x,t[15]=b,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(C=(0,Z.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,Z.jsx)(at,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=C):C=t[21];let w;return t[22]!==n||t[23]!==s||t[24]!==S||t[25]!==C||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(w=(0,Z.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[S,C]}),t[22]=n,t[23]=s,t[24]=S,t[25]=C,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=w):w=t[31],w}function Tr(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var Er=`/mcp/oauth/callback`,Dr=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},Or=e=>{let t=Ar(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},kr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Ar=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Dr(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},jr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,Mr=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=pn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return jr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function Nr(e){return e?[fn(),te.of(Mr),re()]:[]}var Pr={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},Fr={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function Ir(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(Pr)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(Fr)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var Lr=new WeakMap;function Rr(e,t){let n=cn(e.state);if(!n.valid)return Lr.delete(e),0;let r=Lr.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return Lr.set(e,{query:n,doc:e.state.doc,total:a}),a}function zr(e){let t=cn(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function Br(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=Rr(t,n),o=a===0?0:zr(t);i.textContent=a===0?``:`${o}/${a}`}var Vr=new H,Hr=new H,Ur=new H,Wr=new H,Gr=new H,Kr=new H,qr=new H,Jr=e=>e,Yr=se,Xr=on,Zr=un,Qr=class extends le{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`yuri-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},$r=(e,t)=>!e||e.length===0?[]:ve.define({create(n){let r=new pe,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,B.widget({widget:new Qr(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>V.decorations.from(e)}),ei=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return ce.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new pe;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,B.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function ti({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=Q.useRef(null),h=Q.useRef(null),g=Q.useRef(e),_=Q.useRef(t),v=Q.useRef(s),y=Q.useRef(c),b=Q.useRef(f),x=Q.useRef(l),S=Q.useRef(p),C=Q.useRef(new Map),[w,T]=Q.useState([]),E=Q.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=Q.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--yuri-editor-gutter-width`,`${i}px`)},[]);return Q.useEffect(()=>{g.current=e},[e]),Q.useEffect(()=>{_.current=t},[t]),Q.useEffect(()=>{v.current=s,y.current=c},[s,c]),Q.useEffect(()=>{b.current=f},[f]),Q.useEffect(()=>{x.current=l,E(l)},[l,E]),Q.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__YURI_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=ye.create({doc:g.current,extensions:[...e?[V.cspNonce.of(e)]:[],ie({fixed:!0}),Vr.of(ue(a)),rn(),ne.of(` `),qr.of(Nr(p)),de.of([nn,...tn,...an]),V.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=sn(e.startState),n=sn(e.state);t!==n&&b.current?.(n);let r=!cn(e.startState).eq(cn(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&Br(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),Hr.of(V.editable.of(!i)),Ur.of(n??[]),Wr.of(ei(o)),Gr.of($r(l,C.current)),Kr.of(u?[ln({top:!0}),de.of(Jr(dn))]:[])]});return h.current=new V({state:t,parent:m.current}),Yr(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),Q.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[Vr.reconfigure(ue(a)),Hr.reconfigure(V.editable.of(!i)),Ur.reconfigure(n??[]),Wr.reconfigure(ei(o)),Gr.reconfigure($r(l,C.current)),Kr.reconfigure(u?[ln({top:!0}),de.of(Jr(dn))]:[])]}),Yr(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),Q.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:qr.reconfigure(Nr(p))}))},[p]),Q.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Xr(e),requestAnimationFrame(()=>{Ir(e.dom),Br(e.dom,e,!0)})):Zr(e))},[d,u]),Q.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),Yr(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:m,className:K(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,br.createPortal)(e.content,e.container,e.id))]})}var ni=me.define(Ee),ri=Ce.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function ii(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return ni;case`json`:case`jsonc`:case`json5`:return Se().language;case`js`:case`javascript`:return W().language;case`jsx`:return W({jsx:!0}).language;case`ts`:case`typescript`:return W({typescript:!0}).language;case`tsx`:return W({typescript:!0,jsx:!0}).language;case`html`:return xe().language;case`css`:return be().language;case`py`:case`python`:return Te().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return we().language;case`heex`:case`eex`:case`leex`:return xe().language;default:return _e.matchLanguageName(mn,t,!0)}}var ai=e=>e.split(`/`).pop()?.toLowerCase()??``,oi=e=>{let t=ai(e);return t?_e.matchFilename(mn,t):null},si=()=>oe(fe.define([{tag:[U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],fontWeight:`600`},{tag:U.strong,fontWeight:`600`},{tag:U.emphasis,fontStyle:`italic`},{tag:U.strikethrough,textDecoration:`line-through`},{tag:[U.link,U.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:U.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:U.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:U.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:U.heading,color:`var(--markdown-heading1, currentColor)`}]));function ci(e){let t=e.toLowerCase();switch(ai(t)){case`makefile`:case`gnumakefile`:return ni}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return W({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return W({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[Se(),ri];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return Se();case`css`:case`scss`:case`sass`:case`less`:return be();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return xe();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[we({codeLanguages:ii}),si()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return ni;case`py`:case`pyw`:case`pyi`:return Te();default:return null}}async function li(e){let t=oi(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function ui(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=V.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=fe.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],class:`cm-comment`},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],class:`cm-keyword`},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],class:`cm-operator`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],class:`cm-punctuation`},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],class:`cm-string`},{tag:U.escape,class:`cm-string-2`},{tag:[U.number,U.bool,U.atom,U.null,U.self],class:`cm-number`},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],class:`cm-builtin`},{tag:U.definition(U.variableName),class:`cm-def`},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],class:`cm-variable`},{tag:U.propertyName,class:`cm-property`},{tag:U.attributeName,class:`cm-attribute`},{tag:[U.className,U.typeName,U.namespace],class:`cm-variable-3`},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],class:`cm-tag`},{tag:U.link,class:`cm-link`},{tag:[U.heading,U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],class:`cm-keyword`}]),l=fe.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],color:e.colors.syntax.base.comment},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],color:e.colors.syntax.base.keyword},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],color:e.colors.syntax.base.operator},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],color:e.colors.syntax.base.string},{tag:U.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[U.number,U.bool,U.atom,U.null,U.self],color:e.colors.syntax.base.number},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],color:e.colors.syntax.base.function},{tag:U.definition(U.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],color:e.colors.syntax.base.variable},{tag:U.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:U.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[U.className,U.typeName,U.namespace],color:e.colors.syntax.base.type},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:U.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,oe(ge,{fallback:!0}),oe(ae),oe(c),oe(l)]}var di=180,fi=he.define(),pi=1,mi=2,hi=4,gi=new Map,_i=(e,t)=>{let n=`${e}|${t}`,r=gi.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&pi&&(i+=`font-style:italic;`),t&mi&&(i+=`font-weight:bold;`),t&hi&&(i+=`text-decoration:underline;`);let a=B.mark({attributes:{style:i}});return gi.set(n,a),a},vi=(e,t)=>{let n=new pe,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,_i(t,r)))}}return n.finish()},yi=ve.define({create(){return B.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(fi)&&(n=e.value);return n},provide:e=>V.decorations.from(e)}),bi=e=>ce.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},di)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await Jt(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:fi.of(vi(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),xi=e=>[yi,bi(e)],Si=e=>{let t=(0,X.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Z.jsx)(Y,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Z.jsx)(Y,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Z.jsx)(_t,{asChild:!0,children:(0,Z.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Z.jsx)(vt,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(yt,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Ci=w()(E(T((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await $e(),isLoading:!1}),!0}catch(t){return console.error(`Failed to load git identity profiles:`,t),e({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{let t=await et();return t&&t.userName&&t.userEmail?e({globalIdentity:{id:`global`,name:`Global Identity`,userName:t.userName,userEmail:t.userEmail,authType:t.sshCommand?`ssh`:void 0,sshKey:t.sshCommand?t.sshCommand.replace(`ssh -i `,``):null,color:`info`,icon:`house`}}):e({globalIdentity:null}),!0}catch(t){return console.error(`Failed to load global git identity:`,t),e({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{return e({discoveredCredentials:await it()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=s()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await _({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await rt(n),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to create git identity profile:`,e),!1}},updateProfile:async(e,n)=>{try{let r=t().profiles.find(t=>t.id===e);if(!r)throw Error(`Profile not found`);let i={...r,...n};return await Qe(e,i),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to update git identity profile:`,e),!1}},deleteProfile:async n=>{try{return await tt(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:F(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=Ci);var wi=`w-full max-w-[30rem]`,Ti=e=>{let t=(0,X.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Z.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=K(`yuri-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Z.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Z.jsx)(xr,{className:`yuri-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Z.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},Ei=450,Di=({projectRef:e=null})=>{let{t}=G(),{isMobile:n,isTablet:r}=Ht(),i=n||r,a=Fe(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Ne(e=>e.getWorktreeMetadata),c=We(),l=A(e=>e.homeDirectory),[u,d]=Q.useState([]),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState([]),[S,C]=Q.useState(!1),w=Q.useRef(!1),T=Q.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),E=Q.useCallback(async()=>{if(!(!T||v===!1))try{let e=await lt(T);x(e)}catch{}},[T,v]);Q.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await nt(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),Q.useEffect(()=>{if(!T){x([]),C(!1);return}if(v===!1){x([]),C(!1);return}let e=!1;return C(!0),x([]),(async()=>{try{let t=await lt(T);if(e)return;x(t)}catch{}finally{e||C(!1)}})(),()=>{e=!0}},[T,v]),Q.useEffect(()=>{if(!T)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([ze(T),Ve(T)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[T]);let D=Q.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await Be(T,n)?(_(JSON.stringify(e)),!0):(J.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1)}catch{return J.error(t(`settings.yuri.worktrees.setup.toast.saveFailed`)),!1}},[T,t]),O=Q.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);Q.useEffect(()=>{if(!O||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},Ei);return()=>{window.clearTimeout(e)}},[O,m,D,u]);let k=Q.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=Q.useCallback(()=>{d(e=>[...e,``])},[]),M=Q.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=Q.useCallback(()=>{!O||w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},[O,D,u]),P=Q.useCallback(e=>{p(e),T&&Ue(T,e)},[T]),F=Q.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...je.getState().activeSessions,...je.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},l=o(i),u=new Set,d=[...r,...l].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));Me.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=Q.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);Q.useEffect(()=>{v&&o&&E()},[I,v,o,E]);let L=(0,Z.jsxs)(yt,{children:[(0,Z.jsx)(_t,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsxs)(vt,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.yuri.worktrees.setup.tooltipPrefix`),` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.yuri.worktrees.setup.tooltipSuffix`)]})]}),R=(0,Z.jsxs)(yt,{children:[(0,Z.jsx)(_t,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(vt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.yuri.worktrees.list.tooltip`)})]});return o?v===!1?(0,Z.jsx)(Ti,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ti,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.setup.loading`)}):(0,Z.jsxs)(`div`,{className:K(`flex flex-col gap-2`,wi),children:[u.map((e,n)=>(0,Z.jsxs)(`div`,{className:`yuri-settings-group-row flex w-full items-center gap-2`,children:[(0,Z.jsx)(gt,{value:e,onChange:e=>k(n,e.target.value),onBlur:N,placeholder:t(`settings.yuri.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.yuri.worktrees.setup.removeCommandAria`),children:(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Z.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.yuri.worktrees.setup.addCommand`)]}),(0,Z.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Z.jsx)(at,{checked:f,onChange:P,ariaLabel:t(`settings.yuri.worktrees.setup.waitForCommandsAria`)}),(0,Z.jsx)(`span`,{className:K(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.yuri.worktrees.setup.waitForCommands`)})]})]})}),(0,Z.jsx)(Ti,{title:t(`settings.yuri.worktrees.list.title`),titleAccessory:R,children:S?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.list.loading`)}):b.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.yuri.worktrees.list.empty`)}):(0,Z.jsx)(`div`,{className:K(`space-y-1`,wi),children:b.map(e=>(0,Z.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.yuri.worktrees.list.detachedHead`)}),(0,Z.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Z.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:Oe(e.path,l)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:K(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.yuri.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Z.jsx)(Y,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Z.jsx)(Ti,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.worktrees.state.selectProject`)})})},Oi=(e,t)=>t.updatedAtMs-e.updatedAtMs,ki=w((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([Mt(),bt()]),i={};for(let e of r.sort(Oi))i[e.id]=e;t().listenerReady||await Pt(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await Tt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await bt(),n={};for(let e of t.sort(Oi))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await jt({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=Ct(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Rt(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await Et(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await Rt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),Ai=450,ji=()=>S(),Mi=()=>({id:ji(),name:``,command:``,icon:`play`}),Ni=({projectRef:e})=>{let{t}=G(),n=Q.useMemo(()=>m(),[]),r=ki(e=>e.instances),i=ki(e=>e.load),[a,o]=Q.useState([]),[s,c]=Q.useState(!1),[l,u]=Q.useState(null),[d,f]=Q.useState({}),p=Q.useRef(!1),h=Q.useRef(null);Q.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),Q.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await Pe(e);if(t)return;o(n.actions),u(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),u(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let g=Q.useMemo(()=>n?hn(r):[],[r,n]),_=Q.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),v=Q.useMemo(()=>l!==null&&l!==JSON.stringify({actions:a}),[a,l]),y=Q.useCallback(async n=>await Le(e,{actions:n,primaryActionId:null})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(vn,{detail:{projectId:e.id}})),!0):(J.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);Q.useEffect(()=>{if(!v||s||_||p.current)return;let e=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await y(a)}finally{p.current=!1}})())},Ai);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),Q.useEffect(()=>{if(!v||!_||s){_||(h.current=null);return}let e=window.setTimeout(()=>{h.current!==_&&(h.current=_,J.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=Q.useCallback(()=>{let e=Mi();o(t=>[...t,e]),f(t=>({...t,[e.id]:!0}))},[]),x=Q.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),f(t=>{let n={...t};return delete n[e],n})},[]),S=Q.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Z.jsxs)(Ti,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Z.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Z.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Z.jsx)(`div`,{className:K(`space-y-0`,wi),children:a.map(e=>{let r=e.icon||`play`,i=_n[r]||`play`,a=d[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Z.jsxs)(en,{open:a,onOpenChange:t=>{f(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsxs)($t,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Z.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Z.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(Y,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Z.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Z.jsx)(Y,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Z.jsx)(Qt,{className:`pt-1.5`,children:(0,Z.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(Bt,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Z.jsx)(Y,{name:i,className:`h-4 w-4`})})}),(0,Z.jsx)(Ft,{align:`start`,className:`w-56 p-2`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:gn.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:K(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Z.jsx)(Y,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Z.jsx)(gt,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Z.jsx)(Gt,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Z.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":e.autoOpenUrl===!0,onClick:()=>S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:t=>{(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[(0,Z.jsx)(at,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),(0,Z.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Z.jsxs)(`div`,{className:`mt-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(gt,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Z.jsxs)(yt,{children:[(0,Z.jsx)(_t,{asChild:!0,children:(0,Z.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(vt,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),g.length>0?(0,Z.jsxs)(dt,{value:e.desktopOpenSshForward&&g.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Z.jsx)(ct,{className:`h-7 w-full`,children:(0,Z.jsx)(ht,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Z.jsxs)(ut,{children:[(0,Z.jsx)(ot,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Z.jsx)(ot,{value:e.id,children:e.label},e.id))]})]}):(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),_&&a.length>0?(0,Z.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:_}):null]})},Pi=e=>{let t=(0,X.c)(123),{form:n}=e,{t:r}=G(),{currentTheme:i}=Ke(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?ft[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let I;t[4]===r?I=t[5]:(I=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=I);let L;t[6]!==a||t[7]!==F||t[8]!==I?(L=(0,Z.jsx)(gt,{value:a,onChange:F,placeholder:I}),t[6]=a,t[7]=F,t[8]=I,t[9]=L):L=t[9];let R;t[10]!==P||t[11]!==L?(R=(0,Z.jsx)(Sr,{label:P,itemId:`projects.name`,children:L}),t[10]=P,t[11]=L,t[12]=R):R=t[12];let z;t[13]===r?z=t[14]:(z=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=z);let ee;t[15]===r?ee=t[16]:(ee=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=ee);let te;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(te=(0,Z.jsx)(wt,{providerId:p.providerId,modelId:p.modelId,onChange:m,className:`yuri-settings-inline-value`}),t[17]=m,t[18]=p.modelId,t[19]=p.providerId,t[20]=te):te=t[20];let ne;t[21]!==z||t[22]!==ee||t[23]!==te?(ne=(0,Z.jsx)(Sr,{label:z,description:ee,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:te}),t[21]=z,t[22]=ee,t[23]=te,t[24]=ne):ne=t[24];let B;t[25]===r?B=t[26]:(B=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=B);let re;t[27]===u?re=t[28]:(re=()=>u(null),t[27]=u,t[28]=re);let V=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,ie;t[29]===V?ie=t[30]:(ie=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,V),t[29]=V,t[30]=ie);let ae;t[31]===r?ae=t[32]:(ae=r(`settings.projects.page.field.none`),t[31]=r,t[32]=ae);let oe;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=oe):oe=t[33];let se;t[34]!==re||t[35]!==ie||t[36]!==ae?(se=(0,Z.jsx)(`button`,{type:`button`,onClick:re,className:ie,title:ae,children:oe}),t[34]=re,t[35]=ie,t[36]=ae,t[37]=se):se=t[37];let ce;t[38]!==l||t[39]!==u?(ce=mt.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:K(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=ce):ce=t[40];let le;t[41]!==se||t[42]!==ce?(le=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[se,ce]}),t[41]=se,t[42]=ce,t[43]=le):le=t[43];let ue;t[44]!==B||t[45]!==le?(ue=(0,Z.jsx)(Sr,{label:B,itemId:`projects.accent-color`,children:le}),t[44]=B,t[45]=le,t[46]=ue):ue=t[46];let de;t[47]===r?de=t[48]:(de=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=de);let fe;t[49]===O?fe=t[50]:(fe=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=fe);let H;t[51]!==D||t[52]!==fe?(H=(0,Z.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:fe}),t[51]=D,t[52]=fe,t[53]=H):H=t[53];let pe;t[54]===c?pe=t[55]:(pe=()=>c(null),t[54]=c,t[55]=pe);let me=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,he;t[56]===me?he=t[57]:(he=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,me),t[56]=me,t[57]=he);let ge;t[58]===r?ge=t[59]:(ge=r(`settings.projects.page.field.none`),t[58]=r,t[59]=ge);let _e;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(Y,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=_e):_e=t[60];let ve;t[61]!==pe||t[62]!==he||t[63]!==ge?(ve=(0,Z.jsx)(`button`,{type:`button`,onClick:pe,className:he,title:ge,children:_e}),t[61]=pe,t[62]=he,t[63]=ge,t[64]=ve):ve=t[64];let ye;t[65]!==N||t[66]!==s||t[67]!==c?(ye=pt.map(e=>{let t=e.Icon;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Z.jsx)(Y,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=ye):ye=t[68];let U;t[69]!==ve||t[70]!==ye?(U=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[ve,ye]}),t[69]=ve,t[70]=ye,t[71]=U):U=t[71];let be;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(be=w&&E&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Z.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Z.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Z.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Z.jsx)(st,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=be):be=t[82];let W;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(W=w&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Z.jsx)(gt,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Z.jsx)(q,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Z.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=W):W=t[87];let xe;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(xe=!C&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Z.jsx)(q,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=xe):xe=t[94];let Se;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(Se=T&&(0,Z.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=Se):Se=t[99];let Ce;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(Ce=v&&(0,Z.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=Ce):Ce=t[104];let we;t[105]!==xe||t[106]!==Se||t[107]!==Ce?(we=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[xe,Se,Ce]}),t[105]=xe,t[106]=Se,t[107]=Ce,t[108]=we):we=t[108];let Te;t[109]!==H||t[110]!==U||t[111]!==be||t[112]!==W||t[113]!==we?(Te=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[H,U,be,W,we]}),t[109]=H,t[110]=U,t[111]=be,t[112]=W,t[113]=we,t[114]=Te):Te=t[114];let Ee;t[115]!==de||t[116]!==Te?(Ee=(0,Z.jsx)(Sr,{label:de,itemId:`projects.icon`,children:Te}),t[115]=de,t[116]=Te,t[117]=Ee):Ee=t[117];let De;return t[118]!==ue||t[119]!==Ee||t[120]!==R||t[121]!==ne?(De=(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[R,ne,ue,Ee]}),t[118]=ue,t[119]=Ee,t[120]=R,t[121]=ne,t[122]=De):De=t[122],De},Fi=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Ii=e=>{if(!e)return null;let t=e.trim();return t&&Fi.test(t)?t.toLowerCase():null},Li=e=>{let{t}=G(),n=Fe(e=>e.uploadProjectIcon),r=Fe(e=>e.removeProjectIcon),i=Fe(e=>e.discoverProjectIcon),a=Fe(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(null),[m,h]=Q.useState(void 0),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),[w,T]=Q.useState(null),[E,D]=Q.useState(null),[O,k]=Q.useState(!1),A=Q.useRef(null),j=Q.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;Q.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),Q.useEffect(()=>()=>{j()},[j]);let N=Q.useMemo(()=>He(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),I=e?.iconImage?.source===`custom`,L=P&&!S||F,R=L,z=!!(e&&P&&!S),ee=!O&&(F||z),te=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),ne=Q.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),B=Q.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),re=Q.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),V=Q.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){J.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){J.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}J.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),ie=Q.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return J.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return J.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:Ii(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return Q.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:ne,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:I,effectiveHasImageIcon:L,hasRemovableImageIcon:R,showStoredImagePreview:z,showImagePreview:ee,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:B,handleRemoveImageIcon:re,handleDiscoverIcon:V,hasChanges:te,prepareSaveData:ie,currentIconImage:a,project:e}},Ri=450,zi=(e,t)=>{let{t:n}=G(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=Q.useRef(!1);Q.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{J.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},Ri);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},Bi=e=>{let t=(0,X.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=G(),a=Li(n),o;bb0:{if(!n){o=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],o=e}let s=o,c;if(t[3]===r?c=t[4]:(c=async e=>{await r(e)},t[3]=r,t[4]=c),zi(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Z.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Z.jsx)(Pi,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Z.jsx)(Ni,{projectRef:s}),g=(0,Z.jsx)(Di,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function Vi(e,t,n){return Math.min(n,Math.max(t,e))}function Hi(e){if(!Number.isFinite(e))return 0;let t=String(e);if(t.includes(`e-`)){let[,e]=t.split(`e-`);return Number(e)||0}let n=t.split(`.`);return n.length===2?n[1].length:0}function Ui(e,t){let n=Hi(t);return n<=0?e:Number(e.toFixed(n))}var Wi=Q.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=G(),[h,g]=Q.useState(()=>e===void 0?``:String(e)),{isMobile:_}=Ht(),v=Q.useRef(!1),y=Q.useRef(null),b=Q.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);Q.useEffect(()=>()=>{y.current?.()},[]),Q.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let x=Q.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),S=Q.useRef(x);Q.useEffect(()=>{S.current=x},[x]);let C=Q.useCallback(e=>{let a=Ui(Vi(e,n,r),i);S.current=a,t(a)},[r,n,t,i]),w=Q.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&C(n)},[C,u]),T=Q.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=Ui(Vi(a,n,r),i);t===e?S.current=t:C(a),g(String(t))}s?.(t)},[C,h,r,n,s,u,i,e]),E=!!(c||x>=r),D=!!(c||x<=n),O=()=>{D||C(S.current-i)},k=()=>{E||C(S.current+i)},A=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},j=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:K(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:K(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!D&&`active:bg-interactive-hover`),children:(0,Z.jsx)(Y,{name:`subtract`,className:`block h-4 w-4`})}),(0,Z.jsx)(`div`,{"data-slot":`number-input-value`,className:K(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:K(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!E&&`active:bg-interactive-hover`),children:(0,Z.jsx)(Y,{name:`add`,className:`block h-4 w-4`})})]}):(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:K(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:K(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(Y,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Z.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:w,onBlur:T,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:K(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:K(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(Y,{name:`add`,className:`block h-3.5 w-3.5`})})]})});Wi.displayName=`NumberInput`;function Gi(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var Ki={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function qi(e,t){let n=Ki[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Ji(e){return Ki[e]??[]}function Yi(e){return[...e].sort((e,t)=>e.order-t.order)}function Xi(e,t){let n=new Map;for(let r of Object.keys(e)){let e=qi(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function Zi(e,t,n){let r=new Map;for(let i of e){let e=qi(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Qi(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var $i=(e,t=``,n=!1)=>R({queryKey:a.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await l(`/api/quota/magpie`,{signal:t,query:{...e?{directory:e}:{},...n?{refresh:`1`}:{}}});if(!r.ok)throw Error(`Unable to discover Magpie quota sources`);let i=await r.json();if(!i||!Array.isArray(i.sources)||!i.sources.every(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&Array.isArray(e.results)&&e.results.every(t=>o(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),ea=6e4,ta=0,$=0,na,ra=0,ia=0,aa=0,oa=new Map,sa=e=>{let t=yn.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):ea,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||t.includes(e))):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{magpieUsageUrl:typeof e?.magpieUsageUrl==`string`?e.magpieUsageUrl:``,magpieHiddenProviders:Array.isArray(e?.magpieHiddenProviders)?e.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`)):[],autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},ca=async()=>{let e=s()?.settings;if(e)try{let t=(await e.load())?.settings;return sa(t??null)}catch{}if(!b()){let e=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return sa(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:ea,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:yn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},la=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return o(n)&&r.push(n),r},ua=async(e,t)=>{let n=$;oa.set(e,(oa.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await i.fetchQuery({queryKey:a.quota(e),queryFn:({signal:t})=>c(e,t),staleTime:0,retry:!1});if(n!==$)return{providerId:e,stale:!0};if(!o(r))throw Error(`Invalid quota response`);return t(t=>({results:la(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===$?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===$){let n=(oa.get(e)??1)-1;n>0?oa.set(e,n):oa.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},da=()=>{na=void 0,ra+=1,$+=1,ta+=1,oa.clear(),fa.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},fa=w()(E((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:ea,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:yn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=$;try{let n=await ca();if(t!==$)return;e(e=>({...n,dropdownProviderIds:[...n.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...e.results.filter(e=>e.source===`magpie`&&!n.magpieHiddenProviders.includes(e.providerId)).map(e=>e.providerId)]}))}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let n=++ta;e({isLoading:!0,error:null});let r=yn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>ua(t,e))),t().fetchMagpieQuotas(!0)]);if(n===ta){let t=i.find(e=>`error`in e);e({isLoading:!1,...i.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async n=>{if(n.startsWith(`magpie:`))return t().fetchMagpieQuotas(!0);let r=await ua(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=$,a=A.getState().currentDirectory,o=t().magpieUsageUrl,s=JSON.stringify([a,o]);na!==s&&(na=s,ra+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let c=ra,l=++ia;try{let{sources:s,incomplete:u}=await i.fetchQuery($i(a,o,n));if(r!==$||c!==ra||l<aa||a!==A.getState().currentDirectory||o!==t().magpieUsageUrl)return;aa=l,e(e=>{let t=new Map(s.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(u){let n=new Set(s.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...s.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:s,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==$||c!==ra||l<aa||a!==A.getState().currentDirectory||o!==t().magpieUsageUrl)return;aa=l,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),_({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),_({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Qi(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),_({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),pa=()=>{let e=(0,X.c)(11),t=A(ma),n=fa(ha),r=fa(ga),i;e[0]===r?i=e[1]:(i=()=>{r()},e[0]=r,e[1]=i);let a;e[2]!==t||e[3]!==r||e[4]!==n?(a=[t,n,r],e[2]=t,e[3]=r,e[4]=n,e[5]=a):a=e[5],Q.useEffect(i,a);let o=fa(_a),s=fa(va),c=fa(ya),l,u;e[6]!==o||e[7]!==c||e[8]!==s?(l=()=>{if(!o)return;let e=window.setInterval(()=>{c()},s);return()=>window.clearInterval(e)},u=[o,s,c],e[6]=o,e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),Q.useEffect(l,u)};function ma(e){return e.currentDirectory}function ha(e){return e.magpieUsageUrl}function ga(e){return e.fetchMagpieQuotas}function _a(e){return e.autoRefresh}function va(e){return e.refreshIntervalMs}function ya(e){return e.fetchAllQuotas}var ba=e=>{let t=(0,X.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=It(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=xt(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=K(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Z.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Z.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},xa=e=>{let t=(0,X.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=G(),s;t[0]===n.status?s=t[1]:(s=Ot(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=K(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.wait`,{duration:Dt(n.remainingSeconds)})}):(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Z.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=K(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Z.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Z.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:u}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:Dt(n.remainingSeconds)})]}):(0,Z.jsxs)(`span`,{title:f,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Z.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},Sa=e=>e instanceof Error&&e.name===`CancelledError`,Ca=w(()=>({setStatus:e=>St(i,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await i.cancelQueries({queryKey:a.github.auth(r),exact:!0});try{return await At(i,e,r)}catch(e){if(Sa(e))return kt(i,r);throw e}}})),wa={displayMode:`browser`,installed:!1,browserTab:!0},Ta=new Set,Ea=wa,Da=!1,Oa,ka=()=>{let e=Nt();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},Aa=()=>(!Da&&typeof window<`u`&&(Ea=ka(),Da=!0),Ea),ja=()=>{let e=ka();Da=!0,e.displayMode!==Ea.displayMode&&(Ea=e,Ta.forEach(e=>e()))},Ma=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,ja):typeof t.addListener==`function`&&t.addListener(ja);return window.addEventListener(`appinstalled`,ja),window.addEventListener(`focus`,ja),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,ja):typeof t.removeListener==`function`&&t.removeListener(ja);window.removeEventListener(`appinstalled`,ja),window.removeEventListener(`focus`,ja)}},Na=e=>(Ta.add(e),Oa??=Ma(),ja(),()=>{Ta.delete(e),Ta.size===0&&(Oa?.(),Oa=void 0)}),Pa=()=>Q.useSyncExternalStore(Na,Aa,Fa);function Fa(){return wa}var Ia=`Yuri`,La=w()(T(e=>({sidebarBrandName:Ia,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:p(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=Ia),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=Ia),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=Ia),n}}));typeof window<`u`&&t(e=>{r(e)&&La.persist.rehydrate()});var Ra=(e,t)=>e?t.kind===e.kind?t.projectRoot.length===e.projectRoot.length?t.projectId.localeCompare(e.projectId)<0:t.projectRoot.length>e.projectRoot.length:t.kind===`project`:!0,za=(e,t,n)=>{Ra(e.get(t),n)&&e.set(t,n)},Ba=e=>{let t=e;return h(t.directory)??h(t.project?.worktree)},Va=e=>{if(e===`/`||/^[A-Z]:$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:t===0?`/`:t===2&&/^[A-Z]:\//.test(e)?e.slice(0,2):e.slice(0,t)},Ha=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=h(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),za(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=h(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=h(e.path);t&&za(a,t,{projectId:r.id,projectRoot:n,scopeDirectory:t,kind:`worktree`})}}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=e=>{if(!e)return null;if(s.has(e))return s.get(e)??null;if(r){let t=a.get(e)??null;return s.set(e,t),t}let t=[],n=e,i=null;for(;n;){if(s.has(n)){i=s.get(n)??null;break}if(t.push(n),i=a.get(n)??null,i)break;n=Va(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(Ba(r));if(!e)continue;c.set(r.id,e);let i=t.get(e.projectId);if(i?i.push(r):t.set(e.projectId,[r]),!n)continue;let a=n.get(e.scopeDirectory);a?a.add(r.id):n.set(e.scopeDirectory,new Set([r.id]))}};return p(e,l,d),p(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}},Ua=`__other__`;function Wa(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Ga({mode:e=`dialog`}){let{t}=G(),{isMobile:n,isTablet:r,hasTouchInput:i}=Ht(),a=n||r||i,o=e===`page`,s=I(e=>e.isArchivedSessionsDialogOpen),c=I(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=Fe(e=>e.projects),d=je(e=>e.archivedSessions),f=Ne(e=>e.setCurrentSession),p=I(e=>e.setSettingsDialogOpen),[m,h]=Q.useState(!1),[g,_]=Q.useState(null),[v,y]=Q.useState(null);Q.useEffect(()=>{if(!l){_(null),y(null);return}let e=!1;return h(!0),Ge().catch(()=>{e||J.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[l,t]);let x=Q.useMemo(()=>{let e=Ha([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,b(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>Wa(t)-Wa(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=d.filter(e=>!r.has(e.id)).sort((e,t)=>Wa(t)-Wa(e));i.length>0&&n.set(Ua,i);let a=[];for(let e of u){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let o=n.get(Ua);return o&&o.length>0&&a.push({projectId:Ua,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:o}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[d,u,t]),S=d.length,C=g?x.find(e=>e.projectId===g)??null:null,w=Q.useCallback(async e=>{y(e.id);try{await Ie(e.id)?J.success(t(`settings.yuri.archivedSessions.toast.restored`)):J.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{y(null)}},[t]),T=Q.useCallback(e=>{let t=Re(e);f(e.id,t),c(!1),p(!1)},[f,c,p]),E=C?C.label:t(`settings.yuri.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),O=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[C?(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>_(null),children:[(0,Z.jsx)(Y,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,m?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Z.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.emptyProject`)}):(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:C.sessions.map(e=>{let n=Re(e),r=Wa(e),i=v===e.id;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Z.jsxs)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:[r>0?Vt(r):null,r>0&&n?` · `:null,n?Oe(n):null]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Z.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Z.jsxs)(q,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Z.jsx)(Y,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(Y,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.empty`)}):(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>_(e.projectId),className:K(`flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Z.jsx)(Y,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Z.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:Oe(e.path)}):null]}),(0,Z.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Z.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!m&&S>0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:S})}):null]});return o?(0,Z.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),O]}):a?(0,Z.jsx)(Lt,{open:s,title:E,onClose:()=>c(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Z.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:O}):(0,Z.jsx)(Ze,{open:s,onOpenChange:c,children:(0,Z.jsxs)(Je,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Z.jsxs)(qe,{children:[(0,Z.jsx)(Ye,{children:E}),(0,Z.jsx)(Xe,{children:D})]}),O]})})}function Ka(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Ga,{mode:`dialog`}),e[0]=t):t=e[0],t}var qa=48;function Ja({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=De(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/qa)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--yuri-mobile-title-collapse`,r.toFixed(4)))}),u=De(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,Q.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.yuri-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`header`,{ref:i,className:K(`yuri-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Z.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-inner`,children:[(0,Z.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Z.jsx)(`p`,{className:`yuri-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Z.jsx)(`h1`,{className:`yuri-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Z.jsx)(`div`,{className:`yuri-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Z.jsx)(`div`,{className:`yuri-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{kr as A,On as B,xi as C,ti as D,li as E,yr as F,yn as H,sr as I,Mn as L,xr as M,Cr as N,Er as O,wr as P,Pn as R,Si as S,ci as T,bn as U,xn as V,Yi as _,La as a,ki as b,xa as c,pa as d,fa as f,Zi as g,Xi as h,Ha as i,Sr as j,Or as k,ba as l,Gi as m,Ka as n,Pa as o,Ji as p,Ga as r,Ca as s,Ja as t,da as u,Wi as v,ui as w,Ci as x,Bi as y,Nn as z};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/gitApi-DOLBq3YG.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-switch-CAZiOV2G.js","assets/runtime-auth-ef9W7A43.js","assets/queryRuntime-DKGLQtb9.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-7bX6qtBV.js","assets/persistence-Dzooc9Xg.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-base-ui-CdzJ6My_.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-NMQx_cnG.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/runtime-file-resource-C1k5nbWb.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/useMobileNavigationStore-CyTqHrGP.js","assets/vendor-sonner-ZS8XIOVl.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-BBAlbKlC.js","assets/store-BYkfys9K.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useAssistantUIStore-D7JZlg_Q.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t}from"./queryRuntime-DKGLQtb9.js";import{Rt as n,Zt as r,r as i,t as a,tn as o}from"./persistence-Dzooc9Xg.js";import{it as s,rt as c}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as l,Nt as u}from"./platform-7bX6qtBV.js";import{n as d}from"./useUIStore-NMQx_cnG.js";import{n as f,t as p}from"./vendor-react-BP2cRVqX.js";import{A as m}from"./runtime-file-resource-C1k5nbWb.js";import{o as h}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";/* empty css */import{n as g,s as _}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as v,h as y,r as b,t as x}from"./button-BBAlbKlC.js";import{n as ee}from"./store-BYkfys9K.js";import{Aa as te,Mt as ne,S as re,cn as ie,d as S,fo as ae,tn as oe,vn as se,wa as C}from"./useMobileNavigationStore-CyTqHrGP.js";import{n as ce}from"./Icon-Cu3waV3-.js";import{At as le,C as ue,Ct as de,Dt as w,Et as fe,Mt as T,Nt as pe,Ot as me,Rt as he,S as E,St as ge,Tt as _e,a as ve,jt as D,kt as O,t as ye,ut as be,w as xe,wt as Se}from"./useAppFontEffects-DkwXqB_-.js";import{s as Ce}from"./projectMeta-8wYzdBk7.js";import{r as we}from"./tooltip-yKi3siRK.js";import{Ct as Te,ft as k,gt as Ee}from"./speechSettingsQueries-Bz_O_kOx.js";import{d as De,y as Oe}from"./insertionBoundaries-D3WwSv5D.js";import{i as ke,n as Ae,r as je,t as Me}from"./useDesktopWindowControlsLayout-B8GLew3c.js";var Ne=p(),A=f(),j=e(s(),1),M=c(),Pe=e=>{let t=(0,A.c)(3),{mode:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,M.jsx)(be.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i},Fe=e=>{let t=typeof e==`string`?e.trim():``;if(!t)return``;let n=typeof window<`u`?window.__YURI_HOME__:``;if(n&&t===n)return`~`;if(n&&t.startsWith(`${n}/`))return`~/${t.slice(n.length+1)}`;let r=t.split(`/`).filter(Boolean);return r.length<=3?t:`.../${r.slice(-3).join(`/`)}`},N=e=>{let t=typeof e==`string`?e.trim():``;if(!t)return``;let n=t.replace(/\\/g,`/`);return n===`/`?`/`:n.replace(/\/+$/,``)},P=e=>{let t=(0,A.c)(117),{mode:n}=e,{t:i}=v(),a=S(Le),s=S(Re),c=S(ze),u=l(Be),d=ae(Ve),f=ae(He),p=C(Ue),h=C(We),g=se(),_=ie(a??``),y=m(),ee=Oe(Ge),te;t[0]===a?te=t[1]:(te=e=>a?e.worktreeMetadata.get(a)?.path??``:``,t[0]=a,t[1]=te);let ne=S(te),le;t[2]===a?le=t[3]:(le=e=>a?e.worktreeMetadata.get(a)?.branch?.trim()??null:null,t[2]=a,t[3]=le);let ue=S(le),de;t[4]===a?de=t[5]:(de=e=>a?e.getAttachment(a):void 0,t[4]=a,t[5]=de);let w=re(de),fe=S(Ke),[T,pe]=j.useState(!1),me=typeof window<`u`?window.__YURI_MACOS_MAJOR__??0:0,he=Number.isFinite(me)&&me>0,{usesFramelessChrome:E,side:ge}=Me(),_e=he?me>=26?`h-12`:me<=15?`h-14`:``:``,ve;t[6]!==a||t[7]!==g?(ve=a?g.find(e=>e.id===a)??null:null,t[6]=a,t[7]=g,t[8]=ve):ve=t[8];let D=ve,O=D?.worktreeMetadata??null,ye,be;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>{o()&&r(`desktop_get_window_pinned`).then(e=>{typeof e?.pinned==`boolean`&&pe(e.pinned)})},be=[],t[9]=ye,t[10]=be):(ye=t[9],be=t[10]),j.useEffect(ye,be);let xe;t[11]!==s||t[12]!==n||t[13]!==D?.title||t[14]!==i?(xe=D?.title?.trim()||i(s||n===`draft`?`miniChat.header.newSession`:`miniChat.header.session`),t[11]=s,t[12]=n,t[13]=D?.title,t[14]=i,t[15]=xe):xe=t[15];let Se=xe,Ce=D?.directory??null,we;t[16]===Ce?we=t[17]:(we=N(Ce),t[16]=Ce,t[17]=we);let Te=we,k=ne||O?.path||w?.cwd||w?.worktreeRoot||``,Ee;t[18]===k?Ee=t[19]:(Ee=N(k),t[18]=k,t[19]=Ee);let Ne=Ee,Pe;t[20]===u?Pe=t[21]:(Pe=N(u),t[20]=u,t[21]=Pe);let P=Ne||Te||fe||Pe,Ie;t[22]===P?Ie=t[23]:(Ie=Fe(P),t[22]=P,t[23]=Ie);let $e=Ie,et;t[24]!==Te||t[25]!==Ne?(et=e=>{let t=N(Ne||Te||``);if(!t)return null;for(let n of e.availableWorktreesByProject.values()){let e=n.find(e=>N(e.path)===t)?.branch?.trim();if(e)return e}return null},t[24]=Te,t[25]=Ne,t[26]=et):et=t[26];let tt=S(et),nt,rt;t[27]!==ee||t[28]!==P||t[29]!==y.git?(nt=()=>{P&&ee(P,y.git).catch(qe)},rt=[ee,P,y.git],t[27]=ee,t[28]=P,t[29]=y.git,t[30]=nt,t[31]=rt):(nt=t[30],rt=t[31]),j.useEffect(nt,rt),O?.projectDirectory,w?.worktreeRoot;let it;bb0:{let e=O?.projectDirectory??w?.worktreeRoot??null,n;t[32]===e?n=t[33]:(n=N(e),t[32]=e,t[33]=n);let r=n||P;if(!r){it=null;break bb0}let i;t[34]!==r||t[35]!==d?(i=d.map(Je).filter(e=>e.normalizedPath&&(e.normalizedPath===r||r.startsWith(`${e.normalizedPath}/`))).sort(Ye)[0]??null,t[34]=r,t[35]=d,t[36]=i):i=t[36],it=i}let at=it,ot;bb1:{let e=at??f;if(!e){ot=$e||`Yuri`;break bb1}let n;t[37]===e.path?n=t[38]:(n=e.path.split(/[\\/]/).filter(Boolean).at(-1)??e.path,t[37]=e.path,t[38]=n),ot=n}let st=ot,ct=De(P||null),lt;t[39]!==tt||t[40]!==ct||t[41]!==O?.branch||t[42]!==w?.branch||t[43]!==ue?(lt=ct||ue||O?.branch?.trim()||w?.branch?.trim()||tt,t[39]=tt,t[40]=ct,t[41]=O?.branch,t[42]=w?.branch,t[43]=ue,t[44]=lt):lt=t[44];let ut=lt,dt=ut&&ut!==`HEAD`?ut:null,ft;t[45]===p?ft=t[46]:(ft=p(),t[45]=p,t[46]=ft);let pt=ft,mt;bb2:{for(let e=_.length-1;e>=0;--e){let t=_[e];if(t.role!==`assistant`||typeof t.providerID!=`string`||typeof t.modelID!=`string`)continue;let n=h.find(e=>e.id===t.providerID)?.models.find(e=>e.id===t.modelID);if(n){mt=n;break bb2}}mt=void 0}let ht=mt,gt=pt?.limit?pt:ht,F=gt&&typeof gt.limit==`object`&&gt.limit!==null?gt.limit:null,_t=F&&typeof F.context==`number`?F.context:0,vt=F&&typeof F.output==`number`?F.output:0,I=oe(a??``,_t,vt),[L,yt]=j.useState(null),bt;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(bt={WebkitAppRegion:`drag`},t[47]=bt):bt=t[47];let xt=bt,St;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(St={WebkitAppRegion:`no-drag`},t[48]=St):St=t[48];let Ct=St,wt,Tt;t[49]!==I||t[50]!==a?(wt=()=>{if(!a){yt(Xe);return}if(I){yt(e=>e&&e.pending===I.pending&&e.totalTokens===I.totalTokens&&e.percentage===I.percentage&&e.contextLimit===I.contextLimit&&(e.outputLimit??0)===(I.outputLimit??0)&&(e.normalizedOutput??0)===(I.normalizedOutput??0)&&e.thresholdLimit===I.thresholdLimit&&e.lastMessageId===I.lastMessageId?e:I);return}yt(Ze)},Tt=[I,a],t[49]=I,t[50]=a,t[51]=wt,t[52]=Tt):(wt=t[51],Tt=t[52]),j.useEffect(wt,Tt);let Et=L&&L.contextLimit>0?Math.min(999,L.totalTokens/L.contextLimit*100):0,Dt;t[53]===T?Dt=t[54]:(Dt=()=>{let e=!T;pe(e),r(`desktop_set_window_pinned`,{pinned:e}).catch(()=>{pe(!e)})},t[53]=T,t[54]=Dt);let Ot=Dt,kt;t[55]!==u||t[56]!==a||t[57]!==c||t[58]!==P||t[59]!==D?(kt=()=>{let e=a?{sessionId:a,directory:D?.directory??u??``}:{mode:`draft`,directory:P||u||``,projectId:c};r(`desktop_focus_main_window`,e).then(Qe)},t[55]=u,t[56]=a,t[57]=c,t[58]=P,t[59]=D,t[60]=kt):kt=t[60];let At=kt,jt=E?`h-12`:_e||`min-h-14`,R;t[61]===jt?R=t[62]:(R=b(`flex items-center gap-3 bg-background pr-3`,he?`pl-[5.5rem]`:`pl-3`,jt),t[61]=jt,t[62]=R);let z;t[63]!==E||t[64]!==ge?(z=E&&ge===`left`?(0,M.jsx)(je,{visible:!0,position:`left`}):null,t[63]=E,t[64]=ge,t[65]=z):z=t[65];let B;t[66]===i?B=t[67]:(B=i(`sessions.switcher.openAria`),t[66]=i,t[67]=B);let V;t[68]===Se?V=t[69]:(V=(0,M.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full`,children:Se}),t[68]=Se,t[69]=V);let H;t[70]===st?H=t[71]:(H=(0,M.jsx)(`span`,{className:`truncate`,children:st}),t[70]=st,t[71]=H);let U;t[72]===dt?U=t[73]:(U=dt?(0,M.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,M.jsx)(ce,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,M.jsx)(`span`,{className:`truncate`,children:dt})]}):null,t[72]=dt,t[73]=U);let W;t[74]!==H||t[75]!==U?(W=(0,M.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75`,children:[H,U]}),t[74]=H,t[75]=U,t[76]=W):W=t[76];let G;t[77]!==B||t[78]!==V||t[79]!==W?(G=(0,M.jsx)(Ae,{children:(0,M.jsxs)(`button`,{type:`button`,"aria-label":B,style:Ct,className:`flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60`,children:[V,W]})}),t[77]=B,t[78]=V,t[79]=W,t[80]=G):G=t[80];let Mt;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=(0,M.jsx)(`div`,{className:`min-w-0 flex-1`}),t[81]=Mt):Mt=t[81];let K;t[82]!==Et||t[83]!==L?(K=L?(0,M.jsx)(ke,{pending:L.pending,totalTokens:L.totalTokens,percentage:Et,colorPercentage:L.percentage,contextLimit:L.contextLimit,outputLimit:L.outputLimit??0,className:`h-9 shrink-0 pl-1 pr-1 typography-ui-label`,valueClassName:`font-semibold leading-none`,hideIcon:!0,showPercentIcon:!0,percentIconClassName:`h-4.5 w-4.5`}):null,t[82]=Et,t[83]=L,t[84]=K):K=t[84];let q;t[85]!==T||t[86]!==i?(q=i(T?`miniChat.actions.unpinAria`:`miniChat.actions.pinAria`),t[85]=T,t[86]=i,t[87]=q):q=t[87];let J;t[88]!==T||t[89]!==i?(J=i(T?`miniChat.actions.unpin`:`miniChat.actions.pin`),t[88]=T,t[89]=i,t[90]=J):J=t[90];let Y;t[91]===T?Y=t[92]:(Y=T?(0,M.jsx)(ce,{name:`pushpin-2-fill`,className:`h-4 w-4`}):(0,M.jsx)(ce,{name:`pushpin-2`,className:`h-4 w-4`}),t[91]=T,t[92]=Y);let X;t[93]!==Ot||t[94]!==q||t[95]!==J||t[96]!==Y?(X=(0,M.jsx)(x,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ot,"aria-label":q,title:J,style:Ct,children:Y}),t[93]=Ot,t[94]=q,t[95]=J,t[96]=Y,t[97]=X):X=t[97];let Z;t[98]===i?Z=t[99]:(Z=i(`miniChat.actions.openMainAria`),t[98]=i,t[99]=Z);let Q;t[100]===i?Q=t[101]:(Q=i(`miniChat.actions.openMain`),t[100]=i,t[101]=Q);let Nt;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(Nt=(0,M.jsx)(ce,{name:`external-link`,className:`h-4 w-4`}),t[102]=Nt):Nt=t[102];let Pt;t[103]!==At||t[104]!==Z||t[105]!==Q?(Pt=(0,M.jsx)(x,{type:`button`,variant:`ghost`,size:`icon`,onClick:At,"aria-label":Z,title:Q,style:Ct,children:Nt}),t[103]=At,t[104]=Z,t[105]=Q,t[106]=Pt):Pt=t[106];let Ft=E&&ge===`right`,$;t[107]===Ft?$=t[108]:($=(0,M.jsx)(je,{visible:Ft,position:`right`}),t[107]=Ft,t[108]=$);let It;return t[109]!==R||t[110]!==z||t[111]!==G||t[112]!==K||t[113]!==X||t[114]!==Pt||t[115]!==$?(It=(0,M.jsxs)(`header`,{className:R,style:xt,children:[z,G,Mt,K,X,Pt,$]}),t[109]=R,t[110]=z,t[111]=G,t[112]=K,t[113]=X,t[114]=Pt,t[115]=$,t[116]=It):It=t[116],It},Ie=e=>{let t=(0,A.c)(9),{mode:n,autoOpenDraft:r,unavailable:i}=e,a=r!==void 0&&r,o=i!==void 0&&i,{t:s}=v(),c;t[0]===n?c=t[1]:(c=(0,M.jsx)(P,{mode:n}),t[0]=n,t[1]=c);let l;t[2]!==a||t[3]!==s||t[4]!==o?(l=(0,M.jsx)(`main`,{className:`min-h-0 flex-1`,children:o?(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground`,children:(0,M.jsxs)(`div`,{className:`max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`font-medium text-foreground`,children:s(`miniChat.unavailable.title`)}),(0,M.jsx)(`div`,{className:`mt-1 typography-small text-muted-foreground`,children:s(`miniChat.unavailable.description`)})]})}):(0,M.jsx)(Pe,{mode:`mini-chat`,children:(0,M.jsx)(xe,{autoOpenDraft:a})})}),t[2]=a,t[3]=s,t[4]=o,t[5]=l):l=t[5];let u;return t[6]!==c||t[7]!==l?(u=(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8],u};function Le(e){return e.currentSessionId}function Re(e){return!!e.newSessionDraft?.open}function ze(e){return e.newSessionDraft?.selectedProjectId??null}function Be(e){return e.currentDirectory}function Ve(e){return e.projects}function He(e){return e.getActiveProject()}function Ue(e){return e.getCurrentModel}function We(e){return e.providers}function Ge(e){return e.ensureStatus}function Ke(e){return e.newSessionDraft?.open?N(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``}function qe(){}function Je(e){return{...e,normalizedPath:N(e.path)}}function Ye(e,t){return t.path.length-e.path.length}function Xe(e){return e===null?e:null}function Ze(e){return e===null?e:null}function Qe(e){return e?.focused===!0?r(`desktop_close_current_window`):null}var $e=()=>{document.querySelector(`textarea[data-chat-input="true"]`)?.focus()},et=()=>{let e=d(e=>e.shortcutOverrides),t=l(e=>e.currentDirectory),i=ae(e=>e.getActiveProject()),a=S(e=>e.openNewSessionDraft);j.useEffect(()=>{let o=t=>Ee(t,e),s=e=>{if(k(e,o(`focus_input`))){e.preventDefault(),$e();return}if(n()&&k(e,o(`close_context_panel_tab`))){e.preventDefault(),r(`desktop_close_current_window`).catch(e=>{console.warn(`[mini-chat-shortcuts] failed to close current window`,e)});return}if(n()&&k(e,o(`new_mini_chat`))){e.preventDefault(),r(`desktop_open_draft_mini_chat_window`,{directory:t||i?.path||``,projectId:i?.id??null})?.catch(e=>{console.warn(`[mini-chat-shortcuts] failed to open draft mini chat window`,e)});return}if(k(e,o(`new_chat`))){e.preventDefault(),a({selectedProjectId:i?.id??null,directoryOverride:t||i?.path||null,preserveDirectoryOverride:!!(t||i?.path)}),$e();return}if(k(e,o(`open_model_selector`))){e.preventDefault();let{isModelSelectorOpen:t,setModelSelectorOpen:n}=d.getState();n(!t,{instant:!0});return}if(k(e,o(`cycle_thinking_variant`))){let t=C.getState();if(t.getCurrentModelVariants().length===0)return;e.preventDefault(),t.cycleCurrentVariant();let n=C.getState().currentVariant,r=S.getState().currentSessionId,i=C.getState().currentAgentName,a=C.getState().currentProviderId,o=C.getState().currentModelId;r&&i&&a&&o&&te.getState().saveAgentModelVariantForSession(r,i,a,o,n),i&&a&&o&&C.getState().saveAgentModelSelection(i,a,o,n);return}let s=k(e,o(`cycle_favorite_model_forward`)),c=k(e,o(`cycle_favorite_model_backward`));if(s||c){let{favoriteModels:t,addRecentModel:n}=d.getState();if(t.length===0)return;e.preventDefault();let{currentProviderId:r,currentModelId:i,providers:a,setProvider:o,setModel:c,setCurrentVariant:l}=C.getState(),u=t[(t.findIndex(e=>e.providerID===r&&e.modelID===i)+(s?1:-1)+t.length)%t.length];o(u.providerID),c(u.modelID);let f=a.find(e=>e.id===u.providerID)?.models?.find(e=>e.id===u.modelID),p=f?.variants?Object.keys(f.variants):[],m=u.variant!==void 0&&p.includes(u.variant)?u.variant:void 0;l(m),n(u.providerID,u.modelID,m)}};return window.addEventListener(`keydown`,s),()=>window.removeEventListener(`keydown`,s)},[i?.id,i?.path,t,a,e])},tt=`yuri:mini-chat-presence`,nt=()=>{let e=typeof window<`u`?new URLSearchParams(window.location.search):new URLSearchParams;return{mode:e.get(`mode`)===`session`?`session`:`draft`,sessionId:e.get(`sessionId`)?.trim()||null,directory:e.get(`directory`)?.trim()||null,projectId:e.get(`projectId`)?.trim()||null}},rt=({config:e})=>{let t=se(),n=l(e=>e.currentDirectory),r=l(e=>e.setDirectory),i=ae(e=>e.projects),a=S(e=>e.currentSessionId),o=S(e=>!!e.newSessionDraft?.open),s=S(e=>e.newSessionDraft?.open?e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``:``),c=S(e=>e.setCurrentSession),u=S(e=>e.openNewSessionDraft),d=C(e=>e.initializeApp),f=C(e=>e.isInitialized),p=ge();j.useEffect(()=>{d()},[d]),j.useEffect(()=>{if(f)return;let e=!0,t=0,n=window.setInterval(()=>{if(e){if(t+=1,t>10){window.clearInterval(n);return}C.getState().isInitialized||C.getState().initializeApp()}},1e3);return()=>{e=!1,window.clearInterval(n)}},[f]);let m=j.useRef(!1);j.useEffect(()=>{if(!m.current&&e.mode===`session`&&e.directory){if(n===e.directory){m.current=!0;return}r(e.directory,{showOverlay:!1}),m.current=!0}},[e.directory,e.mode,n,r]),j.useEffect(()=>{e.mode!==`draft`||!o||a||!s||n===s||r(s,{showOverlay:!1})},[e.mode,n,a,s,o,r]),_e({enabled:!0,source:`electronMiniChat:recovery`});let v=j.useRef(!1);j.useEffect(()=>{if(v.current||e.mode!==`session`||!e.sessionId)return;if(a===e.sessionId){v.current=!0;return}if(a){v.current=!0;return}let n=t.find(t=>t.id===e.sessionId);if(!n){p.ensureSessionRenderable(e.sessionId);return}let r=n.directory??e.directory;c(e.sessionId,r),v.current=!0},[e,a,t,c,p]);let y=_(t),b=g(e=>{let t=e.detail,n=typeof t?.sessionId==`string`?t.sessionId.trim():``;if(!n||S.getState().currentSessionId===n)return;let r=typeof t?.directory==`string`&&t.directory.trim().length>0?t.directory.trim():y.current.find(e=>e.id===n)?.directory??null;p.ensureSessionRenderable(n),c(n,r),v.current=!0});j.useEffect(()=>(window.addEventListener(`yuri:open-session`,b),()=>window.removeEventListener(`yuri:open-session`,b)),[b]),j.useEffect(()=>{e.mode!==`draft`||o||a||u({selectedProjectId:e.projectId,directoryOverride:e.directory,preserveDirectoryOverride:!!e.directory})},[e,a,o,u]),j.useEffect(()=>{if(i.length===0)return;let e=!1;return(async()=>{await Promise.all(i.map(async t=>{let n=t.path.replace(/\\/g,`/`).replace(/\/+$/,``);if(n)try{if(!(Oe.getState().directories.get(n)?.isGitRepo??await h(()=>import(`./gitApi-DOLBq3YG.js`).then(e=>e.S).then(e=>e.checkIsGitRepository(n)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])))||e)return;await Ce({id:t.id,path:n},{isCurrent:()=>!e})}catch{}}))})(),()=>{e=!0}},[i]);let x=j.useRef(!1);return j.useEffect(()=>{if(x.current||!f)return;let t=()=>{if(x.current)return;x.current=!0;let e=typeof document<`u`?document.getElementById(`initial-loading`):null;e&&(e.classList.add(`fade-out`),window.setTimeout(()=>e.remove(),300))},n=e.mode===`session`?a===e.sessionId:o,r=window.setTimeout(t,n?100:1500);return()=>window.clearTimeout(r)},[f,e.mode,e.sessionId,a,o]),null},it=()=>{let e=(0,A.c)(4),t=S(ft),n=l(pt),r,i;return e[0]!==n||e[1]!==t?(r=()=>{if(!t||!n||typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(tt),r=r=>{e.postMessage({type:`mini-chat-session-presence`,sessionId:t,directory:n,viewed:r})};r(!0);let i=window.setInterval(()=>r(!0),5e3),a=()=>r(!1);return window.addEventListener(`beforeunload`,a),()=>{window.clearInterval(i),window.removeEventListener(`beforeunload`,a),r(!1),e.close()}},i=[n,t],e[0]=n,e[1]=t,e[2]=r,e[3]=i):(r=e[2],i=e[3]),j.useEffect(r,i),null},at=e=>{let t=(0,A.c)(6),n=se(),r=S(mt),[i,a]=j.useState(!1),o,s;return t[0]!==e.mode||t[1]!==e.sessionId||t[2]!==r||t[3]!==n?(o=()=>{if(e.mode!==`session`||!e.sessionId||r===e.sessionId){a(!1);return}if(n.some(t=>t.id===e.sessionId)){a(!1);return}let t=window.setTimeout(()=>a(!0),5e3);return()=>window.clearTimeout(t)},s=[e.mode,e.sessionId,r,n],t[0]=e.mode,t[1]=e.sessionId,t[2]=r,t[3]=n,t[4]=o,t[5]=s):(o=t[4],s=t[5]),j.useEffect(o,s),i};function ot(e){let n=(0,A.c)(16),{apis:r}=e,i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=nt(),n[0]=i):i=n[0];let a=i,o=l(ut),s=S(lt),c=S(ct),d,f;n[1]===o?(d=n[2],f=n[3]):(d=()=>{u.setDirectory(o||a.directory||void 0)},f=[a.directory,o],n[1]=o,n[2]=d,n[3]=f),j.useEffect(d,f);let p,m;n[4]===r?(p=n[5],m=n[6]):(p=()=>(t(r),st),m=[r],n[4]=r,n[5]=p,n[6]=m),j.useEffect(p,m),ye(),et();let h;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(h={enabled:!0},n[7]=h):h=n[7],ue(h),E();let g;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=u.getSdkClient(),n[8]=g):g=n[8];let _=o||a.directory||``,v=!(c&&s===null),y;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,M.jsx)(we,{delayDuration:300,skipDelayDuration:150,children:(0,M.jsxs)(`div`,{className:`h-full text-foreground bg-background`,children:[(0,M.jsx)(dt,{config:a}),(0,M.jsx)(de,{})]})}),n[9]=y):y=n[9];let b;n[10]===r?b=n[11]:(b=(0,M.jsx)(Se,{apis:r,children:y}),n[10]=r,n[11]=b);let x;return n[12]!==b||n[13]!==_||n[14]!==v?(x=(0,M.jsx)(Te,{children:(0,M.jsx)(ne,{sdk:g,directory:_,bootstrapDirectory:v,children:b})}),n[12]=b,n[13]=_,n[14]=v,n[15]=x):x=n[15],x}function st(){return t(null)}function ct(e){return!!e.newSessionDraft?.open}function lt(e){return e.currentSessionId}function ut(e){return e.currentDirectory}var dt=e=>{let t=(0,A.c)(11),{config:n}=e,r=at(n),i;t[0]===n?i=t[1]:(i=(0,M.jsx)(rt,{config:n}),t[0]=n,t[1]=i);let a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,M.jsx)(it,{}),o=(0,M.jsx)(ve,{embeddedBackgroundWorkEnabled:!0}),t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=n.mode===`draft`,c;t[4]!==n.mode||t[5]!==r||t[6]!==s?(c=(0,M.jsx)(Ie,{mode:n.mode,autoOpenDraft:s,unavailable:r}),t[4]=n.mode,t[5]=r,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==i||t[9]!==c?(l=(0,M.jsxs)(M.Fragment,{children:[i,a,o,c]}),t[8]=i,t[9]=c,t[10]=l):l=t[10],l};function ft(e){return e.currentSessionId}function pt(e){return e.currentDirectory}function mt(e){return e.currentSessionId}var ht=()=>{ee(),a().then(()=>{Promise.all([i(),he()]).catch(e=>{console.error(`[mini-chat-main] settings init failed:`,e)}),O(),me(),w()}).catch(e=>{console.error(`[mini-chat-main] appearance init failed:`,e)})};function gt(e){ht();let t=document.getElementById(`root`);if(!t)throw Error(`Root element not found`);(0,Ne.createRoot)(t).render((0,M.jsx)(j.StrictMode,{children:(0,M.jsx)(fe,{children:(0,M.jsx)(y,{children:(0,M.jsx)(le,{children:(0,M.jsx)(D,{children:(0,M.jsx)(T,{children:(0,M.jsx)(pe,{children:(0,M.jsx)(ot,{apis:e})})})})})})})}))}export{gt as renderElectronMiniChatApp};