@puddle-code/cli 0.2.18 → 0.2.21

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 (140) hide show
  1. package/CHANGELOG.md +4 -16
  2. package/dist/host-control.mjs +59 -0
  3. package/dist/index.js +66 -3
  4. package/dist/public/assets/App-NrJUEV9p.js +2 -0
  5. package/dist/public/assets/{Dashboard-DdqyCWkG.js → Dashboard-BhAek_r4.js} +1 -1
  6. package/dist/public/assets/{EditorTabClose-BYTH6g2Z.js → EditorTabClose-CSKAGWsA.js} +1 -1
  7. package/dist/public/assets/{FindWidget-B4wnVQS_.js → FindWidget-B6dVpkKr.js} +1 -1
  8. package/dist/public/assets/LazyTerminal-fxF4IO4o.js +2 -0
  9. package/dist/public/assets/{ModelRefcount-DHis9DXZ.js → ModelRefcount-CrpDNwTn.js} +1 -1
  10. package/dist/public/assets/{NewProjectDialog-B4ySxxDz.js → NewProjectDialog-D-hVQlA4.js} +1 -1
  11. package/dist/public/assets/{PaneEditorBody-tjlNFM2W.js → PaneEditorBody--h9jLt1e.js} +3 -3
  12. package/dist/public/assets/{PdfViewer-Bqvxu-es.js → PdfViewer-CNzO040W.js} +2 -2
  13. package/dist/public/assets/SettingsDialog-DaxYdggs.js +8 -0
  14. package/dist/public/assets/{Terminal-B297I2Hn.js → Terminal-DQL8GETy.js} +5 -5
  15. package/dist/public/assets/{Workspace-BO11vRQa.js → Workspace-BDDSmIKE.js} +5 -5
  16. package/dist/public/assets/{abnfDiagram-VCTEODGH-BgqZK9hy.js → abnfDiagram-VCTEODGH-Dj6CI3Nv.js} +1 -1
  17. package/dist/public/assets/architecture-7GRP2DOG-CDcS1iVd.js +1 -0
  18. package/dist/public/assets/{architectureDiagram-5GKGNRK7-Dic5TzsL.js → architectureDiagram-5GKGNRK7-7n7HJQxV.js} +1 -1
  19. package/dist/public/assets/{blockDiagram-I7D4REHJ-DVS-B-eY.js → blockDiagram-I7D4REHJ-Cmsxv8OS.js} +1 -1
  20. package/dist/public/assets/{buffer-store-CXH0xBDj.js → buffer-store-NeRSjzSg.js} +3 -3
  21. package/dist/public/assets/{button-CZSpHYG9.js → button-hdghxls7.js} +1 -1
  22. package/dist/public/assets/{c4Diagram-7LVT6UL2-BSzLGfzg.js → c4Diagram-7LVT6UL2-D23ryIme.js} +1 -1
  23. package/dist/public/assets/channel-B98_B4F2.js +1 -0
  24. package/dist/public/assets/{chunk-2E4U76K2-CdDCDyYU.js → chunk-2E4U76K2-usroR3SM.js} +1 -1
  25. package/dist/public/assets/{chunk-4HAMMTFA-DEQ4g2Vr.js → chunk-4HAMMTFA-B4mxD8f1.js} +1 -1
  26. package/dist/public/assets/{chunk-75Z2AOVW-Bil9fayR.js → chunk-75Z2AOVW-BSDNHsOk.js} +1 -1
  27. package/dist/public/assets/{chunk-CLGD4ZFX-BCcQCUw7.js → chunk-CLGD4ZFX-DpUm0L6C.js} +1 -1
  28. package/dist/public/assets/{chunk-DU6HZSFF-BsEqNRs6.js → chunk-DU6HZSFF-Cin9bFEJ.js} +1 -1
  29. package/dist/public/assets/{chunk-F27PBJKO-3VPQvVOa.js → chunk-F27PBJKO-BWPIZmRh.js} +1 -1
  30. package/dist/public/assets/{chunk-GMAD6QVW-B1-kp_mS.js → chunk-GMAD6QVW-eS27qQYi.js} +1 -1
  31. package/dist/public/assets/{chunk-GVQU2GXP-CcH5DIRn.js → chunk-GVQU2GXP-DvZzuy44.js} +1 -1
  32. package/dist/public/assets/{chunk-IMKFNOWR-DXsqjjty.js → chunk-IMKFNOWR-CKfEqBn8.js} +1 -1
  33. package/dist/public/assets/{chunk-L3NEJ4N5-CLWbTGk0.js → chunk-L3NEJ4N5-Gq2sL0Oq.js} +1 -1
  34. package/dist/public/assets/{chunk-OSK3NFVY-Cg7bYfyL.js → chunk-OSK3NFVY-DSHFDm2K.js} +1 -1
  35. package/dist/public/assets/{chunk-P2QGCYS3-CPn0gvFx.js → chunk-P2QGCYS3-B0b6PsO0.js} +1 -1
  36. package/dist/public/assets/{chunk-POPQ4Y6H-Dy-mw1ro.js → chunk-POPQ4Y6H-B_whPWNN.js} +1 -1
  37. package/dist/public/assets/{chunk-PWAF6VOD-CrBboqO8.js → chunk-PWAF6VOD-DfdxoQ_F.js} +1 -1
  38. package/dist/public/assets/{chunk-SHT3W25Y-CPJO0R1G.js → chunk-SHT3W25Y-CHrnqlvt.js} +1 -1
  39. package/dist/public/assets/{chunk-SVP7TREG-BIhK7PZA.js → chunk-SVP7TREG-keTkvLck.js} +1 -1
  40. package/dist/public/assets/{chunk-TICWLB2K-CyGrrjlf.js → chunk-TICWLB2K-ZF0XdA5t.js} +1 -1
  41. package/dist/public/assets/{chunk-TLUHSLCS-EdA0yALB.js → chunk-TLUHSLCS-B3xiw07r.js} +2 -2
  42. package/dist/public/assets/classDiagram-ZZMXUADV-CalLaxUD.js +1 -0
  43. package/dist/public/assets/classDiagram-v2-VYDZK3BY-CalLaxUD.js +1 -0
  44. package/dist/public/assets/{context-menu-BcxQJKjd.js → context-menu-fGutCa7q.js} +1 -1
  45. package/dist/public/assets/{copy-DO0WkB3-.js → copy-B38GDFbv.js} +1 -1
  46. package/dist/public/assets/{cssMode-D53Um_ik.js → cssMode-BBPxRrZH.js} +1 -1
  47. package/dist/public/assets/{cynefin-OW5HDTMX-Cc22mgCn.js → cynefin-OW5HDTMX-BKwXHhp6.js} +1 -1
  48. package/dist/public/assets/{cynefinDiagram-5FMLGOSQ-CIyNRThr.js → cynefinDiagram-5FMLGOSQ-B59dmX8D.js} +1 -1
  49. package/dist/public/assets/{dagre-GXQ25YYZ-CnMk_Gwy.js → dagre-GXQ25YYZ-BysK_yGg.js} +1 -1
  50. package/dist/public/assets/{diagram-S7CK7UJ4-D0MGCjd4.js → diagram-S7CK7UJ4-BTvgOprS.js} +1 -1
  51. package/dist/public/assets/{diagram-UQ7AKVKN-BmkJFJIY.js → diagram-UQ7AKVKN-C1FXQfFT.js} +1 -1
  52. package/dist/public/assets/{diagram-VSXAHHWV-Dbl-ipQB.js → diagram-VSXAHHWV-CTub3LLw.js} +1 -1
  53. package/dist/public/assets/{diagram-VX7I27RA-DRVKTRul.js → diagram-VX7I27RA-C8YSQsst.js} +1 -1
  54. package/dist/public/assets/{diagram-Z3DM3KII-RyOfpikP.js → diagram-Z3DM3KII-zBY2ZT-7.js} +1 -1
  55. package/dist/public/assets/dialog-CVAp0B_q.js +41 -0
  56. package/dist/public/assets/disclosure-CWTUvRKU.js +1 -0
  57. package/dist/public/assets/{dist-sv8JIOv-.js → dist-1iWQMdtt.js} +1 -1
  58. package/dist/public/assets/{dist-Ci7LEIn0.js → dist-DWt3BCrg.js} +1 -1
  59. package/dist/public/assets/{ebnfDiagram-PWID7BFC-DsbOKLzm.js → ebnfDiagram-PWID7BFC-DZbYMMq9.js} +1 -1
  60. package/dist/public/assets/{erDiagram-RLTQ6QDP-BRu0Y85B.js → erDiagram-RLTQ6QDP-BufFqh6K.js} +1 -1
  61. package/dist/public/assets/{errors-wktZNO7z.js → errors-0CwhraNS.js} +1 -1
  62. package/dist/public/assets/eventmodeling-NTZA5JFV-CC5F0fZk.js +1 -0
  63. package/dist/public/assets/flowDiagram-HODETNUW-Dmt2DAB8.js +1 -0
  64. package/dist/public/assets/{ganttDiagram-EL5Y4UJY-BvxI4ZZ2.js → ganttDiagram-EL5Y4UJY-CzBnAVfV.js} +1 -1
  65. package/dist/public/assets/{gitGraph-4MIJSDKK-vLrRAKmJ.js → gitGraph-4MIJSDKK-DzkiKDz3.js} +1 -1
  66. package/dist/public/assets/{gitGraphDiagram-WWUBYQGX-BJ4Dh4JQ.js → gitGraphDiagram-WWUBYQGX-Cg5zqV71.js} +1 -1
  67. package/dist/public/assets/{htmlMode-7q2c14cA.js → htmlMode-HP2zLptL.js} +1 -1
  68. package/dist/public/assets/{index-CIyjjiv2.js → index-W9vnFL1i.js} +4 -4
  69. package/dist/public/assets/{info-A6RAGUB7-Dgq4dAoa.js → info-A6RAGUB7-DrzRcVCp.js} +1 -1
  70. package/dist/public/assets/{infoDiagram-27XIBGKW-BBeyIc-M.js → infoDiagram-27XIBGKW-DKhhQ6Mi.js} +1 -1
  71. package/dist/public/assets/{ishikawaDiagram-5VMMS53U-Bcmg0Rdq.js → ishikawaDiagram-5VMMS53U-Sxvy6BP4.js} +1 -1
  72. package/dist/public/assets/{journeyDiagram-3NMN7TZE-CwY84cL9.js → journeyDiagram-3NMN7TZE-DLCDGlAt.js} +1 -1
  73. package/dist/public/assets/{jsonMode-DrKVocC3.js → jsonMode-3cqCCYan.js} +1 -1
  74. package/dist/public/assets/{kanban-definition-UXKFOSKX-CF1YxPMi.js → kanban-definition-UXKFOSKX-BBHezsUK.js} +1 -1
  75. package/dist/public/assets/{line-4eWO9hqS.js → line-CXD0KIW6.js} +1 -1
  76. package/dist/public/assets/{markdown-mermaid-B3PzAp3L.js → markdown-mermaid-gr78oRak.js} +2 -2
  77. package/dist/public/assets/{math-C84CoDfI.js → math-DD0qgOf_.js} +1 -1
  78. package/dist/public/assets/{media-refresh-store-CTzNrUO5.js → media-refresh-store-DTLvGgrw.js} +1 -1
  79. package/dist/public/assets/{mermaid-parser.core-DINfbsjJ.js → mermaid-parser.core-CQpv25sY.js} +3 -3
  80. package/dist/public/assets/{mermaid.core-Cgopz4Nb.js → mermaid.core-CO3okgIG.js} +3 -3
  81. package/dist/public/assets/{mindmap-definition-YA3MSWOX-DiV-gupr.js → mindmap-definition-YA3MSWOX-DnuqRR1y.js} +1 -1
  82. package/dist/public/assets/notification-delivery-rQp5tkM8.js +1 -0
  83. package/dist/public/assets/{packet-AYTQ26CC-D4U8naDn.js → packet-AYTQ26CC--9UnHksn.js} +1 -1
  84. package/dist/public/assets/{pdf-Kc6SO_pI.js → pdf-DFR5TvGJ.js} +1 -1
  85. package/dist/public/assets/{pegDiagram-XKGWAZYB-2EhHewzX.js → pegDiagram-XKGWAZYB-m8JdNNtC.js} +1 -1
  86. package/dist/public/assets/{pie-WAS4IAKB-hLX3y_iU.js → pie-WAS4IAKB-GnDinOP5.js} +1 -1
  87. package/dist/public/assets/{pieDiagram-E7YTZNPT-ZPBxvnxk.js → pieDiagram-E7YTZNPT-u-NA8MFl.js} +1 -1
  88. package/dist/public/assets/{project-abbrev-DuSyhdGL.js → project-abbrev-Ce2YQx3q.js} +1 -1
  89. package/dist/public/assets/{protocol-support-B2anXRJW.js → protocol-support-DM3D3Owq.js} +1 -1
  90. package/dist/public/assets/{quadrantDiagram-AXDQQJYC-BrgYSl9Y.js → quadrantDiagram-AXDQQJYC-si_KhMBB.js} +1 -1
  91. package/dist/public/assets/{radar-RG4KPBEZ-ezwXnTYT.js → radar-RG4KPBEZ-CnJwODJt.js} +1 -1
  92. package/dist/public/assets/{railroad-74A4TZTK-CR-81fO8.js → railroad-74A4TZTK-Cgg0LWTI.js} +1 -1
  93. package/dist/public/assets/railroad-abnf-HS5TGJTU-DPqD3hz7.js +1 -0
  94. package/dist/public/assets/railroad-ebnf-LZEXJU2U-9Jxyrh7e.js +1 -0
  95. package/dist/public/assets/railroad-peg-WCYAUIDC-gr2ZokSI.js +1 -0
  96. package/dist/public/assets/{railroadDiagram-O6MQD6OU-Dm98Dukk.js → railroadDiagram-O6MQD6OU-DuQX8qaE.js} +1 -1
  97. package/dist/public/assets/{requirementDiagram-BXWQKSXE-BKUOU0s7.js → requirementDiagram-BXWQKSXE-Chwrn5Tf.js} +1 -1
  98. package/dist/public/assets/{sankeyDiagram-P5KCCOFB-5197_HSs.js → sankeyDiagram-P5KCCOFB-FpJ30BIQ.js} +1 -1
  99. package/dist/public/assets/{scroll-restoration-ClxX1YHt.js → scroll-restoration-B3J09_am.js} +1 -1
  100. package/dist/public/assets/{selection-actions-BTyYbd08.js → selection-actions-awCJJCSe.js} +1 -1
  101. package/dist/public/assets/{sequenceDiagram-WJ2MYXX4-rNfQjUcO.js → sequenceDiagram-WJ2MYXX4-DVw87Ucm.js} +1 -1
  102. package/dist/public/assets/{stateDiagram-D77RDMKH-Cx5Ee_e1.js → stateDiagram-D77RDMKH-qmBcs9VH.js} +1 -1
  103. package/dist/public/assets/stateDiagram-v2-MP3YSRHH-TK5UygAI.js +1 -0
  104. package/dist/public/assets/{swimlanes-42K2YHIH-wMD3I2QL.js → swimlanes-42K2YHIH-ts5KQGMt.js} +1 -1
  105. package/dist/public/assets/swimlanesDiagram-VR7AAH4N-BUMN0oZf.js +8 -0
  106. package/dist/public/assets/{switch-Y_nZqNi0.js → switch-DMkSxGf3.js} +1 -1
  107. package/dist/public/assets/{timeline-definition-24CTP7MA-mnOLKfvu.js → timeline-definition-24CTP7MA-BDL_pzrt.js} +1 -1
  108. package/dist/public/assets/{treeView-Q6P3EWNA-DYPLE01q.js → treeView-Q6P3EWNA-B1vMOTkl.js} +1 -1
  109. package/dist/public/assets/{treemap-WGGIJYW6-D_iDh6g6.js → treemap-WGGIJYW6-wi5T0FIb.js} +1 -1
  110. package/dist/public/assets/{tsMode-CZWKy2l3.js → tsMode-CsaS5imR.js} +1 -1
  111. package/dist/public/assets/{use-ui-state-9fFSPrEY.js → use-ui-state-2VprViGF.js} +1 -1
  112. package/dist/public/assets/{vennDiagram-4TSXK5OY-Bve1WBMV.js → vennDiagram-4TSXK5OY-Djvp5-2_.js} +1 -1
  113. package/dist/public/assets/{view-state-store-DShmQqnS.js → view-state-store-rOwEBYKn.js} +1 -1
  114. package/dist/public/assets/{wardley-WFR3VGLG-3pdzzC1s.js → wardley-WFR3VGLG-Di-PFH_i.js} +1 -1
  115. package/dist/public/assets/{wardleyDiagram-VM6X3IG4-EPB-PAuG.js → wardleyDiagram-VM6X3IG4-B5Y8UZiL.js} +1 -1
  116. package/dist/public/assets/ws-DsytGlkr.js +1 -0
  117. package/dist/public/assets/{xychartDiagram-S5SC5T6Z-wGpnlL1-.js → xychartDiagram-S5SC5T6Z-d-pvxFe2.js} +1 -1
  118. package/dist/public/index.html +3 -1
  119. package/dist/public/manifest.webmanifest +11 -0
  120. package/dist/public/notification-worker.js +135 -0
  121. package/dist/public/puddle-app.png +0 -0
  122. package/package.json +1 -1
  123. package/dist/public/assets/App-CGG5do99.js +0 -2
  124. package/dist/public/assets/LazyTerminal-DqKe6H-V.js +0 -2
  125. package/dist/public/assets/SettingsDialog-VAdM-npo.js +0 -8
  126. package/dist/public/assets/architecture-7GRP2DOG-D-XtK_lw.js +0 -1
  127. package/dist/public/assets/channel-Dl9lubaq.js +0 -1
  128. package/dist/public/assets/classDiagram-ZZMXUADV-BXIsJXJa.js +0 -1
  129. package/dist/public/assets/classDiagram-v2-VYDZK3BY-BXIsJXJa.js +0 -1
  130. package/dist/public/assets/dialog-cFDquLR6.js +0 -41
  131. package/dist/public/assets/disclosure-FybNXyk_.js +0 -1
  132. package/dist/public/assets/eventmodeling-NTZA5JFV-CyvczrOZ.js +0 -1
  133. package/dist/public/assets/flowDiagram-HODETNUW-CZyfSlpG.js +0 -1
  134. package/dist/public/assets/notification-permission-2B9Xl86r.js +0 -1
  135. package/dist/public/assets/railroad-abnf-HS5TGJTU-DbufkTPM.js +0 -1
  136. package/dist/public/assets/railroad-ebnf-LZEXJU2U-DqvR8uyV.js +0 -1
  137. package/dist/public/assets/railroad-peg-WCYAUIDC-CSIG-i7o.js +0 -1
  138. package/dist/public/assets/stateDiagram-v2-MP3YSRHH-BC_og2uK.js +0 -1
  139. package/dist/public/assets/swimlanesDiagram-VR7AAH4N-DD33Ofd5.js +0 -8
  140. package/dist/public/assets/ws-ClWC7CMz.js +0 -1
@@ -0,0 +1,135 @@
1
+ /* global self, indexedDB */
2
+ /* Notifications only: no fetch interception or caching of host content. */
3
+ let queue = Promise.resolve();
4
+ let database;
5
+ const uuid = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
6
+ function receipts() {
7
+ if (!database)
8
+ database = new Promise((resolve, reject) => {
9
+ const request = indexedDB.open('puddle-notification-receipts', 1);
10
+ request.onupgradeneeded = () =>
11
+ request.result.createObjectStore('seen', { keyPath: 'id' }).createIndex('at', 'at');
12
+ request.onsuccess = () => resolve(request.result);
13
+ request.onerror = () => reject(request.error);
14
+ });
15
+ return database;
16
+ }
17
+ async function seen(id, save = false) {
18
+ const db = await receipts();
19
+ return new Promise((resolve, reject) => {
20
+ const tx = db.transaction('seen', save ? 'readwrite' : 'readonly');
21
+ const store = tx.objectStore('seen');
22
+ let found = false;
23
+ const read = store.get(id);
24
+ read.onsuccess = () => {
25
+ found = !!read.result && read.result.at > Date.now() - 86400000;
26
+ };
27
+ if (save) {
28
+ store.put({ id, at: Date.now() });
29
+ const count = store.count();
30
+ count.onsuccess = () => {
31
+ let remove = Math.max(0, count.result - 512);
32
+ const cursor = store.index('at').openCursor();
33
+ cursor.onsuccess = () => {
34
+ const row = cursor.result;
35
+ if (!row || (remove <= 0 && row.value.at > Date.now() - 86400000)) return;
36
+ row.delete();
37
+ remove--;
38
+ row.continue();
39
+ };
40
+ };
41
+ }
42
+ tx.oncomplete = () => resolve(found);
43
+ tx.onerror = () => reject(tx.error);
44
+ tx.onabort = () => reject(tx.error);
45
+ });
46
+ }
47
+ function show(request, host, fromPush = false, client) {
48
+ const task = queue.then(async () => {
49
+ const deduplicate = request.id.startsWith('puddle-event-');
50
+ // Every push must call showNotification: Safari revokes permission for
51
+ // silent pushes. Matching tags replace a racing live alert without renotify.
52
+ if (deduplicate && !fromPush && (await seen(request.id).catch(() => false))) return;
53
+ await self.registration.showNotification(request.title, {
54
+ body: request.body,
55
+ tag: request.id,
56
+ silent: true,
57
+ renotify: false,
58
+ data: host ? { host } : { client },
59
+ icon: '/puddle-app.png',
60
+ });
61
+ if (deduplicate) await seen(request.id, true).catch(() => {});
62
+ });
63
+ queue = task.catch(() => {});
64
+ return task;
65
+ }
66
+ self.addEventListener('install', () => self.skipWaiting());
67
+ self.addEventListener('activate', (event) => event.waitUntil(self.clients.claim()));
68
+ self.addEventListener('message', (event) => {
69
+ const request = event.data?.request;
70
+ if (
71
+ event.data?.t !== 'show-notification' ||
72
+ !event.source?.url ||
73
+ new URL(event.source.url).origin !== self.location.origin ||
74
+ typeof request?.id !== 'string' ||
75
+ request.id.length > 128 ||
76
+ typeof request.title !== 'string' ||
77
+ request.title.length > 160 ||
78
+ typeof request.body !== 'string' ||
79
+ request.body.length > 256
80
+ )
81
+ return;
82
+ event.waitUntil(
83
+ show(request, undefined, false, event.source.id).then(
84
+ () => event.ports[0]?.postMessage({ ok: true }),
85
+ () => event.ports[0]?.postMessage({ ok: false }),
86
+ ),
87
+ );
88
+ });
89
+ self.addEventListener('push', (event) => {
90
+ let payload;
91
+ try {
92
+ payload = event.data.json();
93
+ } catch {
94
+ return;
95
+ }
96
+ if (!uuid.test(payload?.id) || !uuid.test(payload?.host)) return;
97
+ event.waitUntil(
98
+ show(
99
+ { id: `puddle-event-${payload.id}`, title: 'Puddle', body: 'An agent needs your attention.' },
100
+ payload.host,
101
+ true,
102
+ ),
103
+ );
104
+ });
105
+ self.addEventListener('notificationclick', (event) => {
106
+ event.notification.close();
107
+ const host = event.notification.data?.host;
108
+ const target = uuid.test(host) ? `/?notificationHost=${host}` : '/';
109
+ event.waitUntil(
110
+ (async () => {
111
+ const windows = await self.clients.matchAll({ type: 'window', includeUncontrolled: true });
112
+ windows.sort(
113
+ (a, b) =>
114
+ Number(b.id === event.notification.data?.client) -
115
+ Number(a.id === event.notification.data?.client),
116
+ );
117
+ for (const client of windows) {
118
+ if (
119
+ client.frameType !== 'top-level' ||
120
+ new URL(client.url).origin !== self.location.origin ||
121
+ new URL(client.url).pathname === '/preview.html'
122
+ )
123
+ continue;
124
+ await client.focus();
125
+ client.postMessage({
126
+ t: 'notification-click',
127
+ id: event.notification.tag,
128
+ ...(uuid.test(host) ? { host } : {}),
129
+ });
130
+ return;
131
+ }
132
+ await self.clients.openWindow(target);
133
+ })(),
134
+ );
135
+ });
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puddle-code/cli",
3
- "version": "0.2.18",
3
+ "version": "0.2.21",
4
4
  "description": "puddle \u2014 self-hosted orchestrator for CLI coding agents: serves the cockpit UI and connects it to local or SSH hosts.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/PerceptronV/puddle-code#readme",
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsDialog-VAdM-npo.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/index-CIyjjiv2.js","assets/index-Bwl8S5Du.css","assets/dist-sv8JIOv-.js","assets/protocol-support-B2anXRJW.js","assets/dialog-cFDquLR6.js","assets/button-CZSpHYG9.js","assets/x-CZCUod6A.js","assets/createLucideIcon-DyMAgLa3.js","assets/LazyTerminal-DqKe6H-V.js","assets/switch-Y_nZqNi0.js","assets/notification-permission-2B9Xl86r.js","assets/disclosure-FybNXyk_.js","assets/chevron-down--sjpQEHH.js","assets/dist-Ci7LEIn0.js","assets/code-DRWf9a5s.js","assets/errors-wktZNO7z.js","assets/use-debounced-value-C86N-mOK.js","assets/Dashboard-DdqyCWkG.js","assets/project-abbrev-DuSyhdGL.js","assets/context-menu-BcxQJKjd.js","assets/NewProjectDialog-B4ySxxDz.js","assets/ws-ClWC7CMz.js","assets/Workspace-BO11vRQa.js","assets/copy-DO0WkB3-.js","assets/media-refresh-store-CTzNrUO5.js","assets/use-ui-state-9fFSPrEY.js","assets/preview-kind-QJSMKfUN.js","assets/debounce-B9DrqirV.js","assets/selection-actions-BTyYbd08.js","assets/drafts-B_tChlzR.js","assets/buffer-logic-BAkSBQT7.js","assets/view-state-store-DShmQqnS.js","assets/scroll-restoration-ClxX1YHt.js","assets/Workspace-DdL3ODEC.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{K as n,N as r,T as i,U as a,a as o,c as s,g as c,h as l,i as u,m as d,n as f,r as p,rt as m,s as h,t as g,y as _}from"./index-CIyjjiv2.js";import{n as v,t as y}from"./dist-sv8JIOv-.js";import{$t as b,A as x,B as S,Bt as C,C as w,D as T,E,Et as D,F as O,Gt as k,Ht as A,It as j,Jt as M,K as ee,Kt as N,M as te,Mt as ne,N as re,Nt as ie,O as ae,P as oe,Pt as se,Qt as ce,St as le,T as ue,Ut as de,V as fe,Vt as pe,W as me,Wt as he,Xt as ge,Y as _e,Yt as ve,Z as ye,Zt as be,_ as xe,a as Se,b as Ce,ct as we,ft as Te,g as Ee,gt as De,ht as Oe,k as ke,lt as Ae,m as je,mt as Me,nt as Ne,ot as Pe,p as Fe,pt as Ie,qt as Le,rt as Re,st as ze,tt as Be,w as Ve,x as He,y as Ue,zt as We}from"./protocol-support-B2anXRJW.js";import{n as Ge,t as Ke}from"./copy-DO0WkB3-.js";import{a as qe,c as Je,d as Ye,f as Xe,i as Ze,l as Qe,m as $e,p as et,s as tt,u as nt}from"./project-abbrev-DuSyhdGL.js";import{S as P,c as rt,l as it,n as at,s as ot,t as st,u as ct,v as F}from"./dialog-cFDquLR6.js";import{i as lt,t as I}from"./button-CZSpHYG9.js";import{c as ut,f as dt,i as ft,o as pt,s as L,u as mt}from"./LazyTerminal-DqKe6H-V.js";import{a as ht,c as gt,d as _t,f as vt,l as yt,t as bt,u as xt}from"./switch-Y_nZqNi0.js";import{$ as St,G as Ct,H as wt,J as Tt,K as Et,Q as Dt,U as Ot,W as kt,X as At,Y as jt,at as Mt,d as Nt,et as Pt,f as Ft,h as R,i as It,it as z,m as Lt,nt as Rt,ot as B,p as zt,q as Bt,r as Vt,rt as V,t as Ht,tt as Ut}from"./use-ui-state-9fFSPrEY.js";import{n as H}from"./x-CZCUod6A.js";import{t as U}from"./createLucideIcon-DyMAgLa3.js";import{_ as Wt,c as Gt,d as Kt,f as qt,h as Jt,i as Yt,l as Xt,n as Zt,o as Qt,p as $t,r as en,s as tn,t as nn,u as rn,v as an}from"./notification-permission-2B9Xl86r.js";import{t as on}from"./NewProjectDialog-B4ySxxDz.js";import{n as W}from"./errors-wktZNO7z.js";import{t as G}from"./ws-ClWC7CMz.js";var K=e(t(),1),q=f();function sn(){let[e,t]=(0,K.useState)(`Opening forwarded application…`);return(0,K.useEffect)(()=>{if(!/^\/forward\/([^/]+)\/(\d+)$/.exec(window.location.pathname)){t(`This forwarding link is invalid.`);return}let e=!0;return Ge(new URL(window.location.href)).then(t=>{e&&window.location.replace(t)}).catch(()=>{e&&t(`The application is unavailable. Reconnect to Puddle and open this link again.`)}),()=>{e=!1}},[]),(0,q.jsx)(`p`,{className:`p-8 text-sm text-fg-secondary`,children:e})}var cn=class extends be{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new se({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=ln(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=ln(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=ln(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=ln(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){C.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>he(t,e))}findAll(e={}){return this.getAll().filter(t=>he(e,t))}notify(e){C.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return C.batch(()=>Promise.all(e.map(e=>e.continue().catch(N))))}};function ln(e){return e.options.scope?.id}var un=class extends be{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??de(r,t),a=this.get(i);return a||(a=new j({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){C.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>k(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>k(e,t)):t}notify(e){C.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){C.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){C.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},dn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new un,this.#t=e.mutationCache||new cn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ge.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=We.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(M(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=pe(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return C.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;C.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return C.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=C.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(N).catch(N)}invalidateQueries(e,t={}){return C.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=C.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(N)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(N)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(M(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(N).catch(N)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(N).catch(N)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return We.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(A(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Le(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(A(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Le(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=de(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ve&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},fn=class extends K.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e){this.state.error!==null&&e.resetOn!==this.props.resetOn&&this.setState({error:null})}componentDidCatch(e,t){console.error(`Puddle: the ${this.props.scope} crashed`,e,t.componentStack)}render(){let{error:e}=this.state;return e===null?this.props.children:(0,q.jsxs)(`div`,{className:`flex h-full min-h-40 flex-col items-center justify-center gap-4 px-8 py-10 text-center`,children:[(0,q.jsxs)(`p`,{className:`text-sm text-fg`,children:[`The `,this.props.scope,` stopped rendering.`]}),(0,q.jsx)(`p`,{className:`max-w-lg font-mono text-2xs leading-relaxed text-interrupted`,children:e.message||String(e)}),(0,q.jsx)(`p`,{className:`max-w-sm text-2xs leading-relaxed text-fg-muted`,children:`Your sessions and their worktrees are on the daemon and untouched; the layout is saved. The console has the full stack.`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`text-2xs font-medium text-fg-gold transition-colors hover:underline`,children:`Try again`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function pn(){return(0,q.jsx)(y,{theme:(0,K.useSyncExternalStore)(h,o),position:`bottom-right`,toastOptions:{style:{background:`var(--bg-elevated)`,border:`none`,boxShadow:`0 8px 30px rgb(0 0 0 / 0.25)`,color:`var(--text-primary)`},classNames:{description:`whitespace-pre-wrap break-words font-mono text-2xs leading-snug max-h-40 overflow-y-auto`}}})}function mn(){return(0,q.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,q.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-24`,children:[(0,q.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm leading-relaxed text-fg-secondary`,children:[(0,q.jsxs)(`p`,{children:[`Authorise this browser by running`,` `,(0,q.jsx)(`span`,{className:`font-mono text-accent`,children:`puddle launch`}),` in a terminal.`]}),(0,q.jsx)(`p`,{children:`Use the link it opens. Your sessions, drafts and layouts stay in place.`})]})]})})}var hn=e(m(),1),gn=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,_n=`.monaco-editor`;function vn(e,t){return e?.closest(_n)&&!e.closest(t)?`text`:e?.closest(gn)?`interactive`:`default`}function yn(e,t=`.no-custom-caret`){(0,K.useEffect)(()=>{let n=e.current;if(!n)return;let r=window.matchMedia(`(pointer: fine)`),i=()=>{n.style.opacity=`0`},a=e=>{if(e.pointerType===`touch`||!r.matches){i();return}n.style.transform=`translate3d(${e.clientX}px, ${e.clientY}px, 0) translate(-50%, -50%)`;let a=e.target instanceof Element?e.target:null;if(a instanceof HTMLIFrameElement){i();return}n.style.opacity=`1`;let o=a?.closest(_n),s=vn(a,t),c=s===`text`,l=s===`interactive`,u=c;if(c&&o){let e=getComputedStyle(o);n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`)}else if(!l&&a&&!a.closest(t)&&Array.from(a.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())){let e=getComputedStyle(a);e.userSelect!==`none`&&(u=!0,n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`))}n.classList.toggle(`is-interactive`,l),n.classList.toggle(`is-text`,u)};return window.addEventListener(`pointermove`,a,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,i),window.addEventListener(`blur`,i),()=>{window.removeEventListener(`pointermove`,a),document.documentElement.removeEventListener(`pointerleave`,i),window.removeEventListener(`blur`,i)}},[t,e])}var bn=[`top`,`right`,`bottom`,`left`];function xn(){let e=(0,K.useRef)(null);return yn(e),(0,q.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:bn.map(e=>(0,q.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function Sn(){let e=(0,K.useRef)(null);return yn(e),(0,q.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var Cn=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,wn=40.5,J=4.05,Tn=J*Math.sqrt(3)/2;function En(){let e=[],t=[],n=wn/2,r=Math.ceil(n/Tn)+1,i=e=>Math.round(e*100)/100,a=e=>`M${e.map(([e,t])=>`${i(e)} ${i(t)}`).join(`L`)}Z`;for(let i=-r;i<r;i+=1){let o=n+i*Tn,s=o+Tn,c=(i%2+2)%2*(J/2);for(let i=-r;i<r;i+=1){let r=n+i*J+c,l=[[r+J/2,o],[r,s],[r+J,s]],u=[[r+J/2,o],[r+3*J/2,o],[r+J,s]],d=e=>{let t=e.map(([e])=>e),n=e.map(([,e])=>e);return Math.max(...t)>0&&Math.min(...t)<wn&&Math.max(...n)>0&&Math.min(...n)<wn};d(l)&&e.push(a(l)),d(u)&&t.push(a(u))}}return{light:e.join(``),dark:t.join(``)}}var Dn=En();function On(){let e=(0,K.useRef)(null);return yn(e,Cn),(0,q.jsx)(`div`,{ref:e,className:`custom-cursor rangefinder-cursor`,"aria-hidden":`true`,children:(0,q.jsxs)(`svg`,{className:`rangefinder-cursor-facets`,viewBox:`0 0 ${wn} ${wn}`,focusable:`false`,children:[(0,q.jsx)(`path`,{className:`rangefinder-cursor-facet-light`,d:Dn.light}),(0,q.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:Dn.dark})]})})}function kn(){let{cursorPackage:e}=c(),t=null;switch(e){case`rangefinder`:t=(0,q.jsx)(On,{});break;case`drafting`:t=(0,q.jsx)(xn,{});break;case`invert`:t=(0,q.jsx)(Sn,{});break;case`system`:return null}return(0,hn.createPortal)(t,document.body)}var An=U(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),jn=U(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Mn=U(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),Nn=U(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Pn=U(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Fn=U(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),In=U(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function Ln(){let e=Me(),t=fe(),[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(n),s=()=>{r.trim()&&t.mutate({name:r.trim(),branch_prefix:a.trim()},{onSuccess:e=>ue(e.id)})},c=(e.data?.length??0)>0;return(0,q.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,q.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-16`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Who is working?`})]}),c&&(0,q.jsx)(`div`,{className:`flex flex-col`,children:e.data.map(e=>(0,q.jsxs)(`button`,{onClick:()=>ue(e.id),className:`flex items-center gap-3 rounded-md px-3 py-2.5 text-left transition-colors hover:bg-elevated active:bg-border/70`,children:[(0,q.jsx)(qt,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:H(`text-base`,$t(e.icon_colour)||`text-fg`),children:e.name}),e.branch_prefix&&(0,q.jsxs)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:[e.branch_prefix,`…`]})]},e.id))}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),s()},children:[c&&(0,q.jsx)(`p`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`or create a profile`}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(pt,{htmlFor:`profile-name`,children:`Name`}),(0,q.jsx)(L,{id:`profile-name`,placeholder:`e.g. alice`,value:r,onChange:e=>i(e.target.value),className:`h-10`,autoFocus:!c})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(pt,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,q.jsx)(L,{id:`branch-prefix`,placeholder:`no prefix`,value:a,onChange:e=>o(e.target.value),className:`h-10`})]}),t.error&&(0,q.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}),(0,q.jsx)(I,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!r.trim()||t.isPending,children:`Create profile`})]})]})})}var Rn=1,zn=.9,Bn=.8,Vn=.17,Hn=.1,Un=.999,Wn=.9999,Gn=.99,Kn=/[\\\/_+.#"@\[\(\{&]/,qn=/[\\\/_+.#"@\[\(\{&]/g,Jn=/[\s-]/,Yn=/[\s-]/g;function Xn(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Rn:Gn;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=Xn(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Rn:Kn.test(e.charAt(l-1))?(d*=Bn,p=e.slice(i,l-1).match(qn),p&&i>0&&(d*=Un**+p.length)):Jn.test(e.charAt(l-1))?(d*=zn,m=e.slice(i,l-1).match(Yn),m&&i>0&&(d*=Un**+m.length)):(d*=Vn,i>0&&(d*=Un**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Wn)),(d<Hn&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Xn(e,t,n,r,l+1,a+2,o),f*Hn>d&&(d=f*Hn)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Zn(e){return e.toLowerCase().replace(Yn,` `)}function Qn(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Xn(e,t,Zn(e),Zn(t),0,0,{})}var $n=`[cmdk-group=""]`,er=`[cmdk-group-items=""]`,tr=`[cmdk-group-heading=""]`,nr=`[cmdk-item=""]`,rr=`${nr}:not([aria-disabled="true"])`,ir=`cmdk-item-select`,Y=`data-value`,ar=(e,t,n)=>Qn(e,t,n),or=K.createContext(void 0),sr=()=>K.useContext(or),cr=K.createContext(void 0),lr=()=>K.useContext(cr),ur=K.createContext(void 0),dr=K.forwardRef((e,t)=>{let n=Q(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Q(()=>new Set),i=Q(()=>new Map),a=Q(()=>new Map),o=Q(()=>new Set),s=Sr(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=F(),y=F(),b=F(),x=K.useRef(null),S=wr();Z(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Z(()=>{S(6,k)},[]);let C=K.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=K.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??ar;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(er);t?t.appendChild(e.parentElement===t?e:e.closest(`${er} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${er} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${$n}[${Y}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Y);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest($n)?.querySelector(tr))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${nr}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(rr)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Y))}function ee(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Y))}function N(e){let t=A()?.closest($n),n;for(;t&&!n;)t=e>0?br(t,$n):xr(t,$n),n=t?.querySelector(rr);n?C.setState(`value`,n.getAttribute(Y)):ee(e)}let te=()=>M(j().length-1),ne=e=>{e.preventDefault(),e.metaKey?te():e.altKey?N(1):ee(1)},re=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?N(-1):ee(-1)};return K.createElement(P.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ne(e);break;case`ArrowDown`:ne(e);break;case`p`:case`k`:g&&e.ctrlKey&&re(e);break;case`ArrowUp`:re(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),te();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(ir);t.dispatchEvent(e)}}}}},K.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Dr},c),Er(e,e=>K.createElement(cr.Provider,{value:C},K.createElement(or.Provider,{value:w},e))))}),fr=K.forwardRef((e,t)=>{let n=F(),r=K.useRef(null),i=K.useContext(ur),a=sr(),o=Sr(e),s=o.current?.forceMount??i?.forceMount;Z(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Cr(n,r,[e.value,e.children,r],e.keywords),l=lr(),u=$(e=>e.value&&e.value===c.current),d=$(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);K.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(ir,f),()=>t.removeEventListener(ir,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return K.createElement(P.div,{ref:lt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),pr=K.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=F(),s=K.useRef(null),c=K.useRef(null),l=F(),u=sr(),d=$(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Z(()=>u.group(o),[]),Cr(o,s,[e.value,e.heading,c]);let f=K.useMemo(()=>({id:o,forceMount:i}),[i]);return K.createElement(P.div,{ref:lt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&K.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Er(e,e=>K.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},K.createElement(ur.Provider,{value:f},e))))}),mr=K.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=K.useRef(null),a=$(e=>!e.search);return!n&&!a?null:K.createElement(P.div,{ref:lt(i,t),...r,"cmdk-separator":``,role:`separator`})}),hr=K.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=lr(),o=$(e=>e.search),s=$(e=>e.selectedItemId),c=sr();return K.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),K.createElement(P.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),gr=K.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=K.useRef(null),o=K.useRef(null),s=$(e=>e.selectedItemId),c=sr();return K.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),K.createElement(P.div,{ref:lt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Er(e,e=>K.createElement(`div`,{ref:lt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),_r=K.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return K.createElement(ot,{open:n,onOpenChange:r},K.createElement(ct,{container:o},K.createElement(it,{"cmdk-overlay":``,className:i}),K.createElement(rt,{"aria-label":e.label,"cmdk-dialog":``,className:a},K.createElement(dr,{ref:t,...s}))))}),vr=K.forwardRef((e,t)=>$(e=>e.filtered.count===0)?K.createElement(P.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),yr=K.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return K.createElement(P.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Er(e,e=>K.createElement(`div`,{"aria-hidden":!0},e)))}),X=Object.assign(dr,{List:gr,Item:fr,Input:hr,Group:pr,Separator:mr,Dialog:_r,Empty:vr,Loading:yr});function br(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function xr(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Sr(e){let t=K.useRef(e);return Z(()=>{t.current=e}),t}var Z=typeof window>`u`?K.useEffect:K.useLayoutEffect;function Q(e){let t=K.useRef();return t.current===void 0&&(t.current=e()),t}function $(e){let t=lr(),n=()=>e(t.snapshot());return K.useSyncExternalStore(t.subscribe,n,n)}function Cr(e,t,n,r=[]){let i=K.useRef(),a=sr();return Z(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Y,s),i.current=s}),i}var wr=()=>{let[e,t]=K.useState(),n=Q(()=>new Map);return Z(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Tr(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Er({asChild:e,children:t},n){return e&&K.isValidElement(t)?K.cloneElement(Tr(t),{ref:t.ref},n(t.props.children)):n(t)}var Dr={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Or({className:e,...t}){return(0,q.jsx)(X,{className:H(`flex size-full flex-col overflow-hidden rounded-lg bg-elevated`,e),...t})}function kr({open:e,onOpenChange:t,children:n}){return(0,q.jsx)(st,{open:e,onOpenChange:t,children:(0,q.jsx)(at,{className:`max-w-lg overflow-hidden p-0 [&>button]:hidden`,children:(0,q.jsx)(Or,{loop:!0,children:n})})})}function Ar({className:e,...t}){return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pt-1`,children:[(0,q.jsx)(Rt,{className:`size-4 shrink-0 text-fg-muted`}),(0,q.jsx)(X.Input,{className:H(`flex h-10 w-full bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`,e),...t})]})}function jr({className:e,...t}){return(0,q.jsx)(X.List,{className:H(`max-h-72 overflow-y-auto p-1`,e),...t})}function Mr(e){return(0,q.jsx)(X.Empty,{className:`py-6 text-center text-sm text-fg-muted`,...e})}function Nr({className:e,...t}){return(0,q.jsx)(X.Group,{className:H(`overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-2xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wide [&_[cmdk-group-heading]]:text-fg-muted`,e),...t})}function Pr({className:e,...t}){return(0,q.jsx)(X.Item,{className:H(dt,mt,`[&_svg]:size-3.5 [&_svg]:text-fg-muted data-[selected=true]:[&_svg]:text-action-ink`,e),...t})}function Fr({className:e,...t}){return(0,q.jsx)(`span`,{className:H(`ml-auto font-mono text-2xs tracking-widest text-fg-muted`,e),...t})}var Ir=new class{transport;reload;pause;phase=`idle`;pending=null;constructor(e=fetch,t=()=>window.location.reload(),n=e=>new Promise(t=>setTimeout(t,e))){this.transport=e,this.reload=t,this.pause=n}refresh(e=12e4){return this.pending||=this.run(e).finally(()=>{this.pending=null}),this.pending}async run(e){this.phase=`requesting`;let t={authorization:`Bearer ${_.get()??``}`,"content-type":`application/json`};try{let n=await this.transport(`/cockpit/refresh`,{method:`POST`,headers:t,signal:AbortSignal.timeout(1e4),body:JSON.stringify({refreshId:crypto.randomUUID()})});if(n.status!==202)throw Error(`refresh rejected`);let a=r.parse(await n.json());this.phase=`waiting`;let o=Date.now()+e;for(;Date.now()<o;){await this.pause(1e3);try{let e=await this.transport(`/cockpit/status`,{headers:t,cache:`no-store`,signal:AbortSignal.timeout(3e3)});if(!e.ok)continue;let n=i.parse(await e.json());if(n.instance===a.instance||n.refreshId!==a.refreshId||n.upstream!==`ready`)continue;return this.phase=`complete`,this.reload(),!0}catch{}}}catch{}return this.phase=`failed`,!1}},Lr=null;function Rr(e){return Lr=e,()=>{Lr===e&&(Lr=null)}}function zr(){Lr?.()}var Br=new Set;function Vr(){return[...Br].flatMap(e=>e())}function Hr({onNewSession:e,onNewProject:t}){let[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(`commands`),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(!1),f=et(),m=$e(),h=E(),g=m.id,_=De(h??void 0),v=D(g),y=jt();(0,K.useEffect)(()=>Ce(`palette.toggle`,()=>r(e=>!e)),[]),(0,K.useEffect)(()=>St(()=>r(!0)),[]),(0,K.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let b=(0,K.useMemo)(()=>{let n=[];for(let e of _.data??[])n.push({id:`project-${e.id}`,group:`Projects`,label:e.name,icon:qe,keywords:`switch project open`,run:()=>void f(`/project/${e.id}`)});for(let e of v.data??[])e.status!==`archived`&&n.push({id:`session-${e.id}`,group:`Sessions`,label:y(e),icon:Ze,keywords:`switch session ${e.branch}`,run:()=>void f(`/project/${e.project_id}/session/${e.id}`)});return g!==void 0&&e&&n.push({id:`new-agent`,group:`Actions`,label:`New agent`,icon:vt,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:Ze,keywords:`new terminal create start shell session`,run:()=>e({kind:`terminal`})}),g!==void 0&&n.push({id:`open-path`,group:`Actions`,label:`Open path`,icon:qe,keywords:`open path file directory folder editor tree browse absolute relative home`,closeOnRun:!1,run:()=>{s(``),l(null),a(`path`)}}),t&&n.push({id:`new-project`,group:`Actions`,label:`New project`,icon:_t,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:Wt,keywords:`switch theme dark appearance`,run:()=>void p(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:Jt,keywords:`switch theme light appearance`,run:()=>void p(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:Mn,keywords:`switch theme system appearance`,run:()=>void p(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:In,keywords:`open settings preferences options configure`,run:()=>ht()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:gt,keywords:`switch profile identity user change`,run:()=>Ve.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:xt,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>zr()}),[...n,...Vr()]},[_.data,v.data,g,f,e,t,y]),x=(0,K.useMemo)(()=>{let e=new Map;for(let t of b){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]},[b]),S=async()=>{let e=o.trim();if(!(e===``||u)){d(!0),l(null);try{await At(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,q.jsxs)(kr,{open:n,onOpenChange:r,children:[(0,q.jsx)(Ar,{value:o,onValueChange:e=>{s(e),l(null)},placeholder:i===`path`?`Enter a path…`:`Type a command or search…`,onKeyDown:e=>{i===`path`&&(e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),S()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(`commands`),s(``),l(null)))}}),i===`path`?(0,q.jsx)(jr,{children:(0,q.jsxs)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[(0,q.jsx)(`p`,{children:`Relative paths start from the bound worktree or project. Absolute and ~ paths work too.`}),(0,q.jsx)(`p`,{className:c?`mt-2 text-danger`:`mt-2`,"aria-live":`polite`,children:c??(u?`Opening…`:`Press Enter to open.`)})]})}):(0,q.jsxs)(jr,{children:[(0,q.jsx)(Mr,{children:`Nothing matches.`}),x.map(([e,t])=>(0,q.jsx)(Nr,{heading:e,children:t.map(e=>{let t=e.icon;return(0,q.jsxs)(Pr,{value:`${e.label} ${e.keywords??``}`,onSelect:()=>{e.closeOnRun!==!1&&r(!1),e.run()},children:[t&&(0,q.jsx)(t,{}),e.label,e.shortcut&&(0,q.jsx)(Fr,{children:e.shortcut})]},e.id)})},e))]})]})}function Ur(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function Wr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function Gr(){let e=Ie(E()??void 0).data?.hotkeys;return(0,K.useEffect)(()=>{He(e&&typeof e==`object`?e:void 0)},[e]),(0,K.useEffect)(()=>Ce(`window.close`,()=>{let e=ce();e?.closeWindow?e.closeWindow():window.close()}),[]),(0,K.useEffect)(()=>{let e=e=>{let t=je(e);if(!t)return;let n=Fe(t);if(!n)return;let r=Ee(n);if(!r||!Ue(r,Wr()))return;let i=xe(n);i&&(e.preventDefault(),e.stopPropagation(),i())},t=e=>{let t=je(e);if(!t)return;let n=Fe(t);if(!n)return;let r=Ee(n);if(!r||r.editor&&Wr()||r.deferInTerminal&&Ur())return;let i=xe(n);i&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`keydown`,t)}},[]),null}var Kr=4e3;function qr(){let[e,t]=(0,K.useState)(`hidden`),n=(0,K.useRef)(e);n.current=e,(0,K.useEffect)(()=>{let e=null,r=G.onConnectionChange(r=>{if(r){e!==null&&clearTimeout(e),e=null,n.current===`lost`&&t(`hidden`);return}e!==null||n.current!==`hidden`||(e=setTimeout(()=>{e=null,n.current===`hidden`&&t(`lost`)},Kr))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,K.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Ir.refresh()||(v.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(G.isConnected()?`hidden`:`lost`)))},[]);return(0,K.useEffect)(()=>Rr(()=>void r()),[r]),e===`hidden`?null:(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 bg-elevated px-3 py-2`,children:[(0,q.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:e===`refreshing`?`Restarting the cockpit.`:`Connection to the daemon lost.`}),e===`lost`&&(0,q.jsxs)(I,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,q.jsx)(xt,{}),`Refresh connection`]})]})}function Jr({label:e,percentage:t,hint:n}){let r=Math.max(0,Math.min(100,t));return(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`w-24 shrink-0 truncate text-2xs text-fg-muted`,title:e,children:e}),(0,q.jsx)(`span`,{className:`relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-border`,children:(0,q.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full ${r>=90?`bg-danger`:r>=75?`bg-warning`:`bg-action`}`,style:{width:`${r}%`}})}),(0,q.jsxs)(`span`,{className:`shrink-0 text-2xs tabular-nums text-fg-muted`,children:[Math.round(r),`%`,n?` · ${n}`:``]})]})}function Yr(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Xr(e){if(e===null)return`never`;let t=new Date(e).getTime(),n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<60)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function Zr({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=te(e.id),a=e.logged_in?n:r?t:null,o=i.data?.subscription;return(0,q.jsxs)(`div`,{className:`rounded-md px-2 py-2 transition-colors hover:bg-elevated`,children:[(0,q.jsxs)(`button`,{type:`button`,disabled:a===null,onClick:()=>a?.(),className:`flex w-full items-center gap-3 text-left disabled:cursor-default`,children:[(0,q.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.logged_in?`bg-success`:`bg-idle`}`,"aria-hidden":!0}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.label}),(0,q.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[e.logged_in?`logged in`:`logged out`,i.data&&(0,q.jsxs)(q.Fragment,{children:[` · `,i.data.session_count,` session`,i.data.session_count===1?``:`s`,i.data.active_session_count>0&&` (${i.data.active_session_count} active)`,` · `,`last `,Xr(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,q.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[Yr(i.data.agent_usage.input_tokens),` in ·`,` `,Yr(i.data.agent_usage.output_tokens),` out ·`,` `,Yr(i.data.agent_usage.cache_read_input_tokens),` cached ·`,` `,i.data.agent_usage.message_count,` msgs`]}),i.data?.live_usage?.context_used_percentage!=null&&(0,q.jsx)(`span`,{className:`mt-1 block`,children:(0,q.jsx)(Jr,{label:`context`,percentage:i.data.live_usage.context_used_percentage})})]}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted`,children:r?e.logged_in?n?`new agent`:``:(0,q.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,q.jsx)(an,{className:`size-3`}),`sign in`]}):`unavailable`})]}),o!=null&&o.windows.length>0&&(0,q.jsx)(`div`,{className:`mt-2 flex flex-col gap-1 pl-5`,children:o.windows.map(e=>(0,q.jsx)(Jr,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function Qr(){let[e,t]=(0,K.useState)(!1),[n,r]=(0,K.useState)(!1),i=E(),a=Me(),o=we(),s=a.data?.find(e=>e.id===i),c=re(i??void 0),l=oe(),u=Re(),{open:d,handler:f}=Tt(),[p,m]=(0,K.useState)(null),h=e=>u.mutate(e.id,{onSuccess:t=>m({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>W(e)}),g=e=>{t(!1),d({accountId:e.id})};return n&&s?(0,q.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-3`,children:[(0,q.jsx)(qt,{icon:s.icon,colour:s.icon_colour}),(0,q.jsx)(Pt,{initial:s.name,maxLength:100,className:H(`w-32 text-sm`,$t(s.icon_colour)),onCommit:e=>{r(!1);let t=e.trim();!i||!t||t===s?.name||o.mutate({id:i,name:t},{onError:e=>W(e)})},onCancel:()=>r(!1)})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Xt,{open:e,onOpenChange:t,children:[(0,q.jsxs)(V,{children:[(0,q.jsx)(B,{asChild:!0,children:(0,q.jsx)(Kt,{asChild:!0,children:(0,q.jsxs)(I,{variant:`ghost`,size:`sm`,className:`font-sans compact:h-7 compact:px-1.5`,children:[(0,q.jsx)(qt,{icon:s?.icon,colour:s?.icon_colour}),(0,q.jsx)(`span`,{className:$t(s?.icon_colour),...Ut(()=>{t(!1),r(!0)}),children:s?.name??`…`})]})})}),(0,q.jsx)(z,{children:`Profile`})]}),(0,q.jsxs)(rn,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(l.data??[]).map(e=>{let t=c.data?.filter(t=>t.agent_type===e.id)??[];if(t.length===0)return null;let n=e.available!==!1;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`px-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:[e.display_name,!n&&(0,q.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:[`not installed — no `,e.binary??e.id,` on PATH`]})]}),t.map(e=>(0,q.jsx)(Zr,{account:e,onLogin:()=>h(e),onStartSession:f&&n?()=>g(e):null,installed:n},e.id))]},e.id)}),c.data?.length===0&&(0,q.jsx)(`p`,{className:`px-2 text-sm text-fg-muted`,children:`No accounts yet — add one in settings.`})]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,q.jsxs)(I,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),ht(`accounts`)},children:[(0,q.jsx)(_t,{}),`Add account`]}),(0,q.jsxs)(I,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),Ve.set(null)},children:[(0,q.jsx)(Fn,{}),`Switch profile`]})]})]})]}),p&&(0,q.jsx)(Gt,{stream:p.stream,label:p.label,onClose:()=>m(null)})]})}var $r=`desktop-update`;function ei(){let e=(0,K.useRef)(null);return(0,K.useEffect)(()=>{let t=ce();if(t?.updateReady===void 0||t.onUpdateReady===void 0)return;let n=t=>{e.current!==t&&(e.current=t,v(`Puddle ${t} is downloaded and ready.`,{id:$r,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{ce()?.installUpdate?.(),v.loading(`Restarting into Puddle ${t}…`,{id:`${$r}-restarting`,duration:1/0})}}}))};return t.updateReady().then(e=>{e!==null&&n(e)}),t.onUpdateReady(n)},[]),null}function ti(){let e=E(),t=Me().data?.find(t=>t.id===e),n=Ie(e??void 0),r=le(e??void 0,void 0),i=c(),a=en(),o=Yt(),u=Ae(e??``),d=we(),f=me(),[m,g]=(0,K.useReducer)(e=>e+1,0);(0,K.useEffect)(()=>h(()=>g()),[]);let _=(0,K.useRef)(null);(0,K.useEffect)(()=>{_.current=null},[t?.name]);let v=a.data?.available===!0?a.data.file:void 0,y=t!==void 0&&e!==null&&n.data!==void 0&&r.data!==void 0&&v!==void 0,b=t&&v?Zt(v,t.name):void 0,x=u.isPending||d.isPending||f.isPending||o.isPending||n.isFetching||r.isFetching;(0,K.useEffect)(()=>{if(!y||!b?.enabled||x)return;let a={client:i,theme:s(),profileSettings:n.data,profile:t,scratchpad:r.data},c={setClient:e=>l(e),setTheme:e=>{typeof e==`string`&&p(e)},patchProfileSettings:e=>u.mutate(e),patchProfileColumns:t=>d.mutate({id:e,...t}),createScratchpad:t=>{for(let n of t)f.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},m=JSON.stringify(b.doc);if(_.current!==m){_.current=m,Qt(b.doc,c,a,b.groups);return}let h=tn(b.groups,a),g=JSON.stringify(h);g!==m&&(_.current=g,o.mutate({profile:t.name,entry:{...b,doc:h,updatedAt:new Date().toISOString()}}))})}var ni={desktop:!0,sound:!1,muted_projects:[]};function ri(e){return e.prefs.muted_projects.includes(e.projectId)?{desktop:!1,sound:!1}:{desktop:e.prefs.desktop&&e.permission===`granted`&&!e.windowFocused,sound:e.prefs.sound}}function ii(e,t){for(let[,n]of e.getQueriesData({queryKey:[`sessions`]})){let e=n?.find(e=>e.id===t);if(e)return e}for(let[,n]of e.getQueriesData({queryKey:[`project`]})){let e=n?.sessions.find(e=>e.id===t);if(e)return e}}function ai(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function oi(){try{let e=new AudioContext,t=e.createGain();t.gain.value=.04,t.connect(e.destination);for(let[n,r]of[[880,0],[1318.5,.09]]){let i=e.createOscillator();i.type=`sine`,i.frequency.value=n,i.connect(t),i.start(e.currentTime+r),i.stop(e.currentTime+r+.12)}setTimeout(()=>void e.close(),400)}catch{}}function si(){let e=ie(),t=et(),n=Ie(E()??void 0),r=(0,K.useRef)(ni);r.current={...ni,...n.data?.notifications??{}};let i=ke(Be().data)??`Puddle`,a=(0,K.useRef)(i);(0,K.useEffect)(()=>{document.title===a.current&&(document.title=i),a.current=i},[i]),(0,K.useEffect)(()=>{let n=new Set,i=()=>{document.title=n.size>0?`(${n.size}) ${a.current}`:a.current},o=G.onStatus(a=>{let o=n.has(a.session);a.status===`waiting_input`?n.add(a.session):n.delete(a.session),i(),!(a.status!==`waiting_input`||o)&&(async()=>{let n=ii(e,a.session);if(!n)try{n=(await T(e)).find(e=>e.id===a.session)}catch{return}if(!n||n.kind===`terminal`)return;let i=n,o=ri({prefs:r.current,projectId:i.project_id,windowFocused:document.hasFocus(),permission:nn()});if(o.sound&&oi(),o.desktop){let e=new Notification(ai(i),{body:`Waiting for your input`,tag:`puddle-waiting-${i.id}`});e.onclick=()=>{ce()?.raiseWindow(),window.focus(),t(`/project/${i.project_id}/session/${i.id}`),e.close()}}})()});return()=>{o(),document.title=a.current}},[e,t])}function ci({initial:e,defaultScope:t,allowProject:n=!0,agents:r,onSave:i,onCancel:a}){let[o,s]=(0,K.useState)(e?.title??``),[c,l]=(0,K.useState)(e?.body??``),[u,d]=(0,K.useState)(n?e?.scope??t:`profile`),[f,p]=(0,K.useState)((e?.tags??[]).join(`, `)),[m,h]=(0,K.useState)(e?.agent_type??null),g=()=>{let e=c.trim();e&&i({title:o.trim()||null,body:e,scope:u,tags:f.split(`,`).map(e=>e.trim()).filter(Boolean),agent_type:m})};return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(L,{value:o,placeholder:`Title (optional)`,spellCheck:!1,onChange:e=>s(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-9 text-sm font-medium`}),(0,q.jsx)(ut,{autoFocus:!0,value:c,placeholder:`Prompt or note…`,spellCheck:!1,rows:10,onChange:e=>l(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?a():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&g()},className:`resize-y text-sm leading-relaxed`}),(0,q.jsx)(L,{value:f,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-8 text-xs`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,q.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,q.jsx)(bt,{checked:u===`profile`,onCheckedChange:e=>d(e?`profile`:`project`)}),`Profile-wide`]}),(0,q.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:r.map(e=>(0,q.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":m===e.id,onClick:()=>h(t=>t===e.id?null:e.id),className:H(`rounded-md p-1 transition-colors`,m===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,q.jsx)(Et,{type:e.id,className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,q.jsx)(I,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,q.jsx)(I,{size:`sm`,disabled:!c.trim(),onClick:g,children:`Save`})]})]})}function li(){let e=Ct(),t=E(),n=$e().id,r=le(t??void 0,n).data??[],i=oe().data??[],a=me(),o=Te(),s=ye(),c=kt(),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(null),[_,y]=(0,K.useState)(null);(0,K.useEffect)(()=>Ce(`scratchpad.toggle`,Ot),[]),(0,K.useEffect)(()=>{e||(u(null),f(null),m(null))},[e]);let b=(0,K.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),x=(0,K.useMemo)(()=>[...new Set(r.map(e=>e.agent_type).filter(e=>e!==null))],[r]),S=d!==null||p!==null,C=r.filter(e=>(d===null||e.tags.includes(d))&&(p===null||e.agent_type===p)),w=S?C:_??r,T=e=>{t&&(a.mutate({profile_id:t,scope:e.scope,project_id:e.scope===`project`?n:void 0,title:e.title??void 0,body:e.body,tags:e.tags,agent_type:e.agent_type??void 0}),u(null))},D=(e,t)=>{o.mutate({id:e,scope:t.scope,project_id:t.scope===`project`?n??null:null,title:t.title,body:t.body,tags:t.tags,agent_type:t.agent_type}),u(null)},O=(e,t)=>{let n=_??r,i=n.findIndex(t=>t.id===e),a=n.findIndex(e=>e.id===t);if(i===-1||a===-1||i===a)return;let o=n.slice(),[s]=o.splice(i,1);o.splice(a,0,s),y(o)},k=()=>{let e=h,t=_;if(g(null),y(null),e===null||!t)return;let n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t[n-1],i=t[n+1],a=r?i?(r.position+i.position)/2:r.position+1:(i?i.position:0)-1;o.mutate({id:e,position:a})},A=e=>{navigator.clipboard?.writeText(e.body),v.success(`Copied to clipboard`)};return(0,q.jsxs)(Xt,{open:e,onOpenChange:wt,children:[(0,q.jsxs)(V,{children:[(0,q.jsx)(B,{asChild:!0,children:(0,q.jsx)(Kt,{asChild:!0,children:(0,q.jsxs)(I,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,q.jsx)(Nn,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,q.jsx)(z,{children:`Scratchpad`})]}),(0,q.jsxs)(rn,{className:`w-[34rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,q.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>u(l===`new`?null:`new`),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,q.jsx)(_t,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(b.length>0||x.length>0)&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[b.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(t=>t===e?null:e),className:H(`rounded-full px-2 py-0.5 text-2xs transition-colors`,d===e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:e},e)),x.map(e=>(0,q.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>m(t=>t===e?null:e),className:H(`rounded-md p-1 transition-colors`,p===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,q.jsx)(Et,{type:e,className:`size-3.5`})},e))]}),(0,q.jsxs)(`div`,{className:`no-scrollbar max-h-[65vh] overflow-y-auto px-2 pb-3`,children:[l===`new`&&(0,q.jsx)(`div`,{className:`px-3 py-2`,children:(0,q.jsx)(ci,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:i,onSave:T,onCancel:()=>u(null)})}),w.length===0&&l!==`new`&&(0,q.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:S?`Nothing matches this filter.`:`No entries yet — press + to add a reusable prompt or note.`}),(0,q.jsx)(`ul`,{className:`flex flex-col`,children:w.map(e=>l===e.id?(0,q.jsx)(`li`,{className:`px-3 py-2`,children:(0,q.jsx)(ci,{initial:e,defaultScope:e.scope,allowProject:n!==void 0||e.scope===`project`,agents:i,onSave:t=>D(e.id,t),onCancel:()=>u(null)})},e.id):(0,q.jsx)(`li`,{draggable:!S&&l===null,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,g(e.id)},onDragOver:t=>{h!==null&&(t.preventDefault(),h!==e.id&&O(h,e.id))},onDragEnd:k,className:H(`transition-opacity`,h===e.id&&`opacity-50`),children:(0,q.jsx)(ui,{entry:e,onInsert:c?()=>{c(e.body),wt(!1)}:null,onCopy:()=>A(e),onEdit:()=>u(e.id),onDelete:()=>s.mutate(e.id)})},e.id))})]})]})]})}function ui({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let[a,o]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{onClick:e=>{e.target.closest(`button`)||r()},className:`cursor-pointer rounded-md px-3 py-2.5 transition-colors hover:bg-surface`,children:[e.title&&(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,q.jsx)(`p`,{className:H(`line-clamp-3 whitespace-pre-wrap text-sm text-fg-secondary`,e.title&&`mt-0.5`),children:e.body}),a?(0,q.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),i()},className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:`Delete`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]}):(0,q.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile-wide`:`Project`}),e.agent_type&&(0,q.jsx)(Et,{type:e.agent_type,className:`size-3 text-fg-gold`}),e.tags.map(e=>(0,q.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-2xs text-fg-secondary`,children:e},e)),(0,q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[t&&(0,q.jsx)(di,{icon:An,label:`Insert into focused terminal`,onClick:t}),(0,q.jsx)(di,{icon:Ke,label:`Copy`,onClick:n}),(0,q.jsx)(di,{icon:ft,label:`Edit`,onClick:r}),(0,q.jsx)(di,{icon:yt,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function di({icon:e,label:t,onClick:n}){return(0,q.jsxs)(V,{children:[(0,q.jsx)(B,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(e,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,q.jsx)(z,{children:t})]})}var fi=a.parse({});function pi(e,t){let[n,r]=(0,K.useState)(null),i=O(t).data,a=De(e??void 0,t&&e!==null).data;return(0,K.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=Ht(sessionStorage.getItem(Vt(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return ae(e).then(e=>{n||r(e?e.ui_state:fi)}).catch(()=>{n||r(fi)}),()=>{n=!0}},[t,e]),(0,K.useMemo)(()=>{if(!t||e===null||n===null)return null;let o=t=>{if(!i||!a)return!1;let{patch:o,projectBased:s}=It(n,t,{alive:new Set(i.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(i.map(e=>[e.id,e.project_id])),projectIds:a.map(e=>e.id),currentProject:null}),c={...n,...o};r(c),x(e,c).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(Vt(e),JSON.stringify(c))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}return d().projectBasedLayout!==s&&l({projectBasedLayout:s}),!0},s=Object.fromEntries(Object.entries(n.project_layouts).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:R(t.layout_tree)}]));return(n.layout_mode??`profile`)===`project`?{headless:!0,scope:`project`,projectId:``,layoutRef:null,signature:R(null),slices:s,capture:()=>({layout_tree:null,active_session:null}),apply:o}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:R(n.layout_tree),slices:s,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),apply:o}},[t,e,n,i,a])}var mi=R(null);function hi(){let e=Lt(),t=et(),n=E(),r=zt(),i=pi(n,e&&r===null),a=r??i,o=Ne(n??void 0,void 0).data??[],s=De(n??void 0,e&&n!==null).data??[],c=S(),l=ze(),u=_e(),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(null);(0,K.useEffect)(()=>Ce(`layouts.toggle`,Ft),[]),(0,K.useEffect)(()=>{e||(f(``),m(!1),g(null))},[e]);let _=a?.headless===!0,y=a===null||_?null:o.find(e=>e.id===a.layoutRef)??null,b=a!==null&&!_&&(y===null?a.signature!==mi:R(y.layout_tree)!==a.signature),x=e=>{let t=a?.slices?.[e];if(!t)return!1;let n=t.layoutRef===null?null:o.find(e=>e.id===t.layoutRef)??null;return n?R(n.layout_tree)!==t.signature:t.signature!==mi},C=e=>a===null?!1:e.scope===`profile`?a.scope===`profile`&&b:e.project_id===null?!1:a.scope===`project`?!_&&e.project_id===a.projectId?b:x(e.project_id):b||x(e.project_id),w=e=>y!==null&&e.id===y.id,T=e=>(e===null?void 0:s.find(t=>t.id===e)?.name)??`Project`,D=a!==null&&!_&&a.scope===`project`?o.filter(e=>e.scope===`profile`||e.project_id===a.projectId):o,O=[...D.some(e=>e.scope===`profile`)?[{key:`profile`,name:`Profile-wide`}]:[],...[...new Set(D.flatMap(e=>e.project_id===null?[]:[e.project_id]))].map(e=>({key:e,name:T(e)})).sort((e,t)=>e.name.localeCompare(t.name))],k=h===null?D:h===`profile`?D.filter(e=>e.scope===`profile`):D.filter(e=>e.project_id===h),A=e=>a!==null&&e.scope===a.scope&&(a.scope===`profile`||e.project_id===a.projectId),j=(e,t,r)=>{!a||!n||c.mutate({profile_id:n,scope:a.scope,project_id:a.scope===`project`?a.projectId:void 0,name:e,...t},{onSuccess:e=>{r&&a.apply(e)},onError:e=>W(e)})},M=e=>{if(!a)return;let t=A(e)?e:o.find(t=>t.name===e.name&&A(t));if(!t){j(e.name,a.capture(),!0);return}l.mutate({id:t.id,...a.capture()},{onSuccess:e=>a.apply(e),onError:e=>W(e)})},ee=(e,t)=>j(t,{layout_tree:e.layout_tree,active_session:e.active_session},!1),N=e=>{if(a){if(!a.apply(e)){v.error(`Workspace is still loading — try again in a moment`);return}e.project_id!==null&&e.project_id!==a.projectId&&t(`/project/${e.project_id}`),Nt(!1)}};return(0,q.jsxs)(Xt,{open:e,onOpenChange:Nt,children:[(0,q.jsxs)(V,{children:[(0,q.jsx)(B,{asChild:!0,children:(0,q.jsx)(Kt,{asChild:!0,children:(0,q.jsxs)(I,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,q.jsx)(jn,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,q.jsx)(z,{children:`Layouts`})]}),(0,q.jsxs)(rn,{className:`w-[26rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,q.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Layouts`}),a!==null&&!_&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,q.jsx)(_t,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),a===null?(0,q.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):_?(0,q.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Project-based layout is on — every project keeps its own layout. Open a project to name or save it; loading works from here.`}):(y===null||p)&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[y===null&&(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:`Unnamed layout`}),(0,q.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:a.scope===`profile`?`Profile-wide`:`Project`}),(0,q.jsx)(`span`,{className:`ml-auto text-2xs text-interrupted`,children:`Unsaved`})]}),(0,q.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault();let t=d.trim();t&&(j(t,a.capture(),!0),f(``),m(!1))},children:[(0,q.jsx)(L,{autoFocus:p,value:d,placeholder:y===null?`Name this layout…`:`Save as a new layout…`,spellCheck:!1,onChange:e=>f(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&m(!1)},className:`h-8 flex-1 text-sm`}),(0,q.jsx)(I,{size:`sm`,type:`submit`,disabled:!d.trim(),children:`Save`}),y!==null&&(0,q.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>m(!1),children:`Cancel`})]})]}),O.length>1&&(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:O.map(e=>(0,q.jsx)(vi,{active:h===e.key,onClick:()=>g(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,q.jsxs)(`div`,{className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[k.length===0&&(0,q.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:h===null?`No layouts yet — name and save the current layout to keep it.`:`Nothing matches this filter.`}),(0,q.jsx)(`ul`,{className:`flex flex-col`,children:k.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(gi,{layout:e,projectLabel:e.scope===`profile`?null:T(e.project_id),isCurrent:w(e),dirty:b,loadable:a!==null,savable:a!==null&&!_,confirmBeforeLoad:C(e),overwrites:A(e),onLoad:()=>N(e),onRename:t=>l.mutate({id:e.id,name:t}),onDelete:()=>u.mutate(e.id),onSaveAs:()=>M(e),onDuplicate:t=>ee(e,t)})},e.id))})]})]})]})}function gi({layout:e,projectLabel:t,isCurrent:n,dirty:r,loadable:i,savable:a,confirmBeforeLoad:o,overwrites:s,onLoad:c,onRename:l,onDelete:u,onSaveAs:d,onDuplicate:f}){let[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(null),[_,v]=(0,K.useState)(e.name),y=()=>{if(!(!i||h!==null)){if(o&&p!==`load`){m(`load`);return}m(null),c()}},b=t=>{m(null),v(t===`rename`?e.name:`${e.name} copy`),g(t)},x=()=>{if(n){d();return}m(`save`)},S=n?r?`unsaved`:`active`:null;return(0,q.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||y()},className:H(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[h===null?(0,q.jsxs)(`p`,{className:H(`flex items-baseline gap-2 text-sm font-medium`,S===`active`?`text-success`:S===`unsaved`?`text-interrupted`:`text-fg`),children:[e.name,S!==null&&(0,q.jsx)(`span`,{className:`text-2xs font-normal`,children:S===`active`?`Active`:`Unsaved`})]}):(0,q.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:t=>{t.preventDefault();let n=_.trim();n&&(h===`rename`?n!==e.name&&l(n):f(n)),g(null)},children:[(0,q.jsx)(L,{autoFocus:!0,value:_,spellCheck:!1,onChange:e=>v(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&g(null)},className:`h-7 flex-1 text-sm`}),(0,q.jsx)(I,{size:`sm`,type:`submit`,disabled:!_.trim(),children:h===`rename`?`Rename`:`Save`})]}),p===`save`?(0,q.jsx)(_i,{question:s?`Overwrite “${e.name}” with the current layout?`:`Save the current layout as “${e.name}” here?`,verb:s?`Overwrite`:`Save`,onConfirm:()=>{m(null),d()},onCancel:()=>m(null)}):p===`delete`?(0,q.jsx)(_i,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{m(null),u()},onCancel:()=>m(null)}):p===`load`?(0,q.jsx)(_i,{question:`Loading discards unsaved layout changes.`,verb:`Load`,onConfirm:y,onCancel:()=>m(null)}):(0,q.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[t!==null&&(0,q.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:t}),(0,q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(yi,{icon:Pn,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:x}),(0,q.jsx)(yi,{icon:Ke,label:`Duplicate`,onClick:()=>b(`duplicate`)})]}),(0,q.jsx)(yi,{icon:ft,label:`Rename`,onClick:()=>b(`rename`)}),(0,q.jsx)(yi,{icon:yt,label:`Delete`,onClick:()=>m(`delete`)})]})]})]})}function _i({question:e,verb:t,onConfirm:n,onCancel:r}){return(0,q.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e}),(0,q.jsx)(`button`,{type:`button`,onClick:n,className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:t}),(0,q.jsx)(`button`,{type:`button`,onClick:r,className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]})}function vi({active:e,onClick:t,children:n}){return(0,q.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:H(`rounded-full px-2 py-0.5 text-2xs transition-colors`,e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:n})}function yi({icon:e,label:t,onClick:n}){return(0,q.jsxs)(V,{children:[(0,q.jsx)(B,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(e,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,q.jsx)(z,{children:t})]})}var bi=ce()!==void 0&&/Mac/.test(navigator.platform),xi=(0,K.lazy)(()=>g(()=>import(`./SettingsDialog-VAdM-npo.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function Si(){let e=ie();(0,K.useEffect)(()=>{let t=t=>{for(let[n,r]of e.getQueriesData({queryKey:[`sessions`]}))r&&e.setQueryData(n,r.map(t));for(let[n,r]of e.getQueriesData({queryKey:[`project`]}))r&&e.setQueryData(n,{...r,sessions:r.sessions.map(t)})},n=G.onStatus(e=>t(t=>t.id===e.session?{...t,status:e.status,last_activity_at:e.last_activity_at}:t)),r=G.onRenamed(e=>t(t=>t.id===e.session?{...t,title:e.title,agent_title:`agent_title`in e?e.agent_title:t.agent_title,osc_title:`osc_title`in e?e.osc_title:t.osc_title}:t)),i=G.onAccount(t=>{for(let[n,r]of e.getQueriesData({queryKey:[`accounts`]}))r&&e.setQueryData(n,r.map(e=>e.id===t.account_id?{...e,logged_in:t.logged_in}:e))}),a=t=>{e.invalidateQueries({queryKey:[`sessions`]});for(let n of t)e.invalidateQueries({queryKey:[`project`,n]})},o=G.onSessionsChanged(e=>a(e.project_ids)),s=G.onSessionSwitched(e=>a([e.target_project]));return()=>{n(),r(),i(),o(),s()}},[e])}function Ci(){let e=Be(),t=Pe(),[n,r]=(0,K.useState)(!1),i=ke(e.data),a=n=>{r(!1);let a=n.trim();a!==i&&t.mutate({displayName:a===e.data?.hostname?``:a},{onError:e=>W(e)})},o=!bi&&(0,q.jsx)(`img`,{src:`/puddle.svg`,alt:`Puddle`,className:`size-4`}),s=H(`flex shrink-0 items-center gap-2`,bi&&`[-webkit-app-region:no-drag]`),c=`truncate text-sm font-semibold text-fg-secondary`;return n&&i!==void 0?(0,q.jsxs)(`div`,{className:s,children:[o,(0,q.jsx)(Pt,{initial:e.data?.displayName??i,maxLength:64,className:H(c,`w-40`),onCommit:a,onCancel:()=>r(!1)})]}):(0,q.jsxs)(Je,{to:`/`,className:H(s,`transition-opacity hover:opacity-70`),title:`All projects`,children:[o,i!==void 0&&(0,q.jsx)(`span`,{className:c,...Ut(()=>r(!0)),children:i})]})}function wi(){let e=$e(),t=w(`palette.toggle`),n=Oe(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,q.jsxs)(`button`,{type:`button`,onClick:Dt,className:H(`absolute left-1/2 flex h-6 w-[min(30rem,42%)] -translate-x-1/2 items-center justify-center gap-2 rounded-md bg-ground text-fg-muted transition-colors hover:bg-elevated hover:text-fg-secondary`,bi&&`[-webkit-app-region:no-drag]`),children:[(0,q.jsx)(`span`,{className:`truncate text-xs`,children:r??`Puddle`}),(0,q.jsx)(`span`,{className:`text-2xs`,children:t})]})}function Ti(){let{fullScreen:e,animate:t}=b();return(0,q.jsxs)(`header`,{className:H(`relative flex h-9 shrink-0 items-center gap-3 bg-surface pl-3 pr-3`,bi&&!e&&`pl-[88px] [-webkit-app-region:drag]`,t&&`transition-[padding] duration-200 ease-out`),children:[(0,q.jsx)(Ci,{}),(0,q.jsx)(wi,{}),(0,q.jsxs)(`div`,{className:H(`ml-auto flex items-center`,bi&&`[-webkit-app-region:no-drag]`),children:[(0,q.jsxs)(V,{children:[(0,q.jsx)(B,{asChild:!0,children:(0,q.jsxs)(I,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>ht(),children:[(0,q.jsx)(In,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,q.jsx)(z,{children:`Settings`})]}),(0,q.jsx)(hi,{}),(0,q.jsx)(li,{}),(0,q.jsx)(Qr,{})]})]})}function Ei(){Si(),ti(),si();let{handler:e}=Tt(),t=E(),{pathname:n}=Xe(),[r,i]=(0,K.useState)(!1),a=ee(),o=a.data!==void 0&&Se(a.data.protocol);return(0,K.useEffect)(()=>{if(!o)return;let e=()=>{let e=u();G.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),h(e)},[o]),(0,q.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[(0,q.jsx)(Ti,{}),(0,q.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,q.jsx)(fn,{resetOn:n,scope:n.startsWith(`/project/`)?`workspace`:`view`,children:(0,q.jsx)(Qe,{})})}),(0,q.jsx)(qr,{}),(0,q.jsx)(ei,{}),(0,q.jsx)(Hr,{onNewSession:e??void 0,onNewProject:()=>i(!0)}),t!==null&&(0,q.jsx)(on,{profileId:t,open:r,onOpenChange:i}),(0,q.jsx)(K.Suspense,{fallback:null,children:(0,q.jsx)(xi,{})}),(0,q.jsx)(Gr,{})]})}function Di(){return(0,q.jsx)(Bt,{children:(0,q.jsx)(Ei,{})})}var Oi=(0,K.lazy)(()=>g(()=>import(`./Dashboard-DdqyCWkG.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([20,1,2,3,4,6,5,21,10,7,8,9,11,22,16,23,19,18,24]))),ki=(0,K.lazy)(()=>g(()=>import(`./Workspace-BO11vRQa.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([25,1,2,3,4,5,6,26,10,27,21,7,8,9,11,12,28,29,30,22,16,31,24,14,15,18,32,33,34,35,36]))),Ai=new dn({defaultOptions:{queries:{retry:1,staleTime:5e3}},mutationCache:new cn({onError:e=>W(e)})});function ji(){let e=E(),t=Me(),n=e!==null&&t.data!==void 0&&!t.data.some(t=>t.id===e);return e===null||n?(0,q.jsx)(Ln,{}):(0,q.jsx)(tt,{useTransitions:!1,children:(0,q.jsx)(K.Suspense,{fallback:null,children:(0,q.jsx)(Ye,{children:(0,q.jsxs)(nt,{element:(0,q.jsx)(Di,{}),children:[(0,q.jsx)(nt,{path:`/`,element:(0,q.jsx)(Oi,{})}),(0,q.jsx)(nt,{path:`/project/:id`,element:(0,q.jsx)(ki,{})}),(0,q.jsx)(nt,{path:`/project/:id/session/:sid`,element:(0,q.jsx)(ki,{})})]})})})})}function Mi(){let e=(0,K.useSyncExternalStore)(_.subscribe,_.get);return(0,q.jsx)(ne,{client:Ai,children:(0,q.jsxs)(Mt,{delayDuration:300,children:[(0,q.jsx)(kn,{}),(0,q.jsx)(fn,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,q.jsx)(sn,{}):(0,q.jsx)(ji,{}):(0,q.jsx)(mn,{})}),(0,q.jsx)(pn,{})]})})}export{Mi as App};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-B297I2Hn.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/index-CIyjjiv2.js","assets/index-Bwl8S5Du.css","assets/dist-sv8JIOv-.js","assets/protocol-support-B2anXRJW.js","assets/copy-DO0WkB3-.js","assets/createLucideIcon-DyMAgLa3.js","assets/x-CZCUod6A.js","assets/selection-actions-BTyYbd08.js","assets/button-CZSpHYG9.js","assets/ws-ClWC7CMz.js","assets/FindWidget-B4wnVQS_.js","assets/chevron-down--sjpQEHH.js","assets/code-DRWf9a5s.js","assets/errors-wktZNO7z.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,rt as r,t as i}from"./index-CIyjjiv2.js";import{S as a,w as o,x as s,y as c}from"./dialog-cFDquLR6.js";import{a as l}from"./button-CZSpHYG9.js";import{n as u}from"./x-CZCUod6A.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";var f=e(t(),1),p=[`top`,`right`,`bottom`,`left`],m=Math.min,h=Math.max,g=Math.round,_=Math.floor,v=e=>({x:e,y:e}),y={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function b(e,t,n){return h(e,m(t,n))}function x(e,t){return typeof e==`function`?e(t):e}function S(e){return e.split(`-`)[0]}function C(e){return e.split(`-`)[1]}function w(e){return e===`x`?`y`:`x`}function T(e){return e===`y`?`height`:`width`}function E(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function D(e){return w(E(e))}function O(e,t,n){n===void 0&&(n=!1);let r=C(e),i=D(e),a=T(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=L(o)),[o,L(o)]}function k(e){let t=L(e);return[A(e),t,A(t)]}function A(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var j=[`left`,`right`],M=[`right`,`left`],N=[`top`,`bottom`],P=[`bottom`,`top`];function F(e,t,n){switch(e){case`top`:case`bottom`:return n?t?M:j:t?j:M;case`left`:case`right`:return t?N:P;default:return[]}}function I(e,t,n,r){let i=C(e),a=F(S(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(A)))),a}function L(e){let t=S(e);return y[t]+e.slice(t.length)}function R(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function z(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:R(e)}function B(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ee(e,t,n){let{reference:r,floating:i}=e,a=E(t),o=D(t),s=T(o),c=S(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=C(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function te(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=x(t,e),p=z(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ne=50,re=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:te},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ee(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ne&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ee(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ie=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=x(e,t)||{};if(l==null)return{};let d=z(u),f={x:n,y:r},p=D(i),h=T(p),g=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,S=_?`clientHeight`:`clientWidth`,w=a.reference[h]+a.reference[p]-f[p]-a.floating[h],E=f[p]-a.reference[p],O=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),k=O?O[S]:0;(!k||!await(o.isElement==null?void 0:o.isElement(O)))&&(k=s.floating[S]||a.floating[h]);let A=w/2-E/2,j=k/2-g[h]/2-1,M=m(d[v],j),N=m(d[y],j),P=k-g[h]-N,F=k/2-g[h]/2+A,I=b(M,F,P),L=!c.arrow&&C(i)!=null&&F!==I&&a.reference[h]/2-(F<M?M:N)-g[h]/2<0,R=L?F<M?F-M:F-P:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),ae=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=x(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=S(r),_=E(o),v=S(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[L(o)]:k(o)),C=p!==`none`;!d&&C&&b.push(...I(o,m,p,y));let w=[o,...b],T=await s.detectOverflow(t,h),D=[],A=i.flip?.overflows||[];if(l&&D.push(T[g]),u){let e=O(r,a,y);D.push(T[e[0]],T[e[1]])}if(A=[...A,{placement:r,overflows:D}],!D.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=w[e];if(t&&(!(u===`alignment`&&_!==E(t))||A.every(e=>E(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:A},reset:{placement:t}};let n=A.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=A.filter(e=>{if(C){let t=E(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function oe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function se(e){return p.some(t=>e[t]>=0)}var ce=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=x(e,t);switch(i){case`referenceHidden`:{let e=oe(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:se(e)}}}case`escaped`:{let e=oe(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:se(e)}}}default:return{}}}}},le=new Set([`left`,`top`]);async function ue(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=S(n),s=C(n),c=E(n)===`y`,l=le.has(o)?-1:1,u=a&&c?-1:1,d=x(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var de=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await ue(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},fe=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=x(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=E(i),p=w(f),m=u[p],h=u[f],g=(e,t)=>b(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},pe=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=x(e,t),u={x:n,y:r},d=E(i),f=w(d),p=u[f],m=u[d],h=x(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=le.has(S(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},me=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=x(e,t),c=await i.detectOverflow(t,s),l=S(n),u=C(n),d=E(n)===`y`,{width:f,height:p}=r.floating,g,_;l===`top`||l===`bottom`?(g=l,_=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(_=l,g=u===`end`?`top`:`bottom`);let v=p-c.top-c.bottom,y=f-c.left-c.right,b=m(p-c[g],v),w=m(f-c[_],y),T=t.middlewareData.shift,D=!T,O=b,k=w;T!=null&&T.enabled.x&&(k=y),T!=null&&T.enabled.y&&(O=v),D&&!u&&(d?k=f-2*h(c.left,c.right):O=p-2*h(c.top,c.bottom)),await o({...t,availableWidth:k,availableHeight:O});let A=await i.getDimensions(a.floating);return f!==A.width||p!==A.height?{reset:{rects:!0}}:{}}}};function he(){return typeof window<`u`}function V(e){return ge(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((ge(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ge(e){return he()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return he()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return he()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function _e(e){return!he()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function ve(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ye(e){return/^(table|td|th)$/.test(V(e))}function be(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var xe=/transform|translate|scale|rotate|perspective|filter/,Se=/paint|layout|strict|content/,K=e=>!!e&&e!==`none`,Ce;function we(e){let t=W(e)?J(e):e;return K(t.transform)||K(t.translate)||K(t.scale)||K(t.rotate)||K(t.perspective)||!Ee()&&(K(t.backdropFilter)||K(t.filter))||xe.test(t.willChange||``)||Se.test(t.contain||``)}function Te(e){let t=Y(e);for(;G(t)&&!q(t);){if(we(t))return t;if(be(t))return null;t=Y(t)}return null}function Ee(){return Ce??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ce}function q(e){return/^(html|body|#document)$/.test(V(e))}function J(e){return H(e).getComputedStyle(e)}function De(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||_e(e)&&e.host||U(e);return _e(t)?t.host:t}function Oe(e){let t=Y(e);return q(t)?(e.ownerDocument||e).body:G(t)&&ve(t)?t:Oe(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Oe(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=ke(a);return t.concat(a,a.visualViewport||[],ve(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function ke(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ae(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=g(n)!==a||g(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function je(e){return W(e)?e:e.contextElement}function Z(e){let t=je(e);if(!G(t))return v(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ae(t),o=(a?g(n.width):n.width)/r,s=(a?g(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Me=v(0);function Ne(e){let t=H(e);return!Ee()||!t.visualViewport?Me:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pe(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===H(e)}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=je(e),o=v(1);t&&(r?W(r)&&(o=Z(r)):o=Z(e));let s=Pe(a,n,r)?Ne(a):v(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=H(a),t=W(r)?H(r):r,n=e,i=ke(n);for(;i&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=ke(n)}}return B({width:u,height:d,x:c,y:l})}function Fe(e,t){let n=De(e).scrollLeft;return t?t.left+n:Q(U(e)).left+n}function Ie(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Fe(e,n),y:n.top+t.scrollTop}}function Le(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?be(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=v(1),u=v(0),d=G(r);if((d||!a)&&((V(r)!==`body`||ve(o))&&(c=De(r)),d)){let e=Q(r);l=Z(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ie(o,c):v(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Re(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ze(e){let t=De(e),n=e.ownerDocument.body,r=h(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=h(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Fe(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=h(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Be=25;function Ve(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=H(e),a=U(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Ee()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Fe(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Be&&(s-=o)}return{width:s,height:c,x:l,y:u}}function He(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Z(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ue(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ve(e,n,t);else if(t===`document`)r=ze(U(e));else if(W(t))r=He(t,n);else{let n=Ne(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function We(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;W(o)&&!q(o);){let e=J(o),t=we(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Y(o)}return t.set(e,r),r}function Ge(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?be(t)?[]:We(t,this._c):[].concat(n),r],o=Ue(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ue(t,a[e],i);s=h(n.top,s),c=m(n.right,c),l=m(n.bottom,l),u=h(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Ke(e){let{width:t,height:n}=Ae(e);return{width:t,height:n}}function qe(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=Q(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=v(0);if((r||!a)&&((V(t)!==`body`||ve(i))&&(s=De(t)),r)){let e=Q(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Fe(i));let l=i&&!r&&!a?Ie(i,s):v(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Je(e){return J(e).position===`static`}function Ye(e,t){if(!G(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Xe(e,t){let n=H(e);if(be(e))return n;if(!G(e)){let t=Y(e);for(;t&&!q(t);){if(W(t)&&!Je(t))return t;t=Y(t)}return n}let r=Ye(e,t);for(;r&&ye(r)&&Je(r);)r=Ye(r,t);return r&&q(r)&&Je(r)&&!we(r)?n:r||Te(e)||n}var Ze=async function(e){let t=this.getOffsetParent||Xe,n=this.getDimensions,r=await n(e.floating);return{reference:qe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Qe(e){return J(e).direction===`rtl`}var $e={convertOffsetParentRelativeRectToViewportRelativeRect:Le,getDocumentElement:U,getClippingRect:Ge,getOffsetParent:Xe,getElementRects:Ze,getClientRects:Re,getDimensions:Ke,getScale:Z,isElement:W,isRTL:Qe};function et(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function tt(e,t,n){let r=null,i,a=U(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let g=_(d),v=_(a.clientWidth-(u+f)),y=_(a.clientHeight-(d+p)),b=_(u),x={rootMargin:-g+`px `+-v+`px `+-y+`px `+-b+`px`,threshold:h(0,m(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(!et(l,e.getBoundingClientRect()))return s();if(n!==c){if(!S)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}S=!1}try{r=new IntersectionObserver(C,{...x,root:a.ownerDocument})}catch{r=new IntersectionObserver(C,x)}r.observe(e)}let c=H(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function nt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=je(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?tt(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!et(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var rt=de,it=fe,at=ae,ot=me,st=ce,ct=ie,lt=pe,ut=(e,t,n)=>{let r=new Map,i=n??{},a={...$e,...i.platform,_c:r};return re(e,t,{...i,platform:a})},dt=e(r(),1),ft=typeof document<`u`?f.useLayoutEffect:function(){};function pt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!pt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!pt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function mt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ht(e,t){let n=mt(e);return Math.round(t*n)/n}function gt(e){let t=f.useRef(e);return ft(()=>{t.current=e}),t}function _t(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=f.useState(r);pt(p,r)||m(r);let[h,g]=f.useState(null),[_,v]=f.useState(null),y=f.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=f.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=f.useRef(null),w=f.useRef(null),T=f.useRef(u),E=c!=null,D=gt(c),O=gt(i),k=gt(l),A=f.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),ut(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!pt(T.current,t)&&(T.current=t,dt.flushSync(()=>{d(t)}))})},[p,t,n,O,k]);ft(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=f.useRef(!1);ft(()=>(j.current=!0,()=>{j.current=!1}),[]),ft(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=f.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=f.useMemo(()=>({reference:x,floating:S}),[x,S]),P=f.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=ht(N.floating,u.x),r=ht(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...mt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return f.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var vt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ct({element:r.current,padding:i}).fn(n):r?ct({element:r,padding:i}).fn(n):{}}}},yt=(e,t)=>{let n=rt(e);return{name:n.name,fn:n.fn,options:[e,t]}},bt=(e,t)=>{let n=it(e);return{name:n.name,fn:n.fn,options:[e,t]}},xt=(e,t)=>({fn:lt(e).fn,options:[e,t]}),St=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ct=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=vt(e);return{name:n.name,fn:n.fn,options:[e,t]}},$=n(),Et=`Arrow`,Dt=f.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...o}=e;return(0,$.jsx)(a.svg,{...o,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Dt.displayName=Et;var Ot=Dt;function kt(e){let[t,n]=f.useState(void 0);return c(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var At=`Popper`,[jt,Mt]=o(At),[Nt,Pt]=jt(At),Ft=e=>{let{__scopePopper:t,children:n}=e,[r,i]=f.useState(null),[a,o]=f.useState(void 0);return(0,$.jsx)(Nt,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Ft.displayName=At;var It=`PopperAnchor`,Lt=f.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,o=Pt(It,n),s=f.useRef(null),c=o.onAnchorChange,u=l(t,f.useCallback(e=>{s.current=e,e&&c(e)},[c])),d=f.useRef(null);f.useEffect(()=>{if(!r)return;let e=d.current;d.current=r.current,e!==d.current&&c(d.current)});let p=o.placementState&&qt(o.placementState),m=p?.[0],h=p?.[1];return r?null:(0,$.jsx)(a.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...i,ref:u})});Lt.displayName=It;var Rt=`PopperContent`,[zt,Bt]=jt(Rt),Vt=f.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:o=`center`,alignOffset:u=0,arrowPadding:d=0,avoidCollisions:p=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g=`partial`,hideWhenDetached:_=!1,updatePositionStrategy:v=`optimized`,onPlaced:y,...b}=e,x=Pt(Rt,n),[S,C]=f.useState(null),w=l(t,C),[T,E]=f.useState(null),D=kt(T),O=D?.width??0,k=D?.height??0,A=r+(o===`center`?``:`-`+o),j=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(m)?m:[m],N=M.length>0,P={padding:j,boundary:M.filter(Gt),altBoundary:N},{refs:F,floatingStyles:I,placement:L,isPositioned:R,middlewareData:z}=_t({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>nt(...e,{animationFrame:v===`always`}),elements:{reference:x.anchor},middleware:[yt({mainAxis:i+k,alignmentAxis:u}),p&&bt({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?xt():void 0,...P}),p&&St({...P}),Ct({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Tt({element:T,padding:d}),Kt({arrowWidth:O,arrowHeight:k}),_&&wt({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),B=x.setPlacementState;c(()=>(B(L),()=>{B(void 0)}),[L,B]);let[ee,te]=qt(L),ne=s(y);c(()=>{R&&ne?.()},[R,ne]);let re=z.arrow?.x,ie=z.arrow?.y,ae=z.arrow?.centerOffset!==0,[oe,se]=f.useState();return c(()=>{S&&se(window.getComputedStyle(S).zIndex)},[S]),(0,$.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...I,transform:R?I.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(` `),...z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(zt,{scope:n,placedSide:ee,placedAlign:te,onArrowChange:E,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,$.jsx)(a.div,{"data-side":ee,"data-align":te,...b,ref:w,style:{...b.style,animation:R?void 0:`none`}})})})});Vt.displayName=Rt;var Ht=`PopperArrow`,Ut={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Wt=f.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Bt(Ht,n),a=Ut[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(Ot,{...r,ref:t,style:{...r.style,display:`block`}})})});Wt.displayName=Ht;function Gt(e){return e!==null}var Kt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=qt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function qt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Jt=Ft,Yt=Lt,Xt=Vt,Zt=Wt,Qt=`rounded-md bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 disabled:cursor-not-allowed disabled:opacity-50`,$t=`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,en=`data-[highlighted]:bg-action data-[highlighted]:text-action-ink data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,tn=`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`;function nn({className:e,type:t,...n}){return(0,$.jsx)(`input`,{type:t,className:u(`flex h-8 w-full px-2.5`,Qt,e),...n})}function rn({className:e,...t}){return(0,$.jsx)(`textarea`,{className:u(`flex min-h-16 w-full px-2.5 py-2`,Qt,e),...t})}var an=`Label`,on=f.forwardRef((e,t)=>(0,$.jsx)(a.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));on.displayName=an;var sn=on;function cn({className:e,...t}){return(0,$.jsx)(sn,{className:u(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var ln=d(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),un=d(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]);function dn({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:o,hintsClassName:s,autoFocus:c}){let[l,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(0),h=e=>{n(e.value),r?.(e),d(!1)};return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(nn,{id:e,value:t,onChange:e=>{n(e.target.value),d(!0),m(0)},onFocus:()=>d(!0),onBlur:()=>d(!1),onKeyDown:e=>{if(!(!l||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),m(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),m(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[p]??i[0];t&&(e.preventDefault(),h(t))}else e.key===`Escape`&&(e.stopPropagation(),d(!1))},placeholder:a,className:o,autoComplete:`off`,spellCheck:!1,autoFocus:c}),l&&i.length>0&&(0,$.jsx)(`ul`,{className:u(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,s??`w-full`),children:i.map((e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),h(e)},onMouseEnter:()=>m(t),className:u(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===p,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var fn=(0,f.lazy)(()=>i(()=>import(`./Terminal-B297I2Hn.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))),pn=null;async function mn(){pn=(await i(()=>import(`./Terminal-B297I2Hn.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))).Terminal}function hn(e){return pn?(0,$.jsx)(pn,{...e}):(0,$.jsx)(f.Suspense,{fallback:(0,$.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,$.jsx)(fn,{...e})})}export{Mt as _,ln as a,rn as c,en as d,$t as f,Jt as g,Xt as h,un as i,Qt as l,Zt as m,mn as n,cn as o,Yt as p,dn as r,nn as s,hn as t,tn as u,kt as v};
@@ -1,8 +0,0 @@
1
- import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{A as r,D as i,J as a,O as o,Q as s,X as c,Y as l,Z as u,_ as d,c as f,g as p,h as m,j as h,k as g,m as _,n as v,p as y,q as b,r as x}from"./index-CIyjjiv2.js";import{i as S,n as C,r as w}from"./dist-sv8JIOv-.js";import{$ as T,At as ee,E,K as D,N as O,Nt as te,P as k,Q as ne,R as re,S as ie,St as ae,W as oe,X as se,at as ce,ct as le,d as ue,dt as de,f as fe,gt as pe,h as me,lt as A,m as he,mt as ge,ot as _e,pt as j,q as ve,rt as ye,s as be,tt as xe,w as Se,xt as Ce,z as we}from"./protocol-support-B2anXRJW.js";import{a as M,i as N,n as P,o as F,r as I,t as L}from"./dialog-cFDquLR6.js";import{t as R}from"./button-CZSpHYG9.js";import{a as Te,c as z,i as Ee,o as De,r as Oe,s as B}from"./LazyTerminal-DqKe6H-V.js";import{a as ke,c as Ae,d as je,i as Me,l as Ne,o as Pe,r as Fe,t as V,u as Ie}from"./switch-Y_nZqNi0.js";import{n as H}from"./x-CZCUod6A.js";import{t as U}from"./createLucideIcon-DyMAgLa3.js";import{a as Le,c as Re,d as ze,f as Be,g as Ve,i as He,l as Ue,m as We,n as Ge,o as Ke,p as qe,r as Je,s as Ye,t as Xe,u as Ze,v as Qe}from"./notification-permission-2B9Xl86r.js";import{a as W,i as $e,n as et,o as tt,r as nt,s as rt,t as it}from"./disclosure-FybNXyk_.js";import{t as at}from"./code-DRWf9a5s.js";import{n as G}from"./errors-wktZNO7z.js";import{t as ot}from"./use-debounced-value-C86N-mOK.js";var st=U(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),ct=U(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),lt=U(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),ut=U(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),dt=U(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ft=U(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),pt=U(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),mt=U(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(n(),1),q=v();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(B,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,q.jsxs)(`div`,{className:H(`flex items-center gap-4 py-2.5`,a),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:H(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function ht(){let e=p(),[t,n]=(0,K.useState)(f());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(nt,{value:t,onValueChange:e=>{n(e),x(e)},children:[(0,q.jsx)(tt,{className:`w-32`,children:(0,q.jsx)(rt,{})}),(0,q.jsxs)($e,{children:[(0,q.jsx)(W,{value:`dark`,children:`Dark`}),(0,q.jsx)(W,{value:`light`,children:`Light`}),(0,q.jsx)(W,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(nt,{value:e.cursorPackage,onValueChange:e=>m({cursorPackage:e}),children:[(0,q.jsx)(tt,{className:`w-36`,children:(0,q.jsx)(rt,{})}),(0,q.jsx)($e,{children:d.map(e=>(0,q.jsx)(W,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>m({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>m({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>m({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(nt,{value:e.density,onValueChange:e=>m({density:e}),children:[(0,q.jsx)(tt,{className:`w-36`,children:(0,q.jsx)(rt,{})}),(0,q.jsxs)($e,{children:[(0,q.jsx)(W,{value:`compact`,children:`Compact`}),(0,q.jsx)(W,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(V,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>m({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(V,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>m({showAllProjectSessions:e})})})]})}function gt({profile:e}){let t=le(),[n,r]=(0,K.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>G(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>G(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(Ue,{open:n,onOpenChange:r,children:[(0,q.jsx)(ze,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Be,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Ze,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:H(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,q.jsx)(Be,{icon:null,colour:null,className:`size-4`})}),We.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:H(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,q.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:H(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),u.map(t=>(0,q.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:H(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:H(`size-3.5 rounded-full bg-current`,qe(t))}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var _t=`__none__`;function vt(){let e=E(),t=ge().data?.find(t=>t.id===e),n=O(e??void 0),r=j(e??void 0),i=le(),a=A(e??``),o=se(),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(c(t.name),u(t.branch_prefix))},[t]),!t)return null;let h=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(B,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(R,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(B,{id:`branch-prefix`,value:l,onChange:e=>u(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(R,{size:`sm`,variant:`secondary`,disabled:l===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:l},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsx)(gt,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(nt,{value:typeof h==`number`?String(h):_t,onValueChange:e=>a.mutate({default_account_id:e===_t?null:Number(e)},{onError:e=>G(e)}),children:[(0,q.jsx)(tt,{className:`w-56`,children:(0,q.jsx)(rt,{})}),(0,q.jsxs)($e,{children:[(0,q.jsx)(W,{value:_t,children:`First available`}),n.data?.map(e=>(0,q.jsx)(W,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(R,{variant:`danger`,size:`sm`,onClick:()=>f(!0),children:`Delete…`})}),(0,q.jsx)(L,{open:d,onOpenChange:e=>{e||(f(!1),m(``))},children:(0,q.jsxs)(P,{children:[(0,q.jsxs)(M,{children:[(0,q.jsxs)(F,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(I,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(De,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(B,{id:`delete-confirm-name`,value:p,onChange:e=>m(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(N,{children:[(0,q.jsx)(R,{variant:`ghost`,onClick:()=>{f(!1),m(``)},children:`Cancel`}),(0,q.jsx)(R,{variant:`danger`,disabled:p!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{Me(),Se.set(null)},onError:e=>{f(!1),m(``),G(e)}}),children:`Delete profile`})]})]})})]})}function yt({agent:e,profileId:t,onClose:n,onCreated:r}){let i=we(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=ne(ot(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,p=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>G(e)})};return(0,q.jsx)(L,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(P,{children:[(0,q.jsxs)(M,{children:[(0,q.jsxs)(F,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(I,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,q.jsx)(B,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(Oe,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(N,{children:[(0,q.jsx)(R,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(R,{disabled:!f||i.isPending,onClick:p,children:[(0,q.jsx)(je,{}),`Add account`]})]})]})})}function bt({account:e,gateOpen:t,installed:n}){let r=ye(),i=ce(),a=ve(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(e.label),f=(0,K.useRef)(null);return(0,K.useEffect)(()=>d(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{G(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{f.current?.focus(),f.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Ee,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(V,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>G(e)})})]}),(0,q.jsxs)(R,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>G(e)}),children:[(0,q.jsx)(Qe,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(R,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(Ne,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(Re,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(L,{open:c,onOpenChange:l,children:(0,q.jsxs)(P,{children:[(0,q.jsxs)(M,{children:[(0,q.jsxs)(F,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(I,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(N,{children:[(0,q.jsx)(R,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(R,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),G(e)}}),children:`Delete account`})]})]})})]})}function xt(){let e=E(),t=k(),n=O(e??void 0),r=j(e??void 0),i=ye(),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(null),l=r.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(bt,{account:t,gateOpen:l&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(R,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>c(e),children:[(0,q.jsx)(je,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(Re,{stream:a.stream,label:a.label,hint:a.hint,onClose:()=>o(null)}),s!==null&&e!==null&&(0,q.jsx)(yt,{agent:s,profileId:e,onClose:()=>c(null),onCreated:(e,t)=>{if(t){e.logged_in||C.info(`Imported without credentials — press Login to authenticate.`);return}i.mutate(e.id,{onSuccess:t=>o({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>G(e)})}})]})}function St(){let e=re(),t=_e(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(B,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function Ct({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=et(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(B,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(V,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(V,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function wt(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:p().terminalScrollback,onCommit:e=>m({terminalScrollback:e})})})}function Tt({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(z,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(R,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(R,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var Et={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function Dt({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:c;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(B,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:c}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Fe(Et,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:s.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(R,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(R,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(c),t(c)},children:`Reset to default`})]})]})}function Ot(){let e=E(),t=ge().data?.find(t=>t.id===e),n=j(e??void 0),r=A(e??``),[i,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(``),u=n.data?.allowSkipPermissions===!0,d=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{o(!1),c(``)},onError:e=>G(e)}),f=e=>t=>r.mutate({[e]:t},{onError:e=>G(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(V,{id:`gate`,checked:u,onCheckedChange:e=>{e?o(!0):d(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(V,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>G(e)})})}),(0,q.jsx)(St,{}),(0,q.jsx)(wt,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Ct,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(Ct,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Tt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??a,defaultText:a,onSave:f(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(Tt,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??b,defaultText:b,onSave:f(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(Tt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??l,defaultText:l,onSave:f(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)(Dt,{initial:n.data.tabTitleTemplate||"${name}",onSave:f(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(L,{open:i,onOpenChange:e=>{e||(o(!1),c(``))},children:(0,q.jsxs)(P,{children:[(0,q.jsxs)(M,{children:[(0,q.jsxs)(F,{className:`flex items-center gap-2`,children:[(0,q.jsx)(dt,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(I,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(De,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(B,{id:`confirm-name`,value:s,onChange:e=>c(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(N,{children:[(0,q.jsx)(R,{variant:`ghost`,onClick:()=>{o(!1),c(``)},children:`Cancel`}),(0,q.jsx)(R,{variant:`danger`,disabled:s!==t?.name||r.isPending,onClick:()=>d(!0),children:`Open the gate`})]})]})})]})}var kt={desktop:!0,sound:!1,muted_projects:[]};function At(){let[e,t]=(0,K.useState)(Xe);return(0,K.useEffect)(()=>{let e=()=>t(Xe());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(Xe())]}function jt({permission:e,onRequest:t}){return e===`granted`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function Mt(){let e=E(),t=j(e??void 0),n=A(e??``),r=pe(e??void 0),[i,a]=At(),o={...kt,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>G(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,q.jsx)(V,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,q.jsx)(jt,{permission:i,onRequest:c}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(V,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(V,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function Nt(){let e=p();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>m({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(V,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>m({editorWordWrap:e})})}),(0,q.jsx)(Y,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,q.jsx)(B,{id:`editor-link-host`,type:`text`,placeholder:y.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>m({editorLinkSshHost:e.target.value})})})]})}function Pt({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=he(e.nativeEvent);t&&(n(t),a(!1))},className:H(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:me(e)}),!t&&(0,q.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(lt,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function Ft(){let e=E(),t=j(e??void 0),n=A(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of ue){let t=i(e.id,ie(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>G(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>G(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(V,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>G(e)})})}),fe.map(e=>{let t=ue.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,ie(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(Pt,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var It=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);function Lt(e,t){let[n,i]=(0,K.useState)(null),[a,s]=(0,K.useState)(!0),[c,l]=(0,K.useState)(``),u=(0,K.useRef)(0),d=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{u.current+=1},[]),(0,K.useEffect)(()=>{if(n)return;let e=!0;return d.current=null,s(!0),(async()=>{try{let t=It(crypto.getRandomValues(new Uint8Array(32))),n=It(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t))));e&&(d.current={code:t,challenge:n})}catch(t){e&&l(t instanceof Error?t.message:`Could not prepare sign-in.`)}finally{e&&s(!1)}})(),()=>{e=!1,d.current=null}},[n]);let f=(0,K.useRef)(t);return(0,K.useEffect)(()=>{f.current=t},[t]),(0,K.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{u.current+=1,i(null),l(`Sign-in expired. Try again.`)},Math.max(0,n.request.expires-Date.now()));return()=>clearTimeout(e)},[n]),(0,K.useEffect)(()=>{if(!n||e)return;let t=u.current,r=!1,a,o=async()=>{try{if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);let{ready:e}=g.parse(await S(`POST`,`/cockpit/remote/registration`,{service:n.request.service,code:n.code}));if(r||t!==u.current)return;if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);e?(i(null),await f.current({t:`enable`,registration:{service:n.request.service,app:n.request.app,code:n.code}})):a=setTimeout(()=>void o(),2e3)}catch(e){if(r||t!==u.current)return;i(null),l(e instanceof Error?e.message:`Sign-in failed. Try again.`)}};return a=setTimeout(()=>void o(),2e3),()=>{r=!0,clearTimeout(a)}},[n,e]),{attempt:n,preparing:a,error:c,begin:(t,n,a)=>{if(!(e||!d.current)){l(``);try{let{code:e,challenge:s}=d.current,c=o.safeParse({service:t.trim(),app:n.trim(),label:a.trim(),challenge:s,expires:Date.now()+r.invitationMs});if(!c.success)throw Error(`Enter a host name and exact HTTPS application and relay origins.`);let l=c.data,f=`${l.app}/#register=${encodeURIComponent(JSON.stringify(l))}`;u.current+=1,d.current=null,i({request:l,code:e,url:f}),window.open(f,`_blank`,`noopener,noreferrer`)}catch(e){l(e instanceof Error?e.message:`Could not start sign-in.`)}}},cancel:()=>{u.current+=1,d.current=null,s(!0),i(null)}}}function Rt({service:e=`https://charles.waddlelabs.ai`,app:t=`https://puddle.waddlelabs.ai`,hostName:n,busy:r,disabled:i,enable:a,cancel:o}){let[s,c]=(0,K.useState)(e),[l,u]=(0,K.useState)(t),[d,f]=(0,K.useState)(n),p=Lt(i,a),m=i||p.preparing||!!p.attempt;return(0,q.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:e=>{e.preventDefault(),m||p.begin(s,l,d)},children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Application origin`,(0,q.jsx)(B,{type:`url`,required:!0,value:l,onChange:e=>u(e.target.value),placeholder:`https://app.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Relay origin`,(0,q.jsx)(B,{type:`url`,required:!0,value:s,onChange:e=>c(e.target.value),placeholder:`https://relay.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Host name`,(0,q.jsx)(B,{required:!0,maxLength:80,value:d,onChange:e=>f(e.target.value),disabled:m})]}),o&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saving a new registration revokes existing browser approvals and invitations.`}),p.error&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p.error}),p.attempt?(0,q.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,q.jsxs)(`p`,{role:`status`,children:[`Confirm this host in your browser. Match request`,` `,(0,q.jsx)(`strong`,{className:`font-mono`,children:p.attempt.request.challenge.slice(0,8).toUpperCase()}),`. Sign-in expires in five minutes.`]}),(0,q.jsx)(`a`,{href:p.attempt.url,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:opacity-80`,children:`Continue in browser ↗`}),(0,q.jsx)(R,{type:`button`,variant:`ghost`,onClick:p.cancel,children:`Cancel sign-in`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(R,{type:`submit`,disabled:m||!d.trim()||!s||!l,children:r?`Enabling…`:p.preparing?`Preparing sign-in…`:`Sign in and enable`}),o&&(0,q.jsx)(R,{type:`button`,variant:`ghost`,disabled:m,onClick:o,children:`Cancel`})]})]})}var zt=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Z=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),Bt=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Vt=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ht=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Ut=t((e=>{var t=Z().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Wt=t((e=>{var t=Z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Gt=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Kt=t((e=>{var t=Bt(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),qt=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Jt=t((e=>{var t=qt();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Yt=t(((e,t)=>{var n=Jt();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Xt=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Zt=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
- ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),Q=t((e=>{var t=Xt(),n=Zt();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),Qt=t((e=>{var t=Z(),n=Kt(),r=Bt(),i=Q(),a=Xt(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),$t=t((e=>{var t=Z(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),en=t(((e,t)=>{var n=Q();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),tn=t(((e,t)=>{var n=Q(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),nn=t(((e,t)=>{var n=Q();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),rn=t(((e,t)=>{var n=Q(),r=Z();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
- Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),an=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),on=t((e=>{var t=Q(),n=en(),r=tn(),i=nn(),a=rn(),o=Zt(),s=Z(),c=an();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
- Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),sn=t((e=>{var t=Z(),n=Bt(),r=Vt(),i=Ht(),a=Ut(),o=Wt(),s=Gt(),c=Kt(),l=Yt(),u=Qt(),d=$t(),f=Q(),p=on();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
5
- The chosen QR Code version cannot contain this amount of data.
6
- Minimum version required to store current data is: `+c+`.
7
- `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),cn=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),ln=t((e=>{var t=cn();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),un=t((e=>{var t=cn();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
8
- `;return typeof a==`function`&&a(null,p),p}})),dn=e(t((e=>{var t=zt(),n=sn(),r=ln(),i=un();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function fn({value:e,label:t}){let n=(0,K.useMemo)(()=>{try{let{modules:t}=dn.create(e),n=[];for(let e=0;e<t.size;e+=1)for(let r=0;r<t.size;r+=1)t.get(e,r)&&n.push(`M${r+4} ${e+4}h1v1h-1z`);return{size:t.size+8,path:n.join(``)}}catch{return null}},[e]);return n?(0,q.jsx)(`svg`,{role:`img`,"aria-label":t,"data-theme":`light`,className:`block h-auto max-w-full rounded-lg bg-paper text-fg`,xmlns:`http://www.w3.org/2000/svg`,width:280,height:280,viewBox:`0 0 ${n.size} ${n.size}`,shapeRendering:`crispEdges`,children:(0,q.jsx)(`path`,{fill:`currentColor`,d:n.path})}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`QR code unavailable. Use the pairing link.`})}function pn({url:e,expires:t,dismiss:n}){let[r,i]=(0,K.useState)(``);return(0,K.useEffect)(()=>{let e=setTimeout(n,Math.max(0,t-Date.now()));return()=>clearTimeout(e)},[t,n]),(0,q.jsxs)(`section`,{className:`mt-5 space-y-3`,"aria-label":`Pairing invitation`,children:[(0,q.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`Scan or open this link on the new browser, then approve its exact identity below. Expires`,` `,new Date(t).toLocaleTimeString(),`.`]}),(0,q.jsx)(fn,{value:e,label:`Pairing invitation QR code`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(R,{variant:`secondary`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>i(`Pairing link copied.`)).catch(()=>i(`Could not copy. Open the pairing link or scan the QR code.`))},children:`Copy pairing link`}),(0,q.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`px-2 text-sm text-fg hover:opacity-80`,children:`Open pairing link ↗`}),(0,q.jsx)(R,{variant:`ghost`,onClick:n,children:`Hide invitation`})]}),r&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,children:r})]})}function mn({devices:e,now:t,currentDevice:n,...r}){let i=e.filter(e=>e.status!==`revoked`).sort((e,t)=>Number(t.status===`pending`)-Number(e.status===`pending`));return(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[i.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No browsers yet. Create a pairing invitation to add one.`}),i.map(e=>(0,q.jsx)(hn,{device:e,now:t,current:e.id===n,...r},e.id))]})}function hn({device:e,now:t,current:n,busy:i,approve:a,revoke:o}){let s=e.status===`pending`,c=e.status===`approved`?Math.min(e.expires,e.lastUsed+r.idleMs):e.expires,l=c<=t,u=l?`Expired`:s?`Awaiting approval`:`Approved`,d=(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`truncate text-sm text-fg`,title:e.label,children:e.label}),(0,q.jsxs)(`p`,{className:H(`text-2xs`,l?`text-fg-muted`:s?`text-warning`:`text-success`),children:[u,n&&(0,q.jsx)(`span`,{className:`text-fg-muted`,children:` · this browser`})]})]}),f=(0,q.jsxs)(`div`,{className:`mt-2 space-y-1 text-2xs text-fg-muted`,children:[(0,q.jsx)(`code`,{className:`block break-all text-fg-secondary`,children:e.peer}),(0,q.jsxs)(`p`,{children:[l?`Expired`:`Expires`,` `,new Date(c).toLocaleString()]})]});return(0,q.jsxs)(`article`,{"aria-label":e.label,className:`min-w-0 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[s?d:(0,q.jsx)(it,{className:`min-w-0 flex-1`,summary:d,summaryClassName:`flex-row-reverse gap-2 [&>svg]:m-2`,children:f}),s&&!l&&(0,q.jsxs)(R,{variant:`secondary`,size:`sm`,disabled:i,onClick:()=>a(e.id),"aria-label":`Approve ${e.label}`,children:[(0,q.jsx)(ft,{}),` Approve`]}),(0,q.jsx)(R,{variant:`ghost`,size:`icon`,className:`shrink-0 text-fg-muted`,disabled:i,"aria-label":`Revoke ${e.label}`,title:`Revoke browser`,onClick:()=>o(e.id),children:(0,q.jsx)(Ne,{})})]}),s&&f]})}function gn({devices:e,now:t,busy:n,act:r}){return(0,q.jsx)(it,{className:`mt-6 text-sm`,summary:`Connected browsers`,summaryClassName:`py-2`,children:(0,q.jsxs)(`section`,{className:`space-y-3 pt-2`,"aria-label":`Browsers`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Approval grants terminal control of this host. Compare the identity with the browser requesting access.`}),(0,q.jsx)(mn,{devices:e,now:t,busy:n,approve:e=>void r({t:`approve`,id:e}),revoke:e=>void r({t:`revoke`,id:e})}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Revocation detaches viewers; agents continue running. Browsers expire after 30 days of inactivity or 90 days overall.`})]})})}function _n({open:e,busy:t,error:n,onOpenChange:r,onConfirm:i}){return(0,q.jsx)(L,{open:e,onOpenChange:e=>!t&&r(e),children:(0,q.jsxs)(P,{children:[(0,q.jsx)(F,{children:`Delete this profile’s remote registration?`}),(0,q.jsx)(I,{children:`Disable remote access, remove the saved registration for this profile and revoke its browser approval and invitation. Agents keep running. Connecting again requires a new registration code and fresh browser approvals.`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`This also removes this registration from its account’s remote host list. If the service is unavailable, removal finishes when it reconnects.`}),n&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n}),(0,q.jsxs)(N,{children:[(0,q.jsx)(R,{variant:`ghost`,disabled:t,onClick:()=>r(!1),children:`Cancel`}),(0,q.jsx)(R,{variant:`danger`,disabled:t,onClick:i,children:t?`Deleting…`:`Delete registration`})]})]})})}function vn(){let e=te(),t=xe(),n=E(),r=ge().data?.find(e=>e.id===n)?.name??`this profile`,a=`/cockpit/remote?profile=${encodeURIComponent(n??``)}`,[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(null),x=(0,K.useCallback)(()=>b(null),[]),C=ee({queryKey:[`cockpit-remote`,n],queryFn:async()=>i.parse(await S(`GET`,a)),refetchInterval:!o&&5e3,refetchOnWindowFocus:!o,refetchOnReconnect:!o,retry:!1,gcTime:0,enabled:!!n}),T=async t=>{if(o||!n)return!1;s(!0),d(``),l(``);try{if(e.isFetching({queryKey:[`cockpit-remote`,n],exact:!0})){let e=await C.refetch({cancelRefetch:!1});if(e.isError)throw e.error}let r=h.parse(await S(`POST`,a,t));return t.t===`pair`&&r.url&&r.invitation?b({url:r.url,expires:r.invitation.expires}):(l({enable:`Remote access enabled.`,approve:`Browser approved.`,revoke:`Browser revoked.`,disable:`Remote access disabled. Agents continue running.`,delete_registration:`Registration deleted from this host. Agents continue running.`,reset:`Host identity rotated and all browsers revoked. Enable access and pair again.`,status:`Status refreshed.`,devices:`Browsers refreshed.`,pair:`Invitation created.`}[t.t]),(t.t===`disable`||t.t===`reset`||t.t===`enable`||t.t===`delete_registration`)&&x()),(t.t===`enable`||t.t===`delete_registration`)&&p(!1),g(!1),v(!1),await C.refetch(),!0}catch(e){return d(e instanceof Error?e.message:`Host operation failed. Refresh status before retrying.`),await C.refetch(),!1}finally{s(!1)}},D=C.data,O=C.error instanceof w&&C.error.status===404,k=o||C.isError;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`${r} on ${t.data?.displayName||t.data?.hostname||`this host`} · only this profile’s projects and sessions`,children:`Remote access`}),(0,q.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{role:`status`,className:`text-sm font-medium`,children:C.isError?`Status unavailable`:D?D.availability===`ready`?D.configured?D.enabled?D.connected?`Connected to relay`:`Enabled · relay disconnected`:`Disabled`:`Not configured`:`Daemon upgrade required`:`Checking remote access…`}),(0,q.jsxs)(R,{variant:`ghost`,size:`sm`,disabled:o,onClick:()=>void C.refetch({cancelRefetch:!1}),children:[(0,q.jsx)(Ie,{}),`Refresh status`]})]}),C.isError&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:O?`This cockpit does not provide remote controls. Update Puddle and reopen this window.`:C.error.message}),u&&!_&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:u}),c&&(0,q.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-fg-secondary`,children:c}),D?.availability!==void 0&&D.availability!==`ready`&&(0,q.jsx)(`p`,{className:`mt-3 text-sm text-fg-secondary`,children:`Update the daemon on this host, then refresh status to set up mobile access.`}),D?.availability===`ready`&&(0,q.jsxs)(q.Fragment,{children:[!D.enabled&&D.supervisor&&(!D.configured||f)?(0,q.jsx)(Rt,{service:D.service,app:D.app,hostName:`${t.data?.displayName||t.data?.hostname||`My host`} · ${r}`,busy:o,disabled:k,enable:T,cancel:D.configured?()=>p(!1):void 0},D.host??`new`):D.configured?(0,q.jsxs)(`dl`,{className:`mt-4 space-y-2 text-xs text-fg-secondary`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:`Application`}),(0,q.jsx)(`dd`,{className:`break-all`,children:(0,q.jsxs)(`a`,{href:D.app,target:`_blank`,rel:`noreferrer`,className:`hover:text-fg`,children:[D.app,` ↗`]})})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:`Relay`}),(0,q.jsx)(`dd`,{className:`break-all`,children:D.service})]}),D.peer&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:`Host identity`}),(0,q.jsx)(`dd`,{className:`break-all font-mono`,children:D.peer})]})]}):null,!D.enabled&&!D.supervisor&&(0,q.jsx)(`p`,{className:`mt-4 text-sm text-fg-secondary`,children:`This host needs persistent systemd or launchd supervision before access can be enabled here. For another supervisor, configure both the daemon and connector using the remote CLI commands.`}),D.configured&&(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,role:`group`,"aria-label":`Registration actions`,children:[!D.enabled&&D.supervisor&&!f&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(R,{disabled:k,onClick:()=>void T({t:`enable`}),children:`Enable remote access`}),(0,q.jsx)(R,{variant:`ghost`,disabled:k,onClick:()=>p(!0),children:`Change registration`})]}),D.enabled&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(R,{disabled:k,onClick:()=>void T({t:`pair`}),children:`Pair a browser`}),(0,q.jsx)(R,{variant:`ghost`,disabled:k,onClick:()=>void T({t:`disable`}),children:`Disable remote access`})]}),D.canDeleteRegistration&&(0,q.jsx)(R,{variant:`ghost`,disabled:k,onClick:()=>{d(``),v(!0)},children:`Delete registration`})]}),y&&D.enabled&&(0,q.jsx)(pn,{...y,dismiss:x}),D.configured&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(gn,{devices:D.devices,now:C.dataUpdatedAt,busy:k,act:T}),(0,q.jsxs)(it,{className:`text-sm`,summary:`Host identity recovery`,summaryClassName:`py-2`,children:[(0,q.jsx)(`p`,{className:`my-3 text-xs text-fg-muted`,children:`Rotate a lost or compromised host identity. This profile’s browser approvals and invitations will be revoked.`}),(0,q.jsx)(R,{variant:`ghost`,disabled:k,onClick:()=>g(!0),children:`Reset host identity…`})]})]})]}),(0,q.jsx)(L,{open:m,onOpenChange:e=>!o&&g(e),children:(0,q.jsxs)(P,{children:[(0,q.jsx)(F,{children:`Reset this profile’s remote identity?`}),(0,q.jsx)(I,{children:`Disable remote access, rotate the host identity and revoke this profile’s paired browsers and invitation. Agents keep running. Enable access and pair each browser again afterwards.`}),(0,q.jsxs)(N,{children:[(0,q.jsx)(R,{variant:`ghost`,disabled:o,onClick:()=>g(!1),children:`Cancel`}),(0,q.jsx)(R,{variant:`danger`,disabled:o,onClick:()=>void T({t:`reset`}),children:`Reset host identity`})]})]})}),(0,q.jsx)(_n,{open:_,busy:o,error:u,onOpenChange:v,onConfirm:()=>void T({t:`delete_registration`})})]})}var yn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,$=65,bn=Object.fromEntries([...yn].map((e,t)=>[e,t])),xn=`H`,Sn=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Cn(e){let t=4294967295;for(let n of e)t=Sn[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function wn(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Tn(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function En(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function Dn(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function On(e,t){let n=(t%$+$)%$,r=``;for(let t of e){let e=bn[t];r+=e===void 0?t:yn[(e+n)%$]}return r}async function kn(e){let t=await En(JSON.stringify(e));return On(wn(t)+Cn(t),1+Math.floor(Math.random()*($-1)))}async function An(e){let t=e.trim(),n=t[0];if(!n||bn[n]===void 0)throw Error(`Not a settings export.`);let r=On(t,-((bn[n]-bn[xn]+$)%$));if(r.length<9||r[0]!==xn)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Tn(i);if(Cn(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await Dn(o))}var jn=`puddle.sync-selection`;function Mn(){try{let e=JSON.parse(localStorage.getItem(jn)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return Le.map(e=>e.id)}function Nn({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:Le.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(V,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Pn(){let e=E(),t=j(e??void 0),n=ge().data?.find(t=>t.id===e),r=ae(e??void 0,void 0),i=A(e??``),a=le(),o=oe(),s=Je(),c=He(),[l,u]=(0,K.useState)(``),[d,p]=(0,K.useState)(``),[h,g]=(0,K.useState)(!1),[v,y]=(0,K.useState)(Mn),b=n&&s.data?Ge(s.data.file,n.name):void 0,S=b?.enabled===!0,w=S&&b?b.groups:v,T=()=>({client:_(),theme:f(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),ee={setClient:e=>m(e),setTheme:e=>{typeof e==`string`&&x(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>G(e)}),patchProfileColumns:t=>{e&&a.mutate({id:e,...t},{onError:e=>G(e)})},createScratchpad:t=>{if(e)for(let n of t)o.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},D=(e,t)=>{n&&c.mutate({profile:n.name,entry:{enabled:e.enabled??S,groups:t,doc:Ye(t,T()),updatedAt:new Date().toISOString()}},{onError:e=>G(e)})},O=(e,t)=>{let n=t?[...w,e]:w.filter(t=>t!==e);y(n),localStorage.setItem(jn,JSON.stringify(n)),S&&D({},n)},te=async()=>{g(!0);try{let e=Ke(await An(l.trim()),ee,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?C.error(`Nothing recognised to import.`):(C.success(`Imported ${e.join(`, `)}.`),u(``))}catch(e){C.error(e.message)}finally{g(!1)}},k=async()=>{g(!0);try{let e=await kn(Ye(w,T()));p(e),await navigator.clipboard?.writeText(e),C.success(`Copied to clipboard`)}finally{g(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),s.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(V,{checked:S,disabled:!n||s.isLoading||c.isPending,onCheckedChange:e=>D({enabled:e},w)}),`Sync locally`]})]})]}),(0,q.jsx)(it,{className:`mb-6`,summary:`Choose what to sync`,summaryClassName:`text-xs`,children:(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(Nn,{selected:w,onToggle:O})})}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(R,{size:`sm`,disabled:h,onClick:()=>void k(),children:`Export & copy`}),d&&(0,q.jsx)(z,{readOnly:!0,value:d,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(z,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(R,{size:`sm`,disabled:!l.trim()||h,onClick:()=>void te(),children:`Import`})})]})]})}function Fn(){return(0,q.jsxs)(`div`,{className:`space-y-8`,children:[(0,q.jsx)(vn,{},E()),(0,q.jsx)(Pn,{})]})}function In({repo:e}){let t=de(),n=T(),r=be(D().data?.protocol),[i,a]=(0,K.useState)(e.default_base_branch),[o,s]=(0,K.useState)(e.onboarding_notes??``),c=e=>G(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,q.jsxs)(R,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>C.success(`Fetched.`),onError:c}),children:[(0,q.jsx)(Ie,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,description:r?`Blank = the branch checked out at the clone location when each agent or terminal is created.`:`Choose a branch. Update the host to allow a blank default that follows the clone.`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(B,{id:`base-${e.id}`,placeholder:r?`current clone branch`:void 0,value:i,onChange:e=>a(e.target.value),className:`w-40`}),(0,q.jsx)(R,{size:`sm`,variant:`secondary`,disabled:i.trim()===e.default_base_branch||t.isPending||!r&&!i.trim(),onClick:()=>t.mutate({id:e.id,default_base_branch:i.trim()},{onError:c,onSuccess:()=>a(i.trim())}),children:`Save`})]}),(0,q.jsx)(Y,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,q.jsx)(V,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:c})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,q.jsx)(z,{id:`notes-${e.id}`,value:o,onChange:e=>s(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(R,{size:`sm`,variant:`secondary`,disabled:o===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:o},{onError:c}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function Ln(){let e=Ce();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(In,{repo:e},e.id))]})}function Rn({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=_e();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(B,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>G(e)})}})})}function zn(){let e=re(),t=_e(),n=xe();return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`Affects all profiles on this host`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(B,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>G(e)})}})}),(0,q.jsx)(Rn,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)(Rn,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,q.jsx)(Rn,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)(Rn,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(V,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>G(e)})})})]}):null}var Bn=[{id:`appearance`,label:`Appearance`,icon:Ve,render:()=>(0,q.jsx)(ht,{})},{id:`profile`,label:`Profile`,icon:Ae,render:()=>(0,q.jsx)(vt,{})},{id:`accounts`,label:`Accounts`,icon:mt,render:()=>(0,q.jsx)(xt,{})},{id:`sessions`,label:`Sessions`,icon:pt,render:()=>(0,q.jsx)(Ot,{})},{id:`editor`,label:`Editor`,icon:at,render:()=>(0,q.jsx)(Nt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:ct,render:()=>(0,q.jsx)(Ft,{})},{id:`notifications`,label:`Notifications`,icon:st,render:()=>(0,q.jsx)(Mt,{})},{id:`projects`,label:`Projects`,icon:Te,render:()=>(0,q.jsx)(Ln,{})},{id:`host`,label:`Host`,icon:ut,render:()=>(0,q.jsx)(zn,{})},{id:`remote-sync`,label:`Remote & Sync`,icon:Ie,render:()=>(0,q.jsx)(Fn,{})}],Vn={terminal:`sessions`,repositories:`projects`,remote:`remote-sync`,sync:`remote-sync`};function Hn(){let e=Pe(),t=e===null?null:Vn[e]??e,n=Bn.find(e=>e.id===t)??Bn[0];return(0,q.jsx)(L,{open:e!==null,onOpenChange:e=>!e&&Me(),children:(0,q.jsxs)(P,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,q.jsx)(F,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,q.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Bn.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{onClick:()=>ke(e),className:H(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,q.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Hn as SettingsDialog};