@tickernelz/wardmote-ui 2026.1118.1 → 2026.1118.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/assets/{AdapterManager-1binbhYj.js → AdapterManager-DvntZ2AW.js} +1 -1
  2. package/dist/assets/{AdvancedToolsRoute-DUyXR4Xj.js → AdvancedToolsRoute-CUW8D9Ux.js} +1 -1
  3. package/dist/assets/{AgentActionButtons-DSmnGirw.js → AgentActionButtons-CQLGCtfu.js} +1 -1
  4. package/dist/assets/{AgentChat-Dj952aW1.js → AgentChat-DCwwZA2b.js} +1 -1
  5. package/dist/assets/{AgentChats-Fv5j4CM9.js → AgentChats-DMMLdo-o.js} +1 -1
  6. package/dist/assets/{AgentDetail-CffT38lI.js → AgentDetail-BMVWOVp-.js} +1 -1
  7. package/dist/assets/{AgentTodoCard-De5ZJbUa.js → AgentTodoCard-C4BfJg4x.js} +1 -1
  8. package/dist/assets/{Agents-CDDoQ4Ds.js → Agents-C0IDC6KD.js} +3 -3
  9. package/dist/assets/{AppDetail-DnTOxWEY.js → AppDetail-DzEGsx94.js} +1 -1
  10. package/dist/assets/{AppNotConnected-CgnmB3mH.js → AppNotConnected-BVL32B49.js} +1 -1
  11. package/dist/assets/{ApprovalCard-D6X8gzHU.js → ApprovalCard-DCQ49PuW.js} +1 -1
  12. package/dist/assets/{ApprovalDetail-CWxiqPs6.js → ApprovalDetail-B0J70llD.js} +1 -1
  13. package/dist/assets/{ApprovalPayload-DFsO21LC.js → ApprovalPayload-8lqBw-XQ.js} +1 -1
  14. package/dist/assets/{Approvals-BW3osPe0.js → Approvals-BkiVjx0M.js} +1 -1
  15. package/dist/assets/{AppsReview-4g3PeYWn.js → AppsReview-CeXp22cE.js} +1 -1
  16. package/dist/assets/{ArtifactCard-BoIqK207.js → ArtifactCard-BV82tDLI.js} +1 -1
  17. package/dist/assets/{Artifacts-DDdlgUkk.js → Artifacts-CL5ZmZ3m.js} +1 -1
  18. package/dist/assets/{AssistantConnection-B7yxIifb.js → AssistantConnection-C5rmoEsm.js} +1 -1
  19. package/dist/assets/{AttentionInteractionResolver-BdcCqDXe.js → AttentionInteractionResolver-DxZpuIIF.js} +1 -1
  20. package/dist/assets/{AuditHub-CI0zjHie.js → AuditHub-DDPFGvHG.js} +1 -1
  21. package/dist/assets/{BoardChat--69z_C0h.js → BoardChat-DlaNGzcQ.js} +1 -1
  22. package/dist/assets/{BootstrapSetupUxLab-UIxdNUcO.js → BootstrapSetupUxLab-B2tOIzXd.js} +1 -1
  23. package/dist/assets/{Browse-VPYhJopu.js → Browse-xEc9mGl7.js} +1 -1
  24. package/dist/assets/{BudgetPolicyCard-45TwMzp3.js → BudgetPolicyCard-Ccr3EX5M.js} +1 -1
  25. package/dist/assets/{CaseDetail-CRN2rF4k.js → CaseDetail-CvMk_M-F.js} +1 -1
  26. package/dist/assets/{Cases-CFqnLAMq.js → Cases-H1Y4Oipe.js} +1 -1
  27. package/dist/assets/{ChatEndpointDetail-BTYAtutu.js → ChatEndpointDetail-CjDVQWl8.js} +1 -1
  28. package/dist/assets/{ChatEndpointSetup-CzrgHmvH.js → ChatEndpointSetup-BfohtKVM.js} +1 -1
  29. package/dist/assets/{Companies-C-U5WI6o.js → Companies-C4ObCu9j.js} +1 -1
  30. package/dist/assets/{CompanyAccess-DLgvUIoB.js → CompanyAccess-J5Vwnko2.js} +1 -1
  31. package/dist/assets/{CompanyActivity-8CeynedM.js → CompanyActivity-B7-kMNmz.js} +1 -1
  32. package/dist/assets/{CompanyConnections-BjMmsqei.js → CompanyConnections-D2N6UWXk.js} +1 -1
  33. package/dist/assets/{CompanyEnvironments-D6p-TNkv.js → CompanyEnvironments-ChSu4gxW.js} +1 -1
  34. package/dist/assets/{CompanyExport-Dw0QDMvs.js → CompanyExport-B_opHRSJ.js} +1 -1
  35. package/dist/assets/{CompanyImport-OSi3fM2l.js → CompanyImport-DZAMEBBy.js} +1 -1
  36. package/dist/assets/{CompanySettings-B-aPUQpY.js → CompanySettings-Rz8cwgKC.js} +1 -1
  37. package/dist/assets/{CompanySettingsPluginPage-Kp7iOUP1.js → CompanySettingsPluginPage-CM-ViPwj.js} +1 -1
  38. package/dist/assets/{CompanySkills-HZqJ5DZ8.js → CompanySkills-BnwPuZze.js} +1 -1
  39. package/dist/assets/{ConfigureBuiltInAgentModal-DL3wv3Mb.js → ConfigureBuiltInAgentModal-BAfoTveX.js} +1 -1
  40. package/dist/assets/{CopyableGatewayUrl-BLjhj10P.js → CopyableGatewayUrl-D90Bjxj0.js} +1 -1
  41. package/dist/assets/{Dashboard-DTmjsaEr.js → Dashboard-DepIxrje.js} +1 -1
  42. package/dist/assets/{DecisionDateChips-Br5r2jWZ.js → DecisionDateChips-89KkV4mo.js} +1 -1
  43. package/dist/assets/{DecisionQueuePage-zWDMjHf9.js → DecisionQueuePage-nU9qXzln.js} +1 -1
  44. package/dist/assets/{DesignGuide-BsH97scx.js → DesignGuide-40TixHZ-.js} +1 -1
  45. package/dist/assets/{EmailEndpointSetup-C7PhFwBy.js → EmailEndpointSetup-D7-8f1XV.js} +1 -1
  46. package/dist/assets/{ExecutionWorkspaceDetail-CTDvazWh.js → ExecutionWorkspaceDetail-CnUD3jLO.js} +1 -1
  47. package/dist/assets/{GatewayDetail-BtpnGGIB.js → GatewayDetail-Bg7GU-1a.js} +1 -1
  48. package/dist/assets/{GatewaysList-DrRfNyqk.js → GatewaysList-4vvZCBkY.js} +1 -1
  49. package/dist/assets/{GoalDetail-D5QqhxMg.js → GoalDetail-h7WsjaOO.js} +1 -1
  50. package/dist/assets/{GoalTree-CDexmAKW.js → GoalTree-yPtfejUx.js} +1 -1
  51. package/dist/assets/{Goals-CZinws4s.js → Goals-DOi3E4DX.js} +1 -1
  52. package/dist/assets/{ImageGalleryModal-VT9I4D2p.js → ImageGalleryModal-D_VQgcBt.js} +1 -1
  53. package/dist/assets/{Inbox-BiE243MO.js → Inbox-COKxRKhR.js} +1 -1
  54. package/dist/assets/{InstanceAdvanced-D_iqUmgn.js → InstanceAdvanced-DlMlwZbU.js} +1 -1
  55. package/dist/assets/{InviteLanding-LR84Xv76.js → InviteLanding-BGvJMHKw.js} +1 -1
  56. package/dist/assets/{IssueChatLongThreadPerf-BHdYa83T.js → IssueChatLongThreadPerf-C3U2FZKJ.js} +1 -1
  57. package/dist/assets/{IssueChatThread-Cno8fLc-.js → IssueChatThread-CDKaIB6v.js} +1 -1
  58. package/dist/assets/{IssueDetail-BWZWLO4k.js → IssueDetail-BCwHANTn.js} +1 -1
  59. package/dist/assets/{IssueOutputSection-BuwP0RQx.js → IssueOutputSection-BzXRmoV7.js} +1 -1
  60. package/dist/assets/{IssueRecoveryActionCard-O4GRNsPc.js → IssueRecoveryActionCard-BYtbaP-M.js} +1 -1
  61. package/dist/assets/{IssueReferencePill-EbOs3MtQ.js → IssueReferencePill-BT7NBEy_.js} +1 -1
  62. package/dist/assets/{IssueThreadInteractionCard-BUIzNywc.js → IssueThreadInteractionCard-Btd0rZ23.js} +1 -1
  63. package/dist/assets/{Issues-mVYaoqsX.js → Issues-XKf7zemQ.js} +1 -1
  64. package/dist/assets/{LiveNowTodoLine-DP95vmnd.js → LiveNowTodoLine-CoL6ZNuK.js} +1 -1
  65. package/dist/assets/{ManagedAiConnectionDetails-ZByBvcqo.js → ManagedAiConnectionDetails-CebBi-Tw.js} +1 -1
  66. package/dist/assets/{McpConnect-D42jtK1S.js → McpConnect-ByorZN7G.js} +1 -1
  67. package/dist/assets/{MembershipAction-Df2Qlkdz.js → MembershipAction-De0MBfgb.js} +1 -1
  68. package/dist/assets/{ModelsAndProviders-BzUob8BB.js → ModelsAndProviders-BqM4UJc7.js} +1 -1
  69. package/dist/assets/{NewAgent-BywRvCR0.js → NewAgent-pMTQYNxn.js} +1 -1
  70. package/dist/assets/{PipelineSettings-DFjxoW4i.js → PipelineSettings-C2k3BzLQ.js} +1 -1
  71. package/dist/assets/{Pipelines-CSW-En3n.js → Pipelines-Cr6Xs32p.js} +1 -1
  72. package/dist/assets/{PixelsOffice-B2b8M6LM.js → PixelsOffice-Dfd4XKSj.js} +1 -1
  73. package/dist/assets/{PluginPage-CfSIAMQa.js → PluginPage-fPlWyFSc.js} +1 -1
  74. package/dist/assets/{PluginSettings-TewUkGUA.js → PluginSettings-X_VHvvo5.js} +1 -1
  75. package/dist/assets/{ProfileDetailRoute-CCbLcj8f.js → ProfileDetailRoute-PAsWmN-1.js} +1 -1
  76. package/dist/assets/{ProfileSettings-D1D_hKPu.js → ProfileSettings-BACxlGZS.js} +1 -1
  77. package/dist/assets/{ProfileWizardRoute-BzFGrQkr.js → ProfileWizardRoute-Dbq0n7If.js} +1 -1
  78. package/dist/assets/{ProjectDetail-CEjUARCN.js → ProjectDetail-DOJZUIWu.js} +1 -1
  79. package/dist/assets/{ProjectWorkspaceDetail-7fFllUMH.js → ProjectWorkspaceDetail-ZNnaHnuA.js} +1 -1
  80. package/dist/assets/{ProjectWorkspacesContent-S4UUfVU1.js → ProjectWorkspacesContent-DrWfnTJY.js} +1 -1
  81. package/dist/assets/{Projects-NrtT8d2x.js → Projects-CCzxmEZ8.js} +1 -1
  82. package/dist/assets/{PublicIssueSharePage-CfQDHmOe.js → PublicIssueSharePage-BUSkP1Js.js} +1 -1
  83. package/dist/assets/{ReviewQueueCard-CksOubye.js → ReviewQueueCard-CrCN_30c.js} +1 -1
  84. package/dist/assets/{RichWorkProductCard-XPJ4R-il.js → RichWorkProductCard-DndJn4LV.js} +1 -1
  85. package/dist/assets/{RoutineDetail-AcrnXhjR.js → RoutineDetail-B5MzV_74.js} +1 -1
  86. package/dist/assets/{RoutineRunVariablesDialog-CtSVwZjy.js → RoutineRunVariablesDialog-kGyQVBid.js} +1 -1
  87. package/dist/assets/{Routines-B19G6Lkw.js → Routines-B2zX9h3J.js} +1 -1
  88. package/dist/assets/{ScrollToBottom-csHqjOIa.js → ScrollToBottom-Dd3SpeJi.js} +1 -1
  89. package/dist/assets/{Search-CnO6qC0m.js → Search-D4W3cZZf.js} +1 -1
  90. package/dist/assets/{Secrets-Xz6WSEnG.js → Secrets-C4nbuMIh.js} +1 -1
  91. package/dist/assets/{SkillSourceTree-BC2Ycl7g.js → SkillSourceTree-BvGzMa2u.js} +1 -1
  92. package/dist/assets/{SkillSources-BMogH_qp.js → SkillSources-DL2tNkcr.js} +1 -1
  93. package/dist/assets/{SkillStudio-HekOqqo_.js → SkillStudio-BnZ2cfDq.js} +1 -1
  94. package/dist/assets/{SourceTrustBadge-CXZGc8G4.js → SourceTrustBadge-CCPQEGrC.js} +1 -1
  95. package/dist/assets/{StatusCards-CL-RC2Mf.js → StatusCards-BkE-9R8F.js} +1 -1
  96. package/dist/assets/{SummarySlotCard-BJmo-gDJ.js → SummarySlotCard-D1EyiciB.js} +1 -1
  97. package/dist/assets/{TaskChatLab-CIZVb5Ed.js → TaskChatLab-D3PsNRr5.js} +1 -1
  98. package/dist/assets/{TaskChatMarker-CdRbWeYc.js → TaskChatMarker-DEF88_sr.js} +1 -1
  99. package/dist/assets/{TaskChatProtocolCard-C_A2mV-g.js → TaskChatProtocolCard-Ba_vhDxn.js} +1 -1
  100. package/dist/assets/{TaskChatThreadView-Bd3E40e0.js → TaskChatThreadView-BsPvbxiA.js} +1 -1
  101. package/dist/assets/{TaskTreeControls-DK6EZXLI.js → TaskTreeControls-BKOIbilg.js} +1 -1
  102. package/dist/assets/{Terminal-BcD_c9Om.js → Terminal-1uPX7VEe.js} +1 -1
  103. package/dist/assets/{TerminalView-XV2mBbcS.js → TerminalView-DDv6s-R_.js} +1 -1
  104. package/dist/assets/{TrustPresetSection-Ev8RdYhN.js → TrustPresetSection-BDb0N4Pe.js} +1 -1
  105. package/dist/assets/{UserProfile-C_BKVfMQ.js → UserProfile-DqPRuGWk.js} +1 -1
  106. package/dist/assets/{WhatNeedsMe-CYs2iX06.js → WhatNeedsMe-DtBxgH24.js} +1 -1
  107. package/dist/assets/{Workspaces-B8Wwbx8B.js → Workspaces-BQOyG5HK.js} +1 -1
  108. package/dist/assets/{connection-owner-Ca1nfKiA.js → connection-owner-CPrMcD3t.js} +1 -1
  109. package/dist/assets/{index-LM7k1NmC.js → index-QhteFtm-.js} +3 -3
  110. package/dist/assets/{issue-properties-CKLKB9AO.js → issue-properties--M7WE6Ot.js} +1 -1
  111. package/dist/assets/{issue-workspace-selection-CJYasFEQ.js → issue-workspace-selection-pUdSkrJA.js} +1 -1
  112. package/dist/assets/{pipeline-stage-presentation-BzvR-f05.js → pipeline-stage-presentation-Dv1xgEPW.js} +1 -1
  113. package/dist/assets/{shared-CMP5lH_Q.js → shared-B75ClBUg.js} +1 -1
  114. package/dist/assets/{system-notice-comment-BUfjKy0_.js → system-notice-comment-D0I6rz8Y.js} +1 -1
  115. package/dist/assets/{transcript-adapter-DiPtVkEm.js → transcript-adapter-ClaGWYVL.js} +1 -1
  116. package/dist/assets/{useSummaryDraftStream-uMW1O0Ga.js → useSummaryDraftStream-BDuMgNcA.js} +1 -1
  117. package/dist/index.html +1 -1
  118. package/dist/sw.js +1 -1
  119. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- var va=Object.defineProperty;var a=(s,n)=>va(s,"name",{value:n,configurable:!0});import{i as Sn}from"./rolldown-runtime-ZpX3ckPj.js";import{Ki as at,O as ja,Qn as ka,Zn as wa,er as Na,l as _e,la as Sa,ua as Ia}from"./createLucideIcon-CgrPXnTY.js";import{a as Ca,o as Ta,v as Aa,y as Pa}from"./star-eem0qj3E.js";import{X as In,_ as B,n as Lt,t as v,v as E}from"./queryKeys-BzT8CD34.js";import{o as Ea}from"./companies-query-BEdFiAhG.js";import{S as We,a as Qt,b as Fa,i as zt,l as Ra,o as Wa,p as qa,r as Oa,s as Yt,t as _a,u as Ka,x as Ma}from"./pipeline-stage-presentation-BzvR-f05.js";import{n as $a}from"./CompanyContext-fQCNWI_f.js";import{it as Da,nt as _t,o as Ba,on as Va,ot as La,t as Oe}from"./router-CJbFZfVR.js";import{n as Qa,r as za,t as Ha}from"./collapsible-D_rwONtV.js";import{i as Xs,o as Ga,p as Zs,r as en,s as Ua,t as tn}from"./dropdown-menu-rUbU8QKw.js";import{t as Ja}from"./MarkdownEditor-ubJimjUH.js";import{t as Cn}from"./activity-BwGRpduS.js";import{t as tt}from"./archive-CvT6i844.js";import{t as Kt}from"./arrow-up-right-CFNgVoQj.js";import{t as Ya}from"./badge-check-BNLpGDnd.js";import{t as Xa}from"./check-Bis3vECb.js";import{t as Tn}from"./chevron-down-nRcQ7bok.js";import{t as Za}from"./chevron-right-BP8JjEC_.js";import{t as ei}from"./environment-variables-editor-D6Ylcd74.js";import{t as ti}from"./ellipsis-DyXbAp4P.js";import{t as Ht}from"./key-round-CGxQxRtN.js";import{t as q}from"./button-DI4w5WP7.js";import{t as sn}from"./pause-B6AkvDer.js";import{t as si}from"./play-Czm7OCYh.js";import{t as ni}from"./plus-CwNlqadt.js";import{t as ai}from"./rotate-ccw-DpzLJhXT.js";import{t as Gt}from"./save-Blub8a14.js";import{t as nn}from"./trash-QxFF084e.js";import{t as an}from"./triangle-alert-CnHMpmva.js";import{t as ii}from"./badge-jeXr866I.js";import{t as fe}from"./AgentAvatar-BZiiDlCN.js";import{a as An}from"./ToastContext-DyVJ6bCh.js";import{t as ri}from"./agents-B8n-p0aX.js";import{t as li}from"./instanceSettings-D1nNVWU0.js";import{t as oi}from"./projects-l3kQxnTp.js";import{a as rn,i as ln,n as on,r as cn,s as dn,t as un}from"./dialog-CeH7rDcv.js";import{t as qe}from"./input-BBNGmECW.js";import{t as ci}from"./access-DhB95qNC.js";import{n as di}from"./BreadcrumbContext-DNbB7zWn.js";import{t as mn}from"./secrets-D17QEm13.js";import{t as ui}from"./textarea-CTx68BDs.js";import{r as pn,t as mi}from"./recent-assignees-DmalYaLf.js";import{t as ge}from"./toggle-switch-Dj5GORxn.js";import{t as Mt}from"./InlineEntitySelector-BboofK18.js";import{$n as xn,Fa as Pn,Hn as pi,Ma as En,Qn as xi,T as z,Wa as hi,Xn as gi,Zn as fi,_ as hn,er as gn,fr as yi,nr as bi,or as fn,pr as vi,tr as ji}from"./index-LM7k1NmC.js";import{t as C}from"./pipelines-0Lb8D7gt.js";import{n as ki,t as wi}from"./RoutineVariablesEditor-CHogduM9.js";var o=Sn(Ia(),1),e=Sn(Sa(),1);function Ni({hasAutomation:s,agentName:n,agentIcon:r,agent:i,secrets:d,secretsLoading:u,value:y,onChange:h,onCreateSecret:p,onSetupAutomation:w,onSave:N,saving:P,dirty:x}){if(!s)return(0,e.jsx)(z,{icon:Ht,message:"Secrets are available only to step automation. Pick an agent to run this step, then add the secrets it needs.",action:"Set up automation",onAction:w});const j=n?.trim()||"the responsible agent";return(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-line bg-bg-3/20 px-4 py-3 text-xs text-ink-3",children:[n?(0,e.jsx)(fe,{agent:i,name:j,size:16}):(0,e.jsx)(Ht,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),(0,e.jsxs)("p",{children:["These env vars are injected when"," ",(0,e.jsx)("span",{className:"font-medium text-ink",children:j})," runs this step. They override matching project and agent env on collisions. ",(0,e.jsx)("span",{className:"font-mono",children:"WARDMOTE_*"})," names are reserved."]})]}),u?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading secrets…"}):(0,e.jsx)(ei,{value:y,secrets:d,onCreateSecret:p,onChange:a(Ke=>h(Ke??{}),"onChange")}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)(q,{type:"button",onClick:N,disabled:!x||P,children:[(0,e.jsx)(Gt,{className:"h-4 w-4 mr-1.5"}),P?"Saving…":"Save secrets"]}),x&&!P?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Unsaved changes"}):null]})]})}a(Ni,"StageSecretsPanel");function Si({pipelineId:s,documentKey:n,currentRevisionId:r,hasDocument:i,onRestored:d}){const{pushToast:u}=An(),y=In(),[h,p]=(0,o.useState)(!1),w=E({queryKey:v.pipelines.documentRevisions(s,n),queryFn:a(async()=>{try{return await C.listDocumentRevisions(s,n)}catch(x){if(x instanceof Lt&&x.status===404)return[];throw x}},"queryFn"),enabled:h&&i}),N=B({mutationFn:a(x=>C.restoreDocumentRevision(s,n,x),"mutationFn"),onSuccess:a(async x=>{await Promise.all([y.invalidateQueries({queryKey:v.pipelines.document(s,n)}),y.invalidateQueries({queryKey:v.pipelines.documentRevisions(s,n)})]),d(x.revision.body,x.revision.id),u({title:`Restored revision ${x.restoredFromRevisionNumber}`,body:`Saved as revision ${x.revision.revisionNumber}.`,tone:"success"})},"onSuccess"),onError:a(x=>{u({title:"Failed to restore revision",body:x instanceof Error?x.message:"Wardmote could not restore the revision.",tone:"error"})},"onError")}),P=w.data??[];return(0,e.jsxs)(Ha,{open:h,onOpenChange:p,className:"overflow-hidden rounded-lg border border-line/70",children:[(0,e.jsxs)(za,{className:"flex w-full items-center justify-between px-3 py-2 text-left",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Pn,{className:"h-4 w-4 text-ink-3"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"History"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Past versions of these instructions."})]})]}),h?(0,e.jsx)(Tn,{className:"h-4 w-4 text-ink-3"}):(0,e.jsx)(Za,{className:"h-4 w-4 text-ink-3"})]}),(0,e.jsx)(Qa,{className:"border-t border-line/70",children:i?w.isLoading?(0,e.jsx)("p",{className:"px-4 py-3 text-xs text-ink-3",children:"Loading revisions…"}):w.error?(0,e.jsx)("p",{className:"px-4 py-3 text-xs text-bad",children:w.error instanceof Error?w.error.message:"Could not load revisions."}):P.length===0?(0,e.jsx)("p",{className:"px-4 py-3 text-xs text-ink-3",children:"No revisions recorded yet."}):(0,e.jsx)("ul",{className:"divide-y divide-line/70",children:P.map(x=>{const j=x.id===r;return(0,e.jsxs)("li",{className:_e("flex items-center justify-between gap-3 px-4 py-2.5",j&&"bg-bg-3/30"),children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("p",{className:"text-sm font-medium",children:["Revision ",x.revisionNumber,j?(0,e.jsx)(ii,{variant:"ghost",className:"ml-2 bg-bg-3 text-(length:--text-micro) text-ink-3",children:"Current"}):null]}),(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:[Va(x.createdAt),x.changeSummary?` · ${x.changeSummary}`:""]})]}),j?null:(0,e.jsxs)(q,{type:"button",variant:"ghost",size:"sm",disabled:N.isPending,onClick:a(()=>N.mutate(x.id),"onClick"),children:[(0,e.jsx)(ai,{className:"h-3.5 w-3.5"}),"Restore"]})]},x.id)})}):(0,e.jsx)("p",{className:"px-4 py-3 text-xs text-ink-3",children:"No history yet. Save the instructions to create the first revision."})})]})}a(Si,"PipelineStageHistoryPanel");var Ii=[{label:"Stage",items:[{id:"instructions",label:"Automation",icon:hi},{id:"advanced",label:"Advanced",icon:En},{id:"secrets",label:"Secrets",icon:Ht}]},{label:"Operate",items:[{id:"activity",label:"Activity",icon:Cn},{id:"history",label:"History",icon:Pn}]}],Ci={instructions:"Automation",secrets:"Secrets",activity:"Activity",history:"History",advanced:"Advanced"};function Ti(s){switch(s){case"instructions":case"advanced":case"secrets":case"activity":case"history":return s;default:return null}}a(Ti,"parseStageSectionKey");function Ai(s,n,r){const i=!!(r&&s.some(d=>d.id===r));return n||i?null:s[0]?.id??null}a(Ai,"resolvePipelineSettingsFallbackStageId");var $t=[{value:"working",label:"Working",description:"Items wait here while work happens. An agent or a person moves them forward.",icon:Da},{value:"review",label:"Review",description:"Someone has to approve before items leave. Use this when a person or an agent has to say yes or no.",icon:Ya},{value:"done",label:"Done",description:"The final step. Items that reach here are finished.",icon:Ca},{value:"cancelled",label:"Cancelled",description:"The dead end. Items that reach here are dropped or rejected.",icon:Ta}];function Pi(s){return`stage-instructions:${s}`}a(Pi,"stageInstructionsKey");var Ei=new Set(["text","textarea","number","boolean","select"]);function Fi(s){if(!Array.isArray(s))return[];const n=[];for(const r of s){if(!r||typeof r!="object"||Array.isArray(r))continue;const i=r,d=typeof i.name=="string"&&i.name.trim()?i.name.trim():typeof i.key=="string"&&i.key.trim()?i.key.trim():null;if(!d)continue;const u=typeof i.type=="string"?i.type:"text",y=Ei.has(u)?u:u==="multiline"?"textarea":"text",h=Array.isArray(i.options)?i.options.filter(w=>typeof w=="string"):[],p=i.defaultValue;n.push({name:d,label:typeof i.label=="string"&&i.label.trim()?i.label.trim():null,type:y,defaultValue:p===void 0||typeof p!="string"&&typeof p!="number"&&typeof p!="boolean"?null:p,required:i.required===!0,options:h})}return n}a(Fi,"toRoutineVariables");function H(s){const n=s?.config;return!n||typeof n!="object"||Array.isArray(n)?{variables:[]}:n}a(H,"stageConfig");var Ri=[{value:"shared_workspace",label:"Project default"},{value:"isolated_workspace",label:"New isolated workspace"},{value:"reuse_existing",label:"Reuse existing workspace"}];function ye(s){return typeof s=="string"&&s.trim()?s.trim():""}a(ye,"nullableString");function Ut(s){switch(ye(s)){case"inherit":case"shared_workspace":case"isolated_workspace":case"operator_branch":case"reuse_existing":case"agent_default":return ye(s);default:return""}}a(Ut,"nullableExecutionWorkspaceMode");function Wi(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:null}a(Wi,"nullableExecutionWorkspaceSettings");function it(s){return typeof s=="string"&&s.trim().length>0?s.trim():at}a(it,"pipelineAutomationTitleTemplate");function qi(s,n,r){const i=Na([s,n],r),d=new Set(i.map(u=>u.name));return[...i,...r.filter(u=>!d.has(u.name))]}a(qi,"syncPipelineStageAutomationVariables");function Oi(s){return{assigneeAgentId:s.assigneeAgentId||null,titleTemplate:it(s.titleTemplate),instructionsBody:s.instructionsBody,projectId:s.projectId||null,projectWorkspaceId:s.projectId&&s.projectWorkspaceId?s.projectWorkspaceId:null,executionWorkspaceId:s.projectId&&s.executionWorkspacePreference==="reuse_existing"&&s.executionWorkspaceId?s.executionWorkspaceId:null,executionWorkspacePreference:s.projectId&&s.executionWorkspacePreference?s.executionWorkspacePreference:null,executionWorkspaceSettings:s.executionWorkspaceSettings}}a(Oi,"buildStageAutomationForSave");function yn(s,n){return s?{mode:s==="reuse_existing"?ji(n?.mode):s}:null}a(yn,"executionWorkspaceSettingsForPreference");function nt(s){const n=H(s).automation;if(!n||typeof n!="object"||Array.isArray(n))return{assigneeAgentId:"",titleTemplate:at,instructionsBody:null,projectId:"",projectWorkspaceId:"",executionWorkspaceId:"",executionWorkspacePreference:"",executionWorkspaceSettings:null};const r=Wi(n.executionWorkspaceSettings);return{assigneeAgentId:ye(n.assigneeAgentId),titleTemplate:it(n.titleTemplate),instructionsBody:typeof n.instructionsBody=="string"?n.instructionsBody:null,projectId:ye(n.projectId),projectWorkspaceId:ye(n.projectWorkspaceId),executionWorkspaceId:ye(n.executionWorkspaceId),executionWorkspacePreference:Ut(n.executionWorkspacePreference)||Ut(r?.mode),executionWorkspaceSettings:r}}a(nt,"stageAutomation");function Fn(s){return H(s).disabled===!0}a(Fn,"stageNewEntriesDisabled");function Dt(s){const n=H(s).automation;return!n||typeof n!="object"||Array.isArray(n)?{routineId:"",assigneeAgentId:"",env:{},latestRoutineRevisionId:null}:{routineId:typeof n.routineId=="string"?n.routineId:"",assigneeAgentId:typeof n.assigneeAgentId=="string"?n.assigneeAgentId:"",env:n.env??{},latestRoutineRevisionId:typeof n.latestRoutineRevisionId=="string"?n.latestRoutineRevisionId:null}}a(Dt,"stageAutomationDetail");function _i(s,n,r){return qi(n,r,Fi(H(s).variables))}a(_i,"savedStageVariables");function Ki(s){return s.map(n=>{const{source:r,...i}=n;return i})}a(Ki,"stripVariableEditorMetadata");function Bt(s,n){const r=new Set(n);return r.size===0?s:s.filter(i=>!r.has(i.name))}a(Bt,"stripVariablesByName");function Mi(s,n){const r=new Set(wa(n).filter(i=>!ka(i)));return s.filter(i=>!r.has(i.name)).map(i=>i.name)}a(Mi,"manualVariableNamesForTemplate");var Xt={version:1,mode:"all_except",includeFields:[],excludeFields:[]};function Zt(s){return{version:1,mode:s?.mode==="only"?"only":"all_except",includeFields:[...s?.includeFields??[]],excludeFields:[...s?.excludeFields??[]]}}a(Zt,"copyCarryOverPolicy");function $i(s){if(!s||typeof s!="object"||Array.isArray(s))return null;const n=s,r=typeof n.name=="string"&&n.name.trim()?n.name.trim():typeof n.key=="string"&&n.key.trim()?n.key.trim():"";if(!r)return null;const i=typeof n.label=="string"&&n.label.trim()?n.label.trim():r;return Qt(r)||Qt(i)?null:{key:r,label:i,required:n.required===!0}}a($i,"readVariableField");function Rn(s,n){return s===0?"This item":s===1?`Parent: ${n}`:s===2?`Grandparent: ${n}`:`Ancestor ${s}: ${n}`}a(Rn,"fieldOriginLabel");function Di(s){const n=[...s.pipeline.stages??[]].sort((i,d)=>i.position-d.position),r=new Set;return n.flatMap(i=>(H(i).variables??[]).flatMap(d=>{const u=$i(d);return!u||r.has(u.key)?[]:(r.add(u.key),[{...u,originId:s.pipeline.id,originLabel:Rn(s.depth,s.pipeline.name),originDescription:s.depth===0?s.pipeline.name:null}])}))}a(Di,"pipelineCarryOverFields");function Bi(s){const n=[];for(const r of s.stages??[]){const i=Yt(r)?.targetPipelineId;i&&n.push(i)}return n}a(Bi,"pipelineBreakdownTargetIds");function Vi(s,n){const r=new Set;for(const i of n)i.id!==s.id&&Bi(i).includes(s.id)&&r.add(i.id);for(const i of s.connections?.upstreamPipelineIds??[])r.add(i);return[...r]}a(Vi,"upstreamPipelineIds");function Wn(s,n){if(!s)return[];const r=new Map;for(const p of n)r.set(p.id,p);const i=r.get(s.id);r.set(s.id,i?{...i,...s}:s);const d=[],u=[{pipeline:r.get(s.id),depth:0}],y=new Set;for(;u.length>0;){const p=u.shift();if(!(y.has(p.pipeline.id)||p.depth>8)){y.add(p.pipeline.id),d.push(p);for(const w of Vi(p.pipeline,[...r.values()]).sort()){const N=r.get(w);N&&!y.has(N.id)&&u.push({pipeline:N,depth:p.depth+1})}}}const h=new Set;return d.flatMap(p=>{const w=Di(p).filter(N=>h.has(N.key)?!1:(h.add(N.key),!0));return w.length===0?[]:[{id:p.pipeline.id,label:Rn(p.depth,p.pipeline.name),description:p.depth===0?p.pipeline.name:null,depth:p.depth,fields:w}]})}a(Wn,"buildCarryOverFieldGroups");function Jt(s){return s.flatMap(n=>n.fields)}a(Jt,"flattenCarryOverFields");function rt(s,n){return n.filter(r=>zt(s,r.key)).map(r=>r.key)}a(rt,"selectedCarryOverFieldKeys");function qn(s,n){const r=new Set(s);return{version:1,mode:"all_except",includeFields:[],excludeFields:n.filter(i=>!r.has(i.key)).map(i=>i.key)}}a(qn,"carryOverPolicyForCheckedFields");function Li(s,n,r,i){const d=new Set(rt(s,n));return i?d.add(r):d.delete(r),qn(d,n)}a(Li,"toggleCarryOverField");function Qi(s,n,r){if(!s||!n)return[];const i=new Map;for(const u of r)i.set(u.id,u);const d=i.get(s.id);return i.set(s.id,d?{...d,...s}:s),[...i.values()].flatMap(u=>(u.stages??[]).flatMap(y=>{const h=Yt(y);if(!h||h.targetPipelineId!==s.id||h.targetStageKey!==n.key)return[];const p=Jt(Wn(u,[...i.values()])),w=new Map(p.map(x=>[x.key,x])),N=Zt(h.carryOverPolicy??Xt),P=(N.mode==="only"?N.includeFields.filter(x=>!Qt(x)):rt(N,p)).map(x=>w.get(x)??{key:x,label:x,required:!1,originId:u.id,originLabel:u.name,originDescription:y.name});return P.length===0?[]:[{id:`${u.id}:${y.id}`,label:u.name,description:y.name,depth:1,fields:P}]}))}a(Qi,"buildIncomingCarryOverFieldGroups");function bn(s,n){return n.length===0?Zt(s):qn(rt(s,n),n)}a(bn,"carryOverPolicyForSave");function zi(s,n){return n.length===0?s.mode==="only"?[...s.includeFields]:[]:rt(s,n)}a(zi,"inheritFieldsForSave");function vn(s,n){const r=H(s),i=nt(s),d=Yt(s);return{name:s.name,kind:Xi(s.kind),newEntriesDisabled:Fn(s),disableReason:r.disabledReason??"",assigneeAgentId:i.assigneeAgentId,approvalRequired:!!r.requireApproval,approval:Hi(r),approveTarget:r.approveToStageKey??"",rejectTarget:r.rejectToStageKey??"",requestChangesTarget:r.requestChangesToStageKey??"",requireRejectReason:r.requireRejectReason??!0,requireRequestChangesReason:r.requireRequestChangesReason??!0,requireChildrenTerminal:r.requireChildrenTerminal===!0,autoAdvanceOnChildrenTerminal:typeof r.autoAdvanceOnChildrenTerminal=="string"?r.autoAdvanceOnChildrenTerminal:"",breakdownEnabled:d!==null,breakdownTargetPipelineId:d?.targetPipelineId??"",breakdownTargetStageKey:d?.targetStageKey??"",breakdownPieceNoun:d?.pieceNoun??"piece",breakdownCarryOverPolicy:Zt(d?.carryOverPolicy??Xt),breakdownAdvanceTo:d?.advanceTo??"",breakdownWaitForPieces:d?.waitForPieces??!1,breakdownWhenFinishedMoveTo:d?.whenFinishedMoveTo??"",transitionTargetIds:n.filter(u=>u.fromStageId===s.id).map(u=>u.toStageId).sort(),automationProjectId:i.projectId,automationProjectWorkspaceId:i.projectWorkspaceId,automationExecutionWorkspaceId:i.executionWorkspaceId,automationExecutionWorkspacePreference:i.executionWorkspacePreference,automationExecutionWorkspaceSettings:i.executionWorkspaceSettings,automationTitleTemplate:i.titleTemplate}}a(vn,"computeStageForm");function Hi(s){const n=s.approver;return!n||!n.kind||n.kind==="any_human"?"any_human":(n.kind==="user"||n.kind==="agent")&&n.id?`${n.kind}:${n.id}`:"any_human"}a(Hi,"approvalValue");function Gi(s){if(s==="any_human")return{kind:"any_human",id:null};const[n,r]=s.split(":",2);return(n==="user"||n==="agent")&&r?{kind:n,id:r}:{kind:"any_human",id:null}}a(Gi,"parseApprovalValue");function Ui(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,60).replace(/_+$/g,"")||"stage"}a(Ui,"stageKeyFromName");function Ji(s,n){const r=Ui(s);return n.has(r)?`${r}_${Date.now().toString(36)}`:r}a(Ji,"nextStageKey");function Yi(s){return[...s?.stages??[]].sort((n,r)=>n.position-r.position)}a(Yi,"sortedStages");function Xi(s){return s==="review"||s==="done"||s==="cancelled"?s:"working"}a(Xi,"canonicalStageKind");function Zi(s,n){return n?s.find(r=>r.id!==n.id&&r.position>n.position)??null:null}a(Zi,"nextStageByPosition");function er(s,n){return s.find(r=>r.position>=n)??null}a(er,"nextStageForInsert");function On(s){return Ii}a(On,"stageNavGroups");function jn(s,n){return On(s).some(r=>r.items.some(i=>i.id===n))}a(jn,"isPipelineSettingsStageSectionAvailable");function kn(s,n,r){const i=s.find(d=>d.kind===r&&d.id!==n);return i?i.key:s.find(d=>d.id!==n)?.key??""}a(kn,"defaultReviewTarget");function wn(s){const n=new Set;return s.filter(r=>{if(r.fromStageKey===r.toStageKey)return!1;const i=`${r.fromStageKey}:${r.toStageKey}`;return n.has(i)?!1:(n.add(i),!0)})}a(wn,"dedupeEdges");function Vt(s){return s?`agent:${s}`:""}a(Vt,"stageAssigneeOptionId");function st(s){return s.startsWith("agent:")?s.slice(6):""}a(st,"stageAssigneeIdFromOption");function tr(s){return s||"any_human"}a(tr,"approverValueFromOption");var sr=new Set(["case_id","case_key","case_title","case_version","title","body","case_body"]);function nr(s){if(typeof s=="string")return s;if(typeof s=="number"||typeof s=="boolean")return String(s);if(s==null)return"";try{return JSON.stringify(s,null,2)??""}catch{return String(s)}}a(nr,"primitiveAutomationVariablePreview");function ar(s){return Array.isArray(s)?"array":s==null?"empty":typeof s}a(ar,"automationVariableKind");function ir(s){const n=nr(s.example),r=typeof s.example=="string"?`${s.example.length} chars`:`${n.length} chars`,i=[s.description,`Example: ${ar(s.example)}, ${r}`];return s.exampleSource&&i.push(`From ${s.exampleSource}`),n&&i.push(n.length>500?`${n.slice(0,500)}...`:n),i.join(`
1
+ var va=Object.defineProperty;var a=(s,n)=>va(s,"name",{value:n,configurable:!0});import{i as Sn}from"./rolldown-runtime-ZpX3ckPj.js";import{Ki as at,O as ja,Qn as ka,Zn as wa,er as Na,l as _e,la as Sa,ua as Ia}from"./createLucideIcon-CgrPXnTY.js";import{a as Ca,o as Ta,v as Aa,y as Pa}from"./star-eem0qj3E.js";import{X as In,_ as B,n as Lt,t as v,v as E}from"./queryKeys-BzT8CD34.js";import{o as Ea}from"./companies-query-BEdFiAhG.js";import{S as We,a as Qt,b as Fa,i as zt,l as Ra,o as Wa,p as qa,r as Oa,s as Yt,t as _a,u as Ka,x as Ma}from"./pipeline-stage-presentation-Dv1xgEPW.js";import{n as $a}from"./CompanyContext-fQCNWI_f.js";import{it as Da,nt as _t,o as Ba,on as Va,ot as La,t as Oe}from"./router-CJbFZfVR.js";import{n as Qa,r as za,t as Ha}from"./collapsible-D_rwONtV.js";import{i as Xs,o as Ga,p as Zs,r as en,s as Ua,t as tn}from"./dropdown-menu-rUbU8QKw.js";import{t as Ja}from"./MarkdownEditor-ubJimjUH.js";import{t as Cn}from"./activity-BwGRpduS.js";import{t as tt}from"./archive-CvT6i844.js";import{t as Kt}from"./arrow-up-right-CFNgVoQj.js";import{t as Ya}from"./badge-check-BNLpGDnd.js";import{t as Xa}from"./check-Bis3vECb.js";import{t as Tn}from"./chevron-down-nRcQ7bok.js";import{t as Za}from"./chevron-right-BP8JjEC_.js";import{t as ei}from"./environment-variables-editor-D6Ylcd74.js";import{t as ti}from"./ellipsis-DyXbAp4P.js";import{t as Ht}from"./key-round-CGxQxRtN.js";import{t as q}from"./button-DI4w5WP7.js";import{t as sn}from"./pause-B6AkvDer.js";import{t as si}from"./play-Czm7OCYh.js";import{t as ni}from"./plus-CwNlqadt.js";import{t as ai}from"./rotate-ccw-DpzLJhXT.js";import{t as Gt}from"./save-Blub8a14.js";import{t as nn}from"./trash-QxFF084e.js";import{t as an}from"./triangle-alert-CnHMpmva.js";import{t as ii}from"./badge-jeXr866I.js";import{t as fe}from"./AgentAvatar-BZiiDlCN.js";import{a as An}from"./ToastContext-DyVJ6bCh.js";import{t as ri}from"./agents-B8n-p0aX.js";import{t as li}from"./instanceSettings-D1nNVWU0.js";import{t as oi}from"./projects-l3kQxnTp.js";import{a as rn,i as ln,n as on,r as cn,s as dn,t as un}from"./dialog-CeH7rDcv.js";import{t as qe}from"./input-BBNGmECW.js";import{t as ci}from"./access-DhB95qNC.js";import{n as di}from"./BreadcrumbContext-DNbB7zWn.js";import{t as mn}from"./secrets-D17QEm13.js";import{t as ui}from"./textarea-CTx68BDs.js";import{r as pn,t as mi}from"./recent-assignees-DmalYaLf.js";import{t as ge}from"./toggle-switch-Dj5GORxn.js";import{t as Mt}from"./InlineEntitySelector-BboofK18.js";import{$n as xn,Fa as Pn,Hn as pi,Ma as En,Qn as xi,T as z,Wa as hi,Xn as gi,Zn as fi,_ as hn,er as gn,fr as yi,nr as bi,or as fn,pr as vi,tr as ji}from"./index-QhteFtm-.js";import{t as C}from"./pipelines-0Lb8D7gt.js";import{n as ki,t as wi}from"./RoutineVariablesEditor-CHogduM9.js";var o=Sn(Ia(),1),e=Sn(Sa(),1);function Ni({hasAutomation:s,agentName:n,agentIcon:r,agent:i,secrets:d,secretsLoading:u,value:y,onChange:h,onCreateSecret:p,onSetupAutomation:w,onSave:N,saving:P,dirty:x}){if(!s)return(0,e.jsx)(z,{icon:Ht,message:"Secrets are available only to step automation. Pick an agent to run this step, then add the secrets it needs.",action:"Set up automation",onAction:w});const j=n?.trim()||"the responsible agent";return(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-line bg-bg-3/20 px-4 py-3 text-xs text-ink-3",children:[n?(0,e.jsx)(fe,{agent:i,name:j,size:16}):(0,e.jsx)(Ht,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),(0,e.jsxs)("p",{children:["These env vars are injected when"," ",(0,e.jsx)("span",{className:"font-medium text-ink",children:j})," runs this step. They override matching project and agent env on collisions. ",(0,e.jsx)("span",{className:"font-mono",children:"WARDMOTE_*"})," names are reserved."]})]}),u?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading secrets…"}):(0,e.jsx)(ei,{value:y,secrets:d,onCreateSecret:p,onChange:a(Ke=>h(Ke??{}),"onChange")}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)(q,{type:"button",onClick:N,disabled:!x||P,children:[(0,e.jsx)(Gt,{className:"h-4 w-4 mr-1.5"}),P?"Saving…":"Save secrets"]}),x&&!P?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Unsaved changes"}):null]})]})}a(Ni,"StageSecretsPanel");function Si({pipelineId:s,documentKey:n,currentRevisionId:r,hasDocument:i,onRestored:d}){const{pushToast:u}=An(),y=In(),[h,p]=(0,o.useState)(!1),w=E({queryKey:v.pipelines.documentRevisions(s,n),queryFn:a(async()=>{try{return await C.listDocumentRevisions(s,n)}catch(x){if(x instanceof Lt&&x.status===404)return[];throw x}},"queryFn"),enabled:h&&i}),N=B({mutationFn:a(x=>C.restoreDocumentRevision(s,n,x),"mutationFn"),onSuccess:a(async x=>{await Promise.all([y.invalidateQueries({queryKey:v.pipelines.document(s,n)}),y.invalidateQueries({queryKey:v.pipelines.documentRevisions(s,n)})]),d(x.revision.body,x.revision.id),u({title:`Restored revision ${x.restoredFromRevisionNumber}`,body:`Saved as revision ${x.revision.revisionNumber}.`,tone:"success"})},"onSuccess"),onError:a(x=>{u({title:"Failed to restore revision",body:x instanceof Error?x.message:"Wardmote could not restore the revision.",tone:"error"})},"onError")}),P=w.data??[];return(0,e.jsxs)(Ha,{open:h,onOpenChange:p,className:"overflow-hidden rounded-lg border border-line/70",children:[(0,e.jsxs)(za,{className:"flex w-full items-center justify-between px-3 py-2 text-left",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Pn,{className:"h-4 w-4 text-ink-3"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"History"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Past versions of these instructions."})]})]}),h?(0,e.jsx)(Tn,{className:"h-4 w-4 text-ink-3"}):(0,e.jsx)(Za,{className:"h-4 w-4 text-ink-3"})]}),(0,e.jsx)(Qa,{className:"border-t border-line/70",children:i?w.isLoading?(0,e.jsx)("p",{className:"px-4 py-3 text-xs text-ink-3",children:"Loading revisions…"}):w.error?(0,e.jsx)("p",{className:"px-4 py-3 text-xs text-bad",children:w.error instanceof Error?w.error.message:"Could not load revisions."}):P.length===0?(0,e.jsx)("p",{className:"px-4 py-3 text-xs text-ink-3",children:"No revisions recorded yet."}):(0,e.jsx)("ul",{className:"divide-y divide-line/70",children:P.map(x=>{const j=x.id===r;return(0,e.jsxs)("li",{className:_e("flex items-center justify-between gap-3 px-4 py-2.5",j&&"bg-bg-3/30"),children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("p",{className:"text-sm font-medium",children:["Revision ",x.revisionNumber,j?(0,e.jsx)(ii,{variant:"ghost",className:"ml-2 bg-bg-3 text-(length:--text-micro) text-ink-3",children:"Current"}):null]}),(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:[Va(x.createdAt),x.changeSummary?` · ${x.changeSummary}`:""]})]}),j?null:(0,e.jsxs)(q,{type:"button",variant:"ghost",size:"sm",disabled:N.isPending,onClick:a(()=>N.mutate(x.id),"onClick"),children:[(0,e.jsx)(ai,{className:"h-3.5 w-3.5"}),"Restore"]})]},x.id)})}):(0,e.jsx)("p",{className:"px-4 py-3 text-xs text-ink-3",children:"No history yet. Save the instructions to create the first revision."})})]})}a(Si,"PipelineStageHistoryPanel");var Ii=[{label:"Stage",items:[{id:"instructions",label:"Automation",icon:hi},{id:"advanced",label:"Advanced",icon:En},{id:"secrets",label:"Secrets",icon:Ht}]},{label:"Operate",items:[{id:"activity",label:"Activity",icon:Cn},{id:"history",label:"History",icon:Pn}]}],Ci={instructions:"Automation",secrets:"Secrets",activity:"Activity",history:"History",advanced:"Advanced"};function Ti(s){switch(s){case"instructions":case"advanced":case"secrets":case"activity":case"history":return s;default:return null}}a(Ti,"parseStageSectionKey");function Ai(s,n,r){const i=!!(r&&s.some(d=>d.id===r));return n||i?null:s[0]?.id??null}a(Ai,"resolvePipelineSettingsFallbackStageId");var $t=[{value:"working",label:"Working",description:"Items wait here while work happens. An agent or a person moves them forward.",icon:Da},{value:"review",label:"Review",description:"Someone has to approve before items leave. Use this when a person or an agent has to say yes or no.",icon:Ya},{value:"done",label:"Done",description:"The final step. Items that reach here are finished.",icon:Ca},{value:"cancelled",label:"Cancelled",description:"The dead end. Items that reach here are dropped or rejected.",icon:Ta}];function Pi(s){return`stage-instructions:${s}`}a(Pi,"stageInstructionsKey");var Ei=new Set(["text","textarea","number","boolean","select"]);function Fi(s){if(!Array.isArray(s))return[];const n=[];for(const r of s){if(!r||typeof r!="object"||Array.isArray(r))continue;const i=r,d=typeof i.name=="string"&&i.name.trim()?i.name.trim():typeof i.key=="string"&&i.key.trim()?i.key.trim():null;if(!d)continue;const u=typeof i.type=="string"?i.type:"text",y=Ei.has(u)?u:u==="multiline"?"textarea":"text",h=Array.isArray(i.options)?i.options.filter(w=>typeof w=="string"):[],p=i.defaultValue;n.push({name:d,label:typeof i.label=="string"&&i.label.trim()?i.label.trim():null,type:y,defaultValue:p===void 0||typeof p!="string"&&typeof p!="number"&&typeof p!="boolean"?null:p,required:i.required===!0,options:h})}return n}a(Fi,"toRoutineVariables");function H(s){const n=s?.config;return!n||typeof n!="object"||Array.isArray(n)?{variables:[]}:n}a(H,"stageConfig");var Ri=[{value:"shared_workspace",label:"Project default"},{value:"isolated_workspace",label:"New isolated workspace"},{value:"reuse_existing",label:"Reuse existing workspace"}];function ye(s){return typeof s=="string"&&s.trim()?s.trim():""}a(ye,"nullableString");function Ut(s){switch(ye(s)){case"inherit":case"shared_workspace":case"isolated_workspace":case"operator_branch":case"reuse_existing":case"agent_default":return ye(s);default:return""}}a(Ut,"nullableExecutionWorkspaceMode");function Wi(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:null}a(Wi,"nullableExecutionWorkspaceSettings");function it(s){return typeof s=="string"&&s.trim().length>0?s.trim():at}a(it,"pipelineAutomationTitleTemplate");function qi(s,n,r){const i=Na([s,n],r),d=new Set(i.map(u=>u.name));return[...i,...r.filter(u=>!d.has(u.name))]}a(qi,"syncPipelineStageAutomationVariables");function Oi(s){return{assigneeAgentId:s.assigneeAgentId||null,titleTemplate:it(s.titleTemplate),instructionsBody:s.instructionsBody,projectId:s.projectId||null,projectWorkspaceId:s.projectId&&s.projectWorkspaceId?s.projectWorkspaceId:null,executionWorkspaceId:s.projectId&&s.executionWorkspacePreference==="reuse_existing"&&s.executionWorkspaceId?s.executionWorkspaceId:null,executionWorkspacePreference:s.projectId&&s.executionWorkspacePreference?s.executionWorkspacePreference:null,executionWorkspaceSettings:s.executionWorkspaceSettings}}a(Oi,"buildStageAutomationForSave");function yn(s,n){return s?{mode:s==="reuse_existing"?ji(n?.mode):s}:null}a(yn,"executionWorkspaceSettingsForPreference");function nt(s){const n=H(s).automation;if(!n||typeof n!="object"||Array.isArray(n))return{assigneeAgentId:"",titleTemplate:at,instructionsBody:null,projectId:"",projectWorkspaceId:"",executionWorkspaceId:"",executionWorkspacePreference:"",executionWorkspaceSettings:null};const r=Wi(n.executionWorkspaceSettings);return{assigneeAgentId:ye(n.assigneeAgentId),titleTemplate:it(n.titleTemplate),instructionsBody:typeof n.instructionsBody=="string"?n.instructionsBody:null,projectId:ye(n.projectId),projectWorkspaceId:ye(n.projectWorkspaceId),executionWorkspaceId:ye(n.executionWorkspaceId),executionWorkspacePreference:Ut(n.executionWorkspacePreference)||Ut(r?.mode),executionWorkspaceSettings:r}}a(nt,"stageAutomation");function Fn(s){return H(s).disabled===!0}a(Fn,"stageNewEntriesDisabled");function Dt(s){const n=H(s).automation;return!n||typeof n!="object"||Array.isArray(n)?{routineId:"",assigneeAgentId:"",env:{},latestRoutineRevisionId:null}:{routineId:typeof n.routineId=="string"?n.routineId:"",assigneeAgentId:typeof n.assigneeAgentId=="string"?n.assigneeAgentId:"",env:n.env??{},latestRoutineRevisionId:typeof n.latestRoutineRevisionId=="string"?n.latestRoutineRevisionId:null}}a(Dt,"stageAutomationDetail");function _i(s,n,r){return qi(n,r,Fi(H(s).variables))}a(_i,"savedStageVariables");function Ki(s){return s.map(n=>{const{source:r,...i}=n;return i})}a(Ki,"stripVariableEditorMetadata");function Bt(s,n){const r=new Set(n);return r.size===0?s:s.filter(i=>!r.has(i.name))}a(Bt,"stripVariablesByName");function Mi(s,n){const r=new Set(wa(n).filter(i=>!ka(i)));return s.filter(i=>!r.has(i.name)).map(i=>i.name)}a(Mi,"manualVariableNamesForTemplate");var Xt={version:1,mode:"all_except",includeFields:[],excludeFields:[]};function Zt(s){return{version:1,mode:s?.mode==="only"?"only":"all_except",includeFields:[...s?.includeFields??[]],excludeFields:[...s?.excludeFields??[]]}}a(Zt,"copyCarryOverPolicy");function $i(s){if(!s||typeof s!="object"||Array.isArray(s))return null;const n=s,r=typeof n.name=="string"&&n.name.trim()?n.name.trim():typeof n.key=="string"&&n.key.trim()?n.key.trim():"";if(!r)return null;const i=typeof n.label=="string"&&n.label.trim()?n.label.trim():r;return Qt(r)||Qt(i)?null:{key:r,label:i,required:n.required===!0}}a($i,"readVariableField");function Rn(s,n){return s===0?"This item":s===1?`Parent: ${n}`:s===2?`Grandparent: ${n}`:`Ancestor ${s}: ${n}`}a(Rn,"fieldOriginLabel");function Di(s){const n=[...s.pipeline.stages??[]].sort((i,d)=>i.position-d.position),r=new Set;return n.flatMap(i=>(H(i).variables??[]).flatMap(d=>{const u=$i(d);return!u||r.has(u.key)?[]:(r.add(u.key),[{...u,originId:s.pipeline.id,originLabel:Rn(s.depth,s.pipeline.name),originDescription:s.depth===0?s.pipeline.name:null}])}))}a(Di,"pipelineCarryOverFields");function Bi(s){const n=[];for(const r of s.stages??[]){const i=Yt(r)?.targetPipelineId;i&&n.push(i)}return n}a(Bi,"pipelineBreakdownTargetIds");function Vi(s,n){const r=new Set;for(const i of n)i.id!==s.id&&Bi(i).includes(s.id)&&r.add(i.id);for(const i of s.connections?.upstreamPipelineIds??[])r.add(i);return[...r]}a(Vi,"upstreamPipelineIds");function Wn(s,n){if(!s)return[];const r=new Map;for(const p of n)r.set(p.id,p);const i=r.get(s.id);r.set(s.id,i?{...i,...s}:s);const d=[],u=[{pipeline:r.get(s.id),depth:0}],y=new Set;for(;u.length>0;){const p=u.shift();if(!(y.has(p.pipeline.id)||p.depth>8)){y.add(p.pipeline.id),d.push(p);for(const w of Vi(p.pipeline,[...r.values()]).sort()){const N=r.get(w);N&&!y.has(N.id)&&u.push({pipeline:N,depth:p.depth+1})}}}const h=new Set;return d.flatMap(p=>{const w=Di(p).filter(N=>h.has(N.key)?!1:(h.add(N.key),!0));return w.length===0?[]:[{id:p.pipeline.id,label:Rn(p.depth,p.pipeline.name),description:p.depth===0?p.pipeline.name:null,depth:p.depth,fields:w}]})}a(Wn,"buildCarryOverFieldGroups");function Jt(s){return s.flatMap(n=>n.fields)}a(Jt,"flattenCarryOverFields");function rt(s,n){return n.filter(r=>zt(s,r.key)).map(r=>r.key)}a(rt,"selectedCarryOverFieldKeys");function qn(s,n){const r=new Set(s);return{version:1,mode:"all_except",includeFields:[],excludeFields:n.filter(i=>!r.has(i.key)).map(i=>i.key)}}a(qn,"carryOverPolicyForCheckedFields");function Li(s,n,r,i){const d=new Set(rt(s,n));return i?d.add(r):d.delete(r),qn(d,n)}a(Li,"toggleCarryOverField");function Qi(s,n,r){if(!s||!n)return[];const i=new Map;for(const u of r)i.set(u.id,u);const d=i.get(s.id);return i.set(s.id,d?{...d,...s}:s),[...i.values()].flatMap(u=>(u.stages??[]).flatMap(y=>{const h=Yt(y);if(!h||h.targetPipelineId!==s.id||h.targetStageKey!==n.key)return[];const p=Jt(Wn(u,[...i.values()])),w=new Map(p.map(x=>[x.key,x])),N=Zt(h.carryOverPolicy??Xt),P=(N.mode==="only"?N.includeFields.filter(x=>!Qt(x)):rt(N,p)).map(x=>w.get(x)??{key:x,label:x,required:!1,originId:u.id,originLabel:u.name,originDescription:y.name});return P.length===0?[]:[{id:`${u.id}:${y.id}`,label:u.name,description:y.name,depth:1,fields:P}]}))}a(Qi,"buildIncomingCarryOverFieldGroups");function bn(s,n){return n.length===0?Zt(s):qn(rt(s,n),n)}a(bn,"carryOverPolicyForSave");function zi(s,n){return n.length===0?s.mode==="only"?[...s.includeFields]:[]:rt(s,n)}a(zi,"inheritFieldsForSave");function vn(s,n){const r=H(s),i=nt(s),d=Yt(s);return{name:s.name,kind:Xi(s.kind),newEntriesDisabled:Fn(s),disableReason:r.disabledReason??"",assigneeAgentId:i.assigneeAgentId,approvalRequired:!!r.requireApproval,approval:Hi(r),approveTarget:r.approveToStageKey??"",rejectTarget:r.rejectToStageKey??"",requestChangesTarget:r.requestChangesToStageKey??"",requireRejectReason:r.requireRejectReason??!0,requireRequestChangesReason:r.requireRequestChangesReason??!0,requireChildrenTerminal:r.requireChildrenTerminal===!0,autoAdvanceOnChildrenTerminal:typeof r.autoAdvanceOnChildrenTerminal=="string"?r.autoAdvanceOnChildrenTerminal:"",breakdownEnabled:d!==null,breakdownTargetPipelineId:d?.targetPipelineId??"",breakdownTargetStageKey:d?.targetStageKey??"",breakdownPieceNoun:d?.pieceNoun??"piece",breakdownCarryOverPolicy:Zt(d?.carryOverPolicy??Xt),breakdownAdvanceTo:d?.advanceTo??"",breakdownWaitForPieces:d?.waitForPieces??!1,breakdownWhenFinishedMoveTo:d?.whenFinishedMoveTo??"",transitionTargetIds:n.filter(u=>u.fromStageId===s.id).map(u=>u.toStageId).sort(),automationProjectId:i.projectId,automationProjectWorkspaceId:i.projectWorkspaceId,automationExecutionWorkspaceId:i.executionWorkspaceId,automationExecutionWorkspacePreference:i.executionWorkspacePreference,automationExecutionWorkspaceSettings:i.executionWorkspaceSettings,automationTitleTemplate:i.titleTemplate}}a(vn,"computeStageForm");function Hi(s){const n=s.approver;return!n||!n.kind||n.kind==="any_human"?"any_human":(n.kind==="user"||n.kind==="agent")&&n.id?`${n.kind}:${n.id}`:"any_human"}a(Hi,"approvalValue");function Gi(s){if(s==="any_human")return{kind:"any_human",id:null};const[n,r]=s.split(":",2);return(n==="user"||n==="agent")&&r?{kind:n,id:r}:{kind:"any_human",id:null}}a(Gi,"parseApprovalValue");function Ui(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,60).replace(/_+$/g,"")||"stage"}a(Ui,"stageKeyFromName");function Ji(s,n){const r=Ui(s);return n.has(r)?`${r}_${Date.now().toString(36)}`:r}a(Ji,"nextStageKey");function Yi(s){return[...s?.stages??[]].sort((n,r)=>n.position-r.position)}a(Yi,"sortedStages");function Xi(s){return s==="review"||s==="done"||s==="cancelled"?s:"working"}a(Xi,"canonicalStageKind");function Zi(s,n){return n?s.find(r=>r.id!==n.id&&r.position>n.position)??null:null}a(Zi,"nextStageByPosition");function er(s,n){return s.find(r=>r.position>=n)??null}a(er,"nextStageForInsert");function On(s){return Ii}a(On,"stageNavGroups");function jn(s,n){return On(s).some(r=>r.items.some(i=>i.id===n))}a(jn,"isPipelineSettingsStageSectionAvailable");function kn(s,n,r){const i=s.find(d=>d.kind===r&&d.id!==n);return i?i.key:s.find(d=>d.id!==n)?.key??""}a(kn,"defaultReviewTarget");function wn(s){const n=new Set;return s.filter(r=>{if(r.fromStageKey===r.toStageKey)return!1;const i=`${r.fromStageKey}:${r.toStageKey}`;return n.has(i)?!1:(n.add(i),!0)})}a(wn,"dedupeEdges");function Vt(s){return s?`agent:${s}`:""}a(Vt,"stageAssigneeOptionId");function st(s){return s.startsWith("agent:")?s.slice(6):""}a(st,"stageAssigneeIdFromOption");function tr(s){return s||"any_human"}a(tr,"approverValueFromOption");var sr=new Set(["case_id","case_key","case_title","case_version","title","body","case_body"]);function nr(s){if(typeof s=="string")return s;if(typeof s=="number"||typeof s=="boolean")return String(s);if(s==null)return"";try{return JSON.stringify(s,null,2)??""}catch{return String(s)}}a(nr,"primitiveAutomationVariablePreview");function ar(s){return Array.isArray(s)?"array":s==null?"empty":typeof s}a(ar,"automationVariableKind");function ir(s){const n=nr(s.example),r=typeof s.example=="string"?`${s.example.length} chars`:`${n.length} chars`,i=[s.description,`Example: ${ar(s.example)}, ${r}`];return s.exampleSource&&i.push(`From ${s.exampleSource}`),n&&i.push(n.length>500?`${n.slice(0,500)}...`:n),i.join(`
2
2
  `)}a(ir,"automationVariablePreviewTitle");function rr(s){return s?s.case.caseKey?`${s.case.title} (${s.case.caseKey})`:s.case.title:null}a(rr,"itemExampleSource");function lr(s){const n=s.sampleRow?.case??null,r=rr(s.sampleRow),i=[{key:"pipeline_id",label:"Pipeline ID",description:"ID of the pipeline this automation runs in.",example:s.pipeline.id,exampleSource:null},{key:"pipeline_key",label:"Pipeline key",description:"Stable key of the pipeline this automation runs in.",example:s.pipeline.key,exampleSource:null},{key:"pipeline_name",label:"Pipeline name",description:"Display name of the pipeline this automation runs in.",example:s.pipeline.name,exampleSource:null},{key:"stage_id",label:"Stage ID",description:"ID of this automation stage.",example:s.stage.id,exampleSource:null},{key:"stage_key",label:"Stage key",description:"Stable key of this automation stage.",example:s.stage.key,exampleSource:null},{key:"stage_name",label:"Stage name",description:"Display name of this automation stage.",example:s.stage.name,exampleSource:null}],d=[{key:"title",label:"Item title",description:"Title of the item being automated.",example:n?.title??"",exampleSource:r},{key:"body",label:"Item body",description:"Body text of the item being automated.",example:n?.summary??"",exampleSource:r},{key:"case_id",label:"Item ID",description:"ID of the item being automated.",example:n?.id??"",exampleSource:r},{key:"case_key",label:"Item key",description:"Stable key of the item being automated.",example:n?.caseKey??"",exampleSource:r},{key:"case_title",label:"Item title alias",description:"Compatibility alias for the item title.",example:n?.title??"",exampleSource:r},{key:"case_version",label:"Item version",description:"Current item version when the automation runs.",example:n?.version??"",exampleSource:r}],u=[],y=n?.fields&&typeof n.fields=="object"&&!Array.isArray(n.fields)?n.fields:{};for(const[p,w]of Object.entries(y))Ka.has(p)||sr.has(p)||u.push({key:p,label:p.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2"),description:"Field copied from the current item data.",example:w,exampleSource:r});const h=[{id:"pipeline",label:"Pipeline and stage",variables:i},{id:"item",label:"Current item",variables:d}];return u.length>0&&h.push({id:"fields",label:"Item fields",variables:u}),h}a(lr,"buildAutomationVariableGroups");function or(s){return[...new Set(s.flatMap(n=>n.variables.map(r=>r.key)))]}a(or,"flattenAutomationVariableKeys");function T({label:s,children:n}){return(0,e.jsxs)("div",{className:"grid gap-2 py-3 text-sm sm:grid-cols-(--gtc-41) sm:items-center",children:[(0,e.jsx)("div",{className:"font-medium text-ink-3",children:s}),(0,e.jsx)("div",{className:"min-w-0",children:n})]})}a(T,"FieldRow");function cr({groups:s,onInsert:n}){return s.length===0?null:(0,e.jsxs)("div",{className:"rounded-md border border-dashed border-line bg-bg-3/25 px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:(0,e.jsx)("span",{className:"text-xs font-semibold uppercase text-ink-3",children:"Already available on child items"})}),(0,e.jsx)("div",{className:"space-y-2",children:s.map(r=>(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:[(0,e.jsx)("span",{className:"font-medium text-ink",children:r.label}),r.description?(0,e.jsxs)("span",{children:[" · ",r.description]}):null]}),(0,e.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.fields.map(i=>(0,e.jsx)("button",{type:"button",onClick:a(()=>n(i.key),"onClick"),className:"inline-flex h-7 items-center rounded-md border border-line bg-bg px-2 font-mono text-xs text-ink transition-colors hover:bg-bg-3",title:`Insert {{${i.key}}}`,"aria-label":`Insert {{${i.key}}}`,children:`{{${i.key}}}`},`${r.id}:${i.key}`))})]},r.id))})]})}a(cr,"CarriedFieldTokenHelper");function Nn({groups:s,onInsert:n,label:r="Available variables"}){return s.length===0?null:(0,e.jsxs)("div",{className:"rounded-md border border-line bg-bg-3/20 px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:(0,e.jsx)("span",{className:"text-xs font-semibold uppercase text-ink-3",children:r})}),(0,e.jsx)("div",{className:"space-y-2",children:s.map(i=>(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("p",{className:"text-xs font-medium text-ink-3",children:i.label}),(0,e.jsx)("div",{className:"flex flex-wrap gap-1.5",children:i.variables.map(d=>(0,e.jsx)("button",{type:"button",onClick:a(()=>n(d.key),"onClick"),className:"inline-flex h-7 items-center rounded-md border border-line bg-bg px-2 font-mono text-xs text-ink transition-colors hover:bg-bg-3",title:ir(d),"aria-label":`Insert {{${d.key}}}`,children:`{{${d.key}}}`},`${i.id}:${d.key}`))})]},i.id))})]})}a(Nn,"AutomationVariableTokenHelper");function dr({activeSection:s,stageKind:n,onSectionChange:r}){const i=On(n);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"md:hidden",children:[(0,e.jsx)("label",{className:"sr-only",htmlFor:"stage-section-picker",children:"Stage section"}),(0,e.jsx)("select",{id:"stage-section-picker",value:s,onChange:a(d=>r(d.target.value),"onChange"),className:"h-10 w-full rounded-md border border-line-strong bg-bg px-3 text-sm",children:i.map(d=>(0,e.jsx)("optgroup",{label:d.label,children:d.items.map(u=>(0,e.jsx)("option",{value:u.id,children:u.label},u.id))},d.label))})]}),(0,e.jsx)("nav",{"aria-label":"Stage sections",className:"sticky top-14 hidden max-h-(--sz-calc-39) w-52 shrink-0 flex-col gap-4 self-start overflow-y-auto border-r border-line bg-bg-2/30 px-3 py-4 md:flex",children:i.map(d=>(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,e.jsx)("p",{className:"px-3 py-2 text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-eyebrow) text-ink-3/80",children:d.label}),d.items.map(u=>{const y=u.icon,h=u.id===s;return(0,e.jsxs)("button",{type:"button","aria-current":h?"page":void 0,onClick:a(()=>r(u.id),"onClick"),className:_e("flex h-9 items-center gap-2 rounded-md px-3 text-left text-sm transition-colors motion-safe:duration-150",h?"bg-bg-3 text-ink":"text-ink-3 hover:bg-bg-3/50 hover:text-ink"),children:[(0,e.jsx)(y,{className:"h-3.5 w-3.5 shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:u.label})]},u.id)})]},d.label))})]})}a(dr,"StageSubSidebar");function ur({events:s,stages:n,emptyMessage:r}){return s.length===0?(0,e.jsx)(z,{icon:Cn,message:r}):(0,e.jsx)("div",{className:"overflow-hidden rounded-md border border-line",children:s.map(i=>(0,e.jsxs)("div",{className:"grid min-h-11 grid-cols-(--gtc-15) items-center gap-3 border-b border-line/70 px-3 py-2 text-sm last:border-b-0",children:[(0,e.jsx)("span",{className:"text-xs text-ink-3",title:new Date(i.createdAt).toLocaleString(),children:ja(i.createdAt)}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)(Oe,{to:`/pipelines/${i.pipeline.id}/items/${i.caseId}`,className:"font-medium text-ink hover:underline",children:i.case.title}),(0,e.jsxs)("p",{className:"mt-0.5 text-sm text-ink-3",children:[qa(i,n),i.actorAgent?` by ${i.actorAgent.name}`:null]})]})]},i.id))})}a(ur,"StageEventsList");function rl(){const{pipelineId:s}=Aa(),{selectedCompanyId:n}=$a(),{setBreadcrumbs:r}=di(),{pushToast:i}=An(),d=Ba(),[u]=Pa(),y=In(),[h,p]=(0,o.useState)("instructions"),[w,N]=(0,o.useState)(null),[P,x]=(0,o.useState)(""),[j,Ke]=(0,o.useState)("open"),[G,es]=(0,o.useState)(!1),[ts,_n]=(0,o.useState)(""),[be,ss]=(0,o.useState)(""),[A,ns]=(0,o.useState)(""),[K,Me]=(0,o.useState)(""),[F,$e]=(0,o.useState)(""),[U,ve]=(0,o.useState)(""),[Kn,je]=(0,o.useState)(null),[De,as]=(0,o.useState)("any_human"),[ie,Be]=(0,o.useState)(at),[Ve,Le]=(0,o.useState)(""),[lt,is]=(0,o.useState)([]),ot=(0,o.useRef)(null),ct=(0,o.useRef)(null),dt=(0,o.useRef)(null),[Qe,rs]=(0,o.useState)({}),[ke,ut]=(0,o.useState)(""),[we,mt]=(0,o.useState)(""),[Ne,ls]=(0,o.useState)(""),[pt,os]=(0,o.useState)(!0),[xt,cs]=(0,o.useState)(!0),[ht,ds]=(0,o.useState)(!1),[J,gt]=(0,o.useState)(""),[V,us]=(0,o.useState)(!1),[I,ms]=(0,o.useState)(""),[Y,ft]=(0,o.useState)(""),[re,ps]=(0,o.useState)("piece"),[le,xs]=(0,o.useState)(Xt),[O,yt]=(0,o.useState)(""),[oe,hs]=(0,o.useState)(!1),[M,bt]=(0,o.useState)(""),[vt,gs]=(0,o.useState)(()=>new Set),[Mn,Se]=(0,o.useState)(!1),[ze,fs]=(0,o.useState)(""),[He,ys]=(0,o.useState)(""),[jt,bs]=(0,o.useState)(""),[Ie,kt]=(0,o.useState)(!1),[vs,wt]=(0,o.useState)(""),[$n,Ge]=(0,o.useState)(!1),Ue=E({queryKey:s?v.pipelines.detail(s):["pipelines","detail","none"],queryFn:a(()=>C.get(s),"queryFn"),enabled:!!s&&!!n}),X=E({queryKey:n?v.agents.list(n):["agents","none"],queryFn:a(()=>ri.list(n),"queryFn"),enabled:!!n}),js=E({queryKey:v.auth.session,queryFn:a(()=>Ea.getSession(),"queryFn")}),Dn=E({queryKey:v.instance.experimentalSettings,queryFn:a(()=>li.getExperimental(),"queryFn"),retry:!1}),ks=E({queryKey:s?v.pipelines.health(s):["pipelines","health","none"],queryFn:a(()=>C.getHealth(s),"queryFn"),enabled:!!s&&!!n}),Nt=E({queryKey:n?v.access.companyUserDirectory(n):["access","users","none"],queryFn:a(()=>ci.listUserDirectory(n),"queryFn"),enabled:!!n}),St=E({queryKey:n?v.projects.list(n):["projects","none"],queryFn:a(()=>oi.list(n),"queryFn"),enabled:!!n}),Bn=js.data?.user?.id??js.data?.session?.userId??null,Vn=(0,o.useMemo)(()=>St.data??[],[St.data]),{orderedProjects:ce}=xi({projects:Vn,companyId:n,userId:Bn}),ws=E({queryKey:n?v.secrets.list(n):["secrets","none"],queryFn:a(()=>mn.list(n),"queryFn"),enabled:!!n}),Ln=B({mutationFn:a(t=>{if(!n)throw new Error("Select an organization to create secrets");return mn.create(n,t)},"mutationFn"),onSuccess:a(()=>{n&&y.invalidateQueries({queryKey:v.secrets.list(n)})},"onSuccess")}),Ce=E({queryKey:n?v.pipelines.list(n):["pipelines","none"],queryFn:a(()=>C.list(n),"queryFn"),enabled:!!n}),Ns=E({queryKey:s?v.pipelines.cases(s):["pipelines","cases","none-settings"],queryFn:a(()=>C.listCases(s),"queryFn"),enabled:!!n&&!!s}),It=E({queryKey:I?v.pipelines.intakeForm(I):["pipelines","intake-form","none-breakdown"],queryFn:a(()=>C.getIntakeForm(I),"queryFn"),enabled:!!n&&!!I}),g=Ue.data??null,b=(0,o.useMemo)(()=>Yi(g),[g]),c=b.find(t=>t.id===w)??b[0]??null,Ct=(0,o.useMemo)(()=>Qi(g,c,Ce.data??[]),[g,Ce.data,c]),Ss=(0,o.useMemo)(()=>[...new Set(Jt(Ct).map(t=>t.key))],[Ct]),Is=(0,o.useMemo)(()=>{const t=Ns.data??[];return t.find(l=>l.case.stageId===c?.id)??t[0]??null},[Ns.data,c?.id]),Je=(0,o.useMemo)(()=>g&&c?lr({pipeline:g,stage:c,sampleRow:Is}):[],[g,Is,c]),Cs=(0,o.useMemo)(()=>or(Je),[Je]),Tt=(0,o.useMemo)(()=>[...new Set([...Ss,...Cs])],[Cs,Ss]),Ts=(0,o.useCallback)(t=>{const l=`{{${t}}}`;if(dt.current){dt.current.insertMarkdown(l);return}Le(m=>`${m}${m?" ":""}${l}`)},[]),Qn=(0,o.useCallback)(t=>{const l=`{{${t}}}`;Be(m=>{const k=ot.current;if(!k)return`${m}${m?" ":""}${l}`;const S=k.selectionStart??m.length,W=k.selectionEnd??S,ne=`${m.slice(0,S)}${l}${m.slice(W)}`;return ct.current=S+l.length,ne})},[]);(0,o.useLayoutEffect)(()=>{const t=ct.current;if(t==null)return;ct.current=null;const l=ot.current;l&&(l.focus(),l.setSelectionRange(t,t))},[ie]);const $=c?Pi(c.id):null,Te=E({queryKey:s&&$?v.pipelines.document(s,$):["pipelines","document","none-stage"],queryFn:a(async()=>{try{return await C.getDocument(s,$)}catch(t){if(t instanceof Lt&&t.status===404)return null;throw t}},"queryFn"),enabled:!!s&&!!$&&!!n}).data??null,Z=Te?nt(c).instructionsBody??Te.revision?.body??Te.document?.latestBody??"":nt(c).instructionsBody??H(c).whatHappensHere??"",ee=nt(c).titleTemplate,Ae=(0,o.useMemo)(()=>_i(c,ee,Z),[c,Z,ee]);(0,o.useMemo)(()=>Mi(Ae,[ee,Z]),[Z,Ae,ee]);const zn=Fa({companyId:n,agents:X.data,projects:St.data,members:Nt.data?.users}),de=(0,o.useMemo)(()=>mi(),[]),As=(0,o.useMemo)(()=>de.map(Vt),[de]),Hn=(0,o.useMemo)(()=>pn((X.data??[]).filter(fn),de).map(t=>({id:Vt(t.id),label:t.name,searchText:`${t.name} ${t.role} ${t.title??""}`})),[X.data,de]),Gn=(0,o.useMemo)(()=>gi(),[]),Un=(0,o.useMemo)(()=>ce.map(t=>({id:t.id,label:t.name,searchText:t.description??""})),[ce]),R=(0,o.useMemo)(()=>ce.find(t=>t.id===A)??null,[ce,A]),Jn=(0,o.useMemo)(()=>R?.workspaces.find(t=>t.id===K)??null,[R,K]),{visible:Ye}=vi(),Xe=Ye&&Dn.data?.enableIsolatedWorkspaces===!0&&!!R?.executionWorkspacePolicy?.enabled,Ps=E({queryKey:n&&A?v.executionWorkspaces.summaryList(n,{projectId:A,projectWorkspaceId:K||void 0,reuseEligible:!0}):["execution-workspaces","summary","none-pipeline-stage"],queryFn:a(()=>yi.listSummaries(n,{projectId:A,projectWorkspaceId:K||void 0,reuseEligible:!0}),"queryFn"),enabled:!!n&&!!A&&Xe&&F==="reuse_existing"}),Ze=(0,o.useMemo)(()=>pi(Ps.data??[]),[Ps.data]),Pe=(0,o.useMemo)(()=>Ze.find(t=>t.id===U)??null,[Ze,U]),Yn=(0,o.useMemo)(()=>[...bi(Nt.data?.users),...pn((X.data??[]).filter(fn),de).map(t=>({id:`agent:${t.id}`,label:t.name,searchText:`${t.name} ${t.role} ${t.title??""}`}))],[X.data,de,Nt.data?.users]),ue=(0,o.useMemo)(()=>new Map((X.data??[]).map(t=>[t.id,t])),[X.data]),Es=(0,o.useMemo)(()=>Ma(ks.data?.warnings??[]),[ks.data?.warnings]),At=E({queryKey:n&&s&&c?["pipelines","stage-events",n,s,c.id]:["pipelines","stage-events","none"],queryFn:a(()=>C.listCompanyCaseEvents(n,{limit:75}),"queryFn"),enabled:!!n&&!!s&&!!c&&h==="activity"}),Xn=(0,o.useMemo)(()=>!c||!s?[]:(At.data?.items??[]).filter(t=>t.pipeline.id===s&&(t.fromStageId===c.id||t.toStageId===c.id||t.automation?.stage?.id===c.id)),[s,c,At.data?.items]);(0,o.useEffect)(()=>{g&&r([{label:"Pipelines",href:"/pipelines"},{label:g.name,href:`/pipelines/${g.id}`},{label:"Settings"}])},[g,r]);const me=u.get("stage"),Fs=!!(me&&b.some(t=>t.id===me)),Ee=Ti(u.get("section")),Pt=Ai(b,w,me);(0,o.useEffect)(()=>{me&&Fs&&N(me)},[Fs,me]),(0,o.useEffect)(()=>{Pt&&N(Pt)},[Pt]),(0,o.useEffect)(()=>{if(!c)return;const t=vn(c,g?.transitions??[]);x(t.name),Ke(t.kind),es(t.newEntriesDisabled),_n(t.disableReason),ss(t.assigneeAgentId),ns(t.automationProjectId),Me(t.automationProjectWorkspaceId),$e(t.automationExecutionWorkspacePreference),ve(t.automationExecutionWorkspaceId),je(t.automationExecutionWorkspaceSettings),Be(t.automationTitleTemplate),as(t.approval),ut(t.approveTarget),mt(t.rejectTarget),ls(t.requestChangesTarget),os(t.requireRejectReason),cs(t.requireRequestChangesReason),ds(t.requireChildrenTerminal),gt(t.autoAdvanceOnChildrenTerminal),us(t.breakdownEnabled),ms(t.breakdownTargetPipelineId),ft(t.breakdownTargetStageKey),ps(t.breakdownPieceNoun),xs(t.breakdownCarryOverPolicy),yt(t.breakdownAdvanceTo),hs(t.breakdownWaitForPieces),bt(t.breakdownWhenFinishedMoveTo),gs(new Set(t.transitionTargetIds))},[g?.transitions,c]),(0,o.useEffect)(()=>{!A||!R||(K||Me(gn(R)),Ye&&!F&&$e(xn(R)))},[R,Ye,F,A,K]),(0,o.useEffect)(()=>{c&&Ee&&jn(c.kind,Ee)&&p(Ee)},[Ee,c?.id,c?.kind]),(0,o.useEffect)(()=>{c&&(jn(c.kind,h)||p("instructions"))},[h,Ee,c]),(0,o.useEffect)(()=>{Be(ee),Le(Z),is(Ae)},[c?.id,Z,Ae,ee]);const Rs=Dt(c).env,Ws=JSON.stringify(Rs??{});(0,o.useEffect)(()=>{rs(Rs??{})},[c?.id,Ws]),(0,o.useEffect)(()=>{Se(!1),fs(b.find(t=>t.id!==c?.id)?.id??"")},[c?.id,b]),(0,o.useEffect)(()=>{g&&(ys(g.name),bs(g.description??""),kt(g.enforceTransitions))},[g]);const te=a(async()=>{s&&(await y.invalidateQueries({queryKey:v.pipelines.detail(s)}),await y.invalidateQueries({queryKey:v.pipelines.intakeForm(s)}),await y.invalidateQueries({queryKey:v.pipelines.health(s)}))},"refreshPipeline"),_=B({mutationFn:a(async()=>{if(!s||!c||!g)return null;if(A&&Xe&&F==="reuse_existing"&&!U)throw new Error("Choose an existing workspace before saving this stage.");const t=Gi(De),l=j==="review",m={...H(c),variables:Bt(lt,Tt),disabled:G,disabledReason:G&&ts.trim()||null,automation:Oi({assigneeAgentId:be,titleTemplate:ie,instructionsBody:Ve,projectId:A,projectWorkspaceId:K,executionWorkspaceId:U,executionWorkspacePreference:F,executionWorkspaceSettings:_s}),requireApproval:l,approver:l&&t.kind!=="any_human"?{kind:t.kind,id:t.id}:{kind:"any_human"},requireChildrenTerminal:ht};J?m.autoAdvanceOnChildrenTerminal=J:delete m.autoAdvanceOnChildrenTerminal,V&&I&&Y?(m.breakdown={targetPipelineId:I,targetStageKey:Y,pieceNoun:re.trim()||"piece",carryOverPolicy:bn(le,Fe),inheritFields:zi(le,Fe),waitForPieces:oe,...O?{advanceTo:O}:{},...oe&&M?{whenFinishedMoveTo:M}:{}},delete m.requireChildrenTerminal,delete m.autoAdvanceOnChildrenTerminal):delete m.breakdown,delete m.reviewerKind,j==="review"&&(m.approveToStageKey=ke,m.rejectToStageKey=we,Ne?m.requestChangesToStageKey=Ne:delete m.requestChangesToStageKey,m.requireRejectReason=pt,m.requireRequestChangesReason=xt);const k=new Map(b.map(f=>[f.id,f.key])),S=g.transitions??[],W=S.filter(f=>f.fromStageId!==c.id).flatMap(f=>{const Q=k.get(f.fromStageId),ae=k.get(f.toStageId);return!Q||!ae?[]:[{fromStageKey:Q,toStageKey:ae,label:f.label??null}]}),ne=new Map(b.map(f=>[f.key,f.id])),D=new Set(j==="review"?[ke,we,Ne].map(f=>ne.get(f)).filter(f=>!!f):Ie?vt:[]);for(const f of b)f.kind==="cancelled"&&f.id!==c.id&&D.add(f.id);const Re=[...D].flatMap(f=>{const Q=k.get(f);if(!Q)return[];const ae=S.find(Ys=>Ys.fromStageId===c.id&&Ys.toStageId===f);return[{fromStageKey:c.key,toStageKey:Q,label:ae?.label??null}]});return await C.updateStage(s,c.id,{name:P.trim(),kind:j,config:m}),(j==="review"||Ie)&&await C.setTransitions(s,{transitions:wn([...W,...Re])}),null},"mutationFn"),onSuccess:a(async()=>{s&&$&&await Promise.all([y.invalidateQueries({queryKey:v.pipelines.document(s,$)}),y.invalidateQueries({queryKey:v.pipelines.documentRevisions(s,$)})]),await te(),i({title:"Stage saved",tone:"success"})},"onSuccess"),onError:a(async t=>{i({title:"Failed to save stage",body:t instanceof Error?t.message:"Wardmote could not save the stage.",tone:"error"})},"onError")}),qs=B({mutationFn:a(async()=>{if(!s||!c)return null;const t=Dt(c),l=Object.keys(Qe).length>0?Qe:null;return await C.updateStageAutomationEnv(s,c.id,{env:l,baseRoutineRevisionId:t.latestRoutineRevisionId}),null},"mutationFn"),onSuccess:a(async()=>{await te(),n&&await y.invalidateQueries({queryKey:v.secrets.list(n)}),i({title:"Stage secrets saved",tone:"success"})},"onSuccess"),onError:a(async t=>{i({title:"Failed to save secrets",body:t instanceof Lt||t instanceof Error?t.message:"Wardmote could not save the stage secrets.",tone:"error"})},"onError")}),Et=B({mutationFn:a(async t=>{if(!s||!g)return null;const l=b[b.length-1]??null,m=t?t.position+1:l?l.position+100:100,k=t?b.find(D=>D.position>t.position)??null:null,S=new Set(b.map(D=>D.key)),W=er(b,m),ne=await C.createStage(s,{key:Ji("New stage",S),name:"New stage",kind:"working",position:m,config:{variables:[],requireChildrenTerminal:!0,...W?{autoAdvanceOnChildrenTerminal:W.key}:{}}});if(t){const D=new Map(b.map(f=>[f.id,f.key])),Re=(g.transitions??[]).filter(f=>!(k&&f.fromStageId===t.id&&f.toStageId===k.id)).flatMap(f=>{const Q=D.get(f.fromStageId),ae=D.get(f.toStageId);return!Q||!ae?[]:[{fromStageKey:Q,toStageKey:ae,label:f.label??null}]});Re.push({fromStageKey:t.key,toStageKey:ne.key,label:null}),k&&Re.push({fromStageKey:ne.key,toStageKey:k.key,label:null}),await C.setTransitions(s,{transitions:wn(Re)})}return ne},"mutationFn"),onSuccess:a(async t=>{await te(),t&&N(t.id),i({title:"Stage added",tone:"success"})},"onSuccess")}),pe=B({mutationFn:a(async()=>!s||!c?null:C.deleteStage(s,c.id,{moveCasesToStageId:ze||null}),"mutationFn"),onSuccess:a(async()=>{const t=ze||(b.find(l=>l.id!==c?.id)?.id??null);Se(!1),N(t),await te(),n&&await y.invalidateQueries({queryKey:v.pipelines.list(n)}),i({title:"Stage deleted",tone:"success"})},"onSuccess"),onError:a(t=>{i({title:"Failed to delete stage",body:t instanceof Error?t.message:"Wardmote could not delete the stage.",tone:"error"})},"onError")}),xe=B({mutationFn:a(()=>C.update(s,{name:He.trim(),description:jt.trim()||null}),"mutationFn"),onSuccess:a(async()=>{await te(),n&&await y.invalidateQueries({queryKey:v.pipelines.list(n)}),i({title:"Pipeline updated",tone:"success"})},"onSuccess")}),Os=B({mutationFn:a(t=>C.update(s,{enforceTransitions:t}),"mutationFn"),onSuccess:a(async()=>{await te(),i({title:"Transition rules updated",tone:"success"})},"onSuccess"),onError:a(t=>{kt(g?.enforceTransitions??!1),i({title:"Failed to update transition rules",body:t instanceof Error?t.message:"Wardmote could not update transition rules.",tone:"error"})},"onError")}),se=B({mutationFn:a(t=>C.update(s,{archived:t}),"mutationFn"),onSuccess:a(async(t,l)=>{Ge(!1),wt(""),n&&await y.invalidateQueries({queryKey:v.pipelines.list(n)}),l?d("/pipelines"):(await te(),i({title:"Pipeline restored",tone:"success"}))},"onSuccess")}),Zn=a(t=>{Ke(t),t==="review"&&(ut(l=>l||kn(b,c?.id??null,"done")),mt(l=>l||kn(b,c?.id??null,"cancelled")))},"setStageKindWithDefaults"),ea=a(t=>{t&&fi(t);const l=ce.find(m=>m.id===t);ns(t),Me(gn(l)),$e(l&&Ye?xn(l):""),ve(""),je(null)},"handleAutomationProjectChange"),ta=a(t=>{Me(t),ve(""),je(null)},"handleAutomationProjectWorkspaceChange"),sa=a(t=>{const l=Ut(t);$e(l),je(null),l!=="reuse_existing"&&ve("")},"handleAutomationExecutionWorkspacePreferenceChange"),na=a(t=>{ve(t);const l=Ze.find(m=>m.id===t)??null;je(yn("reuse_existing",l))},"handleAutomationExecutionWorkspaceIdChange"),aa=a(t=>{p(t);const l=new URLSearchParams(u);c?.id&&l.set("stage",c.id),l.set("section",t),d(`/pipelines/${s}/settings?${l.toString()}`,{replace:!0})},"handleStageSectionChange");if(!n)return(0,e.jsx)(z,{icon:_t,message:"Select an organization to edit pipeline settings."});if(!s)return(0,e.jsx)(z,{icon:_t,message:"No pipeline selected."});if(Ue.isLoading)return(0,e.jsx)(hn,{variant:"list"});if(Ue.error)return(0,e.jsx)("p",{className:"text-sm text-bad",children:Ue.error.message});if(!g)return(0,e.jsx)(z,{icon:_t,message:"Pipeline not found."});const ia=!!g.archivedAt,ra=vs===g.name&&!se.isPending,la=He!==g.name||jt!==(g.description??""),Ft=j==="review"&&(!ke||!we),he=b.filter(t=>t.id!==c?.id),oa=j==="review",Rt=Zi(b,c)??he[0]??null,_s=A&&F?Kn??yn(F,Pe):null,Wt=!Xe||F!=="reuse_existing"||!!U,Ks=c?vn(c,g.transitions??[]):null,Ms=c?{name:P,kind:j,newEntriesDisabled:G,disableReason:ts,assigneeAgentId:be,approvalRequired:j==="review",approval:De,approveTarget:ke,rejectTarget:we,requestChangesTarget:Ne,requireRejectReason:pt,requireRequestChangesReason:xt,requireChildrenTerminal:ht,autoAdvanceOnChildrenTerminal:J,breakdownEnabled:V,breakdownTargetPipelineId:I,breakdownTargetStageKey:Y,breakdownPieceNoun:re,breakdownCarryOverPolicy:le,breakdownAdvanceTo:O,breakdownWaitForPieces:oe,breakdownWhenFinishedMoveTo:M,transitionTargetIds:[...vt].sort(),automationProjectId:A,automationProjectWorkspaceId:A?K:"",automationExecutionWorkspaceId:A&&F==="reuse_existing"?U:"",automationExecutionWorkspacePreference:A?F:"",automationExecutionWorkspaceSettings:_s,automationTitleTemplate:it(ie)}:null,qt=$t.find(t=>t.value===j)??$t[0],ca=qt.icon,da=c!=null&&it(ie)!==ee,ua=c!=null&&Ve!==Z,ma=c!=null&&JSON.stringify(Bt(Ki(lt),Tt))!==JSON.stringify(Bt(Ae,Tt)),Ot=be?ue.get(be)??null:null,pa=c!=null&&JSON.stringify(Qe)!==Ws,xa=Ks!=null&&Ms!=null&&JSON.stringify(Ks)!==JSON.stringify(Ms)||da||ua||ma,$s=(Ce.data??[]).filter(t=>t.id!==s&&!t.archivedAt),L=$s.find(t=>t.id===I)??(Ce.data??[]).find(t=>t.id===I)??null,Ds=[...L?.stages??[]].sort((t,l)=>t.position-l.position),Bs=Ds.find(t=>t.key===Y)??null,et=Wn(g,Ce.data??[]),Fe=Jt(et),Vs=Fe.filter(t=>zt(le,t.key)),ha=new Map((It.data?.fields??[]).map(t=>[t.key,t])),Ls=It.data?.stageName??Bs?.name??null,Qs=It.data?.stageId??null,ga=!!L?.archivedAt,zs=I?`/pipelines/${I}/settings${Qs?`?stage=${Qs}`:""}`:null,Hs=Wa(re),Gs=new Map(b.map(t=>[t.key,t.name])),Us={targetPipelineName:L?.name??"",entryStageName:Bs?.name??Y,advanceToName:O?Gs.get(O)??O:null,whenFinishedName:M?Gs.get(M)??M:null,inheritedFieldLabels:Vs.map(t=>t.label)},fa={targetPipelineId:I,targetStageKey:Y,pieceNoun:re.trim()||"piece",inheritFields:Vs.map(t=>t.key),carryOverPolicy:bn(le,Fe),advanceTo:O||null,waitForPieces:oe,whenFinishedMoveTo:M||null},Js=V?Oa(fa,Us):null,ya=!oa&&!We(j)?(0,e.jsx)(T,{label:"Allowed next steps",children:(0,e.jsx)("div",{className:"space-y-2",children:he.map(t=>{const l=t.kind==="cancelled",m=l||vt.has(t.id);return(0,e.jsxs)("label",{className:_e("flex items-center gap-2 rounded-md border border-line px-3 py-2 text-sm",l&&"text-ink-3"),children:[(0,e.jsx)("input",{type:"checkbox",checked:m,disabled:l,onChange:a(k=>{l||gs(S=>{const W=new Set(S);return k.target.checked?W.add(t.id):W.delete(t.id),W})},"onChange")}),(0,e.jsx)("span",{className:"flex-1",children:t.name}),l?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Always available"}):null]},t.id)})})}):null,ba=We(j)?null:(0,e.jsxs)("div",{className:"rounded-lg border border-line",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-4 border-b border-line p-4",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"Break into smaller pieces"}),(0,e.jsx)("p",{className:"max-w-md text-sm text-ink-3",children:"The agent decides what the pieces are. Wardmote creates and tracks them."})]}),(0,e.jsx)(ge,{"aria-label":"Break into smaller pieces",checked:V,onCheckedChange:a(t=>{us(t),t&&!O&&yt(Rt?.key??"")},"onCheckedChange")})]}),V?(0,e.jsxs)("div",{className:"divide-y divide-line px-4",children:[(0,e.jsx)(T,{label:"Create each piece in",children:(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex w-full max-w-sm items-center",children:[(0,e.jsxs)("select",{"aria-label":"Create each piece in",value:I,onChange:a(t=>{ms(t.target.value),ft("")},"onChange"),className:"h-10 min-w-0 flex-1 rounded-md border border-line-strong bg-bg px-3 text-sm",children:[(0,e.jsx)("option",{value:"",children:"Choose a pipeline"}),$s.map(t=>(0,e.jsx)("option",{value:t.id,children:t.name},t.id))]}),I?(0,e.jsx)(Oe,{to:`/pipelines/${I}`,"aria-label":`Open ${L?.name??"selected"} pipeline`,title:`Open ${L?.name??"selected"} pipeline`,className:"ml-2 inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-ink-3 hover:bg-bg-3 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:(0,e.jsx)(Kt,{className:"h-4 w-4"})}):null]}),I?null:(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"A pipeline in this workspace"})]})}),(0,e.jsx)(T,{label:"starting at",children:(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("select",{"aria-label":"Starting stage for each piece",value:Y,onChange:a(t=>ft(t.target.value),"onChange"),disabled:!I,className:"h-10 w-full max-w-sm rounded-md border border-line-strong bg-bg px-3 text-sm disabled:opacity-50",children:[(0,e.jsx)("option",{value:"",children:"Choose a stage"}),Ds.map(t=>(0,e.jsx)("option",{value:t.key,children:t.name},t.id))]}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"The stage every new piece starts in"})]})}),(0,e.jsx)(T,{label:"Call each piece a",children:(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(qe,{"aria-label":"Call each piece a",value:re,onChange:a(t=>ps(t.target.value),"onChange"),placeholder:"piece",className:"h-10 w-full max-w-sm"}),(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Drives copy on this case (e.g. “3 of 5 ",Hs," finished”)"]})]})}),(0,e.jsx)(T,{label:"Carry over",children:(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"space-y-1 rounded-md border border-dashed border-line bg-bg-3/30 px-3 py-2 text-xs",children:[(0,e.jsx)("p",{className:"text-ink-3",children:"Values are copied from this item and its ancestors. New eligible fields stay on unless you uncheck them."}),I?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-1 text-ink-3",children:[(0,e.jsx)("span",{children:"Destination validation:"}),(0,e.jsx)("span",{className:"font-medium text-ink",children:L?.name??"selected pipeline"}),Ls?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{"aria-hidden":!0,children:"·"}),(0,e.jsx)("span",{className:"font-medium text-ink",children:Ls})]}):null]}):null,zs?(0,e.jsxs)(Oe,{to:zs,className:"inline-flex items-center gap-1 font-medium text-accent hover:underline",children:["Review destination fields",(0,e.jsx)(Kt,{className:"h-3 w-3"})]}):null,ga?(0,e.jsxs)("p",{className:"flex items-center gap-1 text-amber-700 dark:text-amber-300",children:[(0,e.jsx)(tt,{className:"h-3 w-3 shrink-0"}),"This destination pipeline is archived, so its validation fields can't be edited until it's restored."]}):null]}),et.length>0?(0,e.jsx)("div",{className:"space-y-3",children:et.map(t=>(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"text-xs font-medium text-ink-3",children:[t.label,t.description?(0,e.jsxs)("span",{className:"ml-1 font-normal",children:["· ",t.description]}):null]}),(0,e.jsx)("div",{className:"space-y-1.5",children:t.fields.map(l=>{const m=zt(le,l.key),k=ha.get(l.key);return(0,e.jsxs)("label",{className:"flex items-center gap-2 rounded-md border border-line px-3 py-2 text-sm",children:[(0,e.jsx)("input",{type:"checkbox",checked:m,onChange:a(S=>{xs(W=>Li(W,Fe,l.key,S.target.checked))},"onChange")}),(0,e.jsx)("span",{className:"flex-1",children:l.label}),k?.required?(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:["Required by ",L?.name??"destination"]}):k?(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:["Validated by ",L?.name??"destination"]}):null]},`${t.id}:${l.key}`)})})]},t.id))}):null,et.length===0?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"This pipeline and its ancestors do not define any fields that can be carried over yet."}):null,(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Name and title fields are kept unique for each new ",re.trim()||"piece","."]})]})}),(0,e.jsx)(T,{label:"Then move this case to",children:(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("select",{"aria-label":"Then move this case to",value:O,onChange:a(t=>yt(t.target.value),"onChange"),className:"h-10 w-full max-w-sm rounded-md border border-line-strong bg-bg px-3 text-sm",children:[(0,e.jsx)("option",{value:"",children:"Stay on this step"}),he.map(t=>(0,e.jsx)("option",{value:t.key,children:t.name},t.id))]}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"As soon as the pieces are created"})]})}),(0,e.jsx)(T,{label:"Wait",children:(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("label",{className:"flex items-start gap-2 text-sm",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:oe,onChange:a(t=>{const l=t.target.checked;hs(l),l&&!M&&bt(O||Rt?.key||"")},"onChange")}),(0,e.jsxs)("span",{className:"font-medium text-ink",children:["Wait until all ",Hs," are finished, then move it to"]})]}),(0,e.jsxs)("select",{"aria-label":"Move this case when all pieces finish",value:M,onChange:a(t=>bt(t.target.value),"onChange"),disabled:!oe,className:"h-10 w-full max-w-sm rounded-md border border-line-strong bg-bg px-3 text-sm disabled:opacity-50",children:[(0,e.jsx)("option",{value:"",children:"Choose a stage"}),he.map(t=>(0,e.jsx)("option",{value:t.key,children:t.name},t.id))]}),O?(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["If nothing is worth splitting, this case still moves to ",Us.advanceToName,"."]}):null]})}),Js?(0,e.jsx)("div",{className:"py-4",children:(0,e.jsx)("p",{className:"rounded-md bg-bg-3/40 p-3 text-sm text-ink-3",children:Js})}):null]}):null]});return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("form",{className:"border-b border-line pb-5",onSubmit:a(t=>{t.preventDefault(),xe.mutate()},"onSubmit"),children:[(0,e.jsxs)("div",{className:"mb-3 flex items-start justify-between gap-3",children:[(0,e.jsx)(Oe,{to:`/pipelines/${g.id}`,className:"text-sm text-ink-3 hover:text-ink",children:"Back to board"}),(0,e.jsxs)(tn,{children:[(0,e.jsx)(Zs,{asChild:!0,children:(0,e.jsx)(q,{type:"button",variant:"secondary",size:"icon",className:"h-8 w-8",title:"Pipeline actions",children:(0,e.jsx)(ti,{className:"h-4 w-4"})})}),(0,e.jsx)(en,{align:"end",children:ia?(0,e.jsxs)(Xs,{onSelect:a(()=>se.mutate(!1),"onSelect"),children:[(0,e.jsx)(tt,{className:"h-4 w-4"}),"Restore pipeline"]}):(0,e.jsxs)(Xs,{variant:"destructive",onSelect:a(()=>Ge(!0),"onSelect"),children:[(0,e.jsx)(tt,{className:"h-4 w-4"}),"Archive pipeline"]})})]})]}),(0,e.jsxs)("div",{className:"grid gap-3 md:grid-cols-(--gtc-13) md:items-end",children:[(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,e.jsx)("span",{className:"sr-only",children:"Pipeline name"}),(0,e.jsx)(qe,{"aria-label":"Pipeline name",value:He,onChange:a(t=>ys(t.target.value),"onChange"),required:!0,className:"h-auto border-0 bg-transparent px-0 py-0 text-2xl font-semibold tracking-normal shadow-none focus-visible:ring-0"})]}),(0,e.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,e.jsx)("span",{className:"sr-only",children:"Pipeline description"}),(0,e.jsx)(ui,{"aria-label":"Pipeline description",value:jt,onChange:a(t=>bs(t.target.value),"onChange"),rows:2,placeholder:"Add a description",className:"min-h-0 resize-none border-0 bg-transparent px-0 py-0 text-sm text-ink-3 shadow-none focus-visible:ring-0"})]})]}),la||xe.isPending?(0,e.jsxs)(q,{type:"submit",disabled:xe.isPending||!He.trim(),children:[(0,e.jsx)(Gt,{className:"h-4 w-4"}),xe.isPending?"Saving...":"Save details"]}):null]}),xe.error?(0,e.jsx)("p",{className:"mt-3 text-sm text-bad",children:xe.error.message}):null]}),(0,e.jsxs)("div",{className:"space-y-6",children:[b.length===0?(0,e.jsx)(z,{icon:La,message:"No stages configured.",action:"Add first stage",onAction:a(()=>Et.mutate(null),"onAction")}):(0,e.jsx)("div",{className:"overflow-x-auto border-y border-line py-4",children:(0,e.jsx)("div",{className:"flex min-w-max items-center gap-2",children:b.map((t,l)=>{const m=Es[t.id]?.length??0,k=!We(t.kind),S=_a(t.kind);return(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex flex-col items-start gap-1",children:[(0,e.jsxs)("button",{type:"button","aria-label":m>0?`${t.name}, ${m} ${m===1?"warning":"warnings"}`:t.name,className:_e("min-h-20 w-48 rounded-md border px-3 py-2 text-left text-sm transition-colors",S.outer,c?.id===t.id?"ring-2 ring-ink/25":"hover:ring-1 hover:ring-ink/10"),onClick:a(()=>N(t.id),"onClick"),children:[(0,e.jsxs)("span",{className:"flex items-start justify-between gap-2",children:[(0,e.jsx)("span",{className:"min-w-0 flex-1 font-semibold text-ink",children:t.name}),m>0?(0,e.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs font-semibold text-amber-700 dark:text-amber-300",children:[(0,e.jsx)(an,{className:"h-3.5 w-3.5"}),m," ",m===1?"warning":"warnings"]}):null]}),(0,e.jsxs)("span",{className:"mt-1 block text-xs text-ink-3",children:["Step ",l+1]}),Fn(t)?(0,e.jsxs)("span",{className:"mt-2 inline-flex items-center gap-1 text-xs font-medium text-amber-700 dark:text-amber-300",children:[(0,e.jsx)(an,{className:"h-3 w-3"}),"New entries paused"]}):null]}),(0,e.jsxs)(Oe,{to:`/pipelines/${s}`,className:"inline-flex items-center gap-1 text-xs font-medium text-ink-3 hover:text-ink hover:underline",children:["View queue",(0,e.jsx)(Kt,{className:"h-3 w-3","aria-hidden":"true"})]})]}),k?(0,e.jsx)("button",{type:"button","aria-label":`Insert stage after ${t.name}`,className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-dashed border-line text-ink-3 hover:border-ink hover:text-ink",onClick:a(()=>Et.mutate(t),"onClick"),disabled:Et.isPending,children:(0,e.jsx)(ni,{className:"h-4 w-4"})}):null,l===b.length-1?null:(0,e.jsx)("span",{className:"h-px w-8 bg-line","aria-hidden":"true"})]},t.id)})})}),c?(0,e.jsxs)("form",{className:"space-y-5",onSubmit:a(t=>{t.preventDefault(),_.mutate()},"onSubmit"),children:[(0,e.jsxs)("div",{className:"flex flex-col gap-5 md:flex-row md:gap-0",children:[(0,e.jsx)(dr,{activeSection:h,stageKind:j,onSectionChange:aa}),(0,e.jsxs)("div",{className:"min-w-0 flex-1 md:px-8",children:[(0,e.jsxs)("div",{className:"mb-4 flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold text-ink",children:Ci[h]}),h==="instructions"?(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(q,{type:"button",variant:"secondary",size:"icon",className:_e("h-8 w-8",G&&" "),title:G?"Resume new entries":"Pause new entries","aria-label":G?"Resume new entries":"Pause new entries",onClick:a(()=>es(t=>!t),"onClick"),children:G?(0,e.jsx)(si,{className:"h-4 w-4"}):(0,e.jsx)(sn,{className:"h-4 w-4"})}),(0,e.jsx)(q,{type:"button",variant:"danger",size:"icon",className:"h-8 w-8",title:`Delete ${c.name}`,"aria-label":`Delete ${c.name}`,onClick:a(()=>Se(!0),"onClick"),children:(0,e.jsx)(nn,{className:"h-4 w-4"})})]}):null]}),(0,e.jsx)(Ra,{className:"mb-4",warnings:Es[c.id]??[]}),h==="instructions"?(0,e.jsx)("div",{className:"w-full max-w-3xl",children:(0,e.jsxs)("div",{className:"divide-y divide-line border-b border-line",children:[(0,e.jsx)(T,{label:"Name",children:(0,e.jsx)(qe,{value:P,onChange:a(t=>x(t.target.value),"onChange"),required:!0})}),(0,e.jsx)(T,{label:"Step type",children:(0,e.jsxs)("div",{className:"max-w-xl space-y-2",children:[(0,e.jsxs)(tn,{children:[(0,e.jsx)(Zs,{asChild:!0,children:(0,e.jsxs)(q,{type:"button",variant:"secondary","aria-label":"Step type",className:"h-auto min-h-10 w-full justify-between whitespace-normal px-3 py-2 text-left",children:[(0,e.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(ca,{className:"h-4 w-4 shrink-0 text-ink-3"}),(0,e.jsx)("span",{className:"truncate",children:qt.label})]}),(0,e.jsx)(Tn,{className:"h-4 w-4 shrink-0 text-ink-3"})]})}),(0,e.jsx)(en,{align:"start",className:"w-(--sz-calc-40)",children:(0,e.jsx)(Ga,{value:j,onValueChange:Zn,children:$t.map(t=>{const l=t.icon;return(0,e.jsxs)(Ua,{value:t.value,className:"items-start gap-3 py-2.5",children:[(0,e.jsx)(l,{className:"mt-0.5 h-4 w-4 shrink-0 text-ink-3"}),(0,e.jsxs)("span",{className:"min-w-0",children:[(0,e.jsx)("span",{className:"block font-medium text-ink",children:t.label}),(0,e.jsx)("span",{className:"mt-0.5 block text-xs leading-5 text-ink-3",children:t.description})]})]},t.value)})})})]}),(0,e.jsx)("p",{className:"text-sm leading-6 text-ink-3",children:qt.description})]})}),j==="review"?(0,e.jsx)(T,{label:"Approver",children:(0,e.jsx)(Mt,{value:De==="any_human"?"":De,options:Yn,recentOptionIds:As,placeholder:"Approver",noneLabel:"Any human",searchPlaceholder:"Search approvers...",emptyMessage:"No approvers found.",onChange:a(t=>as(tr(t)),"onChange"),renderTriggerValue:a(t=>{if(!t)return(0,e.jsx)("span",{className:"text-ink-3",children:"Any human"});const l=t.id.startsWith("agent:")?ue.get(t.id.slice(6)):null;return(0,e.jsxs)(e.Fragment,{children:[l?(0,e.jsx)(fe,{agent:l,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):null,(0,e.jsx)("span",{className:"truncate",children:t.label})]})},"renderTriggerValue"),renderOption:a(t=>{if(!t.id)return(0,e.jsx)("span",{className:"truncate",children:t.label});const l=t.id.startsWith("agent:")?ue.get(t.id.slice(6)):null;return(0,e.jsxs)(e.Fragment,{children:[l?(0,e.jsx)(fe,{agent:l,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):null,(0,e.jsx)("span",{className:"truncate",children:t.label})]})},"renderOption")})}):null,j==="review"?(0,e.jsxs)(T,{label:"Review outcomes",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[[["Approved items move to",ke,ut,"Choose a stage"],["Declined items move to",we,mt,"Choose a stage"],["Items needing changes move to",Ne,ls,"Stay in review"]].map(([t,l,m,k])=>(0,e.jsxs)("div",{className:"grid grid-cols-1 items-center gap-2 sm:grid-cols-(--gtc-42)",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:t}),(0,e.jsxs)("select",{"aria-label":t,value:l,onChange:a(S=>m(S.target.value),"onChange"),className:"h-10 w-full rounded-md border border-line-strong bg-bg px-3 text-sm",children:[(0,e.jsx)("option",{value:"",children:k}),he.map(S=>(0,e.jsx)("option",{value:S.key,children:S.name},S.id))]})]},t)),(0,e.jsxs)("div",{className:"grid grid-cols-1 items-center gap-2 sm:grid-cols-(--gtc-42)",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:"Ask for a note when requesting changes"}),(0,e.jsx)("div",{className:"sm:justify-self-start",children:(0,e.jsx)(ge,{checked:xt,onCheckedChange:cs})})]}),(0,e.jsxs)("div",{className:"grid grid-cols-1 items-center gap-2 sm:grid-cols-(--gtc-42)",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:"Ask for a note when declining"}),(0,e.jsx)("div",{className:"sm:justify-self-start",children:(0,e.jsx)(ge,{checked:pt,onCheckedChange:os})})]})]}),Ft?(0,e.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"Pick where approved and declined items should go before saving."}):null]}):null]})}):null,h==="instructions"&&!We(j)?(0,e.jsxs)("div",{className:"mt-8 w-full max-w-3xl space-y-6",children:[(0,e.jsx)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,e.jsxs)("div",{className:"inline-flex min-w-full flex-wrap items-center gap-2 text-sm text-ink-3 sm:min-w-max sm:flex-nowrap",children:[(0,e.jsx)("span",{children:"When an item enters this step"}),(0,e.jsx)(Mt,{value:Vt(be),options:Hn,recentOptionIds:As,placeholder:"Pick agent",noneLabel:"No automation",searchPlaceholder:"Search agents...",emptyMessage:"No agents found.",onChange:a(t=>ss(st(t)),"onChange"),renderTriggerValue:a(t=>{if(!t)return(0,e.jsx)("span",{className:"text-ink-3",children:"Pick agent"});const l=st(t.id)?ue.get(st(t.id)):null;return(0,e.jsxs)(e.Fragment,{children:[l?(0,e.jsx)(fe,{agent:l,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):null,(0,e.jsx)("span",{className:"truncate",children:t.label})]})},"renderTriggerValue"),renderOption:a(t=>{if(!t.id)return(0,e.jsx)("span",{className:"truncate",children:t.label});const l=st(t.id),m=l?ue.get(l):null;return(0,e.jsxs)(e.Fragment,{children:[m?(0,e.jsx)(fe,{agent:m,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):null,(0,e.jsx)("span",{className:"truncate",children:t.label})]})},"renderOption")}),(0,e.jsx)("span",{children:"runs these instructions, then moves the item to the next step."})]})}),Ot?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"divide-y divide-line border-y border-line",children:[(0,e.jsxs)(T,{label:"Project context",children:[(0,e.jsxs)("div",{className:"grid gap-2 sm:grid-cols-(--gtc-43)",children:[(0,e.jsx)(Mt,{value:A,options:Un,recentOptionIds:Gn,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",onChange:ea,renderTriggerValue:a(t=>t&&R?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:R.color??"var(--project-seed)"}}),(0,e.jsx)("span",{className:"truncate",children:t.label})]}):(0,e.jsx)("span",{className:"text-ink-3",children:"Project"}),"renderTriggerValue"),renderOption:a(t=>{if(!t.id)return(0,e.jsx)("span",{className:"truncate",children:t.label});const l=ce.find(m=>m.id===t.id);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:l?.color??"var(--project-seed)"}}),(0,e.jsx)("span",{className:"truncate",children:t.label})]})},"renderOption")}),R?(0,e.jsxs)("select",{"aria-label":"Project workspace",value:K,onChange:a(t=>ta(t.target.value),"onChange"),className:"h-10 w-full rounded-md border border-line-strong bg-bg px-3 text-sm",children:[(0,e.jsx)("option",{value:"",children:"Project fallback"}),(R.workspaces??[]).map(t=>(0,e.jsxs)("option",{value:t.id,children:[t.name,t.isPrimary?" · primary":""]},t.id))]}):(0,e.jsx)("div",{className:"flex h-10 items-center rounded-md border border-dashed border-line px-3 text-sm text-ink-3",children:"Project workspace"})]}),R&&!Jn?(0,e.jsx)("p",{className:"mt-2 text-xs text-ink-3",children:"This project has no saved workspace default. Wardmote will use the project fallback when automation runs."}):null]}),R&&Xe?(0,e.jsxs)(T,{label:"Execution workspace",children:[(0,e.jsxs)("div",{className:"grid gap-2 sm:grid-cols-(--gtc-43)",children:[(0,e.jsx)("select",{"aria-label":"Execution workspace mode",value:F||"shared_workspace",onChange:a(t=>sa(t.target.value),"onChange"),className:"h-10 w-full rounded-md border border-line-strong bg-bg px-3 text-sm",children:Ri.map(t=>(0,e.jsx)("option",{value:t.value,children:t.label},t.value))}),F==="reuse_existing"?(0,e.jsxs)("select",{"aria-label":"Existing execution workspace",value:U,onChange:a(t=>na(t.target.value),"onChange"),className:"h-10 w-full rounded-md border border-line-strong bg-bg px-3 text-sm",children:[(0,e.jsx)("option",{value:"",children:"Choose an existing workspace"}),Ze.map(t=>(0,e.jsxs)("option",{value:t.id,children:[t.name," · ",t.status," · ",t.branchName??t.cwd??t.id.slice(0,8)]},t.id))]}):(0,e.jsx)("div",{className:"flex h-10 items-center rounded-md border border-dashed border-line px-3 text-sm text-ink-3",children:F==="isolated_workspace"?"A new workspace will be created":"Project default workspace"})]}),F==="reuse_existing"&&Pe?(0,e.jsxs)("p",{className:"mt-2 text-xs text-ink-3",children:["Reusing ",Pe.name," from ",Pe.branchName??Pe.cwd??"existing workspace","."]}):null,Wt?null:(0,e.jsx)("p",{className:"mt-2 text-xs text-amber-700 dark:text-amber-300",children:"Choose an existing workspace before saving reuse mode."})]}):null]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3",children:[(0,e.jsx)(fe,{agent:Ot,size:16,className:"h-4 w-4 shrink-0"}),(0,e.jsxs)("span",{children:[Ot.name," runs this step automatically."]})]}),(0,e.jsx)(T,{label:"Issue title",children:(0,e.jsx)(qe,{ref:ot,"aria-label":"Issue title template",value:ie,onChange:a(t=>Be(t.target.value),"onChange"),placeholder:at,className:"font-mono text-sm"})}),(0,e.jsx)(Nn,{groups:Je,onInsert:Qn,label:"Issue title variables"}),V?(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"What should the agent decide?"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"The mechanics are handled below. Write only the judgment."})]}):null,(0,e.jsx)("div",{"data-testid":"stage-instructions-editor",children:(0,e.jsx)(Ja,{ref:dt,value:Ve,onChange:Le,placeholder:V?"Describe the judgment the agent should make — what counts as a piece worth splitting out?":"Tell the agent exactly what to do when an item enters this step...",bordered:!1,contentClassName:"min-h-(--sz-120px) text-sm leading-7",mentions:zn,onSubmit:a(()=>{!_.isPending&&P.trim()&&!Ft&&Wt&&_.mutate()},"onSubmit")})}),(0,e.jsx)(Nn,{groups:Je,onInsert:Ts}),(0,e.jsx)(cr,{groups:Ct,onInsert:Ts})]}):(0,e.jsx)(z,{icon:sn,message:"Nothing runs here automatically. Items wait until a person moves them, or you can pick an agent to run this step."}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(ki,{}),(0,e.jsx)(wi,{title:ie,description:Ve,value:lt,onChange:is},c?.id??"stage")]}),ba]}):null,h==="secrets"?(0,e.jsx)("div",{className:"w-full max-w-3xl",children:(()=>{const t=Dt(c),l=t.assigneeAgentId?ue.get(t.assigneeAgentId)??null:null;return(0,e.jsx)(Ni,{hasAutomation:!!(t.routineId&&t.assigneeAgentId),agentName:l?.name??null,agentIcon:l?.icon??null,agent:l??void 0,secrets:ws.data??[],secretsLoading:ws.isLoading,value:Qe,onChange:rs,onCreateSecret:a(async(m,k)=>Ln.mutateAsync({name:m,value:k}),"onCreateSecret"),onSetupAutomation:a(()=>p("instructions"),"onSetupAutomation"),onSave:a(()=>qs.mutate(),"onSave"),saving:qs.isPending,dirty:pa})})()}):null,h==="advanced"?(0,e.jsxs)("div",{className:"w-full max-w-3xl space-y-8",children:[(0,e.jsxs)("div",{className:"divide-y divide-line border-b border-line",children:[(0,e.jsx)("div",{className:"py-3",children:(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"Transitions"})}),(0,e.jsx)(T,{label:"Strict mode",children:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(ge,{"aria-label":"Strictly enforce transitions",checked:Ie,disabled:Os.isPending,onCheckedChange:a(t=>{kt(t),Os.mutate(t)},"onCheckedChange")}),(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:"Strictly enforce transitions"})]}),(0,e.jsx)("p",{className:"max-w-2xl text-sm text-ink-3",children:Ie?"Items can only move to configured next steps. Operators can force an off-path move by giving a reason.":"Items can move to any step. Saved allowed-next-step choices are kept, but they are not enforced."})]})}),Ie?ya:null]}),We(j)?null:V?(0,e.jsx)(z,{icon:En,message:"Advanced child settings are hidden while Break into smaller pieces is enabled. Configure that workflow in Automation."}):(0,e.jsxs)("div",{className:"divide-y divide-line border-b border-line",children:[(0,e.jsx)("div",{className:"py-3",children:(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"Children"})}),(0,e.jsx)(T,{label:"Block children",children:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(ge,{checked:ht,onCheckedChange:ds}),(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:"Block until all child items are done or cancelled"})]}),(0,e.jsx)("p",{className:"max-w-2xl text-sm text-ink-3",children:"When on, this step can't move forward while any child item is still open. When off, items can move through even with open children."})]})}),(0,e.jsx)(T,{label:"Advance children",children:(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(ge,{checked:!!J,onCheckedChange:a(t=>{gt(t&&(J||Rt?.key)||"")},"onCheckedChange")}),(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:"Advance when the last child is done"})]}),(0,e.jsxs)("div",{className:"grid grid-cols-1 items-center gap-2 sm:grid-cols-(--gtc-44)",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink-3",children:"Move to"}),(0,e.jsxs)("select",{"aria-label":"Move to stage when children finish",value:J,onChange:a(t=>gt(t.target.value),"onChange"),disabled:!J,className:"h-10 w-full rounded-md border border-line-strong bg-bg px-3 text-sm disabled:opacity-50",children:[(0,e.jsx)("option",{value:"",children:"Choose a stage"}),he.map(t=>(0,e.jsx)("option",{value:t.key,children:t.name},t.id))]})]}),(0,e.jsx)("p",{className:"max-w-2xl text-sm text-ink-3",children:"When on and every child is done, this step moves the item forward automatically. When off, someone has to move it."})]})})]})]}):null,h==="activity"?(0,e.jsx)("div",{className:"w-full space-y-3",children:At.isLoading?(0,e.jsx)(hn,{variant:"list"}):(0,e.jsx)(ur,{events:Xn,stages:b,emptyMessage:"No stage activity yet."})}):null,h==="history"?(0,e.jsx)("div",{className:"w-full max-w-3xl",children:$?(0,e.jsx)(Si,{pipelineId:s,documentKey:$,currentRevisionId:Te?.document?.latestRevisionId??null,hasDocument:!!Te,onRestored:a((t,l)=>{Le(t)},"onRestored")}):null}):null]})]}),_.error?(0,e.jsx)("p",{className:"text-sm text-bad",children:_.error.message}):null,xa||_.isPending?(0,e.jsxs)("div",{className:"sticky bottom-0 z-10 -mx-6 mt-6 flex items-center justify-between gap-3 border-t border-line bg-bg/95 px-6 py-3 backdrop-blur motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-2",children:[(0,e.jsx)("span",{className:"text-sm text-ink-3",children:_.isPending?"Saving changes…":"You have unsaved changes."}),(0,e.jsxs)(q,{type:"submit",disabled:_.isPending||!P.trim()||Ft||!Wt,children:[_.isPending?(0,e.jsx)(Xa,{className:"h-4 w-4"}):(0,e.jsx)(Gt,{className:"h-4 w-4"}),_.isPending?"Saving...":"Save stage"]})]}):null]}):null]}),(0,e.jsx)(un,{open:Mn,onOpenChange:Se,children:(0,e.jsxs)(on,{children:[(0,e.jsxs)(rn,{children:[(0,e.jsx)(dn,{children:"Delete stage"}),(0,e.jsxs)(cn,{children:["Delete ",c?.name??"this stage"," from this pipeline. Connected stage transitions are removed."]})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[b.length>1?(0,e.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,e.jsx)("span",{children:"Move existing items to"}),(0,e.jsx)("select",{"aria-label":"Move existing items to",value:ze,onChange:a(t=>fs(t.target.value),"onChange"),className:"h-10 w-full rounded-md border border-line-strong bg-bg px-3 text-sm",children:b.filter(t=>t.id!==c?.id).map(t=>(0,e.jsx)("option",{value:t.id,children:t.name},t.id))})]}):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"This is the only stage. Deletion succeeds only if it has no items."}),pe.error?(0,e.jsx)("p",{className:"text-sm text-bad",children:pe.error.message}):null]}),(0,e.jsxs)(ln,{children:[(0,e.jsx)(q,{type:"button",variant:"secondary",onClick:a(()=>Se(!1),"onClick"),disabled:pe.isPending,children:"Cancel"}),(0,e.jsxs)(q,{type:"button",variant:"delete",disabled:pe.isPending||b.length>1&&!ze,onClick:a(()=>pe.mutate(),"onClick"),children:[(0,e.jsx)(nn,{className:"h-4 w-4"}),pe.isPending?"Deleting...":"Delete stage"]})]})]})}),(0,e.jsx)(un,{open:$n,onOpenChange:a(t=>{Ge(t),t||wt("")},"onOpenChange"),children:(0,e.jsxs)(on,{children:[(0,e.jsxs)(rn,{children:[(0,e.jsx)(dn,{children:"Archive pipeline"}),(0,e.jsx)(cn,{children:"Archiving hides this pipeline from everyday views. Its stages and items are kept and can be restored later."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("label",{className:"block space-y-1.5 text-sm font-medium",children:[(0,e.jsxs)("span",{children:["Type ",g.name," to confirm"]}),(0,e.jsx)(qe,{"aria-label":"Archive confirmation",value:vs,onChange:a(t=>wt(t.target.value),"onChange"),autoComplete:"off"})]}),se.error?(0,e.jsx)("p",{className:"text-sm text-bad",children:se.error.message}):null]}),(0,e.jsxs)(ln,{children:[(0,e.jsx)(q,{type:"button",variant:"secondary",onClick:a(()=>Ge(!1),"onClick"),disabled:se.isPending,children:"Cancel"}),(0,e.jsxs)(q,{type:"button",variant:"danger",disabled:!ra,onClick:a(()=>se.mutate(!0),"onClick"),children:[(0,e.jsx)(tt,{className:"h-4 w-4"}),se.isPending?"Archiving...":"Archive pipeline"]})]})]})})]})}a(rl,"PipelineSettings");export{rl as PipelineSettings};