mastra 1.40.2-alpha.6 → 1.40.2-alpha.7

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 (175) hide show
  1. package/dist/commands/connect/api.d.ts +2 -0
  2. package/dist/commands/connect/nango.d.ts +3 -21
  3. package/dist/commands/env/platform-api.d.ts +14 -0
  4. package/dist/commands/env/vars.d.ts +18 -0
  5. package/dist/docs/SKILL.md +1 -1
  6. package/dist/docs/assets/SOURCE_MAP.json +4 -4
  7. package/dist/docs/references/reference-cli-mastra.md +22 -0
  8. package/dist/factory/assets/{AlertDialog.es-Z2cFKrup.js → AlertDialog.es-Dd0j0SAo.js} +1 -1
  9. package/dist/factory/assets/{BoardConfigPage-D6MXB-5e.js → BoardConfigPage-CY0I73js.js} +1 -1
  10. package/dist/factory/assets/{BoardIcons-DXB--WrY.js → BoardIcons-BZwAAPO8.js} +1 -1
  11. package/dist/factory/assets/{BoardIntakePage-Bgmt_xi0.js → BoardIntakePage-BmLhWdlQ.js} +1 -1
  12. package/dist/factory/assets/{BoardRulesPage-7z2gx492.js → BoardRulesPage-CxpDy8Vt.js} +1 -1
  13. package/dist/factory/assets/{Breadcrumb.es-D9PSmzYq.js → Breadcrumb.es-CVW-e0jJ.js} +1 -1
  14. package/dist/factory/assets/Card-C1AF3dS4-gxDCT3SZ.js +1 -0
  15. package/dist/factory/assets/CodeBlock.es-BJ0-aeYG.js +6 -0
  16. package/dist/factory/assets/{CodeEditor-CfxlNg4f-D29InJfs.js → CodeEditor-DKVZX8c1-D3tFx8Wi.js} +1 -1
  17. package/dist/factory/assets/Command.es-DYk0Ffqt.js +41 -0
  18. package/dist/factory/assets/CompositeItem-CSfZykYZ.js +1 -0
  19. package/dist/factory/assets/{CompositeRoot-C9XORM0H.js → CompositeRoot-BDBckJr1.js} +1 -1
  20. package/dist/factory/assets/{ConditionRows-EkFcLg06.js → ConditionRows-BXZDW3lX.js} +1 -1
  21. package/dist/factory/assets/CreateFactoryPage-CdbDQ-iV.js +1 -0
  22. package/dist/factory/assets/{DescriptionMarkdown-CoP2xvHU.js → DescriptionMarkdown-C5kG44nn.js} +1 -1
  23. package/dist/factory/assets/{EmptyState-DJaZF543-Cw3WDQUb.js → EmptyState-DJaZF543-BTdobX9X.js} +1 -1
  24. package/dist/factory/assets/{FactorySkillPage-5Gc2equn.js → FactorySkillPage-CMrHhFOw.js} +3 -3
  25. package/dist/factory/assets/{FactorySkillsPage-BYbovjqy.js → FactorySkillsPage-vhvDsQ0Z.js} +1 -1
  26. package/dist/factory/assets/Field.es-C1w4lsXS.js +1 -0
  27. package/dist/factory/assets/{GithubIcon-CAFdTOs1.css → GithubIcon-C0PmZadW.css} +1 -1
  28. package/dist/factory/assets/GithubIcon.es-BmZS8JQG.js +55 -0
  29. package/dist/factory/assets/{GoogleIcon.es-DhsJaQu2.js → GoogleIcon.es-SXicaMB_.js} +1 -1
  30. package/dist/factory/assets/HrefLink-y54gg66e.js +1 -0
  31. package/dist/factory/assets/{IconArrowRight.es-B8AZJjlM.js → IconArrowRight.es-DoSwFft1.js} +1 -1
  32. package/dist/factory/assets/IconArrowRotateClockwise.es-CbHVv0Jf.js +1 -0
  33. package/dist/factory/assets/{IconArrowRotateCounterClockwise.es-DwgpnNS1.js → IconArrowRotateCounterClockwise.es-Dxk4yi6B.js} +1 -1
  34. package/dist/factory/assets/{IconBuildings.es-s5AevMJE.js → IconBuildings.es-DXiy4I-c.js} +1 -1
  35. package/dist/factory/assets/{IconChainLink3.es-CNFznS2g.js → IconChainLink3.es-BVxXB7oe.js} +1 -1
  36. package/dist/factory/assets/IconChevronRightMedium.es-BkPdzxSm.js +1 -0
  37. package/dist/factory/assets/{IconCircleCheck.es-e9o_0ikv.js → IconCircleCheck.es-D6u0E19o.js} +1 -1
  38. package/dist/factory/assets/{IconCircleDashed.es-Chw6BTXK.js → IconCircleDashed.es-CrssFpNj.js} +1 -1
  39. package/dist/factory/assets/{IconCircleX.es-3P8aywDS.js → IconCircleX.es-Bah9f48z.js} +1 -1
  40. package/dist/factory/assets/{IconCodeBrackets.es-o1byTuto.js → IconCodeBrackets.es-CuUuf_Z9.js} +1 -1
  41. package/dist/factory/assets/{IconFileBend.es-2E9_cK4k.js → IconFileBend.es-BDqOO-eT.js} +1 -1
  42. package/dist/factory/assets/{IconFormCircle.es-DT5Y3tym.js → IconFormCircle.es-BAAQjWeh.js} +1 -1
  43. package/dist/factory/assets/{IconHand5Finger.es-B8Atsegj.js → IconHand5Finger.es-DbQDEApG.js} +1 -1
  44. package/dist/factory/assets/{IconHashtag.es-DPNqJOUe.js → IconHashtag.es-CFMCiJRV.js} +1 -1
  45. package/dist/factory/assets/{IconKanbanView.es-CsviBYCf.js → IconKanbanView.es-CXYeZT50.js} +1 -1
  46. package/dist/factory/assets/{IconKey2.es-BpH7t1TL.js → IconKey2.es-c-pQ7fii.js} +1 -1
  47. package/dist/factory/assets/{IconMinusMedium.es-Dd0yb_Wf.js → IconMinusMedium.es-BHqCu_dX.js} +1 -1
  48. package/dist/factory/assets/{IconPencil.es-D_eBYY1c.js → IconPencil.es-DqPc7VYz.js} +1 -1
  49. package/dist/factory/assets/{IconPlugin1.es-cRNReen7.js → IconPlugin1.es-D6CUXlu_.js} +1 -1
  50. package/dist/factory/assets/{IconPlusMedium.es-QmObHPf-.js → IconPlusMedium.es-BOotRziY.js} +1 -1
  51. package/dist/factory/assets/{IconScript.es-Bpq9XfIa.js → IconScript.es-CSjJFbyA.js} +1 -1
  52. package/dist/factory/assets/{IconServer.es-ZVlwcZAW.js → IconServer.es-By-yxfUV.js} +1 -1
  53. package/dist/factory/assets/{IconSettingsSliderHor.es-CSwP_iSG.js → IconSettingsSliderHor.es-CWhsvZzL.js} +1 -1
  54. package/dist/factory/assets/{IconShieldCheck.es-vPJGxBAr.js → IconShieldCheck.es-Cps6CwGD.js} +1 -1
  55. package/dist/factory/assets/{IconSquareArrowTopRight.es-C-xkvcAK.js → IconSquareArrowTopRight.es-BA_OOKAF.js} +1 -1
  56. package/dist/factory/assets/{IconUser.es-8QnHQfy-.js → IconUser.es-ZvgkqymT.js} +1 -1
  57. package/dist/factory/assets/{IconUserDuo.es-0xR_m2_v.js → IconUserDuo.es-CJ2yCPc7.js} +1 -1
  58. package/dist/factory/assets/{InlineText-vWKzGKx_.js → InlineText-tcMMASWp.js} +1 -1
  59. package/dist/factory/assets/{Input-CNUJ--WV.js → Input-BWp76snh.js} +1 -1
  60. package/dist/factory/assets/{InputNumber.es-BoS5sRR-.js → InputNumber.es-DuTGd35f.js} +1 -1
  61. package/dist/factory/assets/KnowledgePage-DCcitSOk.js +13 -0
  62. package/dist/factory/assets/KnowledgePage-L9gD6-rr.css +1 -0
  63. package/dist/factory/assets/{LoadErrorState-DVbqZ6DX.js → LoadErrorState-B6WrspsB.js} +1 -1
  64. package/dist/factory/assets/{MarkdownRenderer-CfkpBq7t-B3F-Cy2O.js → MarkdownRenderer-BpCw3sc3-QbpHR9ZL.js} +2 -2
  65. package/dist/factory/assets/{MastraGatewayBilling-DJPEHZAK.js → MastraGatewayBilling-DHfgi3gb.js} +1 -1
  66. package/dist/factory/assets/{NewBoardPage-BodHD8H8.js → NewBoardPage-DoLZgbSQ.js} +1 -1
  67. package/dist/factory/assets/{NewPage-DzoengAI.js → NewPage-c0luvVcE.js} +1 -1
  68. package/dist/factory/assets/{OnboardingPage-C4cH2Ucw.js → OnboardingPage-DUlIJiRQ.js} +1 -1
  69. package/dist/factory/assets/{ProviderBrandIcon-CdBRvNbA.js → ProviderBrandIcon-DvMLpnTc.js} +1 -1
  70. package/dist/factory/assets/{RadioGroup-CM2PCyNZ.js → RadioGroup-B980sx1z.js} +1 -1
  71. package/dist/factory/assets/{RadioGroup.es-Ws4_oCJe.js → RadioGroup.es-BfW3ErPZ.js} +1 -1
  72. package/dist/factory/assets/{RootGuards-dZlWJMm5.js → RootGuards-BNlIx3jH.js} +1 -1
  73. package/dist/factory/assets/{RulesPage-DLQAZVIA.js → RulesPage-Dul5FLpw.js} +1 -1
  74. package/dist/factory/assets/SearchInput.es-B6oIv0hQ.js +1 -0
  75. package/dist/factory/assets/SessionLayout-2Oqv7hBl.js +4 -0
  76. package/dist/factory/assets/SessionPage-DkoKp_WW.js +1 -0
  77. package/dist/factory/assets/{SessionSharingPopover-B-YZDS4X.js → SessionSharingPopover-d9TlNyFr.js} +1 -1
  78. package/dist/factory/assets/SettingsPage-Da0IUyQa.js +3 -0
  79. package/dist/factory/assets/{SettingsSubsection-DznON6FW.js → SettingsSubsection-B_X_u0Kt.js} +1 -1
  80. package/dist/factory/assets/Sidebar.es-CFLW5bYW.js +1 -0
  81. package/dist/factory/assets/{SignInPage-BuZ1OFJf.js → SignInPage-BCtFfzzk.js} +1 -1
  82. package/dist/factory/assets/{SkillBadges-DbbPhC5O.js → SkillBadges-IJt3Rano.js} +1 -1
  83. package/dist/factory/assets/{SlackConnectionPage-BNQ6GOrm.js → SlackConnectionPage-BnDwJ3TI.js} +1 -1
  84. package/dist/factory/assets/{StackedDiffs-thBeypvG.js → StackedDiffs-C6mm4aE1.js} +1 -1
  85. package/dist/factory/assets/TabsRoot-DNjGHnQQ.js +1 -0
  86. package/dist/factory/assets/ThinkingLevel.es-DUHMUmiq.js +1 -0
  87. package/dist/factory/assets/{TrashIcon.es-CLx-KWTg.js → TrashIcon.es-DoCvaCDh.js} +1 -1
  88. package/dist/factory/assets/{Tree-B90XgTY4-CO90N5uT.js → Tree-B90XgTY4-B_Crja84.js} +1 -1
  89. package/dist/factory/assets/{buttons-group-DA_wORqQ-DfA-q_d9.js → buttons-group-DA_wORqQ-87uBfszt.js} +1 -1
  90. package/dist/factory/assets/buttons-group-DA_wORqQ-CAiyfnsa.css +1 -0
  91. package/dist/factory/assets/combobox-parts-DhYtFSRV-BZqyW5dv.js +1 -0
  92. package/dist/factory/assets/{copy-button-Brk8iwgE-DHsIfP0z.js → copy-button-BPysC9gu-Ce9_m0Wu.js} +1 -1
  93. package/dist/factory/assets/{createLucideIcon-B6gALBEh.js → createLucideIcon-BHFyd0LL.js} +1 -1
  94. package/dist/factory/assets/{esm-Dp9Y59hS.js → esm-KJWZ33y-.js} +1 -1
  95. package/dist/factory/assets/index-CNDr9VfG.css +1 -0
  96. package/dist/factory/assets/{index-DfNj4qTr.js → index-DtRZNzyn.js} +17 -17
  97. package/dist/factory/assets/{index.module-D3qeux6j.js → index.module-Dtojw6Gd.js} +1 -1
  98. package/dist/factory/assets/{input-DqReKX0A-B4MUvQwj.js → input-DqReKX0A-ScC7s6sY.js} +3 -3
  99. package/dist/factory/assets/{input-group-C2kg3je7-38FwKlyX.js → input-group-C64rGEu8-tF1AZfiZ.js} +1 -1
  100. package/dist/factory/assets/{onboardingFlow-D-slZE6d.js → onboardingFlow-DTVR_ThV.js} +1 -1
  101. package/dist/factory/assets/{overlays-B3sO28Cg.js → overlays-B4T3HdBk.js} +1 -1
  102. package/dist/factory/assets/{popup-anchor.es-B4jCSTe8.js → popup-anchor.es-g9MI9mVW.js} +1 -1
  103. package/dist/factory/assets/relative-time.es-BTUAMo6M.js +1 -0
  104. package/dist/factory/assets/{ruleLanes-D9QkgLJm.js → ruleLanes-zac0HQwn.js} +1 -1
  105. package/dist/factory/assets/select-jT0h_BBB-6ji8g_rW.js +1 -0
  106. package/dist/factory/assets/{selection-control.es-B9lRtuFy.js → selection-control.es-BcC6tY27.js} +1 -1
  107. package/dist/factory/assets/settings-C5r2ThW9-D7BpEINa.js +1 -0
  108. package/dist/factory/assets/{settingsSections-B0_LEh3l.js → settingsSections-XZPX_pR6.js} +1 -1
  109. package/dist/factory/assets/{spinner-B9ykw74u-oAX9C1zS.js → spinner-B9ykw74u-DYljVQkq.js} +1 -1
  110. package/dist/factory/assets/use-isomorphic-layout-effect.es-D5aMR-pO.js +1 -0
  111. package/dist/factory/assets/use-keydown.es-Celupa-_.js +1 -0
  112. package/dist/factory/assets/use-measured-auto-height.es-Do6xK0xw.js +1 -0
  113. package/dist/factory/assets/{useBoardCatalog-DZf1osB2.js → useBoardCatalog-C-gXjA-g.js} +1 -1
  114. package/dist/factory/assets/{useBoardEditor-Dm78Yoiu.js → useBoardEditor-Bn11vS5Q.js} +1 -1
  115. package/dist/factory/assets/useChatSessionContext-CAxNkdHm.js +1 -0
  116. package/dist/factory/assets/{useDocumentVisible-b4XBg6N4.js → useDocumentVisible-Dj_ihe5o.js} +1 -1
  117. package/dist/factory/assets/useDraftModelGuards-BCXwizit.css +1 -0
  118. package/dist/factory/assets/{useDraftModelGuards-CVpGc7UY.js → useDraftModelGuards-_-KExOpc.js} +15 -15
  119. package/dist/factory/assets/{useFactoryDecisions-C9GWqAN_.js → useFactoryDecisions-600qQ62i.js} +1 -1
  120. package/dist/factory/assets/{useGlobalSearchControls-BbAiVtBx.js → useGlobalSearchControls-CDvuBRkd.js} +1 -1
  121. package/dist/factory/assets/{useInfiniteQuery-hSoUGHIM.js → useInfiniteQuery-BqXR1JQ-.js} +1 -1
  122. package/dist/factory/assets/{useIntakeRoutes-BNBPe6sx.js → useIntakeRoutes-OObHoZos.js} +1 -1
  123. package/dist/factory/assets/{useLinearData-XOkwHgla.js → useLinearData-Bbyd0L4b.js} +1 -1
  124. package/dist/factory/assets/{usePlatformConnections-R32iBFFQ.js → usePlatformConnections-PVZyB721.js} +1 -1
  125. package/dist/factory/assets/{useRouteSessionId-DhLFIOOv.js → useRouteSessionId-DjQx4Cd4.js} +1 -1
  126. package/dist/factory/assets/{useRowDrag-DQBjWerU.js → useRowDrag-0taus7Yi.js} +1 -1
  127. package/dist/factory/assets/{useSessionCard-CiybjeGQ.js → useSessionCard-bQ1xW_Go.js} +1 -1
  128. package/dist/factory/assets/{useSessionRepository-BEhYLqfE.js → useSessionRepository-tNhUsjDB.js} +1 -1
  129. package/dist/factory/assets/{useSessionRows-aTHnrKGG.js → useSessionRows-CnLoToLZ.js} +1 -1
  130. package/dist/factory/assets/{useThreadWorkspacePath-B11HTzns.js → useThreadWorkspacePath-BZmjtdux.js} +1 -1
  131. package/dist/factory/assets/workspaces-DgeuLqOD.js +2 -0
  132. package/dist/factory/index.html +68 -68
  133. package/dist/index.js +160 -17
  134. package/dist/studio/assets/{CodeDiff.es-4MSY_kim.js → CodeDiff.es-DPLF0xDv.js} +1 -1
  135. package/dist/studio/assets/{index-WsPILIoi.js → index-DMAiK4D1.js} +2 -2
  136. package/dist/studio/assets/lib-DtdM3YyA.js +1 -0
  137. package/dist/studio/assets/{main-RtWN6k82.js → main-BGtwg6oJ.js} +276 -276
  138. package/dist/studio/assets/style-DpqHossu.css +3 -0
  139. package/dist/studio/index.html +2 -2
  140. package/package.json +5 -5
  141. package/dist/factory/assets/Card-BbxDmj8W-BRp0MNo6.js +0 -1
  142. package/dist/factory/assets/CodeBlock.es-BeD4YikJ.js +0 -6
  143. package/dist/factory/assets/Command.es-Dzh7LzCA.js +0 -41
  144. package/dist/factory/assets/CompositeItem-CD2x3KaL.js +0 -1
  145. package/dist/factory/assets/CreateFactoryPage-CpCoY7SG.js +0 -1
  146. package/dist/factory/assets/Field.es-BmqB8MIv.js +0 -1
  147. package/dist/factory/assets/GithubIcon.es-B1lB1Q-8.js +0 -55
  148. package/dist/factory/assets/HrefLink-Q5kgIdVD.js +0 -1
  149. package/dist/factory/assets/IconArrowRotateClockwise.es-C13-sgU6.js +0 -1
  150. package/dist/factory/assets/IconChevronRightMedium.es-BjSIsine.js +0 -1
  151. package/dist/factory/assets/KnowledgePage-BuLpZT5G.css +0 -1
  152. package/dist/factory/assets/KnowledgePage-TsgNTo8W.js +0 -13
  153. package/dist/factory/assets/KnowledgePageCard.es-CevF12s3.js +0 -1
  154. package/dist/factory/assets/SearchInput.es-CzE_Qk4w.js +0 -1
  155. package/dist/factory/assets/SessionLayout-DcW2_NIr.js +0 -4
  156. package/dist/factory/assets/SessionPage-DV9mReRe.js +0 -1
  157. package/dist/factory/assets/SettingsPage-CRTowo_E.js +0 -3
  158. package/dist/factory/assets/Sidebar.es-9pwBnu_Z.js +0 -1
  159. package/dist/factory/assets/SkeletonRows-6RPIfKEw.js +0 -1
  160. package/dist/factory/assets/TabsRoot-C1o0G1CK.js +0 -1
  161. package/dist/factory/assets/ThinkingLevel.es-D6B6ha12.js +0 -1
  162. package/dist/factory/assets/buttons-group-DA_wORqQ-CQ16Y5ib.css +0 -1
  163. package/dist/factory/assets/combobox-parts-s-DJvMW4-CR5ZbuEq.js +0 -1
  164. package/dist/factory/assets/index-BZ_1FOXM.css +0 -1
  165. package/dist/factory/assets/relative-time.es-Dgi2DC2E.js +0 -1
  166. package/dist/factory/assets/select-Bdt18YBg-DJqvU5Dv.js +0 -1
  167. package/dist/factory/assets/settings-DTWGb7K_-PW2CFx0g.js +0 -1
  168. package/dist/factory/assets/use-isomorphic-layout-effect.es-BlwNoFb0.js +0 -1
  169. package/dist/factory/assets/useChatSessionContext-BHyuVY1T.js +0 -1
  170. package/dist/factory/assets/useDraftModelGuards-Cky35Lcg.css +0 -1
  171. package/dist/factory/assets/workspaces-C47kKdw3.js +0 -2
  172. package/dist/studio/assets/lib-G2sOOZND.js +0 -1
  173. package/dist/studio/assets/style-B0eucVno.css +0 -3
  174. /package/dist/factory/assets/{MarkdownRenderer-CfkpBq7t-C04mQel5.css → MarkdownRenderer-BpCw3sc3-C04mQel5.css} +0 -0
  175. /package/dist/factory/assets/{combobox-parts-s-DJvMW4-CYlMQsMB.css → combobox-parts-DhYtFSRV-CYlMQsMB.css} +0 -0
@@ -60,6 +60,8 @@ export interface ConnectSession {
60
60
  connectUrl: string;
61
61
  /** Nango connect session token for the headless auth flow. */
62
62
  sessionToken: string;
63
+ /** Nango API host for this session (self-hosted Nango). Absent on older platforms. */
64
+ apiBaseUrl?: string | null;
63
65
  expiresAt: string;
64
66
  }
65
67
  export declare function fetchIntegrationCatalog(token: string, orgId: string): Promise<IntegrationCatalogEntry[]>;
@@ -1,24 +1,4 @@
1
1
  import type { IntegrationAuthField } from './api.js';
2
- /**
3
- * Headless Nango auth for the CLI, ported from the platform frontend's
4
- * `headless-connect.ts`.
5
- *
6
- * For OAuth (including MCP, which is OAuth 2 under the hood) Nango exposes a
7
- * plain URL — `/oauth/connect/:integrationId?connect_session_token=…` — that
8
- * redirects straight to the provider's own consent screen, so the CLI opens
9
- * it in the user's browser with no intermediate Nango-branded page. Any
10
- * params the provider needs first (e.g. an MCP server URL) come from
11
- * `authFields` and are collected in the terminal before the browser opens.
12
- *
13
- * For API key / Basic auth no browser is involved at all: the credentials are
14
- * POSTed to Nango's `/api-auth/*` endpoints keyed by the connect session
15
- * token, and Nango validates them with the provider.
16
- *
17
- * Remaining auth types (two-step, app, …) still need the forms and setup
18
- * guides Nango's hosted Connect UI renders, so the CLI falls back to opening
19
- * the session's `connectUrl`.
20
- */
21
- export declare const NANGO_HOST: string;
22
2
  export declare function isOAuthAuthType(authType: string | null): boolean;
23
3
  export declare function isCredentialAuthType(authType: string | null): boolean;
24
4
  /** The form fields to collect before auth can start. */
@@ -37,7 +17,7 @@ export declare function splitAuthValues(fields: IntegrationAuthField[], values:
37
17
  * detected by polling the platform's connection list rather than the SDK's
38
18
  * websocket channel.
39
19
  */
40
- export declare function oauthConnectUrl(integrationId: string, sessionToken: string, params?: Record<string, string>): string;
20
+ export declare function oauthConnectUrl(integrationId: string, sessionToken: string, params?: Record<string, string>, apiBaseUrl?: string | null): string;
41
21
  /**
42
22
  * Submit API key / Basic credentials to Nango, mirroring the frontend SDK's
43
23
  * `customAuth` fetch for the two credential shapes the CLI supports.
@@ -46,6 +26,8 @@ export declare function submitCredentialAuth(input: {
46
26
  integrationId: string;
47
27
  authType: string | null;
48
28
  sessionToken: string;
29
+ /** Nango host returned with the connect session, if any. */
30
+ apiBaseUrl?: string | null;
49
31
  credentials: Record<string, string>;
50
32
  params?: Record<string, string>;
51
33
  }): Promise<void>;
@@ -99,6 +99,20 @@ export declare function createEnvironment(token: string, orgId: string, projectI
99
99
  * immediately. 409 means the environment has never been deployed.
100
100
  */
101
101
  export declare function restartEnvironment(token: string, orgId: string, projectId: string, envId: string): Promise<void>;
102
+ /**
103
+ * Save an environment's env vars and/or their kinds.
104
+ *
105
+ * `envVars` replaces the whole stored map, so callers must send every var
106
+ * they want to keep. Write-only secrets can be kept by sending
107
+ * `SECRET_VALUE_PLACEHOLDER` as their value. `envVarMeta` flags apply to the
108
+ * named vars only; other vars keep their stored kind.
109
+ */
110
+ export declare function updateEnvironmentVars(token: string, orgId: string, projectId: string, envId: string, updates: {
111
+ envVars?: Record<string, string>;
112
+ envVarMeta?: Record<string, {
113
+ secret: boolean;
114
+ }>;
115
+ }): Promise<Environment>;
102
116
  export declare function deleteEnvironment(token: string, orgId: string, projectId: string, envId: string): Promise<void>;
103
117
  /**
104
118
  * Look up an existing diagnosis for a failed environment deploy.
@@ -26,4 +26,22 @@ export declare function envVarsPullAction(envArg: string | undefined, options: {
26
26
  output?: string;
27
27
  force?: boolean;
28
28
  }): Promise<void>;
29
+ /**
30
+ * Set env vars on an environment and/or choose their kind.
31
+ *
32
+ * Secrets are write-only: the platform encrypts them and only delivers them
33
+ * to the deployed service at boot. Config vars stay readable and are stored
34
+ * on the provider. `--secret`/`--config` apply to every variable in the
35
+ * command and send `envVarMeta` flags for them; vars not in the command keep
36
+ * their stored kind. Bare `KEY` arguments change only the kind.
37
+ *
38
+ * The platform replaces the whole env map on save, so the stored vars are
39
+ * sent back with the new values merged in. Write-only secrets come back as a
40
+ * placeholder, which the platform reads as "keep the stored value".
41
+ */
42
+ export declare function envVarsSetAction(envArg: string | undefined, varArgs: string[], options: {
43
+ project?: string;
44
+ secret?: boolean;
45
+ config?: boolean;
46
+ }): Promise<void>;
29
47
  //# sourceMappingURL=vars.d.ts.map
@@ -3,7 +3,7 @@ name: mastra
3
3
  description: Documentation for mastra. Use when working with mastra APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "mastra"
6
- version: "1.40.2-alpha.6"
6
+ version: "1.40.2-alpha.7"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.40.2-alpha.6",
2
+ "version": "1.40.2-alpha.7",
3
3
  "package": "mastra",
4
4
  "exports": {
5
5
  "PosthogAnalytics": {
@@ -10,7 +10,7 @@
10
10
  "analytics": {
11
11
  "types": "dist/index.d.ts",
12
12
  "implementation": "dist/index.js",
13
- "line": 40193
13
+ "line": 40336
14
14
  },
15
15
  "create": {
16
16
  "types": "dist/commands/create/create.d.ts",
@@ -20,12 +20,12 @@
20
20
  "origin": {
21
21
  "types": "dist/index.d.ts",
22
22
  "implementation": "dist/index.js",
23
- "line": 40200
23
+ "line": 40343
24
24
  },
25
25
  "version": {
26
26
  "types": "dist/index.d.ts",
27
27
  "implementation": "dist/index.js",
28
- "line": 40192
28
+ "line": 40335
29
29
  },
30
30
  "answerRelevancyScorer": {
31
31
  "types": "dist/index.d.ts",
@@ -505,6 +505,28 @@ File to write. Defaults to `.env`.
505
505
 
506
506
  Replace an existing output file.
507
507
 
508
+ ### `mastra env vars set`
509
+
510
+ Sets env vars on an environment and chooses whether they're stored as a [secret or config](https://mastra.ai/docs/mastra-platform/deploy/environments), leaving variables you don't name at their stored values. New values apply on the next deploy or `mastra env restart`.
511
+
512
+ ```bash
513
+ mastra env vars set <env> API_KEY=sk-123 --secret
514
+ mastra env vars set <env> LOG_LEVEL=debug FEATURE_X=on --config
515
+ mastra env vars set <env> DATABASE_URL --secret
516
+ ```
517
+
518
+ Pass variables as `KEY=VALUE`. To change only how an existing variable is stored, pass its name without a value along with `--secret` or `--config`. The flag applies to every variable in the command, so set secrets and config values with separate commands.
519
+
520
+ `<env>` can be an environment name, slug, or ID, and can be omitted when the project has exactly one environment. Values passed on the command line can end up in your shell history.
521
+
522
+ #### `--secret`
523
+
524
+ Store every variable in the command as a secret, which is write-only and delivered at boot.
525
+
526
+ #### `--config`
527
+
528
+ Store every variable in the command as config, which stays readable and is stored on the hosting provider. Converting an existing secret into config requires passing its value in the same command, because the platform can't read the stored secret back.
529
+
508
530
  ### `mastra env db`
509
531
 
510
532
  Manages databases attached to a project on Mastra platform. Databases are provisioned from a managed provider (for example Turso or Neon) and inject their connection env vars into deploys automatically.
@@ -1 +1 @@
1
- import{At as e,Dt as t,Et as n,Mt as r,Nt as i,Ot as a,Pt as o,St as s,Tt as c,jt as l,kt as u,ni as d,wt as f}from"./GithubIcon.es-B1lB1Q-8.js";import{O as p,T as m}from"./IconChevronRightMedium.es-BjSIsine.js";var h=p();function g(e){return(0,h.jsx)(s,{...e,modal:!0,disablePointerDismissal:!0})}function _({size:e=`sm`,...n}){return(0,h.jsx)(t,{"data-slot":`alert-dialog-content`,size:e,showCloseButton:!1,...n,role:`alertdialog`})}function v({children:e,...t}){return(0,h.jsx)(n,{render:(0,h.jsx)(d,{variant:`primary`,size:`md`,className:m(i,o.md),children:e}),...t})}g.Trigger=r,g.Content=_,g.Header=e,g.Footer=u,g.Body=f,g.Title=l,g.Description=a,g.Action=v,g.Cancel=c;export{g as t};
1
+ import{At as e,Dt as t,Et as n,Mt as r,Nt as i,Ot as a,Pt as o,St as s,Tt as c,jt as l,kt as u,ni as d,wt as f}from"./GithubIcon.es-BmZS8JQG.js";import{O as p,T as m}from"./IconChevronRightMedium.es-BkPdzxSm.js";var h=p();function g(e){return(0,h.jsx)(s,{...e,modal:!0,disablePointerDismissal:!0})}function _({size:e=`sm`,...n}){return(0,h.jsx)(t,{"data-slot":`alert-dialog-content`,size:e,showCloseButton:!1,...n,role:`alertdialog`})}function v({children:e,...t}){return(0,h.jsx)(n,{render:(0,h.jsx)(d,{variant:`primary`,size:`md`,className:m(i,o.md),children:e}),...t})}g.Trigger=r,g.Content=_,g.Header=e,g.Footer=u,g.Body=f,g.Title=l,g.Description=a,g.Action=v,g.Cancel=c;export{g as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-D9PSmzYq.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,Cr as a,Fr as o,Gn as s,Nr as c,O as l,Pr as u,Qn as d,Tr as f,Wn as p,Xn as m,Zn as h,_r as g,ar as _,br as v,dr as y,er as b,fr as x,gr as S,in as C,ir as w,k as T,mr as E,nn as ee,nr as D,pn as te,pr as O,rn as k,rr as A,sr as j,tn as M,tr as N,ur as P,wr as ne,xr as re}from"./index-DfNj4qTr.js";import{a as ie}from"./Sidebar.es-9pwBnu_Z.js";import{d as F,f as I,i as ae,t as L,u as R}from"./settings-DTWGb7K_-PW2CFx0g.js";import{O as oe,T as z,k as se,n as B,s as V,t as ce}from"./IconChevronRightMedium.es-BjSIsine.js";import{$n as H,Fi as le,Li as ue,Pi as de,Qr as fe,cr as pe,dr as me,n as U,ni as W,r as he,zt as ge}from"./GithubIcon.es-B1lB1Q-8.js";import{c as _e,o as ve,r as ye,s as be,t as xe}from"./useBoardEditor-Dm78Yoiu.js";import{i as Se,t as Ce}from"./SkillBadges-DbbPhC5O.js";import{a as G,c as we,f as Te,l as Ee,s as De}from"./boardConfigPaths-Btimpi_r.js";import{t as K}from"./AlertDialog.es-Z2cFKrup.js";import{t as q}from"./SettingsSubsection-DznON6FW.js";import{r as Oe}from"./CompositeItem-CD2x3KaL.js";import{n as ke}from"./useBoardCatalog-DZf1osB2.js";import{h as Ae,o as je}from"./useIntakeRoutes-BNBPe6sx.js";import{a as Me,d as Ne,t as Pe}from"./BoardIcons-DXB--WrY.js";import{i as Fe,n as Ie,r as Le,t as Re}from"./IconPencil.es-D_eBYY1c.js";import{r as ze}from"./overlays-B3sO28Cg.js";import{t as Be}from"./DescriptionMarkdown-CoP2xvHU.js";import{h as Ve,w as He,y as Ue}from"./ruleLanes-D9QkgLJm.js";import{k as We}from"./TabsRoot-C1o0G1CK.js";import{t as Ge}from"./CodeEditor-CfxlNg4f-D29InJfs.js";import{a as Ke,n as qe,r as Je,t as Ye}from"./Field.es-BmqB8MIv.js";import{t as Xe}from"./input-DqReKX0A-B4MUvQwj.js";import{a as Ze,n as Qe}from"./input-group-C2kg3je7-38FwKlyX.js";import{a as $e,i as et,n as tt,r as nt,t as rt}from"./InputNumber.es-BoS5sRR-.js";import{i as it,n as at,r as ot,t as st}from"./select-Bdt18YBg-DJqvU5Dv.js";import{E as ct}from"./combobox-parts-s-DJvMW4-CR5ZbuEq.js";import{n as lt,t as ut}from"./ConditionRows-EkFcLg06.js";import{n as dt}from"./IconUserDuo.es-0xR_m2_v.js";import{_t as ft}from"./useSessionRows-aTHnrKGG.js";import{t as pt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as mt}from"./TrashIcon.es-CLx-KWTg.js";import{n as ht,t as gt}from"./boardCatalog-y-s19dQU.js";import{t as _t}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as vt}from"./InlineText-vWKzGKx_.js";import{t as yt}from"./LoadErrorState-DVbqZ6DX.js";var J=e(se(),1),bt=`mx-auto w-full max-w-2xl`,xt=`[container-type:inline-size] h-full min-h-0 overflow-auto overscroll-x-contain [scrollbar-gutter:stable]`,St=`sticky left-0 w-[100cqw] px-4`,Y=oe();function X({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Y.jsx)(`div`,{className:z(St,i),children:(0,Y.jsx)(`div`,{className:z(bt,n),children:r})}):(0,Y.jsx)(`div`,{className:z(bt,i,n),children:r})}function Ct({factoryId:e,boardId:t,phase:n,skills:r}){let i=n.runner;if(!i)return null;let a=i.skill,o=a?r?.find(e=>e.name===a):void 0,s=a!==void 0&&r!==void 0&&o===void 0,c=s||o?.error!==void 0,u=a&&!s?we(e,t,a):G(e,t,n.key),f=a?l:ze;return(0,Y.jsxs)(Ie,{children:[(0,Y.jsxs)(Fe,{delay:0,closeDelay:100,render:(0,Y.jsx)(H,{to:u}),className:z(V,`border-border bg-fill-subtle hover:bg-fill flex w-fit max-w-full min-w-0 items-center gap-1.5 rounded-md border px-1.5 py-0.5 transition-colors`,c&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Y.jsx)(f,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Y.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),c&&(0,Y.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Y.jsxs)(Le,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-96 max-w-[calc(100vw-2rem)] flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(f,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Y.jsx)(Ce,{skill:o})]}),s?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,a,` skill, so cards entering `,n.name,` fail to start.`]}):o?.error?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Y.jsx)(d,{children:`Loading the skill…`}),o?.content.trim()&&(0,Y.jsx)(wt,{title:`Skill instructions`,children:(0,Y.jsx)(Be,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Y.jsx)(wt,{title:`${n.name} adds`,children:(0,Y.jsx)(Be,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Y.jsx)(wt,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Y.jsx)(B,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Y.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function wt({title:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Y.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Tt({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Y.jsxs)(Ie,{children:[(0,Y.jsx)(Fe,{delay:0,closeDelay:100,render:(0,Y.jsx)(H,{to:n}),className:z(V,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ve(e.length)}),(0,Y.jsxs)(Le,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2`,children:[(0,Y.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Y.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Y.jsx)(s,{rule:e,boardId:r,boards:i},e.id))})]})]})}var Et=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Dt({factoryId:e,boardId:t,phases:n,skills:r,action:a,onAutoStart:o}){let s=ke(e),c=je(e),l=s.isPending||c.isPending,u=s.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,f=n.map(e=>h(e,n)),g=c.data&&u?i(c.data.intakeRoutes,{key:t,initialPhase:u}):void 0;return(0,Y.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[a&&(0,Y.jsx)(X,{pinned:!0,className:`flex justify-end`,children:a}),c.isError&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(U,{variant:`warning`,children:(0,Y.jsx)(U.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),g&&g.leaving.length>0&&(0,Y.jsx)(X,{pinned:!0,className:`mb-4`,children:(0,Y.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Y.jsx)(Tt,{rules:g.leaving,title:`Rules that send cards to other boards`,to:De(e,t,`leaving`),boardId:t,boards:s.data}),` `,g.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Y.jsx)(`ol`,{"aria-label":`Phases`,className:z(`mx-auto flex w-max`,Et),children:n.map(i=>{let a=Me(t,i.kind),c=g?.into.get(i.key)??[];return(0,Y.jsxs)(`li`,{"aria-label":i.name,className:`before:via-border-strong relative flex w-64 shrink-0 flex-col px-2 not-first:before:absolute not-first:before:inset-y-0 not-first:before:left-0 not-first:before:w-px not-first:before:bg-linear-to-b not-first:before:from-transparent not-first:before:to-transparent`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Y.jsxs)(H,{to:G(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Y.jsx)(Pe,{stage:i.key,kind:a,decorative:!0}),(0,Y.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Y.jsx)(`div`,{className:`px-3 py-3`,children:(0,Y.jsx)(m,{boardId:t,phase:h(i,n),phases:f,arrivals:(0,Y.jsxs)(Y.Fragment,{children:[l?(0,Y.jsx)(Oe,{className:`h-4 w-20`}):g?c.length>0?(0,Y.jsx)(Tt,{rules:c,title:`Rules that move cards into ${i.name}`,to:De(e,t,{into:i.key}),boardId:t,boards:s.data}):(0,Y.jsx)(d,{children:`No rule moves cards here`}):(0,Y.jsx)(d,{children:`Rules didn’t load`}),i.key===u&&(0,Y.jsx)(d,{children:`New cards start here`})]}),starts:(0,Y.jsx)(p,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:o&&(e=>o(i.key,e))}),agent:(0,Y.jsx)(Ct,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Ot=`Finish or remove unfinished conditions to save.`;function kt({label:e,description:t,rule:n,disabled:r,facts:i=Ue,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,J.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,J.useId)(),g=p===void 0?a(s,n):v(s,p),_=e=>{m(e);let t=re(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Y.jsxs)(Ye,{invalid:g!==void 0,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(Ke,{htmlFor:h,children:e}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,a(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Y.jsx)(qe,{children:t}),p===void 0?r?(0,Y.jsx)(B,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:He(n,o)}):(0,Y.jsx)(`div`,{id:h,children:(0,Y.jsx)(ut,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Ot):l(e,a(s,e))}})}):(0,Y.jsx)(M,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Y.jsx)(Je,{children:g})]})}var At=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function jt({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let s=e=>o(n.includes(e)?n.filter(t=>t!==e):t.filter(t=>t.key===e||n.includes(t.key)).map(e=>e.key));return(0,Y.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Y.jsx)(Pe,{stage:t.key,kind:Me(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Y.jsxs)(`li`,{className:z(At,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`(this phase)`})]},t.key);let c=n.includes(t.key),l=c&&r.has(t.key),u=l||a,d=(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":l?`${t.name} (locked)`:void 0,"aria-disabled":u||void 0,onClick:u?void 0:()=>s(t.key),className:z(At,`group/move transition-colors`,c?`bg-fill text-foreground border-transparent`:`border-border text-muted-foreground border-dashed`,!u&&(c?`hover:bg-fill-hover`:`hover:text-foreground hover:border-border-strong`),u&&!l&&`cursor-default`,V),children:[(0,Y.jsx)(`span`,{className:z(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Y.jsx)(dt,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Y.jsx)(ft,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Y.jsx)(pt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Y.jsx)(`li`,{className:`min-w-0`,children:l?(0,Y.jsxs)(de,{children:[(0,Y.jsx)(ue,{render:d}),(0,Y.jsx)(le,{children:`Factory's code makes this move`})]}):d},t.key)})})}function Mt({children:e}){return(0,Y.jsx)(B,{as:`span`,variant:`label`,className:`truncate`,children:e})}function Nt({label:e,children:t}){return(0,Y.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Z({icon:e,title:t,description:n,children:r}){let i=(0,J.useId)();return(0,Y.jsxs)(`li`,{"aria-labelledby":i,className:`before:bg-border relative grid grid-cols-[--spacing(7)_minmax(0,1fr)] gap-x-3 pb-8 before:absolute before:top-9 before:bottom-1 before:left-[calc(--spacing(3.5)-0.5px)] before:w-px last:pb-0 last:before:hidden`,children:[(0,Y.jsx)(`span`,{className:`border-border bg-card text-muted-foreground [&_svg]:size-icon-sm flex size-7 items-center justify-center rounded-full border`,children:e}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Y.jsx)(B,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Pt=`__none__`,Ft=`sm:max-w-xs`,It=(e,t)=>e>=t-200?` ${e}/${t}`:``;function Q({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Y.jsxs)(ae,{children:[(0,Y.jsxs)(Ye,{invalid:!!n,disabled:r,children:[(0,Y.jsx)(F,{children:e}),(0,Y.jsx)(qe,{children:t}),i,n&&(0,Y.jsx)(Je,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Y.jsx)(L,{children:(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(Ge,{"aria-label":e,value:t,placeholder:n,editable:!r,onChange:i,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1})})})}function Rt({phase:e,phases:t,requiredNextPhases:n,skills:r,skillsEditable:i,factoryId:a,boardId:o,disabled:s,rawRules:c,onChange:u,onRawRule:d,onUnfinished:f,onRemove:p}){let m=lt(a),h=e.kind===`working`,g=y(e,t),_=e.runner?.instructions??``,v=e.runner?.goal,x=v?.objective??``,C=e.tools??[],w=e.exitTool?.id??``,T=e.runner?.skill,E=T?r?.find(e=>e.name===T):void 0,ee=T!==void 0&&r!==void 0&&E===void 0,O=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));u({...e,runner:Object.keys(r).length>0?r:null})},k=e=>({text:c[e],onChange:t=>d(e,t)}),M=(0,Y.jsx)(jt,{phase:e,phases:t,next:g,required:new Set(n),boardId:o,disabled:s,onChange:t=>u({...e,nextPhases:t})}),P=p&&(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(W,{variant:`ghost`,icon:(0,Y.jsx)(mt,{}),onClick:p,children:[`Remove `,e.name]})});return h?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsxs)(Nt,{label:`How ${e.name} runs`,children:[(0,Y.jsx)(Z,{icon:(0,Y.jsx)(Ne,{}),title:`Starts`,children:(0,Y.jsxs)(L,{children:[(0,Y.jsx)(I,{label:`Start on its own`,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:s,onCheckedChange:t=>{u(S(e,t)),t||d(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Ae,options:{"source.repository":m},disabled:s,json:k(`autoStartWhen`),onUnfinished:e=>f(`autoStartWhen`,e),onChange:t=>u({...e,autoStartWhen:t})})})]})}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ze,{}),title:`Agent runs`,children:[(0,Y.jsx)(Q,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${It(_.length,N)}`,error:_.length>1e3?`Too long to save.`:void 0,disabled:s,children:(0,Y.jsx)(Lt,{label:`${e.name} instructions`,value:_,placeholder:`Tell the agent what to do, in Markdown`,disabled:s,onChange:e=>O({instructions:e})})}),(0,Y.jsx)(Q,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${It(x.length,D)}`,error:x.length>2e3?`Too long to save.`:void 0,disabled:s,after:v&&(0,Y.jsxs)(Ye,{invalid:!j(v.maxRuns),disabled:s,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(Ke,{info:`After this many runs without meeting the goal, the card waits for a person. From 1 to 50; leave empty for Factory's default.`,children:`Pause goal after`}),(0,Y.jsx)(rt,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:v.maxRuns??null,disabled:s,onValueChange:e=>{let{maxRuns:t,...n}=v;O({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Y.jsxs)(nt,{size:`sm`,children:[(0,Y.jsx)($e,{placeholder:`Default`}),(0,Y.jsxs)(Qe,{align:`inline-end`,variant:`flush`,children:[(0,Y.jsx)(Ze,{className:`mr-1`,children:`runs`}),(0,Y.jsx)(tt,{}),(0,Y.jsx)(et,{})]})]})})]}),!j(v.maxRuns)&&(0,Y.jsxs)(Je,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Y.jsx)(Lt,{label:`${e.name} goal`,value:x,placeholder:`Describe what done looks like`,disabled:s,onChange:e=>O({goal:e.trim()?{...v,objective:e}:void 0})})}),(0,Y.jsx)(Q,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:s,children:(0,Y.jsx)(Xe,{className:Ft,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:b,disabled:s,onChange:e=>O({context:e.target.value})})}),(0,Y.jsx)(q,{title:`Skill`,children:(0,Y.jsx)(L,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(st,{value:T??Pt,disabled:s,onValueChange:e=>O({skill:e===Pt?void 0:String(e)}),children:[(0,Y.jsx)(it,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(l,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:T??`No skill`})]})}),(0,Y.jsxs)(at,{children:[(0,Y.jsx)(ot,{value:Pt,children:`None`}),(r??[]).map(e=>(0,Y.jsx)(ot,{value:e.name,children:e.name},e.name))]})]}),ee&&(0,Y.jsx)(We,{variant:`destructive`,children:`Not found`}),E?.error&&(0,Y.jsx)(We,{variant:`destructive`,children:`Failed to load`}),E&&(0,Y.jsx)(Ce,{skill:E}),E&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,icon:i?(0,Y.jsx)(Re,{}):(0,Y.jsx)(he,{}),"aria-label":`${i?`Edit`:`View`} ${E.name}`,className:`ml-auto`,render:(0,Y.jsx)(H,{to:we(a,o,E.name)}),children:i?`Edit`:`View`})]}),E?.error?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,E.error]}):ee?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,T,` skill, so cards entering `,e.name,` fail to start.`]}):E?.description&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:E.description})]})})}),(0,Y.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Y.jsx)(L,{children:A.map(t=>(0,Y.jsx)(I,{label:t.label,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: ${t.label}`,checked:C.includes(t.id),disabled:s,onCheckedChange:n=>{let r=A.map(({id:e})=>e).filter(e=>e===t.id?n:C.includes(e));u({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ne,{}),title:`Ends`,children:[(0,Y.jsx)(Q,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:s,children:(0,Y.jsx)(Xe,{className:Ft,"aria-label":`${e.name} exit tool`,value:w,disabled:s,onChange:t=>{let n=t.target.value.trim();u({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||d(`autoApproveWhen`,void 0)}})}),w!==``&&(0,Y.jsxs)(L,{children:[(0,Y.jsx)(I,{label:`Approve on its own`,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: approve ${w} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:s,onCheckedChange:t=>{u({...e,exitTool:{...e.exitTool,id:w,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||d(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Ae,options:{"source.repository":m},disabled:s,json:k(`autoApproveWhen`),onUnfinished:e=>f(`autoApproveWhen`,e),onChange:t=>u({...e,exitTool:{...e.exitTool,id:w,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Y.jsx)(Z,{icon:(0,Y.jsx)(te,{}),title:`Allowed moves`,children:M})]}),P]}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(q,{title:`Allowed moves`,children:M}),P]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:s,onReload:c}){let{board:u,canEdit:d}=i,{draft:f,rawRules:p,locked:m,setDraft:h,setRawRule:g,discard:v}=k(e.id,t,u),[y,b]=(0,J.useState)(0),C=()=>{v(),b(e=>e+1)},ee=me(),D=_e(e.id,t),te=fe(),A=!d||!u.editable,j=n?f.phases.find(e=>e.key===n):void 0,M=j&&`${j.key}:${u.revision??`code`}:${y}`,[N,P]=(0,J.useState)({page:M,fields:[]});N.page!==M&&P({page:M,fields:[]});let ne=N.page===M?N.fields:[],re=(e,t)=>P(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),ie=!A&&(_(f,u)||Object.keys(p).length>0||ne.length>0),F=f.phases.filter(e=>x(e,p)||e===j&&ne.length>0),I=f.name.trim()===``,ae=D.error?.code===`revision_mismatch`,R=pe(({nextLocation:n})=>{let r=te.getQueryData(ge.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!ie||r===!1)return!1;let i=Te(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),oe=G(e.id,t),se;return se=n&&!j?(0,Y.jsx)(r,{titleSlot:(0,Y.jsxs)(`span`,{role:`alert`,children:[u.name,` has no such phase.`]}),actionSlot:(0,Y.jsx)(W,{size:`sm`,render:(0,Y.jsx)(H,{to:oe}),children:`Back to general`})}):j?(0,Y.jsx)(Rt,{phase:j,phases:f.phases,requiredNextPhases:u.codeBehaviour?.[j.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:A||m,rawRules:{autoStartWhen:p[O(j.key,`autoStartWhen`)],autoApproveWhen:p[O(j.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{g(O(j.key,e),t),re(e,!1)},onUnfinished:re,onRemove:A||m||!w(f.phases,j.key,u.codeBehaviour)?void 0:()=>{for(let e of zt)g(O(j.key,e),void 0);h(e=>({...e,phases:E(e.phases,j.key)})),ee(oe)},onChange:e=>h(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},M):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(Dt,{factoryId:e.id,boardId:t,phases:f.phases,skills:a,onAutoStart:A||m?void 0:(e,t)=>{h(n=>({...n,phases:n.phases.map(n=>n.key===e?S(n,t):n)})),t||g(O(e,`autoStartWhen`),void 0)},action:s&&!A?(0,Y.jsx)(T,{factoryId:e.id,boardId:t,board:u,disabled:m}):void 0}),(0,Y.jsx)(X,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:s&&(0,Y.jsx)(q,{title:`Factory`,children:(0,Y.jsx)(L,{children:(0,Y.jsxs)(H,{to:Ee(e.id,t),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,Y.jsx)(l,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Y.jsx)(B,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Y.jsx)(ce,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Y.jsxs)(`div`,{className:z(`flex flex-col gap-8 pb-4`,!j&&`w-max min-w-full`),children:[u.editable?!d&&(0,Y.jsx)(X,{pinned:!j,children:(0,Y.jsx)(U,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Y.jsx)(X,{pinned:!j,children:(0,Y.jsx)(U,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!j&&u.problems.length>0&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(U,{variant:`warning`,title:`This board has problems`,children:(0,Y.jsx)(U.Message,{children:u.problems.join(` `)})})}),se,ie&&(0,Y.jsxs)(X,{pinned:!j,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[ae&&(0,Y.jsx)(U,{variant:`warning`,title:`Someone else changed this board`,action:(0,Y.jsx)(U.Button,{onClick:c,children:`Reload`}),children:(0,Y.jsx)(U.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),D.error&&!ae&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not saved. `,D.error.reasons]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(B,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:I?`Name the board to save.`:F.length>0?`Fix ${F.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:D.isPending,onClick:C,children:`Discard`}),(0,Y.jsx)(W,{size:`sm`,variant:`primary`,disabled:D.isPending||I||F.length>0,onClick:()=>D.mutate({name:f.name,description:f.description,phases:f.phases,expectedRevision:u.revision??0}),children:D.isPending?`Saving…`:`Save`})]})]}),(0,Y.jsx)(K,{open:R.state===`blocked`,onOpenChange:e=>!e&&R.reset?.(),children:(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Discard changes to `,u.name,`?`]}),(0,Y.jsx)(K.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Keep editing`}),(0,Y.jsx)(W,{variant:`destructive`,size:`md`,onClick:()=>{v(),R.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Y.jsxs)(K,{children:[(0,Y.jsx)(K.Trigger,{render:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(mt,{}),disabled:t,children:`Delete`})}),(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Delete `,e,`?`]}),(0,Y.jsx)(K.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Cancel`}),(0,Y.jsx)(K.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Y.jsxs)(K,{children:[(0,Y.jsx)(K.Trigger,{render:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(_t,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Reset `,e,` to default?`]}),(0,Y.jsx)(K.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Cancel`}),(0,Y.jsx)(K.Action,{onClick:n,children:`Reset`})]})]})]})}var $={resting:{label:`Resting`,meaning:`No agent works here. Cards wait for a person or an event to move them.`},working:{label:`Working`,meaning:`An agent works on each card here, following the steps below.`},terminal:{label:`Terminal`,meaning:`Cards are finished here. Their agent sessions stop.`}},Ut=[`resting`,`working`,`terminal`];function Wt({label:e,meaning:t,children:n}){return(0,Y.jsxs)(de,{children:[(0,Y.jsx)(ue,{render:(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:z(`inline-flex rounded-sm`,V),children:n})}),(0,Y.jsx)(le,{side:`bottom`,className:`max-w-72`,children:t})]})}function Gt({factoryId:e,boardId:t,phaseKey:n,response:r}){let{board:i,canEdit:a}=r,{draft:s,locked:c,setDraft:l,setRawRule:u,discard:d}=k(e,t,i),f=ke(e),p=me(),m=!a||!i.editable||c,h=be(e,t),_=ve(e,t,()=>{d();let n=ht(f.data??[]).find(e=>e.id!==t);p(n?gt(e,n.id):`/factories/${e}`,{replace:!0})}),v=!n&&a&&i.editable,y=v&&i.source!==`stored`,b=v&&i.source!==`builtin`,x=n?s.phases.find(e=>e.key===n):void 0;if(n&&!x)return null;let S=e=>l(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),C=e=>{x&&(u(O(x.key,`autoStartWhen`),void 0),u(O(x.key,`autoApproveWhen`),void 0),l(t=>({...t,phases:t.phases.map(n=>n.key===x.key?g(n,e,t.phases):n)})))},w=x?x.name:s.name,T=(x?x.description:s.description)??``,E=x!==void 0&&!m&&!P(s.phases,x.key,i.codeBehaviour);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(o,{children:[(0,Y.jsxs)(o.Title,{className:`gap-2.5`,children:[x&&(0,Y.jsx)(Pe,{stage:x.key,kind:Me(t,x.kind),decorative:!0}),(0,Y.jsx)(vt,{value:w,label:x?`Phase name`:`Board name`,required:!0,readOnly:m,variant:`heading`,tone:`ink`,onChange:e=>x?S({name:e}):l(t=>({...t,name:e}))})]}),x&&(0,Y.jsx)(o.Meta,{beside:!0,children:E?(0,Y.jsxs)(st,{value:x.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&C(t)},children:[(0,Y.jsx)(it,{size:`sm`,"aria-label":`Phase kind`,children:$[x.kind].label}),(0,Y.jsx)(at,{children:Ut.map(e=>(0,Y.jsx)(ot,{value:e,children:$[e].label},e))})]}):(0,Y.jsx)(Wt,{label:$[x.kind].label,meaning:$[x.kind].meaning,children:(0,Y.jsx)(We,{children:$[x.kind].label})})}),(T||!m)&&(0,Y.jsx)(o.Description,{children:(0,Y.jsx)(vt,{value:T,label:x?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:m,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>x?S({description:e||null}):l(t=>({...t,description:e||null}))})}),(y||b)&&(0,Y.jsxs)(o.Action,{className:`gap-1`,children:[y&&(0,Y.jsx)(Ht,{name:i.name,pending:c,onReset:()=>h.mutate(i.revision??0)}),b&&(0,Y.jsx)(Vt,{name:i.name,pending:c,onDelete:()=>_.mutate(i.revision??0)})]})]}),h.error&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not reset. `,h.error.reasons]})}),_.error&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not deleted. `,_.error.reasons]})})]})}function Kt(){let e=f(),i=ee(),a=i?.boardId??``,o=i?.phaseKey,{isMobile:s,desktopState:l}=ie(),d=s||l===`collapsed`,p=ye(e.id,a),m=Se(e.id),h=p.data?.board,g=C(e.id,a,h),_=o?g?.phases.find(e=>e.key===o):void 0,v=G(e.id,a),y=c({breadcrumbs:d&&h?(0,Y.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Y.jsx)(t,{as:H,to:gt(e.id,a),children:g?.name||h.name}),o?(0,Y.jsx)(t,{as:H,to:v,children:`Configure`}):(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),_&&(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:_.name})]}):void 0}),b=p.isSuccess&&(!o||_)?(0,Y.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:o,response:p.data},`${a}:${p.data.board.revision??`code`}`):void 0,x=p.isPending?(0,Y.jsx)(L,{children:(0,Y.jsx)(R,{label:`Loading board`,rows:3})}):p.isError&&p.error instanceof xe&&p.error.code===`board_not_found`?(0,Y.jsx)(r,{variant:`fill`,titleSlot:(0,Y.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):p.isError?(0,Y.jsx)(yt,{title:`Couldn’t load this board`,error:p.error,onRetry:()=>void p.refetch(),retrying:p.isFetching}):(0,Y.jsx)(Bt,{factory:e,boardId:a,phaseKey:o,response:p.data,skills:m.data?.skills,skillsEditable:m.data?.canEdit??!1,sidebarHidden:d,onReload:()=>void p.refetch()},`${a}:${p.data.board.revision??`code`}`);return o?(0,Y.jsx)(u,{variant:`settings`,header:b,...y,children:x}):(0,Y.jsx)(u,{variant:`page`,body:`fixed`,header:b&&(0,Y.jsx)(`div`,{className:z(`mx-auto w-full max-w-2xl`,`pb-3`),children:b}),...y,children:(0,Y.jsx)(`div`,{className:p.isSuccess?xt:z(bt,`px-4`),children:x})})}export{Kt as BoardConfigPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-CVW-e0jJ.js";import{t as r}from"./EmptyState-DJaZF543-BTdobX9X.js";import{$n as i,Cr as a,Fr as o,Gn as s,Nr as c,O as l,Pr as u,Qn as d,Tr as f,Wn as p,Xn as m,Zn as h,_r as g,ar as _,br as v,dr as y,er as b,fr as x,gr as S,in as C,ir as w,k as T,mr as E,nn as ee,nr as D,pn as te,pr as O,rn as k,rr as A,sr as j,tn as M,tr as N,ur as P,wr as ne,xr as re}from"./index-DtRZNzyn.js";import{a as ie}from"./Sidebar.es-CFLW5bYW.js";import{d as F,f as I,i as ae,t as L,u as R}from"./settings-C5r2ThW9-D7BpEINa.js";import{O as oe,T as z,k as se,n as B,s as V,t as ce}from"./IconChevronRightMedium.es-BkPdzxSm.js";import{$n as H,Fi as le,Li as ue,Pi as de,Qr as fe,cr as pe,dr as me,n as U,ni as W,r as he,zt as ge}from"./GithubIcon.es-BmZS8JQG.js";import{c as _e,o as ve,r as ye,s as be,t as xe}from"./useBoardEditor-Bn11vS5Q.js";import{i as Se,t as Ce}from"./SkillBadges-IJt3Rano.js";import{a as G,c as we,f as Te,l as Ee,s as De}from"./boardConfigPaths-Btimpi_r.js";import{t as K}from"./AlertDialog.es-Dd0j0SAo.js";import{t as q}from"./SettingsSubsection-B_X_u0Kt.js";import{r as Oe}from"./CompositeItem-CSfZykYZ.js";import{n as ke}from"./useBoardCatalog-C-gXjA-g.js";import{h as Ae,o as je}from"./useIntakeRoutes-OObHoZos.js";import{a as Me,d as Ne,t as Pe}from"./BoardIcons-BZwAAPO8.js";import{i as Fe,n as Ie,r as Le,t as Re}from"./IconPencil.es-DqPc7VYz.js";import{r as ze}from"./overlays-B4T3HdBk.js";import{t as Be}from"./DescriptionMarkdown-C5kG44nn.js";import{h as Ve,w as He,y as Ue}from"./ruleLanes-zac0HQwn.js";import{k as We}from"./TabsRoot-DNjGHnQQ.js";import{t as Ge}from"./CodeEditor-DKVZX8c1-D3tFx8Wi.js";import{a as Ke,n as qe,r as Je,t as Ye}from"./Field.es-C1w4lsXS.js";import{t as Xe}from"./input-DqReKX0A-ScC7s6sY.js";import{a as Ze,n as Qe}from"./input-group-C64rGEu8-tF1AZfiZ.js";import{a as $e,i as et,n as tt,r as nt,t as rt}from"./InputNumber.es-DuTGd35f.js";import{i as it,n as at,r as ot,t as st}from"./select-jT0h_BBB-6ji8g_rW.js";import{E as ct}from"./combobox-parts-DhYtFSRV-BZqyW5dv.js";import{n as lt,t as ut}from"./ConditionRows-BXZDW3lX.js";import{n as dt}from"./IconUserDuo.es-CJ2yCPc7.js";import{_t as ft}from"./useSessionRows-CnLoToLZ.js";import{t as pt}from"./IconPlusMedium.es-BOotRziY.js";import{t as mt}from"./TrashIcon.es-DoCvaCDh.js";import{n as ht,t as gt}from"./boardCatalog-y-s19dQU.js";import{t as _t}from"./IconArrowRotateCounterClockwise.es-Dxk4yi6B.js";import{t as vt}from"./InlineText-tcMMASWp.js";import{t as yt}from"./LoadErrorState-B6WrspsB.js";var J=e(se(),1),bt=`mx-auto w-full max-w-2xl`,xt=`[container-type:inline-size] h-full min-h-0 overflow-auto overscroll-x-contain [scrollbar-gutter:stable]`,St=`sticky left-0 w-[100cqw] px-4`,Y=oe();function X({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Y.jsx)(`div`,{className:z(St,i),children:(0,Y.jsx)(`div`,{className:z(bt,n),children:r})}):(0,Y.jsx)(`div`,{className:z(bt,i,n),children:r})}function Ct({factoryId:e,boardId:t,phase:n,skills:r}){let i=n.runner;if(!i)return null;let a=i.skill,o=a?r?.find(e=>e.name===a):void 0,s=a!==void 0&&r!==void 0&&o===void 0,c=s||o?.error!==void 0,u=a&&!s?we(e,t,a):G(e,t,n.key),f=a?l:ze;return(0,Y.jsxs)(Ie,{children:[(0,Y.jsxs)(Fe,{delay:0,closeDelay:100,render:(0,Y.jsx)(H,{to:u}),className:z(V,`border-border bg-fill-subtle hover:bg-fill flex w-fit max-w-full min-w-0 items-center gap-1.5 rounded-md border px-1.5 py-0.5 transition-colors`,c&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Y.jsx)(f,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Y.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),c&&(0,Y.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Y.jsxs)(Le,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-96 max-w-[calc(100vw-2rem)] flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(f,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Y.jsx)(Ce,{skill:o})]}),s?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,a,` skill, so cards entering `,n.name,` fail to start.`]}):o?.error?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Y.jsx)(d,{children:`Loading the skill…`}),o?.content.trim()&&(0,Y.jsx)(wt,{title:`Skill instructions`,children:(0,Y.jsx)(Be,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Y.jsx)(wt,{title:`${n.name} adds`,children:(0,Y.jsx)(Be,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Y.jsx)(wt,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Y.jsx)(B,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Y.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function wt({title:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Y.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Tt({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Y.jsxs)(Ie,{children:[(0,Y.jsx)(Fe,{delay:0,closeDelay:100,render:(0,Y.jsx)(H,{to:n}),className:z(V,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ve(e.length)}),(0,Y.jsxs)(Le,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2`,children:[(0,Y.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Y.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Y.jsx)(s,{rule:e,boardId:r,boards:i},e.id))})]})]})}var Et=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Dt({factoryId:e,boardId:t,phases:n,skills:r,action:a,onAutoStart:o}){let s=ke(e),c=je(e),l=s.isPending||c.isPending,u=s.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,f=n.map(e=>h(e,n)),g=c.data&&u?i(c.data.intakeRoutes,{key:t,initialPhase:u}):void 0;return(0,Y.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[a&&(0,Y.jsx)(X,{pinned:!0,className:`flex justify-end`,children:a}),c.isError&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(U,{variant:`warning`,children:(0,Y.jsx)(U.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),g&&g.leaving.length>0&&(0,Y.jsx)(X,{pinned:!0,className:`mb-4`,children:(0,Y.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Y.jsx)(Tt,{rules:g.leaving,title:`Rules that send cards to other boards`,to:De(e,t,`leaving`),boardId:t,boards:s.data}),` `,g.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Y.jsx)(`ol`,{"aria-label":`Phases`,className:z(`mx-auto flex w-max`,Et),children:n.map(i=>{let a=Me(t,i.kind),c=g?.into.get(i.key)??[];return(0,Y.jsxs)(`li`,{"aria-label":i.name,className:`before:via-border-strong relative flex w-64 shrink-0 flex-col px-2 not-first:before:absolute not-first:before:inset-y-0 not-first:before:left-0 not-first:before:w-px not-first:before:bg-linear-to-b not-first:before:from-transparent not-first:before:to-transparent`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Y.jsxs)(H,{to:G(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Y.jsx)(Pe,{stage:i.key,kind:a,decorative:!0}),(0,Y.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Y.jsx)(`div`,{className:`px-3 py-3`,children:(0,Y.jsx)(m,{boardId:t,phase:h(i,n),phases:f,arrivals:(0,Y.jsxs)(Y.Fragment,{children:[l?(0,Y.jsx)(Oe,{className:`h-4 w-20`}):g?c.length>0?(0,Y.jsx)(Tt,{rules:c,title:`Rules that move cards into ${i.name}`,to:De(e,t,{into:i.key}),boardId:t,boards:s.data}):(0,Y.jsx)(d,{children:`No rule moves cards here`}):(0,Y.jsx)(d,{children:`Rules didn’t load`}),i.key===u&&(0,Y.jsx)(d,{children:`New cards start here`})]}),starts:(0,Y.jsx)(p,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:o&&(e=>o(i.key,e))}),agent:(0,Y.jsx)(Ct,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Ot=`Finish or remove unfinished conditions to save.`;function kt({label:e,description:t,rule:n,disabled:r,facts:i=Ue,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,J.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,J.useId)(),g=p===void 0?a(s,n):v(s,p),_=e=>{m(e);let t=re(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Y.jsxs)(Ye,{invalid:g!==void 0,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(Ke,{htmlFor:h,children:e}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,a(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Y.jsx)(qe,{children:t}),p===void 0?r?(0,Y.jsx)(B,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:He(n,o)}):(0,Y.jsx)(`div`,{id:h,children:(0,Y.jsx)(ut,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Ot):l(e,a(s,e))}})}):(0,Y.jsx)(M,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Y.jsx)(Je,{children:g})]})}var At=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function jt({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let s=e=>o(n.includes(e)?n.filter(t=>t!==e):t.filter(t=>t.key===e||n.includes(t.key)).map(e=>e.key));return(0,Y.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Y.jsx)(Pe,{stage:t.key,kind:Me(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Y.jsxs)(`li`,{className:z(At,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`(this phase)`})]},t.key);let c=n.includes(t.key),l=c&&r.has(t.key),u=l||a,d=(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":l?`${t.name} (locked)`:void 0,"aria-disabled":u||void 0,onClick:u?void 0:()=>s(t.key),className:z(At,`group/move transition-colors`,c?`bg-fill text-foreground border-transparent`:`border-border text-muted-foreground border-dashed`,!u&&(c?`hover:bg-fill-hover`:`hover:text-foreground hover:border-border-strong`),u&&!l&&`cursor-default`,V),children:[(0,Y.jsx)(`span`,{className:z(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Y.jsx)(dt,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Y.jsx)(ft,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Y.jsx)(pt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Y.jsx)(`li`,{className:`min-w-0`,children:l?(0,Y.jsxs)(de,{children:[(0,Y.jsx)(ue,{render:d}),(0,Y.jsx)(le,{children:`Factory's code makes this move`})]}):d},t.key)})})}function Mt({children:e}){return(0,Y.jsx)(B,{as:`span`,variant:`label`,className:`truncate`,children:e})}function Nt({label:e,children:t}){return(0,Y.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Z({icon:e,title:t,description:n,children:r}){let i=(0,J.useId)();return(0,Y.jsxs)(`li`,{"aria-labelledby":i,className:`before:bg-border relative grid grid-cols-[--spacing(7)_minmax(0,1fr)] gap-x-3 pb-8 before:absolute before:top-9 before:bottom-1 before:left-[calc(--spacing(3.5)-0.5px)] before:w-px last:pb-0 last:before:hidden`,children:[(0,Y.jsx)(`span`,{className:`border-border bg-card text-muted-foreground [&_svg]:size-icon-sm flex size-7 items-center justify-center rounded-full border`,children:e}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Y.jsx)(B,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Pt=`__none__`,Ft=`sm:max-w-xs`,It=(e,t)=>e>=t-200?` ${e}/${t}`:``;function Q({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Y.jsxs)(ae,{children:[(0,Y.jsxs)(Ye,{invalid:!!n,disabled:r,children:[(0,Y.jsx)(F,{children:e}),(0,Y.jsx)(qe,{children:t}),i,n&&(0,Y.jsx)(Je,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Y.jsx)(L,{children:(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(Ge,{"aria-label":e,value:t,placeholder:n,editable:!r,onChange:i,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1})})})}function Rt({phase:e,phases:t,requiredNextPhases:n,skills:r,skillsEditable:i,factoryId:a,boardId:o,disabled:s,rawRules:c,onChange:u,onRawRule:d,onUnfinished:f,onRemove:p}){let m=lt(a),h=e.kind===`working`,g=y(e,t),_=e.runner?.instructions??``,v=e.runner?.goal,x=v?.objective??``,C=e.tools??[],w=e.exitTool?.id??``,T=e.runner?.skill,E=T?r?.find(e=>e.name===T):void 0,ee=T!==void 0&&r!==void 0&&E===void 0,O=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));u({...e,runner:Object.keys(r).length>0?r:null})},k=e=>({text:c[e],onChange:t=>d(e,t)}),M=(0,Y.jsx)(jt,{phase:e,phases:t,next:g,required:new Set(n),boardId:o,disabled:s,onChange:t=>u({...e,nextPhases:t})}),P=p&&(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(W,{variant:`ghost`,icon:(0,Y.jsx)(mt,{}),onClick:p,children:[`Remove `,e.name]})});return h?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsxs)(Nt,{label:`How ${e.name} runs`,children:[(0,Y.jsx)(Z,{icon:(0,Y.jsx)(Ne,{}),title:`Starts`,children:(0,Y.jsxs)(L,{children:[(0,Y.jsx)(I,{label:`Start on its own`,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:s,onCheckedChange:t=>{u(S(e,t)),t||d(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Ae,options:{"source.repository":m},disabled:s,json:k(`autoStartWhen`),onUnfinished:e=>f(`autoStartWhen`,e),onChange:t=>u({...e,autoStartWhen:t})})})]})}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ze,{}),title:`Agent runs`,children:[(0,Y.jsx)(Q,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${It(_.length,N)}`,error:_.length>1e3?`Too long to save.`:void 0,disabled:s,children:(0,Y.jsx)(Lt,{label:`${e.name} instructions`,value:_,placeholder:`Tell the agent what to do, in Markdown`,disabled:s,onChange:e=>O({instructions:e})})}),(0,Y.jsx)(Q,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${It(x.length,D)}`,error:x.length>2e3?`Too long to save.`:void 0,disabled:s,after:v&&(0,Y.jsxs)(Ye,{invalid:!j(v.maxRuns),disabled:s,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(Ke,{info:`After this many runs without meeting the goal, the card waits for a person. From 1 to 50; leave empty for Factory's default.`,children:`Pause goal after`}),(0,Y.jsx)(rt,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:v.maxRuns??null,disabled:s,onValueChange:e=>{let{maxRuns:t,...n}=v;O({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Y.jsxs)(nt,{size:`sm`,children:[(0,Y.jsx)($e,{placeholder:`Default`}),(0,Y.jsxs)(Qe,{align:`inline-end`,variant:`flush`,children:[(0,Y.jsx)(Ze,{className:`mr-1`,children:`runs`}),(0,Y.jsx)(tt,{}),(0,Y.jsx)(et,{})]})]})})]}),!j(v.maxRuns)&&(0,Y.jsxs)(Je,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Y.jsx)(Lt,{label:`${e.name} goal`,value:x,placeholder:`Describe what done looks like`,disabled:s,onChange:e=>O({goal:e.trim()?{...v,objective:e}:void 0})})}),(0,Y.jsx)(Q,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:s,children:(0,Y.jsx)(Xe,{className:Ft,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:b,disabled:s,onChange:e=>O({context:e.target.value})})}),(0,Y.jsx)(q,{title:`Skill`,children:(0,Y.jsx)(L,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(st,{value:T??Pt,disabled:s,onValueChange:e=>O({skill:e===Pt?void 0:String(e)}),children:[(0,Y.jsx)(it,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(l,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:T??`No skill`})]})}),(0,Y.jsxs)(at,{children:[(0,Y.jsx)(ot,{value:Pt,children:`None`}),(r??[]).map(e=>(0,Y.jsx)(ot,{value:e.name,children:e.name},e.name))]})]}),ee&&(0,Y.jsx)(We,{variant:`destructive`,children:`Not found`}),E?.error&&(0,Y.jsx)(We,{variant:`destructive`,children:`Failed to load`}),E&&(0,Y.jsx)(Ce,{skill:E}),E&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,icon:i?(0,Y.jsx)(Re,{}):(0,Y.jsx)(he,{}),"aria-label":`${i?`Edit`:`View`} ${E.name}`,className:`ml-auto`,render:(0,Y.jsx)(H,{to:we(a,o,E.name)}),children:i?`Edit`:`View`})]}),E?.error?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,E.error]}):ee?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,T,` skill, so cards entering `,e.name,` fail to start.`]}):E?.description&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:E.description})]})})}),(0,Y.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Y.jsx)(L,{children:A.map(t=>(0,Y.jsx)(I,{label:t.label,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: ${t.label}`,checked:C.includes(t.id),disabled:s,onCheckedChange:n=>{let r=A.map(({id:e})=>e).filter(e=>e===t.id?n:C.includes(e));u({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ne,{}),title:`Ends`,children:[(0,Y.jsx)(Q,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:s,children:(0,Y.jsx)(Xe,{className:Ft,"aria-label":`${e.name} exit tool`,value:w,disabled:s,onChange:t=>{let n=t.target.value.trim();u({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||d(`autoApproveWhen`,void 0)}})}),w!==``&&(0,Y.jsxs)(L,{children:[(0,Y.jsx)(I,{label:`Approve on its own`,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: approve ${w} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:s,onCheckedChange:t=>{u({...e,exitTool:{...e.exitTool,id:w,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||d(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Ae,options:{"source.repository":m},disabled:s,json:k(`autoApproveWhen`),onUnfinished:e=>f(`autoApproveWhen`,e),onChange:t=>u({...e,exitTool:{...e.exitTool,id:w,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Y.jsx)(Z,{icon:(0,Y.jsx)(te,{}),title:`Allowed moves`,children:M})]}),P]}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(q,{title:`Allowed moves`,children:M}),P]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:s,onReload:c}){let{board:u,canEdit:d}=i,{draft:f,rawRules:p,locked:m,setDraft:h,setRawRule:g,discard:v}=k(e.id,t,u),[y,b]=(0,J.useState)(0),C=()=>{v(),b(e=>e+1)},ee=me(),D=_e(e.id,t),te=fe(),A=!d||!u.editable,j=n?f.phases.find(e=>e.key===n):void 0,M=j&&`${j.key}:${u.revision??`code`}:${y}`,[N,P]=(0,J.useState)({page:M,fields:[]});N.page!==M&&P({page:M,fields:[]});let ne=N.page===M?N.fields:[],re=(e,t)=>P(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),ie=!A&&(_(f,u)||Object.keys(p).length>0||ne.length>0),F=f.phases.filter(e=>x(e,p)||e===j&&ne.length>0),I=f.name.trim()===``,ae=D.error?.code===`revision_mismatch`,R=pe(({nextLocation:n})=>{let r=te.getQueryData(ge.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!ie||r===!1)return!1;let i=Te(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),oe=G(e.id,t),se;return se=n&&!j?(0,Y.jsx)(r,{titleSlot:(0,Y.jsxs)(`span`,{role:`alert`,children:[u.name,` has no such phase.`]}),actionSlot:(0,Y.jsx)(W,{size:`sm`,render:(0,Y.jsx)(H,{to:oe}),children:`Back to general`})}):j?(0,Y.jsx)(Rt,{phase:j,phases:f.phases,requiredNextPhases:u.codeBehaviour?.[j.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:A||m,rawRules:{autoStartWhen:p[O(j.key,`autoStartWhen`)],autoApproveWhen:p[O(j.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{g(O(j.key,e),t),re(e,!1)},onUnfinished:re,onRemove:A||m||!w(f.phases,j.key,u.codeBehaviour)?void 0:()=>{for(let e of zt)g(O(j.key,e),void 0);h(e=>({...e,phases:E(e.phases,j.key)})),ee(oe)},onChange:e=>h(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},M):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(Dt,{factoryId:e.id,boardId:t,phases:f.phases,skills:a,onAutoStart:A||m?void 0:(e,t)=>{h(n=>({...n,phases:n.phases.map(n=>n.key===e?S(n,t):n)})),t||g(O(e,`autoStartWhen`),void 0)},action:s&&!A?(0,Y.jsx)(T,{factoryId:e.id,boardId:t,board:u,disabled:m}):void 0}),(0,Y.jsx)(X,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:s&&(0,Y.jsx)(q,{title:`Factory`,children:(0,Y.jsx)(L,{children:(0,Y.jsxs)(H,{to:Ee(e.id,t),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,Y.jsx)(l,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Y.jsx)(B,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Y.jsx)(ce,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Y.jsxs)(`div`,{className:z(`flex flex-col gap-8 pb-4`,!j&&`w-max min-w-full`),children:[u.editable?!d&&(0,Y.jsx)(X,{pinned:!j,children:(0,Y.jsx)(U,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Y.jsx)(X,{pinned:!j,children:(0,Y.jsx)(U,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!j&&u.problems.length>0&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(U,{variant:`warning`,title:`This board has problems`,children:(0,Y.jsx)(U.Message,{children:u.problems.join(` `)})})}),se,ie&&(0,Y.jsxs)(X,{pinned:!j,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[ae&&(0,Y.jsx)(U,{variant:`warning`,title:`Someone else changed this board`,action:(0,Y.jsx)(U.Button,{onClick:c,children:`Reload`}),children:(0,Y.jsx)(U.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),D.error&&!ae&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not saved. `,D.error.reasons]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(B,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:I?`Name the board to save.`:F.length>0?`Fix ${F.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:D.isPending,onClick:C,children:`Discard`}),(0,Y.jsx)(W,{size:`sm`,variant:`primary`,disabled:D.isPending||I||F.length>0,onClick:()=>D.mutate({name:f.name,description:f.description,phases:f.phases,expectedRevision:u.revision??0}),children:D.isPending?`Saving…`:`Save`})]})]}),(0,Y.jsx)(K,{open:R.state===`blocked`,onOpenChange:e=>!e&&R.reset?.(),children:(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Discard changes to `,u.name,`?`]}),(0,Y.jsx)(K.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Keep editing`}),(0,Y.jsx)(W,{variant:`destructive`,size:`md`,onClick:()=>{v(),R.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Y.jsxs)(K,{children:[(0,Y.jsx)(K.Trigger,{render:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(mt,{}),disabled:t,children:`Delete`})}),(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Delete `,e,`?`]}),(0,Y.jsx)(K.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Cancel`}),(0,Y.jsx)(K.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Y.jsxs)(K,{children:[(0,Y.jsx)(K.Trigger,{render:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(_t,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Reset `,e,` to default?`]}),(0,Y.jsx)(K.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Cancel`}),(0,Y.jsx)(K.Action,{onClick:n,children:`Reset`})]})]})]})}var $={resting:{label:`Resting`,meaning:`No agent works here. Cards wait for a person or an event to move them.`},working:{label:`Working`,meaning:`An agent works on each card here, following the steps below.`},terminal:{label:`Terminal`,meaning:`Cards are finished here. Their agent sessions stop.`}},Ut=[`resting`,`working`,`terminal`];function Wt({label:e,meaning:t,children:n}){return(0,Y.jsxs)(de,{children:[(0,Y.jsx)(ue,{render:(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:z(`inline-flex rounded-sm`,V),children:n})}),(0,Y.jsx)(le,{side:`bottom`,className:`max-w-72`,children:t})]})}function Gt({factoryId:e,boardId:t,phaseKey:n,response:r}){let{board:i,canEdit:a}=r,{draft:s,locked:c,setDraft:l,setRawRule:u,discard:d}=k(e,t,i),f=ke(e),p=me(),m=!a||!i.editable||c,h=be(e,t),_=ve(e,t,()=>{d();let n=ht(f.data??[]).find(e=>e.id!==t);p(n?gt(e,n.id):`/factories/${e}`,{replace:!0})}),v=!n&&a&&i.editable,y=v&&i.source!==`stored`,b=v&&i.source!==`builtin`,x=n?s.phases.find(e=>e.key===n):void 0;if(n&&!x)return null;let S=e=>l(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),C=e=>{x&&(u(O(x.key,`autoStartWhen`),void 0),u(O(x.key,`autoApproveWhen`),void 0),l(t=>({...t,phases:t.phases.map(n=>n.key===x.key?g(n,e,t.phases):n)})))},w=x?x.name:s.name,T=(x?x.description:s.description)??``,E=x!==void 0&&!m&&!P(s.phases,x.key,i.codeBehaviour);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(o,{children:[(0,Y.jsxs)(o.Title,{className:`gap-2.5`,children:[x&&(0,Y.jsx)(Pe,{stage:x.key,kind:Me(t,x.kind),decorative:!0}),(0,Y.jsx)(vt,{value:w,label:x?`Phase name`:`Board name`,required:!0,readOnly:m,variant:`heading`,tone:`ink`,onChange:e=>x?S({name:e}):l(t=>({...t,name:e}))})]}),x&&(0,Y.jsx)(o.Meta,{beside:!0,children:E?(0,Y.jsxs)(st,{value:x.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&C(t)},children:[(0,Y.jsx)(it,{size:`sm`,"aria-label":`Phase kind`,children:$[x.kind].label}),(0,Y.jsx)(at,{children:Ut.map(e=>(0,Y.jsx)(ot,{value:e,children:$[e].label},e))})]}):(0,Y.jsx)(Wt,{label:$[x.kind].label,meaning:$[x.kind].meaning,children:(0,Y.jsx)(We,{children:$[x.kind].label})})}),(T||!m)&&(0,Y.jsx)(o.Description,{children:(0,Y.jsx)(vt,{value:T,label:x?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:m,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>x?S({description:e||null}):l(t=>({...t,description:e||null}))})}),(y||b)&&(0,Y.jsxs)(o.Action,{className:`gap-1`,children:[y&&(0,Y.jsx)(Ht,{name:i.name,pending:c,onReset:()=>h.mutate(i.revision??0)}),b&&(0,Y.jsx)(Vt,{name:i.name,pending:c,onDelete:()=>_.mutate(i.revision??0)})]})]}),h.error&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not reset. `,h.error.reasons]})}),_.error&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not deleted. `,_.error.reasons]})})]})}function Kt(){let e=f(),i=ee(),a=i?.boardId??``,o=i?.phaseKey,{isMobile:s,desktopState:l}=ie(),d=s||l===`collapsed`,p=ye(e.id,a),m=Se(e.id),h=p.data?.board,g=C(e.id,a,h),_=o?g?.phases.find(e=>e.key===o):void 0,v=G(e.id,a),y=c({breadcrumbs:d&&h?(0,Y.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Y.jsx)(t,{as:H,to:gt(e.id,a),children:g?.name||h.name}),o?(0,Y.jsx)(t,{as:H,to:v,children:`Configure`}):(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),_&&(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:_.name})]}):void 0}),b=p.isSuccess&&(!o||_)?(0,Y.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:o,response:p.data},`${a}:${p.data.board.revision??`code`}`):void 0,x=p.isPending?(0,Y.jsx)(L,{children:(0,Y.jsx)(R,{label:`Loading board`,rows:3})}):p.isError&&p.error instanceof xe&&p.error.code===`board_not_found`?(0,Y.jsx)(r,{variant:`fill`,titleSlot:(0,Y.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):p.isError?(0,Y.jsx)(yt,{title:`Couldn’t load this board`,error:p.error,onRetry:()=>void p.refetch(),retrying:p.isFetching}):(0,Y.jsx)(Bt,{factory:e,boardId:a,phaseKey:o,response:p.data,skills:m.data?.skills,skillsEditable:m.data?.canEdit??!1,sidebarHidden:d,onReload:()=>void p.refetch()},`${a}:${p.data.board.revision??`code`}`);return o?(0,Y.jsx)(u,{variant:`settings`,header:b,...y,children:x}):(0,Y.jsx)(u,{variant:`page`,body:`fixed`,header:b&&(0,Y.jsx)(`div`,{className:z(`mx-auto w-full max-w-2xl`,`pb-3`),children:b}),...y,children:(0,Y.jsx)(`div`,{className:p.isSuccess?xt:z(bt,`px-4`),children:x})})}export{Kt as BoardConfigPage};
@@ -1 +1 @@
1
- import{O as e,T as t,f as n}from"./IconChevronRightMedium.es-BjSIsine.js";import{s as r}from"./useBoardCatalog-DZf1osB2.js";import{B as i}from"./useSessionRows-aTHnrKGG.js";import{i as a,n as o,o as s,r as c}from"./TrashIcon.es-CLx-KWTg.js";import{t as l}from"./IconCircleDashed.es-Chw6BTXK.js";import{t as u}from"./IconCircleX.es-3P8aywDS.js";import{n as d}from"./IconSettingsSliderHor.es-CSwP_iSG.js";import{t as f}from"./IconCircleCheck.es-e9o_0ikv.js";var p=e();function m({size:e=16,className:t}){return(0,p.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:t,"aria-hidden":!0,children:(0,p.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M8 14.67C11.68 14.67 14.67 11.68 14.67 8C14.67 4.32 11.68 1.33 8 1.33C4.32 1.33 1.33 4.32 1.33 8C1.33 11.68 4.32 14.67 8 14.67ZM9.14 5.53C8.88 5.27 8.46 5.27 8.2 5.53C7.93 5.79 7.93 6.21 8.2 6.47L9.06 7.33H5.33C4.97 7.33 4.67 7.63 4.67 8C4.67 8.37 4.97 8.67 5.33 8.67H9.06L8.2 9.53C7.93 9.79 7.93 10.21 8.2 10.47C8.46 10.73 8.88 10.73 9.14 10.47L11.14 8.47C11.4 8.21 11.4 7.79 11.14 7.53L9.14 5.53Z`,fill:`currentColor`})})}var h=n(`IconPlay`,()=>(0,p.jsx)(`path`,{d:`M20.245 10.2984L9.05099 3.38443C7.71854 2.56145 6 3.51992 6 5.08603V18.914C6 20.4801 7.71854 21.4385 9.05098 20.6156L20.245 13.7016C21.5104 12.9201 21.5104 11.0799 20.245 10.2984Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`})),g=n(`IconHammer`,()=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M6.70694 14.7929C6.31641 15.1834 5.68325 15.1834 5.29272 14.7929L2.45696 11.9571C2.06643 11.5666 2.06643 10.9334 2.45696 10.5429L9.70694 3.29289C9.89447 3.10536 10.1488 3 10.414 3L14.0857 3C14.3509 3 14.6052 3.10536 14.7928 3.29289L15.7927 4.29286C16.1832 4.68338 16.1832 5.31655 15.7927 5.70707L6.70694 14.7929Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,p.jsx)(`path`,{d:`M9.5 12.5L16.3358 19.3358C17.1168 20.1168 18.3832 20.1168 19.1642 19.3358L19.3358 19.1642C20.1168 18.3832 20.1168 17.1168 19.3358 16.3358L12.5 9.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}));function _({source:e,className:n}){let{Icon:r,iconClassName:a}=i[e];return(0,p.jsx)(r,{"data-source":e,className:t(`size-4 shrink-0`,a,n),"aria-hidden":!0})}var v={Investigate:d,Build:g,"Prepare approval":o,Review:c};function y(e){let t=v[e]??h;return(0,p.jsx)(t,{"aria-hidden":!0})}var b={resting:`neutral`,working:`info`,terminal:`success`},x={neutral:{icon:`text-muted-foreground`,tint:`bg-fill-subtle`,strongTint:`bg-fill-strong`,gradientFrom:`from-fill-subtle`},orange:{icon:`text-(--orange-500) dark:text-(--orange-400)`,tint:`bg-badge-orange-subtle`,strongTint:`bg-badge-orange-strong`,gradientFrom:`from-badge-orange-subtle`},cyan:{icon:`text-(--cyan-500) dark:text-(--cyan-400)`,tint:`bg-badge-cyan-subtle`,strongTint:`bg-badge-cyan-strong`,gradientFrom:`from-badge-cyan-subtle`},info:{icon:`text-info-indicator`,tint:`bg-info-subtle`,strongTint:`bg-badge-blue-strong`,gradientFrom:`from-badge-blue-subtle`},green:{icon:`text-badge-green-indicator`,tint:`bg-badge-green-subtle`,strongTint:`bg-badge-green-strong`,gradientFrom:`from-badge-green-subtle`},purple:{icon:`text-badge-purple-indicator`,tint:`bg-badge-purple-subtle`,strongTint:`bg-badge-purple-strong`,gradientFrom:`from-badge-purple-subtle`},success:{icon:`text-(--green-500) dark:text-(--green-400)`,tint:`bg-success-subtle`,strongTint:`bg-badge-green-strong`,gradientFrom:`from-badge-green-subtle`},destructive:{icon:`text-destructive-indicator`,tint:`bg-destructive-subtle`,strongTint:`bg-badge-red-strong`,gradientFrom:`from-badge-red-subtle`}};function S({source:e,className:n}){return(0,p.jsx)(`span`,{"aria-hidden":!0,style:{maskImage:`url(${e})`},className:t(`size-4 shrink-0 bg-current mask-center mask-no-repeat mask-contain`,n)})}var C=2.25,w=2*Math.PI*C;function T({progress:e,className:n}){return(0,p.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,className:t(`shrink-0`,n),children:[(0,p.jsx)(`circle`,{cx:8,cy:8,r:6,stroke:`currentColor`,strokeWidth:1.5}),(0,p.jsx)(`circle`,{cx:8,cy:8,r:C,stroke:`currentColor`,strokeWidth:C*2,strokeDasharray:`${e*w} ${w}`,transform:`rotate(-90 8 8)`})]})}function E(e,t){return t?void 0:a(e)}function D(e,t){return e===`work`||e===`review`?void 0:t}function O(e,t){let n=r(e,t);return e&&n?D(e.id,n):void 0}function k(e,t){let n=E(e,t);return n?s(n):b[t??`resting`]}function A({stage:e,kind:n,className:r}){let i=t(`shrink-0`,r);switch(E(e,n)??n??`resting`){case`intake`:return(0,p.jsx)(m,{className:i});case`triage`:return(0,p.jsx)(S,{source:`/factory-stage-icons/triage.svg`,className:r});case`planning`:return(0,p.jsx)(T,{progress:.25,className:r});case`execute`:case`working`:return(0,p.jsx)(T,{progress:.5,className:r});case`review`:case`pr-review`:return(0,p.jsx)(S,{source:`/factory-stage-icons/review.svg`,className:r});case`done`:case`terminal`:return(0,p.jsx)(f,{"aria-hidden":!0,className:t(`size-icon-md`,i)});case`canceled`:return(0,p.jsx)(u,{"aria-hidden":!0,className:t(`size-icon-md`,i)});case`resting`:return(0,p.jsx)(l,{"aria-hidden":!0,className:t(`size-icon-md`,i)})}}function j(e,t){return x[k(e,t)].tint}function M(e,n){return t(`bg-fill-subtle dark:bg-card bg-linear-to-r to-transparent`,x[k(e,n)].gradientFrom)}function N(e,t){return x[k(e,t)].strongTint}function P(e,t){return x[k(e,t)].icon}var F=`opacity-30`;function I({stage:e,kind:t,decorative:n=!1}){let r=(0,p.jsx)(A,{stage:e,kind:t,className:x[k(e,t)].icon});return n||!t?r:(0,p.jsx)(`span`,{role:`img`,"aria-label":`${t} phase`,className:`inline-flex shrink-0`,children:r})}export{D as a,N as c,h as d,m as f,O as i,j as l,_ as n,P as o,y as r,M as s,I as t,F as u};
1
+ import{O as e,T as t,f as n}from"./IconChevronRightMedium.es-BkPdzxSm.js";import{s as r}from"./useBoardCatalog-C-gXjA-g.js";import{B as i}from"./useSessionRows-CnLoToLZ.js";import{i as a,n as o,o as s,r as c}from"./TrashIcon.es-DoCvaCDh.js";import{t as l}from"./IconCircleDashed.es-CrssFpNj.js";import{t as u}from"./IconCircleX.es-Bah9f48z.js";import{n as d}from"./IconSettingsSliderHor.es-CWhsvZzL.js";import{t as f}from"./IconCircleCheck.es-D6u0E19o.js";var p=e();function m({size:e=16,className:t}){return(0,p.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:t,"aria-hidden":!0,children:(0,p.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M8 14.67C11.68 14.67 14.67 11.68 14.67 8C14.67 4.32 11.68 1.33 8 1.33C4.32 1.33 1.33 4.32 1.33 8C1.33 11.68 4.32 14.67 8 14.67ZM9.14 5.53C8.88 5.27 8.46 5.27 8.2 5.53C7.93 5.79 7.93 6.21 8.2 6.47L9.06 7.33H5.33C4.97 7.33 4.67 7.63 4.67 8C4.67 8.37 4.97 8.67 5.33 8.67H9.06L8.2 9.53C7.93 9.79 7.93 10.21 8.2 10.47C8.46 10.73 8.88 10.73 9.14 10.47L11.14 8.47C11.4 8.21 11.4 7.79 11.14 7.53L9.14 5.53Z`,fill:`currentColor`})})}var h=n(`IconPlay`,()=>(0,p.jsx)(`path`,{d:`M20.245 10.2984L9.05099 3.38443C7.71854 2.56145 6 3.51992 6 5.08603V18.914C6 20.4801 7.71854 21.4385 9.05098 20.6156L20.245 13.7016C21.5104 12.9201 21.5104 11.0799 20.245 10.2984Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`})),g=n(`IconHammer`,()=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`path`,{d:`M6.70694 14.7929C6.31641 15.1834 5.68325 15.1834 5.29272 14.7929L2.45696 11.9571C2.06643 11.5666 2.06643 10.9334 2.45696 10.5429L9.70694 3.29289C9.89447 3.10536 10.1488 3 10.414 3L14.0857 3C14.3509 3 14.6052 3.10536 14.7928 3.29289L15.7927 4.29286C16.1832 4.68338 16.1832 5.31655 15.7927 5.70707L6.70694 14.7929Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,p.jsx)(`path`,{d:`M9.5 12.5L16.3358 19.3358C17.1168 20.1168 18.3832 20.1168 19.1642 19.3358L19.3358 19.1642C20.1168 18.3832 20.1168 17.1168 19.3358 16.3358L12.5 9.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}));function _({source:e,className:n}){let{Icon:r,iconClassName:a}=i[e];return(0,p.jsx)(r,{"data-source":e,className:t(`size-4 shrink-0`,a,n),"aria-hidden":!0})}var v={Investigate:d,Build:g,"Prepare approval":o,Review:c};function y(e){let t=v[e]??h;return(0,p.jsx)(t,{"aria-hidden":!0})}var b={resting:`neutral`,working:`info`,terminal:`success`},x={neutral:{icon:`text-muted-foreground`,tint:`bg-fill-subtle`,strongTint:`bg-fill-strong`,gradientFrom:`from-fill-subtle`},orange:{icon:`text-(--orange-500) dark:text-(--orange-400)`,tint:`bg-badge-orange-subtle`,strongTint:`bg-badge-orange-strong`,gradientFrom:`from-badge-orange-subtle`},cyan:{icon:`text-(--cyan-500) dark:text-(--cyan-400)`,tint:`bg-badge-cyan-subtle`,strongTint:`bg-badge-cyan-strong`,gradientFrom:`from-badge-cyan-subtle`},info:{icon:`text-info-indicator`,tint:`bg-info-subtle`,strongTint:`bg-badge-blue-strong`,gradientFrom:`from-badge-blue-subtle`},green:{icon:`text-badge-green-indicator`,tint:`bg-badge-green-subtle`,strongTint:`bg-badge-green-strong`,gradientFrom:`from-badge-green-subtle`},purple:{icon:`text-badge-purple-indicator`,tint:`bg-badge-purple-subtle`,strongTint:`bg-badge-purple-strong`,gradientFrom:`from-badge-purple-subtle`},success:{icon:`text-(--green-500) dark:text-(--green-400)`,tint:`bg-success-subtle`,strongTint:`bg-badge-green-strong`,gradientFrom:`from-badge-green-subtle`},destructive:{icon:`text-destructive-indicator`,tint:`bg-destructive-subtle`,strongTint:`bg-badge-red-strong`,gradientFrom:`from-badge-red-subtle`}};function S({source:e,className:n}){return(0,p.jsx)(`span`,{"aria-hidden":!0,style:{maskImage:`url(${e})`},className:t(`size-4 shrink-0 bg-current mask-center mask-no-repeat mask-contain`,n)})}var C=2.25,w=2*Math.PI*C;function T({progress:e,className:n}){return(0,p.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,className:t(`shrink-0`,n),children:[(0,p.jsx)(`circle`,{cx:8,cy:8,r:6,stroke:`currentColor`,strokeWidth:1.5}),(0,p.jsx)(`circle`,{cx:8,cy:8,r:C,stroke:`currentColor`,strokeWidth:C*2,strokeDasharray:`${e*w} ${w}`,transform:`rotate(-90 8 8)`})]})}function E(e,t){return t?void 0:a(e)}function D(e,t){return e===`work`||e===`review`?void 0:t}function O(e,t){let n=r(e,t);return e&&n?D(e.id,n):void 0}function k(e,t){let n=E(e,t);return n?s(n):b[t??`resting`]}function A({stage:e,kind:n,className:r}){let i=t(`shrink-0`,r);switch(E(e,n)??n??`resting`){case`intake`:return(0,p.jsx)(m,{className:i});case`triage`:return(0,p.jsx)(S,{source:`/factory-stage-icons/triage.svg`,className:r});case`planning`:return(0,p.jsx)(T,{progress:.25,className:r});case`execute`:case`working`:return(0,p.jsx)(T,{progress:.5,className:r});case`review`:case`pr-review`:return(0,p.jsx)(S,{source:`/factory-stage-icons/review.svg`,className:r});case`done`:case`terminal`:return(0,p.jsx)(f,{"aria-hidden":!0,className:t(`size-icon-md`,i)});case`canceled`:return(0,p.jsx)(u,{"aria-hidden":!0,className:t(`size-icon-md`,i)});case`resting`:return(0,p.jsx)(l,{"aria-hidden":!0,className:t(`size-icon-md`,i)})}}function j(e,t){return x[k(e,t)].tint}function M(e,n){return t(`bg-fill-subtle dark:bg-card bg-linear-to-r to-transparent`,x[k(e,n)].gradientFrom)}function N(e,t){return x[k(e,t)].strongTint}function P(e,t){return x[k(e,t)].icon}var F=`opacity-30`;function I({stage:e,kind:t,decorative:n=!1}){let r=(0,p.jsx)(A,{stage:e,kind:t,className:x[k(e,t)].icon});return n||!t?r:(0,p.jsx)(`span`,{role:`img`,"aria-label":`${t} phase`,className:`inline-flex shrink-0`,children:r})}export{D as a,N as c,h as d,m as f,O as i,j as l,_ as n,P as o,y as r,M as s,I as t,F as u};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Fr as t,Nr as n,Pr as r,Tr as i,nn as a}from"./index-DfNj4qTr.js";import{n as o,t as s}from"./Breadcrumb.es-D9PSmzYq.js";import{a as c}from"./Sidebar.es-9pwBnu_Z.js";import{$n as l,n as u,ni as d}from"./GithubIcon.es-B1lB1Q-8.js";import{r as f}from"./useBoardEditor-Dm78Yoiu.js";import{a as p,n as m,s as h,t as g}from"./boardConfigPaths-Btimpi_r.js";import{k as _}from"./TabsRoot-C1o0G1CK.js";import{yt as v}from"./useSessionRows-aTHnrKGG.js";import{O as y,T as b,k as x,n as S}from"./IconChevronRightMedium.es-BjSIsine.js";import{o as C,s as w,t as T,u as E}from"./settings-DTWGb7K_-PW2CFx0g.js";import{a as D,c as O,d as k,i as A,l as j,n as M,o as N,r as P,t as F,u as I}from"./useRowDrag-DQBjWerU.js";import{o as L}from"./useIntakeRoutes-BNBPe6sx.js";import{h as R,p as z}from"./ruleLanes-D9QkgLJm.js";import{s as B}from"./Field.es-BmqB8MIv.js";import{n as V}from"./useBoardCatalog-DZf1osB2.js";import{t as H}from"./SettingsSubsection-DznON6FW.js";import{s as U}from"./settingsSections-B0_LEh3l.js";var W=e(x(),1),G=y();function K({factoryId:e}){let t=A(e),n=D(e),r=new Map((V(e).data??[]).map(e=>[e.id,e.name])),i=t.data?.pages??[],a=i.flatMap(e=>e.notRouted),o=i[0]?.canEdit??!1,s=e=>n.mutate(e.id,{onSuccess:t=>v.success(`Filing “${e.title}” on ${r.get(t.boardKey)??t.boardKey}.`),onError:e=>v.error(e.message)}),c=t.isPending?`Loading…`:t.isError?`Items not routed didn’t load.`:t.hasNextPage?`${a.length>0?`${a.length}+`:`More`} waiting for a board.`:a.length===0?`Every new issue and pull request found a board.`:`${a.length} waiting for a board.`;return(0,G.jsxs)(`section`,{id:m,"aria-label":`Not routed`,className:`flex scroll-mt-4 flex-col gap-3 px-3.5 pt-3 pb-3.5`,children:[(0,G.jsx)(C,{media:(0,G.jsx)(w,{children:(0,G.jsx)(j,{})}),title:(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Not routed`,(0,G.jsx)(B,{"aria-label":`When an item is not routed`,children:`A new issue or pull request ends up here when no board’s rules take it. Change a board’s rules, then route it again.`})]}),description:c}),(a.length>0||t.hasNextPage)&&(0,G.jsxs)(`ul`,{"aria-label":`Items not routed`,className:`ml-11 flex flex-col`,children:[a.map(t=>(0,G.jsx)(`li`,{className:`border-border border-t py-3`,children:(0,G.jsxs)(C,{title:t.url?(0,G.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:t.title}):t.title,description:(0,G.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[t.sourceKey&&(0,G.jsx)(`span`,{children:t.sourceKey}),(0,G.jsx)(`span`,{children:t.reason??`No board’s rules match it.`}),(0,G.jsx)(`time`,{dateTime:t.decidedAt,children:q(t.decidedAt)})]}),children:[(0,G.jsx)(M,{factoryProjectId:e,itemId:t.id,label:`Why?`}),o&&(0,G.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>s(t),disabled:n.isPending&&n.variables===t.id,children:`Route again`})]})},t.id)),t.hasNextPage&&(0,G.jsx)(`li`,{className:`border-border flex justify-center border-t pt-3`,children:(0,G.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>void t.fetchNextPage(),disabled:t.isFetchingNextPage,children:t.isFetchingNextPage?`Loading…`:`Load more`})})]})]})}function q(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}var J=b(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:top-0 data-[drop=before]:before:block data-[drop=after]:before:bottom-0 data-[drop=after]:before:block`);function Y({factoryId:e}){let t=P(e);return(0,G.jsx)(H,{id:g,scope:`factory`,title:`Intake order`,description:`A new issue or pull request is offered to each board in this order. The first board whose rules take it keeps it.`,children:t.isPending?(0,G.jsx)(T,{children:(0,G.jsx)(E,{label:`Loading intake order`,variant:`item`,rows:3})}):t.isError?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(u,{variant:`destructive`,children:`The intake order didn’t load.`}),(0,G.jsx)(`div`,{className:`border-border rounded-xl border`,children:(0,G.jsx)(K,{factoryId:e})})]}):(0,G.jsx)(X,{factoryId:e,order:t.data},e)})}function X({factoryId:e,order:t}){let n=L(e),r=N(e),[i,a]=(0,W.useState)(),o=t.boards.map(e=>e.boardKey),s=i&&$(i,o)?i:void 0,c=s??o,f=new Map(t.boards.map(e=>[e.boardKey,e.name])),p=s!==void 0&&s.some((e,t)=>e!==o[t]),m=(e,t)=>{let n=[...c],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),a(n))},g=F({min:0,max:c.length-1,onDrop:m}),_=()=>r.mutate(c,{onSuccess:()=>{a(void 0),v.success(`Intake order saved.`)},onError:e=>v.error(e.message)}),y=t.canEdit&&c.length>1,x=y&&!r.isPending;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(Q,{order:t,changed:p}),n.isError&&(0,G.jsx)(u,{variant:`warning`,children:`Rule counts didn’t load.`}),(0,G.jsxs)(`div`,{className:`border-border flex flex-col rounded-xl border`,children:[(0,G.jsx)(T,{role:`list`,"aria-label":`Intake order`,children:c.map((t,r)=>{let i=g.drag?.from===r,a=f.get(t)??t;return(0,G.jsx)(C,{role:`listitem`,"data-drop":g.dropAt(r),style:i?{transform:`translateY(${g.drag?.offset??0}px)`}:void 0,onPointerDown:x?e=>g.onPointerDown(e,r):void 0,onKeyDown:x?e=>g.onKeyDown(e,r):void 0,className:b(`group/row`,J,i&&`z-10 opacity-90`),media:(0,G.jsxs)(w,{children:[(0,G.jsx)(S,{as:`span`,variant:`caption`,className:b(`tabular-nums`,y&&`pointer-fine:group-hover/row:hidden`,i&&`hidden`),children:r+1}),y&&(0,G.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:b(`text-icon3 hidden cursor-grab touch-none pointer-fine:group-hover/row:inline-flex`,i&&`inline-flex`),children:(0,G.jsx)(O,{className:`size-icon-md`})})]}),title:a,description:(0,G.jsx)(Z,{routes:n.data?.intakeRoutes,boardKey:t}),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/row:opacity-100 pointer-fine:group-hover/row:opacity-100`,children:[y&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(d,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!x||r===0,onClick:()=>m(r,r-1),children:(0,G.jsx)(I,{})}),(0,G.jsx)(d,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!x||r===c.length-1,onClick:()=>m(r,r+1),children:(0,G.jsx)(k,{})})]}),(0,G.jsx)(d,{size:`sm`,variant:`ghost`,render:(0,G.jsx)(l,{to:h(e,t)}),children:`Edit rules`})]})},t)})}),(0,G.jsx)(K,{factoryId:e})]}),t.canEdit&&p&&(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>a(void 0),disabled:r.isPending,children:`Discard`}),(0,G.jsx)(d,{size:`sm`,variant:`primary`,onClick:_,disabled:r.isPending,children:`Save order`})]})]})}function Z({routes:e,boardKey:t}){if(!e)return null;let{count:n,catchesAll:r}=z(e.filter(e=>e.target.boardKey===t));return(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{children:n===0?`No rules for new issues and pull requests`:`${R(n)} for new issues and pull requests`}),r&&(0,G.jsx)(_,{children:`Ends in catch-all`})]})}function Q({order:e,changed:t}){let{compared:n,differing:r,notRouted:i}=e.comparison,a=[];if(e.origin===`derived`&&a.push(`Worked out from the old route list until someone saves an order.`),n>0){let e=i>0?`, ${i} of them Not routed`:``;a.push(r===0?`The last ${n} cards land on the same boards as with the old route list.`:`Of the last ${n} cards, ${r} would land on another board than with the old route list${e}.`)}return e.evaluator===`route-list`&&a.push(`Intake still files cards by the old route list.`),t&&a.push(`Not saved yet. The comparison is for the saved order.`),a.length===0?null:(0,G.jsx)(u,{variant:`info`,children:(0,G.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,G.jsx)(`span`,{children:e},e))})})}function $(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function ee(){let e=i(),u=a()?.boardId??``,{isMobile:d,desktopState:m}=c(),h=d||m===`collapsed`,g=f(e.id,u).data?.board,_=n({breadcrumbs:h&&g?(0,G.jsxs)(s,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,G.jsx)(o,{as:l,to:p(e.id,u),children:g.name}),(0,G.jsx)(o,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,G.jsx)(r,{variant:`settings`,header:(0,G.jsxs)(t,{children:[(0,G.jsx)(t.Title,{children:`Routing`}),(0,G.jsx)(t.Description,{children:(0,G.jsxs)(`span`,{children:[`The order boards are offered new issues and pull requests. What comes in is chosen in`,` `,(0,G.jsx)(l,{to:U(e.id,`intake`),className:`underline`,children:`Settings → Work Intake`}),`.`]})})]}),..._,children:(0,G.jsx)(Y,{factoryId:e.id})})}export{ee as BoardIntakePage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Fr as t,Nr as n,Pr as r,Tr as i,nn as a}from"./index-DtRZNzyn.js";import{n as o,t as s}from"./Breadcrumb.es-CVW-e0jJ.js";import{a as c}from"./Sidebar.es-CFLW5bYW.js";import{$n as l,n as u,ni as d}from"./GithubIcon.es-BmZS8JQG.js";import{r as f}from"./useBoardEditor-Bn11vS5Q.js";import{a as p,n as m,s as h,t as g}from"./boardConfigPaths-Btimpi_r.js";import{k as _}from"./TabsRoot-DNjGHnQQ.js";import{yt as v}from"./useSessionRows-CnLoToLZ.js";import{O as y,T as b,k as x,n as S}from"./IconChevronRightMedium.es-BkPdzxSm.js";import{o as C,s as w,t as T,u as E}from"./settings-C5r2ThW9-D7BpEINa.js";import{a as D,c as O,d as k,i as A,l as j,n as M,o as N,r as P,t as F,u as I}from"./useRowDrag-0taus7Yi.js";import{o as L}from"./useIntakeRoutes-OObHoZos.js";import{h as R,p as z}from"./ruleLanes-zac0HQwn.js";import{s as B}from"./Field.es-C1w4lsXS.js";import{n as V}from"./useBoardCatalog-C-gXjA-g.js";import{t as H}from"./SettingsSubsection-B_X_u0Kt.js";import{s as U}from"./settingsSections-XZPX_pR6.js";var W=e(x(),1),G=y();function K({factoryId:e}){let t=A(e),n=D(e),r=new Map((V(e).data??[]).map(e=>[e.id,e.name])),i=t.data?.pages??[],a=i.flatMap(e=>e.notRouted),o=i[0]?.canEdit??!1,s=e=>n.mutate(e.id,{onSuccess:t=>v.success(`Filing “${e.title}” on ${r.get(t.boardKey)??t.boardKey}.`),onError:e=>v.error(e.message)}),c=t.isPending?`Loading…`:t.isError?`Items not routed didn’t load.`:t.hasNextPage?`${a.length>0?`${a.length}+`:`More`} waiting for a board.`:a.length===0?`Every new issue and pull request found a board.`:`${a.length} waiting for a board.`;return(0,G.jsxs)(`section`,{id:m,"aria-label":`Not routed`,className:`flex scroll-mt-4 flex-col gap-3 px-3.5 pt-3 pb-3.5`,children:[(0,G.jsx)(C,{media:(0,G.jsx)(w,{children:(0,G.jsx)(j,{})}),title:(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Not routed`,(0,G.jsx)(B,{"aria-label":`When an item is not routed`,children:`A new issue or pull request ends up here when no board’s rules take it. Change a board’s rules, then route it again.`})]}),description:c}),(a.length>0||t.hasNextPage)&&(0,G.jsxs)(`ul`,{"aria-label":`Items not routed`,className:`ml-11 flex flex-col`,children:[a.map(t=>(0,G.jsx)(`li`,{className:`border-border border-t py-3`,children:(0,G.jsxs)(C,{title:t.url?(0,G.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:t.title}):t.title,description:(0,G.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[t.sourceKey&&(0,G.jsx)(`span`,{children:t.sourceKey}),(0,G.jsx)(`span`,{children:t.reason??`No board’s rules match it.`}),(0,G.jsx)(`time`,{dateTime:t.decidedAt,children:q(t.decidedAt)})]}),children:[(0,G.jsx)(M,{factoryProjectId:e,itemId:t.id,label:`Why?`}),o&&(0,G.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>s(t),disabled:n.isPending&&n.variables===t.id,children:`Route again`})]})},t.id)),t.hasNextPage&&(0,G.jsx)(`li`,{className:`border-border flex justify-center border-t pt-3`,children:(0,G.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>void t.fetchNextPage(),disabled:t.isFetchingNextPage,children:t.isFetchingNextPage?`Loading…`:`Load more`})})]})]})}function q(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}var J=b(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:top-0 data-[drop=before]:before:block data-[drop=after]:before:bottom-0 data-[drop=after]:before:block`);function Y({factoryId:e}){let t=P(e);return(0,G.jsx)(H,{id:g,scope:`factory`,title:`Intake order`,description:`A new issue or pull request is offered to each board in this order. The first board whose rules take it keeps it.`,children:t.isPending?(0,G.jsx)(T,{children:(0,G.jsx)(E,{label:`Loading intake order`,variant:`item`,rows:3})}):t.isError?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(u,{variant:`destructive`,children:`The intake order didn’t load.`}),(0,G.jsx)(`div`,{className:`border-border rounded-xl border`,children:(0,G.jsx)(K,{factoryId:e})})]}):(0,G.jsx)(X,{factoryId:e,order:t.data},e)})}function X({factoryId:e,order:t}){let n=L(e),r=N(e),[i,a]=(0,W.useState)(),o=t.boards.map(e=>e.boardKey),s=i&&$(i,o)?i:void 0,c=s??o,f=new Map(t.boards.map(e=>[e.boardKey,e.name])),p=s!==void 0&&s.some((e,t)=>e!==o[t]),m=(e,t)=>{let n=[...c],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),a(n))},g=F({min:0,max:c.length-1,onDrop:m}),_=()=>r.mutate(c,{onSuccess:()=>{a(void 0),v.success(`Intake order saved.`)},onError:e=>v.error(e.message)}),y=t.canEdit&&c.length>1,x=y&&!r.isPending;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(Q,{order:t,changed:p}),n.isError&&(0,G.jsx)(u,{variant:`warning`,children:`Rule counts didn’t load.`}),(0,G.jsxs)(`div`,{className:`border-border flex flex-col rounded-xl border`,children:[(0,G.jsx)(T,{role:`list`,"aria-label":`Intake order`,children:c.map((t,r)=>{let i=g.drag?.from===r,a=f.get(t)??t;return(0,G.jsx)(C,{role:`listitem`,"data-drop":g.dropAt(r),style:i?{transform:`translateY(${g.drag?.offset??0}px)`}:void 0,onPointerDown:x?e=>g.onPointerDown(e,r):void 0,onKeyDown:x?e=>g.onKeyDown(e,r):void 0,className:b(`group/row`,J,i&&`z-10 opacity-90`),media:(0,G.jsxs)(w,{children:[(0,G.jsx)(S,{as:`span`,variant:`caption`,className:b(`tabular-nums`,y&&`pointer-fine:group-hover/row:hidden`,i&&`hidden`),children:r+1}),y&&(0,G.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:b(`text-icon3 hidden cursor-grab touch-none pointer-fine:group-hover/row:inline-flex`,i&&`inline-flex`),children:(0,G.jsx)(O,{className:`size-icon-md`})})]}),title:a,description:(0,G.jsx)(Z,{routes:n.data?.intakeRoutes,boardKey:t}),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/row:opacity-100 pointer-fine:group-hover/row:opacity-100`,children:[y&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(d,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!x||r===0,onClick:()=>m(r,r-1),children:(0,G.jsx)(I,{})}),(0,G.jsx)(d,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!x||r===c.length-1,onClick:()=>m(r,r+1),children:(0,G.jsx)(k,{})})]}),(0,G.jsx)(d,{size:`sm`,variant:`ghost`,render:(0,G.jsx)(l,{to:h(e,t)}),children:`Edit rules`})]})},t)})}),(0,G.jsx)(K,{factoryId:e})]}),t.canEdit&&p&&(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>a(void 0),disabled:r.isPending,children:`Discard`}),(0,G.jsx)(d,{size:`sm`,variant:`primary`,onClick:_,disabled:r.isPending,children:`Save order`})]})]})}function Z({routes:e,boardKey:t}){if(!e)return null;let{count:n,catchesAll:r}=z(e.filter(e=>e.target.boardKey===t));return(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{children:n===0?`No rules for new issues and pull requests`:`${R(n)} for new issues and pull requests`}),r&&(0,G.jsx)(_,{children:`Ends in catch-all`})]})}function Q({order:e,changed:t}){let{compared:n,differing:r,notRouted:i}=e.comparison,a=[];if(e.origin===`derived`&&a.push(`Worked out from the old route list until someone saves an order.`),n>0){let e=i>0?`, ${i} of them Not routed`:``;a.push(r===0?`The last ${n} cards land on the same boards as with the old route list.`:`Of the last ${n} cards, ${r} would land on another board than with the old route list${e}.`)}return e.evaluator===`route-list`&&a.push(`Intake still files cards by the old route list.`),t&&a.push(`Not saved yet. The comparison is for the saved order.`),a.length===0?null:(0,G.jsx)(u,{variant:`info`,children:(0,G.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,G.jsx)(`span`,{children:e},e))})})}function $(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function ee(){let e=i(),u=a()?.boardId??``,{isMobile:d,desktopState:m}=c(),h=d||m===`collapsed`,g=f(e.id,u).data?.board,_=n({breadcrumbs:h&&g?(0,G.jsxs)(s,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,G.jsx)(o,{as:l,to:p(e.id,u),children:g.name}),(0,G.jsx)(o,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,G.jsx)(r,{variant:`settings`,header:(0,G.jsxs)(t,{children:[(0,G.jsx)(t.Title,{children:`Routing`}),(0,G.jsx)(t.Description,{children:(0,G.jsxs)(`span`,{children:[`The order boards are offered new issues and pull requests. What comes in is chosen in`,` `,(0,G.jsx)(l,{to:U(e.id,`intake`),className:`underline`,children:`Settings → Work Intake`}),`.`]})})]}),..._,children:(0,G.jsx)(Y,{factoryId:e.id})})}export{ee as BoardIntakePage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$n as t,Fr as n,Jn as r,Kn as i,Nr as a,Pr as o,Tr as s,Yn as c,nn as l,qn as u}from"./index-DfNj4qTr.js";import{n as d,t as f}from"./Breadcrumb.es-D9PSmzYq.js";import{a as p}from"./Sidebar.es-9pwBnu_Z.js";import{$n as m,At as h,Dt as ee,St as g,ir as _,jt as v,kt as y,n as b,ni as x,t as S,wt as C}from"./GithubIcon.es-B1lB1Q-8.js";import{r as w,t as T}from"./useBoardEditor-Dm78Yoiu.js";import{a as E,i as D,o as O,s as k,t as A}from"./boardConfigPaths-Btimpi_r.js";import{r as j}from"./CompositeItem-CD2x3KaL.js";import{yt as M}from"./useSessionRows-aTHnrKGG.js";import{d as N,n as te}from"./settings-DTWGb7K_-PW2CFx0g.js";import{O as P,T as F,k as I,n as L}from"./IconChevronRightMedium.es-BjSIsine.js";import{n as R}from"./useBoardCatalog-DZf1osB2.js";import{c as ne,d as re,l as z,n as B,r as ie,s as V,t as H,u as U}from"./useRowDrag-DQBjWerU.js";import{a as ae,d as oe,f as se,g as W,o as ce,r as G,s as le}from"./useIntakeRoutes-BNBPe6sx.js";import{C as ue,E as de,_ as fe,a as pe,c as K,d as me,f as he,g as ge,i as _e,l as q,m as ve,n as ye,o as be,s as xe,u as J,w as Se}from"./ruleLanes-D9QkgLJm.js";import{t as Y}from"./createLucideIcon-B6gALBEh.js";import{a as Ce,t as we}from"./BoardIcons-DXB--WrY.js";import{t as Te}from"./input-DqReKX0A-B4MUvQwj.js";import{n as Ee,t as De}from"./RadioGroup.es-Ws4_oCJe.js";import{n as Oe,t as ke}from"./ConditionRows-EkFcLg06.js";import{i as X,k as Ae}from"./TabsRoot-C1o0G1CK.js";import{E as je}from"./combobox-parts-s-DJvMW4-CR5ZbuEq.js";var Me={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Me.node;var Ne=Y(Me),Pe={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Pe.node;var Fe=Y(Pe),Ie={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ie.node;var Le=Y(Ie),Re={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Re.node;var ze=Y(Re),Be={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Be.node;var Ve=Y(Be),He={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};He.node;var Ue=Y(He),We={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};We.node;var Ge=Y(We),Ke={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};Ke.node;var qe=Y(Ke),Je={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Je.node;var Ye=Y(Je),Xe={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Xe.node;var Ze=Y(Xe),Qe={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Qe.node;var $e=Y(Qe),Z=e(I(),1),Q=P();function et({when:e,options:t,everything:n}){let r=ue(e,t);return!e||!r?(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:n}):(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:r.parts.map((t,n)=>{let i=e.conditions[n],a=i&&`conditions`in i?i:void 0;return(0,Q.jsxs)(`span`,{className:`contents`,children:[n>0&&(0,Q.jsx)(L,{as:`span`,variant:`meta`,tone:`muted`,children:r.join}),a?(0,Q.jsxs)(`span`,{className:`border-border inline-flex max-w-full items-center gap-1 rounded-md border border-dashed px-1 py-0.5`,children:[(0,Q.jsx)(L,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Q.jsx)(tt,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Q.jsx)(tt,{children:t})]},n)})})}function tt({children:e}){return(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}function nt({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let a=e.find(e=>e.id===n);if(!a)return(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let o=r??a.initialPhase,s=a.phases.find(e=>e.id===o);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[a.id!==t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`truncate`,children:i(a)}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),s&&(0,Q.jsx)(we,{stage:s.id,kind:Ce(a.id,s.kind),decorative:!0}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`truncate`,children:u(a,o)??o})]})}function rt({factoryId:e,rules:t,board:n,boards:a}){return(0,Q.jsxs)(`section`,{"aria-label":`From other boards`,className:`border-border mt-3 flex flex-col gap-1.5 border-t pt-3`,children:[(0,Q.jsxs)(L,{as:`h4`,variant:`meta`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(qe,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),`From other boards`]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(t=>{let o=a.find(e=>e.id===t.target.boardKey);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(m,{to:k(e,t.target.boardKey),"aria-label":`${t.name}, on ${o?i(o):t.target.boardKey}`,className:F(`group flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,!t.enabled&&`opacity-50`),children:[(0,Q.jsxs)(`span`,{className:`border-border group-hover:border-border-hover flex w-full min-w-0 flex-col gap-1 rounded-lg border border-dashed px-3 py-2 sm:flex-1`,children:[(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:o?i(o):`${t.target.boardKey} (not installed)`}),(0,Q.jsx)(et,{when:t.when,options:r(o),everything:`Every card`})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`border-border-strong h-0 w-8 shrink-0 border-t border-dashed`}),(0,Q.jsx)(Ne,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex w-44 shrink-0 items-center px-3 py-2`,children:(0,Q.jsx)(nt,{boards:a,ownBoard:n.id,boardKey:n.id,phaseKey:t.target.phaseKey})})]}),!t.enabled&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:`Off`})]})},t.id)})})]})}function it({factoryId:e,boardKey:t,order:n,evaluator:r}){let i=n.some(e=>e.boardKey===t);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r===`route-list`?(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:`Intake still files new issues and pull requests by the old route list, not by board.`}):i?(0,Q.jsxs)(`ol`,{"aria-label":`Intake order`,className:`flex flex-wrap items-center gap-1`,children:[n.map(n=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`li`,{children:n.boardKey===t?(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`ink`,"aria-current":`step`,className:`bg-surface3 rounded-md px-2 py-0.5 font-medium`,children:n.name}):(0,Q.jsx)(m,{to:k(e,n.boardKey),className:`text-muted-foreground hover:text-foreground rounded-md px-2 py-0.5`,children:(0,Q.jsx)(L,{as:`span`,variant:`caption`,children:n.name})})}),(0,Q.jsx)(Le,{"aria-hidden":!0,className:`text-muted-foreground size-icon-xs shrink-0`})]},n.boardKey)),(0,Q.jsx)(`li`,{children:(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`px-2 py-0.5`,children:`Not routed`})})]}):(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:`Not in the intake order: new issues and pull requests never reach these rules.`}),(0,Q.jsxs)(m,{to:O(e,t,A),className:`text-muted-foreground hover:text-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(Ge,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`underline decoration-dotted underline-offset-2`,children:`Reorder`})]})]})}var at=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,ot=`border-border-focus bg-fill-hover`,st=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function ct({selected:e,disabled:t,onClick:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,onClick:n,className:F(at,`disabled:opacity-50`,e?ot:st),children:r})}function lt({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`label`,{onClick:r,className:F(at,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?ot:st,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsx)(Ee,{value:e,disabled:n,"aria-labelledby":a,className:`sr-only`}),(0,Q.jsx)(`span`,{id:a,className:`flex min-w-0 items-start gap-3`,children:i})]})}function ut(){return(0,Q.jsx)(Ae,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(S,{"aria-hidden":`true`}),children:`GitHub only`})}var dt=120,ft=W(le),$=[{id:`trigger`,title:`Trigger`,question:`What should this rule listen for?`},{id:`conditions`,title:`Only if`,question:`Which items should it apply to?`},{id:`action`,title:`Move to`,question:`Where should it go?`},{id:`review`,title:`Review`,question:`Name and check your rule`}];function pt(e,t){let n=e?.phases??[];return t?n.filter(e=>e.kind!==`terminal`):n}function mt(e,t){if(t){let e=ft.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return se(e,t)??void 0}function ht(e,t,n){let r=`When ${e.map(e=>J(e).label.toLowerCase()).join(` or `)}${t?`, ${Se(t).charAt(0).toLowerCase()}${Se(t).slice(1)}`:``}, move to ${n}`;return r.length>dt?`${r.slice(0,119)}…`:r}function gt({factoryId:e,board:t,boards:n,initial:a,initialEvent:o,initialStep:s,readOnly:c,saving:l,error:d,onSave:f,onClose:p}){let m=Oe(e),[_,S]=(0,Z.useState)(()=>a?.on??(o?[o]:[])),[w,T]=(0,Z.useState)(()=>a?.when??null),[E,D]=(0,Z.useState)(()=>(a?.when?.conditions.length??0)>0),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(()=>a?.target.moveToBoardKey??t.id),[M,N]=(0,Z.useState)(()=>a?a.target.phaseKey??void 0:void 0),[te,P]=(0,Z.useState)(()=>a?.name),[I,R]=(0,Z.useState)(s),[ne,re]=(0,Z.useState)(0),z=ve(_),B=n.find(e=>e.id===A),ie=pt(B,z),V=ie.find(e=>e.id===(M??B?.initialPhase)),H=E?w:null,U=_.length?mt(_,H):void 0,ae=V&&B?`${i(B)} › ${u(B,V.id)}`:``,se=te??(V?ht(_,H,ae):``),W={trigger:_.length>0,conditions:_.length>0&&!(E&&O)&&!U,action:V!==void 0,review:se.trim().length>0},ce=!c&&W.trigger&&W.conditions&&W.action&&W.review,G=$.findIndex(e=>e.id===I),le=$[G]??$[0],ue=e=>{S(e),ve(e)&&A!==t.id&&(j(t.id),N(void 0))},fe=()=>{ce&&V&&f({name:se.trim(),on:_,when:H,target:{phaseKey:V.id,moveToBoardKey:A===t.id?null:A}})},pe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};T(H===null?{operator:`AND`,conditions:[e]}:H.operator===`AND`?{...H,conditions:[...H.conditions,e]}:{operator:`AND`,conditions:[H,e]}),D(!0),k(!1),re(e=>e+1)},K={trigger:_.length?_.map(e=>J(e).label).join(`, `):void 0,conditions:_.length?Se(H,r(t)):void 0,action:V?(0,Q.jsx)(nt,{boards:n,ownBoard:t.id,boardKey:A,phaseKey:V.id}):void 0,review:void 0};return(0,Q.jsx)(g,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(ee,{size:`xl`,children:[(0,Q.jsx)(h,{children:(0,Q.jsx)(v,{children:c?`Rule`:a?`Edit rule`:`Add rule`})}),(0,Q.jsx)(C,{children:(0,Q.jsxs)(`div`,{className:`grid min-h-105 grid-cols-1 gap-6 sm:grid-cols-[12rem_1fr]`,children:[(0,Q.jsx)(`nav`,{"aria-label":`Rule steps`,className:`sm:border-border flex gap-1 overflow-x-auto sm:flex-col sm:border-r sm:pr-4`,children:$.map((e,t)=>{let n=t===0||$.slice(0,t).every(e=>W[e.id]),r=W[e.id]&&e.id!==`review`;return(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":I===e.id?`step`:void 0,onClick:()=>R(e.id),className:F(`flex shrink-0 items-start gap-2.5 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-40`,I===e.id?`bg-fill-hover`:`hover:bg-fill-subtle`),children:[(0,Q.jsx)(L,{as:`span`,variant:`meta`,className:F(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border`,r?`border-transparent bg-fill-inverse text-background`:`border-border-strong`),children:r?(0,Q.jsx)(Fe,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),K[e.id]&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:K[e.id]})]})]},e.id)})}),(0,Q.jsxs)(`section`,{"aria-label":le.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsx)(L,{as:`h3`,variant:`heading`,children:le.question}),I===`trigger`&&(0,Q.jsx)(yt,{value:_,disabled:c,onChange:ue}),I===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(De,{"aria-label":`Which ones`,value:E?`matching`:`every`,disabled:c,onValueChange:e=>{D(e===`matching`),k(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Q.jsx)(lt,{value:`every`,selected:!E,disabled:c,children:(0,Q.jsx)(_t,{title:z?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(lt,{value:`matching`,selected:E,disabled:c,children:(0,Q.jsx)(_t,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),E&&(0,Q.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Q.jsx)(ke,{label:`Conditions`,rule:w,facts:de(_),options:{...r(t),"source.repository":m},onChange:(e,t)=>{T(e),k(t)}},ne)}),U&&(0,Q.jsx)(b,{variant:`warning`,children:U}),!a?.outsiderPullRequestsGated&&oe(_,H)&&(0,Q.jsx)(b,{variant:`info`,children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{children:`Also matches pull requests from outside authors.`}),!c&&(0,Q.jsx)(`button`,{type:`button`,onClick:pe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),I===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[z?(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:`An item with no card yet can only be filed on this board.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Q.jsx)(De,{"aria-label":`Board`,value:A,disabled:c,onValueChange:e=>{typeof e==`string`&&e!==A&&(j(e),N(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:n.map(e=>(0,Q.jsx)(lt,{value:e.id,selected:e.id===A,disabled:c,children:(0,Q.jsxs)(L,{as:`span`,variant:`label`,tone:`ink`,children:[i(e),e.id===t.id?` (this board)`:``]})},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Q.jsx)(De,{"aria-label":`Phase`,value:V?.id??null,disabled:c,onValueChange:e=>typeof e==`string`&&N(e),className:`grid-cols-1 sm:grid-cols-2`,children:B&&ie.map(e=>(0,Q.jsx)(lt,{value:e.id,selected:e.id===V?.id,disabled:c,onClick:()=>{N(e.id),R(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(we,{stage:e.id,kind:Ce(B.id,e.kind),decorative:!0}),(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,children:u(B,e.id)})]})},e.id))})]})]}),I===`review`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Q.jsx)(Te,{value:se,maxLength:dt,disabled:c,onChange:e=>P(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,className:`mb-3 block`,children:`This rule reads as`}),(0,Q.jsxs)(`ol`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(vt,{label:`When`,children:K.trigger}),(0,Q.jsx)(vt,{label:`Only if`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Ve,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),K.conditions]})}),(0,Q.jsx)(vt,{label:`Then`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Q.jsx)(Ne,{className:`size-icon-sm`,"aria-hidden":!0}),` `,K.action]})})]})]})]}),d&&(0,Q.jsx)(b,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(y,{children:[(0,Q.jsx)(x,{variant:`ghost`,onClick:p,children:c?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),G>0&&(0,Q.jsx)(x,{variant:`default`,onClick:()=>R($[G-1].id),children:`Back`}),!c&&(I===`review`||a&&ce?(0,Q.jsx)(x,{variant:`primary`,disabled:!ce||l,onClick:fe,children:l?`Saving…`:a?`Save rule`:`Create rule`}):(0,Q.jsx)(x,{variant:`primary`,disabled:!W[I],onClick:()=>R($[G+1]?.id??`review`),children:`Continue`}))]})]})})}function _t({title:e,hint:t}){return(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function vt({label:e,children:t}){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Q.jsx)(L,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Q.jsx)(L,{as:`span`,variant:`body-sm`,children:t})]})}function yt({value:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.includes(`work_item.created`)&&(0,Q.jsxs)(b,{variant:`info`,children:[`Also listens on “`,J(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),ye.map(r=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:r.title}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.events.map(r=>{let i=J(r),a=i.icon,o=e.includes(r);return(0,Q.jsxs)(ct,{selected:o,disabled:t||o&&e.length===1,onClick:()=>n(o?e.filter(e=>e!==r):[...e,r]),children:[(0,Q.jsx)(a,{className:`text-badge-amber-indicator mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(_t,{title:i.label,hint:i.description}),i.githubOnly&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(ut,{})})]},r)})})]},r.title))]})}function bt({count:e,into:t,leaving:n,showAll:r}){let i=n?`sending cards to ${t}`:`moving cards into ${t}`;return(0,Q.jsxs)(`div`,{className:`border-border flex items-center gap-2 rounded-lg border px-3 py-2`,children:[(0,Q.jsx)(Ue,{className:`size-icon-md text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`p`,variant:`body-sm`,tone:e===void 0?`muted`:`ink`,className:`flex-1`,children:e===void 0?`Couldn’t pick out the rules ${i}, so every rule is shown.`:e===0?`No rule is ${i}.`:`Only the ${e===1?`rule`:`${e} rules`} ${i}.`}),(0,Q.jsx)(x,{size:`sm`,variant:`ghost`,render:(0,Q.jsx)(m,{to:r}),children:`Show all`})]})}var xt=F(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:-top-1 data-[drop=before]:before:block data-[drop=after]:before:-bottom-1 data-[drop=after]:before:block`);function St({event:e,rules:t,board:n,boards:r,phaseOptions:a,canEdit:o,skips:s,footer:c,incoming:l,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:ee,onUngate:g}){let _=J(e),v=_.icon,y=pe(t,e),b=K(e),S=be(e),C=H({min:0,max:t.length-1,onDrop:m}),w=o&&t.length>1&&!d,T=c??(t.length?`Otherwise, the card stays where it is`:l?`No rules: this board’s cards stay where they are`:`No rules: the card stays where it is`);return(0,Q.jsxs)(`section`,{"aria-label":_.label,className:F(`flex flex-col gap-3 rounded-xl border border-border bg-card p-4`,!t.length&&!l&&`opacity-60 focus-within:opacity-100 hover:opacity-100`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(v,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`h3`,variant:`label`,tone:`ink`,children:_.label}),_.githubOnly&&(0,Q.jsx)(ut,{})]}),_.description&&(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:_.description})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`${_.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((c,l)=>{if(d&&!d.has(c.id))return null;let p=ge(t,e,l),v=p>=0,T=!c.enabled||v,E=C.drag?.from===l,D=s?.get(c.id),O=r.find(e=>e.id===(c.target.moveToBoardKey??c.target.boardKey)),k=!he(c.name,[_.label,Se(c.when,a),O&&i(O),u(O,c.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":c.name,"data-drop":C.dropAt(l),style:E?{transform:`translateY(${C.drag?.offset??0}px)`}:void 0,onPointerDown:w?e=>C.onPointerDown(e,l):void 0,className:F(`group/rule flex flex-col`,xt,E&&`z-10 opacity-90`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 sm:flex-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Edit conditions of ${c.name}`,onClick:()=>f(c,`conditions`),onKeyDown:w?e=>C.onKeyDown(e,l):void 0,className:F(`flex w-full items-start gap-2.5 rounded-lg border bg-fill-subtle px-3 py-2 text-left transition-colors hover:border-border-hover`,T?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Q.jsxs)(L,{as:`span`,variant:`meta`,tone:`muted`,className:`bg-fill mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full tabular-nums`,children:[(0,Q.jsx)(`span`,{className:F(w&&`pointer-fine:group-hover/rule:hidden`,E&&`hidden`),children:l+1}),w&&(0,Q.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:F(`hidden cursor-grab touch-none pointer-fine:group-hover/rule:flex`,E&&`flex`),children:(0,Q.jsx)(ne,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[k&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:c.name}),(0,Q.jsx)(et,{when:c.when,options:a,everything:S})]})]}),w&&(0,Q.jsxs)(`div`,{className:`border-border bg-card absolute top-0 right-2 flex -translate-y-1/2 rounded-md border shadow-sm transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/rule:opacity-100 pointer-fine:group-hover/rule:opacity-100`,children:[(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:l===0,onClick:()=>m(l,l-1),children:(0,Q.jsx)(U,{})}),(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:l===t.length-1,onClick:()=>m(l,l+1),children:(0,Q.jsx)(re,{})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 sm:shrink-0`,children:[(0,Q.jsxs)(`div`,{className:F(`flex min-w-0 items-center`,T&&`opacity-40`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:F(`h-px w-8 shrink-0`,T?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Q.jsx)(Ne,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit where ${c.name} moves the card`,onClick:()=>f(c,`action`),className:`border-border bg-fill-subtle hover:border-border-hover flex w-44 shrink-0 rounded-lg border px-3 py-2 text-left`,children:(0,Q.jsx)(nt,{boards:r,ownBoard:n.id,boardKey:c.target.moveToBoardKey??c.target.boardKey,phaseKey:c.target.phaseKey})})]}),o&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(je,{"aria-label":`${c.name} on`,checked:c.enabled,onCheckedChange:e=>h(c,e)}),(0,Q.jsxs)(X,{children:[(0,Q.jsx)(X.Trigger,{render:(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${c.name}`,children:(0,Q.jsx)(ze,{})})}),(0,Q.jsx)(X.Content,{align:`end`,children:(0,Q.jsxs)(X.Item,{variant:`destructive`,onClick:()=>ee(c),children:[(0,Q.jsx)(Ze,{}),`Delete rule`]})})]})]})]})]}),T&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,p+1,` above matches `,S.toLowerCase(),`.`]}):`Off, skipped`}),c.problems.map(e=>(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),D&&(0,Q.jsx)(wt,{skips:D}),fe(c,e)&&(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[`Skips outside authors’ pull requests (older rule).`,o&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>g(c),className:`underline`,children:`Let outside authors match`})]}),me(c,e)&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),b&&xe(c)&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:J(`work_item.created`).label}),l!==y&&!d&&(0,Q.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-7 items-center pl-5.5`,children:[(0,Q.jsx)(`span`,{className:`bg-border-strong h-full w-px`}),(0,Q.jsx)(L,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},c.id)}),!d&&(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[y<0&&(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`flex flex-1 items-center gap-2.5 px-3 py-1.5`,children:[(0,Q.jsx)(z,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),T]}),o&&(0,Q.jsx)(x,{variant:`ghost`,size:`sm`,icon:(0,Q.jsx)(Ye,{}),onClick:p,children:`Add rule`})]})]}),l]})]})}function Ct(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function wt({skips:e}){let{count:t,latest:n}=e;return(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[`Skipped `,t===1?`once`:`${t} times`,` in the last 30 days: `,Ct(n.reason),`.`]}),n.url?(0,Q.jsxs)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`Latest: `,n.title]}):(0,Q.jsxs)(`span`,{children:[`Latest: `,n.title]})]})}var Tt=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function Et(e){return e instanceof T&&e.code!==void 0&&Tt.has(e.code)}function Dt(e){return Et(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function Ot({factoryId:e,boardId:t}){let n=R(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(j,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(b,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Q.jsx)(kt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Q.jsx)(b,{variant:`warning`,children:`This board isn’t installed.`})}function kt({factoryId:e,board:n,boards:i}){let a=G(e,n.id),o=ce(e),s=ie(e),l=V(e),d=ae(e),[f,p]=(0,Z.useState)(),m=(0,Z.useRef)(void 0),h=e=>{m.current=e,p(e)},[ee,g]=(0,Z.useState)(),v=a.data?.intakeRoutes??[],y=a.data?.canEdit??!1,x=r(n),S=(o.data?.intakeRoutes??[]).filter(e=>e.target.moveToBoardKey===n.id&&e.target.boardKey!==n.id),C=new Map(l.data?.skipped.map(e=>[e.routeId,e])),[w]=_(),T=w.get(`into`)??void 0,E=w.has(D),O=E||T!==void 0,A=O&&o.data?t(o.data.intakeRoutes,{key:n.id,initialPhase:n.initialPhase}):void 0,P=A&&new Set((E?A.leaving:A.into.get(T??``)??[]).map(e=>e.id)),F=e=>!P||e.some(e=>P.has(e.id));if(a.isPending||O&&o.isPending)return(0,Q.jsx)(j,{className:`h-64 w-full`});if(a.isError)return(0,Q.jsx)(b,{variant:`destructive`,children:`This board’s rules didn’t load.`});let I=e=>d.mutateAsync(e).catch(e=>M.error(Dt(e))),L=(e,t,r)=>{let i=q(v,e).map(e=>e.id);I([{kind:`reorder`,boardKey:n.id,ids:c(v,i,t,r)}])},R=e=>{g(void 0),h(e)},ne=async e=>{let t=m.current,r=t?.rule,i=()=>t!==void 0&&m.current===t;g(void 0);try{if(r)await d.mutateAsync([{kind:`update`,id:r.id,patch:{name:e.name,on:e.on,when:e.when,target:{boardKey:r.target.boardKey,...e.target,joinClosedIssue:r.target.joinClosedIssue},expectedRevision:r.revision}}]);else{let[t]=await d.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:n.id,...e.target}}}]);i()&&h(void 0),t&&await z(t,e.on).catch(e=>M.error(Dt(e)));return}i()&&h(void 0)}catch(e){if(!i())return;if(r&&Et(e))return re(r);g(Dt(e))}},re=async e=>{let t=m.current,n=(await a.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&m.current===t&&(n?(h({...t,rule:n}),g(`Someone else changed this rule first. It now shows their version; make your change again.`)):(h(void 0),M.error(`Someone else deleted this rule first.`)))},z=async(e,t)=>{if(e.target.boardKey!==n.id)return;let r=(await a.refetch()).data?.intakeRoutes??[],i=r.map(e=>e.id),o=i.indexOf(e.id),s=t.flatMap(t=>{let n=q(r,t),a=n[ge(n,t,n.findIndex(t=>t.id===e.id))];return a?[i.indexOf(a.id)]:[]}),l=Math.min(...s);o<0||!(l<o)||await d.mutateAsync([{kind:`reorder`,boardKey:n.id,ids:c(r,i,o,l)}])},B=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:_e(s.data?.boards,n.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[o.isError&&(0,Q.jsx)(b,{variant:`warning`,children:`Rules on other boards that move cards here didn’t load, so they aren’t shown.`}),O&&(0,Q.jsx)(bt,{count:P?.size,into:E||!T?`other boards`:u(n,T)??T,leaving:E,showAll:k(e,n.id)}),ye.filter(e=>e.events.some(e=>F([...q(v,e),...q(S,e)]))).map(t=>(0,Q.jsxs)(`section`,{"aria-label":t.title,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(N,{children:t.title}),t.events.some(K)?s.data&&(0,Q.jsx)(it,{factoryId:e,boardKey:n.id,order:s.data.boards,evaluator:s.data.evaluator}):(0,Q.jsx)(te,{children:`Only cards already on this board; other boards never see them.`})]}),t.events.map(t=>{let r=K(t),a=q(v,t),o=q(S,t).filter(e=>!P||P.has(e.id));return F([...a,...o])?(0,Q.jsx)(St,{event:t,rules:a,board:n,boards:i,phaseOptions:x,canEdit:y,skips:C,footer:r?B:void 0,only:P,incoming:o.length?(0,Q.jsx)(rt,{factoryId:e,rules:o,board:n,boards:i}):void 0,onEdit:(e,t)=>R({rule:e,step:t}),onAdd:()=>R({event:t,step:`conditions`}),onMove:(e,n)=>L(t,e,n),onToggle:(e,t)=>void I([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void I([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&M.success(`Deleted “${e.name}”`)),onUngate:e=>void I([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&M.success(`“${e.name}” now matches outside authors’ pull requests`))},t):null})]},t.title)),f&&(0,Q.jsx)(gt,{factoryId:e,board:n,boards:i,initial:f.rule,initialEvent:f.event,initialStep:f.step,readOnly:!y,saving:d.isPending,error:ee,onSave:e=>void ne(e),onClose:()=>h(void 0)},f.rule?`${f.rule.id}:${f.rule.revision}`:`new-${f.event}`)]})}function At(){let e=s(),t=l()?.boardId??``,{isMobile:r,desktopState:i}=p(),c=r||i===`collapsed`,u=w(e.id,t).data?.board,h=a({breadcrumbs:c&&u?(0,Q.jsxs)(f,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(d,{as:m,to:E(e.id,t),children:u.name}),(0,Q.jsx)(d,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(o,{variant:`settings`,header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(n,{children:[(0,Q.jsx)(n.Title,{children:`Rules`}),(0,Q.jsx)(n.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(B,{factoryProjectId:e.id,label:`Test an issue or pull request`})})]}),...h,children:(0,Q.jsx)(Ot,{factoryId:e.id,boardId:t})})}export{At as BoardRulesPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$n as t,Fr as n,Jn as r,Kn as i,Nr as a,Pr as o,Tr as s,Yn as c,nn as l,qn as u}from"./index-DtRZNzyn.js";import{n as d,t as f}from"./Breadcrumb.es-CVW-e0jJ.js";import{a as p}from"./Sidebar.es-CFLW5bYW.js";import{$n as m,At as h,Dt as ee,St as g,ir as _,jt as v,kt as y,n as b,ni as x,t as S,wt as C}from"./GithubIcon.es-BmZS8JQG.js";import{r as w,t as T}from"./useBoardEditor-Bn11vS5Q.js";import{a as E,i as D,o as O,s as k,t as A}from"./boardConfigPaths-Btimpi_r.js";import{r as j}from"./CompositeItem-CSfZykYZ.js";import{yt as M}from"./useSessionRows-CnLoToLZ.js";import{d as N,n as te}from"./settings-C5r2ThW9-D7BpEINa.js";import{O as P,T as F,k as I,n as L}from"./IconChevronRightMedium.es-BkPdzxSm.js";import{n as R}from"./useBoardCatalog-C-gXjA-g.js";import{c as ne,d as re,l as z,n as B,r as ie,s as V,t as H,u as U}from"./useRowDrag-0taus7Yi.js";import{a as ae,d as oe,f as se,g as W,o as ce,r as G,s as le}from"./useIntakeRoutes-OObHoZos.js";import{C as ue,E as de,_ as fe,a as pe,c as K,d as me,f as he,g as ge,i as _e,l as q,m as ve,n as ye,o as be,s as xe,u as J,w as Se}from"./ruleLanes-zac0HQwn.js";import{t as Y}from"./createLucideIcon-BHFyd0LL.js";import{a as Ce,t as we}from"./BoardIcons-BZwAAPO8.js";import{t as Te}from"./input-DqReKX0A-ScC7s6sY.js";import{n as Ee,t as De}from"./RadioGroup.es-BfW3ErPZ.js";import{n as Oe,t as ke}from"./ConditionRows-BXZDW3lX.js";import{i as X,k as Ae}from"./TabsRoot-DNjGHnQQ.js";import{E as je}from"./combobox-parts-DhYtFSRV-BZqyW5dv.js";var Me={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Me.node;var Ne=Y(Me),Pe={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Pe.node;var Fe=Y(Pe),Ie={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ie.node;var Le=Y(Ie),Re={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Re.node;var ze=Y(Re),Be={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Be.node;var Ve=Y(Be),He={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};He.node;var Ue=Y(He),We={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};We.node;var Ge=Y(We),Ke={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};Ke.node;var qe=Y(Ke),Je={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Je.node;var Ye=Y(Je),Xe={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Xe.node;var Ze=Y(Xe),Qe={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Qe.node;var $e=Y(Qe),Z=e(I(),1),Q=P();function et({when:e,options:t,everything:n}){let r=ue(e,t);return!e||!r?(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:n}):(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:r.parts.map((t,n)=>{let i=e.conditions[n],a=i&&`conditions`in i?i:void 0;return(0,Q.jsxs)(`span`,{className:`contents`,children:[n>0&&(0,Q.jsx)(L,{as:`span`,variant:`meta`,tone:`muted`,children:r.join}),a?(0,Q.jsxs)(`span`,{className:`border-border inline-flex max-w-full items-center gap-1 rounded-md border border-dashed px-1 py-0.5`,children:[(0,Q.jsx)(L,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Q.jsx)(tt,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Q.jsx)(tt,{children:t})]},n)})})}function tt({children:e}){return(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}function nt({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let a=e.find(e=>e.id===n);if(!a)return(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let o=r??a.initialPhase,s=a.phases.find(e=>e.id===o);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[a.id!==t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`truncate`,children:i(a)}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),s&&(0,Q.jsx)(we,{stage:s.id,kind:Ce(a.id,s.kind),decorative:!0}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`truncate`,children:u(a,o)??o})]})}function rt({factoryId:e,rules:t,board:n,boards:a}){return(0,Q.jsxs)(`section`,{"aria-label":`From other boards`,className:`border-border mt-3 flex flex-col gap-1.5 border-t pt-3`,children:[(0,Q.jsxs)(L,{as:`h4`,variant:`meta`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(qe,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),`From other boards`]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(t=>{let o=a.find(e=>e.id===t.target.boardKey);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(m,{to:k(e,t.target.boardKey),"aria-label":`${t.name}, on ${o?i(o):t.target.boardKey}`,className:F(`group flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,!t.enabled&&`opacity-50`),children:[(0,Q.jsxs)(`span`,{className:`border-border group-hover:border-border-hover flex w-full min-w-0 flex-col gap-1 rounded-lg border border-dashed px-3 py-2 sm:flex-1`,children:[(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:o?i(o):`${t.target.boardKey} (not installed)`}),(0,Q.jsx)(et,{when:t.when,options:r(o),everything:`Every card`})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`border-border-strong h-0 w-8 shrink-0 border-t border-dashed`}),(0,Q.jsx)(Ne,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex w-44 shrink-0 items-center px-3 py-2`,children:(0,Q.jsx)(nt,{boards:a,ownBoard:n.id,boardKey:n.id,phaseKey:t.target.phaseKey})})]}),!t.enabled&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:`Off`})]})},t.id)})})]})}function it({factoryId:e,boardKey:t,order:n,evaluator:r}){let i=n.some(e=>e.boardKey===t);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r===`route-list`?(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:`Intake still files new issues and pull requests by the old route list, not by board.`}):i?(0,Q.jsxs)(`ol`,{"aria-label":`Intake order`,className:`flex flex-wrap items-center gap-1`,children:[n.map(n=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`li`,{children:n.boardKey===t?(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`ink`,"aria-current":`step`,className:`bg-surface3 rounded-md px-2 py-0.5 font-medium`,children:n.name}):(0,Q.jsx)(m,{to:k(e,n.boardKey),className:`text-muted-foreground hover:text-foreground rounded-md px-2 py-0.5`,children:(0,Q.jsx)(L,{as:`span`,variant:`caption`,children:n.name})})}),(0,Q.jsx)(Le,{"aria-hidden":!0,className:`text-muted-foreground size-icon-xs shrink-0`})]},n.boardKey)),(0,Q.jsx)(`li`,{children:(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`px-2 py-0.5`,children:`Not routed`})})]}):(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:`Not in the intake order: new issues and pull requests never reach these rules.`}),(0,Q.jsxs)(m,{to:O(e,t,A),className:`text-muted-foreground hover:text-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(Ge,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`underline decoration-dotted underline-offset-2`,children:`Reorder`})]})]})}var at=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,ot=`border-border-focus bg-fill-hover`,st=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function ct({selected:e,disabled:t,onClick:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,onClick:n,className:F(at,`disabled:opacity-50`,e?ot:st),children:r})}function lt({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`label`,{onClick:r,className:F(at,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?ot:st,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsx)(Ee,{value:e,disabled:n,"aria-labelledby":a,className:`sr-only`}),(0,Q.jsx)(`span`,{id:a,className:`flex min-w-0 items-start gap-3`,children:i})]})}function ut(){return(0,Q.jsx)(Ae,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(S,{"aria-hidden":`true`}),children:`GitHub only`})}var dt=120,ft=W(le),$=[{id:`trigger`,title:`Trigger`,question:`What should this rule listen for?`},{id:`conditions`,title:`Only if`,question:`Which items should it apply to?`},{id:`action`,title:`Move to`,question:`Where should it go?`},{id:`review`,title:`Review`,question:`Name and check your rule`}];function pt(e,t){let n=e?.phases??[];return t?n.filter(e=>e.kind!==`terminal`):n}function mt(e,t){if(t){let e=ft.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return se(e,t)??void 0}function ht(e,t,n){let r=`When ${e.map(e=>J(e).label.toLowerCase()).join(` or `)}${t?`, ${Se(t).charAt(0).toLowerCase()}${Se(t).slice(1)}`:``}, move to ${n}`;return r.length>dt?`${r.slice(0,119)}…`:r}function gt({factoryId:e,board:t,boards:n,initial:a,initialEvent:o,initialStep:s,readOnly:c,saving:l,error:d,onSave:f,onClose:p}){let m=Oe(e),[_,S]=(0,Z.useState)(()=>a?.on??(o?[o]:[])),[w,T]=(0,Z.useState)(()=>a?.when??null),[E,D]=(0,Z.useState)(()=>(a?.when?.conditions.length??0)>0),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(()=>a?.target.moveToBoardKey??t.id),[M,N]=(0,Z.useState)(()=>a?a.target.phaseKey??void 0:void 0),[te,P]=(0,Z.useState)(()=>a?.name),[I,R]=(0,Z.useState)(s),[ne,re]=(0,Z.useState)(0),z=ve(_),B=n.find(e=>e.id===A),ie=pt(B,z),V=ie.find(e=>e.id===(M??B?.initialPhase)),H=E?w:null,U=_.length?mt(_,H):void 0,ae=V&&B?`${i(B)} › ${u(B,V.id)}`:``,se=te??(V?ht(_,H,ae):``),W={trigger:_.length>0,conditions:_.length>0&&!(E&&O)&&!U,action:V!==void 0,review:se.trim().length>0},ce=!c&&W.trigger&&W.conditions&&W.action&&W.review,G=$.findIndex(e=>e.id===I),le=$[G]??$[0],ue=e=>{S(e),ve(e)&&A!==t.id&&(j(t.id),N(void 0))},fe=()=>{ce&&V&&f({name:se.trim(),on:_,when:H,target:{phaseKey:V.id,moveToBoardKey:A===t.id?null:A}})},pe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};T(H===null?{operator:`AND`,conditions:[e]}:H.operator===`AND`?{...H,conditions:[...H.conditions,e]}:{operator:`AND`,conditions:[H,e]}),D(!0),k(!1),re(e=>e+1)},K={trigger:_.length?_.map(e=>J(e).label).join(`, `):void 0,conditions:_.length?Se(H,r(t)):void 0,action:V?(0,Q.jsx)(nt,{boards:n,ownBoard:t.id,boardKey:A,phaseKey:V.id}):void 0,review:void 0};return(0,Q.jsx)(g,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(ee,{size:`xl`,children:[(0,Q.jsx)(h,{children:(0,Q.jsx)(v,{children:c?`Rule`:a?`Edit rule`:`Add rule`})}),(0,Q.jsx)(C,{children:(0,Q.jsxs)(`div`,{className:`grid min-h-105 grid-cols-1 gap-6 sm:grid-cols-[12rem_1fr]`,children:[(0,Q.jsx)(`nav`,{"aria-label":`Rule steps`,className:`sm:border-border flex gap-1 overflow-x-auto sm:flex-col sm:border-r sm:pr-4`,children:$.map((e,t)=>{let n=t===0||$.slice(0,t).every(e=>W[e.id]),r=W[e.id]&&e.id!==`review`;return(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":I===e.id?`step`:void 0,onClick:()=>R(e.id),className:F(`flex shrink-0 items-start gap-2.5 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-40`,I===e.id?`bg-fill-hover`:`hover:bg-fill-subtle`),children:[(0,Q.jsx)(L,{as:`span`,variant:`meta`,className:F(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border`,r?`border-transparent bg-fill-inverse text-background`:`border-border-strong`),children:r?(0,Q.jsx)(Fe,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),K[e.id]&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:K[e.id]})]})]},e.id)})}),(0,Q.jsxs)(`section`,{"aria-label":le.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsx)(L,{as:`h3`,variant:`heading`,children:le.question}),I===`trigger`&&(0,Q.jsx)(yt,{value:_,disabled:c,onChange:ue}),I===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(De,{"aria-label":`Which ones`,value:E?`matching`:`every`,disabled:c,onValueChange:e=>{D(e===`matching`),k(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Q.jsx)(lt,{value:`every`,selected:!E,disabled:c,children:(0,Q.jsx)(_t,{title:z?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(lt,{value:`matching`,selected:E,disabled:c,children:(0,Q.jsx)(_t,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),E&&(0,Q.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Q.jsx)(ke,{label:`Conditions`,rule:w,facts:de(_),options:{...r(t),"source.repository":m},onChange:(e,t)=>{T(e),k(t)}},ne)}),U&&(0,Q.jsx)(b,{variant:`warning`,children:U}),!a?.outsiderPullRequestsGated&&oe(_,H)&&(0,Q.jsx)(b,{variant:`info`,children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{children:`Also matches pull requests from outside authors.`}),!c&&(0,Q.jsx)(`button`,{type:`button`,onClick:pe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),I===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[z?(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:`An item with no card yet can only be filed on this board.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Q.jsx)(De,{"aria-label":`Board`,value:A,disabled:c,onValueChange:e=>{typeof e==`string`&&e!==A&&(j(e),N(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:n.map(e=>(0,Q.jsx)(lt,{value:e.id,selected:e.id===A,disabled:c,children:(0,Q.jsxs)(L,{as:`span`,variant:`label`,tone:`ink`,children:[i(e),e.id===t.id?` (this board)`:``]})},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Q.jsx)(De,{"aria-label":`Phase`,value:V?.id??null,disabled:c,onValueChange:e=>typeof e==`string`&&N(e),className:`grid-cols-1 sm:grid-cols-2`,children:B&&ie.map(e=>(0,Q.jsx)(lt,{value:e.id,selected:e.id===V?.id,disabled:c,onClick:()=>{N(e.id),R(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(we,{stage:e.id,kind:Ce(B.id,e.kind),decorative:!0}),(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,children:u(B,e.id)})]})},e.id))})]})]}),I===`review`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Q.jsx)(Te,{value:se,maxLength:dt,disabled:c,onChange:e=>P(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,className:`mb-3 block`,children:`This rule reads as`}),(0,Q.jsxs)(`ol`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(vt,{label:`When`,children:K.trigger}),(0,Q.jsx)(vt,{label:`Only if`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Ve,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),K.conditions]})}),(0,Q.jsx)(vt,{label:`Then`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Q.jsx)(Ne,{className:`size-icon-sm`,"aria-hidden":!0}),` `,K.action]})})]})]})]}),d&&(0,Q.jsx)(b,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(y,{children:[(0,Q.jsx)(x,{variant:`ghost`,onClick:p,children:c?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),G>0&&(0,Q.jsx)(x,{variant:`default`,onClick:()=>R($[G-1].id),children:`Back`}),!c&&(I===`review`||a&&ce?(0,Q.jsx)(x,{variant:`primary`,disabled:!ce||l,onClick:fe,children:l?`Saving…`:a?`Save rule`:`Create rule`}):(0,Q.jsx)(x,{variant:`primary`,disabled:!W[I],onClick:()=>R($[G+1]?.id??`review`),children:`Continue`}))]})]})})}function _t({title:e,hint:t}){return(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function vt({label:e,children:t}){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Q.jsx)(L,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Q.jsx)(L,{as:`span`,variant:`body-sm`,children:t})]})}function yt({value:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.includes(`work_item.created`)&&(0,Q.jsxs)(b,{variant:`info`,children:[`Also listens on “`,J(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),ye.map(r=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:r.title}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.events.map(r=>{let i=J(r),a=i.icon,o=e.includes(r);return(0,Q.jsxs)(ct,{selected:o,disabled:t||o&&e.length===1,onClick:()=>n(o?e.filter(e=>e!==r):[...e,r]),children:[(0,Q.jsx)(a,{className:`text-badge-amber-indicator mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(_t,{title:i.label,hint:i.description}),i.githubOnly&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(ut,{})})]},r)})})]},r.title))]})}function bt({count:e,into:t,leaving:n,showAll:r}){let i=n?`sending cards to ${t}`:`moving cards into ${t}`;return(0,Q.jsxs)(`div`,{className:`border-border flex items-center gap-2 rounded-lg border px-3 py-2`,children:[(0,Q.jsx)(Ue,{className:`size-icon-md text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`p`,variant:`body-sm`,tone:e===void 0?`muted`:`ink`,className:`flex-1`,children:e===void 0?`Couldn’t pick out the rules ${i}, so every rule is shown.`:e===0?`No rule is ${i}.`:`Only the ${e===1?`rule`:`${e} rules`} ${i}.`}),(0,Q.jsx)(x,{size:`sm`,variant:`ghost`,render:(0,Q.jsx)(m,{to:r}),children:`Show all`})]})}var xt=F(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:-top-1 data-[drop=before]:before:block data-[drop=after]:before:-bottom-1 data-[drop=after]:before:block`);function St({event:e,rules:t,board:n,boards:r,phaseOptions:a,canEdit:o,skips:s,footer:c,incoming:l,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:ee,onUngate:g}){let _=J(e),v=_.icon,y=pe(t,e),b=K(e),S=be(e),C=H({min:0,max:t.length-1,onDrop:m}),w=o&&t.length>1&&!d,T=c??(t.length?`Otherwise, the card stays where it is`:l?`No rules: this board’s cards stay where they are`:`No rules: the card stays where it is`);return(0,Q.jsxs)(`section`,{"aria-label":_.label,className:F(`flex flex-col gap-3 rounded-xl border border-border bg-card p-4`,!t.length&&!l&&`opacity-60 focus-within:opacity-100 hover:opacity-100`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(v,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`h3`,variant:`label`,tone:`ink`,children:_.label}),_.githubOnly&&(0,Q.jsx)(ut,{})]}),_.description&&(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:_.description})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`${_.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((c,l)=>{if(d&&!d.has(c.id))return null;let p=ge(t,e,l),v=p>=0,T=!c.enabled||v,E=C.drag?.from===l,D=s?.get(c.id),O=r.find(e=>e.id===(c.target.moveToBoardKey??c.target.boardKey)),k=!he(c.name,[_.label,Se(c.when,a),O&&i(O),u(O,c.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":c.name,"data-drop":C.dropAt(l),style:E?{transform:`translateY(${C.drag?.offset??0}px)`}:void 0,onPointerDown:w?e=>C.onPointerDown(e,l):void 0,className:F(`group/rule flex flex-col`,xt,E&&`z-10 opacity-90`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 sm:flex-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Edit conditions of ${c.name}`,onClick:()=>f(c,`conditions`),onKeyDown:w?e=>C.onKeyDown(e,l):void 0,className:F(`flex w-full items-start gap-2.5 rounded-lg border bg-fill-subtle px-3 py-2 text-left transition-colors hover:border-border-hover`,T?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Q.jsxs)(L,{as:`span`,variant:`meta`,tone:`muted`,className:`bg-fill mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full tabular-nums`,children:[(0,Q.jsx)(`span`,{className:F(w&&`pointer-fine:group-hover/rule:hidden`,E&&`hidden`),children:l+1}),w&&(0,Q.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:F(`hidden cursor-grab touch-none pointer-fine:group-hover/rule:flex`,E&&`flex`),children:(0,Q.jsx)(ne,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[k&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:c.name}),(0,Q.jsx)(et,{when:c.when,options:a,everything:S})]})]}),w&&(0,Q.jsxs)(`div`,{className:`border-border bg-card absolute top-0 right-2 flex -translate-y-1/2 rounded-md border shadow-sm transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/rule:opacity-100 pointer-fine:group-hover/rule:opacity-100`,children:[(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:l===0,onClick:()=>m(l,l-1),children:(0,Q.jsx)(U,{})}),(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:l===t.length-1,onClick:()=>m(l,l+1),children:(0,Q.jsx)(re,{})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 sm:shrink-0`,children:[(0,Q.jsxs)(`div`,{className:F(`flex min-w-0 items-center`,T&&`opacity-40`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:F(`h-px w-8 shrink-0`,T?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Q.jsx)(Ne,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit where ${c.name} moves the card`,onClick:()=>f(c,`action`),className:`border-border bg-fill-subtle hover:border-border-hover flex w-44 shrink-0 rounded-lg border px-3 py-2 text-left`,children:(0,Q.jsx)(nt,{boards:r,ownBoard:n.id,boardKey:c.target.moveToBoardKey??c.target.boardKey,phaseKey:c.target.phaseKey})})]}),o&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(je,{"aria-label":`${c.name} on`,checked:c.enabled,onCheckedChange:e=>h(c,e)}),(0,Q.jsxs)(X,{children:[(0,Q.jsx)(X.Trigger,{render:(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${c.name}`,children:(0,Q.jsx)(ze,{})})}),(0,Q.jsx)(X.Content,{align:`end`,children:(0,Q.jsxs)(X.Item,{variant:`destructive`,onClick:()=>ee(c),children:[(0,Q.jsx)(Ze,{}),`Delete rule`]})})]})]})]})]}),T&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,p+1,` above matches `,S.toLowerCase(),`.`]}):`Off, skipped`}),c.problems.map(e=>(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),D&&(0,Q.jsx)(wt,{skips:D}),fe(c,e)&&(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[`Skips outside authors’ pull requests (older rule).`,o&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>g(c),className:`underline`,children:`Let outside authors match`})]}),me(c,e)&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),b&&xe(c)&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:J(`work_item.created`).label}),l!==y&&!d&&(0,Q.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-7 items-center pl-5.5`,children:[(0,Q.jsx)(`span`,{className:`bg-border-strong h-full w-px`}),(0,Q.jsx)(L,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},c.id)}),!d&&(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[y<0&&(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`flex flex-1 items-center gap-2.5 px-3 py-1.5`,children:[(0,Q.jsx)(z,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),T]}),o&&(0,Q.jsx)(x,{variant:`ghost`,size:`sm`,icon:(0,Q.jsx)(Ye,{}),onClick:p,children:`Add rule`})]})]}),l]})]})}function Ct(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function wt({skips:e}){let{count:t,latest:n}=e;return(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[`Skipped `,t===1?`once`:`${t} times`,` in the last 30 days: `,Ct(n.reason),`.`]}),n.url?(0,Q.jsxs)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`Latest: `,n.title]}):(0,Q.jsxs)(`span`,{children:[`Latest: `,n.title]})]})}var Tt=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function Et(e){return e instanceof T&&e.code!==void 0&&Tt.has(e.code)}function Dt(e){return Et(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function Ot({factoryId:e,boardId:t}){let n=R(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(j,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(b,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Q.jsx)(kt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Q.jsx)(b,{variant:`warning`,children:`This board isn’t installed.`})}function kt({factoryId:e,board:n,boards:i}){let a=G(e,n.id),o=ce(e),s=ie(e),l=V(e),d=ae(e),[f,p]=(0,Z.useState)(),m=(0,Z.useRef)(void 0),h=e=>{m.current=e,p(e)},[ee,g]=(0,Z.useState)(),v=a.data?.intakeRoutes??[],y=a.data?.canEdit??!1,x=r(n),S=(o.data?.intakeRoutes??[]).filter(e=>e.target.moveToBoardKey===n.id&&e.target.boardKey!==n.id),C=new Map(l.data?.skipped.map(e=>[e.routeId,e])),[w]=_(),T=w.get(`into`)??void 0,E=w.has(D),O=E||T!==void 0,A=O&&o.data?t(o.data.intakeRoutes,{key:n.id,initialPhase:n.initialPhase}):void 0,P=A&&new Set((E?A.leaving:A.into.get(T??``)??[]).map(e=>e.id)),F=e=>!P||e.some(e=>P.has(e.id));if(a.isPending||O&&o.isPending)return(0,Q.jsx)(j,{className:`h-64 w-full`});if(a.isError)return(0,Q.jsx)(b,{variant:`destructive`,children:`This board’s rules didn’t load.`});let I=e=>d.mutateAsync(e).catch(e=>M.error(Dt(e))),L=(e,t,r)=>{let i=q(v,e).map(e=>e.id);I([{kind:`reorder`,boardKey:n.id,ids:c(v,i,t,r)}])},R=e=>{g(void 0),h(e)},ne=async e=>{let t=m.current,r=t?.rule,i=()=>t!==void 0&&m.current===t;g(void 0);try{if(r)await d.mutateAsync([{kind:`update`,id:r.id,patch:{name:e.name,on:e.on,when:e.when,target:{boardKey:r.target.boardKey,...e.target,joinClosedIssue:r.target.joinClosedIssue},expectedRevision:r.revision}}]);else{let[t]=await d.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:n.id,...e.target}}}]);i()&&h(void 0),t&&await z(t,e.on).catch(e=>M.error(Dt(e)));return}i()&&h(void 0)}catch(e){if(!i())return;if(r&&Et(e))return re(r);g(Dt(e))}},re=async e=>{let t=m.current,n=(await a.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&m.current===t&&(n?(h({...t,rule:n}),g(`Someone else changed this rule first. It now shows their version; make your change again.`)):(h(void 0),M.error(`Someone else deleted this rule first.`)))},z=async(e,t)=>{if(e.target.boardKey!==n.id)return;let r=(await a.refetch()).data?.intakeRoutes??[],i=r.map(e=>e.id),o=i.indexOf(e.id),s=t.flatMap(t=>{let n=q(r,t),a=n[ge(n,t,n.findIndex(t=>t.id===e.id))];return a?[i.indexOf(a.id)]:[]}),l=Math.min(...s);o<0||!(l<o)||await d.mutateAsync([{kind:`reorder`,boardKey:n.id,ids:c(r,i,o,l)}])},B=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:_e(s.data?.boards,n.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[o.isError&&(0,Q.jsx)(b,{variant:`warning`,children:`Rules on other boards that move cards here didn’t load, so they aren’t shown.`}),O&&(0,Q.jsx)(bt,{count:P?.size,into:E||!T?`other boards`:u(n,T)??T,leaving:E,showAll:k(e,n.id)}),ye.filter(e=>e.events.some(e=>F([...q(v,e),...q(S,e)]))).map(t=>(0,Q.jsxs)(`section`,{"aria-label":t.title,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(N,{children:t.title}),t.events.some(K)?s.data&&(0,Q.jsx)(it,{factoryId:e,boardKey:n.id,order:s.data.boards,evaluator:s.data.evaluator}):(0,Q.jsx)(te,{children:`Only cards already on this board; other boards never see them.`})]}),t.events.map(t=>{let r=K(t),a=q(v,t),o=q(S,t).filter(e=>!P||P.has(e.id));return F([...a,...o])?(0,Q.jsx)(St,{event:t,rules:a,board:n,boards:i,phaseOptions:x,canEdit:y,skips:C,footer:r?B:void 0,only:P,incoming:o.length?(0,Q.jsx)(rt,{factoryId:e,rules:o,board:n,boards:i}):void 0,onEdit:(e,t)=>R({rule:e,step:t}),onAdd:()=>R({event:t,step:`conditions`}),onMove:(e,n)=>L(t,e,n),onToggle:(e,t)=>void I([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void I([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&M.success(`Deleted “${e.name}”`)),onUngate:e=>void I([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&M.success(`“${e.name}” now matches outside authors’ pull requests`))},t):null})]},t.title)),f&&(0,Q.jsx)(gt,{factoryId:e,board:n,boards:i,initial:f.rule,initialEvent:f.event,initialStep:f.step,readOnly:!y,saving:d.isPending,error:ee,onSave:e=>void ne(e),onClose:()=>h(void 0)},f.rule?`${f.rule.id}:${f.rule.revision}`:`new-${f.event}`)]})}function At(){let e=s(),t=l()?.boardId??``,{isMobile:r,desktopState:i}=p(),c=r||i===`collapsed`,u=w(e.id,t).data?.board,h=a({breadcrumbs:c&&u?(0,Q.jsxs)(f,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(d,{as:m,to:E(e.id,t),children:u.name}),(0,Q.jsx)(d,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(o,{variant:`settings`,header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(n,{children:[(0,Q.jsx)(n.Title,{children:`Rules`}),(0,Q.jsx)(n.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(B,{factoryProjectId:e.id,label:`Test an issue or pull request`})})]}),...h,children:(0,Q.jsx)(Ot,{factoryId:e.id,boardId:t})})}export{At as BoardRulesPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ei as t,Jt as n,Mi as r,qt as i}from"./GithubIcon.es-B1lB1Q-8.js";import{O as a,T as o,k as s,o as c}from"./IconChevronRightMedium.es-BjSIsine.js";import{r as l}from"./CompositeItem-CD2x3KaL.js";import{t as u}from"./popup-anchor.es-B4jCSTe8.js";var d=e(s(),1),f=a(),p=e=>(0,f.jsx)(`svg`,{width:`19.125`,height:`18`,viewBox:`-1.0625 -1 19.125 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,f.jsx)(`path`,{d:`M5.25684 12.6387L10.4003 3.36133H11.7432L6.5997 12.6387H5.25684Z`,fill:`currentColor`})}),m=({children:e,label:t,className:n,listClassName:r})=>(0,f.jsx)(`nav`,{"aria-label":t,className:n,children:(0,f.jsx)(`ol`,{className:o(`flex items-center gap-0.5`,r),children:e})}),h=e=>(0,f.jsx)(l,{className:`h-3 w-24`,...e}),g=({className:e,as:a,to:s,href:l,isCurrent:m,action:g,switcher:_,icon:v,isLoading:y,children:b,...x})=>{let S=a||`span`,C=!(!_||!m&&(s||l)),w=d.useRef(null);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`li`,{ref:w,className:o(`group flex h-control-sm min-w-0 items-center`,m?`shrink`:`shrink-0`,C&&`relative rounded-full has-[[data-slot=crumb-switcher]_[data-popup-open]]:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:hover:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:active:bg-fill`),children:[(0,f.jsxs)(S,{"aria-current":m?`page`:void 0,className:o(`inline-flex min-w-0 items-center gap-2 overflow-hidden rounded-full px-[.9em]`,t.sm,c,m?`max-w-xs cursor-default text-foreground`:C?o(n,`max-w-48`):o(i,`max-w-48 cursor-pointer hover:bg-fill-subtle active:bg-fill`),e),to:s,href:l,...x,children:[v&&(0,f.jsx)(r,{className:o(`ml-[-.3em] shrink-0 opacity-50 group-hover:opacity-100`,`transition-opacity duration-normal ease-out-custom`),children:v}),y?(0,f.jsx)(h,{}):(0,f.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:b})]}),_&&(0,f.jsx)(`span`,{"data-slot":`crumb-switcher`,className:o(`-ml-1 flex h-control-sm shrink-0 items-center`,C&&`[&_button]:bg-transparent! [&_button:enabled]:after:absolute [&_button:enabled]:after:inset-0 [&_button:enabled]:after:rounded-full`),children:(0,f.jsx)(u,{value:w,children:_})}),g&&(0,f.jsx)(`span`,{className:`-ml-1 flex h-control-sm shrink-0 items-center`,children:g})]}),!m&&(0,f.jsx)(`li`,{role:`separator`,className:`flex h-full items-center`,children:(0,f.jsx)(r,{className:`text-placeholder`,children:(0,f.jsx)(p,{})})})]})};export{g as n,m as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ei as t,Jt as n,Mi as r,qt as i}from"./GithubIcon.es-BmZS8JQG.js";import{O as a,T as o,k as s,o as c}from"./IconChevronRightMedium.es-BkPdzxSm.js";import{r as l}from"./CompositeItem-CSfZykYZ.js";import{t as u}from"./popup-anchor.es-g9MI9mVW.js";var d=e(s(),1),f=a(),p=e=>(0,f.jsx)(`svg`,{width:`19.125`,height:`18`,viewBox:`-1.0625 -1 19.125 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,f.jsx)(`path`,{d:`M5.25684 12.6387L10.4003 3.36133H11.7432L6.5997 12.6387H5.25684Z`,fill:`currentColor`})}),m=({children:e,label:t,className:n,listClassName:r})=>(0,f.jsx)(`nav`,{"aria-label":t,className:n,children:(0,f.jsx)(`ol`,{className:o(`flex items-center gap-0.5`,r),children:e})}),h=e=>(0,f.jsx)(l,{className:`h-3 w-24`,...e}),g=({className:e,as:a,to:s,href:l,isCurrent:m,action:g,switcher:_,icon:v,isLoading:y,children:b,...x})=>{let S=a||`span`,C=!(!_||!m&&(s||l)),w=d.useRef(null);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`li`,{ref:w,className:o(`group flex h-control-sm min-w-0 items-center`,m?`shrink`:`shrink-0`,C&&`relative rounded-full has-[[data-slot=crumb-switcher]_[data-popup-open]]:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:hover:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:active:bg-fill`),children:[(0,f.jsxs)(S,{"aria-current":m?`page`:void 0,className:o(`inline-flex min-w-0 items-center gap-2 overflow-hidden rounded-full px-[.9em]`,t.sm,c,m?`max-w-xs cursor-default text-foreground`:C?o(n,`max-w-48`):o(i,`max-w-48 cursor-pointer hover:bg-fill-subtle active:bg-fill`),e),to:s,href:l,...x,children:[v&&(0,f.jsx)(r,{className:o(`ml-[-.3em] shrink-0 opacity-50 group-hover:opacity-100`,`transition-opacity duration-normal ease-out-custom`),children:v}),y?(0,f.jsx)(h,{}):(0,f.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:b})]}),_&&(0,f.jsx)(`span`,{"data-slot":`crumb-switcher`,className:o(`-ml-1 flex h-control-sm shrink-0 items-center`,C&&`[&_button]:bg-transparent! [&_button:enabled]:after:absolute [&_button:enabled]:after:inset-0 [&_button:enabled]:after:rounded-full`),children:(0,f.jsx)(u,{value:w,children:_})}),g&&(0,f.jsx)(`span`,{className:`-ml-1 flex h-control-sm shrink-0 items-center`,children:g})]}),!m&&(0,f.jsx)(`li`,{role:`separator`,className:`flex h-full items-center`,children:(0,f.jsx)(r,{className:`text-subtle-foreground`,children:(0,f.jsx)(p,{})})})]})};export{g as n,m as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Is as t,Ls as n,Si as r,js as i,zs as a}from"./GithubIcon.es-BmZS8JQG.js";import{O as o,T as s,c,k as l}from"./IconChevronRightMedium.es-BkPdzxSm.js";var u=e(l(),1),d=o(),f=s(`motion-safe:not-disabled:not-aria-disabled:hover:[&_[data-emphasis=grow-y]]:scale-y-125`,`motion-safe:not-disabled:not-aria-disabled:hover:[&_[data-emphasis=grow-x]]:scale-x-125`,`motion-safe:not-disabled:not-aria-disabled:hover:[&_[data-emphasis=pop]]:scale-110`,`motion-safe:not-disabled:not-aria-disabled:focus-visible:[&_[data-emphasis=grow-y]]:scale-y-125`,`motion-safe:not-disabled:not-aria-disabled:focus-visible:[&_[data-emphasis=grow-x]]:scale-x-125`,`motion-safe:not-disabled:not-aria-disabled:focus-visible:[&_[data-emphasis=pop]]:scale-110`),p=a(s(t,`rounded-xl transition-all duration-normal ease-out-custom motion-reduce:transition-none`),{variants:{elevation:{flat:`shadow-none`,raised:``},interactive:{true:s(n,r,f,`cursor-pointer active:scale-99 aria-[current=true]:[--surface-rim:var(--border-focus)]`),false:``}},compoundVariants:[{elevation:`flat`,interactive:!0,class:s(c,`aria-[current=true]:outline-1 aria-[current=true]:-outline-offset-1 aria-[current=true]:outline-border-focus aria-[current=true]:outline-solid`)}],defaultVariants:{elevation:`raised`,interactive:!1}}),m=u.forwardRef(({className:e,elevation:t,interactive:n,as:r,...i},a)=>{let o=r||(n?`button`:`div`);return(0,d.jsx)(o,{ref:a,type:o===`button`?`button`:void 0,className:s(p({elevation:t,interactive:n}),e),...i})});m.displayName=`Card`;function h({className:e,elevation:t,LinkComponent:n=`a`,...r}){return(0,d.jsx)(n,{className:s(p({elevation:t,interactive:!0}),e),...r})}var g=u.forwardRef(({className:e,...t},n)=>(0,d.jsx)(`div`,{ref:n,className:s(`flex flex-col space-y-1.5 px-3 py-1`,e),...t}));g.displayName=`CardHeader`;var _=u.forwardRef(({className:e,...t},n)=>(0,d.jsx)(`h3`,{ref:n,className:s(`text-subheading text-foreground`,e),...t}));_.displayName=`CardTitle`;var v=u.forwardRef(({className:e,...t},n)=>(0,d.jsx)(`p`,{ref:n,className:s(`text-caption text-muted-foreground`,e),...t}));v.displayName=`CardDescription`;var y=a(``,{variants:{density:{default:`p-3`,compact:`p-2`}},defaultVariants:{density:`default`}}),b=u.forwardRef(({className:e,density:t,...n},r)=>(0,d.jsx)(`div`,{ref:r,className:s(y({density:t}),e),...n}));b.displayName=`CardContent`;var x=u.forwardRef(({className:e,...t},n)=>(0,d.jsx)(`div`,{ref:n,className:s(`flex items-center p-3 pt-0`,e),...t}));x.displayName=`CardFooter`;var S=u.forwardRef(({className:e,as:t=`div`,...n},r)=>(0,d.jsx)(t,{ref:r,className:s(i,`overflow-hidden rounded-lg bg-nested px-3 *:py-3 [&>*+*]:border-t [&>*+*]:border-separator`,e),...n}));S.displayName=`CardInset`;export{b as n,h as r,m as t};