@spencerboucher/switchyard 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +7 -7
  2. package/dist/bridge/enroll.js +12 -3
  3. package/dist/catalog/worker.js +5913 -0
  4. package/dist/policies/worker.js +1024 -913
  5. package/dist/switchyard.mjs +11098 -7609
  6. package/package.json +1 -1
  7. package/web-dist/assets/AutomationView-I80YGJ3M.js +2 -0
  8. package/web-dist/assets/AutomationView-I80YGJ3M.js.map +1 -0
  9. package/web-dist/assets/Checkbox-BdFQsqCG.js +2 -0
  10. package/web-dist/assets/{Checkbox-Bh46F55q.js.map → Checkbox-BdFQsqCG.js.map} +1 -1
  11. package/web-dist/assets/DangerZone-C6qU1pp7.js +2 -0
  12. package/web-dist/assets/{DangerZone-K_oXMpbq.js.map → DangerZone-C6qU1pp7.js.map} +1 -1
  13. package/web-dist/assets/Field-DGV7eljt.js +2 -0
  14. package/web-dist/assets/Field-DGV7eljt.js.map +1 -0
  15. package/web-dist/assets/NavigationEditor-COtm2NQY.js +2 -0
  16. package/web-dist/assets/{NavigationEditor-BfNZ411c.js.map → NavigationEditor-COtm2NQY.js.map} +1 -1
  17. package/web-dist/assets/Overlay-hRkfpjK4.js +2 -0
  18. package/web-dist/assets/{Overlay-wZFuaSA5.js.map → Overlay-hRkfpjK4.js.map} +1 -1
  19. package/web-dist/assets/{Priority-Ce4btFLm.js → Priority-DL3f-tRD.js} +2 -2
  20. package/web-dist/assets/{Priority-Ce4btFLm.js.map → Priority-DL3f-tRD.js.map} +1 -1
  21. package/web-dist/assets/RadioCards-9YvqB3va.js +2 -0
  22. package/web-dist/assets/{RadioCards-DR-fWNLB.js.map → RadioCards-9YvqB3va.js.map} +1 -1
  23. package/web-dist/assets/ScopeRepository-BPiPUjHi.js +6 -0
  24. package/web-dist/assets/ScopeRepository-BPiPUjHi.js.map +1 -0
  25. package/web-dist/assets/ScopeSelect-DmWCXeIf.js +2 -0
  26. package/web-dist/assets/ScopeSelect-DmWCXeIf.js.map +1 -0
  27. package/web-dist/assets/SegmentedControl-CefWecy1.js +2 -0
  28. package/web-dist/assets/SegmentedControl-CefWecy1.js.map +1 -0
  29. package/web-dist/assets/Select-CdANXO3X.js +2 -0
  30. package/web-dist/assets/{Select-CvbSg3M1.js.map → Select-CdANXO3X.js.map} +1 -1
  31. package/web-dist/assets/StructuredValue-BjKzgQDM.js +5 -0
  32. package/web-dist/assets/StructuredValue-BjKzgQDM.js.map +1 -0
  33. package/web-dist/assets/Switch-DrrWalaQ.js +2 -0
  34. package/web-dist/assets/{Switch-B89oAK_3.js.map → Switch-DrrWalaQ.js.map} +1 -1
  35. package/web-dist/assets/Tabs-Cvyw8P4s.js +184 -0
  36. package/web-dist/assets/Tabs-Cvyw8P4s.js.map +1 -0
  37. package/web-dist/assets/{TextLink-irMcg7Xz.js → TextLink-DMi_ZI43.js} +2 -2
  38. package/web-dist/assets/{TextLink-irMcg7Xz.js.map → TextLink-DMi_ZI43.js.map} +1 -1
  39. package/web-dist/assets/{UINodeRenderer-_99GFFDS.js → UINodeRenderer-CDPAUIOO.js} +3 -3
  40. package/web-dist/assets/{UINodeRenderer-_99GFFDS.js.map → UINodeRenderer-CDPAUIOO.js.map} +1 -1
  41. package/web-dist/assets/UnfilteredNote-CgsOTad1.js +2 -0
  42. package/web-dist/assets/{UnfilteredNote-iQIfVXkA.js.map → UnfilteredNote-CgsOTad1.js.map} +1 -1
  43. package/web-dist/assets/api-Dlk6L3Cu.js +2 -0
  44. package/web-dist/assets/api-Dlk6L3Cu.js.map +1 -0
  45. package/web-dist/assets/{arrow-down-BKhm3D2d.js → arrow-down-Cc6k_L7W.js} +2 -2
  46. package/web-dist/assets/{arrow-down-BKhm3D2d.js.map → arrow-down-Cc6k_L7W.js.map} +1 -1
  47. package/web-dist/assets/{arrow-up-poMxdOwI.js → arrow-up-CW1a5Bhp.js} +2 -2
  48. package/web-dist/assets/{arrow-up-poMxdOwI.js.map → arrow-up-CW1a5Bhp.js.map} +1 -1
  49. package/web-dist/assets/attention-AZ2a-mzO.js +2 -0
  50. package/web-dist/assets/attention-AZ2a-mzO.js.map +1 -0
  51. package/web-dist/assets/auth-Dzip9fVv.js +2 -0
  52. package/web-dist/assets/auth-Dzip9fVv.js.map +1 -0
  53. package/web-dist/assets/automations-BYFgPSs2.js +2 -0
  54. package/web-dist/assets/{automations-DWz_Lxch.js.map → automations-BYFgPSs2.js.map} +1 -1
  55. package/web-dist/assets/board-D2LALQcR.js +6 -0
  56. package/web-dist/assets/board-D2LALQcR.js.map +1 -0
  57. package/web-dist/assets/{calendar-clock-U5kMaB5u.js → calendar-clock-CkYP2-Qf.js} +2 -2
  58. package/web-dist/assets/{calendar-clock-U5kMaB5u.js.map → calendar-clock-CkYP2-Qf.js.map} +1 -1
  59. package/web-dist/assets/chevron-right-Q-RTE0ar.js +2 -0
  60. package/web-dist/assets/{chevron-right-B-aa_CvO.js.map → chevron-right-Q-RTE0ar.js.map} +1 -1
  61. package/web-dist/assets/code-BuAtgr-5.js +24 -0
  62. package/web-dist/assets/code-BuAtgr-5.js.map +1 -0
  63. package/web-dist/assets/{core.esm-CHa4oRMo.js → core.esm-yL4bmFrt.js} +2 -2
  64. package/web-dist/assets/{core.esm-CHa4oRMo.js.map → core.esm-yL4bmFrt.js.map} +1 -1
  65. package/web-dist/assets/{describe-C5NtR2LE.js → describe-B1R7Rpb3.js} +3 -3
  66. package/web-dist/assets/{describe-C5NtR2LE.js.map → describe-B1R7Rpb3.js.map} +1 -1
  67. package/web-dist/assets/enroll-BJIkw0lm.js +2 -0
  68. package/web-dist/assets/{enroll-DlZYKudD.js.map → enroll-BJIkw0lm.js.map} +1 -1
  69. package/web-dist/assets/external-link-BHZxy4tb.js +2 -0
  70. package/web-dist/assets/external-link-BHZxy4tb.js.map +1 -0
  71. package/web-dist/assets/{git-branch-CltFrgh4.js → git-branch-C5Xwi6aW.js} +2 -2
  72. package/web-dist/assets/{git-branch-CltFrgh4.js.map → git-branch-C5Xwi6aW.js.map} +1 -1
  73. package/web-dist/assets/{grip-vertical-QSdwyQ9C.js → grip-vertical-kzr2x5pf.js} +2 -2
  74. package/web-dist/assets/{grip-vertical-QSdwyQ9C.js.map → grip-vertical-kzr2x5pf.js.map} +1 -1
  75. package/web-dist/assets/{hand-5eeZJSl_.js → hand-DStB4fR7.js} +2 -2
  76. package/web-dist/assets/{hand-5eeZJSl_.js.map → hand-DStB4fR7.js.map} +1 -1
  77. package/web-dist/assets/index-Bm6tklht.css +2 -0
  78. package/web-dist/assets/index-D3WBnjbc.js +17 -0
  79. package/web-dist/assets/index-D3WBnjbc.js.map +1 -0
  80. package/web-dist/assets/{link-2-DXaJEVgz.js → link-2-Cny9mRKW.js} +2 -2
  81. package/web-dist/assets/{link-2-DXaJEVgz.js.map → link-2-Cny9mRKW.js.map} +1 -1
  82. package/web-dist/assets/logic-BOdOYgZ4.js +4 -0
  83. package/web-dist/assets/{logic-4hQwsm8w.js.map → logic-BOdOYgZ4.js.map} +1 -1
  84. package/web-dist/assets/logic-CHh1lc3G.js +2 -0
  85. package/web-dist/assets/{logic-c8AsGwGr.js.map → logic-CHh1lc3G.js.map} +1 -1
  86. package/web-dist/assets/more-BrHzsSfh.js +2 -0
  87. package/web-dist/assets/{more-RENHRep9.js.map → more-BrHzsSfh.js.map} +1 -1
  88. package/web-dist/assets/{pencil-DvO-Zlyh.js → pencil-BmHgPcCk.js} +2 -2
  89. package/web-dist/assets/{pencil-DvO-Zlyh.js.map → pencil-BmHgPcCk.js.map} +1 -1
  90. package/web-dist/assets/{play-CPNEXvVs.js → play-Dul6ZDzY.js} +2 -2
  91. package/web-dist/assets/{play-CPNEXvVs.js.map → play-Dul6ZDzY.js.map} +1 -1
  92. package/web-dist/assets/{plus-DC4JQpXX.js → plus-DzBRN9tc.js} +2 -2
  93. package/web-dist/assets/{plus-DC4JQpXX.js.map → plus-DzBRN9tc.js.map} +1 -1
  94. package/web-dist/assets/{policyLogic-CXFbVtEs.js → policyLogic-DVorBdH6.js} +2 -2
  95. package/web-dist/assets/{policyLogic-CXFbVtEs.js.map → policyLogic-DVorBdH6.js.map} +1 -1
  96. package/web-dist/assets/{prefs-BTwRvULi.js → prefs-CUMuH2EM.js} +2 -2
  97. package/web-dist/assets/{prefs-BTwRvULi.js.map → prefs-CUMuH2EM.js.map} +1 -1
  98. package/web-dist/assets/preload-helper-vwPq19u5.js +9 -0
  99. package/web-dist/assets/preload-helper-vwPq19u5.js.map +1 -0
  100. package/web-dist/assets/queue-hRZWM_pM.js +2 -0
  101. package/web-dist/assets/{queue-C25GCl3M.js.map → queue-hRZWM_pM.js.map} +1 -1
  102. package/web-dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  103. package/web-dist/assets/{rotate-ccw-DuLdXOxM.js → rotate-ccw-ByDiAA6o.js} +2 -2
  104. package/web-dist/assets/{rotate-ccw-DuLdXOxM.js.map → rotate-ccw-ByDiAA6o.js.map} +1 -1
  105. package/web-dist/assets/{search-tZdcGLqS.js → search-DarT116I.js} +2 -2
  106. package/web-dist/assets/{search-tZdcGLqS.js.map → search-DarT116I.js.map} +1 -1
  107. package/web-dist/assets/settings-DHfdrqxv.js +6 -0
  108. package/web-dist/assets/settings-DHfdrqxv.js.map +1 -0
  109. package/web-dist/assets/states-hcvSpyb1.js +60 -0
  110. package/web-dist/assets/states-hcvSpyb1.js.map +1 -0
  111. package/web-dist/assets/{terminal-CEttp_7_.js → terminal-BmpsRI95.js} +2 -2
  112. package/web-dist/assets/{terminal-CEttp_7_.js.map → terminal-BmpsRI95.js.map} +1 -1
  113. package/web-dist/assets/terminal-login-COaZPzQx.js +2 -0
  114. package/web-dist/assets/{terminal-login-BceUiMHs.js.map → terminal-login-COaZPzQx.js.map} +1 -1
  115. package/web-dist/assets/useBreakpoint-CXotoLeq.js +2 -0
  116. package/web-dist/assets/{useBreakpoint-CdYPa6z0.js.map → useBreakpoint-CXotoLeq.js.map} +1 -1
  117. package/web-dist/assets/useNow-BweXkeWc.js +2 -0
  118. package/web-dist/assets/{useNow-CyygPGnv.js.map → useNow-BweXkeWc.js.map} +1 -1
  119. package/web-dist/assets/useResource-DAMkbbuf.js +2 -0
  120. package/web-dist/assets/useResource-DAMkbbuf.js.map +1 -0
  121. package/web-dist/assets/useSwipeTabs-3qLCxSS7.js +2 -0
  122. package/web-dist/assets/{useSwipeTabs-CJFQTmAs.js.map → useSwipeTabs-3qLCxSS7.js.map} +1 -1
  123. package/web-dist/assets/workboard-BEcRsjyQ.js +3 -0
  124. package/web-dist/assets/workboard-BEcRsjyQ.js.map +1 -0
  125. package/web-dist/index.html +9 -7
  126. package/web-dist/sw.js +1 -1
  127. package/web-dist/sw.js.map +1 -1
  128. package/web-dist/assets/AutomationView-BFZ5tGrI.js +0 -2
  129. package/web-dist/assets/AutomationView-BFZ5tGrI.js.map +0 -1
  130. package/web-dist/assets/Checkbox-Bh46F55q.js +0 -2
  131. package/web-dist/assets/DangerZone-K_oXMpbq.js +0 -2
  132. package/web-dist/assets/Field-DRcZixOF.js +0 -2
  133. package/web-dist/assets/Field-DRcZixOF.js.map +0 -1
  134. package/web-dist/assets/Markdown-BaCvc-cI.js +0 -184
  135. package/web-dist/assets/Markdown-BaCvc-cI.js.map +0 -1
  136. package/web-dist/assets/NavigationEditor-BfNZ411c.js +0 -2
  137. package/web-dist/assets/Overlay-wZFuaSA5.js +0 -2
  138. package/web-dist/assets/RadioCards-DR-fWNLB.js +0 -2
  139. package/web-dist/assets/ScopeSelect-B1RxBDV7.js +0 -2
  140. package/web-dist/assets/ScopeSelect-B1RxBDV7.js.map +0 -1
  141. package/web-dist/assets/SegmentedControl-M7WpGnaN.js +0 -2
  142. package/web-dist/assets/SegmentedControl-M7WpGnaN.js.map +0 -1
  143. package/web-dist/assets/Select-CvbSg3M1.js +0 -2
  144. package/web-dist/assets/StructuredValue-By3sh_00.js +0 -5
  145. package/web-dist/assets/StructuredValue-By3sh_00.js.map +0 -1
  146. package/web-dist/assets/Switch-B89oAK_3.js +0 -2
  147. package/web-dist/assets/Tabs-CzGFkSHO.js +0 -2
  148. package/web-dist/assets/Tabs-CzGFkSHO.js.map +0 -1
  149. package/web-dist/assets/UnfilteredNote-iQIfVXkA.js +0 -2
  150. package/web-dist/assets/api-CzS9UH7Q.js +0 -2
  151. package/web-dist/assets/api-CzS9UH7Q.js.map +0 -1
  152. package/web-dist/assets/attention-UZIRcx_k.js +0 -2
  153. package/web-dist/assets/attention-UZIRcx_k.js.map +0 -1
  154. package/web-dist/assets/automations-DWz_Lxch.js +0 -2
  155. package/web-dist/assets/board-BqGDwbGB.js +0 -6
  156. package/web-dist/assets/board-BqGDwbGB.js.map +0 -1
  157. package/web-dist/assets/chevron-right-B-aa_CvO.js +0 -2
  158. package/web-dist/assets/code-Di_a0pVO.js +0 -28
  159. package/web-dist/assets/code-Di_a0pVO.js.map +0 -1
  160. package/web-dist/assets/enroll-DlZYKudD.js +0 -2
  161. package/web-dist/assets/index-CbdB9RE5.js +0 -17
  162. package/web-dist/assets/index-CbdB9RE5.js.map +0 -1
  163. package/web-dist/assets/index-XQGPQuFK.css +0 -2
  164. package/web-dist/assets/logic-4hQwsm8w.js +0 -4
  165. package/web-dist/assets/logic-c8AsGwGr.js +0 -2
  166. package/web-dist/assets/more-RENHRep9.js +0 -2
  167. package/web-dist/assets/queue-C25GCl3M.js +0 -2
  168. package/web-dist/assets/selection-BVtvp1aZ.js +0 -9
  169. package/web-dist/assets/selection-BVtvp1aZ.js.map +0 -1
  170. package/web-dist/assets/settings-BApavmGp.js +0 -7
  171. package/web-dist/assets/settings-BApavmGp.js.map +0 -1
  172. package/web-dist/assets/states-CM1Zt9qO.js +0 -60
  173. package/web-dist/assets/states-CM1Zt9qO.js.map +0 -1
  174. package/web-dist/assets/terminal-login-BceUiMHs.js +0 -2
  175. package/web-dist/assets/useBreakpoint-CdYPa6z0.js +0 -2
  176. package/web-dist/assets/useNow-CyygPGnv.js +0 -2
  177. package/web-dist/assets/useResource-DQOWQ7YZ.js +0 -2
  178. package/web-dist/assets/useResource-DQOWQ7YZ.js.map +0 -1
  179. package/web-dist/assets/useSwipeTabs-CJFQTmAs.js +0 -2
  180. package/web-dist/assets/workboard-D39MZMSb.js +0 -3
  181. package/web-dist/assets/workboard-D39MZMSb.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScopeSelect-DmWCXeIf.js","names":["useRef","useId","createPortal","useState","useRef","useId","useId","__toESM","useSyncStore","require_jsx_runtime","cn","require_react","require_react_dom","useFocusTrap","registerKeyboardLayer","useDragDismiss","useScrollLock","verticalNavigationDelta","describeScope","useSelectedScope","scopeOptionLabel","Check","usePrefs","useBreakpoint","Select","import_react","import_react_dom","import_jsx_runtime","groupItems","items","i","plain","g","groups","current","flush","item","ActionSheet","panel","id","open","onClose","label","title","description","icons","Toggle","on","Menu","controlledOpen","innerOpen","setInnerOpen","onOpenChangeRef","onOpenChange","setOpen","value","next","phone","sheet","presentation","btnRef","menuRef","focusItem","focusMenuItem","dir","unregister","onDoc","close","refocus","className","trigger","o","sheetTitle","sheetDescription","side","align","topKeyboardLayer","vim","delta","els","menu","idx","useScopeDescriber","scopes","s","projects","hosts","v","subject","ScopeSelect","selectedId","setSelectedId","scope","labelVisible","describe","allLabel"],"sources":["../../src/components/ui/ActionSheet.tsx","../../src/components/ui/Menu.tsx","../../src/features/scopes/ScopeSelect.tsx"],"sourcesContent":["import { Check } from \"lucide-react\";\nimport { type ReactNode, useId, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../lib/cn\";\nimport { useDragDismiss } from \"../../lib/useDragDismiss\";\nimport type { MenuHeading, MenuItem } from \"./Menu\";\nimport { useFocusTrap, useScrollLock } from \"./useFocusTrap\";\n\ntype Entry = MenuItem | MenuHeading | \"separator\";\n\ninterface Group {\n key: string;\n heading?: string;\n items: MenuItem[];\n}\n\n/**\n * Split a menu into the grouped cards of a native action sheet. Separators and headings start a\n * group. A flat list is grouped by kind instead: actions, then settings (checkbox and radio\n * items), then destructive actions last, nearest the thumb's Cancel.\n */\nexport function groupItems(items: Entry[]): Group[] {\n const structured = items.some((i) => i === \"separator\" || \"heading\" in i);\n if (!structured) {\n const plain = items as MenuItem[];\n return [\n { key: \"actions\", items: plain.filter((i) => !i.kind && !i.danger) },\n { key: \"settings\", items: plain.filter((i) => i.kind && !i.danger) },\n { key: \"danger\", items: plain.filter((i) => i.danger) },\n ].filter((g) => g.items.length > 0);\n }\n const groups: Group[] = [];\n let current: Group = { key: \"g0\", items: [] };\n const flush = () => {\n if (current.items.length > 0) groups.push(current);\n };\n for (const [i, item] of items.entries()) {\n if (item === \"separator\") {\n flush();\n current = { key: `g${i}`, items: [] };\n } else if (\"heading\" in item) {\n flush();\n current = { key: item.id, heading: item.heading, items: [] };\n } else current.items.push(item);\n }\n flush();\n return groups;\n}\n\n/**\n * A menu as a native-style bottom sheet: the phone presentation of `Menu` and of long-press\n * actions. Grouped rounded cards, a Cancel button within thumb reach, drag down to close.\n */\nexport function ActionSheet({\n open,\n onClose,\n title,\n description,\n items,\n label,\n}: {\n open: boolean;\n onClose: () => void;\n title?: ReactNode;\n description?: ReactNode;\n items: Entry[];\n label: string;\n}) {\n const panel = useRef<HTMLDivElement>(null);\n const id = useId();\n useFocusTrap(panel, open, onClose, panel);\n useScrollLock(open);\n useDragDismiss(panel, open, onClose);\n if (!open) return null;\n const groups = groupItems(items);\n return createPortal(\n <div className=\"fixed inset-0 z-50 flex items-end justify-center\">\n <div className=\"sy-fade-in absolute inset-0 bg-overlay\" aria-hidden onClick={onClose} />\n <div\n ref={panel}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={label}\n tabIndex={-1}\n className=\"sy-sheet-in relative flex max-h-[85dvh] w-full max-w-md flex-col gap-2 px-2 pb-[calc(var(--safe-bottom)+0.5rem)] outline-none select-none [-webkit-touch-callout:none]\"\n >\n <div className=\"flex min-h-0 flex-col overflow-hidden rounded-2xl bg-surface shadow-pop\">\n <div className=\"flex shrink-0 justify-center pt-2 pb-1\" aria-hidden>\n <div className=\"h-1 w-9 rounded-full bg-border-strong\" />\n </div>\n {(title || description) && (\n <div className=\"shrink-0 px-6 pb-2 text-center\">\n {title && <p className=\"truncate text-sm font-semibold\">{title}</p>}\n {description && <p className=\"truncate text-xs text-muted\">{description}</p>}\n </div>\n )}\n <div\n role=\"menu\"\n aria-label={label}\n data-testid=\"action-sheet\"\n data-sheet-scroll\n className=\"flex min-h-0 flex-col gap-3 overflow-y-auto overscroll-contain px-3 pt-1 pb-3\"\n >\n {groups.map((g) => {\n const icons = g.items.some((i) => i.icon && !i.kind);\n return (\n <div key={g.key}>\n {g.heading && (\n <p className=\"px-3 pb-1 text-xs font-medium tracking-wide text-muted uppercase\">\n {g.heading}\n </p>\n )}\n <div className=\"overflow-hidden rounded-xl bg-surface-2\">\n {g.items.map((item, i) => (\n // biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-checked is only set with the menuitemradio/menuitemcheckbox roles\n <button\n key={item.id}\n type=\"button\"\n role={\n item.kind === \"radio\"\n ? \"menuitemradio\"\n : item.kind === \"checkbox\"\n ? \"menuitemcheckbox\"\n : \"menuitem\"\n }\n aria-checked={item.kind ? !!item.checked : undefined}\n aria-describedby={item.description ? `${id}-${item.id}-desc` : undefined}\n disabled={item.disabled}\n className={cn(\n \"flex min-h-12 w-full items-center gap-3 px-4 py-2.5 text-left text-[15px] leading-5 outline-none\",\n \"active:bg-surface-3 focus-visible:bg-surface-3 disabled:opacity-45\",\n i > 0 && \"border-t border-border\",\n item.danger ? \"text-danger\" : \"text-text\",\n )}\n onClick={() => {\n // Synchronously, so file pickers and dialogs still have the user gesture.\n onClose();\n item.onSelect();\n }}\n >\n {icons && (\n <span\n aria-hidden\n className={cn(\n \"flex size-5 shrink-0 items-center justify-center [&>svg]:size-[18px]\",\n !item.danger && \"text-muted\",\n )}\n >\n {!item.kind && item.icon}\n </span>\n )}\n <span className=\"min-w-0 flex-1\">\n <span className=\"block\">{item.label}</span>\n {item.hint && (\n <span className=\"block text-xs leading-4 text-muted\">{item.hint}</span>\n )}\n {item.description && (\n <span id={`${id}-${item.id}-desc`} hidden>\n {item.description}\n </span>\n )}\n </span>\n {item.kind === \"checkbox\" && <Toggle on={!!item.checked} />}\n {item.kind === \"radio\" && item.checked && (\n <Check aria-hidden className=\"size-5 shrink-0 text-accent\" />\n )}\n </button>\n ))}\n </div>\n </div>\n );\n })}\n </div>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"h-13 w-full shrink-0 rounded-2xl bg-surface text-[15px] font-semibold text-accent shadow-pop active:bg-surface-2\"\n >\n Cancel\n </button>\n </div>\n </div>,\n document.body,\n );\n}\n\n/** A switch-shaped indicator for checkbox items (the row itself is the control). */\nfunction Toggle({ on }: { on: boolean }) {\n return (\n <span\n aria-hidden\n className={cn(\n \"relative inline-flex h-6 w-10 shrink-0 rounded-full transition-colors\",\n on ? \"bg-accent\" : \"bg-border-strong\",\n )}\n >\n <span\n className={cn(\n \"absolute top-0.5 size-5 rounded-full bg-white shadow transition-transform\",\n on ? \"translate-x-[18px]\" : \"translate-x-0.5\",\n )}\n />\n </span>\n );\n}\n","import { Check } from \"lucide-react\";\nimport { type ReactNode, useEffect, useId, useRef, useState } from \"react\";\nimport { useBreakpoint } from \"../../app/useBreakpoint\";\nimport { verticalNavigationDelta } from \"../../features/palette/shortcuts\";\nimport { cn } from \"../../lib/cn\";\nimport { usePrefs } from \"../../prefs\";\nimport { ActionSheet } from \"./ActionSheet\";\nimport { registerKeyboardLayer, topKeyboardLayer } from \"./keyboardLayers\";\n\nexport interface MenuItem {\n id: string;\n label: string;\n icon?: ReactNode;\n onSelect: () => void;\n danger?: boolean;\n disabled?: boolean;\n /** Short explanation shown under the label (e.g. why it is disabled). */\n hint?: string;\n /** What the item does, in one sentence: a hover tooltip and the item's accessible description. */\n description?: string;\n /** A radio or checkbox item shows a check mark when `checked`. */\n kind?: \"radio\" | \"checkbox\";\n checked?: boolean;\n}\n\n/** A non-interactive label above a group of items. */\nexport interface MenuHeading {\n id: string;\n heading: string;\n}\n\nexport interface MenuProps {\n /** Render the trigger; spread the given props onto a button. */\n trigger: (props: {\n ref: React.Ref<HTMLButtonElement>;\n onClick: () => void;\n onKeyDown: (e: React.KeyboardEvent) => void;\n \"aria-haspopup\": \"menu\";\n \"aria-expanded\": boolean;\n \"aria-controls\": string;\n }) => ReactNode;\n items: (MenuItem | MenuHeading | \"separator\")[];\n align?: \"start\" | \"end\";\n /** Open below (default) or above the trigger. */\n side?: \"bottom\" | \"top\";\n /** Extra classes for the wrapper (e.g. `w-full`). */\n className?: string;\n /** Accessible name of the menu. */\n label: string;\n /** Controlled open state (a long-press can open the menu). */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** \"auto\" opens as a bottom sheet on the phone; \"dropdown\" always drops down. */\n presentation?: \"auto\" | \"dropdown\";\n /** Phone sheet heading (defaults to the label) and a line under it. */\n sheetTitle?: ReactNode;\n sheetDescription?: ReactNode;\n}\n\n/** Popup menu with arrow-key navigation, Escape and outside click to close. */\nexport function Menu({\n trigger,\n items,\n align = \"end\",\n side = \"bottom\",\n label,\n className,\n open: controlledOpen,\n onOpenChange,\n presentation = \"auto\",\n sheetTitle,\n sheetDescription,\n}: MenuProps) {\n const [innerOpen, setInnerOpen] = useState(false);\n const open = controlledOpen ?? innerOpen;\n const onOpenChangeRef = useRef(onOpenChange);\n onOpenChangeRef.current = onOpenChange;\n const setOpen = (next: boolean | ((o: boolean) => boolean)) => {\n const value = typeof next === \"function\" ? next(open) : next;\n setInnerOpen(value);\n onOpenChangeRef.current?.(value);\n };\n const phone = useBreakpoint() === \"mobile\";\n const sheet = presentation === \"auto\" && phone;\n const id = useId();\n const btnRef = useRef<HTMLButtonElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n\n const focusItem = (dir: 1 | -1 | \"first\" | \"last\") => focusMenuItem(menuRef.current, dir);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: setOpen only reads the latest props\n useEffect(() => {\n if (!open || sheet) return;\n const layer = {\n root: menuRef,\n onEscape: () => {\n setOpen(false);\n btnRef.current?.focus();\n },\n trapsFocus: false,\n };\n const unregister = registerKeyboardLayer(layer);\n requestAnimationFrame(() => focusMenuItem(menuRef.current, \"first\"));\n const onDoc = (e: PointerEvent) => {\n if (\n !menuRef.current?.contains(e.target as Node) &&\n !btnRef.current?.contains(e.target as Node)\n ) {\n setOpen(false);\n }\n };\n document.addEventListener(\"pointerdown\", onDoc);\n return () => {\n unregister();\n document.removeEventListener(\"pointerdown\", onDoc);\n };\n }, [open, sheet]);\n\n const close = (refocus = true) => {\n setOpen(false);\n if (refocus) btnRef.current?.focus();\n };\n\n return (\n <div className={cn(\"relative inline-flex\", className)}>\n {trigger({\n ref: btnRef,\n onClick: () => setOpen((o) => !o),\n onKeyDown: (e) => {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n setOpen(true);\n }\n },\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": open,\n \"aria-controls\": id,\n })}\n {sheet && (\n <ActionSheet\n open={open}\n onClose={() => setOpen(false)}\n title={sheetTitle ?? label}\n description={sheetDescription}\n label={label}\n items={items}\n />\n )}\n {open && !sheet && (\n <div\n ref={menuRef}\n id={id}\n role=\"menu\"\n aria-label={label}\n tabIndex={-1}\n className={cn(\n \"absolute z-40 max-h-[min(28rem,calc(100dvh-8rem))] min-w-48 max-w-[min(20rem,calc(100vw-1rem))] overflow-y-auto overscroll-contain rounded-lg border border-border bg-surface py-1 shadow-pop\",\n side === \"top\" ? \"bottom-full mb-1\" : \"top-full mt-1\",\n align === \"end\" ? \"right-0\" : \"left-0\",\n )}\n onKeyDown={(e) => {\n if (topKeyboardLayer()?.root !== menuRef) return;\n const vim = usePrefs.getState().vimNavigation;\n const delta =\n !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey\n ? verticalNavigationDelta(e.key, vim)\n : 0;\n if (delta) {\n e.preventDefault();\n e.stopPropagation();\n focusItem(delta as 1 | -1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n e.stopPropagation();\n focusItem(\"first\");\n } else if (\n e.key === \"End\" ||\n (vim && e.key === \"G\" && e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey)\n ) {\n e.preventDefault();\n e.stopPropagation();\n focusItem(\"last\");\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n close();\n } else if (e.key === \"Tab\") {\n close(false);\n }\n }}\n >\n {items.map((item, i) =>\n item === \"separator\" ? (\n // biome-ignore lint/suspicious/noArrayIndexKey: separators have no identity\n <hr key={`sep-${i}`} className=\"my-1 border-t border-border\" />\n ) : \"heading\" in item ? (\n <div\n key={item.id}\n role=\"presentation\"\n className=\"px-3 pt-1.5 pb-1 text-xs font-medium text-muted\"\n >\n {item.heading}\n </div>\n ) : (\n // biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-checked is only set with the menuitemradio/menuitemcheckbox roles\n <button\n key={item.id}\n type=\"button\"\n role={\n item.kind === \"radio\"\n ? \"menuitemradio\"\n : item.kind === \"checkbox\"\n ? \"menuitemcheckbox\"\n : \"menuitem\"\n }\n aria-checked={item.kind ? !!item.checked : undefined}\n title={item.description}\n aria-describedby={item.description ? `${id}-${item.id}-desc` : undefined}\n disabled={item.disabled}\n className={cn(\n \"tap flex w-full items-start gap-2 px-3 py-2 text-left text-sm hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:opacity-55\",\n item.danger ? \"text-danger\" : \"text-text\",\n )}\n onClick={() => {\n close();\n item.onSelect();\n }}\n >\n {item.kind ? (\n <span aria-hidden className=\"mt-0.5 size-4 shrink-0\">\n {item.checked && <Check className=\"size-4\" />}\n </span>\n ) : (\n item.icon && <span className=\"mt-0.5 shrink-0\">{item.icon}</span>\n )}\n <span className=\"min-w-0\">\n <span className=\"block\">{item.label}</span>\n {item.hint && <span className=\"block text-xs text-muted\">{item.hint}</span>}\n {item.description && (\n <span id={`${id}-${item.id}-desc`} hidden>\n {item.description}\n </span>\n )}\n </span>\n </button>\n ),\n )}\n </div>\n )}\n </div>\n );\n}\n\nfunction focusMenuItem(menu: HTMLElement | null, dir: 1 | -1 | \"first\" | \"last\"): void {\n const els = [\n ...(menu?.querySelectorAll<HTMLElement>('[role^=\"menuitem\"]:not([disabled])') ?? []),\n ];\n if (els.length === 0) return;\n const idx = els.indexOf(document.activeElement as HTMLElement);\n let next = 0;\n if (dir === \"first\") next = 0;\n else if (dir === \"last\") next = els.length - 1;\n else next = (idx + dir + els.length) % els.length;\n els[next]!.focus();\n}\n","import type { Scope } from \"@switchyard/protocol\";\nimport { useId } from \"react\";\nimport { Select } from \"../../components/ui/Select\";\nimport { cn } from \"../../lib/cn\";\nimport { useSyncStore } from \"../../sync/store\";\nimport { describeScope, scopeOptionLabel } from \"./describe\";\nimport { useSelectedScope } from \"./selection\";\n\n/** The scopes and the one-line description of a scope. */\nexport function useScopeDescriber(): {\n scopes: Record<string, Scope>;\n describe: (v: Scope, subject?: \"sessions\" | \"tasks\") => string;\n} {\n const scopes = useSyncStore((s) => s.scopes);\n const projects = useSyncStore((s) => s.projects);\n const hosts = useSyncStore((s) => s.hosts);\n return {\n scopes,\n describe: (v, subject) => describeScope(v, { projects, hosts }, subject),\n };\n}\n\n/** Selects the scope shared by Sessions and Board; \"\" is everything (`allLabel`). */\nexport function ScopeSelect({\n allLabel,\n className,\n labelVisible,\n subject = \"sessions\",\n}: {\n allLabel: string;\n className?: string;\n labelVisible?: boolean;\n /** What the page lists, for the description. */\n subject?: \"sessions\" | \"tasks\";\n}) {\n const id = useId();\n const { scopes, describe } = useScopeDescriber();\n const [selectedId, setSelectedId] = useSelectedScope();\n const scope = (selectedId ? scopes[selectedId] : null) ?? null;\n return (\n <div\n className={cn(\n labelVisible ? \"flex min-w-0 flex-col gap-1\" : \"flex min-w-0 items-center gap-2\",\n className,\n )}\n >\n <label htmlFor={id} className={labelVisible ? \"text-sm font-medium\" : \"sr-only\"}>\n Scope\n </label>\n <Select\n id={id}\n className={labelVisible ? \"w-full\" : \"max-w-56\"}\n value={scope?.id ?? \"\"}\n title={scope ? describe(scope, subject) : undefined}\n onChange={(e) => setSelectedId(e.target.value || null)}\n >\n <option value=\"\">{allLabel}</option>\n {Object.values(scopes).map((v) => (\n <option key={v.id} value={v.id}>\n {scopeOptionLabel(v)}\n </option>\n ))}\n </Select>\n {labelVisible && scope && <p className=\"text-xs text-muted\">{describe(scope, subject)}</p>}\n </div>\n );\n}\n"],"mappings":"A,+cAqBA,SAAgB4B,EAAW,EAAyB,CAElD,GAAI,CADeC,EAAM,KAAM,GAAMC,IAAM,aAAe,YAAaA,CAClE,EAAY,CACf,IAAMC,EAAQF,EACd,MAAO,CACL,CAAE,IAAK,UAAW,MAAOE,EAAM,OAAQ,GAAM,CAACD,EAAE,MAAQ,CAACA,EAAE,MAAM,CAAE,EACnE,CAAE,IAAK,WAAY,MAAOC,EAAM,OAAQ,GAAMD,EAAE,MAAQ,CAACA,EAAE,MAAM,CAAE,EACnE,CAAE,IAAK,SAAU,MAAOC,EAAM,OAAQ,GAAMD,EAAE,MAAM,CAAE,CACxD,CAAC,CAAC,OAAQ,GAAME,EAAE,MAAM,OAAS,CAAC,CACpC,CACA,IAAMC,EAAkB,CAAC,EACrBC,EAAiB,CAAE,IAAK,KAAM,MAAO,CAAC,CAAE,EACtCC,MAAc,CACdD,EAAQ,MAAM,OAAS,GAAGD,EAAO,KAAKC,CAAO,CACnD,EACA,IAAK,GAAM,CAACJ,EAAGM,KAASP,EAAM,QAAQ,EAChCO,IAAS,aACXD,EAAM,EACN,EAAU,CAAE,IAAK,IAAIL,IAAK,MAAO,CAAC,CAAE,GAC3B,YAAaM,GACtBD,EAAM,EACN,EAAU,CAAE,IAAKC,EAAK,GAAI,QAASA,EAAK,QAAS,MAAO,CAAC,CAAE,GACtDF,EAAQ,MAAM,KAAKE,CAAI,EAGhC,OADAD,EAAM,EACCF,CACT,CAMA,SAAgBI,EAAY,CAC1B,OACA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AjE,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,qBAAsB,SAAAmE,EAASF,EAAOJ,CAAO,CAAK,CAAA,CACtF,C,EAET,C"}
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{D as t,d as n,m as r,v as i,yn as a}from"./states-hcvSpyb1.js";import{K as o}from"./index-D3WBnjbc.js";var s={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};s.node;var c=t(s),l={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};l.node;var u=t(l),d=e(a(),1),f=r();async function p(e,t=`Copied to clipboard`){try{return await navigator.clipboard.writeText(e),t&&o.success(t),!0}catch{return o.error(`Could not copy. Select the text and copy it manually.`),!1}}function m({text:e,label:t=`Copy`,toastMessage:r,size:i=`sm`}){let[a,o]=(0,d.useState)(!1),s=(0,d.useRef)(null);return(0,d.useEffect)(()=>()=>void(s.current&&clearTimeout(s.current)),[]),(0,f.jsx)(n,{size:i,icon:a?(0,f.jsx)(c,{className:`size-4`}):(0,f.jsx)(u,{className:`size-4`}),onClick:async()=>{await p(e,r)&&(o(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>o(!1),2e3))},children:a?`Copied`:t})}function h({text:e,label:t,copyLabel:n=`Copy`}){return(0,f.jsxs)(`figure`,{className:`m-0 flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,f.jsx)(`figcaption`,{className:`sr-only`,children:t}),(0,f.jsx)(`pre`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-sm`,children:e}),(0,f.jsx)(m,{text:e,label:n})]})}var g=`cubic-bezier(0.2, 0.9, 0.25, 1)`;function _(e,t,n){let r=(0,d.useRef)(null),i=(0,d.useRef)(!1),a=(0,d.useRef)(t);a.current=t;let o=()=>[...e.current?.querySelectorAll(`[data-indicator-key]`)??[]].filter(t=>t.closest(`[data-indicator-root]`)===e.current),s=(e,t,n)=>{let i=r.current;i&&(i.style.transition=n?`transform 260ms ${g}, width 260ms ${g}`:`none`,i.style.transform=`translateX(${e}px)`,i.style.width=`${t}px`,i.style.opacity=t>0?`1`:`0`)},c=e=>{let t=o().find(e=>e.dataset.indicatorKey===a.current);if(!t)return s(0,0,!1);s(t.offsetLeft,t.offsetWidth,e&&i.current),i.current=!0};return(0,d.useLayoutEffect)(()=>c(!0),[t]),(0,d.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>c(!1));n.observe(t);for(let e of o())n.observe(e);return()=>n.disconnect()}),(0,d.useEffect)(()=>{if(n)return n.listen(e=>{if(e===null)return c(!0);let t=o(),n=t.findIndex(e=>e.dataset.indicatorKey===a.current),r=t[n],i=t[n+(e>0?1:-1)];if(!r||!i)return;let l=Math.min(1,Math.abs(e));s(r.offsetLeft+(i.offsetLeft-r.offsetLeft)*l,r.offsetWidth+(i.offsetWidth-r.offsetWidth)*l,!1)})},[n]),r}function v({options:e,value:t,onChange:n,label:r,className:a,block:o,progress:s}){let c=(0,d.useRef)(null),l=_(c,t,s),u=e.findIndex(e=>e.value===t);return(0,f.jsxs)(`div`,{ref:c,role:`radiogroup`,"aria-label":r,"data-indicator-root":!0,className:i(`relative inline-flex rounded-lg border border-border bg-surface-2 p-0.5`,o&&`flex w-full`,a),onKeyDown:t=>{let r=-1;t.key===`ArrowRight`||t.key===`ArrowDown`?r=(u+1)%e.length:(t.key===`ArrowLeft`||t.key===`ArrowUp`)&&(r=(u-1+e.length)%e.length),!(r<0)&&(t.preventDefault(),n(e[r].value),t.currentTarget.querySelectorAll(`[role="radio"]`)[r]?.focus())},children:[(0,f.jsx)(`span`,{ref:l,"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0.5 left-0 rounded-md border border-border bg-surface opacity-0 shadow-sm`}),e.map(e=>{let r=e.value===t;return(0,f.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,title:e.title,tabIndex:r?0:-1,"data-indicator-key":e.value,onClick:()=>n(e.value),className:i(`tap relative inline-flex min-h-8 flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-3 text-sm font-medium whitespace-nowrap transition-colors`,r?`text-text`:`text-muted hover:text-text`),children:[e.icon,e.label,e.badge]},e.value)})]})}export{u as a,p as i,_ as n,c as o,h as r,v as t};
2
+ //# sourceMappingURL=SegmentedControl-CefWecy1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SegmentedControl-CefWecy1.js","names":["__iconData","useState","useRef","useRef","useRef","__toESM","createLucideIcon","Button","require_jsx_runtime","cn","require_react","toast","__iconData$1","Check","__iconData","Copy","import_react","import_jsx_runtime","copyText","text","success","CopyButton","copied","setCopied","timer","toastMessage","label","CopyBlock","copyLabel","EASE","useIndicator","indicator","placed","valueRef","value","items","list","el","place","animate","x","w","toSelected","sel","root","ro","progress","f","all","i","cur","next","t","SegmentedControl","thumb","idx","options","o","block","className","e","onChange","selected"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/check.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/copy.mjs","../../src/components/ui/Copy.tsx","../../src/components/ui/useIndicator.ts","../../src/components/ui/SegmentedControl.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"check\",\n size: 24,\n node: [[\"path\", { d: \"M20 6 9 17l-5-5\", key: \"1gmf2c\" }]]\n};\n__iconData.node;\nconst Check = createLucideIcon(__iconData);\n\nexport { __iconData, Check as default };\n//# sourceMappingURL=check.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"copy\",\n size: 24,\n node: [\n [\"rect\", { width: \"14\", height: \"14\", x: \"8\", y: \"8\", rx: \"2\", ry: \"2\", key: \"17jyea\" }],\n [\"path\", { d: \"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\", key: \"zix9uf\" }]\n ]\n};\n__iconData.node;\nconst Copy = createLucideIcon(__iconData);\n\nexport { __iconData, Copy as default };\n//# sourceMappingURL=copy.mjs.map\n","import { Check, Copy } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { Button } from \"./Button\";\nimport { toast } from \"./Toast\";\n\n/** Copy text to the clipboard with a toast; pass `false` to stay silent on success. */\nexport async function copyText(\n text: string,\n success: string | false = \"Copied to clipboard\",\n): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n if (success) toast.success(success);\n return true;\n } catch {\n toast.error(\"Could not copy. Select the text and copy it manually.\");\n return false;\n }\n}\n\nexport function CopyButton({\n text,\n label = \"Copy\",\n toastMessage,\n size = \"sm\",\n}: {\n text: string;\n label?: string;\n toastMessage?: string;\n size?: \"sm\" | \"md\";\n}) {\n const [copied, setCopied] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => () => void (timer.current && clearTimeout(timer.current)), []);\n return (\n <Button\n size={size}\n icon={copied ? <Check className=\"size-4\" /> : <Copy className=\"size-4\" />}\n onClick={async () => {\n if (await copyText(text, toastMessage)) {\n setCopied(true);\n if (timer.current) clearTimeout(timer.current);\n timer.current = setTimeout(() => setCopied(false), 2000);\n }\n }}\n >\n {copied ? \"Copied\" : label}\n </Button>\n );\n}\n\n/** A monospace command or URL with a copy button; wraps instead of overflowing. */\nexport function CopyBlock({\n text,\n label,\n copyLabel = \"Copy\",\n}: {\n text: string;\n /** Accessible name of the code block. */\n label: string;\n copyLabel?: string;\n}) {\n return (\n <figure className=\"m-0 flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start\">\n <figcaption className=\"sr-only\">{label}</figcaption>\n <pre className=\"min-w-0 flex-1 whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-sm\">\n {text}\n </pre>\n <CopyButton text={text} label={copyLabel} />\n </figure>\n );\n}\n","import { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\nimport type { SwipeProgress } from \"../../lib/swipeProgress\";\n\nconst EASE = \"cubic-bezier(0.2, 0.9, 0.25, 1)\";\n\n/**\n * A selection indicator (a tab underline, a segmented control's thumb) that slides between the\n * items of `list` marked `data-indicator-key`, and follows a swipe's `progress` live.\n */\nexport function useIndicator(\n list: RefObject<HTMLElement | null>,\n value: string,\n progress?: SwipeProgress,\n): RefObject<HTMLSpanElement | null> {\n const indicator = useRef<HTMLSpanElement>(null);\n const placed = useRef(false);\n const valueRef = useRef(value);\n valueRef.current = value;\n\n const items = () =>\n [...(list.current?.querySelectorAll<HTMLElement>(\"[data-indicator-key]\") ?? [])].filter(\n (el) => el.closest(\"[data-indicator-root]\") === list.current,\n );\n const place = (x: number, w: number, animate: boolean) => {\n const el = indicator.current;\n if (!el) return;\n el.style.transition = animate ? `transform 260ms ${EASE}, width 260ms ${EASE}` : \"none\";\n el.style.transform = `translateX(${x}px)`;\n el.style.width = `${w}px`;\n el.style.opacity = w > 0 ? \"1\" : \"0\";\n };\n const toSelected = (animate: boolean) => {\n const sel = items().find((el) => el.dataset.indicatorKey === valueRef.current);\n if (!sel) return place(0, 0, false);\n place(sel.offsetLeft, sel.offsetWidth, animate && placed.current);\n placed.current = true;\n };\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: placement follows the selection\n useLayoutEffect(() => toSelected(true), [value]);\n\n // Labels and counts change width; the list resizes with the window.\n // biome-ignore lint/correctness/useExhaustiveDependencies: observers read the latest value\n useEffect(() => {\n const root = list.current;\n if (!root || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => toSelected(false));\n ro.observe(root);\n for (const el of items()) ro.observe(el);\n return () => ro.disconnect();\n });\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: subscribe once per progress channel\n useEffect(() => {\n if (!progress) return;\n return progress.listen((f) => {\n if (f === null) return toSelected(true);\n const all = items();\n const i = all.findIndex((el) => el.dataset.indicatorKey === valueRef.current);\n const cur = all[i];\n const next = all[i + (f > 0 ? 1 : -1)];\n if (!cur || !next) return;\n const t = Math.min(1, Math.abs(f));\n place(\n cur.offsetLeft + (next.offsetLeft - cur.offsetLeft) * t,\n cur.offsetWidth + (next.offsetWidth - cur.offsetWidth) * t,\n false,\n );\n });\n }, [progress]);\n\n return indicator;\n}\n","import { type ReactNode, useRef } from \"react\";\nimport { cn } from \"../../lib/cn\";\nimport type { SwipeProgress } from \"../../lib/swipeProgress\";\nimport { useIndicator } from \"./useIndicator\";\n\nexport interface SegmentOption<T extends string> {\n value: T;\n label: ReactNode;\n icon?: ReactNode;\n badge?: ReactNode;\n /** Tooltip. */\n title?: string;\n}\n\nexport interface SegmentedControlProps<T extends string> {\n options: SegmentOption<T>[];\n value: T;\n onChange: (value: T) => void;\n /** Accessible name. */\n label: string;\n className?: string;\n block?: boolean;\n /** A swipe between the options' panels; the selection follows it. */\n progress?: SwipeProgress;\n}\n\n/** Radio-group style switcher (e.g. mobile Chat / Changes / Details). */\nexport function SegmentedControl<T extends string>({\n options,\n value,\n onChange,\n label,\n className,\n block,\n progress,\n}: SegmentedControlProps<T>) {\n const root = useRef<HTMLDivElement>(null);\n const thumb = useIndicator(root, value, progress);\n const idx = options.findIndex((o) => o.value === value);\n return (\n <div\n ref={root}\n role=\"radiogroup\"\n aria-label={label}\n data-indicator-root\n className={cn(\n \"relative inline-flex rounded-lg border border-border bg-surface-2 p-0.5\",\n block && \"flex w-full\",\n className,\n )}\n onKeyDown={(e) => {\n let next = -1;\n if (e.key === \"ArrowRight\" || e.key === \"ArrowDown\") next = (idx + 1) % options.length;\n else if (e.key === \"ArrowLeft\" || e.key === \"ArrowUp\")\n next = (idx - 1 + options.length) % options.length;\n if (next < 0) return;\n e.preventDefault();\n onChange(options[next]!.value);\n const btns = e.currentTarget.querySelectorAll<HTMLElement>('[role=\"radio\"]');\n btns[next]?.focus();\n }}\n >\n {/* The selection: one thumb that slides between the options. */}\n <span\n ref={thumb}\n aria-hidden\n className=\"pointer-events-none absolute inset-y-0.5 left-0 rounded-md border border-border bg-surface opacity-0 shadow-sm\"\n />\n {options.map((o) => {\n const selected = o.value === value;\n return (\n // biome-ignore lint/a11y/useSemanticElements: button-based radio group (WAI-ARIA radio pattern)\n <button\n key={o.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n title={o.title}\n tabIndex={selected ? 0 : -1}\n data-indicator-key={o.value}\n onClick={() => onChange(o.value)}\n className={cn(\n \"tap relative inline-flex min-h-8 flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-3 text-sm font-medium whitespace-nowrap transition-colors\",\n selected ? \"text-text\" : \"text-muted hover:text-text\",\n )}\n >\n {o.icon}\n {o.label}\n {o.badge}\n </button>\n );\n })}\n </div>\n );\n}\n"],"ignoreList":[0,1],"mappings":"A,iKASA,IAAMA,EAAa,CACjB,KAAM,QACN,KAAM,GACN,KAAM,CAAC,CAAC,OAAQ,CAAE,EAAG,kBAAmB,IAAK,QAAS,CAAC,CAAC,CAC1D,EACAA,EAAW,KACX,IAAMa,EAAQP,EAAiBN,CAAU,ECNnCc,EAAa,CACjB,KAAM,OACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,KAAM,EAAG,IAAK,EAAG,IAAK,GAAI,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,EACvF,CAAC,OAAQ,CAAE,EAA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,EAAQL,EAAK,CAAE,KAAK,EAE7BS,EADe,cAAc,iBAA8B,gBAC3D,CAAA,CAAKT,EAAK,EAAE,MAAM,EACpB,EApBF,SAAA,EAuBE,EAAAlC,EAAA,IAAA,CAAC,OAAD,CACE,IAAKqC,EACL,cAAA,GACA,UAAU,gHACX,CAAA,EACAE,EAAQ,IAAK,GAAM,CAClB,IAAMM,EAAWL,EAAE,QAAUvB,EAC7B,OAEE,EAAAjB,EAAA,KAAA,CAAC,SAAD,CAEE,KAAK,SACL,KAAK,QACL,eAAc6C,EACd,MAAOL,EAAE,MACT,SAAUK,EAAW,EAAI,GACzB,qBAAoBL,EAAE,MACtB,YAAeI,EAASJ,EAAE,KAAK,EAC/B,UAAWhD,EACT,gLACAqD,EAAW,YAAc,4BAC3B,EAZF,SAAA,CAcGL,EAAE,KACFA,EAAE,MACFA,EAAE,KACG,CAhBD,EAAAA,EAAE,KAgBD,CAEZ,CAAC,CACE,C,EAET,C"}
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{m as t,v as n,yn as r}from"./states-hcvSpyb1.js";import{U as i}from"./index-D3WBnjbc.js";var a=e(r(),1),o=t(),s=(0,a.forwardRef)(function({className:e,width:t=`full`,children:r,...a},s){return(0,o.jsx)(`select`,{ref:s,className:n(`tap block h-9 min-w-0 px-2.5`,t===`auto`?`w-auto`:`w-full`,i,e),...a,children:r})});export{s as t};
2
+ //# sourceMappingURL=Select-CdANXO3X.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select-CvbSg3M1.js","names":["forwardRef","__toESM","require_jsx_runtime","require_react","cn","CONTROL_CLASSES","import_react","import_jsx_runtime","Select","rest","width","className"],"sources":["../../src/components/ui/Select.tsx"],"sourcesContent":["import { forwardRef, type SelectHTMLAttributes } from \"react\";\nimport { cn } from \"../../lib/cn\";\nimport { CONTROL_CLASSES } from \"./TextArea\";\n\nexport interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {\n /** \"full\" (default) fills its container; \"auto\" sizes to content for inline toolbars. */\n width?: \"full\" | \"auto\";\n}\n\n/** Native select with the same look, focus ring and invalid state as TextInput. */\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { className, width = \"full\", children, ...rest },\n ref,\n) {\n return (\n <select\n ref={ref}\n className={cn(\n \"tap block h-9 min-w-0 px-2.5\",\n width === \"auto\" ? \"w-auto\" : \"w-full\",\n CONTROL_CLASSES,\n className,\n )}\n {...rest}\n >\n {children}\n </select>\n );\n});\n"],"mappings":"A,6HAUaQ,GAAA,EAASR,EAAAA,WAAAA,CAA2C,SAC/D,CAAE,YAAW,QAAQ,OAAQ,WAAU,GAAGS,GAC1C,EACA,CACA,OACE,EAAAF,EAAA,IAAA,CAAC,SAAD,CACO,MACL,UAAWH,EACT,+BACAM,IAAU,OAAS,SAAW,SAC9BL,EACAM,CACF,EACA,GAAIF,EAEH,UACK,CAAA,CAEZ,CAAC,E"}
1
+ {"version":3,"file":"Select-CdANXO3X.js","names":["forwardRef","__toESM","require_jsx_runtime","cn","require_react","CONTROL_CLASSES","import_react","import_jsx_runtime","Select","rest","width","className"],"sources":["../../src/components/ui/Select.tsx"],"sourcesContent":["import { forwardRef, type SelectHTMLAttributes } from \"react\";\nimport { cn } from \"../../lib/cn\";\nimport { CONTROL_CLASSES } from \"./TextArea\";\n\nexport interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {\n /** \"full\" (default) fills its container; \"auto\" sizes to content for inline toolbars. */\n width?: \"full\" | \"auto\";\n}\n\n/** Native select with the same look, focus ring and invalid state as TextInput. */\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { className, width = \"full\", children, ...rest },\n ref,\n) {\n return (\n <select\n ref={ref}\n className={cn(\n \"tap block h-9 min-w-0 px-2.5\",\n width === \"auto\" ? \"w-auto\" : \"w-full\",\n CONTROL_CLASSES,\n className,\n )}\n {...rest}\n >\n {children}\n </select>\n );\n});\n"],"mappings":"A,wKAUaQ,GAAA,EAASR,EAAAA,WAAAA,CAA2C,SAC/D,CAAE,YAAW,QAAQ,OAAQ,WAAU,GAAGS,GAC1C,EACA,CACA,OACE,EAAAF,EAAA,IAAA,CAAC,SAAD,CACO,MACL,UAAWJ,EACT,+BACAO,IAAU,OAAS,SAAW,SAC9BL,EACAM,CACF,EACA,GAAIF,EAEH,UACK,CAAA,CAEZ,CAAC,E"}
@@ -0,0 +1,5 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$t as t,Bt as n,D as r,F as i,G as a,It as o,Lt as s,Mt as c,Qt as l,Rt as u,S as d,_ as f,a as p,c as m,cn as h,d as g,en as _,f as v,g as y,gn as b,in as x,m as S,n as C,rn as w,tn as T,v as E,yn as D,z as O}from"./states-hcvSpyb1.js";import{a as k,n as A,t as j,y as M}from"./Overlay-hRkfpjK4.js";import{s as N}from"./auth-Dzip9fVv.js";import{y as P}from"./preload-helper-vwPq19u5.js";import{a as ee,o as F}from"./SegmentedControl-CefWecy1.js";import{t as I}from"./external-link-BHZxy4tb.js";import{t as te}from"./plus-DzBRN9tc.js";import{t as ne}from"./search-DarT116I.js";import{F as re,G as L,K as R,O as z,W as B,ct as ie,j as V,t as ae,u as oe}from"./index-D3WBnjbc.js";import{t as H}from"./TextLink-DMi_ZI43.js";import{r as se,t as U}from"./Field-DGV7eljt.js";import{n as W,t as ce}from"./RadioCards-9YvqB3va.js";import{t as le}from"./Select-CdANXO3X.js";import{n as G}from"./Switch-DrrWalaQ.js";import{n as ue}from"./ScopeSelect-DmWCXeIf.js";import{t as K}from"./Checkbox-BdFQsqCG.js";var de={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};de.node;var fe=r(de),pe={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};pe.node;var me=r(pe),q=e(D(),1),J=S();function he({value:e,min:t,max:n,onChange:r,label:i,pane:a=`before`,step:o=16,onReset:s,orientation:c=`vertical`,className:l}){let u=(0,q.useRef)(null),d=e=>Math.round(Math.min(n,Math.max(t,e))),f=a===`before`?1:-1,p=c===`horizontal`,m=p?`ArrowDown`:`ArrowRight`,h=p?`ArrowUp`:`ArrowLeft`;return(0,J.jsx)(`div`,{role:`separator`,"aria-orientation":c,"aria-label":i,"aria-valuenow":Math.round(e),"aria-valuemin":t,"aria-valuemax":n,tabIndex:0,className:E(`group relative z-10 shrink-0 touch-none select-none`,p?`h-1.5 w-full cursor-row-resize`:`w-1.5 cursor-col-resize`,`focus-visible:outline-none`,l),onPointerDown:t=>{t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),u.current={x:p?t.clientY:t.clientX,value:e}},onPointerMove:e=>{if(!u.current)return;let t=p?e.clientY:e.clientX;r(d(u.current.value+f*(t-u.current.x)))},onPointerUp:e=>{u.current=null,e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{u.current=null},onDoubleClick:s,onKeyDown:i=>{let a=i.shiftKey?o*4:o;if(i.key===m)r(d(e+f*a));else if(i.key===h)r(d(e-f*a));else if(i.key===`Home`)r(t);else if(i.key===`End`)r(n);else if(i.key===`Enter`&&s)s();else return;i.preventDefault()},children:(0,J.jsx)(`div`,{"aria-hidden":!0,className:E(`absolute bg-border group-hover:bg-accent group-focus-visible:bg-accent`,p?`inset-x-0 top-1/2 h-px -translate-y-1/2 group-hover:h-0.5 group-focus-visible:h-0.5`:`inset-y-0 left-1/2 w-px -translate-x-1/2 group-hover:w-0.5 group-focus-visible:w-0.5`)})})}var Y=`/api/catalog/connections`,X=V(`projects`),Z=V(`projects/connect`),ge=V(`projects/connect/pat`);function _e(e=`github.com`){return`https://${e}/settings/tokens/new?scopes=repo,read:org,project&description=Switchyard`}var ve=_e(),ye={to:X,label:`Projects`};function Q(e){if(e)try{let t=new URL(e);if(t.protocol===`https:`&&!t.username&&!t.password)return t.href}catch{}}function be(){let[e,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let e=new AbortController;return t(Y,void 0,e.signal).then(t=>{e.signal.aborted||(n(t),i(null))},t=>{e.signal.aborted||(x(t)&&(t.status===404||t.code===`unsupported_capability`)?(n({available:!1,connections:[],conflicts:[]}),i(null)):i(t))}),()=>e.abort()},[a]),(0,q.useEffect)(()=>{let e=window.setInterval(()=>o(e=>e+1),6e4);return()=>window.clearInterval(e)},[]),{inventory:e,error:r,reload:()=>o(e=>e+1)}}function xe(e){return`${e.account} · ${e.kind===`pat`?`Personal token`:`GitHub App`}`}var Se={pending:`Waiting for installation or organization approval`,ready:`Connected`,stale:`Sync failed. Showing the last known repositories.`,suspended:`Installation suspended. Check its status on GitHub.`,removed:`Installation removed on GitHub`,disconnected:`Disconnected from Switchyard`},Ce={ready:`success`,pending:`warning`,stale:`warning`,suspended:`danger`,removed:`danger`,disconnected:`neutral`};function we(e){if(e.kind!==`pat`)return null;let t=e.selection?.owners??[],n=e.selection?.repositories??[],r=[];return t.length>0&&r.push(t.join(`, `)),n.length>0&&r.push(`${n.length} repo${n.length===1?``:`s`}`),r.length>0?r.join(` · `):`No repositories selected yet`}function Te({catalog:{inventory:e,error:t,reload:n},projects:r}){return!e&&!t?(0,J.jsx)(m,{label:`Loading repository connections…`}):(0,J.jsxs)(W,{title:`Repository connections`,description:`Connect with the GitHub App for personal accounts, or add a Personal Access Token for work organizations.`,actions:e?.available&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(h,{to:Z,className:v(`primary`,`sm`),children:[(0,J.jsx)(te,{"aria-hidden":!0,className:`size-3.5`}),`Connect GitHub`]}),(0,J.jsxs)(h,{to:ge,className:v(`secondary`,`sm`),children:[(0,J.jsx)(ie,{"aria-hidden":!0,className:`size-3.5`}),`Add Personal Token`]})]}),children:[t!=null&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{error:t}),(0,J.jsx)(g,{size:`sm`,onClick:n,children:`Reload connections`})]}),e&&!e.available&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`The repository connector is unavailable. Existing projects show the last known catalog.`}),e?.available&&e.connections.length===0&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No GitHub accounts connected.`}),e&&e.connections.length>0&&(0,J.jsx)(`div`,{className:`divide-y divide-border`,children:e.connections.map(t=>(0,J.jsx)(Ee,{connection:t,available:e.available,reload:n},t.id))}),e?.conflicts.map(t=>(0,J.jsx)(De,{conflict:t,projects:r,disabled:!e.available,reload:n},JSON.stringify([t.connectionId,t.externalId])))]})}function Ee({connection:e,available:t,reload:n}){let[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),m=(0,q.useRef)(!1),h=e.kind===`pat`,_=e.state===`disconnected`,b=!h&&!_&&(e.state===`pending`||e.state===`removed`)?Q(e.installUrl):void 0,x=_?void 0:Q(e.manageUrl),S=async t=>{if(!r){i(t),o(null);try{await T(`${Y}/${encodeURIComponent(e.id)}/${t}`),t===`disconnect`&&c(!1)}catch(e){o(e)}finally{n(),i(null)}}};(0,q.useEffect)(()=>{if(!t||_)return;let e=()=>{document.visibilityState===`visible`&&m.current&&(m.current=!1,S(`refresh`))};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}});let C=we(e);return(0,J.jsxs)(`div`,{"data-testid":`catalog-connection-${e.id}`,"data-account":e.account,className:`space-y-3 py-4 first:pt-1 last:pb-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.account}),(0,J.jsx)(M,{tone:`neutral`,children:h?`Personal token`:`GitHub App`}),(0,J.jsx)(`span`,{role:`status`,children:(0,J.jsx)(M,{tone:Ce[e.state],children:Se[e.state]})})]}),e.lastSyncedAt&&(0,J.jsxs)(`span`,{className:`text-xs text-subtle`,children:[`Synced`,` `,(0,J.jsx)(`time`,{dateTime:e.lastSyncedAt,title:f(e.lastSyncedAt),children:y(e.lastSyncedAt)})]})]}),C&&(0,J.jsx)(`p`,{className:`truncate text-xs text-muted`,children:C}),e.lastError&&(0,J.jsx)(`p`,{className:`break-words text-sm text-warning`,children:e.lastError}),b&&(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Install the app, select repositories on GitHub, then return here and refresh.`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-0.5`,children:[b&&(0,J.jsxs)(`a`,{href:b,target:`_blank`,rel:`noopener noreferrer`,className:v(`primary`,`sm`),onClick:()=>{m.current=!0},children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-3.5`}),`Install on GitHub`]}),h&&t&&!_&&(0,J.jsx)(g,{size:`sm`,disabled:!!r,onClick:()=>u(!0),children:`Edit repositories`}),x&&!b&&(0,J.jsxs)(`a`,{href:x,target:`_blank`,rel:`noopener noreferrer`,className:v(`secondary`,`sm`),onClick:()=>{m.current=!0},children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-3.5`}),h?`Manage token on GitHub`:`Manage repositories on GitHub`]}),t&&!_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(g,{size:`sm`,icon:(0,J.jsx)(d,{className:`size-3.5`}),busy:r===`refresh`,disabled:r===`disconnect`,onClick:()=>void S(`refresh`),children:e.state===`pending`||b?`Refresh connection`:`Refresh`}),(0,J.jsx)(g,{size:`sm`,variant:`ghost`,className:`ml-auto text-muted hover:text-danger`,disabled:!!r,onClick:()=>{o(null),c(!0)},children:`Disconnect`})]})]}),e.lastError?.startsWith(`Reconnect provider`)&&(0,J.jsx)(H,{to:h?ge:Z,variant:`action`,children:`Reconnect provider`}),!s&&(0,J.jsx)(p,{error:a}),(0,J.jsx)(j,{open:s,title:`Disconnect ${e.account}?`,onClose:()=>{r||c(!1)},onConfirm:()=>S(`disconnect`),confirmLabel:`Disconnect`,busy:r===`disconnect`,error:a,children:(0,J.jsx)(`p`,{className:`text-sm`,children:`Repositories shared only by this connection will move to Previous projects. Checkouts and session history will remain.`})}),h&&(0,J.jsx)(A,{open:l,onClose:()=>u(!1),title:`Edit repositories · ${e.account}`,description:`Choose organizations and individual repositories to include in Switchyard.`,children:(0,J.jsx)(Me,{connectionId:e.id,initialSelection:e.selection,onSaved:()=>{u(!1),n(),R.success(`Repositories updated`)},onCancel:()=>u(!1)})})]})}function De({conflict:e,projects:t,disabled:n,reload:r}){let i=(0,q.useId)(),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(null),d=e.projectIds.filter(e=>t.some(t=>t.id===e));return(0,J.jsxs)(`form`,{className:`space-y-2 border-t border-border pt-3`,onSubmit:async t=>{if(t.preventDefault(),!(s||n||!d.includes(a))){c(!0),u(null);try{await T(`${Y}/${encodeURIComponent(e.connectionId)}/resolve-history`,{externalId:e.externalId,projectId:a}),r(),R.success(`Existing history selected`)}catch(e){u(e)}finally{c(!1)}}},children:[(0,J.jsx)(U,{id:i,label:`Choose existing history`,hint:`More than one previous project matches ${e.fullName}. Choose which history to keep using for this repository. The others remain available separately.`,children:(0,J.jsxs)(le,{id:i,value:d.includes(a)?a:``,disabled:n||s,onChange:e=>o(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`Choose a previous project`}),d.map(e=>(0,J.jsxs)(`option`,{value:e,children:[t.find(t=>t.id===e)?.name,` · `,e]},e))]})}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(g,{size:`sm`,type:`submit`,busy:s,disabled:n||!d.includes(a),children:`Use selected history`}),d.includes(a)&&(0,J.jsx)(H,{to:V(`projects/${encodeURIComponent(a)}`),target:`_blank`,rel:`noreferrer`,children:`View selected project`})]}),(0,J.jsx)(p,{error:l})]})}function Oe({connection:e,onReady:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(null),o=Q(e.installUrl),s=(0,q.useRef)(!1),c=async()=>{if(!n){r(!0),a(null);try{(await T(`${Y}/${encodeURIComponent(e.id)}/refresh`)).connections.find(t=>t.id===e.id)?.state===`ready`&&(R.success(`GitHub repositories synced`),t())}catch(e){a(e)}finally{r(!1)}}};return(0,q.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&s.current&&c()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}}),(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Signed in as `,e.account]}),(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Choose which repositories to share on GitHub. Switchyard syncs them automatically when you return to this tab.`}),(0,J.jsx)(p,{error:i}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o&&(0,J.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:v(`primary`),onClick:()=>{s.current=!0},children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-4`}),`Choose repositories on GitHub`]}),(0,J.jsx)(g,{size:`sm`,busy:n,onClick:c,children:`Check now`}),(0,J.jsx)(h,{className:v(`secondary`),to:X,replace:!0,children:`Open Projects`})]})]})}function ke(){let e=b(),[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),h=(0,q.useRef)(!1),_=async()=>{if(!l){u(!0),f(null),i(null);try{let e=await T(`${Y}/begin`,{});if(e.mode===`oauth`){let t=Q(e.authorizeUrl);if(!t)throw Error(`GitHub did not return a valid sign-in URL.`);o(!0),window.location.assign(t);return}let t=Q(e.verificationUri);if(!t)throw Error(`GitHub did not return a valid sign-in URL.`);n({...e,verificationUri:t})}catch(e){f(e)}finally{u(!1)}}};return(0,q.useEffect)(()=>{h.current||(h.current=!0,_())},[]),(0,q.useEffect)(()=>{if(!t||r)return;let a=!0,o,s=r=>{o=window.setTimeout(async()=>{try{let r=await T(`${Y}/poll`,{flowId:t.flowId});if(!a)return;r.status===`complete`?(n(null),R.success(`Connected GitHub as ${r.connection.account}`),r.connection.state===`ready`?e(X,{replace:!0}):i(r.connection)):s(r.interval??t.interval)}catch(e){if(!a)return;f(e),n(null)}},Math.max(1,r)*1e3)};return s(t.interval),()=>{a=!1,o!==void 0&&window.clearTimeout(o)}},[t,r,e]),(0,J.jsx)(z,{title:`Connect GitHub`,description:`Sign in with GitHub once to list repositories across your personal account and organizations.`,back:ye,children:(0,J.jsx)(W,{children:a||l&&!t&&!d?(0,J.jsx)(m,{label:`Redirecting to GitHub…`}):r?(0,J.jsx)(Oe,{connection:r,onReady:()=>e(X,{replace:!0})}):t?(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Enter this code on GitHub to authorize Switchyard. This page updates automatically once you approve it.`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(`code`,{"data-testid":`github-device-code`,className:`rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-lg font-semibold tracking-widest`,children:t.userCode}),(0,J.jsx)(g,{size:`sm`,icon:s?(0,J.jsx)(F,{className:`size-4`}):(0,J.jsx)(ee,{className:`size-4`}),onClick:async()=>{try{await navigator.clipboard.writeText(t.userCode),c(!0),window.setTimeout(()=>c(!1),2e3)}catch{R.error(`Could not copy code`)}},children:s?`Copied`:`Copy code`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`a`,{href:t.verificationUri,target:`_blank`,rel:`noreferrer`,className:v(`primary`),children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-4`}),`Open GitHub`]}),(0,J.jsx)(g,{onClick:()=>{n(null),f(null)},children:`Cancel`})]}),(0,J.jsx)(`p`,{className:`text-xs text-subtle`,children:`Waiting for GitHub approval…`})]}):(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(p,{error:d}),(0,J.jsx)(g,{variant:`primary`,busy:l,onClick:_,children:`Sign in with GitHub`})]})})})}function Ae(){let e=b(),t=N(e=>e.status===`authenticated`),n=(0,q.useRef)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!t)return;if(!n.current){let e=oe();if(!e){o(!0);return}n.current=T(`${Y}/complete`,e)}let r=!0;return n.current.then(({connection:t})=>{r&&(R.success(`Connected GitHub as ${t.account}`),t.state===`ready`?e(X,{replace:!0}):i(t))},()=>{r&&o(!0)}),()=>{r=!1}},[t,e]),(0,J.jsx)(z,{title:`Connect GitHub`,back:ye,children:r?(0,J.jsx)(W,{children:(0,J.jsx)(Oe,{connection:r,onReady:()=>e(X,{replace:!0})})}):a?(0,J.jsxs)(W,{title:`Could not complete GitHub sign-in`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`This sign-in expired or was cancelled. Try connecting GitHub again from this device.`}),(0,J.jsx)(`div`,{children:(0,J.jsx)(h,{className:v(`primary`),to:Z,replace:!0,children:`Try again`})})]}):(0,J.jsx)(m,{label:`Connecting GitHub…`})})}function je(e,t,n){let r=new Set(e);return n?r.add(t):r.delete(t),r}function Me({connectionId:e,initialSelection:n,onSaved:r,onCancel:i}){let[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(!1),[h,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(()=>new Set(n?.owners??[])),[x,S]=(0,q.useState)(()=>new Set(n?.repositories??[])),[C,w]=(0,q.useState)(0),T=(0,q.useCallback)(()=>w(e=>e+1),[]);(0,q.useEffect)(()=>{let n=new AbortController;return o(null),c(null),t(`${Y}/${encodeURIComponent(e)}/available`,void 0,n.signal).then(e=>{n.signal.aborted||o(e)},e=>{n.signal.aborted||c(e)}),()=>n.abort()},[e,C]);let E=h.trim().toLowerCase(),D=(0,q.useMemo)(()=>a?E?a.owners.filter(e=>e.login.toLowerCase().includes(E)||a.repositories.some(t=>t.owner.toLowerCase()===e.login.toLowerCase()&&`${t.owner}/${t.name}`.toLowerCase().includes(E))):a.owners:[],[a,E]),O=(0,q.useMemo)(()=>{if(!a)return[];let e=[...a.repositories].sort((e,t)=>`${e.owner}/${e.name}`.localeCompare(`${t.owner}/${t.name}`));return E?e.filter(e=>`${e.owner}/${e.name}`.toLowerCase().includes(E)):e},[a,E]),k=async()=>{if(!d){f(!0),u(null);try{await _(`${Y}/${encodeURIComponent(e)}/selection`,{selection:{owners:[...y],repositories:[...x]}}),r()}catch(e){u(e)}finally{f(!1)}}};if(!a&&!s)return(0,J.jsx)(m,{label:`Loading accessible organizations and repositories…`});if(s)return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(p,{error:s}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(g,{size:`sm`,onClick:T,children:`Retry`}),i&&(0,J.jsx)(g,{size:`sm`,variant:`ghost`,onClick:i,children:`Cancel`})]})]});if(!a)return null;let A=O.slice(0,200);return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(ne,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-subtle`}),(0,J.jsx)(L,{type:`search`,"aria-label":`Search organizations or repositories`,placeholder:`Search organizations or repositories`,value:h,onChange:e=>v(e.target.value),className:`pl-8`})]}),(0,J.jsxs)(`p`,{className:`text-xs text-muted`,children:[y.size,` organization`,y.size===1?``:`s`,` and `,x.size,` individual repositor`,x.size===1?`y`:`ies`,` selected.`]}),D.length>0&&(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Organizations & accounts`}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Checking an account includes all repositories in it.`}),(0,J.jsx)(`div`,{className:`max-h-44 divide-y divide-border overflow-y-auto rounded-lg border border-border bg-surface-2/40`,children:D.map(e=>(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(K,{label:(0,J.jsxs)(`span`,{children:[e.login,` `,(0,J.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,e.type,`)`]})]}),checked:y.has(e.login),onChange:t=>b(n=>je(n,e.login,t))})},e.login))})]}),(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Repositories`}),A.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:a.repositories.length===0?`No accessible repositories returned by this token.`:`No repositories match your search.`}):(0,J.jsxs)(`div`,{className:`max-h-64 divide-y divide-border overflow-y-auto rounded-lg border border-border bg-surface-2/40`,children:[A.map(e=>{let t=`${e.owner}/${e.name}`,n=y.has(e.owner);return(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(K,{label:(0,J.jsxs)(`span`,{children:[t,n&&(0,J.jsxs)(`span`,{className:`ml-1.5 text-xs text-muted`,children:[`(via `,e.owner,`)`]})]}),checked:x.has(t),onChange:e=>S(n=>je(n,t,e))})},e.externalId)}),O.length>A.length&&(0,J.jsxs)(`p`,{className:`px-3 py-2 text-xs text-muted`,children:[`Showing first `,A.length,` of `,O.length,` matches. Search to narrow the list.`]})]})]}),(0,J.jsx)(p,{error:l}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-t border-border pt-4`,children:[i&&(0,J.jsx)(g,{disabled:d,onClick:i,children:`Cancel`}),(0,J.jsx)(g,{variant:`primary`,busy:d,onClick:()=>void k(),children:`Save selection`})]})]})}function Ne(){let e=b(),[t,n]=(0,q.useState)(``),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),l=async e=>{if(e.preventDefault(),r)return;let a=t.trim();if(a.length<10)o(Error(`Paste a valid GitHub Personal Access Token.`));else{i(!0),o(null);try{let e=await T(`${Y}/pat`,{token:a});n(``),R.success(`Connected GitHub as ${e.connection.account}`),c(e.connection)}catch(e){o(e)}finally{i(!1)}}};return(0,J.jsx)(z,{title:s?`Choose repositories · ${s.account}`:`Connect with Personal Access Token`,description:s?`Choose which organizations and individual repositories to include in Switchyard.`:`Use a Classic or Fine-Grained Personal Access Token to access work organizations without installing an app.`,back:ye,children:(0,J.jsx)(W,{children:s?(0,J.jsx)(Me,{connectionId:s.id,initialSelection:s.selection,onSaved:()=>{R.success(`Repositories updated`),e(X,{replace:!0})},onCancel:()=>e(X,{replace:!0})}):(0,J.jsxs)(`form`,{className:`max-w-xl space-y-5`,onSubmit:e=>void l(e),children:[(0,J.jsxs)(`div`,{className:`space-y-2.5 rounded-lg border border-border bg-surface-2/50 p-3.5`,children:[(0,J.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Classic PATs need `,(0,J.jsx)(`code`,{className:`text-xs`,children:`repo`}),`,`,` `,(0,J.jsx)(`code`,{className:`text-xs`,children:`read:org`}),`, and`,` `,(0,J.jsx)(`code`,{className:`text-xs`,children:`project`}),` scopes. Fine-Grained PATs are also supported.`]}),(0,J.jsx)(`div`,{children:(0,J.jsxs)(`a`,{href:ve,target:`_blank`,rel:`noopener noreferrer`,className:v(`secondary`,`sm`),children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-3.5`}),`Create a Classic PAT on GitHub`]})})]}),(0,J.jsx)(U,{label:`Personal access token`,hint:`Your token is stored only on the coordinator.`,children:e=>(0,J.jsx)(L,{...e,type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`ghp_… or github_pat_…`,value:t,onChange:e=>n(e.target.value)})}),(0,J.jsx)(p,{error:a}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,J.jsx)(g,{type:`submit`,variant:`primary`,busy:r,disabled:!t.trim(),children:`Continue`}),(0,J.jsx)(h,{className:v(`secondary`),to:X,children:`Cancel`})]})]})})})}function Pe({draft:e,errors:t,set:n,connections:r,hosts:i,columns:a}){let o=(0,q.useId)(),{inventory:s}=be(),c=r??s?.connections??[],l=e.board.trim()!==``,u=c.some(t=>t.id===e.connectionId)?e.connectionId:``;return(0,q.useEffect)(()=>{if(r===void 0&&s&&!s.connections.some(t=>t.id===e.connectionId)&&(!e.connectionId||e.connectionId.startsWith(`hst_`))){let t=(s.connections.find(e=>e.state===`ready`)??s.connections[0])?.id??``;t!==e.connectionId&&n(`connectionId`,t)}},[r,s,e.connectionId,n]),(0,J.jsxs)(`div`,{"data-testid":`github-source-form`,className:`flex flex-col gap-3`,children:[(0,J.jsx)(U,{label:`GitHub connection`,hint:c.length===0&&(r!==void 0||s!==null)?(0,J.jsxs)(J.Fragment,{children:[`No GitHub connections yet.`,` `,(0,J.jsx)(H,{to:V(`projects`),variant:`inline`,children:`Connect GitHub in Settings › Projects`}),`.`]}):`Reads issues and moves board cards for this scope.`,error:t.connectionId,children:e=>(0,J.jsxs)(le,{...e,value:u,onChange:e=>n(`connectionId`,e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`Choose a GitHub connection`}),c.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.account,` (`,e.kind===`pat`?`Personal token`:`GitHub App`,`)`]},e.id))]})}),(0,J.jsx)(U,{label:`GitHub owner`,hint:`An organization or user, such as fieldgoalco.`,error:t.owner,children:t=>(0,J.jsx)(L,{...t,value:e.owner,spellCheck:!1,onChange:e=>n(`owner`,e.target.value)})}),(0,J.jsx)(U,{label:`Repositories`,optional:!0,hint:`One owner/name per line. Leave empty for every repository of the owner.`,error:t.repositories,children:t=>(0,J.jsx)(B,{...t,rows:3,value:e.repositories,spellCheck:!1,onChange:e=>n(`repositories`,e.target.value)})}),(0,J.jsx)(U,{label:`Repositories of other owners`,optional:!0,hint:`One owner/name per line. Their projects join this scope, and issues assigned to you there are tracked too.`,error:t.extraRepositories,children:t=>(0,J.jsx)(B,{...t,rows:2,value:e.extraRepositories,spellCheck:!1,onChange:e=>n(`extraRepositories`,e.target.value)})}),(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-semibold`,children:`Projects board`}),(0,J.jsx)(U,{label:`Board number`,optional:!0,hint:`A GitHub Projects board of the owner. Needs Projects permission on the selected GitHub connection.`,error:t.board,children:t=>(0,J.jsx)(L,{...t,inputMode:`numeric`,value:e.board,onChange:e=>n(`board`,e.target.value)})}),l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`datalist`,{id:o,children:a.map(e=>(0,J.jsx)(`option`,{value:e},e))}),(0,J.jsx)(U,{label:`Issues to follow`,hint:`On the board, issues need no assignee.`,children:t=>(0,J.jsxs)(le,{...t,value:e.follow,onChange:e=>n(`follow`,e.target.value),children:[(0,J.jsx)(`option`,{value:`assigned`,children:`Assigned to me`}),(0,J.jsx)(`option`,{value:`board`,children:`Every open issue on the board`})]})}),(0,J.jsx)(U,{label:`Status field`,children:t=>(0,J.jsx)(L,{...t,value:e.statusField,onChange:e=>n(`statusField`,e.target.value)})}),(0,J.jsx)(U,{label:`Column when work starts`,optional:!0,children:t=>(0,J.jsx)(L,{...t,list:o,value:e.onStart,onChange:e=>n(`onStart`,e.target.value)})}),(0,J.jsx)(U,{label:`Column when a pull request opens`,optional:!0,children:t=>(0,J.jsx)(L,{...t,list:o,value:e.onReview,onChange:e=>n(`onReview`,e.target.value)})}),(0,J.jsx)(U,{label:`Backlog columns`,optional:!0,hint:`Cards in these columns are not tracked until they have a branch or pull request. Separate names with commas.`,error:t.backlog,children:t=>(0,J.jsx)(L,{...t,value:e.backlog,onChange:e=>n(`backlog`,e.target.value)})}),(0,J.jsx)(U,{label:`Priority field`,optional:!0,hint:`A single-select field, such as Priority. Not-started issues are listed by it.`,children:t=>(0,J.jsx)(L,{...t,value:e.priorityField,onChange:e=>n(`priorityField`,e.target.value)})}),(0,J.jsx)(G,{label:`Move cards on GitHub`,description:e.follow===`board`?`Cards assigned to you or to nobody, only the status field, and only from the column Switchyard last saw.`:`Only cards assigned to you, only the status field, and only from the column Switchyard last saw.`,checked:e.writeBack,onChange:e=>n(`writeBack`,e)}),e.writeBack&&(0,J.jsx)(G,{label:`Also move cards assigned to others too`,checked:e.moveShared,onChange:e=>n(`moveShared`,e)})]})]}),(0,J.jsx)(G,{label:`Make worktrees for issue branches`,description:`Off: Switchyard only links the worktrees you make and never creates one.`,checked:e.worktrees,onChange:e=>n(`worktrees`,e)}),(0,J.jsx)(G,{label:`Sync this scope`,checked:e.enabled,onChange:e=>n(`enabled`,e)}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Its projects are the ones in Settings › Projects whose repositories this covers.`})]})}var Fe=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),$=e=>e.split(`
2
+ `).map(e=>e.trim()).filter(Boolean);function Ie(e,t=``){let n=e?.source??null;return n?{name:e?.name??``,connectionId:n.connectionId??t,owner:n.owner,repositories:(n.repositories??[]).join(`
3
+ `),extraRepositories:(n.extraRepositories??[]).join(`
4
+ `),board:n.board?String(n.board.projectNumber):``,statusField:n.board?.statusField??`Status`,onStart:n.board?.onStart??``,onReview:n.board?.onReview??``,follow:s(n),backlog:o(n).join(`, `),priorityField:n.board?.priorityField??``,writeBack:n.writeBack,moveShared:n.moveShared,worktrees:u(n),enabled:n.enabled}:{name:e?.name??``,connectionId:t,owner:``,repositories:``,extraRepositories:``,board:``,statusField:`Status`,onStart:``,onReview:``,follow:`assigned`,backlog:``,priorityField:``,writeBack:!1,moveShared:!0,worktrees:!0,enabled:!0}}function Le(e){let t={},r=e.name.trim();r?r.length>60&&(t.name=`Use 60 characters or fewer.`):t.name=`Enter a name.`,e.connectionId||(t.connectionId=`Choose a GitHub connection.`),c.safeParse(e.owner.trim()).success||(t.owner=`Enter a GitHub organization or user name.`),$(e.repositories).some(e=>!n.safeParse(e).success)&&(t.repositories=`Use owner/name, one per line.`);let i=$(e.extraRepositories);i.some(e=>!n.safeParse(e).success)?t.extraRepositories=`Use owner/name, one per line.`:i.length>20&&(t.extraRepositories=`Use 20 repositories or fewer.`);let a=e.board.trim();return a&&!/^[1-9][0-9]*$/.test(a)&&(t.board=`Enter the board's number, as in its URL.`),Fe(e.backlog).length>20&&(t.backlog=`Use 20 columns or fewer.`),t}function Re(e){let t=$(e.repositories),n=e.board.trim(),r={connectionId:e.connectionId,owner:e.owner.trim(),repositories:t.length?t:null,extraRepositories:$(e.extraRepositories),board:n?{projectNumber:Number(n),statusField:e.statusField.trim()||`Status`,onStart:e.onStart.trim()||null,onReview:e.onReview.trim()||null,backlog:Fe(e.backlog),priorityField:e.priorityField.trim()||null}:null,follow:n?e.follow:`assigned`,writeBack:n?e.writeBack:!1,moveShared:e.moveShared,worktrees:e.worktrees,enabled:e.enabled};return{name:e.name.trim(),source:r}}function ze(e,t){let n=(()=>{if(!e.writeBack||!e.board)return`Off`;let t=[e.board.onStart?`To "${e.board.onStart}" when work starts`:null,e.board.onReview?`${e.board.onStart?`to`:`To`} "${e.board.onReview}" when a pull request opens`:null].filter(e=>!!e);return t.length===0?`On, but no columns are set`:`${t.join(`, `)}${e.moveShared?``:`; never shared cards`}`})(),r=t?e.login?`${t}, signed in as ${e.login}`:`${t}, not synced yet`:e.login?`Signed in as ${e.login}`:e.connectionId?`${e.connectionId}, not synced yet`:`Not connected (select a GitHub connection)`,i=[[`GitHub`,`${e.owner}${e.repositories?`: ${e.repositories.join(`, `)}`:` (all repositories)`}${e.extraRepositories?.length?`, plus ${e.extraRepositories.join(`, `)}`:``}`],[`Connection`,r]];return e.board&&(i.push([`Board`,`#${e.board.projectNumber}, field ${e.board.statusField}${e.board.priorityField?`, priority ${e.board.priorityField}`:``}${o(e).length?`; hides ${o(e).join(`, `)} until started`:``}`]),i.push([`Moves cards`,n])),i}var Be=[{value:`projects`,label:`Projects you choose`,explanation:`Sessions in the projects you check, plus any session you pin.`},{value:`pins`,label:`Pins only`,explanation:`Only the sessions you pin to it.`},{value:`github`,label:`GitHub issues`,explanation:`Issues assigned to you or on a Projects board, and the sessions working on them.`}];function Ve(e){return e?.source?`github`:e?.mode===`pinned`?`pins`:`projects`}function He(e,t){return{name:e?.name??``,contents:Ve(e),projectIds:e?.projectIds??[],hostIds:e?.hostIds??[],github:Ie(e,t)}}function Ue(e){let t=Le({...e.github,name:e.name});return e.contents===`github`?t:t.name?{name:t.name}:{}}function We(e,t){let n=e.name.trim(),r=e.hostIds.length?e.hostIds:null;return e.contents===`github`?{name:n,mode:`all`,hostIds:r,source:Re({...e.github,name:n}).source}:{name:n,mode:e.contents===`pins`?`pinned`:`all`,projectIds:e.projectIds.length?e.projectIds:null,hostIds:r,...t?.source?{source:null}:{}}}function Ge(e,t){return!!t?.source&&e.contents!==`github`}function Ke({scope:e,describe:t,onNavigate:n}){let r=a(e=>e.clients),i=a(e=>e.hosts),o=P(e,Object.values(r),i),s=e.name.trim().replace(/\s+/g,`-`);return(0,J.jsxs)(`dl`,{"data-testid":`scope-about`,className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-md bg-surface-2 px-3 py-2 text-sm`,children:[(0,J.jsx)(`dt`,{className:`text-muted`,children:`Contains`}),(0,J.jsx)(`dd`,{className:`min-w-0`,children:t(e)}),(0,J.jsx)(`dt`,{className:`text-muted`,children:`Mirrored in`}),(0,J.jsxs)(`dd`,{className:`flex min-w-0 flex-col gap-0.5`,children:[o??(0,J.jsx)(`span`,{children:`No client.`}),!o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`text-muted`,children:[`To mirror it in herdr, choose it in`,` `,(0,J.jsx)(H,{to:ae.settings(`clients`),onClick:n,children:`Settings › Clients`}),`, or run:`]}),(0,J.jsxs)(`code`,{className:`block break-all text-xs`,children:[`switchyard clients bind herdr:`,s,` --scope `,e.name]})]})]})]})}function qe(e,t,n){return n?[...e,t]:e.filter(e=>e!==t)}function Je({editing:e,onClose:t,onSaved:n}){let{scopes:r,describe:o}=ue(),s=O(),c=i(),{inventory:u}=be(),d=u?.connections??[],f=a(e=>e.issues),p=(d.find(e=>e.state===`ready`)??d[0])?.id??``,m=e&&e!==`new`?r[e]??null:null,h=e??`closed`,[v,y]=(0,q.useState)(null),[b,S]=(0,q.useState)(()=>He(null,p)),[E,D]=(0,q.useState)({}),[k,M]=(0,q.useState)(!1),[N,P]=(0,q.useState)(null),[ee,F]=(0,q.useState)(!1);v!==h&&(y(h),S(He(m,p)),D({}),P(null),F(!1));let I=(0,q.useMemo)(()=>m?Object.values(f).find(e=>e.scopeId===m.id&&e.board)?.board?.options.map(e=>e.name)??[]:[],[f,m]),te=(e,t)=>S(n=>({...n,github:{...n.github,[e]:t}})),ne=async()=>{let e=Ue(b);if(D(e),Object.keys(e).length>0)return;M(!0),P(null);let r=We(b,m);try{let e=m?await _(`/api/scopes/${encodeURIComponent(m.id)}`,r):await T(`/api/scopes`,r);R.success(`Scope ${e.name} saved`),n(e.id),t()}catch(e){P(e)}finally{M(!1)}},re=async()=>{if(m){M(!0);try{await l(`/api/scopes/${encodeURIComponent(m.id)}`),R.success(`Scope ${m.name} deleted`),F(!1),t()}catch(e){P(e)}finally{M(!1)}}},z=x(N,`conflict`)?w(N):null,B=e!==null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{open:B&&!ee,onClose:t,title:m?`Edit scope`:`New scope`,description:`A scope is a named part of your work, shown on Sessions and the Board.`,footer:(0,J.jsxs)(J.Fragment,{children:[m&&(0,J.jsx)(g,{variant:`danger`,onClick:()=>F(!0),className:`mr-auto`,children:`Delete`}),(0,J.jsx)(g,{onClick:t,children:`Cancel`}),(0,J.jsx)(g,{variant:`primary`,busy:k,disabled:!b.name.trim(),onClick:()=>void ne(),children:Ge(b,m)?`Save and disconnect GitHub`:`Save`})]}),children:(0,J.jsxs)(`div`,{"data-testid":`scope-form`,className:`flex flex-col gap-3`,children:[m&&(0,J.jsx)(Ke,{scope:m,describe:o,onNavigate:t}),(0,J.jsx)(U,{label:`Name`,id:`sy-scope-name`,error:E.name??z,children:e=>(0,J.jsx)(L,{...e,value:b.name,maxLength:60,onChange:e=>S({...b,name:e.target.value})})}),(0,J.jsx)(ce,{legend:`Contains`,columns:1,value:b.contents,options:Be,onChange:e=>S({...b,contents:e})}),Ge(b,m)&&(0,J.jsx)(`p`,{role:`status`,className:`rounded-md border border-border bg-warning-soft px-3 py-2 text-sm`,children:`Saving disconnects GitHub: this scope's issues leave the Board. Its sessions and worktrees stay.`}),b.contents===`projects`&&(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Projects (none checked: any)`}),s.map(e=>(0,J.jsx)(K,{label:e.name,checked:b.projectIds.includes(e.id),onChange:t=>S({...b,projectIds:qe(b.projectIds,e.id,t)})},e.id))]}),b.contents===`github`&&(0,J.jsx)(Pe,{draft:b.github,errors:E,set:te,connections:d,columns:I}),b.contents!==`pins`&&!!m?.hostIds?.length&&(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Hosts (none checked: any)`}),c.map(e=>(0,J.jsx)(K,{label:e.name,checked:b.hostIds.includes(e.id),onChange:t=>S({...b,hostIds:qe(b.hostIds,e.id,t)})},e.id))]}),N!==null&&!z&&(0,J.jsx)(C,{compact:!0,title:`Could not save`,error:w(N)})]})}),(0,J.jsx)(j,{open:B&&ee,onClose:()=>F(!1),title:`Delete this scope?`,description:`Sessions are not affected. Clients mirroring it then mirror nothing and keep their tabs.${m?.source?` Its issues are removed from the Board.`:``}`,confirmLabel:`Delete scope`,busy:k,error:N,onConfirm:()=>void re()})]})}function Ye({open:e,onOpenChange:t,trigger:n,label:r,side:i=`bottom`,align:a=`start`,initialFocus:o,className:s,fitViewport:c,children:l}){let u=(0,q.useId)(),d=(0,q.useRef)(null),f=(0,q.useRef)(null);k(d,e,()=>t(!1),o);let[p,m]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{if(!e||!c){m(null);return}let t=()=>{let e=f.current?.getBoundingClientRect();if(!e)return;let t=Math.min(288,window.innerWidth-16),n=Math.min(Math.max(e.left,8),window.innerWidth-t-8);m(i===`top`?{position:`fixed`,width:t,left:n,bottom:window.innerHeight-e.top+4,maxHeight:e.top-12}:{position:`fixed`,width:t,left:n,top:e.bottom+4,maxHeight:window.innerHeight-e.bottom-12})};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,c,i]),(0,q.useEffect)(()=>{if(!e)return;let n=e=>{let n=e.target;!d.current?.contains(n)&&!f.current?.contains(n)&&t(!1)};return document.addEventListener(`pointerdown`,n),()=>document.removeEventListener(`pointerdown`,n)},[e,t]),(0,J.jsxs)(`div`,{className:`relative inline-flex`,children:[n({ref:f,onClick:()=>t(!e),"aria-haspopup":`dialog`,"aria-expanded":e,"aria-controls":u}),e&&(0,J.jsx)(`div`,{ref:d,id:u,role:`dialog`,"aria-label":r,tabIndex:-1,style:p??void 0,className:E(p?`fixed`:`absolute`,`z-40 max-h-[calc(100dvh-2rem)] max-w-[calc(100vw-1rem)] overflow-y-auto overscroll-contain rounded-lg border border-border bg-surface p-3 shadow-pop`,!p&&(i===`top`?`bottom-full mb-1`:`top-full mt-1`),!p&&(a===`end`?`right-0`:`left-0`),s),children:l})]})}function Xe(e){let t=e.trim();return t?t.length>128||t===`.`||t===`..`||/^\.git$/i.test(t)||/[/\\]/.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)?`Use one folder name, not a path or .git.`:null:`Enter a folder name.`}function Ze(e,t=!1){return e.revokedAt?`${e.name} was revoked. Enroll it again or choose another host.`:e.connectivity===`connected`?!e.checkoutProvision&&!t?`Update this host agent to prepare checkouts, or attach an existing clone.`:null:`${e.name} is offline. Reconnect it or choose another host.`}function Qe({project:e,host:t,hasCheckout:n,attachFallback:r,onBusyChange:i,onPrepared:o}){let s=(0,q.useId)(),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),[f,m]=(0,q.useState)(),[h,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),b=(0,q.useRef)(!1),[x,S]=(0,q.useState)(null),[C,w]=(0,q.useState)(!1),E=`/api/projects/${encodeURIComponent(e.id)}/checkouts`;if(!t)return(0,J.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`No checkout yet`}),(0,J.jsxs)(`p`,{className:`text-muted`,children:[`Choose or connect a host to prepare a checkout.`,` `,(0,J.jsx)(H,{to:V(`hosts`),target:`_blank`,rel:`noreferrer`,variant:`action`,children:`Open Hosts`})]})]});let D=Ze(t,n),O=!n&&!t.checkoutRoot,k=u.trim()?Xe(u):null,A=r&&!t.revokedAt&&t.connectivity===`connected`&&!h,j=async e=>{if(!(b.current||D||O&&!h)){b.current=!0,y(`preview`),S(null);try{let n=await T(`${E}/preview`,{hostId:t.id,...e===void 0?{}:{folderName:e}});if(h&&n.path!==h)throw Error(`The checkout destination changed. Inspect the original path on the host before preparing a different checkout.`);l(n),m(e),_(null)}catch(e){S(e)}finally{b.current=!1,y(null)}}},M=async()=>{if(!(b.current||D||!c?.previewId||c.action===`collision`)){b.current=!0,y(`apply`),i?.(!0),S(null);try{let e=await T(`${E}/provision`,{previewId:c.previewId});a.getState().recordPreparedCheckout(e.checkout,e.workspaces),l(null),R.success(`Checkout ready`),o?.()}catch(e){_(c.path),l(null),S(e)}finally{b.current=!1,i?.(!1),y(null)}}};return(0,J.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-md border border-border p-3 text-sm`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:n?`Prepare checkout`:`No checkout yet`}),(0,J.jsxs)(`p`,{className:`text-muted`,children:[`Host: `,t.name]}),D&&(0,J.jsx)(`p`,{className:`text-muted`,children:D}),O&&(0,J.jsxs)(`p`,{className:`text-muted`,children:[`Set a`,` `,(0,J.jsx)(H,{to:V(`hosts/${encodeURIComponent(t.id)}`),target:`_blank`,rel:`noreferrer`,children:`checkout location`}),` `,`for this host, or attach an existing clone.`]}),h&&(0,J.jsxs)(`p`,{className:`break-words text-muted`,children:[`Check the checkout status at `,(0,J.jsx)(`span`,{className:`font-mono`,children:h}),` before trying again.`]}),(0,J.jsx)(p,{error:x}),c?(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`p`,{className:`break-words`,children:[`Destination: `,(0,J.jsx)(`span`,{className:`font-mono`,children:c.path})]}),c.action===`collision`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{children:`Choose another folder. The existing path will not be changed.`}),(0,J.jsx)(U,{label:`Alternative folder name`,id:s,error:k,children:(0,J.jsx)(L,{id:s,value:u,disabled:!!v,onChange:e=>d(e.target.value),autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...se(s,{error:k})})}),(0,J.jsx)(g,{disabled:!!D||!!v||!u.trim()||!!k||u.trim()===f,onClick:()=>void j(u.trim()),children:`Preview this folder`})]}):c.previewId?(0,J.jsx)(g,{variant:`primary`,busy:v===`apply`,disabled:!!D,onClick:()=>void M(),children:c.action===`reuse`?`Use existing checkout`:`Clone to ${t.name}`}):(0,J.jsx)(`p`,{children:`Cancel this preview and preview again before preparing this checkout.`}),(0,J.jsx)(g,{size:`sm`,variant:`ghost`,disabled:!!v,onClick:()=>{l(null),d(``),S(null)},children:`Cancel preview`})]}):!D&&(!O||h)?(0,J.jsx)(g,{busy:v===`preview`,onClick:()=>void j(h?f:void 0),children:h?`Check checkout status`:`Preview checkout`}):null,A&&(D||O||!t.checkoutProvision)&&(C?(0,J.jsx)($e,{project:e,host:t,onBusyChange:i,onAttached:()=>{w(!1),o?.()}}):(0,J.jsx)(`div`,{children:(0,J.jsx)(g,{onClick:()=>w(!0),children:`Attach existing checkout`})}))]})}function $e({project:e,host:t,onBusyChange:n,onAttached:r}){let i=(0,q.useId)(),o=(0,q.useRef)(!1),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),m=re(s);return(0,J.jsxs)(`form`,{className:`space-y-2`,onSubmit:async i=>{if(i.preventDefault(),!(o.current||m)){o.current=!0,u(!0),n?.(!0),f(null);try{let n=await T(`/api/projects/${encodeURIComponent(e.id)}/checkouts`,{hostId:t.id,path:s.trim()});a.getState().recordPreparedCheckout(n.checkout,n.workspaces),R.success(`Checkout attached`),r()}catch(e){f(e)}finally{u(!1),n?.(!1),o.current=!1}}},children:[(0,J.jsx)(U,{id:i,label:`Checkout path on the host`,hint:`Absolute path to an existing clone of this repository.`,children:(0,J.jsx)(L,{id:i,value:s,className:`font-mono`,onChange:e=>c(e.target.value),autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...se(i,{hint:!0})})}),(0,J.jsx)(p,{error:d}),(0,J.jsx)(g,{type:`submit`,busy:l,disabled:!!m,children:`Attach checkout`})]})}function et(e){return e.startsWith(`local:`)?`Local only`:e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``)}function tt(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.repoIdentity.toLowerCase().includes(n)}function nt({value:e}){let t=200,n=new Set,r=()=>(0,J.jsx)(`span`,{children:`More data omitted`});function i(e,a){if(t<=0||(t--,a>8))return r();if(e===null)return`None`;if(typeof e==`string`)return e===``?`Empty text`:e.length>4e3?`${e.slice(0,4e3)}…`:e;if(typeof e==`number`)return Number.isFinite(e)?String(e):`Not available`;if(typeof e==`boolean`)return e?`Yes`:`No`;if(typeof e!=`object`)return`Not available`;let o=Array.isArray(e),s=Object.getPrototypeOf(e);if(!o&&s!==Object.prototype&&s!==null)return`Not available`;if(n.has(e))return r();n.add(e);let c=[];if(o)for(let n=0;n<e.length;n++){if(t<=0){c.push((0,J.jsx)(`li`,{children:r()},`omitted`));break}let o=Object.getOwnPropertyDescriptor(e,String(n));c.push((0,J.jsx)(`li`,{children:i(o&&`value`in o?o.value:void 0,a+1)},n))}else for(let n in e){if(!Object.hasOwn(e,n))continue;if(t<=0){c.push((0,J.jsx)(`div`,{children:r()},`omitted`));break}let o=Object.getOwnPropertyDescriptor(e,n);c.push((0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`dt`,{className:`font-medium break-words`,children:n}),(0,J.jsx)(`dd`,{className:`min-w-0 pl-3`,children:i(o&&`value`in o?o.value:void 0,a+1)})]},n))}return n.delete(e),c.length?o?(0,J.jsx)(`ol`,{className:`min-w-0 list-decimal space-y-1 pl-5`,children:c}):(0,J.jsx)(`dl`,{className:`min-w-0 space-y-1`,children:c}):o?`No items`:`No fields`}return(0,J.jsx)(`div`,{className:`min-w-0 text-xs break-words whitespace-pre-wrap`,children:i(e,0)})}export{fe as _,Ye as a,Z as c,Ne as d,Te as f,me as g,he as h,Qe as i,ke as l,be as m,tt as n,Je as o,xe as p,et as r,ze as s,nt as t,Ae as u};
5
+ //# sourceMappingURL=StructuredValue-BjKzgQDM.js.map