mastra 1.40.2-alpha.2 → 1.40.2-alpha.3
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.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/factory/assets/{BoardConfigPage-Dan9VyhL.js → BoardConfigPage-Dyf45WS_.js} +1 -1
- package/dist/factory/assets/{BoardIntakePage-BYZy_ru_.js → BoardIntakePage-D3ZiWxdW.js} +1 -1
- package/dist/factory/assets/{BoardRulesPage-CxNhQl3d.js → BoardRulesPage-BxX6-8ie.js} +1 -1
- package/dist/factory/assets/ConditionRows-BV6wHoaG.js +1 -0
- package/dist/factory/assets/{CreateFactoryPage-CoxfdoDW.js → CreateFactoryPage-CVz7eZwg.js} +1 -1
- package/dist/factory/assets/{FactorySkillPage-ix3Ct4E0.js → FactorySkillPage-CNqkoQZi.js} +1 -1
- package/dist/factory/assets/{FactorySkillsPage-SPaAjjue.js → FactorySkillsPage-CcrItaCy.js} +1 -1
- package/dist/factory/assets/{IconScript.es-BQPM-6BN.js → IconScript.es-Co_pin4X.js} +1 -1
- package/dist/factory/assets/{KnowledgePage-nfIFPgp6.js → KnowledgePage-2eDOQtWm.js} +1 -1
- package/dist/factory/assets/{MastraGatewayBilling-Bpx-h8Vt.js → MastraGatewayBilling-DUU0LSY2.js} +1 -1
- package/dist/factory/assets/{NewBoardPage-VIlgPMpB.js → NewBoardPage-CYvk9BEW.js} +1 -1
- package/dist/factory/assets/{NewPage-BnMyEhkh.js → NewPage-DeDa0phC.js} +1 -1
- package/dist/factory/assets/{OnboardingPage-CHfAWT72.js → OnboardingPage-DdcZpJsc.js} +1 -1
- package/dist/factory/assets/{ProviderBrandIcon-C7mph6N5.js → ProviderBrandIcon-BYIRXEhA.js} +1 -1
- package/dist/factory/assets/{RulesPage-Bm395CUB.js → RulesPage-DmQpSMtC.js} +1 -1
- package/dist/factory/assets/SessionLayout-Uelj8cZ6.js +4 -0
- package/dist/factory/assets/{SessionPage-B9E-jG8M.js → SessionPage-NE-3YkG9.js} +1 -1
- package/dist/factory/assets/{SettingsPage-BKDcpSlF.js → SettingsPage-DJ8lifvY.js} +1 -1
- package/dist/factory/assets/{SlackConnectionPage-ChNhPiV-.js → SlackConnectionPage-BHG7f16i.js} +1 -1
- package/dist/factory/assets/{StackedDiffs-BFXdSF8w.js → StackedDiffs-KRfZDfPC.js} +1 -1
- package/dist/factory/assets/{Tree-B90XgTY4-cZ-SkEZr.js → Tree-B90XgTY4-BLd80tNF.js} +1 -1
- package/dist/factory/assets/{index-CD4tM4nf.js → index-7W2GRQBh.js} +2 -2
- package/dist/factory/assets/index-Ht7Ui57o.css +1 -0
- package/dist/factory/assets/{useDraftModelGuards-BwRi1qov.js → useDraftModelGuards-CIXGo6vX.js} +1 -1
- package/dist/factory/assets/{workspaces-CF_kIkTd.js → workspaces-CwZ9bD-Y.js} +1 -1
- package/dist/factory/index.html +2 -2
- package/dist/index.js +1 -1
- package/dist/studio/assets/{index-B4zG_u8m.js → index-Cv39a2ni.js} +2 -2
- package/dist/studio/assets/{main-CEtWndOQ.js → main-D_UBSd_f.js} +391 -328
- package/dist/studio/assets/style-DY-TR8Ov.css +3 -0
- package/dist/studio/index.html +2 -2
- package/package.json +4 -4
- package/dist/factory/assets/ConditionRows-DJVG4EHd.js +0 -1
- package/dist/factory/assets/IconMerged.es-BudaK6HC.js +0 -1
- package/dist/factory/assets/SessionLayout-BShjmacL.js +0 -4
- package/dist/factory/assets/index-Bi7K7czv.css +0 -1
- package/dist/studio/assets/style-CW1SmVpP.css +0 -3
package/dist/docs/SKILL.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-BpvMnN1l.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,$t as a,Cr as o,D as s,E as c,Hn as l,Jn as u,Mr as d,Qn as f,Sr as p,Un as m,Xn as h,Yn as g,Zn as _,ar as v,cr as y,dn as b,dr as x,en as S,er as ee,fr as C,hr as w,jr as T,lr as E,mr as te,nn as D,nr as O,rr as k,tn as ne,tr as A,ur as j,vr as M,xr as N,yr as P}from"./index-CD4tM4nf.js";import{A as F,a as re,j as I}from"./Sidebar.es-DSPzNNju.js";import{d as ie,f as L,r as ae,t as R,u as oe}from"./settings-DAvFqX1V-D4umTesm.js";import{O as se,T as z,k as ce,n as B,s as V,t as le}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as H}from"./lib-DkXXjRNC.js";import{c as ue,o as de,r as fe,s as pe,t as me}from"./useBoardEditor-DiWa4Lcl.js";import{i as he,t as ge}from"./SkillBadges-BN_VjOtf.js";import{a as U,c as _e,f as ve,l as ye,s as be}from"./boardConfigPaths-Btimpi_r.js";import{t as W}from"./AlertDialog.es-DDAl3sXA.js";import{$n as xe,Fi as G,ga as Se,ji as Ce,lr as we,ma as Te,n as K,pa as Ee,r as De,zt as Oe}from"./GithubIcon.es-BPBhMx2H.js";import{t as q}from"./SettingsSubsection-BGJrlda9.js";import{n as ke,r as J,t as Ae}from"./settingsColumn-CrKuH8q1.js";import{n as je}from"./useBoardCatalog-vK4woIAH.js";import{h as Me,o as Ne}from"./useIntakeRoutes-CdL4o1Vv.js";import{a as Pe,d as Fe,t as Ie}from"./BoardIcons-Cml_taka.js";import{i as Le,n as Re,r as ze,t as Be}from"./IconPencil.es-C5rZ8A6j.js";import{r as Ve}from"./overlays-B3sO28Cg.js";import{t as He}from"./DescriptionMarkdown-BH7uH0Yx.js";import{h as Ue,w as We,y as Ge}from"./ruleLanes-DEg70O95.js";import{t as Ke}from"./CodeEditor-DmElSGLM-BqTClSRY.js";import{a as qe,n as Je,r as Ye,t as Xe}from"./Field.es-BPlWASZ-.js";import{t as Ze}from"./input-DqReKX0A-BMaPtvZH.js";import{a as Qe,n as $e}from"./input-group-CXvse9n7-C3ds8HOQ.js";import{a as et,i as tt,n as nt,r as rt,t as it}from"./InputNumber.es-Dvj2CMW7.js";import{c as at,d as ot,et as st,l as ct,u as lt}from"./icons-C18D46Pv.js";import{E as ut}from"./combobox-parts-Bmj5kzrt-DzYjyBt5.js";import{n as dt,t as ft}from"./ConditionRows-DJVG4EHd.js";import{t as pt}from"./IconLock.es-9mYeLe9c.js";import{t as mt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as ht}from"./TrashIcon.es-CLx-KWTg.js";import{t as Y}from"./page-header-Maytcmgh--oRyXaDt.js";import{n as gt,t as _t}from"./boardCatalog-y-s19dQU.js";import{t as vt}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as yt}from"./InlineText-vWKzGKx_.js";import{t as bt}from"./LoadErrorState-CtPpeSh8.js";var X=e(ce(),1),Z=se();function Q({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Z.jsx)(`div`,{className:z(ke,i),children:(0,Z.jsx)(`div`,{className:z(J,n),children:r})}):(0,Z.jsx)(`div`,{className:z(J,i,n),children:r})}function xt({factoryId:e,boardId:t,phase:n,skills:r}){let i=n.runner;if(!i)return null;let a=i.skill,o=a?r?.find(e=>e.name===a):void 0,s=a!==void 0&&r!==void 0&&o===void 0,l=s||o?.error!==void 0,u=a&&!s?_e(e,t,a):U(e,t,n.key),d=a?c:Ve;return(0,Z.jsxs)(Re,{children:[(0,Z.jsxs)(Le,{delay:0,closeDelay:100,render:(0,Z.jsx)(H,{to:u}),className:z(V,`border-border bg-fill-subtle hover:bg-fill flex w-fit max-w-full min-w-0 items-center gap-1.5 rounded-md border px-1.5 py-0.5 transition-colors`,l&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),l&&(0,Z.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Z.jsxs)(ze,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-96 max-w-[calc(100vw-2rem)] flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Z.jsx)(ge,{skill:o})]}),s?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,a,` skill, so cards entering `,n.name,` fail to start.`]}):o?.error?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Z.jsx)(h,{children:`Loading the skill…`}),o?.content.trim()&&(0,Z.jsx)(St,{title:`Skill instructions`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Z.jsx)(St,{title:`${n.name} adds`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Z.jsx)(St,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Z.jsx)(B,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Z.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function St({title:e,children:t}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Z.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Ct({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Z.jsxs)(Re,{children:[(0,Z.jsx)(Le,{delay:0,closeDelay:100,render:(0,Z.jsx)(H,{to:n}),className:z(V,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ue(e.length)}),(0,Z.jsxs)(ze,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2`,children:[(0,Z.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Z.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Z.jsx)(m,{rule:e,boardId:r,boards:i},e.id))})]})]})}var wt=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Tt({factoryId:e,boardId:t,phases:n,skills:r,action:i,onAutoStart:a}){let o=je(e),s=Ne(e),c=o.isPending||s.isPending,d=o.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,f=n.map(e=>g(e,n)),p=s.data&&d?_(s.data.intakeRoutes,{key:t,initialPhase:d}):void 0;return(0,Z.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[i&&(0,Z.jsx)(Q,{pinned:!0,className:`flex justify-end`,children:i}),s.isError&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(K,{variant:`warning`,children:(0,Z.jsx)(K.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),p&&p.leaving.length>0&&(0,Z.jsx)(Q,{pinned:!0,className:`mb-4`,children:(0,Z.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Z.jsx)(Ct,{rules:p.leaving,title:`Rules that send cards to other boards`,to:be(e,t,`leaving`),boardId:t,boards:o.data}),` `,p.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Z.jsx)(`ol`,{"aria-label":`Phases`,className:z(`mx-auto flex w-max`,wt),children:n.map(i=>{let s=Pe(t,i.kind),m=p?.into.get(i.key)??[];return(0,Z.jsxs)(`li`,{"aria-label":i.name,className:`before:via-border-strong relative flex w-64 shrink-0 flex-col px-2 not-first:before:absolute not-first:before:inset-y-0 not-first:before:left-0 not-first:before:w-px not-first:before:bg-linear-to-b not-first:before:from-transparent not-first:before:to-transparent`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Z.jsxs)(H,{to:U(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Z.jsx)(Ie,{stage:i.key,kind:s,decorative:!0}),(0,Z.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Z.jsx)(`div`,{className:`px-3 py-3`,children:(0,Z.jsx)(u,{boardId:t,phase:g(i,n),phases:f,arrivals:(0,Z.jsxs)(Z.Fragment,{children:[c?(0,Z.jsx)(I,{className:`h-4 w-20`}):p?m.length>0?(0,Z.jsx)(Ct,{rules:m,title:`Rules that move cards into ${i.name}`,to:be(e,t,{into:i.key}),boardId:t,boards:o.data}):(0,Z.jsx)(h,{children:`No rule moves cards here`}):(0,Z.jsx)(h,{children:`Rules didn’t load`}),i.key===d&&(0,Z.jsx)(h,{children:`New cards start here`})]}),starts:(0,Z.jsx)(l,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:a&&(e=>a(i.key,e))}),agent:(0,Z.jsx)(xt,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Et=`Finish or remove unfinished conditions to save.`;function Dt({label:e,description:t,rule:n,disabled:r,facts:i=Ge,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,X.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,X.useId)(),g=p===void 0?N(s,n):M(s,p),_=e=>{m(e);let t=P(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Z.jsxs)(Xe,{invalid:g!==void 0,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(qe,{htmlFor:h,children:e}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,N(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Z.jsx)(Je,{children:t}),p===void 0?r?(0,Z.jsx)(B,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:We(n,o)}):(0,Z.jsx)(`div`,{id:h,children:(0,Z.jsx)(ft,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Et):l(e,N(s,e))}})}):(0,Z.jsx)(a,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Z.jsx)(Ye,{children:g})]})}var Ot=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function kt({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let s=e=>o(n.includes(e)?n.filter(t=>t!==e):t.filter(t=>t.key===e||n.includes(t.key)).map(e=>e.key));return(0,Z.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Z.jsx)(Ie,{stage:t.key,kind:Pe(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Z.jsxs)(`li`,{className:z(Ot,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Z.jsx)(At,{children:t.name}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`(this phase)`})]},t.key);let c=n.includes(t.key),l=c&&r.has(t.key),u=l||a,d=(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":l?`${t.name} (locked)`:void 0,"aria-disabled":u||void 0,onClick:u?void 0:()=>s(t.key),className:z(Ot,`group/move transition-colors`,c?`bg-fill text-foreground border-transparent`:`border-border text-muted-foreground border-dashed`,!u&&(c?`hover:bg-fill-hover`:`hover:text-foreground hover:border-border-strong`),u&&!l&&`cursor-default`,V),children:[(0,Z.jsx)(`span`,{className:z(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Z.jsx)(At,{children:t.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Z.jsx)(pt,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Z.jsx)(st,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Z.jsx)(mt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Z.jsx)(`li`,{className:`min-w-0`,children:l?(0,Z.jsxs)(Ee,{children:[(0,Z.jsx)(Se,{render:d}),(0,Z.jsx)(Te,{children:`Factory's code makes this move`})]}):d},t.key)})})}function At({children:e}){return(0,Z.jsx)(B,{as:`span`,variant:`label`,className:`truncate`,children:e})}function jt({label:e,children:t}){return(0,Z.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Mt({icon:e,title:t,description:n,children:r}){let i=(0,X.useId)();return(0,Z.jsxs)(`li`,{"aria-labelledby":i,className:`before:bg-border relative grid grid-cols-[--spacing(7)_minmax(0,1fr)] gap-x-3 pb-8 before:absolute before:top-9 before:bottom-1 before:left-[calc(--spacing(3.5)-0.5px)] before:w-px last:pb-0 last:before:hidden`,children:[(0,Z.jsx)(`span`,{className:`border-border bg-card text-muted-foreground [&_svg]:size-icon-sm flex size-7 items-center justify-center rounded-full border`,children:e}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Z.jsx)(B,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Nt=`__none__`,Pt=`sm:max-w-xs`,Ft=(e,t)=>e>=t-200?` ${e}/${t}`:``;function It({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Z.jsxs)(ae,{children:[(0,Z.jsxs)(Xe,{invalid:!!n,disabled:r,children:[(0,Z.jsx)(ie,{children:e}),(0,Z.jsx)(Je,{children:t}),i,n&&(0,Z.jsx)(Ye,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Z.jsx)(R,{children:(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Ke,{"aria-label":e,value:t,placeholder:n,editable:!r,onChange:i,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1})})})}function Rt({phase:e,phases:t,requiredNextPhases:n,skills:r,skillsEditable:a,factoryId:o,boardId:s,disabled:l,rawRules:u,onChange:d,onRawRule:m,onUnfinished:h,onRemove:g}){let _=dt(o),y=e.kind===`working`,x=E(e,t),S=e.runner?.instructions??``,C=e.runner?.goal,w=C?.objective??``,T=e.tools??[],D=e.exitTool?.id??``,O=e.runner?.skill,k=O?r?.find(e=>e.name===O):void 0,ne=O!==void 0&&r!==void 0&&k===void 0,j=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));d({...e,runner:Object.keys(r).length>0?r:null})},M=e=>({text:u[e],onChange:t=>m(e,t)}),N=(0,Z.jsx)(kt,{phase:e,phases:t,next:x,required:new Set(n),boardId:s,disabled:l,onChange:t=>d({...e,nextPhases:t})}),P=g&&(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(G,{variant:`ghost`,icon:(0,Z.jsx)(ht,{}),onClick:g,children:[`Remove `,e.name]})});return y?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsxs)(jt,{label:`How ${e.name} runs`,children:[(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(Fe,{}),title:`Starts`,children:(0,Z.jsxs)(R,{children:[(0,Z.jsx)(L,{label:`Start on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:l,onCheckedChange:t=>{d(te(e,t)),t||m(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Me,options:{"source.repository":_},disabled:l,json:M(`autoStartWhen`),onUnfinished:e=>h(`autoStartWhen`,e),onChange:t=>d({...e,autoStartWhen:t})})})]})}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(Ve,{}),title:`Agent runs`,children:[(0,Z.jsx)(It,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${Ft(S.length,i)}`,error:S.length>1e3?`Too long to save.`:void 0,disabled:l,children:(0,Z.jsx)(Lt,{label:`${e.name} instructions`,value:S,placeholder:`Tell the agent what to do, in Markdown`,disabled:l,onChange:e=>j({instructions:e})})}),(0,Z.jsx)(It,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${Ft(w.length,ee)}`,error:w.length>2e3?`Too long to save.`:void 0,disabled:l,after:C&&(0,Z.jsxs)(Xe,{invalid:!v(C.maxRuns),disabled:l,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(qe,{info:`After this many runs without meeting the goal, the card waits for a person. From 1 to 50; leave empty for Factory's default.`,children:`Pause goal after`}),(0,Z.jsx)(it,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:C.maxRuns??null,disabled:l,onValueChange:e=>{let{maxRuns:t,...n}=C;j({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Z.jsxs)(rt,{size:`sm`,children:[(0,Z.jsx)(et,{placeholder:`Default`}),(0,Z.jsxs)($e,{align:`inline-end`,variant:`flush`,children:[(0,Z.jsx)(Qe,{className:`mr-1`,children:`runs`}),(0,Z.jsx)(nt,{}),(0,Z.jsx)(tt,{})]})]})})]}),!v(C.maxRuns)&&(0,Z.jsxs)(Ye,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Z.jsx)(Lt,{label:`${e.name} goal`,value:w,placeholder:`Describe what done looks like`,disabled:l,onChange:e=>j({goal:e.trim()?{...C,objective:e}:void 0})})}),(0,Z.jsx)(It,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:f,disabled:l,onChange:e=>j({context:e.target.value})})}),(0,Z.jsx)(q,{title:`Skill`,children:(0,Z.jsx)(R,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsxs)(at,{value:O??Nt,disabled:l,onValueChange:e=>j({skill:e===Nt?void 0:String(e)}),children:[(0,Z.jsx)(ot,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(c,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:O??`No skill`})]})}),(0,Z.jsxs)(ct,{children:[(0,Z.jsx)(lt,{value:Nt,children:`None`}),(r??[]).map(e=>(0,Z.jsx)(lt,{value:e.name,children:e.name},e.name))]})]}),ne&&(0,Z.jsx)(F,{variant:`destructive`,children:`Not found`}),k?.error&&(0,Z.jsx)(F,{variant:`destructive`,children:`Failed to load`}),k&&(0,Z.jsx)(ge,{skill:k}),k&&(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,icon:a?(0,Z.jsx)(Be,{}):(0,Z.jsx)(De,{}),"aria-label":`${a?`Edit`:`View`} ${k.name}`,className:`ml-auto`,render:(0,Z.jsx)(H,{to:_e(o,s,k.name)}),children:a?`Edit`:`View`})]}),k?.error?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,k.error]}):ne?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,O,` skill, so cards entering `,e.name,` fail to start.`]}):k?.description&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:k.description})]})})}),(0,Z.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Z.jsx)(R,{children:A.map(t=>(0,Z.jsx)(L,{label:t.label,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: ${t.label}`,checked:T.includes(t.id),disabled:l,onCheckedChange:n=>{let r=A.map(({id:e})=>e).filter(e=>e===t.id?n:T.includes(e));d({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(p,{}),title:`Ends`,children:[(0,Z.jsx)(It,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} exit tool`,value:D,disabled:l,onChange:t=>{let n=t.target.value.trim();d({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||m(`autoApproveWhen`,void 0)}})}),D!==``&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(L,{label:`Approve on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: approve ${D} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:l,onCheckedChange:t=>{d({...e,exitTool:{...e.exitTool,id:D,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||m(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Me,options:{"source.repository":_},disabled:l,json:M(`autoApproveWhen`),onUnfinished:e=>h(`autoApproveWhen`,e),onChange:t=>d({...e,exitTool:{...e.exitTool,id:D,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(b,{}),title:`Allowed moves`,children:N})]}),P]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(q,{title:`Allowed moves`,children:N}),P]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:l,onReload:u}){let{board:d,canEdit:f}=i,{draft:p,rawRules:m,locked:h,setDraft:g,setRawRule:_,discard:v}=ne(e.id,t,d),[y,b]=(0,X.useState)(0),S=()=>{v(),b(e=>e+1)},ee=we(),w=ue(e.id,t),T=Ce(),E=!f||!d.editable,D=n?p.phases.find(e=>e.key===n):void 0,A=D&&`${D.key}:${d.revision??`code`}:${y}`,[M,N]=(0,X.useState)({page:A,fields:[]});M.page!==A&&N({page:A,fields:[]});let P=M.page===A?M.fields:[],F=(e,t)=>N(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),re=!E&&(k(p,d)||Object.keys(m).length>0||P.length>0),I=p.phases.filter(e=>j(e,m)||e===D&&P.length>0),ie=p.name.trim()===``,L=w.error?.code===`revision_mismatch`,ae=xe(({nextLocation:n})=>{let r=T.getQueryData(Oe.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!re||r===!1)return!1;let i=ve(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),oe=U(e.id,t),se;return se=n&&!D?(0,Z.jsx)(r,{titleSlot:(0,Z.jsxs)(`span`,{role:`alert`,children:[d.name,` has no such phase.`]}),actionSlot:(0,Z.jsx)(G,{size:`sm`,render:(0,Z.jsx)(H,{to:oe}),children:`Back to general`})}):D?(0,Z.jsx)(Rt,{phase:D,phases:p.phases,requiredNextPhases:d.codeBehaviour?.[D.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:E||h,rawRules:{autoStartWhen:m[x(D.key,`autoStartWhen`)],autoApproveWhen:m[x(D.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{_(x(D.key,e),t),F(e,!1)},onUnfinished:F,onRemove:E||h||!O(p.phases,D.key,d.codeBehaviour)?void 0:()=>{for(let e of zt)_(x(D.key,e),void 0);g(e=>({...e,phases:C(e.phases,D.key)})),ee(oe)},onChange:e=>g(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},A):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(Tt,{factoryId:e.id,boardId:t,phases:p.phases,skills:a,onAutoStart:E||h?void 0:(e,t)=>{g(n=>({...n,phases:n.phases.map(n=>n.key===e?te(n,t):n)})),t||_(x(e,`autoStartWhen`),void 0)},action:l&&!E?(0,Z.jsx)(s,{factoryId:e.id,boardId:t,board:d,disabled:h}):void 0}),(0,Z.jsx)(Q,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:l&&(0,Z.jsx)(q,{title:`Factory`,children:(0,Z.jsx)(R,{children:(0,Z.jsxs)(H,{to:ye(e.id,t),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,Z.jsx)(c,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Z.jsx)(B,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Z.jsx)(le,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Z.jsxs)(`div`,{className:z(`flex flex-col gap-8 pb-4`,!D&&`w-max min-w-full`),children:[d.editable?!f&&(0,Z.jsx)(Q,{pinned:!D,children:(0,Z.jsx)(K,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Z.jsx)(Q,{pinned:!D,children:(0,Z.jsx)(K,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!D&&d.problems.length>0&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(K,{variant:`warning`,title:`This board has problems`,children:(0,Z.jsx)(K.Message,{children:d.problems.join(` `)})})}),se,re&&(0,Z.jsxs)(Q,{pinned:!D,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[L&&(0,Z.jsx)(K,{variant:`warning`,title:`Someone else changed this board`,action:(0,Z.jsx)(K.Button,{onClick:u,children:`Reload`}),children:(0,Z.jsx)(K.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),w.error&&!L&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not saved. `,w.error.reasons]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(B,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:ie?`Name the board to save.`:I.length>0?`Fix ${I.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,disabled:w.isPending,onClick:S,children:`Discard`}),(0,Z.jsx)(G,{size:`sm`,variant:`primary`,disabled:w.isPending||ie||I.length>0,onClick:()=>w.mutate({name:p.name,description:p.description,phases:p.phases,expectedRevision:d.revision??0}),children:w.isPending?`Saving…`:`Save`})]})]}),(0,Z.jsx)(W,{open:ae.state===`blocked`,onOpenChange:e=>!e&&ae.reset?.(),children:(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Discard changes to `,d.name,`?`]}),(0,Z.jsx)(W.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Keep editing`}),(0,Z.jsx)(G,{variant:`destructive`,size:`md`,onClick:()=>{v(),ae.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Z.jsxs)(W,{children:[(0,Z.jsx)(W.Trigger,{render:(0,Z.jsx)(G,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(ht,{}),disabled:t,children:`Delete`})}),(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Delete `,e,`?`]}),(0,Z.jsx)(W.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Cancel`}),(0,Z.jsx)(W.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Z.jsxs)(W,{children:[(0,Z.jsx)(W.Trigger,{render:(0,Z.jsx)(G,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(vt,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Reset `,e,` to default?`]}),(0,Z.jsx)(W.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Cancel`}),(0,Z.jsx)(W.Action,{onClick:n,children:`Reset`})]})]})]})}var $={resting:{label:`Resting`,meaning:`No agent works here. Cards wait for a person or an event to move them.`},working:{label:`Working`,meaning:`An agent works on each card here, following the steps below.`},terminal:{label:`Terminal`,meaning:`Cards are finished here. Their agent sessions stop.`}},Ut=[`resting`,`working`,`terminal`];function Wt({label:e,meaning:t,children:n}){return(0,Z.jsxs)(Ee,{children:[(0,Z.jsx)(Se,{render:(0,Z.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:z(`inline-flex rounded-sm`,V),children:n})}),(0,Z.jsx)(Te,{side:`bottom`,className:`max-w-72`,children:t})]})}function Gt({factoryId:e,boardId:t,phaseKey:n,response:r}){let{board:i,canEdit:a}=r,{draft:o,locked:s,setDraft:c,setRawRule:l,discard:u}=ne(e,t,i),d=je(e),f=we(),p=!a||!i.editable||s,m=pe(e,t),h=de(e,t,()=>{u();let n=gt(d.data??[]).find(e=>e.id!==t);f(n?_t(e,n.id):`/factories/${e}`,{replace:!0})}),g=!n&&a&&i.editable,_=g&&i.source!==`stored`,v=g&&i.source!==`builtin`,b=n?o.phases.find(e=>e.key===n):void 0;if(n&&!b)return null;let S=e=>c(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),ee=e=>{b&&(l(x(b.key,`autoStartWhen`),void 0),l(x(b.key,`autoApproveWhen`),void 0),c(t=>({...t,phases:t.phases.map(n=>n.key===b.key?w(n,e,t.phases):n)})))},C=b?b.name:o.name,T=(b?b.description:o.description)??``,E=b!==void 0&&!p&&!y(o.phases,b.key,i.codeBehaviour);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Y,{children:[(0,Z.jsxs)(Y.Title,{className:`gap-2.5`,children:[b&&(0,Z.jsx)(Ie,{stage:b.key,kind:Pe(t,b.kind),decorative:!0}),(0,Z.jsx)(yt,{value:C,label:b?`Phase name`:`Board name`,required:!0,readOnly:p,variant:`heading`,tone:`ink`,onChange:e=>b?S({name:e}):c(t=>({...t,name:e}))})]}),b&&(0,Z.jsx)(Y.Meta,{beside:!0,children:E?(0,Z.jsxs)(at,{value:b.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&ee(t)},children:[(0,Z.jsx)(ot,{size:`sm`,"aria-label":`Phase kind`,children:$[b.kind].label}),(0,Z.jsx)(ct,{children:Ut.map(e=>(0,Z.jsx)(lt,{value:e,children:$[e].label},e))})]}):(0,Z.jsx)(Wt,{label:$[b.kind].label,meaning:$[b.kind].meaning,children:(0,Z.jsx)(F,{children:$[b.kind].label})})}),(T||!p)&&(0,Z.jsx)(Y.Description,{children:(0,Z.jsx)(yt,{value:T,label:b?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:p,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>b?S({description:e||null}):c(t=>({...t,description:e||null}))})}),(_||v)&&(0,Z.jsxs)(Y.Action,{className:`gap-1`,children:[_&&(0,Z.jsx)(Ht,{name:i.name,pending:s,onReset:()=>m.mutate(i.revision??0)}),v&&(0,Z.jsx)(Vt,{name:i.name,pending:s,onDelete:()=>h.mutate(i.revision??0)})]})]}),m.error&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not reset. `,m.error.reasons]})}),h.error&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not deleted. `,h.error.reasons]})})]})}function Kt(){let e=o(),i=S(),a=i?.boardId??``,s=i?.phaseKey,{isMobile:c,desktopState:l}=re(),u=c||l===`collapsed`,f=fe(e.id,a),p=he(e.id),m=f.data?.board,h=D(e.id,a,m),g=s?h?.phases.find(e=>e.key===s):void 0,_=U(e.id,a),v=T({breadcrumbs:u&&m?(0,Z.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(t,{as:H,to:_t(e.id,a),children:h?.name||m.name}),s?(0,Z.jsx)(t,{as:H,to:_,children:`Configure`}):(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),g&&(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:g.name})]}):void 0}),y=f.isSuccess&&(!s||g)?(0,Z.jsx)(`div`,{className:z(J,s?`pb-8`:`pb-3`),children:(0,Z.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:s,response:f.data},`${a}:${f.data.board.revision??`code`}`)}):void 0;return(0,Z.jsx)(d,{variant:s?`narrow`:`fit`,header:y,...v,children:(0,Z.jsx)(`div`,{className:s||!f.isSuccess?z(J,!s&&`px-4`):Ae,children:f.isPending?(0,Z.jsx)(R,{children:(0,Z.jsx)(oe,{label:`Loading board`,rows:3})}):f.isError&&f.error instanceof me&&f.error.code===`board_not_found`?(0,Z.jsx)(r,{variant:`fill`,titleSlot:(0,Z.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):f.isError?(0,Z.jsx)(bt,{title:`Couldn’t load this board`,error:f.error,onRetry:()=>void f.refetch(),retrying:f.isFetching}):(0,Z.jsx)(Bt,{factory:e,boardId:a,phaseKey:s,response:f.data,skills:p.data?.skills,skillsEditable:p.data?.canEdit??!1,sidebarHidden:u,onReload:()=>void f.refetch()},`${a}:${f.data.board.revision??`code`}`)})})}export{Kt as BoardConfigPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-BpvMnN1l.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,$t as a,Cr as o,D as s,E as c,Hn as l,Jn as u,Mr as d,Qn as f,Sr as p,Un as m,Xn as h,Yn as g,Zn as _,ar as v,cr as y,dn as b,dr as x,en as S,er as ee,fr as C,hr as w,jr as T,lr as E,mr as te,nn as D,nr as O,rr as k,tn as ne,tr as A,ur as j,vr as M,xr as N,yr as P}from"./index-7W2GRQBh.js";import{A as F,a as re,j as I}from"./Sidebar.es-DSPzNNju.js";import{d as ie,f as L,r as ae,t as R,u as oe}from"./settings-DAvFqX1V-D4umTesm.js";import{O as se,T as z,k as ce,n as B,s as V,t as le}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as H}from"./lib-DkXXjRNC.js";import{c as ue,o as de,r as fe,s as pe,t as me}from"./useBoardEditor-DiWa4Lcl.js";import{i as he,t as ge}from"./SkillBadges-BN_VjOtf.js";import{a as U,c as _e,f as ve,l as ye,s as be}from"./boardConfigPaths-Btimpi_r.js";import{t as W}from"./AlertDialog.es-DDAl3sXA.js";import{$n as xe,Fi as G,ga as Se,ji as Ce,lr as we,ma as Te,n as K,pa as Ee,r as De,zt as Oe}from"./GithubIcon.es-BPBhMx2H.js";import{t as q}from"./SettingsSubsection-BGJrlda9.js";import{n as ke,r as J,t as Ae}from"./settingsColumn-CrKuH8q1.js";import{n as je}from"./useBoardCatalog-vK4woIAH.js";import{h as Me,o as Ne}from"./useIntakeRoutes-CdL4o1Vv.js";import{a as Pe,d as Fe,t as Ie}from"./BoardIcons-Cml_taka.js";import{i as Le,n as Re,r as ze,t as Be}from"./IconPencil.es-C5rZ8A6j.js";import{r as Ve}from"./overlays-B3sO28Cg.js";import{t as He}from"./DescriptionMarkdown-BH7uH0Yx.js";import{h as Ue,w as We,y as Ge}from"./ruleLanes-DEg70O95.js";import{t as Ke}from"./CodeEditor-DmElSGLM-BqTClSRY.js";import{a as qe,n as Je,r as Ye,t as Xe}from"./Field.es-BPlWASZ-.js";import{t as Ze}from"./input-DqReKX0A-BMaPtvZH.js";import{a as Qe,n as $e}from"./input-group-CXvse9n7-C3ds8HOQ.js";import{a as et,i as tt,n as nt,r as rt,t as it}from"./InputNumber.es-Dvj2CMW7.js";import{c as at,d as ot,et as st,l as ct,u as lt}from"./icons-C18D46Pv.js";import{E as ut}from"./combobox-parts-Bmj5kzrt-DzYjyBt5.js";import{n as dt,t as ft}from"./ConditionRows-BV6wHoaG.js";import{t as pt}from"./IconLock.es-9mYeLe9c.js";import{t as mt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as ht}from"./TrashIcon.es-CLx-KWTg.js";import{t as Y}from"./page-header-Maytcmgh--oRyXaDt.js";import{n as gt,t as _t}from"./boardCatalog-y-s19dQU.js";import{t as vt}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as yt}from"./InlineText-vWKzGKx_.js";import{t as bt}from"./LoadErrorState-CtPpeSh8.js";var X=e(ce(),1),Z=se();function Q({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Z.jsx)(`div`,{className:z(ke,i),children:(0,Z.jsx)(`div`,{className:z(J,n),children:r})}):(0,Z.jsx)(`div`,{className:z(J,i,n),children:r})}function xt({factoryId:e,boardId:t,phase:n,skills:r}){let i=n.runner;if(!i)return null;let a=i.skill,o=a?r?.find(e=>e.name===a):void 0,s=a!==void 0&&r!==void 0&&o===void 0,l=s||o?.error!==void 0,u=a&&!s?_e(e,t,a):U(e,t,n.key),d=a?c:Ve;return(0,Z.jsxs)(Re,{children:[(0,Z.jsxs)(Le,{delay:0,closeDelay:100,render:(0,Z.jsx)(H,{to:u}),className:z(V,`border-border bg-fill-subtle hover:bg-fill flex w-fit max-w-full min-w-0 items-center gap-1.5 rounded-md border px-1.5 py-0.5 transition-colors`,l&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),l&&(0,Z.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Z.jsxs)(ze,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-96 max-w-[calc(100vw-2rem)] flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Z.jsx)(ge,{skill:o})]}),s?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,a,` skill, so cards entering `,n.name,` fail to start.`]}):o?.error?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Z.jsx)(h,{children:`Loading the skill…`}),o?.content.trim()&&(0,Z.jsx)(St,{title:`Skill instructions`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Z.jsx)(St,{title:`${n.name} adds`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Z.jsx)(St,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Z.jsx)(B,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Z.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function St({title:e,children:t}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Z.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Ct({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Z.jsxs)(Re,{children:[(0,Z.jsx)(Le,{delay:0,closeDelay:100,render:(0,Z.jsx)(H,{to:n}),className:z(V,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ue(e.length)}),(0,Z.jsxs)(ze,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2`,children:[(0,Z.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Z.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Z.jsx)(m,{rule:e,boardId:r,boards:i},e.id))})]})]})}var wt=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Tt({factoryId:e,boardId:t,phases:n,skills:r,action:i,onAutoStart:a}){let o=je(e),s=Ne(e),c=o.isPending||s.isPending,d=o.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,f=n.map(e=>g(e,n)),p=s.data&&d?_(s.data.intakeRoutes,{key:t,initialPhase:d}):void 0;return(0,Z.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[i&&(0,Z.jsx)(Q,{pinned:!0,className:`flex justify-end`,children:i}),s.isError&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(K,{variant:`warning`,children:(0,Z.jsx)(K.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),p&&p.leaving.length>0&&(0,Z.jsx)(Q,{pinned:!0,className:`mb-4`,children:(0,Z.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Z.jsx)(Ct,{rules:p.leaving,title:`Rules that send cards to other boards`,to:be(e,t,`leaving`),boardId:t,boards:o.data}),` `,p.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Z.jsx)(`ol`,{"aria-label":`Phases`,className:z(`mx-auto flex w-max`,wt),children:n.map(i=>{let s=Pe(t,i.kind),m=p?.into.get(i.key)??[];return(0,Z.jsxs)(`li`,{"aria-label":i.name,className:`before:via-border-strong relative flex w-64 shrink-0 flex-col px-2 not-first:before:absolute not-first:before:inset-y-0 not-first:before:left-0 not-first:before:w-px not-first:before:bg-linear-to-b not-first:before:from-transparent not-first:before:to-transparent`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Z.jsxs)(H,{to:U(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Z.jsx)(Ie,{stage:i.key,kind:s,decorative:!0}),(0,Z.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Z.jsx)(`div`,{className:`px-3 py-3`,children:(0,Z.jsx)(u,{boardId:t,phase:g(i,n),phases:f,arrivals:(0,Z.jsxs)(Z.Fragment,{children:[c?(0,Z.jsx)(I,{className:`h-4 w-20`}):p?m.length>0?(0,Z.jsx)(Ct,{rules:m,title:`Rules that move cards into ${i.name}`,to:be(e,t,{into:i.key}),boardId:t,boards:o.data}):(0,Z.jsx)(h,{children:`No rule moves cards here`}):(0,Z.jsx)(h,{children:`Rules didn’t load`}),i.key===d&&(0,Z.jsx)(h,{children:`New cards start here`})]}),starts:(0,Z.jsx)(l,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:a&&(e=>a(i.key,e))}),agent:(0,Z.jsx)(xt,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Et=`Finish or remove unfinished conditions to save.`;function Dt({label:e,description:t,rule:n,disabled:r,facts:i=Ge,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,X.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,X.useId)(),g=p===void 0?N(s,n):M(s,p),_=e=>{m(e);let t=P(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Z.jsxs)(Xe,{invalid:g!==void 0,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(qe,{htmlFor:h,children:e}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,N(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Z.jsx)(Je,{children:t}),p===void 0?r?(0,Z.jsx)(B,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:We(n,o)}):(0,Z.jsx)(`div`,{id:h,children:(0,Z.jsx)(ft,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Et):l(e,N(s,e))}})}):(0,Z.jsx)(a,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Z.jsx)(Ye,{children:g})]})}var Ot=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function kt({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let s=e=>o(n.includes(e)?n.filter(t=>t!==e):t.filter(t=>t.key===e||n.includes(t.key)).map(e=>e.key));return(0,Z.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Z.jsx)(Ie,{stage:t.key,kind:Pe(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Z.jsxs)(`li`,{className:z(Ot,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Z.jsx)(At,{children:t.name}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`(this phase)`})]},t.key);let c=n.includes(t.key),l=c&&r.has(t.key),u=l||a,d=(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":l?`${t.name} (locked)`:void 0,"aria-disabled":u||void 0,onClick:u?void 0:()=>s(t.key),className:z(Ot,`group/move transition-colors`,c?`bg-fill text-foreground border-transparent`:`border-border text-muted-foreground border-dashed`,!u&&(c?`hover:bg-fill-hover`:`hover:text-foreground hover:border-border-strong`),u&&!l&&`cursor-default`,V),children:[(0,Z.jsx)(`span`,{className:z(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Z.jsx)(At,{children:t.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Z.jsx)(pt,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Z.jsx)(st,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Z.jsx)(mt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Z.jsx)(`li`,{className:`min-w-0`,children:l?(0,Z.jsxs)(Ee,{children:[(0,Z.jsx)(Se,{render:d}),(0,Z.jsx)(Te,{children:`Factory's code makes this move`})]}):d},t.key)})})}function At({children:e}){return(0,Z.jsx)(B,{as:`span`,variant:`label`,className:`truncate`,children:e})}function jt({label:e,children:t}){return(0,Z.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Mt({icon:e,title:t,description:n,children:r}){let i=(0,X.useId)();return(0,Z.jsxs)(`li`,{"aria-labelledby":i,className:`before:bg-border relative grid grid-cols-[--spacing(7)_minmax(0,1fr)] gap-x-3 pb-8 before:absolute before:top-9 before:bottom-1 before:left-[calc(--spacing(3.5)-0.5px)] before:w-px last:pb-0 last:before:hidden`,children:[(0,Z.jsx)(`span`,{className:`border-border bg-card text-muted-foreground [&_svg]:size-icon-sm flex size-7 items-center justify-center rounded-full border`,children:e}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Z.jsx)(B,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Nt=`__none__`,Pt=`sm:max-w-xs`,Ft=(e,t)=>e>=t-200?` ${e}/${t}`:``;function It({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Z.jsxs)(ae,{children:[(0,Z.jsxs)(Xe,{invalid:!!n,disabled:r,children:[(0,Z.jsx)(ie,{children:e}),(0,Z.jsx)(Je,{children:t}),i,n&&(0,Z.jsx)(Ye,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Z.jsx)(R,{children:(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Ke,{"aria-label":e,value:t,placeholder:n,editable:!r,onChange:i,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1})})})}function Rt({phase:e,phases:t,requiredNextPhases:n,skills:r,skillsEditable:a,factoryId:o,boardId:s,disabled:l,rawRules:u,onChange:d,onRawRule:m,onUnfinished:h,onRemove:g}){let _=dt(o),y=e.kind===`working`,x=E(e,t),S=e.runner?.instructions??``,C=e.runner?.goal,w=C?.objective??``,T=e.tools??[],D=e.exitTool?.id??``,O=e.runner?.skill,k=O?r?.find(e=>e.name===O):void 0,ne=O!==void 0&&r!==void 0&&k===void 0,j=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));d({...e,runner:Object.keys(r).length>0?r:null})},M=e=>({text:u[e],onChange:t=>m(e,t)}),N=(0,Z.jsx)(kt,{phase:e,phases:t,next:x,required:new Set(n),boardId:s,disabled:l,onChange:t=>d({...e,nextPhases:t})}),P=g&&(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(G,{variant:`ghost`,icon:(0,Z.jsx)(ht,{}),onClick:g,children:[`Remove `,e.name]})});return y?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsxs)(jt,{label:`How ${e.name} runs`,children:[(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(Fe,{}),title:`Starts`,children:(0,Z.jsxs)(R,{children:[(0,Z.jsx)(L,{label:`Start on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:l,onCheckedChange:t=>{d(te(e,t)),t||m(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Me,options:{"source.repository":_},disabled:l,json:M(`autoStartWhen`),onUnfinished:e=>h(`autoStartWhen`,e),onChange:t=>d({...e,autoStartWhen:t})})})]})}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(Ve,{}),title:`Agent runs`,children:[(0,Z.jsx)(It,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${Ft(S.length,i)}`,error:S.length>1e3?`Too long to save.`:void 0,disabled:l,children:(0,Z.jsx)(Lt,{label:`${e.name} instructions`,value:S,placeholder:`Tell the agent what to do, in Markdown`,disabled:l,onChange:e=>j({instructions:e})})}),(0,Z.jsx)(It,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${Ft(w.length,ee)}`,error:w.length>2e3?`Too long to save.`:void 0,disabled:l,after:C&&(0,Z.jsxs)(Xe,{invalid:!v(C.maxRuns),disabled:l,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(qe,{info:`After this many runs without meeting the goal, the card waits for a person. From 1 to 50; leave empty for Factory's default.`,children:`Pause goal after`}),(0,Z.jsx)(it,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:C.maxRuns??null,disabled:l,onValueChange:e=>{let{maxRuns:t,...n}=C;j({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Z.jsxs)(rt,{size:`sm`,children:[(0,Z.jsx)(et,{placeholder:`Default`}),(0,Z.jsxs)($e,{align:`inline-end`,variant:`flush`,children:[(0,Z.jsx)(Qe,{className:`mr-1`,children:`runs`}),(0,Z.jsx)(nt,{}),(0,Z.jsx)(tt,{})]})]})})]}),!v(C.maxRuns)&&(0,Z.jsxs)(Ye,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Z.jsx)(Lt,{label:`${e.name} goal`,value:w,placeholder:`Describe what done looks like`,disabled:l,onChange:e=>j({goal:e.trim()?{...C,objective:e}:void 0})})}),(0,Z.jsx)(It,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:f,disabled:l,onChange:e=>j({context:e.target.value})})}),(0,Z.jsx)(q,{title:`Skill`,children:(0,Z.jsx)(R,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsxs)(at,{value:O??Nt,disabled:l,onValueChange:e=>j({skill:e===Nt?void 0:String(e)}),children:[(0,Z.jsx)(ot,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(c,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:O??`No skill`})]})}),(0,Z.jsxs)(ct,{children:[(0,Z.jsx)(lt,{value:Nt,children:`None`}),(r??[]).map(e=>(0,Z.jsx)(lt,{value:e.name,children:e.name},e.name))]})]}),ne&&(0,Z.jsx)(F,{variant:`destructive`,children:`Not found`}),k?.error&&(0,Z.jsx)(F,{variant:`destructive`,children:`Failed to load`}),k&&(0,Z.jsx)(ge,{skill:k}),k&&(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,icon:a?(0,Z.jsx)(Be,{}):(0,Z.jsx)(De,{}),"aria-label":`${a?`Edit`:`View`} ${k.name}`,className:`ml-auto`,render:(0,Z.jsx)(H,{to:_e(o,s,k.name)}),children:a?`Edit`:`View`})]}),k?.error?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,k.error]}):ne?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,O,` skill, so cards entering `,e.name,` fail to start.`]}):k?.description&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:k.description})]})})}),(0,Z.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Z.jsx)(R,{children:A.map(t=>(0,Z.jsx)(L,{label:t.label,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: ${t.label}`,checked:T.includes(t.id),disabled:l,onCheckedChange:n=>{let r=A.map(({id:e})=>e).filter(e=>e===t.id?n:T.includes(e));d({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(p,{}),title:`Ends`,children:[(0,Z.jsx)(It,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} exit tool`,value:D,disabled:l,onChange:t=>{let n=t.target.value.trim();d({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||m(`autoApproveWhen`,void 0)}})}),D!==``&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(L,{label:`Approve on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: approve ${D} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:l,onCheckedChange:t=>{d({...e,exitTool:{...e.exitTool,id:D,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||m(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Me,options:{"source.repository":_},disabled:l,json:M(`autoApproveWhen`),onUnfinished:e=>h(`autoApproveWhen`,e),onChange:t=>d({...e,exitTool:{...e.exitTool,id:D,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(b,{}),title:`Allowed moves`,children:N})]}),P]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(q,{title:`Allowed moves`,children:N}),P]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:l,onReload:u}){let{board:d,canEdit:f}=i,{draft:p,rawRules:m,locked:h,setDraft:g,setRawRule:_,discard:v}=ne(e.id,t,d),[y,b]=(0,X.useState)(0),S=()=>{v(),b(e=>e+1)},ee=we(),w=ue(e.id,t),T=Ce(),E=!f||!d.editable,D=n?p.phases.find(e=>e.key===n):void 0,A=D&&`${D.key}:${d.revision??`code`}:${y}`,[M,N]=(0,X.useState)({page:A,fields:[]});M.page!==A&&N({page:A,fields:[]});let P=M.page===A?M.fields:[],F=(e,t)=>N(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),re=!E&&(k(p,d)||Object.keys(m).length>0||P.length>0),I=p.phases.filter(e=>j(e,m)||e===D&&P.length>0),ie=p.name.trim()===``,L=w.error?.code===`revision_mismatch`,ae=xe(({nextLocation:n})=>{let r=T.getQueryData(Oe.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!re||r===!1)return!1;let i=ve(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),oe=U(e.id,t),se;return se=n&&!D?(0,Z.jsx)(r,{titleSlot:(0,Z.jsxs)(`span`,{role:`alert`,children:[d.name,` has no such phase.`]}),actionSlot:(0,Z.jsx)(G,{size:`sm`,render:(0,Z.jsx)(H,{to:oe}),children:`Back to general`})}):D?(0,Z.jsx)(Rt,{phase:D,phases:p.phases,requiredNextPhases:d.codeBehaviour?.[D.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:E||h,rawRules:{autoStartWhen:m[x(D.key,`autoStartWhen`)],autoApproveWhen:m[x(D.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{_(x(D.key,e),t),F(e,!1)},onUnfinished:F,onRemove:E||h||!O(p.phases,D.key,d.codeBehaviour)?void 0:()=>{for(let e of zt)_(x(D.key,e),void 0);g(e=>({...e,phases:C(e.phases,D.key)})),ee(oe)},onChange:e=>g(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},A):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(Tt,{factoryId:e.id,boardId:t,phases:p.phases,skills:a,onAutoStart:E||h?void 0:(e,t)=>{g(n=>({...n,phases:n.phases.map(n=>n.key===e?te(n,t):n)})),t||_(x(e,`autoStartWhen`),void 0)},action:l&&!E?(0,Z.jsx)(s,{factoryId:e.id,boardId:t,board:d,disabled:h}):void 0}),(0,Z.jsx)(Q,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:l&&(0,Z.jsx)(q,{title:`Factory`,children:(0,Z.jsx)(R,{children:(0,Z.jsxs)(H,{to:ye(e.id,t),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,Z.jsx)(c,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Z.jsx)(B,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Z.jsx)(le,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Z.jsxs)(`div`,{className:z(`flex flex-col gap-8 pb-4`,!D&&`w-max min-w-full`),children:[d.editable?!f&&(0,Z.jsx)(Q,{pinned:!D,children:(0,Z.jsx)(K,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Z.jsx)(Q,{pinned:!D,children:(0,Z.jsx)(K,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!D&&d.problems.length>0&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(K,{variant:`warning`,title:`This board has problems`,children:(0,Z.jsx)(K.Message,{children:d.problems.join(` `)})})}),se,re&&(0,Z.jsxs)(Q,{pinned:!D,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[L&&(0,Z.jsx)(K,{variant:`warning`,title:`Someone else changed this board`,action:(0,Z.jsx)(K.Button,{onClick:u,children:`Reload`}),children:(0,Z.jsx)(K.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),w.error&&!L&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not saved. `,w.error.reasons]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(B,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:ie?`Name the board to save.`:I.length>0?`Fix ${I.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,disabled:w.isPending,onClick:S,children:`Discard`}),(0,Z.jsx)(G,{size:`sm`,variant:`primary`,disabled:w.isPending||ie||I.length>0,onClick:()=>w.mutate({name:p.name,description:p.description,phases:p.phases,expectedRevision:d.revision??0}),children:w.isPending?`Saving…`:`Save`})]})]}),(0,Z.jsx)(W,{open:ae.state===`blocked`,onOpenChange:e=>!e&&ae.reset?.(),children:(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Discard changes to `,d.name,`?`]}),(0,Z.jsx)(W.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Keep editing`}),(0,Z.jsx)(G,{variant:`destructive`,size:`md`,onClick:()=>{v(),ae.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Z.jsxs)(W,{children:[(0,Z.jsx)(W.Trigger,{render:(0,Z.jsx)(G,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(ht,{}),disabled:t,children:`Delete`})}),(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Delete `,e,`?`]}),(0,Z.jsx)(W.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Cancel`}),(0,Z.jsx)(W.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Z.jsxs)(W,{children:[(0,Z.jsx)(W.Trigger,{render:(0,Z.jsx)(G,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(vt,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Reset `,e,` to default?`]}),(0,Z.jsx)(W.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Cancel`}),(0,Z.jsx)(W.Action,{onClick:n,children:`Reset`})]})]})]})}var $={resting:{label:`Resting`,meaning:`No agent works here. Cards wait for a person or an event to move them.`},working:{label:`Working`,meaning:`An agent works on each card here, following the steps below.`},terminal:{label:`Terminal`,meaning:`Cards are finished here. Their agent sessions stop.`}},Ut=[`resting`,`working`,`terminal`];function Wt({label:e,meaning:t,children:n}){return(0,Z.jsxs)(Ee,{children:[(0,Z.jsx)(Se,{render:(0,Z.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:z(`inline-flex rounded-sm`,V),children:n})}),(0,Z.jsx)(Te,{side:`bottom`,className:`max-w-72`,children:t})]})}function Gt({factoryId:e,boardId:t,phaseKey:n,response:r}){let{board:i,canEdit:a}=r,{draft:o,locked:s,setDraft:c,setRawRule:l,discard:u}=ne(e,t,i),d=je(e),f=we(),p=!a||!i.editable||s,m=pe(e,t),h=de(e,t,()=>{u();let n=gt(d.data??[]).find(e=>e.id!==t);f(n?_t(e,n.id):`/factories/${e}`,{replace:!0})}),g=!n&&a&&i.editable,_=g&&i.source!==`stored`,v=g&&i.source!==`builtin`,b=n?o.phases.find(e=>e.key===n):void 0;if(n&&!b)return null;let S=e=>c(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),ee=e=>{b&&(l(x(b.key,`autoStartWhen`),void 0),l(x(b.key,`autoApproveWhen`),void 0),c(t=>({...t,phases:t.phases.map(n=>n.key===b.key?w(n,e,t.phases):n)})))},C=b?b.name:o.name,T=(b?b.description:o.description)??``,E=b!==void 0&&!p&&!y(o.phases,b.key,i.codeBehaviour);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Y,{children:[(0,Z.jsxs)(Y.Title,{className:`gap-2.5`,children:[b&&(0,Z.jsx)(Ie,{stage:b.key,kind:Pe(t,b.kind),decorative:!0}),(0,Z.jsx)(yt,{value:C,label:b?`Phase name`:`Board name`,required:!0,readOnly:p,variant:`heading`,tone:`ink`,onChange:e=>b?S({name:e}):c(t=>({...t,name:e}))})]}),b&&(0,Z.jsx)(Y.Meta,{beside:!0,children:E?(0,Z.jsxs)(at,{value:b.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&ee(t)},children:[(0,Z.jsx)(ot,{size:`sm`,"aria-label":`Phase kind`,children:$[b.kind].label}),(0,Z.jsx)(ct,{children:Ut.map(e=>(0,Z.jsx)(lt,{value:e,children:$[e].label},e))})]}):(0,Z.jsx)(Wt,{label:$[b.kind].label,meaning:$[b.kind].meaning,children:(0,Z.jsx)(F,{children:$[b.kind].label})})}),(T||!p)&&(0,Z.jsx)(Y.Description,{children:(0,Z.jsx)(yt,{value:T,label:b?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:p,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>b?S({description:e||null}):c(t=>({...t,description:e||null}))})}),(_||v)&&(0,Z.jsxs)(Y.Action,{className:`gap-1`,children:[_&&(0,Z.jsx)(Ht,{name:i.name,pending:s,onReset:()=>m.mutate(i.revision??0)}),v&&(0,Z.jsx)(Vt,{name:i.name,pending:s,onDelete:()=>h.mutate(i.revision??0)})]})]}),m.error&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not reset. `,m.error.reasons]})}),h.error&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not deleted. `,h.error.reasons]})})]})}function Kt(){let e=o(),i=S(),a=i?.boardId??``,s=i?.phaseKey,{isMobile:c,desktopState:l}=re(),u=c||l===`collapsed`,f=fe(e.id,a),p=he(e.id),m=f.data?.board,h=D(e.id,a,m),g=s?h?.phases.find(e=>e.key===s):void 0,_=U(e.id,a),v=T({breadcrumbs:u&&m?(0,Z.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(t,{as:H,to:_t(e.id,a),children:h?.name||m.name}),s?(0,Z.jsx)(t,{as:H,to:_,children:`Configure`}):(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),g&&(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:g.name})]}):void 0}),y=f.isSuccess&&(!s||g)?(0,Z.jsx)(`div`,{className:z(J,s?`pb-8`:`pb-3`),children:(0,Z.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:s,response:f.data},`${a}:${f.data.board.revision??`code`}`)}):void 0;return(0,Z.jsx)(d,{variant:s?`narrow`:`fit`,header:y,...v,children:(0,Z.jsx)(`div`,{className:s||!f.isSuccess?z(J,!s&&`px-4`):Ae,children:f.isPending?(0,Z.jsx)(R,{children:(0,Z.jsx)(oe,{label:`Loading board`,rows:3})}):f.isError&&f.error instanceof me&&f.error.code===`board_not_found`?(0,Z.jsx)(r,{variant:`fill`,titleSlot:(0,Z.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):f.isError?(0,Z.jsx)(bt,{title:`Couldn’t load this board`,error:f.error,onRetry:()=>void f.refetch(),retrying:f.isFetching}):(0,Z.jsx)(Bt,{factory:e,boardId:a,phaseKey:s,response:f.data,skills:p.data?.skills,skillsEditable:p.data?.canEdit??!1,sidebarHidden:u,onReload:()=>void f.refetch()},`${a}:${f.data.board.revision??`code`}`)})})}export{Kt as BoardConfigPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-BpvMnN1l.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Mr as a,en as o,jr as s}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-BpvMnN1l.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Mr as a,en as o,jr as s}from"./index-7W2GRQBh.js";import{A as c,a as l}from"./Sidebar.es-DSPzNNju.js";import{O as u,T as d,k as f,n as p}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as m}from"./lib-DkXXjRNC.js";import{r as h}from"./useBoardEditor-DiWa4Lcl.js";import{a as g,n as _,s as v,t as y}from"./boardConfigPaths-Btimpi_r.js";import{r as b}from"./settingsColumn-CrKuH8q1.js";import{Fi as x,n as S}from"./GithubIcon.es-BPBhMx2H.js";import{tt as C}from"./icons-C18D46Pv.js";import{a as w,o as T,t as E,u as D}from"./settings-DAvFqX1V-D4umTesm.js";import{a as O,c as k,d as A,i as j,l as M,n as N,o as P,r as F,t as I,u as L}from"./useRowDrag-Bmj1hhAE.js";import{o as R}from"./useIntakeRoutes-CdL4o1Vv.js";import{h as z,p as B}from"./ruleLanes-DEg70O95.js";import{s as V}from"./Field.es-BPlWASZ-.js";import{n as H}from"./useBoardCatalog-vK4woIAH.js";import{t as U}from"./SettingsSubsection-BGJrlda9.js";import{s as W}from"./settingsSections-B0_LEh3l.js";var G=e(f(),1),K=u();function q({factoryId:e}){let t=j(e),n=O(e),r=new Map((H(e).data??[]).map(e=>[e.id,e.name])),i=t.data?.pages??[],a=i.flatMap(e=>e.notRouted),o=i[0]?.canEdit??!1,s=e=>n.mutate(e.id,{onSuccess:t=>C.success(`Filing “${e.title}” on ${r.get(t.boardKey)??t.boardKey}.`),onError:e=>C.error(e.message)}),c=t.isPending?`Loading…`:t.isError?`Items not routed didn’t load.`:t.hasNextPage?`${a.length>0?`${a.length}+`:`More`} waiting for a board.`:a.length===0?`Every new issue and pull request found a board.`:`${a.length} waiting for a board.`;return(0,K.jsxs)(`section`,{id:_,"aria-label":`Not routed`,className:`flex scroll-mt-4 flex-col gap-3 px-3.5 pt-3 pb-3.5`,children:[(0,K.jsx)(w,{media:(0,K.jsx)(T,{children:(0,K.jsx)(M,{})}),title:(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Not routed`,(0,K.jsx)(V,{"aria-label":`When an item is not routed`,children:`A new issue or pull request ends up here when no board’s rules take it. Change a board’s rules, then route it again.`})]}),description:c}),(a.length>0||t.hasNextPage)&&(0,K.jsxs)(`ul`,{"aria-label":`Items not routed`,className:`ml-11 flex flex-col`,children:[a.map(t=>(0,K.jsx)(`li`,{className:`border-border border-t py-3`,children:(0,K.jsxs)(w,{title:t.url?(0,K.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:t.title}):t.title,description:(0,K.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[t.sourceKey&&(0,K.jsx)(`span`,{children:t.sourceKey}),(0,K.jsx)(`span`,{children:t.reason??`No board’s rules match it.`}),(0,K.jsx)(`time`,{dateTime:t.decidedAt,children:J(t.decidedAt)})]}),children:[(0,K.jsx)(N,{factoryProjectId:e,itemId:t.id,label:`Why?`}),o&&(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>s(t),disabled:n.isPending&&n.variables===t.id,children:`Route again`})]})},t.id)),t.hasNextPage&&(0,K.jsx)(`li`,{className:`border-border flex justify-center border-t pt-3`,children:(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>void t.fetchNextPage(),disabled:t.isFetchingNextPage,children:t.isFetchingNextPage?`Loading…`:`Load more`})})]})]})}function J(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}var Y=d(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:top-0 data-[drop=before]:before:block data-[drop=after]:before:bottom-0 data-[drop=after]:before:block`);function X({factoryId:e}){let t=F(e);return(0,K.jsx)(U,{id:y,scope:`factory`,title:`Intake order`,description:`A new issue or pull request is offered to each board in this order. The first board whose rules take it keeps it.`,children:t.isPending?(0,K.jsx)(E,{children:(0,K.jsx)(D,{label:`Loading intake order`,variant:`item`,rows:3})}):t.isError?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(S,{variant:`destructive`,children:`The intake order didn’t load.`}),(0,K.jsx)(`div`,{className:`border-border rounded-xl border`,children:(0,K.jsx)(q,{factoryId:e})})]}):(0,K.jsx)(Z,{factoryId:e,order:t.data},e)})}function Z({factoryId:e,order:t}){let n=R(e),r=P(e),[i,a]=(0,G.useState)(),o=t.boards.map(e=>e.boardKey),s=i&&ee(i,o)?i:void 0,c=s??o,l=new Map(t.boards.map(e=>[e.boardKey,e.name])),u=s!==void 0&&s.some((e,t)=>e!==o[t]),f=(e,t)=>{let n=[...c],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),a(n))},h=I({min:0,max:c.length-1,onDrop:f}),g=()=>r.mutate(c,{onSuccess:()=>{a(void 0),C.success(`Intake order saved.`)},onError:e=>C.error(e.message)}),_=t.canEdit&&c.length>1,y=_&&!r.isPending;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)($,{order:t,changed:u}),n.isError&&(0,K.jsx)(S,{variant:`warning`,children:`Rule counts didn’t load.`}),(0,K.jsxs)(`div`,{className:`border-border flex flex-col rounded-xl border`,children:[(0,K.jsx)(E,{role:`list`,"aria-label":`Intake order`,children:c.map((t,r)=>{let i=h.drag?.from===r,a=l.get(t)??t;return(0,K.jsx)(w,{role:`listitem`,"data-drop":h.dropAt(r),style:i?{transform:`translateY(${h.drag?.offset??0}px)`}:void 0,onPointerDown:y?e=>h.onPointerDown(e,r):void 0,onKeyDown:y?e=>h.onKeyDown(e,r):void 0,className:d(`group/row`,Y,i&&`z-10 opacity-90`),media:(0,K.jsxs)(T,{children:[(0,K.jsx)(p,{as:`span`,variant:`caption`,className:d(`tabular-nums`,_&&`pointer-fine:group-hover/row:hidden`,i&&`hidden`),children:r+1}),_&&(0,K.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:d(`text-icon3 hidden cursor-grab touch-none pointer-fine:group-hover/row:inline-flex`,i&&`inline-flex`),children:(0,K.jsx)(k,{className:`size-icon-md`})})]}),title:a,description:(0,K.jsx)(Q,{routes:n.data?.intakeRoutes,boardKey:t}),children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/row:opacity-100 pointer-fine:group-hover/row:opacity-100`,children:[_&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(x,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!y||r===0,onClick:()=>f(r,r-1),children:(0,K.jsx)(L,{})}),(0,K.jsx)(x,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!y||r===c.length-1,onClick:()=>f(r,r+1),children:(0,K.jsx)(A,{})})]}),(0,K.jsx)(x,{size:`sm`,variant:`ghost`,render:(0,K.jsx)(m,{to:v(e,t)}),children:`Edit rules`})]})},t)})}),(0,K.jsx)(q,{factoryId:e})]}),t.canEdit&&u&&(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>a(void 0),disabled:r.isPending,children:`Discard`}),(0,K.jsx)(x,{size:`sm`,variant:`primary`,onClick:g,disabled:r.isPending,children:`Save order`})]})]})}function Q({routes:e,boardKey:t}){if(!e)return null;let{count:n,catchesAll:r}=B(e.filter(e=>e.target.boardKey===t));return(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{children:n===0?`No rules for new issues and pull requests`:`${z(n)} for new issues and pull requests`}),r&&(0,K.jsx)(c,{children:`Ends in catch-all`})]})}function $({order:e,changed:t}){let{compared:n,differing:r,notRouted:i}=e.comparison,a=[];if(e.origin===`derived`&&a.push(`Worked out from the old route list until someone saves an order.`),n>0){let e=i>0?`, ${i} of them Not routed`:``;a.push(r===0?`The last ${n} cards land on the same boards as with the old route list.`:`Of the last ${n} cards, ${r} would land on another board than with the old route list${e}.`)}return e.evaluator===`route-list`&&a.push(`Intake still files cards by the old route list.`),t&&a.push(`Not saved yet. The comparison is for the saved order.`),a.length===0?null:(0,K.jsx)(S,{variant:`info`,children:(0,K.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,K.jsx)(`span`,{children:e},e))})})}function ee(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function te(){let e=i(),c=o()?.boardId??``,{isMobile:u,desktopState:f}=l(),p=u||f===`collapsed`,_=h(e.id,c).data?.board,v=s({breadcrumbs:p&&_?(0,K.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,K.jsx)(t,{as:m,to:g(e.id,c),children:_.name}),(0,K.jsx)(t,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,K.jsx)(a,{variant:`narrow`,header:(0,K.jsx)(`div`,{className:d(b,`pb-8`),children:(0,K.jsxs)(r,{children:[(0,K.jsx)(r.Title,{children:`Routing`}),(0,K.jsx)(r.Description,{children:(0,K.jsxs)(`span`,{children:[`The order boards are offered new issues and pull requests. What comes in is chosen in`,` `,(0,K.jsx)(m,{to:W(e.id,`intake`),className:`underline`,children:`Settings → Work Intake`}),`.`]})})]})}),...v,children:(0,K.jsx)(`div`,{className:d(b,`flex flex-col gap-8`),children:(0,K.jsx)(X,{factoryId:e.id})})})}export{te as BoardIntakePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-BpvMnN1l.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Gn as a,Kn as o,Mr as s,Wn as c,Zn as l,en as u,jr as d,qn as f}from"./index-CD4tM4nf.js";import{A as p,a as m,j as h,p as g}from"./Sidebar.es-DSPzNNju.js";import{O as _,T as v,k as y,n as b}from"./IconChevronRightMedium.es-BjSIsine.js";import{o as x,t as S}from"./lib-DkXXjRNC.js";import{r as C,t as w}from"./useBoardEditor-DiWa4Lcl.js";import{a as T,i as E,o as D,s as O,t as k}from"./boardConfigPaths-Btimpi_r.js";import{At as A,Dt as j,Fi as M,St as N,jt as ee,kt as P,n as F,t as te,wt as ne}from"./GithubIcon.es-BPBhMx2H.js";import{tt as I}from"./icons-C18D46Pv.js";import{n as L}from"./useBoardCatalog-vK4woIAH.js";import{c as re,d as ie,l as R,n as z,r as ae,s as B,t as V,u as H}from"./useRowDrag-Bmj1hhAE.js";import{a as oe,d as se,f as U,g as W,o as G,r as K,s as ce}from"./useIntakeRoutes-CdL4o1Vv.js";import{C as le,E as ue,_ as de,a as fe,c as q,d as pe,f as me,g as he,i as ge,l as J,m as _e,n as ve,o as ye,s as be,u as Y,w as xe}from"./ruleLanes-DEg70O95.js";import{t as X}from"./createLucideIcon-B6gALBEh.js";import{a as Se,t as Ce}from"./BoardIcons-Cml_taka.js";import{t as we}from"./input-DqReKX0A-BMaPtvZH.js";import{n as Te,t as Ee}from"./RadioGroup.es-CyxlfqIJ.js";import{n as De,t as Oe}from"./ConditionRows-DJVG4EHd.js";import{E as ke}from"./combobox-parts-Bmj5kzrt-DzYjyBt5.js";var Ae={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ae.node;var je=X(Ae),Me={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Me.node;var Ne=X(Me),Pe={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Pe.node;var Fe=X(Pe),Ie={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Ie.node;var Le=X(Ie),Re={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Re.node;var ze=X(Re),Be={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};Be.node;var Ve=X(Be),He={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};He.node;var Ue=X(He),We={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};We.node;var Ge=X(We),Ke={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ke.node;var qe=X(Ke),Je={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Je.node;var Ye=X(Je),Xe={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Xe.node;var Ze=X(Xe),Z=e(y(),1),Q=_();function Qe({when:e,options:t,everything:n}){let r=le(e,t);return!e||!r?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:n}):(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:r.parts.map((t,n)=>{let i=e.conditions[n],a=i&&`conditions`in i?i:void 0;return(0,Q.jsxs)(`span`,{className:`contents`,children:[n>0&&(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:r.join}),a?(0,Q.jsxs)(`span`,{className:`border-border inline-flex max-w-full items-center gap-1 rounded-md border border-dashed px-1 py-0.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Q.jsx)($e,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Q.jsx)($e,{children:t})]},n)})})}function $e({children:e}){return(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}function et({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let i=e.find(e=>e.id===n);if(!i)return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let o=r??i.initialPhase,s=i.phases.find(e=>e.id===o);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[i.id!==t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:c(i)}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),s&&(0,Q.jsx)(Ce,{stage:s.id,kind:Se(i.id,s.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:a(i,o)??o})]})}function tt({factoryId:e,rules:t,board:n,boards:r}){return(0,Q.jsxs)(`section`,{"aria-label":`From other boards`,className:`border-border mt-3 flex flex-col gap-1.5 border-t pt-3`,children:[(0,Q.jsxs)(b,{as:`h4`,variant:`meta`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ge,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),`From other boards`]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(t=>{let i=r.find(e=>e.id===t.target.boardKey);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(S,{to:O(e,t.target.boardKey),"aria-label":`${t.name}, on ${i?c(i):t.target.boardKey}`,className:v(`group flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,!t.enabled&&`opacity-50`),children:[(0,Q.jsxs)(`span`,{className:`border-border group-hover:border-border-hover flex w-full min-w-0 flex-col gap-1 rounded-lg border border-dashed px-3 py-2 sm:flex-1`,children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:i?c(i):`${t.target.boardKey} (not installed)`}),(0,Q.jsx)(Qe,{when:t.when,options:o(i),everything:`Every card`})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`border-border-strong h-0 w-8 shrink-0 border-t border-dashed`}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex w-44 shrink-0 items-center px-3 py-2`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:n.id,phaseKey:t.target.phaseKey})})]}),!t.enabled&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`Off`})]})},t.id)})})]})}function nt({factoryId:e,boardKey:t,order:n,evaluator:r}){let i=n.some(e=>e.boardKey===t);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r===`route-list`?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Intake still files new issues and pull requests by the old route list, not by board.`}):i?(0,Q.jsxs)(`ol`,{"aria-label":`Intake order`,className:`flex flex-wrap items-center gap-1`,children:[n.map(n=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`li`,{children:n.boardKey===t?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,"aria-current":`step`,className:`bg-surface3 rounded-md px-2 py-0.5 font-medium`,children:n.name}):(0,Q.jsx)(S,{to:O(e,n.boardKey),className:`text-muted-foreground hover:text-foreground rounded-md px-2 py-0.5`,children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,children:n.name})})}),(0,Q.jsx)(Fe,{"aria-hidden":!0,className:`text-muted-foreground size-icon-xs shrink-0`})]},n.boardKey)),(0,Q.jsx)(`li`,{children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`px-2 py-0.5`,children:`Not routed`})})]}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Not in the intake order: new issues and pull requests never reach these rules.`}),(0,Q.jsxs)(S,{to:D(e,t,k),className:`text-muted-foreground hover:text-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(Ue,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`underline decoration-dotted underline-offset-2`,children:`Reorder`})]})]})}var rt=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,it=`border-border-focus bg-fill-hover`,at=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function ot({selected:e,disabled:t,onClick:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,onClick:n,className:v(rt,`disabled:opacity-50`,e?it:at),children:r})}function st({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`label`,{onClick:r,className:v(rt,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?it:at,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsx)(Te,{value:e,disabled:n,"aria-labelledby":a,className:`sr-only`}),(0,Q.jsx)(`span`,{id:a,className:`flex min-w-0 items-start gap-3`,children:i})]})}function ct(){return(0,Q.jsx)(p,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(te,{"aria-hidden":`true`}),children:`GitHub only`})}var lt=120,ut=W(ce),$=[{id:`trigger`,title:`Trigger`,question:`What should this rule listen for?`},{id:`conditions`,title:`Only if`,question:`Which items should it apply to?`},{id:`action`,title:`Move to`,question:`Where should it go?`},{id:`review`,title:`Review`,question:`Name and check your rule`}];function dt(e,t){let n=e?.phases??[];return t?n.filter(e=>e.kind!==`terminal`):n}function ft(e,t){if(t){let e=ut.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return U(e,t)??void 0}function pt(e,t,n){let r=`When ${e.map(e=>Y(e).label.toLowerCase()).join(` or `)}${t?`, ${xe(t).charAt(0).toLowerCase()}${xe(t).slice(1)}`:``}, move to ${n}`;return r.length>lt?`${r.slice(0,119)}…`:r}function mt({factoryId:e,board:t,boards:n,initial:r,initialEvent:i,initialStep:s,readOnly:l,saving:u,error:d,onSave:f,onClose:p}){let m=De(e),[h,g]=(0,Z.useState)(()=>r?.on??(i?[i]:[])),[_,y]=(0,Z.useState)(()=>r?.when??null),[x,S]=(0,Z.useState)(()=>(r?.when?.conditions.length??0)>0),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(()=>r?.target.moveToBoardKey??t.id),[D,O]=(0,Z.useState)(()=>r?r.target.phaseKey??void 0:void 0),[k,te]=(0,Z.useState)(()=>r?.name),[I,L]=(0,Z.useState)(s),[re,ie]=(0,Z.useState)(0),R=_e(h),z=n.find(e=>e.id===T),ae=dt(z,R),B=ae.find(e=>e.id===(D??z?.initialPhase)),V=x?_:null,H=h.length?ft(h,V):void 0,oe=B&&z?`${c(z)} › ${a(z,B.id)}`:``,U=k??(B?pt(h,V,oe):``),W={trigger:h.length>0,conditions:h.length>0&&!(x&&C)&&!H,action:B!==void 0,review:U.trim().length>0},G=!l&&W.trigger&&W.conditions&&W.action&&W.review,K=$.findIndex(e=>e.id===I),ce=$[K]??$[0],le=e=>{g(e),_e(e)&&T!==t.id&&(E(t.id),O(void 0))},de=()=>{G&&B&&f({name:U.trim(),on:h,when:V,target:{phaseKey:B.id,moveToBoardKey:T===t.id?null:T}})},fe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};y(V===null?{operator:`AND`,conditions:[e]}:V.operator===`AND`?{...V,conditions:[...V.conditions,e]}:{operator:`AND`,conditions:[V,e]}),S(!0),w(!1),ie(e=>e+1)},q={trigger:h.length?h.map(e=>Y(e).label).join(`, `):void 0,conditions:h.length?xe(V,o(t)):void 0,action:B?(0,Q.jsx)(et,{boards:n,ownBoard:t.id,boardKey:T,phaseKey:B.id}):void 0,review:void 0};return(0,Q.jsx)(N,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(j,{size:`xl`,children:[(0,Q.jsx)(A,{children:(0,Q.jsx)(ee,{children:l?`Rule`:r?`Edit rule`:`Add rule`})}),(0,Q.jsx)(ne,{children:(0,Q.jsxs)(`div`,{className:`grid min-h-105 grid-cols-1 gap-6 sm:grid-cols-[12rem_1fr]`,children:[(0,Q.jsx)(`nav`,{"aria-label":`Rule steps`,className:`sm:border-border flex gap-1 overflow-x-auto sm:flex-col sm:border-r sm:pr-4`,children:$.map((e,t)=>{let n=t===0||$.slice(0,t).every(e=>W[e.id]),r=W[e.id]&&e.id!==`review`;return(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":I===e.id?`step`:void 0,onClick:()=>L(e.id),className:v(`flex shrink-0 items-start gap-2.5 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-40`,I===e.id?`bg-fill-hover`:`hover:bg-fill-subtle`),children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,className:v(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border`,r?`border-transparent bg-fill-inverse text-background`:`border-border-strong`),children:r?(0,Q.jsx)(Ne,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),q[e.id]&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:q[e.id]})]})]},e.id)})}),(0,Q.jsxs)(`section`,{"aria-label":ce.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsx)(b,{as:`h3`,variant:`heading`,children:ce.question}),I===`trigger`&&(0,Q.jsx)(_t,{value:h,disabled:l,onChange:le}),I===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(Ee,{"aria-label":`Which ones`,value:x?`matching`:`every`,disabled:l,onValueChange:e=>{S(e===`matching`),w(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Q.jsx)(st,{value:`every`,selected:!x,disabled:l,children:(0,Q.jsx)(ht,{title:R?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(st,{value:`matching`,selected:x,disabled:l,children:(0,Q.jsx)(ht,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),x&&(0,Q.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Q.jsx)(Oe,{label:`Conditions`,rule:_,facts:ue(h),options:{...o(t),"source.repository":m},onChange:(e,t)=>{y(e),w(t)}},re)}),H&&(0,Q.jsx)(F,{variant:`warning`,children:H}),!r?.outsiderPullRequestsGated&&se(h,V)&&(0,Q.jsx)(F,{variant:`info`,children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{children:`Also matches pull requests from outside authors.`}),!l&&(0,Q.jsx)(`button`,{type:`button`,onClick:fe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),I===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[R?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`An item with no card yet can only be filed on this board.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Q.jsx)(Ee,{"aria-label":`Board`,value:T,disabled:l,onValueChange:e=>{typeof e==`string`&&e!==T&&(E(e),O(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:n.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===T,disabled:l,children:(0,Q.jsxs)(b,{as:`span`,variant:`label`,tone:`ink`,children:[c(e),e.id===t.id?` (this board)`:``]})},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Q.jsx)(Ee,{"aria-label":`Phase`,value:B?.id??null,disabled:l,onValueChange:e=>typeof e==`string`&&O(e),className:`grid-cols-1 sm:grid-cols-2`,children:z&&ae.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===B?.id,disabled:l,onClick:()=>{O(e.id),L(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ce,{stage:e.id,kind:Se(z.id,e.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,children:a(z,e.id)})]})},e.id))})]})]}),I===`review`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Q.jsx)(we,{value:U,maxLength:lt,disabled:l,onChange:e=>te(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,className:`mb-3 block`,children:`This rule reads as`}),(0,Q.jsxs)(`ol`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(gt,{label:`When`,children:q.trigger}),(0,Q.jsx)(gt,{label:`Only if`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(ze,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),q.conditions]})}),(0,Q.jsx)(gt,{label:`Then`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Q.jsx)(je,{className:`size-icon-sm`,"aria-hidden":!0}),` `,q.action]})})]})]})]}),d&&(0,Q.jsx)(F,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(P,{children:[(0,Q.jsx)(M,{variant:`ghost`,onClick:p,children:l?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),K>0&&(0,Q.jsx)(M,{variant:`default`,onClick:()=>L($[K-1].id),children:`Back`}),!l&&(I===`review`||r&&G?(0,Q.jsx)(M,{variant:`primary`,disabled:!G||u,onClick:de,children:u?`Saving…`:r?`Save rule`:`Create rule`}):(0,Q.jsx)(M,{variant:`primary`,disabled:!W[I],onClick:()=>L($[K+1]?.id??`review`),children:`Continue`}))]})]})})}function ht({title:e,hint:t}){return(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function gt({label:e,children:t}){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,children:t})]})}function _t({value:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.includes(`work_item.created`)&&(0,Q.jsxs)(F,{variant:`info`,children:[`Also listens on “`,Y(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),ve.map(r=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:r.title}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.events.map(r=>{let i=Y(r),a=i.icon,o=e.includes(r);return(0,Q.jsxs)(ot,{selected:o,disabled:t||o&&e.length===1,onClick:()=>n(o?e.filter(e=>e!==r):[...e,r]),children:[(0,Q.jsx)(a,{className:`text-badge-amber-indicator mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(ht,{title:i.label,hint:i.description}),i.githubOnly&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(ct,{})})]},r)})})]},r.title))]})}function vt({count:e,into:t,leaving:n,showAll:r}){let i=n?`sending cards to ${t}`:`moving cards into ${t}`;return(0,Q.jsxs)(`div`,{className:`border-border flex items-center gap-2 rounded-lg border px-3 py-2`,children:[(0,Q.jsx)(Ve,{className:`size-icon-md text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`p`,variant:`body-sm`,tone:e===void 0?`muted`:`ink`,className:`flex-1`,children:e===void 0?`Couldn’t pick out the rules ${i}, so every rule is shown.`:e===0?`No rule is ${i}.`:`Only the ${e===1?`rule`:`${e} rules`} ${i}.`}),(0,Q.jsx)(M,{size:`sm`,variant:`ghost`,render:(0,Q.jsx)(S,{to:r}),children:`Show all`})]})}var yt=v(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:-top-1 data-[drop=before]:before:block data-[drop=after]:before:-bottom-1 data-[drop=after]:before:block`);function bt({event:e,rules:t,board:n,boards:r,phaseOptions:i,canEdit:o,skips:s,footer:l,incoming:u,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:_,onUngate:y}){let x=Y(e),S=x.icon,C=fe(t,e),w=q(e),T=ye(e),E=V({min:0,max:t.length-1,onDrop:m}),D=o&&t.length>1&&!d,O=l??(t.length?`Otherwise, the card stays where it is`:u?`No rules: this board’s cards stay where they are`:`No rules: the card stays where it is`);return(0,Q.jsxs)(`section`,{"aria-label":x.label,className:v(`flex flex-col gap-3 rounded-xl border border-border bg-card p-4`,!t.length&&!u&&`opacity-60 focus-within:opacity-100 hover:opacity-100`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(S,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`h3`,variant:`label`,tone:`ink`,children:x.label}),x.githubOnly&&(0,Q.jsx)(ct,{})]}),x.description&&(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:x.description})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`${x.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((l,u)=>{if(d&&!d.has(l.id))return null;let p=he(t,e,u),S=p>=0,O=!l.enabled||S,k=E.drag?.from===u,A=s?.get(l.id),j=r.find(e=>e.id===(l.target.moveToBoardKey??l.target.boardKey)),N=!me(l.name,[x.label,xe(l.when,i),j&&c(j),a(j,l.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":l.name,"data-drop":E.dropAt(u),style:k?{transform:`translateY(${E.drag?.offset??0}px)`}:void 0,onPointerDown:D?e=>E.onPointerDown(e,u):void 0,className:v(`group/rule flex flex-col`,yt,k&&`z-10 opacity-90`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 sm:flex-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Edit conditions of ${l.name}`,onClick:()=>f(l,`conditions`),onKeyDown:D?e=>E.onKeyDown(e,u):void 0,className:v(`flex w-full items-start gap-2.5 rounded-lg border bg-fill-subtle px-3 py-2 text-left transition-colors hover:border-border-hover`,O?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Q.jsxs)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`bg-fill mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full tabular-nums`,children:[(0,Q.jsx)(`span`,{className:v(D&&`pointer-fine:group-hover/rule:hidden`,k&&`hidden`),children:u+1}),D&&(0,Q.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:v(`hidden cursor-grab touch-none pointer-fine:group-hover/rule:flex`,k&&`flex`),children:(0,Q.jsx)(re,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[N&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:l.name}),(0,Q.jsx)(Qe,{when:l.when,options:i,everything:T})]})]}),D&&(0,Q.jsxs)(`div`,{className:`border-border bg-card absolute top-0 right-2 flex -translate-y-1/2 rounded-md border shadow-sm transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/rule:opacity-100 pointer-fine:group-hover/rule:opacity-100`,children:[(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:u===0,onClick:()=>m(u,u-1),children:(0,Q.jsx)(H,{})}),(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:u===t.length-1,onClick:()=>m(u,u+1),children:(0,Q.jsx)(ie,{})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 sm:shrink-0`,children:[(0,Q.jsxs)(`div`,{className:v(`flex min-w-0 items-center`,O&&`opacity-40`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:v(`h-px w-8 shrink-0`,O?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit where ${l.name} moves the card`,onClick:()=>f(l,`action`),className:`border-border bg-fill-subtle hover:border-border-hover flex w-44 shrink-0 rounded-lg border px-3 py-2 text-left`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:l.target.moveToBoardKey??l.target.boardKey,phaseKey:l.target.phaseKey})})]}),o&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(ke,{"aria-label":`${l.name} on`,checked:l.enabled,onCheckedChange:e=>h(l,e)}),(0,Q.jsxs)(g,{children:[(0,Q.jsx)(g.Trigger,{render:(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${l.name}`,children:(0,Q.jsx)(Le,{})})}),(0,Q.jsx)(g.Content,{align:`end`,children:(0,Q.jsxs)(g.Item,{variant:`destructive`,onClick:()=>_(l),children:[(0,Q.jsx)(Ye,{}),`Delete rule`]})})]})]})]})]}),O&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:S?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,p+1,` above matches `,T.toLowerCase(),`.`]}):`Off, skipped`}),l.problems.map(e=>(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),A&&(0,Q.jsx)(St,{skips:A}),de(l,e)&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[`Skips outside authors’ pull requests (older rule).`,o&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(l),className:`underline`,children:`Let outside authors match`})]}),pe(l,e)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),w&&be(l)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:Y(`work_item.created`).label}),u!==C&&!d&&(0,Q.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-7 items-center pl-5.5`,children:[(0,Q.jsx)(`span`,{className:`bg-border-strong h-full w-px`}),(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},l.id)}),!d&&(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[C<0&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`flex flex-1 items-center gap-2.5 px-3 py-1.5`,children:[(0,Q.jsx)(R,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),O]}),o&&(0,Q.jsx)(M,{variant:`ghost`,size:`sm`,icon:(0,Q.jsx)(qe,{}),onClick:p,children:`Add rule`})]})]}),u]})]})}function xt(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function St({skips:e}){let{count:t,latest:n}=e;return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[`Skipped `,t===1?`once`:`${t} times`,` in the last 30 days: `,xt(n.reason),`.`]}),n.url?(0,Q.jsxs)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`Latest: `,n.title]}):(0,Q.jsxs)(`span`,{children:[`Latest: `,n.title]})]})}var Ct=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function wt(e){return e instanceof w&&e.code!==void 0&&Ct.has(e.code)}function Tt(e){return wt(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function Et({factoryId:e,boardId:t}){let n=L(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(h,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(F,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Q.jsx)(Dt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Q.jsx)(F,{variant:`warning`,children:`This board isn’t installed.`})}function Dt({factoryId:e,board:t,boards:n}){let r=K(e,t.id),i=G(e),s=ae(e),c=B(e),u=oe(e),[d,p]=(0,Z.useState)(),m=(0,Z.useRef)(void 0),g=e=>{m.current=e,p(e)},[_,v]=(0,Z.useState)(),y=r.data?.intakeRoutes??[],S=r.data?.canEdit??!1,C=o(t),w=(i.data?.intakeRoutes??[]).filter(e=>e.target.moveToBoardKey===t.id&&e.target.boardKey!==t.id),T=new Map(c.data?.skipped.map(e=>[e.routeId,e])),[D]=x(),k=D.get(`into`)??void 0,A=D.has(E),j=A||k!==void 0,M=j&&i.data?l(i.data.intakeRoutes,{key:t.id,initialPhase:t.initialPhase}):void 0,N=M&&new Set((A?M.leaving:M.into.get(k??``)??[]).map(e=>e.id)),ee=e=>!N||e.some(e=>N.has(e.id));if(r.isPending||j&&i.isPending)return(0,Q.jsx)(h,{className:`h-64 w-full`});if(r.isError)return(0,Q.jsx)(F,{variant:`destructive`,children:`This board’s rules didn’t load.`});let P=e=>u.mutateAsync(e).catch(e=>I.error(Tt(e))),te=(e,n,r)=>{let i=J(y,e).map(e=>e.id);P([{kind:`reorder`,boardKey:t.id,ids:f(y,i,n,r)}])},ne=e=>{v(void 0),g(e)},L=async e=>{let n=m.current,r=n?.rule,i=()=>n!==void 0&&m.current===n;v(void 0);try{if(r)await u.mutateAsync([{kind:`update`,id:r.id,patch:{name:e.name,on:e.on,when:e.when,target:{boardKey:r.target.boardKey,...e.target,joinClosedIssue:r.target.joinClosedIssue},expectedRevision:r.revision}}]);else{let[n]=await u.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:t.id,...e.target}}}]);i()&&g(void 0),n&&await ie(n,e.on).catch(e=>I.error(Tt(e)));return}i()&&g(void 0)}catch(e){if(!i())return;if(r&&wt(e))return re(r);v(Tt(e))}},re=async e=>{let t=m.current,n=(await r.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&m.current===t&&(n?(g({...t,rule:n}),v(`Someone else changed this rule first. It now shows their version; make your change again.`)):(g(void 0),I.error(`Someone else deleted this rule first.`)))},ie=async(e,n)=>{if(e.target.boardKey!==t.id)return;let i=(await r.refetch()).data?.intakeRoutes??[],a=i.map(e=>e.id),o=a.indexOf(e.id),s=n.flatMap(t=>{let n=J(i,t),r=n[he(n,t,n.findIndex(t=>t.id===e.id))];return r?[a.indexOf(r.id)]:[]}),c=Math.min(...s);o<0||!(c<o)||await u.mutateAsync([{kind:`reorder`,boardKey:t.id,ids:f(i,a,o,c)}])},R=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:ge(s.data?.boards,t.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[i.isError&&(0,Q.jsx)(F,{variant:`warning`,children:`Rules on other boards that move cards here didn’t load, so they aren’t shown.`}),j&&(0,Q.jsx)(vt,{count:N?.size,into:A||!k?`other boards`:a(t,k)??k,leaving:A,showAll:O(e,t.id)}),ve.filter(e=>e.events.some(e=>ee([...J(y,e),...J(w,e)]))).map(r=>(0,Q.jsxs)(`section`,{"aria-label":r.title,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`h2`,variant:`subheading`,tone:`ink`,children:r.title}),r.events.some(q)?s.data&&(0,Q.jsx)(nt,{factoryId:e,boardKey:t.id,order:s.data.boards,evaluator:s.data.evaluator}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Only cards already on this board; other boards never see them.`})]}),r.events.map(r=>{let i=q(r),a=J(y,r),o=J(w,r).filter(e=>!N||N.has(e.id));return ee([...a,...o])?(0,Q.jsx)(bt,{event:r,rules:a,board:t,boards:n,phaseOptions:C,canEdit:S,skips:T,footer:i?R:void 0,only:N,incoming:o.length?(0,Q.jsx)(tt,{factoryId:e,rules:o,board:t,boards:n}):void 0,onEdit:(e,t)=>ne({rule:e,step:t}),onAdd:()=>ne({event:r,step:`conditions`}),onMove:(e,t)=>te(r,e,t),onToggle:(e,t)=>void P([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void P([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&I.success(`Deleted “${e.name}”`)),onUngate:e=>void P([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&I.success(`“${e.name}” now matches outside authors’ pull requests`))},r):null})]},r.title)),d&&(0,Q.jsx)(mt,{factoryId:e,board:t,boards:n,initial:d.rule,initialEvent:d.event,initialStep:d.step,readOnly:!S,saving:u.isPending,error:_,onSave:e=>void L(e),onClose:()=>g(void 0)},d.rule?`${d.rule.id}:${d.rule.revision}`:`new-${d.event}`)]})}var Ot=`mx-auto w-full max-w-3xl`;function kt(){let e=i(),a=u()?.boardId??``,{isMobile:o,desktopState:c}=m(),l=o||c===`collapsed`,f=C(e.id,a).data?.board,p=d({breadcrumbs:l&&f?(0,Q.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(t,{as:S,to:T(e.id,a),children:f.name}),(0,Q.jsx)(t,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(s,{variant:`narrow`,header:(0,Q.jsxs)(`div`,{className:v(Ot,`pb-8`),children:[(0,Q.jsxs)(r,{children:[(0,Q.jsx)(r.Title,{children:`Rules`}),(0,Q.jsx)(r.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(z,{factoryProjectId:e.id,label:`Test an issue or pull request`})})]}),...p,children:(0,Q.jsx)(`div`,{className:Ot,children:(0,Q.jsx)(Et,{factoryId:e.id,boardId:a})})})}export{kt as BoardRulesPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-BpvMnN1l.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Gn as a,Kn as o,Mr as s,Wn as c,Zn as l,en as u,jr as d,qn as f}from"./index-7W2GRQBh.js";import{A as p,a as m,j as h,p as g}from"./Sidebar.es-DSPzNNju.js";import{O as _,T as v,k as y,n as b}from"./IconChevronRightMedium.es-BjSIsine.js";import{o as x,t as S}from"./lib-DkXXjRNC.js";import{r as C,t as w}from"./useBoardEditor-DiWa4Lcl.js";import{a as T,i as E,o as D,s as O,t as k}from"./boardConfigPaths-Btimpi_r.js";import{At as A,Dt as j,Fi as M,St as N,jt as ee,kt as P,n as F,t as te,wt as ne}from"./GithubIcon.es-BPBhMx2H.js";import{tt as I}from"./icons-C18D46Pv.js";import{n as L}from"./useBoardCatalog-vK4woIAH.js";import{c as re,d as ie,l as R,n as z,r as ae,s as B,t as V,u as H}from"./useRowDrag-Bmj1hhAE.js";import{a as oe,d as se,f as U,g as W,o as G,r as K,s as ce}from"./useIntakeRoutes-CdL4o1Vv.js";import{C as le,E as ue,_ as de,a as fe,c as q,d as pe,f as me,g as he,i as ge,l as J,m as _e,n as ve,o as ye,s as be,u as Y,w as xe}from"./ruleLanes-DEg70O95.js";import{t as X}from"./createLucideIcon-B6gALBEh.js";import{a as Se,t as Ce}from"./BoardIcons-Cml_taka.js";import{t as we}from"./input-DqReKX0A-BMaPtvZH.js";import{n as Te,t as Ee}from"./RadioGroup.es-CyxlfqIJ.js";import{n as De,t as Oe}from"./ConditionRows-BV6wHoaG.js";import{E as ke}from"./combobox-parts-Bmj5kzrt-DzYjyBt5.js";var Ae={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ae.node;var je=X(Ae),Me={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Me.node;var Ne=X(Me),Pe={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Pe.node;var Fe=X(Pe),Ie={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Ie.node;var Le=X(Ie),Re={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Re.node;var ze=X(Re),Be={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};Be.node;var Ve=X(Be),He={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};He.node;var Ue=X(He),We={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};We.node;var Ge=X(We),Ke={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ke.node;var qe=X(Ke),Je={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Je.node;var Ye=X(Je),Xe={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Xe.node;var Ze=X(Xe),Z=e(y(),1),Q=_();function Qe({when:e,options:t,everything:n}){let r=le(e,t);return!e||!r?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:n}):(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:r.parts.map((t,n)=>{let i=e.conditions[n],a=i&&`conditions`in i?i:void 0;return(0,Q.jsxs)(`span`,{className:`contents`,children:[n>0&&(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:r.join}),a?(0,Q.jsxs)(`span`,{className:`border-border inline-flex max-w-full items-center gap-1 rounded-md border border-dashed px-1 py-0.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Q.jsx)($e,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Q.jsx)($e,{children:t})]},n)})})}function $e({children:e}){return(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}function et({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let i=e.find(e=>e.id===n);if(!i)return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let o=r??i.initialPhase,s=i.phases.find(e=>e.id===o);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[i.id!==t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:c(i)}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),s&&(0,Q.jsx)(Ce,{stage:s.id,kind:Se(i.id,s.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:a(i,o)??o})]})}function tt({factoryId:e,rules:t,board:n,boards:r}){return(0,Q.jsxs)(`section`,{"aria-label":`From other boards`,className:`border-border mt-3 flex flex-col gap-1.5 border-t pt-3`,children:[(0,Q.jsxs)(b,{as:`h4`,variant:`meta`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ge,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),`From other boards`]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(t=>{let i=r.find(e=>e.id===t.target.boardKey);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(S,{to:O(e,t.target.boardKey),"aria-label":`${t.name}, on ${i?c(i):t.target.boardKey}`,className:v(`group flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,!t.enabled&&`opacity-50`),children:[(0,Q.jsxs)(`span`,{className:`border-border group-hover:border-border-hover flex w-full min-w-0 flex-col gap-1 rounded-lg border border-dashed px-3 py-2 sm:flex-1`,children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:i?c(i):`${t.target.boardKey} (not installed)`}),(0,Q.jsx)(Qe,{when:t.when,options:o(i),everything:`Every card`})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`border-border-strong h-0 w-8 shrink-0 border-t border-dashed`}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex w-44 shrink-0 items-center px-3 py-2`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:n.id,phaseKey:t.target.phaseKey})})]}),!t.enabled&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`Off`})]})},t.id)})})]})}function nt({factoryId:e,boardKey:t,order:n,evaluator:r}){let i=n.some(e=>e.boardKey===t);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r===`route-list`?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Intake still files new issues and pull requests by the old route list, not by board.`}):i?(0,Q.jsxs)(`ol`,{"aria-label":`Intake order`,className:`flex flex-wrap items-center gap-1`,children:[n.map(n=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`li`,{children:n.boardKey===t?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,"aria-current":`step`,className:`bg-surface3 rounded-md px-2 py-0.5 font-medium`,children:n.name}):(0,Q.jsx)(S,{to:O(e,n.boardKey),className:`text-muted-foreground hover:text-foreground rounded-md px-2 py-0.5`,children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,children:n.name})})}),(0,Q.jsx)(Fe,{"aria-hidden":!0,className:`text-muted-foreground size-icon-xs shrink-0`})]},n.boardKey)),(0,Q.jsx)(`li`,{children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`px-2 py-0.5`,children:`Not routed`})})]}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Not in the intake order: new issues and pull requests never reach these rules.`}),(0,Q.jsxs)(S,{to:D(e,t,k),className:`text-muted-foreground hover:text-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(Ue,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`underline decoration-dotted underline-offset-2`,children:`Reorder`})]})]})}var rt=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,it=`border-border-focus bg-fill-hover`,at=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function ot({selected:e,disabled:t,onClick:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,onClick:n,className:v(rt,`disabled:opacity-50`,e?it:at),children:r})}function st({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`label`,{onClick:r,className:v(rt,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?it:at,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsx)(Te,{value:e,disabled:n,"aria-labelledby":a,className:`sr-only`}),(0,Q.jsx)(`span`,{id:a,className:`flex min-w-0 items-start gap-3`,children:i})]})}function ct(){return(0,Q.jsx)(p,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(te,{"aria-hidden":`true`}),children:`GitHub only`})}var lt=120,ut=W(ce),$=[{id:`trigger`,title:`Trigger`,question:`What should this rule listen for?`},{id:`conditions`,title:`Only if`,question:`Which items should it apply to?`},{id:`action`,title:`Move to`,question:`Where should it go?`},{id:`review`,title:`Review`,question:`Name and check your rule`}];function dt(e,t){let n=e?.phases??[];return t?n.filter(e=>e.kind!==`terminal`):n}function ft(e,t){if(t){let e=ut.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return U(e,t)??void 0}function pt(e,t,n){let r=`When ${e.map(e=>Y(e).label.toLowerCase()).join(` or `)}${t?`, ${xe(t).charAt(0).toLowerCase()}${xe(t).slice(1)}`:``}, move to ${n}`;return r.length>lt?`${r.slice(0,119)}…`:r}function mt({factoryId:e,board:t,boards:n,initial:r,initialEvent:i,initialStep:s,readOnly:l,saving:u,error:d,onSave:f,onClose:p}){let m=De(e),[h,g]=(0,Z.useState)(()=>r?.on??(i?[i]:[])),[_,y]=(0,Z.useState)(()=>r?.when??null),[x,S]=(0,Z.useState)(()=>(r?.when?.conditions.length??0)>0),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(()=>r?.target.moveToBoardKey??t.id),[D,O]=(0,Z.useState)(()=>r?r.target.phaseKey??void 0:void 0),[k,te]=(0,Z.useState)(()=>r?.name),[I,L]=(0,Z.useState)(s),[re,ie]=(0,Z.useState)(0),R=_e(h),z=n.find(e=>e.id===T),ae=dt(z,R),B=ae.find(e=>e.id===(D??z?.initialPhase)),V=x?_:null,H=h.length?ft(h,V):void 0,oe=B&&z?`${c(z)} › ${a(z,B.id)}`:``,U=k??(B?pt(h,V,oe):``),W={trigger:h.length>0,conditions:h.length>0&&!(x&&C)&&!H,action:B!==void 0,review:U.trim().length>0},G=!l&&W.trigger&&W.conditions&&W.action&&W.review,K=$.findIndex(e=>e.id===I),ce=$[K]??$[0],le=e=>{g(e),_e(e)&&T!==t.id&&(E(t.id),O(void 0))},de=()=>{G&&B&&f({name:U.trim(),on:h,when:V,target:{phaseKey:B.id,moveToBoardKey:T===t.id?null:T}})},fe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};y(V===null?{operator:`AND`,conditions:[e]}:V.operator===`AND`?{...V,conditions:[...V.conditions,e]}:{operator:`AND`,conditions:[V,e]}),S(!0),w(!1),ie(e=>e+1)},q={trigger:h.length?h.map(e=>Y(e).label).join(`, `):void 0,conditions:h.length?xe(V,o(t)):void 0,action:B?(0,Q.jsx)(et,{boards:n,ownBoard:t.id,boardKey:T,phaseKey:B.id}):void 0,review:void 0};return(0,Q.jsx)(N,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(j,{size:`xl`,children:[(0,Q.jsx)(A,{children:(0,Q.jsx)(ee,{children:l?`Rule`:r?`Edit rule`:`Add rule`})}),(0,Q.jsx)(ne,{children:(0,Q.jsxs)(`div`,{className:`grid min-h-105 grid-cols-1 gap-6 sm:grid-cols-[12rem_1fr]`,children:[(0,Q.jsx)(`nav`,{"aria-label":`Rule steps`,className:`sm:border-border flex gap-1 overflow-x-auto sm:flex-col sm:border-r sm:pr-4`,children:$.map((e,t)=>{let n=t===0||$.slice(0,t).every(e=>W[e.id]),r=W[e.id]&&e.id!==`review`;return(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":I===e.id?`step`:void 0,onClick:()=>L(e.id),className:v(`flex shrink-0 items-start gap-2.5 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-40`,I===e.id?`bg-fill-hover`:`hover:bg-fill-subtle`),children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,className:v(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border`,r?`border-transparent bg-fill-inverse text-background`:`border-border-strong`),children:r?(0,Q.jsx)(Ne,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),q[e.id]&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:q[e.id]})]})]},e.id)})}),(0,Q.jsxs)(`section`,{"aria-label":ce.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsx)(b,{as:`h3`,variant:`heading`,children:ce.question}),I===`trigger`&&(0,Q.jsx)(_t,{value:h,disabled:l,onChange:le}),I===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(Ee,{"aria-label":`Which ones`,value:x?`matching`:`every`,disabled:l,onValueChange:e=>{S(e===`matching`),w(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Q.jsx)(st,{value:`every`,selected:!x,disabled:l,children:(0,Q.jsx)(ht,{title:R?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(st,{value:`matching`,selected:x,disabled:l,children:(0,Q.jsx)(ht,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),x&&(0,Q.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Q.jsx)(Oe,{label:`Conditions`,rule:_,facts:ue(h),options:{...o(t),"source.repository":m},onChange:(e,t)=>{y(e),w(t)}},re)}),H&&(0,Q.jsx)(F,{variant:`warning`,children:H}),!r?.outsiderPullRequestsGated&&se(h,V)&&(0,Q.jsx)(F,{variant:`info`,children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{children:`Also matches pull requests from outside authors.`}),!l&&(0,Q.jsx)(`button`,{type:`button`,onClick:fe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),I===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[R?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`An item with no card yet can only be filed on this board.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Q.jsx)(Ee,{"aria-label":`Board`,value:T,disabled:l,onValueChange:e=>{typeof e==`string`&&e!==T&&(E(e),O(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:n.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===T,disabled:l,children:(0,Q.jsxs)(b,{as:`span`,variant:`label`,tone:`ink`,children:[c(e),e.id===t.id?` (this board)`:``]})},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Q.jsx)(Ee,{"aria-label":`Phase`,value:B?.id??null,disabled:l,onValueChange:e=>typeof e==`string`&&O(e),className:`grid-cols-1 sm:grid-cols-2`,children:z&&ae.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===B?.id,disabled:l,onClick:()=>{O(e.id),L(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ce,{stage:e.id,kind:Se(z.id,e.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,children:a(z,e.id)})]})},e.id))})]})]}),I===`review`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Q.jsx)(we,{value:U,maxLength:lt,disabled:l,onChange:e=>te(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,className:`mb-3 block`,children:`This rule reads as`}),(0,Q.jsxs)(`ol`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(gt,{label:`When`,children:q.trigger}),(0,Q.jsx)(gt,{label:`Only if`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(ze,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),q.conditions]})}),(0,Q.jsx)(gt,{label:`Then`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Q.jsx)(je,{className:`size-icon-sm`,"aria-hidden":!0}),` `,q.action]})})]})]})]}),d&&(0,Q.jsx)(F,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(P,{children:[(0,Q.jsx)(M,{variant:`ghost`,onClick:p,children:l?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),K>0&&(0,Q.jsx)(M,{variant:`default`,onClick:()=>L($[K-1].id),children:`Back`}),!l&&(I===`review`||r&&G?(0,Q.jsx)(M,{variant:`primary`,disabled:!G||u,onClick:de,children:u?`Saving…`:r?`Save rule`:`Create rule`}):(0,Q.jsx)(M,{variant:`primary`,disabled:!W[I],onClick:()=>L($[K+1]?.id??`review`),children:`Continue`}))]})]})})}function ht({title:e,hint:t}){return(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function gt({label:e,children:t}){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,children:t})]})}function _t({value:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.includes(`work_item.created`)&&(0,Q.jsxs)(F,{variant:`info`,children:[`Also listens on “`,Y(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),ve.map(r=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:r.title}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.events.map(r=>{let i=Y(r),a=i.icon,o=e.includes(r);return(0,Q.jsxs)(ot,{selected:o,disabled:t||o&&e.length===1,onClick:()=>n(o?e.filter(e=>e!==r):[...e,r]),children:[(0,Q.jsx)(a,{className:`text-badge-amber-indicator mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(ht,{title:i.label,hint:i.description}),i.githubOnly&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(ct,{})})]},r)})})]},r.title))]})}function vt({count:e,into:t,leaving:n,showAll:r}){let i=n?`sending cards to ${t}`:`moving cards into ${t}`;return(0,Q.jsxs)(`div`,{className:`border-border flex items-center gap-2 rounded-lg border px-3 py-2`,children:[(0,Q.jsx)(Ve,{className:`size-icon-md text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`p`,variant:`body-sm`,tone:e===void 0?`muted`:`ink`,className:`flex-1`,children:e===void 0?`Couldn’t pick out the rules ${i}, so every rule is shown.`:e===0?`No rule is ${i}.`:`Only the ${e===1?`rule`:`${e} rules`} ${i}.`}),(0,Q.jsx)(M,{size:`sm`,variant:`ghost`,render:(0,Q.jsx)(S,{to:r}),children:`Show all`})]})}var yt=v(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:-top-1 data-[drop=before]:before:block data-[drop=after]:before:-bottom-1 data-[drop=after]:before:block`);function bt({event:e,rules:t,board:n,boards:r,phaseOptions:i,canEdit:o,skips:s,footer:l,incoming:u,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:_,onUngate:y}){let x=Y(e),S=x.icon,C=fe(t,e),w=q(e),T=ye(e),E=V({min:0,max:t.length-1,onDrop:m}),D=o&&t.length>1&&!d,O=l??(t.length?`Otherwise, the card stays where it is`:u?`No rules: this board’s cards stay where they are`:`No rules: the card stays where it is`);return(0,Q.jsxs)(`section`,{"aria-label":x.label,className:v(`flex flex-col gap-3 rounded-xl border border-border bg-card p-4`,!t.length&&!u&&`opacity-60 focus-within:opacity-100 hover:opacity-100`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(S,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`h3`,variant:`label`,tone:`ink`,children:x.label}),x.githubOnly&&(0,Q.jsx)(ct,{})]}),x.description&&(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:x.description})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`${x.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((l,u)=>{if(d&&!d.has(l.id))return null;let p=he(t,e,u),S=p>=0,O=!l.enabled||S,k=E.drag?.from===u,A=s?.get(l.id),j=r.find(e=>e.id===(l.target.moveToBoardKey??l.target.boardKey)),N=!me(l.name,[x.label,xe(l.when,i),j&&c(j),a(j,l.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":l.name,"data-drop":E.dropAt(u),style:k?{transform:`translateY(${E.drag?.offset??0}px)`}:void 0,onPointerDown:D?e=>E.onPointerDown(e,u):void 0,className:v(`group/rule flex flex-col`,yt,k&&`z-10 opacity-90`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 sm:flex-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Edit conditions of ${l.name}`,onClick:()=>f(l,`conditions`),onKeyDown:D?e=>E.onKeyDown(e,u):void 0,className:v(`flex w-full items-start gap-2.5 rounded-lg border bg-fill-subtle px-3 py-2 text-left transition-colors hover:border-border-hover`,O?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Q.jsxs)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`bg-fill mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full tabular-nums`,children:[(0,Q.jsx)(`span`,{className:v(D&&`pointer-fine:group-hover/rule:hidden`,k&&`hidden`),children:u+1}),D&&(0,Q.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:v(`hidden cursor-grab touch-none pointer-fine:group-hover/rule:flex`,k&&`flex`),children:(0,Q.jsx)(re,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[N&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:l.name}),(0,Q.jsx)(Qe,{when:l.when,options:i,everything:T})]})]}),D&&(0,Q.jsxs)(`div`,{className:`border-border bg-card absolute top-0 right-2 flex -translate-y-1/2 rounded-md border shadow-sm transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/rule:opacity-100 pointer-fine:group-hover/rule:opacity-100`,children:[(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:u===0,onClick:()=>m(u,u-1),children:(0,Q.jsx)(H,{})}),(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:u===t.length-1,onClick:()=>m(u,u+1),children:(0,Q.jsx)(ie,{})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 sm:shrink-0`,children:[(0,Q.jsxs)(`div`,{className:v(`flex min-w-0 items-center`,O&&`opacity-40`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:v(`h-px w-8 shrink-0`,O?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit where ${l.name} moves the card`,onClick:()=>f(l,`action`),className:`border-border bg-fill-subtle hover:border-border-hover flex w-44 shrink-0 rounded-lg border px-3 py-2 text-left`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:l.target.moveToBoardKey??l.target.boardKey,phaseKey:l.target.phaseKey})})]}),o&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(ke,{"aria-label":`${l.name} on`,checked:l.enabled,onCheckedChange:e=>h(l,e)}),(0,Q.jsxs)(g,{children:[(0,Q.jsx)(g.Trigger,{render:(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${l.name}`,children:(0,Q.jsx)(Le,{})})}),(0,Q.jsx)(g.Content,{align:`end`,children:(0,Q.jsxs)(g.Item,{variant:`destructive`,onClick:()=>_(l),children:[(0,Q.jsx)(Ye,{}),`Delete rule`]})})]})]})]})]}),O&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:S?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,p+1,` above matches `,T.toLowerCase(),`.`]}):`Off, skipped`}),l.problems.map(e=>(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),A&&(0,Q.jsx)(St,{skips:A}),de(l,e)&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[`Skips outside authors’ pull requests (older rule).`,o&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(l),className:`underline`,children:`Let outside authors match`})]}),pe(l,e)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),w&&be(l)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:Y(`work_item.created`).label}),u!==C&&!d&&(0,Q.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-7 items-center pl-5.5`,children:[(0,Q.jsx)(`span`,{className:`bg-border-strong h-full w-px`}),(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},l.id)}),!d&&(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[C<0&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`flex flex-1 items-center gap-2.5 px-3 py-1.5`,children:[(0,Q.jsx)(R,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),O]}),o&&(0,Q.jsx)(M,{variant:`ghost`,size:`sm`,icon:(0,Q.jsx)(qe,{}),onClick:p,children:`Add rule`})]})]}),u]})]})}function xt(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function St({skips:e}){let{count:t,latest:n}=e;return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[`Skipped `,t===1?`once`:`${t} times`,` in the last 30 days: `,xt(n.reason),`.`]}),n.url?(0,Q.jsxs)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`Latest: `,n.title]}):(0,Q.jsxs)(`span`,{children:[`Latest: `,n.title]})]})}var Ct=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function wt(e){return e instanceof w&&e.code!==void 0&&Ct.has(e.code)}function Tt(e){return wt(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function Et({factoryId:e,boardId:t}){let n=L(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(h,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(F,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Q.jsx)(Dt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Q.jsx)(F,{variant:`warning`,children:`This board isn’t installed.`})}function Dt({factoryId:e,board:t,boards:n}){let r=K(e,t.id),i=G(e),s=ae(e),c=B(e),u=oe(e),[d,p]=(0,Z.useState)(),m=(0,Z.useRef)(void 0),g=e=>{m.current=e,p(e)},[_,v]=(0,Z.useState)(),y=r.data?.intakeRoutes??[],S=r.data?.canEdit??!1,C=o(t),w=(i.data?.intakeRoutes??[]).filter(e=>e.target.moveToBoardKey===t.id&&e.target.boardKey!==t.id),T=new Map(c.data?.skipped.map(e=>[e.routeId,e])),[D]=x(),k=D.get(`into`)??void 0,A=D.has(E),j=A||k!==void 0,M=j&&i.data?l(i.data.intakeRoutes,{key:t.id,initialPhase:t.initialPhase}):void 0,N=M&&new Set((A?M.leaving:M.into.get(k??``)??[]).map(e=>e.id)),ee=e=>!N||e.some(e=>N.has(e.id));if(r.isPending||j&&i.isPending)return(0,Q.jsx)(h,{className:`h-64 w-full`});if(r.isError)return(0,Q.jsx)(F,{variant:`destructive`,children:`This board’s rules didn’t load.`});let P=e=>u.mutateAsync(e).catch(e=>I.error(Tt(e))),te=(e,n,r)=>{let i=J(y,e).map(e=>e.id);P([{kind:`reorder`,boardKey:t.id,ids:f(y,i,n,r)}])},ne=e=>{v(void 0),g(e)},L=async e=>{let n=m.current,r=n?.rule,i=()=>n!==void 0&&m.current===n;v(void 0);try{if(r)await u.mutateAsync([{kind:`update`,id:r.id,patch:{name:e.name,on:e.on,when:e.when,target:{boardKey:r.target.boardKey,...e.target,joinClosedIssue:r.target.joinClosedIssue},expectedRevision:r.revision}}]);else{let[n]=await u.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:t.id,...e.target}}}]);i()&&g(void 0),n&&await ie(n,e.on).catch(e=>I.error(Tt(e)));return}i()&&g(void 0)}catch(e){if(!i())return;if(r&&wt(e))return re(r);v(Tt(e))}},re=async e=>{let t=m.current,n=(await r.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&m.current===t&&(n?(g({...t,rule:n}),v(`Someone else changed this rule first. It now shows their version; make your change again.`)):(g(void 0),I.error(`Someone else deleted this rule first.`)))},ie=async(e,n)=>{if(e.target.boardKey!==t.id)return;let i=(await r.refetch()).data?.intakeRoutes??[],a=i.map(e=>e.id),o=a.indexOf(e.id),s=n.flatMap(t=>{let n=J(i,t),r=n[he(n,t,n.findIndex(t=>t.id===e.id))];return r?[a.indexOf(r.id)]:[]}),c=Math.min(...s);o<0||!(c<o)||await u.mutateAsync([{kind:`reorder`,boardKey:t.id,ids:f(i,a,o,c)}])},R=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:ge(s.data?.boards,t.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[i.isError&&(0,Q.jsx)(F,{variant:`warning`,children:`Rules on other boards that move cards here didn’t load, so they aren’t shown.`}),j&&(0,Q.jsx)(vt,{count:N?.size,into:A||!k?`other boards`:a(t,k)??k,leaving:A,showAll:O(e,t.id)}),ve.filter(e=>e.events.some(e=>ee([...J(y,e),...J(w,e)]))).map(r=>(0,Q.jsxs)(`section`,{"aria-label":r.title,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`h2`,variant:`subheading`,tone:`ink`,children:r.title}),r.events.some(q)?s.data&&(0,Q.jsx)(nt,{factoryId:e,boardKey:t.id,order:s.data.boards,evaluator:s.data.evaluator}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Only cards already on this board; other boards never see them.`})]}),r.events.map(r=>{let i=q(r),a=J(y,r),o=J(w,r).filter(e=>!N||N.has(e.id));return ee([...a,...o])?(0,Q.jsx)(bt,{event:r,rules:a,board:t,boards:n,phaseOptions:C,canEdit:S,skips:T,footer:i?R:void 0,only:N,incoming:o.length?(0,Q.jsx)(tt,{factoryId:e,rules:o,board:t,boards:n}):void 0,onEdit:(e,t)=>ne({rule:e,step:t}),onAdd:()=>ne({event:r,step:`conditions`}),onMove:(e,t)=>te(r,e,t),onToggle:(e,t)=>void P([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void P([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&I.success(`Deleted “${e.name}”`)),onUngate:e=>void P([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&I.success(`“${e.name}” now matches outside authors’ pull requests`))},r):null})]},r.title)),d&&(0,Q.jsx)(mt,{factoryId:e,board:t,boards:n,initial:d.rule,initialEvent:d.event,initialStep:d.step,readOnly:!S,saving:u.isPending,error:_,onSave:e=>void L(e),onClose:()=>g(void 0)},d.rule?`${d.rule.id}:${d.rule.revision}`:`new-${d.event}`)]})}var Ot=`mx-auto w-full max-w-3xl`;function kt(){let e=i(),a=u()?.boardId??``,{isMobile:o,desktopState:c}=m(),l=o||c===`collapsed`,f=C(e.id,a).data?.board,p=d({breadcrumbs:l&&f?(0,Q.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(t,{as:S,to:T(e.id,a),children:f.name}),(0,Q.jsx)(t,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(s,{variant:`narrow`,header:(0,Q.jsxs)(`div`,{className:v(Ot,`pb-8`),children:[(0,Q.jsxs)(r,{children:[(0,Q.jsx)(r.Title,{children:`Rules`}),(0,Q.jsx)(r.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(z,{factoryProjectId:e.id,label:`Test an issue or pull request`})})]}),...p,children:(0,Q.jsx)(`div`,{className:Ot,children:(0,Q.jsx)(Et,{factoryId:e.id,boardId:a})})})}export{kt as BoardRulesPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{O as t,T as n,f as r,i,k as a,n as o,s}from"./IconChevronRightMedium.es-BjSIsine.js";import{Fi as c,c as l,h as u,qn as d}from"./GithubIcon.es-BPBhMx2H.js";import{c as f,d as p,l as m,u as h}from"./icons-C18D46Pv.js";import{t as g}from"./IconPlusMedium.es-QmObHPf-.js";import{a as _,c as v,d as y,i as b,l as x,s as S,u as C}from"./combobox-parts-Bmj5kzrt-DzYjyBt5.js";import{t as ee}from"./IconUser.es-8QnHQfy-.js";import{H as w,U as T}from"./useSessionRows-BXScIz1L.js";import{t as te}from"./IconCircleCheck.es-e9o_0ikv.js";import{D as ne,O as re,S as ie,b as E,x as D}from"./ruleLanes-DEg70O95.js";import{m as ae}from"./useIntakeRoutes-CdL4o1Vv.js";import{t as oe}from"./createLucideIcon-B6gALBEh.js";import{t as se}from"./TrashIcon.es-CLx-KWTg.js";import{t as ce}from"./input-DqReKX0A-BMaPtvZH.js";import{d as le,o as ue,r as de}from"./useLinearData-C1EljeRN.js";import{t as fe}from"./IconUserDuo.es-X0H45vYw.js";import{Dn as pe,Ln as O,Rn as k,_r as me,br as he,gr as ge,wn as _e}from"./index-7W2GRQBh.js";import{t as ve}from"./IconHashtag.es-DPNqJOUe.js";import{t as A}from"./IconPlugin1.es-cRNReen7.js";import{t as j}from"./IconShieldCheck.es-vPJGxBAr.js";var M={name:`folder-git-2`,size:24,node:[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]};M.node;var ye=oe(M);function be({factoryProjectId:e,repositories:t=[],bindings:n=[],linearProjects:r=[],linearTeams:i=[],jiraProjects:a=[]}){let o=t=>new Set(n.filter(n=>n.integrationId===t&&n.factoryProjectId===e).map(e=>e.sourceId)),s=o(`linear`),c=o(`jira`),l=[...t.map(e=>({value:e.slug,provider:e.provider??`github`})),...r.filter(e=>s.has(e.id)).flatMap(e=>e.teams.map(e=>({value:e.key,provider:`linear`}))),...i.filter(e=>s.has(le(e))).map(e=>({value:e.key,provider:`linear`})),...a.filter(e=>c.has(e.id)).map(e=>({value:e.key,provider:`jira`}))],u=new Set;return l.filter(e=>{let t=`${e.provider}\0${e.value.toLowerCase()}`;return!u.has(t)&&(u.add(t),!0)})}var xe=e=>`provider`in e&&typeof e.provider==`string`;function Se(e,t){if(!Array.isArray(e.suggestions))return e;let n=me(t),r=new Set;return{...e,suggestions:e.suggestions.filter(e=>{if(n&&xe(e)&&!n.has(e.provider))return!1;let t=e.value.toLowerCase();return!r.has(t)&&(r.add(t),!0)})}}function Ce(e){let t=l(e),n=u(),r=t=>(n.data??[]).some(n=>n.integrationId===t&&n.factoryProjectId===e),i=de(r(`linear`)),a=ue(r(`linear`)),o=pe(r(`jira`));return be({factoryProjectId:e,repositories:t.data?.repositories,bindings:n.data,linearProjects:i.data?.projects,linearTeams:a.data?.teams,jiraProjects:o.data})}var N=t(),P=`flex h-control-sm w-14 shrink-0 items-center`;function F({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-lines`,className:n(`flex flex-col gap-2`,e),...t})}function I({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line`,className:n(`flex items-start gap-2`,e),...t})}function L({className:e,children:t,...r}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-keyword`,"aria-hidden":t===void 0||void 0,className:n(P,i({variant:`caption`,tone:`muted`}),e),...r,children:t})}function we({value:e,onValueChange:t,"aria-label":n=`Match all or any`}){return(0,N.jsx)(`div`,{"data-slot":`rule-line-logic`,className:P,children:(0,N.jsxs)(f,{value:e,onValueChange:e=>e&&t(e),children:[(0,N.jsx)(p,{size:`sm`,variant:`ghost`,"aria-label":n,className:`-ml-2 w-fit px-2`,children:(0,N.jsx)(`span`,{className:i({variant:`caption`,tone:`ink`}),children:e===`AND`?`and`:`or`})}),(0,N.jsxs)(m,{children:[(0,N.jsx)(h,{value:`AND`,children:`and`}),(0,N.jsx)(h,{value:`OR`,children:`or`})]})]})})}function R({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line-content`,className:n(`flex min-h-control-sm min-w-0 flex-1 flex-wrap items-center gap-1.5`,e),...t})}function Te({depth:e,className:t,...r}){return(0,N.jsx)(`div`,{role:`group`,"data-slot":`rule-line-group`,className:n(`flex min-w-0 flex-1 items-start gap-2 rounded-lg border border-border p-2`,e%2==0?`bg-fill-subtle`:`bg-card`,`[&>[data-slot=rule-lines]]:min-w-0 [&>[data-slot=rule-lines]]:flex-1`,t),...r})}function Ee({className:e,...t}){return(0,N.jsx)(c,{variant:`ghost`,size:`icon-sm`,className:n(`ml-auto`,e),...t,children:(0,N.jsx)(d,{})})}function De({className:e,children:t,...r}){return(0,N.jsxs)(c,{variant:`ghost`,size:`sm`,className:n(`ml-auto`,e),...r,children:[(0,N.jsx)(se,{}),t]})}function Oe({className:e,...t}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-hint`,className:n(i({variant:`caption`,tone:`muted`}),`px-1`,e),...t})}function z({icon:e,className:t,children:r,...a}){return(0,N.jsxs)(`button`,{type:`button`,"data-slot":`rule-add-button`,className:n(i({variant:`caption`,tone:`muted`}),`inline-flex h-control-sm items-center gap-1.5 rounded-full border border-dashed border-border px-3 hover:border-border-strong hover:text-foreground [&_svg]:size-icon-sm`,s,t),...a,children:[e,r]})}var ke=r(`IconColumns3`,()=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`path`,{d:`M18 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V6C20 4.89543 19.1046 4 18 4Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M9.33984 4V20`,stroke:`currentColor`,strokeWidth:`2`}),(0,N.jsx)(`path`,{d:`M14.6602 4V20`,stroke:`currentColor`,strokeWidth:`2`})]})),Ae=r(`IconFontStyle`,()=>(0,N.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M19.4639 19H20C20.5523 19 21 19.4477 21 20C21 20.5523 20.5523 21 20 21H14.5C13.9477 21 13.5 20.5523 13.5 20C13.5 19.4477 13.9477 19 14.5 19H15.2578L13.9551 15H8.15625L6.85449 19H7.5C8.05228 19 8.5 19.4477 8.5 20C8.5 20.5523 8.05228 21 7.5 21H4.5C3.94772 21 3.5 20.5523 3.5 20C3.5 19.4477 3.94772 19 4.5 19H4.75L9.29418 5.04203C9.69064 3.82426 10.8258 3 12.1065 3C13.3871 3 14.5223 3.82418 14.9188 5.04188L19.4639 19ZM8.80762 13H13.3037L11.3409 6.97096C11.251 6.69479 10.8603 6.69479 10.7704 6.97096L8.80762 13Z`,fill:`currentColor`})),je=r(`IconMerged`,()=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`circle`,{cx:`18`,cy:`18`,r:`2`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M6 8V16`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M8 6H16C17.1046 6 18 6.89543 18 8V16`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),Me=r(`IconZap`,()=>(0,N.jsx)(`path`,{d:`M19.5657 9H13.5C13.2239 9 13 8.77614 13 8.5V2.40139C13 1.90668 12.3584 1.71242 12.084 2.12404L4.01823 14.2226C3.79672 14.5549 4.03491 15 4.43426 15H10.5C10.7761 15 11 15.2239 11 15.5V21.5986C11 22.0933 11.6416 22.2876 11.916 21.876L19.9818 9.77735C20.2033 9.44507 19.9651 9 19.5657 9Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`})),B=e(a(),1),V=new Set([`exists`,`not_exists`]),H=new Set([`in`,`not_in`]),U=e=>`items`in e,Ne=0,W=()=>`condition-${++Ne}`,G=()=>({key:W(),field:``,operator:``}),Pe=e=>e+2<=3;function Fe(e){let t=e=>`conditions`in e?{key:W(),logic:e.operator,items:e.conditions.map(t)}:{key:W(),field:e.field,operator:e.operator,value:e.value};return{key:`root`,logic:e?.operator??`AND`,items:e?.conditions.map(t)??[]}}var Ie=e=>ae.some(t=>t===e);function Le(e){if(!e.field)return!1;if(V.has(e.operator))return!0;let{value:t}=e;return t===void 0?!1:Array.isArray(t)?t.length>0:typeof t!=`string`||t.trim()!==``}function K(e){let t=!1,n=e=>{if(U(e)){let t=e.items.map(n).filter(e=>e!==void 0);return t.length>0?{operator:e.logic,conditions:t}:void 0}let{operator:r}=e;if(!Ie(r)||!Le(e))t=!0;else return V.has(r)?{field:e.field,operator:r}:{field:e.field,operator:r,value:e.value}},r=e.items.map(n).filter(e=>e!==void 0);return{rule:r.length>0?{operator:e.logic,conditions:r}:null,incomplete:t}}function q(e,t,n){if(!V.has(t))return e.type===`boolean`?typeof n!=`boolean`||n:H.has(t)?Array.isArray(n)?n:n===void 0||n===``?[]:[n]:Array.isArray(n)?n[0]:n}var Re=r(`IconListAdd`,()=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`path`,{d:`M4 6H20`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M4 12H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M15 15L21 15`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M18 12V18`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M4 18H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),ze={"item.labels":_e,"item.title":Ae,"item.author":ee,"item.key":ve,"item.state":w,"item.assignees":fe,"item.pullRequest":T,"item.trusted":j,"pullRequest.trusted":j,"source.kind":T,"source.integration":A,"source.provider":A,"source.repository":ye,"pullRequest.closesIssue":je,"closedIssue.phase":ke,"closedIssue.hasPullRequest":T,"event.type":Me,"event.reason":te},Be=re();function J(e,t){return e?.operatorLabels?.[t]??E.find(e=>e.id===t)?.label??t}function Y(e){return Array.isArray(e?.suggestions)&&e.suggestions.length>0?e.suggestions:void 0}function Ve({label:e,rule:t,facts:n,options:r,emptyHint:i,onChange:a}){let s=ie(n,r),[c,l]=(0,B.useState)(()=>Fe(t)),{rule:u,incomplete:d}=K(c),f=he(u);return(0,N.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,N.jsx)(X,{role:`group`,"aria-label":e,group:c,depth:0,fields:s,emptyHint:i,onChange:e=>{l(e);let{rule:t,incomplete:n}=K(e);a(t,n)}}),d&&(0,N.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:`Finish or remove unfinished conditions to save.`}),f&&(0,N.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:f})]})}function X({role:e,"aria-label":t,group:n,depth:r,fields:i,limits:a=[],emptyHint:o,onChange:s,onRemove:c}){let l=(e,t)=>s({...n,items:t===void 0?n.items.filter((t,n)=>n!==e):n.items.with(e,t)}),u=e=>s({...n,items:[...n.items,e]}),d=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(z,{icon:(0,N.jsx)(g,{}),onClick:()=>u(G()),children:`Add condition`}),Pe(r)&&(0,N.jsx)(z,{icon:(0,N.jsx)(Re,{}),onClick:()=>u({key:W(),logic:n.logic===`AND`?`OR`:`AND`,items:[G()]}),children:`Add group`}),c&&(0,N.jsx)(De,{onClick:c,children:`Remove group`})]});if(n.items.length===0)return(0,N.jsx)(F,{role:e,"aria-label":t,children:(0,N.jsxs)(I,{children:[(0,N.jsx)(L,{children:`Where`}),(0,N.jsxs)(R,{children:[d,o&&(0,N.jsx)(Oe,{children:o})]})]})});let f=n.logic===`AND`?`and`:`or`,p=ge(n.logic,a,n.items.filter(e=>!U(e)));return(0,N.jsxs)(F,{role:e,"aria-label":t,children:[n.items.map((e,t)=>(0,N.jsxs)(I,{children:[t===1?(0,N.jsx)(we,{value:n.logic,onValueChange:e=>s({...n,logic:e})}):(0,N.jsx)(L,{children:t===0?`Where`:f}),U(e)?(0,N.jsx)(Te,{depth:r,"aria-label":e.logic===`AND`?`All of these`:`Any of these`,children:(0,N.jsx)(X,{group:e,depth:r+1,fields:i,limits:p,onChange:e=>l(t,e.items.length>0?e:void 0),onRemove:()=>l(t,void 0)})}):(0,N.jsx)(He,{row:e,fields:i,limits:p.filter(t=>t!==e),onChange:e=>l(t,e),onRemove:()=>l(t,void 0)})]},e.key)),(0,N.jsxs)(I,{children:[(0,N.jsx)(L,{}),(0,N.jsx)(R,{children:d})]})]})}function Z({id:e}){let t=ze[e]??w;return(0,N.jsx)(t,{"aria-hidden":`true`,className:`text-muted-foreground size-3.5 shrink-0`})}function He({row:e,fields:t,limits:n,onChange:r,onRemove:i}){let a=Be.find(t=>t.id===e.field),s=a&&!t.some(e=>e.id===a.id)?[a,...t]:t,c=s.find(t=>t.id===e.field),l=c&&Se(c,n),u=!!l&&ne(l.id)&&(!e.operator||e.operator===`exists`||e.operator===`not_exists`);return(0,N.jsxs)(R,{children:[(0,N.jsxs)(f,{value:e.field||null,onValueChange:t=>{let n=s.find(e=>e.id===t);if(!n)return;let i=n.operators?.[0]??`equals`;r({...e,field:n.id,operator:i,value:q(n,i,void 0)})},children:[(0,N.jsx)(p,{size:`sm`,"aria-label":`Field`,className:`w-fit max-w-full`,children:(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[l&&(0,N.jsx)(Z,{id:l.id}),(0,N.jsx)(o,{as:`span`,variant:`caption`,className:`truncate`,children:l?.label??(e.field||`Choose a field`)})]})}),(0,N.jsx)(m,{children:s.map(e=>(0,N.jsx)(h,{value:e.id,children:(0,N.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(Z,{id:e.id}),e.label]})},e.id))})]}),l?.type===`boolean`&&(0,N.jsx)(Ue,{row:e,field:l,onChange:r}),l&&u&&(0,N.jsx)(We,{row:e,field:l,onChange:r}),l&&l.type!==`boolean`&&!u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(f,{value:e.operator,onValueChange:t=>t&&r({...e,operator:t,value:q(l,t,e.value)}),children:[(0,N.jsx)(p,{size:`sm`,variant:`ghost`,"aria-label":`Operator`,className:`w-fit`,children:(0,N.jsx)(o,{as:`span`,variant:`caption`,children:J(l,e.operator)})}),(0,N.jsx)(m,{children:(l.operators??[]).map(e=>(0,N.jsx)(h,{value:e,children:J(l,e)},e))})]}),!V.has(e.operator)&&(0,N.jsx)(Ge,{row:e,field:l,onChange:r})]}),(0,N.jsx)(Ee,{"aria-label":`Remove condition`,onClick:i})]})}function Ue({row:e,field:t,onChange:n}){let r=Y(t)??[{value:`true`,label:`Yes`},{value:`false`,label:`No`}],i=e.operator!==`not_equals`==(e.value!==!1);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,N.jsx)(O,{size:`sm`,"aria-label":t.label,value:String(i),onValueChange:t=>n({...e,operator:`equals`,value:t===`true`}),children:r.map(e=>(0,N.jsx)(k,{value:e.value,children:e.label},e.value))})]})}function We({row:e,field:t,onChange:n}){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,N.jsxs)(O,{size:`sm`,"aria-label":t.label,value:e.operator===`not_exists`?`false`:`true`,onValueChange:t=>n({...e,operator:t===`true`?`exists`:`not_exists`,value:void 0}),children:[(0,N.jsx)(k,{value:`true`,children:`Yes`}),(0,N.jsx)(k,{value:`false`,children:`No`})]})]})}function Ge({row:e,field:t,onChange:n}){let r=Y(t),i=H.has(e.operator),a=E.find(t=>t.id===e.operator)?.freeText===!0;if(t.strict===!1&&!a){let a=Array.isArray(e.value)?e.value.map(String):e.value===void 0?[]:[String(e.value)];return(0,N.jsx)(qe,{options:(r??[]).map(e=>({value:e.value,label:e.label??e.value})),values:a,many:i,placeholder:D[t.id]??`Search or type a value`,onChange:t=>n({...e,value:i?t:t[0]})})}if(r&&i){let t=Array.isArray(e.value)?e.value.map(String):[];return(0,N.jsx)(Ke,{options:r.map(e=>({value:e.value,label:e.label??e.value})),values:t,onChange:t=>n({...e,value:t})})}if(r){let t=r.find(t=>t.value===String(e.value??``));return(0,N.jsxs)(f,{value:e.value===void 0?null:String(e.value),onValueChange:t=>t!==null&&n({...e,value:t}),children:[(0,N.jsx)(p,{size:`sm`,"aria-label":`Value`,className:`w-fit`,children:(0,N.jsx)(o,{as:`span`,variant:`caption`,className:`font-medium`,children:t?.label??(e.value===void 0?`Choose a value`:String(e.value))})}),(0,N.jsx)(m,{children:r.map(e=>(0,N.jsx)(h,{value:e.value,children:e.label},e.value))})]})}return(0,N.jsx)(Je,{row:e,field:t,many:i,onChange:n})}function Q(e){return e.length===0?`Choose values`:e.length>3?`${e.slice(0,2).join(`, `)} +${e.length-2}`:e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function Ke({options:e,values:t,onChange:r}){let i=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),a=[...e,...i.filter(t=>!e.includes(t))],s=i.map(e=>e.label);return(0,N.jsxs)(x,{multiple:!0,autoHighlight:!0,items:a,value:i,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:e=>r(e.map(e=>e.value)),children:[(0,N.jsx)(y,{size:`sm`,"aria-label":`Values`,title:s.join(`, `),className:`w-fit max-w-64`,children:(0,N.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,s.length===0&&`text-muted-foreground`),children:Q(s)})}),(0,N.jsxs)(b,{children:[(0,N.jsx)(C,{placeholder:`Search`}),(0,N.jsx)(_,{children:`No option found.`}),(0,N.jsx)(v,{children:e=>(0,N.jsx)(S,{value:e,children:e.label},e.value)})]})]})}function qe({options:e,values:t,many:r,placeholder:i,onChange:a}){let[s,c]=(0,B.useState)(``),l=s.trim(),u=t=>e.some(e=>e.value.toLowerCase()===t.toLowerCase()),d=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),f=[...e,...d.filter(t=>!e.includes(t)),...l&&!u(l)&&!t.includes(l)?[{value:l,label:`Use “${l}”`}]:[]],p=d.map(e=>e.value),m={autoHighlight:!0,items:f,inputValue:s,onInputValueChange:c,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value},h=(0,N.jsxs)(b,{children:[(0,N.jsx)(C,{placeholder:i}),(0,N.jsx)(_,{children:`Type a value to use it.`}),(0,N.jsx)(v,{children:e=>(0,N.jsx)(S,{value:e,children:e.label},e.value)})]}),g=(0,N.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,p.length===0&&`text-muted-foreground`),children:p.length===0?i:Q(p)});return r?(0,N.jsxs)(x,{...m,multiple:!0,value:d,onValueChange:e=>a(e.map(e=>e.value)),children:[(0,N.jsx)(y,{size:`sm`,"aria-label":`Values`,title:p.join(`, `),className:`w-fit max-w-64`,children:g}),h]}):(0,N.jsxs)(x,{...m,value:d[0]??null,onValueChange:e=>e&&a([e.value]),children:[(0,N.jsx)(y,{size:`sm`,"aria-label":`Value`,title:p[0],className:`w-fit max-w-64`,children:g}),h]})}function $(e){return Array.isArray(e)?e.join(`, `):e===void 0?``:String(e)}function Je({row:e,field:t,many:n,onChange:r}){let[i,a]=(0,B.useState)(),o=i??$(e.value),s=()=>{if(i===void 0||(a(void 0),i===$(e.value)))return;if(n){let t=i.split(`,`).map(e=>e.trim());r({...e,value:t.filter(e=>e!==``)});return}if(t.type!==`number`){r({...e,value:i.trim()});return}let o=Number(i.trim());r({...e,value:i.trim()!==``&&Number.isFinite(o)?o:void 0})};return(0,N.jsx)(ce,{size:`sm`,"aria-label":`Value`,type:t.type===`number`&&!n?`number`:`text`,placeholder:D[t.id]??(n?`Values, comma separated`:`Value`),value:o,className:`w-48`,onChange:e=>a(e.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&a(void 0)}})}export{Ce as n,Ve as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./page-header-Maytcmgh--oRyXaDt.js";import{A as n,Dn as r,Fn as i,In as a,Mr as o,On as s,j as c,jr as l,kn as u,n as d,t as f}from"./index-CD4tM4nf.js";import{n as p,t as m}from"./SkeletonRows-C85xPCWB.js";import{O as h,T as g,k as _,n as v}from"./IconChevronRightMedium.es-BjSIsine.js";import{Fi as y,N as b,U as x,Yr as ee,Zn as S,a as te,b as ne,ji as re,k as C,l as w,lr as ie,or as ae,pr as oe,q as se,t as T,v as ce,w as le,x as ue,y as E,zt as de}from"./GithubIcon.es-BPBhMx2H.js";import{a as fe,f as D,i as pe,m as O,n as me,o as he,p as ge,r as _e,t as ve}from"./MastraGatewayBilling-Bpx-h8Vt.js";import{g as ye,h as k,i as A,m as j,n as M,r as N}from"./usePlatformConnections-CYfXtAjx.js";import{a as P,c as be,i as xe,s as Se}from"./useLinearData-C1EljeRN.js";import{a as F,r as I,t as L,tt as R}from"./icons-C18D46Pv.js";import{_ as Ce,t as we}from"./IconArrowRotateClockwise.es-DnnDHxyi.js";import{n as z}from"./IconSquareArrowTopRight.es-C-xkvcAK.js";import{i as B,s as Te,t as Ee}from"./Command.es-DYj7l4_8.js";import{F as V,M as H,d as De,j as Oe,x as ke}from"./Sidebar.es-DSPzNNju.js";import{t as U}from"./IconArrowRight.es-B8AZJjlM.js";import{t as W}from"./spinner-B9ykw74u-BLKI_KJ9.js";import{S as G,c as Ae,t as K}from"./ProviderBrandIcon-C7mph6N5.js";var q=e(_(),1);function je({draft:e,onFactoryCreated:t,onRepositoryLinked:n,onCreated:r}){let{baseUrl:i}=S(),a=re(),o=te(),s=w(),c=ce(),l=E(`linear`),u=E(`jira`),d=async e=>{try{await c.mutateAsync({integrationId:e.integrationId,sourceId:e.sourceId,factoryProjectId:e.factoryProjectId})}catch(e){if(!(e instanceof ne))throw e;R.warning(`This Jira project already feeds another factory`,{description:`Add a label filter in Settings › Work Intake to route some of its issues here.`});return}let t=await ue(i),n=le(t[e.integrationId],e.sourceId);n!==t[e.integrationId]&&await(e.integrationId===`linear`?l:u).mutateAsync(n)};return ee({mutationFn:async({modelId:c})=>{if(!e?.name||!e.repository)throw Error(`Start over from the name step.`);let l=e.factoryId?{id:e.factoryId,name:e.name}:await o.mutateAsync({name:e.name});e.factoryId||await t(l),e.linkedRepositoryId||await n((await s.mutateAsync({factoryProjectId:l.id,repo:e.repository})).projectRepositoryId),await Promise.all([se(i,l.id,c),e.linearProjectId?d({integrationId:`linear`,sourceId:e.linearProjectId,factoryProjectId:l.id}):void 0,e.jiraProjectId?d({integrationId:`jira`,sourceId:e.jiraProjectId,factoryProjectId:l.id}):void 0]),await a.invalidateQueries({queryKey:de.factories()}),await r(l)}})}var J=h();function Y({label:e,rows:t=3}){return(0,J.jsx)(m,{label:e,rows:t,className:`gap-0 p-1`,children:(0,J.jsxs)(`div`,{"aria-hidden":!0,className:`flex items-start gap-3 rounded-lg border border-transparent px-3 py-2.5`,children:[(0,J.jsx)(Oe,{className:`mt-0.5 size-4 shrink-0 motion-reduce:before:animate-none`}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsx)(H,{line:`text-label`,className:`w-3/5 max-w-48 motion-reduce:before:animate-none`}),(0,J.jsx)(H,{line:`text-meta`,className:`w-4/5 max-w-64 motion-reduce:before:animate-none`})]})]})})}var X=`animate-in fade-in slide-in-from-bottom-2 duration-200 motion-reduce:animate-none`;function Me({step:e,title:t,placeholder:r,searchable:i=!0,value:a,onValueChange:o,onBack:s,onSkip:c,children:l}){let u=f.indexOf(e);return(0,J.jsxs)(Ee,{loop:!0,shouldFilter:!1,label:t,className:`flex max-h-[34rem] w-full flex-col gap-2 overflow-visible bg-transparent`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[s&&(0,J.jsxs)(y,{variant:`ghost`,size:`sm`,onMouseDown:e=>e.preventDefault(),onClick:s,"aria-label":`Go back to previous step`,children:[(0,J.jsx)(ke,{"aria-hidden":`true`}),`Back`]}),(0,J.jsx)(v,{tone:`ink`,as:`p`,"aria-hidden":`true`,variant:`body`,className:g(`min-w-0 flex-1 truncate`,X),children:t},e),c&&(0,J.jsxs)(y,{variant:`ghost`,size:`sm`,onMouseDown:e=>e.preventDefault(),onClick:c,children:[`Skip`,(0,J.jsx)(U,{"aria-hidden":`true`})]}),(0,J.jsx)(`ol`,{className:`flex shrink-0 gap-1`,"aria-label":`Step ${u+1} of ${f.length}`,children:f.map((t,n)=>(0,J.jsx)(`li`,{"aria-current":t===e?`step`:void 0,className:g(`h-1 w-6 rounded-full transition-colors`,n<=u?`bg-success-indicator`:`bg-fill`)},t))})]}),(0,J.jsx)(n,{autoFocus:!0,placeholder:r,value:a,onValueChange:o,rightSlot:(0,J.jsx)(V,{size:`sm`,children:`Esc`}),wrapperClassName:g(`h-14 px-4`,!i&&`[&>svg]:hidden`)}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1.5 px-1`,children:[(0,J.jsx)(V,{size:`sm`,children:`↑`}),(0,J.jsx)(V,{size:`sm`,children:`↓`}),(0,J.jsx)(V,{size:`sm`,children:`↵`}),(0,J.jsx)(V,{size:`sm`,children:`Esc`})]}),(0,J.jsx)(Te,{scrollArea:!0,"aria-label":t,className:`max-h-none rounded-none border-none bg-transparent px-0 py-1 shadow-none`,scrollAreaClassName:`min-h-0 flex-1`,children:(0,J.jsx)(`div`,{className:X,onMouseDown:e=>e.preventDefault(),children:l},e)})]})}function Z({children:e}){return(0,J.jsx)(v,{as:`p`,role:`alert`,variant:`caption`,className:`text-destructive-foreground m-0 px-3 py-2`,children:e})}function Q({children:e}){return(0,J.jsx)(v,{tone:`muted`,as:`p`,variant:`caption`,className:`m-0 px-3 py-2`,children:e})}function Ne({query:e,onSelectProject:t}){let n=s(),i=n.data,a=i?.configured===!0,o=r(a),l=N(`jira`,i?.mode===`platform`),d=M(`jira`),f=A(`jira`),p=i?.connections?.find(e=>e.status===`needs_reauth`),m=e.trim().toLowerCase(),h=e=>e.toLowerCase().includes(m),g=d.isPending||f.isPending,_=p?`Reconnect Jira`:`Connect Jira`,v=f.error??d.error,y=()=>{p?f.mutate({connectionId:p.id}):d.mutate({})};if(n.isPending||a&&o.isPending)return(0,J.jsx)(Y,{label:`Loading Jira projects`,rows:2});if(!a){let e=i?.mode===`platform`&&l.isSuccess;return!e&&i?.reason===`missing_config`?null:(0,J.jsxs)(B,{heading:`Jira`,children:[v&&(0,J.jsx)(Z,{children:v.message}),e&&h(_)?(0,J.jsx)(c,{icon:(0,J.jsx)(I,{}),title:g?`Connecting Jira…`:_,subtitle:`Import Jira issues into the Factory Work board`,value:`connect-jira`,disabled:g,onSelect:y}):!e&&(0,J.jsx)(Q,{children:`Jira is not available for this organization.`})]})}if(o.isError)return(0,J.jsx)(B,{heading:`Jira`,children:u(o.error)&&p?(0,J.jsx)(c,{icon:(0,J.jsx)(I,{}),title:g?`Connecting Jira…`:`Reconnect Jira`,subtitle:`Its authorization expired, so its projects cannot be read`,value:`reconnect-jira`,disabled:g,onSelect:y}):(0,J.jsx)(Z,{children:o.error.message})});let b=o.data??[],x=b.filter(e=>h(`${e.name} ${e.key} ${e.site??``}`));return(0,J.jsxs)(B,{heading:`Jira projects`,children:[x.map(e=>(0,J.jsx)(c,{icon:(0,J.jsx)(I,{}),title:e.name,subtitle:e.key||e.site?(0,J.jsxs)(z,{singleLine:!0,children:[e.key&&(0,J.jsx)(z.Item,{className:`shrink-0`,children:e.key}),e.site&&(0,J.jsx)(z.Item,{children:e.site})]}):`Its issues feed this Factory Work board`,shortcut:(0,J.jsx)(V,{size:`sm`,children:`↵`}),value:`jira-${e.id}`,onSelect:()=>t(e.id)},e.id)),x.length===0&&(0,J.jsx)(Q,{children:b.length>0?`No Jira project matches this search.`:`No Jira projects are available yet.`})]})}function Pe({query:e,onConnect:t,onSelectProject:n,onSkip:r}){let i=P(),a=i.data,o=a?.connected===!0,s=xe(o),l=e.trim().toLowerCase(),u=e=>e.toLowerCase().includes(l),d=u(`Skip for now`)&&(0,J.jsx)(c,{icon:(0,J.jsx)(U,{}),title:`Skip for now`,subtitle:`This Factory takes its work from GitHub only`,value:`skip-linear`,onSelect:r});if(i.isPending||o&&s.isPending)return(0,J.jsx)(Y,{label:`Loading Linear projects`,rows:2});if(!o){let e=a?.reason!==`missing_config`&&a?.reason!==`organization_required`,n=a?.reason===`not_connected`?`Connect Linear`:`Reconnect Linear`;return(0,J.jsxs)(B,{heading:`Linear`,children:[d,e?u(n)&&(0,J.jsx)(c,{icon:(0,J.jsx)(F,{}),title:n,subtitle:`Import issues and priorities into the Factory board`,value:`connect-linear`,onSelect:t}):(0,J.jsx)(Q,{children:`Linear is not configured for this deployment.`})]})}if(s.isError)return(0,J.jsxs)(B,{heading:`Linear`,children:[d,be(s.error)?(0,J.jsx)(c,{icon:(0,J.jsx)(F,{}),title:`Reconnect Linear`,subtitle:`Its authorization expired, so its projects cannot be read`,value:`connect-linear`,onSelect:t}):(0,J.jsx)(Z,{children:s.error.message})]});let f=s.data??[],p=f.filter(e=>u(e.name));return(0,J.jsxs)(B,{heading:`Projects in ${a.workspace?.name??`Linear`}`,children:[d,p.map(e=>(0,J.jsx)(c,{icon:(0,J.jsx)(F,{}),title:e.name,subtitle:e.teams.map(e=>e.name).join(`, `)||`Its issues feed this Factory board`,shortcut:(0,J.jsx)(V,{size:`sm`,children:`↵`}),value:`linear-${e.id}`,onSelect:()=>n(e.id)},e.id)),p.length===0&&(0,J.jsx)(Q,{children:f.length>0?`No Linear project matches this search.`:`This workspace has no projects yet.`})]})}function Fe({provider:e,query:t,savingModelId:n,error:r,onPick:i,onChangeProvider:a}){let o=pe(e.provider);if(o.isPending)return(0,J.jsx)(Y,{label:`Loading models`,rows:3});if(o.catalogError)return(0,J.jsx)(Z,{children:o.catalogError.message});let s=_e(e.provider),l=t.trim().toLowerCase(),u=o.models.filter(e=>e.id.toLowerCase().includes(l)||e.modelName.toLowerCase().includes(l)).toSorted((e,t)=>Number(t.id===s)-Number(e.id===s)||Ae(e.releaseDate,t.releaseDate)||e.modelName.localeCompare(t.modelName)),d=n!==void 0;return(0,J.jsxs)(J.Fragment,{children:[r&&(0,J.jsx)(Z,{children:r}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 pt-2`,children:[(0,J.jsx)(fe,{modelId:o.suggestedModelId}),e.connectWithMastraAccount&&(0,J.jsx)(me,{})]}),u.length>0?(0,J.jsx)(B,{heading:`${G(e.provider)} models`,children:u.map(e=>(0,J.jsx)(c,{icon:n===e.id?(0,J.jsx)(W,{size:`sm`,"aria-label":`Creating Factory`}):(0,J.jsx)(K,{provider:e.provider}),title:e.id,subtitle:e.modelName,badge:e.id===o.suggestedModelId?`Suggested`:void 0,shortcut:(0,J.jsx)(V,{size:`sm`,children:`↵`}),value:e.id,disabled:d,onSelect:()=>i(e.id)},e.id))}):(0,J.jsx)(Q,{children:`No models match this search.`}),(0,J.jsx)(B,{heading:`Provider`,children:(0,J.jsx)(c,{icon:(0,J.jsx)(we,{}),title:`Change provider`,subtitle:G(e.provider),value:`change-provider`,disabled:d,onSelect:a})})]})}function Ie({connection:e,query:t,error:n}){if(e.isPending)return(0,J.jsx)(Y,{label:`Loading model providers`,rows:3});if(e.catalogError)return(0,J.jsx)(Z,{children:e.catalogError.message});let r=e.gatewayProvider&&D(e.gatewayProvider,t)?e.gatewayProvider:void 0,i=e.signInProviders.filter(e=>D(e,t)),a=e.keyProviders.filter(e=>e.oauth?.supported!==!0&&D(e,t));return(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsx)(Z,{children:n}),!r&&i.length===0&&a.length===0&&(0,J.jsx)(Q,{children:`No providers match this search.`}),r&&(0,J.jsx)(B,{heading:`Recommended`,children:(0,J.jsx)(c,{icon:(0,J.jsx)(K,{provider:r.provider}),title:G(r.provider),subtitle:(0,J.jsx)(ve,{}),badge:e.isConfigured(r)?`Connected`:void 0,value:`gateway-${r.provider}`,disabled:e.pending,onSelect:e.chooseGateway})}),i.length>0&&(0,J.jsx)(B,{heading:`Sign in`,children:i.map(t=>(0,J.jsx)(c,{icon:(0,J.jsx)(K,{provider:t.provider}),title:G(t.provider),subtitle:e.isConfigured(t)?`Signed in on this deployment`:`Sign in with your account`,badge:e.isConfigured(t)?`Connected`:void 0,value:`signin-${t.provider}`,disabled:e.pending,onSelect:()=>e.chooseSignInProvider(t)},t.provider))}),a.length>0&&(0,J.jsx)(B,{heading:`API key`,children:a.map(t=>(0,J.jsx)(c,{icon:(0,J.jsx)(K,{provider:t.provider}),title:G(t.provider),subtitle:e.isConfigured(t)?`API key saved`:`Connect with an API key`,badge:e.isConfigured(t)?`Connected`:void 0,value:`key-${t.provider}`,disabled:e.pending,onSelect:()=>e.chooseKeyProvider(t)},t.provider))})]})}function Le({query:e,savingModelId:t,error:n,onPick:r}){let i=ge(),a=i.connected?i.provider:void 0;return(0,J.jsxs)(J.Fragment,{children:[a?(0,J.jsx)(Fe,{provider:a,query:e,savingModelId:t,error:n,onPick:e=>r(a.provider,e),onChangeProvider:i.clear}):(0,J.jsx)(Ie,{connection:i,query:e,error:i.error??n}),(0,J.jsx)(he,{keyProvider:i.keyDialogProvider,oauth:i.activeOAuth,authEnabled:i.authEnabled,onCloseKeyDialog:i.closeKeyDialog,onCloseOAuth:i.closeOAuth,onCompleteOAuth:i.completeOAuth})]})}function $({name:e,onSubmit:t}){let n=e.trim();return(0,J.jsx)(B,{heading:`Create`,children:(0,J.jsx)(c,{icon:(0,J.jsx)(ye,{}),title:n?`Create “${n}”`:`Type a name to create your Factory`,shortcut:(0,J.jsx)(V,{size:`sm`,children:`↵`}),value:`create-factory`,disabled:!n,onSelect:()=>t(n)})})}function Re(e){switch(e?.reason){case`missing_config`:return`GitHub is not configured for this deployment.`;case`organization_required`:return`Join an organization to connect GitHub repositories.`;case`auth_required`:return`Sign in again to connect GitHub.`;default:return`Install the GitHub App to grant access to repositories.`}}function ze({query:e,githubRedirecting:t,onConnect:n,onManageConnection:r,onSelectRepository:o}){let s=j(),l=s.data?.connected===!0,u=a(),d=!!(u.data?.enabled&&u.data.configured),f=i(d),p=M(`gitlab`),m=p.isPending,h=async()=>{try{await p.mutateAsync({}),R.success(`GitLab connected`)}catch(e){R.error(e instanceof Error?e.message:`Failed to connect GitLab`)}};if(s.isPending||u.isPending)return(0,J.jsx)(Y,{label:`Loading repositories`,rows:3});let g=l?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Be,{query:e,onSelectRepository:o}),(0,J.jsx)(B,{heading:`GitHub`,children:(0,J.jsx)(c,{icon:(0,J.jsx)(De,{}),title:`Manage GitHub connection`,subtitle:`Add installations or grant access to more repositories`,value:`manage-github`,onSelect:r})})]}):(()=>{let e=s.data?.reason===`organization_required`||s.data?.reason===`missing_config`;return(0,J.jsx)(B,{heading:`GitHub`,children:(0,J.jsx)(c,{icon:t?(0,J.jsx)(W,{size:`sm`,"aria-label":`Connecting to GitHub`}):(0,J.jsx)(T,{}),title:e?`GitHub unavailable`:`Connect GitHub`,subtitle:Re(s.data),value:`connect-github`,disabled:e||t,onSelect:n})})})();return(0,J.jsxs)(J.Fragment,{children:[g,d?(0,J.jsx)(Ve,{query:e,projects:f.data?.flatMap(e=>{let t=C(e);return t?[t]:[]}),pending:f.isPending,error:f.error,onSelectRepository:o}):(()=>{let e=!u.data?.enabled||u.data.reason===`organization_required`,t=u.data?.enabled?u.data.reason===`organization_required`?`Join an organization to connect GitLab repositories.`:`Sign in to GitLab to grant access to your projects.`:`GitLab is not available for this deployment.`;return(0,J.jsx)(B,{heading:`GitLab`,children:(0,J.jsx)(c,{icon:m?(0,J.jsx)(W,{size:`sm`,"aria-label":`Connecting to GitLab`}):(0,J.jsx)(L,{}),title:e?`GitLab unavailable`:`Connect GitLab`,subtitle:t,value:`connect-gitlab`,disabled:e||m,onSelect:()=>void h()})})})()]})}function Be({query:e,onSelectRepository:t}){let n=k(e,750),r=O(n||void 0,!0);return r.isPending?(0,J.jsx)(Y,{label:`Loading repositories`,rows:3}):r.isError?(0,J.jsx)(Z,{children:r.error.message}):r.data.length===0?(0,J.jsx)(Q,{children:`No repositories found.`}):(0,J.jsx)(B,{heading:`Repositories`,children:r.data.map(e=>(0,J.jsx)(c,{icon:(0,J.jsx)(T,{}),title:e.fullName,subtitle:(0,J.jsxs)(z,{singleLine:!0,children:[(0,J.jsx)(z.Item,{className:`shrink-0`,children:e.private?`Private`:`Public`}),(0,J.jsx)(z.Item,{children:e.defaultBranch})]}),value:`repo-${e.id}`,onSelect:()=>t(e)},e.id))})}function Ve({query:e,projects:t,pending:n,error:r,onSelectRepository:i}){let a=e.trim().toLowerCase(),o=(t??[]).filter(e=>e.fullName.toLowerCase().includes(a));return n?(0,J.jsx)(Y,{label:`Loading GitLab repositories`,rows:3}):r?(0,J.jsx)(Z,{children:r.message}):(0,J.jsx)(B,{heading:`GitLab repositories`,children:o.length===0?(0,J.jsx)(Q,{children:`No GitLab repositories found.`}):o.map(e=>(0,J.jsx)(c,{icon:(0,J.jsx)(L,{}),title:e.fullName,subtitle:(0,J.jsxs)(z,{singleLine:!0,children:[(0,J.jsx)(z.Item,{className:`shrink-0`,children:`GitLab`}),(0,J.jsx)(z.Item,{children:e.defaultBranch})]}),value:`gitlab-repo-${e.id}`,onSelect:()=>i(e)},e.id))})}var He={name:{title:`Name your new Factory`,placeholder:`e.g. Mastra`,searchable:!1},vcs:{title:`Choose your codebase`,placeholder:`Search repositories`},"project-management":{title:`Connect the work behind the code`,placeholder:`Search options`},"model-provider":{title:`Choose your Factory model`,placeholder:`Search models and providers`}};function Ue(e){return e instanceof Error?e.message:`Something went wrong. Please try again.`}function We(){let e=ie(),t=ae(),{factoryId:n}=oe(),{baseUrl:r}=S(),i=d(),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(),l=i.draft,u=j();O(void 0,l?.step===`name`&&u.data?.connected===!0);let f=je({draft:l,onFactoryCreated:e=>i.rememberFactory(e),onRepositoryLinked:e=>i.rememberLinkedRepository(e),onCreated:async t=>{await i.clear(),e(Ce(t))}}),m=f.isPending;p({Escape:()=>{t.key==="default"?e(n?`/factories/${n}`:`/`):e(-1)}},{enabled:!m,insideFields:!0});let h=l?.step;if(!h)return null;let g=(s?.step===h?s.value:void 0)??(h===`name`?l.name??``:``);return(0,J.jsx)(`div`,{className:`flex min-h-0 flex-col gap-2 pt-6`,children:(0,J.jsxs)(Me,{...He[h],step:h,value:g,onValueChange:e=>c({step:h,value:e}),onBack:h===`name`||m||l.factoryId||l.linkedRepositoryId?void 0:()=>{c(void 0),i.back()},onSkip:h===`project-management`?()=>void i.skipProjectManagement():void 0,children:[h===`name`&&(0,J.jsx)($,{name:g,onSubmit:i.startVcs}),h===`vcs`&&(0,J.jsx)(ze,{query:g,githubRedirecting:a,onConnect:()=>{o(!0),i.persistBeforeRedirect(n),b(r)},onManageConnection:()=>{i.persistBeforeRedirect(n),x(r)},onSelectRepository:e=>void i.chooseRepository(e)}),h===`project-management`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Pe,{query:g,onConnect:()=>{i.persistBeforeRedirect(n),Se(r)},onSelectProject:e=>void i.chooseLinearProject(e),onSkip:()=>void i.skipProjectManagement()}),(0,J.jsx)(Ne,{query:g,onSelectProject:e=>void i.chooseJiraProject(e)})]}),h===`model-provider`&&(0,J.jsx)(Le,{query:g,savingModelId:f.isPending?f.variables?.modelId:void 0,error:f.error?Ue(f.error):void 0,onPick:(e,t)=>f.mutate({modelId:t})})]})})}function Ge(){let e=l();return(0,J.jsx)(o,{...e,variant:`narrow`,header:(0,J.jsx)(t,{children:(0,J.jsx)(t.Title,{children:`New Factory`})}),children:(0,J.jsx)(We,{})})}export{Ge as CreateFactoryPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./page-header-Maytcmgh--oRyXaDt.js";import{A as n,Dn as r,Fn as i,In as a,Mr as o,On as s,j as c,jr as l,kn as u,n as d,t as f}from"./index-7W2GRQBh.js";import{n as p,t as m}from"./SkeletonRows-C85xPCWB.js";import{O as h,T as g,k as _,n as v}from"./IconChevronRightMedium.es-BjSIsine.js";import{Fi as y,N as b,U as x,Yr as ee,Zn as S,a as te,b as ne,ji as re,k as C,l as w,lr as ie,or as ae,pr as oe,q as se,t as T,v as ce,w as le,x as ue,y as E,zt as de}from"./GithubIcon.es-BPBhMx2H.js";import{a as fe,f as D,i as pe,m as O,n as me,o as he,p as ge,r as _e,t as ve}from"./MastraGatewayBilling-DUU0LSY2.js";import{g as ye,h as k,i as A,m as j,n as M,r as N}from"./usePlatformConnections-CYfXtAjx.js";import{a as P,c as be,i as xe,s as Se}from"./useLinearData-C1EljeRN.js";import{a as F,r as I,t as L,tt as R}from"./icons-C18D46Pv.js";import{_ as Ce,t as we}from"./IconArrowRotateClockwise.es-DnnDHxyi.js";import{n as z}from"./IconSquareArrowTopRight.es-C-xkvcAK.js";import{i as B,s as Te,t as Ee}from"./Command.es-DYj7l4_8.js";import{F as V,M as H,d as De,j as Oe,x as ke}from"./Sidebar.es-DSPzNNju.js";import{t as U}from"./IconArrowRight.es-B8AZJjlM.js";import{t as W}from"./spinner-B9ykw74u-BLKI_KJ9.js";import{S as G,c as Ae,t as K}from"./ProviderBrandIcon-BYIRXEhA.js";var q=e(_(),1);function je({draft:e,onFactoryCreated:t,onRepositoryLinked:n,onCreated:r}){let{baseUrl:i}=S(),a=re(),o=te(),s=w(),c=ce(),l=E(`linear`),u=E(`jira`),d=async e=>{try{await c.mutateAsync({integrationId:e.integrationId,sourceId:e.sourceId,factoryProjectId:e.factoryProjectId})}catch(e){if(!(e instanceof ne))throw e;R.warning(`This Jira project already feeds another factory`,{description:`Add a label filter in Settings › Work Intake to route some of its issues here.`});return}let t=await ue(i),n=le(t[e.integrationId],e.sourceId);n!==t[e.integrationId]&&await(e.integrationId===`linear`?l:u).mutateAsync(n)};return ee({mutationFn:async({modelId:c})=>{if(!e?.name||!e.repository)throw Error(`Start over from the name step.`);let l=e.factoryId?{id:e.factoryId,name:e.name}:await o.mutateAsync({name:e.name});e.factoryId||await t(l),e.linkedRepositoryId||await n((await s.mutateAsync({factoryProjectId:l.id,repo:e.repository})).projectRepositoryId),await Promise.all([se(i,l.id,c),e.linearProjectId?d({integrationId:`linear`,sourceId:e.linearProjectId,factoryProjectId:l.id}):void 0,e.jiraProjectId?d({integrationId:`jira`,sourceId:e.jiraProjectId,factoryProjectId:l.id}):void 0]),await a.invalidateQueries({queryKey:de.factories()}),await r(l)}})}var J=h();function Y({label:e,rows:t=3}){return(0,J.jsx)(m,{label:e,rows:t,className:`gap-0 p-1`,children:(0,J.jsxs)(`div`,{"aria-hidden":!0,className:`flex items-start gap-3 rounded-lg border border-transparent px-3 py-2.5`,children:[(0,J.jsx)(Oe,{className:`mt-0.5 size-4 shrink-0 motion-reduce:before:animate-none`}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsx)(H,{line:`text-label`,className:`w-3/5 max-w-48 motion-reduce:before:animate-none`}),(0,J.jsx)(H,{line:`text-meta`,className:`w-4/5 max-w-64 motion-reduce:before:animate-none`})]})]})})}var X=`animate-in fade-in slide-in-from-bottom-2 duration-200 motion-reduce:animate-none`;function Me({step:e,title:t,placeholder:r,searchable:i=!0,value:a,onValueChange:o,onBack:s,onSkip:c,children:l}){let u=f.indexOf(e);return(0,J.jsxs)(Ee,{loop:!0,shouldFilter:!1,label:t,className:`flex max-h-[34rem] w-full flex-col gap-2 overflow-visible bg-transparent`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[s&&(0,J.jsxs)(y,{variant:`ghost`,size:`sm`,onMouseDown:e=>e.preventDefault(),onClick:s,"aria-label":`Go back to previous step`,children:[(0,J.jsx)(ke,{"aria-hidden":`true`}),`Back`]}),(0,J.jsx)(v,{tone:`ink`,as:`p`,"aria-hidden":`true`,variant:`body`,className:g(`min-w-0 flex-1 truncate`,X),children:t},e),c&&(0,J.jsxs)(y,{variant:`ghost`,size:`sm`,onMouseDown:e=>e.preventDefault(),onClick:c,children:[`Skip`,(0,J.jsx)(U,{"aria-hidden":`true`})]}),(0,J.jsx)(`ol`,{className:`flex shrink-0 gap-1`,"aria-label":`Step ${u+1} of ${f.length}`,children:f.map((t,n)=>(0,J.jsx)(`li`,{"aria-current":t===e?`step`:void 0,className:g(`h-1 w-6 rounded-full transition-colors`,n<=u?`bg-success-indicator`:`bg-fill`)},t))})]}),(0,J.jsx)(n,{autoFocus:!0,placeholder:r,value:a,onValueChange:o,rightSlot:(0,J.jsx)(V,{size:`sm`,children:`Esc`}),wrapperClassName:g(`h-14 px-4`,!i&&`[&>svg]:hidden`)}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1.5 px-1`,children:[(0,J.jsx)(V,{size:`sm`,children:`↑`}),(0,J.jsx)(V,{size:`sm`,children:`↓`}),(0,J.jsx)(V,{size:`sm`,children:`↵`}),(0,J.jsx)(V,{size:`sm`,children:`Esc`})]}),(0,J.jsx)(Te,{scrollArea:!0,"aria-label":t,className:`max-h-none rounded-none border-none bg-transparent px-0 py-1 shadow-none`,scrollAreaClassName:`min-h-0 flex-1`,children:(0,J.jsx)(`div`,{className:X,onMouseDown:e=>e.preventDefault(),children:l},e)})]})}function Z({children:e}){return(0,J.jsx)(v,{as:`p`,role:`alert`,variant:`caption`,className:`text-destructive-foreground m-0 px-3 py-2`,children:e})}function Q({children:e}){return(0,J.jsx)(v,{tone:`muted`,as:`p`,variant:`caption`,className:`m-0 px-3 py-2`,children:e})}function Ne({query:e,onSelectProject:t}){let n=s(),i=n.data,a=i?.configured===!0,o=r(a),l=N(`jira`,i?.mode===`platform`),d=M(`jira`),f=A(`jira`),p=i?.connections?.find(e=>e.status===`needs_reauth`),m=e.trim().toLowerCase(),h=e=>e.toLowerCase().includes(m),g=d.isPending||f.isPending,_=p?`Reconnect Jira`:`Connect Jira`,v=f.error??d.error,y=()=>{p?f.mutate({connectionId:p.id}):d.mutate({})};if(n.isPending||a&&o.isPending)return(0,J.jsx)(Y,{label:`Loading Jira projects`,rows:2});if(!a){let e=i?.mode===`platform`&&l.isSuccess;return!e&&i?.reason===`missing_config`?null:(0,J.jsxs)(B,{heading:`Jira`,children:[v&&(0,J.jsx)(Z,{children:v.message}),e&&h(_)?(0,J.jsx)(c,{icon:(0,J.jsx)(I,{}),title:g?`Connecting Jira…`:_,subtitle:`Import Jira issues into the Factory Work board`,value:`connect-jira`,disabled:g,onSelect:y}):!e&&(0,J.jsx)(Q,{children:`Jira is not available for this organization.`})]})}if(o.isError)return(0,J.jsx)(B,{heading:`Jira`,children:u(o.error)&&p?(0,J.jsx)(c,{icon:(0,J.jsx)(I,{}),title:g?`Connecting Jira…`:`Reconnect Jira`,subtitle:`Its authorization expired, so its projects cannot be read`,value:`reconnect-jira`,disabled:g,onSelect:y}):(0,J.jsx)(Z,{children:o.error.message})});let b=o.data??[],x=b.filter(e=>h(`${e.name} ${e.key} ${e.site??``}`));return(0,J.jsxs)(B,{heading:`Jira projects`,children:[x.map(e=>(0,J.jsx)(c,{icon:(0,J.jsx)(I,{}),title:e.name,subtitle:e.key||e.site?(0,J.jsxs)(z,{singleLine:!0,children:[e.key&&(0,J.jsx)(z.Item,{className:`shrink-0`,children:e.key}),e.site&&(0,J.jsx)(z.Item,{children:e.site})]}):`Its issues feed this Factory Work board`,shortcut:(0,J.jsx)(V,{size:`sm`,children:`↵`}),value:`jira-${e.id}`,onSelect:()=>t(e.id)},e.id)),x.length===0&&(0,J.jsx)(Q,{children:b.length>0?`No Jira project matches this search.`:`No Jira projects are available yet.`})]})}function Pe({query:e,onConnect:t,onSelectProject:n,onSkip:r}){let i=P(),a=i.data,o=a?.connected===!0,s=xe(o),l=e.trim().toLowerCase(),u=e=>e.toLowerCase().includes(l),d=u(`Skip for now`)&&(0,J.jsx)(c,{icon:(0,J.jsx)(U,{}),title:`Skip for now`,subtitle:`This Factory takes its work from GitHub only`,value:`skip-linear`,onSelect:r});if(i.isPending||o&&s.isPending)return(0,J.jsx)(Y,{label:`Loading Linear projects`,rows:2});if(!o){let e=a?.reason!==`missing_config`&&a?.reason!==`organization_required`,n=a?.reason===`not_connected`?`Connect Linear`:`Reconnect Linear`;return(0,J.jsxs)(B,{heading:`Linear`,children:[d,e?u(n)&&(0,J.jsx)(c,{icon:(0,J.jsx)(F,{}),title:n,subtitle:`Import issues and priorities into the Factory board`,value:`connect-linear`,onSelect:t}):(0,J.jsx)(Q,{children:`Linear is not configured for this deployment.`})]})}if(s.isError)return(0,J.jsxs)(B,{heading:`Linear`,children:[d,be(s.error)?(0,J.jsx)(c,{icon:(0,J.jsx)(F,{}),title:`Reconnect Linear`,subtitle:`Its authorization expired, so its projects cannot be read`,value:`connect-linear`,onSelect:t}):(0,J.jsx)(Z,{children:s.error.message})]});let f=s.data??[],p=f.filter(e=>u(e.name));return(0,J.jsxs)(B,{heading:`Projects in ${a.workspace?.name??`Linear`}`,children:[d,p.map(e=>(0,J.jsx)(c,{icon:(0,J.jsx)(F,{}),title:e.name,subtitle:e.teams.map(e=>e.name).join(`, `)||`Its issues feed this Factory board`,shortcut:(0,J.jsx)(V,{size:`sm`,children:`↵`}),value:`linear-${e.id}`,onSelect:()=>n(e.id)},e.id)),p.length===0&&(0,J.jsx)(Q,{children:f.length>0?`No Linear project matches this search.`:`This workspace has no projects yet.`})]})}function Fe({provider:e,query:t,savingModelId:n,error:r,onPick:i,onChangeProvider:a}){let o=pe(e.provider);if(o.isPending)return(0,J.jsx)(Y,{label:`Loading models`,rows:3});if(o.catalogError)return(0,J.jsx)(Z,{children:o.catalogError.message});let s=_e(e.provider),l=t.trim().toLowerCase(),u=o.models.filter(e=>e.id.toLowerCase().includes(l)||e.modelName.toLowerCase().includes(l)).toSorted((e,t)=>Number(t.id===s)-Number(e.id===s)||Ae(e.releaseDate,t.releaseDate)||e.modelName.localeCompare(t.modelName)),d=n!==void 0;return(0,J.jsxs)(J.Fragment,{children:[r&&(0,J.jsx)(Z,{children:r}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 pt-2`,children:[(0,J.jsx)(fe,{modelId:o.suggestedModelId}),e.connectWithMastraAccount&&(0,J.jsx)(me,{})]}),u.length>0?(0,J.jsx)(B,{heading:`${G(e.provider)} models`,children:u.map(e=>(0,J.jsx)(c,{icon:n===e.id?(0,J.jsx)(W,{size:`sm`,"aria-label":`Creating Factory`}):(0,J.jsx)(K,{provider:e.provider}),title:e.id,subtitle:e.modelName,badge:e.id===o.suggestedModelId?`Suggested`:void 0,shortcut:(0,J.jsx)(V,{size:`sm`,children:`↵`}),value:e.id,disabled:d,onSelect:()=>i(e.id)},e.id))}):(0,J.jsx)(Q,{children:`No models match this search.`}),(0,J.jsx)(B,{heading:`Provider`,children:(0,J.jsx)(c,{icon:(0,J.jsx)(we,{}),title:`Change provider`,subtitle:G(e.provider),value:`change-provider`,disabled:d,onSelect:a})})]})}function Ie({connection:e,query:t,error:n}){if(e.isPending)return(0,J.jsx)(Y,{label:`Loading model providers`,rows:3});if(e.catalogError)return(0,J.jsx)(Z,{children:e.catalogError.message});let r=e.gatewayProvider&&D(e.gatewayProvider,t)?e.gatewayProvider:void 0,i=e.signInProviders.filter(e=>D(e,t)),a=e.keyProviders.filter(e=>e.oauth?.supported!==!0&&D(e,t));return(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsx)(Z,{children:n}),!r&&i.length===0&&a.length===0&&(0,J.jsx)(Q,{children:`No providers match this search.`}),r&&(0,J.jsx)(B,{heading:`Recommended`,children:(0,J.jsx)(c,{icon:(0,J.jsx)(K,{provider:r.provider}),title:G(r.provider),subtitle:(0,J.jsx)(ve,{}),badge:e.isConfigured(r)?`Connected`:void 0,value:`gateway-${r.provider}`,disabled:e.pending,onSelect:e.chooseGateway})}),i.length>0&&(0,J.jsx)(B,{heading:`Sign in`,children:i.map(t=>(0,J.jsx)(c,{icon:(0,J.jsx)(K,{provider:t.provider}),title:G(t.provider),subtitle:e.isConfigured(t)?`Signed in on this deployment`:`Sign in with your account`,badge:e.isConfigured(t)?`Connected`:void 0,value:`signin-${t.provider}`,disabled:e.pending,onSelect:()=>e.chooseSignInProvider(t)},t.provider))}),a.length>0&&(0,J.jsx)(B,{heading:`API key`,children:a.map(t=>(0,J.jsx)(c,{icon:(0,J.jsx)(K,{provider:t.provider}),title:G(t.provider),subtitle:e.isConfigured(t)?`API key saved`:`Connect with an API key`,badge:e.isConfigured(t)?`Connected`:void 0,value:`key-${t.provider}`,disabled:e.pending,onSelect:()=>e.chooseKeyProvider(t)},t.provider))})]})}function Le({query:e,savingModelId:t,error:n,onPick:r}){let i=ge(),a=i.connected?i.provider:void 0;return(0,J.jsxs)(J.Fragment,{children:[a?(0,J.jsx)(Fe,{provider:a,query:e,savingModelId:t,error:n,onPick:e=>r(a.provider,e),onChangeProvider:i.clear}):(0,J.jsx)(Ie,{connection:i,query:e,error:i.error??n}),(0,J.jsx)(he,{keyProvider:i.keyDialogProvider,oauth:i.activeOAuth,authEnabled:i.authEnabled,onCloseKeyDialog:i.closeKeyDialog,onCloseOAuth:i.closeOAuth,onCompleteOAuth:i.completeOAuth})]})}function $({name:e,onSubmit:t}){let n=e.trim();return(0,J.jsx)(B,{heading:`Create`,children:(0,J.jsx)(c,{icon:(0,J.jsx)(ye,{}),title:n?`Create “${n}”`:`Type a name to create your Factory`,shortcut:(0,J.jsx)(V,{size:`sm`,children:`↵`}),value:`create-factory`,disabled:!n,onSelect:()=>t(n)})})}function Re(e){switch(e?.reason){case`missing_config`:return`GitHub is not configured for this deployment.`;case`organization_required`:return`Join an organization to connect GitHub repositories.`;case`auth_required`:return`Sign in again to connect GitHub.`;default:return`Install the GitHub App to grant access to repositories.`}}function ze({query:e,githubRedirecting:t,onConnect:n,onManageConnection:r,onSelectRepository:o}){let s=j(),l=s.data?.connected===!0,u=a(),d=!!(u.data?.enabled&&u.data.configured),f=i(d),p=M(`gitlab`),m=p.isPending,h=async()=>{try{await p.mutateAsync({}),R.success(`GitLab connected`)}catch(e){R.error(e instanceof Error?e.message:`Failed to connect GitLab`)}};if(s.isPending||u.isPending)return(0,J.jsx)(Y,{label:`Loading repositories`,rows:3});let g=l?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Be,{query:e,onSelectRepository:o}),(0,J.jsx)(B,{heading:`GitHub`,children:(0,J.jsx)(c,{icon:(0,J.jsx)(De,{}),title:`Manage GitHub connection`,subtitle:`Add installations or grant access to more repositories`,value:`manage-github`,onSelect:r})})]}):(()=>{let e=s.data?.reason===`organization_required`||s.data?.reason===`missing_config`;return(0,J.jsx)(B,{heading:`GitHub`,children:(0,J.jsx)(c,{icon:t?(0,J.jsx)(W,{size:`sm`,"aria-label":`Connecting to GitHub`}):(0,J.jsx)(T,{}),title:e?`GitHub unavailable`:`Connect GitHub`,subtitle:Re(s.data),value:`connect-github`,disabled:e||t,onSelect:n})})})();return(0,J.jsxs)(J.Fragment,{children:[g,d?(0,J.jsx)(Ve,{query:e,projects:f.data?.flatMap(e=>{let t=C(e);return t?[t]:[]}),pending:f.isPending,error:f.error,onSelectRepository:o}):(()=>{let e=!u.data?.enabled||u.data.reason===`organization_required`,t=u.data?.enabled?u.data.reason===`organization_required`?`Join an organization to connect GitLab repositories.`:`Sign in to GitLab to grant access to your projects.`:`GitLab is not available for this deployment.`;return(0,J.jsx)(B,{heading:`GitLab`,children:(0,J.jsx)(c,{icon:m?(0,J.jsx)(W,{size:`sm`,"aria-label":`Connecting to GitLab`}):(0,J.jsx)(L,{}),title:e?`GitLab unavailable`:`Connect GitLab`,subtitle:t,value:`connect-gitlab`,disabled:e||m,onSelect:()=>void h()})})})()]})}function Be({query:e,onSelectRepository:t}){let n=k(e,750),r=O(n||void 0,!0);return r.isPending?(0,J.jsx)(Y,{label:`Loading repositories`,rows:3}):r.isError?(0,J.jsx)(Z,{children:r.error.message}):r.data.length===0?(0,J.jsx)(Q,{children:`No repositories found.`}):(0,J.jsx)(B,{heading:`Repositories`,children:r.data.map(e=>(0,J.jsx)(c,{icon:(0,J.jsx)(T,{}),title:e.fullName,subtitle:(0,J.jsxs)(z,{singleLine:!0,children:[(0,J.jsx)(z.Item,{className:`shrink-0`,children:e.private?`Private`:`Public`}),(0,J.jsx)(z.Item,{children:e.defaultBranch})]}),value:`repo-${e.id}`,onSelect:()=>t(e)},e.id))})}function Ve({query:e,projects:t,pending:n,error:r,onSelectRepository:i}){let a=e.trim().toLowerCase(),o=(t??[]).filter(e=>e.fullName.toLowerCase().includes(a));return n?(0,J.jsx)(Y,{label:`Loading GitLab repositories`,rows:3}):r?(0,J.jsx)(Z,{children:r.message}):(0,J.jsx)(B,{heading:`GitLab repositories`,children:o.length===0?(0,J.jsx)(Q,{children:`No GitLab repositories found.`}):o.map(e=>(0,J.jsx)(c,{icon:(0,J.jsx)(L,{}),title:e.fullName,subtitle:(0,J.jsxs)(z,{singleLine:!0,children:[(0,J.jsx)(z.Item,{className:`shrink-0`,children:`GitLab`}),(0,J.jsx)(z.Item,{children:e.defaultBranch})]}),value:`gitlab-repo-${e.id}`,onSelect:()=>i(e)},e.id))})}var He={name:{title:`Name your new Factory`,placeholder:`e.g. Mastra`,searchable:!1},vcs:{title:`Choose your codebase`,placeholder:`Search repositories`},"project-management":{title:`Connect the work behind the code`,placeholder:`Search options`},"model-provider":{title:`Choose your Factory model`,placeholder:`Search models and providers`}};function Ue(e){return e instanceof Error?e.message:`Something went wrong. Please try again.`}function We(){let e=ie(),t=ae(),{factoryId:n}=oe(),{baseUrl:r}=S(),i=d(),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(),l=i.draft,u=j();O(void 0,l?.step===`name`&&u.data?.connected===!0);let f=je({draft:l,onFactoryCreated:e=>i.rememberFactory(e),onRepositoryLinked:e=>i.rememberLinkedRepository(e),onCreated:async t=>{await i.clear(),e(Ce(t))}}),m=f.isPending;p({Escape:()=>{t.key==="default"?e(n?`/factories/${n}`:`/`):e(-1)}},{enabled:!m,insideFields:!0});let h=l?.step;if(!h)return null;let g=(s?.step===h?s.value:void 0)??(h===`name`?l.name??``:``);return(0,J.jsx)(`div`,{className:`flex min-h-0 flex-col gap-2 pt-6`,children:(0,J.jsxs)(Me,{...He[h],step:h,value:g,onValueChange:e=>c({step:h,value:e}),onBack:h===`name`||m||l.factoryId||l.linkedRepositoryId?void 0:()=>{c(void 0),i.back()},onSkip:h===`project-management`?()=>void i.skipProjectManagement():void 0,children:[h===`name`&&(0,J.jsx)($,{name:g,onSubmit:i.startVcs}),h===`vcs`&&(0,J.jsx)(ze,{query:g,githubRedirecting:a,onConnect:()=>{o(!0),i.persistBeforeRedirect(n),b(r)},onManageConnection:()=>{i.persistBeforeRedirect(n),x(r)},onSelectRepository:e=>void i.chooseRepository(e)}),h===`project-management`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Pe,{query:g,onConnect:()=>{i.persistBeforeRedirect(n),Se(r)},onSelectProject:e=>void i.chooseLinearProject(e),onSkip:()=>void i.skipProjectManagement()}),(0,J.jsx)(Ne,{query:g,onSelectProject:e=>void i.chooseJiraProject(e)})]}),h===`model-provider`&&(0,J.jsx)(Le,{query:g,savingModelId:f.isPending?f.variables?.modelId:void 0,error:f.error?Ue(f.error):void 0,onPick:(e,t)=>f.mutate({modelId:t})})]})})}function Ge(){let e=l();return(0,J.jsx)(o,{...e,variant:`narrow`,header:(0,J.jsx)(t,{children:(0,J.jsx)(t.Title,{children:`New Factory`})}),children:(0,J.jsx)(We,{})})}export{Ge as CreateFactoryPage};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-BpvMnN1l.js";import{$n as r,Fi as i,Hr as a,Zi as o,_c as s,dr as c,lr as l,n as u,or as d,pc as f,pr as p,qi as m,vo as h}from"./GithubIcon.es-BPBhMx2H.js";import{t as g}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{Bn as _,Cr as v,Mr as ee,Vn as y,en as b,jr as x}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-BpvMnN1l.js";import{$n as r,Fi as i,Hr as a,Zi as o,_c as s,dr as c,lr as l,n as u,or as d,pc as f,pr as p,qi as m,vo as h}from"./GithubIcon.es-BPBhMx2H.js";import{t as g}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{Bn as _,Cr as v,Mr as ee,Vn as y,en as b,jr as x}from"./index-7W2GRQBh.js";import{C as S,a as C,j as w,x as te}from"./Sidebar.es-DSPzNNju.js";import{O as T,T as E,k as ne,n as D}from"./IconChevronRightMedium.es-BjSIsine.js";import{a as re,t as O}from"./lib-DkXXjRNC.js";import{r as ie}from"./useBoardEditor-DiWa4Lcl.js";import{i as ae,n as oe,r as se,t as ce}from"./SkillBadges-BN_VjOtf.js";import{a as le,c as ue,l as k}from"./boardConfigPaths-Btimpi_r.js";import{t as A}from"./AlertDialog.es-DDAl3sXA.js";import{t as de}from"./InlineText-vWKzGKx_.js";import{o as fe}from"./CodeBlock.es-lPYMhQRD.js";import{t as pe}from"./MarkdownRenderer-Y8TNNi2F-Dq4iwrPa.js";import{t as me}from"./IconChainLink3.es-CNFznS2g.js";import{t as he}from"./IconCodeBrackets.es-o1byTuto.js";import{a as ge,i as _e,n as ve,o as ye,r as be,t as xe}from"./esm-DH1__fiI.js";import{t as Se}from"./createLucideIcon-B6gALBEh.js";import{a as j,i as Ce}from"./dist-6WNNvkM4.js";import{n as we,r as Te}from"./dist-CMX7_OjZ.js";import{F as M,L as Ee,M as N,N as P,R as De,X as Oe,dt as ke,it as Ae,j as je,mt as Me,ut as F,vt as Ne,yt as Pe}from"./dist-Sr6WSEaV.js";import{r as Fe}from"./settingsColumn-CrKuH8q1.js";import{t as Ie}from"./LoadErrorState-CtPpeSh8.js";var Le={name:`italic`,size:24,node:[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]};Le.node;var Re=Se(Le),ze={name:`letter-b`,size:24,node:[[`path`,{d:`M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8`,key:`n8tvfh`}]],aliases:[`bold`]};ze.node;var Be=Se(ze),I=e(ne(),1);function Ve(e){let t=(0,I.useRef)(!1),n=()=>e&&!t.current,i=r(({currentLocation:e,nextLocation:t})=>n()&&e.pathname!==t.pathname);return re(e=>{n()&&e.preventDefault()}),{blocker:i,leave:e=>{t.current=!0,e()}}}var L=T();function R({blocker:e,title:t,description:n}){return(0,L.jsx)(A,{open:e.state===`blocked`,onOpenChange:t=>!t&&e.reset?.(),children:(0,L.jsxs)(A.Content,{children:[(0,L.jsxs)(A.Header,{children:[(0,L.jsx)(A.Title,{children:t}),(0,L.jsx)(A.Description,{children:n})]}),(0,L.jsxs)(A.Footer,{children:[(0,L.jsx)(A.Cancel,{children:`Keep editing`}),(0,L.jsx)(i,{variant:`destructive`,size:`md`,onClick:()=>e.proceed?.(),children:`Discard`})]})]})})}function z({notices:e,status:t,children:n}){return(0,L.jsxs)(`div`,{className:`rounded-card bg-card shadow-overlay dark:bg-muted sticky bottom-4 z-10 flex flex-col gap-3 p-3`,children:[e,(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(D,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:t}),n]})]})}function B({name:e,description:t,frontmatter:n,instructions:r}){return`---\n${[`name: ${JSON.stringify(e)}`,`description: ${JSON.stringify(t)}`,...Object.entries(n??{}).map(([e,t])=>`${e}: ${JSON.stringify(t)}`)].join(`
|
|
2
2
|
`)}\n---\n\n${r.trim()}\n`}function V({value:e,required:t,readOnly:n,onChange:r}){return(0,L.jsx)(D,{as:`p`,variant:`body`,tone:`muted`,children:(0,L.jsx)(de,{value:e,label:`Description`,placeholder:`Describe when agents should use it`,multiline:!0,required:t,readOnly:n,variant:`body`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:r})})}var He=e(h(),1),Ue=class extends De{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-md-bullet`,e.textContent=`•`,e}},H=P.replace({}),We=P.replace({widget:new Ue}),U=new Map,Ge=e=>{let t=U.get(e);return t||(t=P.line({class:e}),U.set(e,t)),t},Ke={EmphasisMark:[`Emphasis`,`StrongEmphasis`],StrikethroughMark:[`Strikethrough`],CodeMark:[`InlineCode`]},W=(e,t)=>e.some(e=>e.from<=t.to&&e.to>=t.from),G=e=>e.length-e.trimStart().length;function qe(e,t,n){let r=e.doc.lineAt(t.from);if(t.from===n.from)return{from:t.from,to:t.to+G(e.sliceDoc(t.to,r.to))};let i=e.sliceDoc(r.from,t.from);return{from:t.from-(i.length-i.trimEnd().length),to:t.to}}function Je(e){let{state:t}=e,n=e.hasFocus?t.selection.ranges:[],r=[],i=new Map,a=(e,t)=>{let n=i.get(e)??new Set;n.add(t),i.set(e,n)},o=(e,n,r)=>{let i=t.doc.lineAt(Math.max(e.from,n.from)),o=t.doc.lineAt(Math.min(e.to,n.to));for(let e=i.number;e<=o.number;e++)a(t.doc.line(e).from,r)},s=(e,t,i=H)=>{W(n,t)||r.push(i.range(e.from,e.to))};for(let i of e.visibleRanges)N(t).iterate({from:i.from,to:i.to,enter:e=>{let{name:c}=e;if(c===`FencedCode`)return o(e,i,`cm-md-fence-line`),e.from>=i.from&&a(t.doc.lineAt(e.from).from,`cm-md-fence-start`),e.to<=i.to&&a(t.doc.lineAt(e.to).from,`cm-md-fence-end`),!1;if(c===`Blockquote`){o(e,i,`cm-md-quote-line`);return}let l=e.node;if(c===`Link`){let[n,r]=l.getChildren(`LinkMark`);n&&r&&l.getChild(`URL`)&&t.doc.lineAt(r.from).to>=e.to&&(s(n,e),s({from:r.from,to:e.to},e));return}let u=t.doc.lineAt(e.from);if(c===`HorizontalRule`){W(n,u)||(r.push(H.range(e.from,e.to)),a(u.from,`cm-md-rule-line`));return}let d=l.parent;if(d){if(c===`HeaderMark`&&d.name.startsWith(`ATXHeading`))s(qe(t,l,d),u);else if(c===`QuoteMark`){let n=Math.min(1,G(t.sliceDoc(e.to,u.to)));s({from:e.from,to:e.to+n},u)}else c===`ListMark`&&d.parent?.name===`BulletList`?s(e,u,We):Ke[c]?.includes(d.name)&&s(e,d)}}});for(let[e,t]of i)r.push(Ge([...t].join(` `)).range(e));return P.set(r,!0)}var Ye=Ee.fromClass(class{decorations;constructor(e){this.decorations=Je(e)}update(e){let t=N(e.startState)!==N(e.state);(e.docChanged||e.selectionSet||e.focusChanged||e.viewportChanged||t)&&(this.decorations=Je(e.view))}},{decorations:e=>e.decorations}),K={node:`StrongEmphasis`,marker:`**`},q={node:`Emphasis`,marker:`*`},Xe={node:`InlineCode`,marker:"`"},Ze=/^https?:\/\/\S+$/,Qe=/^\s*(?:(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?|>\s?|#{1,6}\s+)*/,$e=/^(?:FencedCode|CodeBlock)$/,et=/^(?:Paragraph|ATXHeading\d|SetextHeading\d|Task|TableCell)$/,tt=[1,-1],nt=K.marker.length+q.marker.length;function J(e,t,n){let r=N(e);for(let e of tt)for(let i=r.resolveInner(t.from,e);i;i=i.parent)if(i.name===n&&i.from<=t.from&&i.to>=t.to)return i;return null}function rt(e,t){for(let n=e;n;n=n.parent)if(t.test(n.name))return n;return null}var Y=(e,t)=>tt.some(n=>rt(N(e).resolveInner(t,n),$e)!==null),it=(e,t)=>{let n=N(e).resolveInner(t.from,1);if(n.name===`HeaderMark`)return!1;let r=rt(n,et);return r!==null&&t.to<=r.to};function at(e,t){let n=[];for(let r=t.from;r<=t.to;){let i=e.doc.lineAt(r),a=i.from+(Qe.exec(i.text)?.[0].length??0),o=Math.max(t.from,a),s=Math.min(t.to,i.to),c=e.sliceDoc(o,s),l=o+c.length-c.trimStart().length,u=s-(c.length-c.trimEnd().length),d={from:l,to:u};l<u&&it(e,d)&&n.push(d),r=i.to+1}return n}function ot(e,t,n){let r=J(e,{from:t,to:t},n.node);return!r?.firstChild||!r.lastChild?null:t>=r.firstChild.to&&t<=r.lastChild.from?r:null}function st(e,t,n){if(t.empty)return!!ot(e,t.from,n);let r=at(e,t);return r.length>0&&r.every(t=>J(e,t,n.node))}var X=e=>e.firstChild&&e.lastChild?[{from:e.from,to:e.firstChild.to},{from:e.lastChild.from,to:e.to}]:[];function ct(e,t,n){let r=[];return N(e).iterate({from:t.from,to:t.to,enter:e=>{e.name===n&&e.to>t.from&&e.from<t.to&&r.push(e.node)}}),r}function Z(e,t,n){let r=e.changes(t),i=r.mapPos(n.from,1),a=Math.max(i,r.mapPos(n.to,-1));return{changes:r,range:n.anchor===n.from?F.range(i,a):F.range(a,i)}}function lt(e,t,n){let r=e.doc.lineAt(t),i=t-r.from,a=0;for(;r.text.charAt(i-a-1)===n;)a++;let o=0;for(;r.text.charAt(i+o)===n;)o++;return{before:a,after:o}}function ut(e,t,n,r){let i=t.from;if(Y(e,i))return{range:t};let a=r?ot(e,i,n):null;if(a?.lastChild&&i===a.lastChild.from)return{range:F.cursor(a.to)};if(a)return Z(e,X(a),t);let{marker:o}=n,{before:s,after:c}=lt(e,i,o.charAt(0));return s===c&&(s===o.length||s===nt)?{changes:{from:i-o.length,to:i+o.length},range:F.cursor(i-o.length)}:{changes:{from:i,insert:o+o},range:F.cursor(i+o.length)}}function dt(e,t,n,r){let i=[];for(let a of at(e,t)){if(r){let t=J(e,a,n.node);t&&i.push(...X(t));continue}let t=ct(e,a,n.node),o=Math.min(a.from,...t.map(e=>e.from)),s=Math.max(a.to,...t.map(e=>e.to));i.push(...t.flatMap(X),{from:o,insert:n.marker},{from:s,insert:n.marker})}return Z(e,i,t)}var Q=(e,t)=>e.selection.ranges.every(n=>st(e,n,t)),$=e=>({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=Q(t,e),i=t.changeByRange(n=>n.empty?ut(t,n,e,r):dt(t,n,e,r));return n(t.update(i,{scrollIntoView:!0,userEvent:`input.format`})),!0},ft=(e,t)=>{let n=J(e,t,`Link`);return n?.getChild(`URL`)?n:null},pt=e=>e.selection.ranges.every(t=>ft(e,t));function mt(e,t,n){if(n){let n=ft(e,t),[r,i]=n?.getChildren(`LinkMark`)??[];return!n||!r||!i?{range:t}:Z(e,[{from:n.from,to:r.to},{from:i.from,to:n.to}],t)}if(Y(e,t.from)||e.doc.lineAt(t.from).number!==e.doc.lineAt(t.to).number)return{range:t};let r=e.sliceDoc(t.from,t.to);return Ze.test(r)?{changes:{from:t.from,to:t.to,insert:`[](${r})`},range:F.cursor(t.from+1)}:t.empty?{changes:{from:t.from,insert:`[]()`},range:F.cursor(t.from+1)}:{changes:[{from:t.from,insert:`[`},{from:t.to,insert:`]()`}],range:F.cursor(t.to+3)}}var ht=[{id:`bold`,label:`Bold`,key:`b`,run:$(K),isActive:e=>Q(e,K)},{id:`italic`,label:`Italic`,key:`i`,run:$(q),isActive:e=>Q(e,q)},{id:`code`,label:`Code`,key:`e`,run:$(Xe),isActive:e=>Q(e,Xe)},{id:`link`,label:`Link`,key:`k`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=pt(e);return t(e.update(e.changeByRange(t=>mt(e,t,n)),{scrollIntoView:!0,userEvent:`input.format`})),!0},isActive:pt}],gt=Me.high(Oe.of(ht.map(e=>({key:`Mod-${e.key}`,run:e.run})))),_t=Ce([...fe,{tag:j.heading1,class:`cm-md-heading cm-md-h1`},{tag:j.heading2,class:`cm-md-heading cm-md-h2`},{tag:j.heading3,class:`cm-md-heading cm-md-h3`},{tag:[j.heading4,j.heading5,j.heading6],class:`cm-md-heading`},{tag:j.strong,class:`cm-md-strong`},{tag:j.emphasis,class:`cm-md-emphasis`},{tag:j.strikethrough,class:`cm-md-strike`},{tag:j.link,class:`cm-md-link`},{tag:j.url,class:`cm-md-url`},{tag:j.monospace,class:`cm-md-code`},{tag:j.quote,class:`cm-md-quote`},{tag:[j.processingInstruction,j.contentSeparator,j.labelName],class:`cm-md-mark`}]),vt=M.theme({"&.cm-editor":{fontSize:`var(--text-body)`},".cm-content":{lineHeight:`var(--markdown-leading)`},".cm-placeholder":{color:`var(--placeholder)`},".cm-md-link.cm-md-url, .cm-md-link.cm-md-mark":{color:`var(--placeholder)`,textDecoration:`none`},".cm-md-mark":{color:`var(--placeholder)`},".cm-md-bullet":{color:`var(--muted-foreground)`},".cm-line.cm-md-quote-line":{borderLeft:`var(--markdown-quote-rule)`,paddingLeft:`var(--markdown-quote-inset)`},".cm-line.cm-md-fence-line":{backgroundColor:`var(--fill)`,padding:`0 0.75em`,fontFamily:`var(--font-mono)`,fontSize:`0.875em`},".cm-line.cm-md-fence-start":{borderTopLeftRadius:`6px`,borderTopRightRadius:`6px`,paddingTop:`0.25em`},".cm-line.cm-md-fence-end":{borderBottomLeftRadius:`6px`,borderBottomRightRadius:`6px`,paddingBottom:`0.25em`},".cm-md-fence-line .cm-md-code":{backgroundColor:`transparent`,padding:`0`,fontSize:`inherit`},".cm-line.cm-md-rule-line":{background:`linear-gradient(var(--border), var(--border)) no-repeat center / 100% 1px`},"&.cm-editor .cm-tooltip.cm-tooltip-autocomplete > ul":{maxHeight:`none`,padding:`4px`,fontFamily:`var(--font-body)`},"&.cm-editor .cm-tooltip.cm-tooltip-autocomplete > ul > li":{display:`flex`,alignItems:`baseline`,borderRadius:`4px`,padding:`4px 8px`,lineHeight:`1.5`},"&.cm-editor .cm-completionDetail":{fontFamily:`var(--font-mono)`,fontStyle:`normal`}}),yt=[M.editorAttributes.of({class:`mastra-markdown-editor`}),je(_t),vt],bt=Ne.define(),xt=Pe.define({create:()=>!1,update:(e,t)=>t.effects.reduce((e,t)=>t.is(bt)?t.value:e,e)}),St=M.theme({".cm-tooltip.cm-md-toolbar":{border:`none`,backgroundColor:`transparent`}});function Ct(){let e=null,t=new Set,n=n=>{e=n;for(let e of t)e()},r=e=>{let t=document.createElement(`div`);return t.className=`cm-md-toolbar`,{dom:t,offset:{x:0,y:6},mount:()=>n({host:t,view:e,state:e.state}),update:r=>{(r.docChanged||r.selectionSet)&&n({host:t,view:e,state:r.state})},destroy:()=>n(null)}},i=(e,t)=>{let{from:n,to:i,empty:a}=e.selection.main;return a||e.readOnly||!e.field(xt)?null:t?.pos===n&&t.end===i?t:{pos:n,end:i,above:!0,arrow:!1,create:r}},a=Pe.define({create:e=>i(e,null),update:(e,t)=>i(t.state,e),provide:e=>Ae.from(e)});return{extension:[xt,M.focusChangeEffect.of((e,t)=>bt.of(t)),a,St],subscribe:e=>(t.add(e),()=>t.delete(e)),getSnapshot:()=>e}}var wt=[{label:`Heading 1`,markdown:`#`,insert:`# `},{label:`Heading 2`,markdown:`##`,insert:`## `},{label:`Heading 3`,markdown:`###`,insert:`### `},{label:`Bulleted list`,markdown:`-`,insert:`- `},{label:`Numbered list`,markdown:`1.`,insert:`1. `},{label:`Quote`,markdown:`>`,insert:`> `},{label:`Code block`,markdown:"```",insert:"```\n\n```",caret:4},{label:`Divider`,markdown:`***`,insert:`***
|
|
3
3
|
`}].map((e,t)=>({label:e.label,detail:e.markdown,type:`keyword`,boost:-t,apply:(t,n,r,i)=>{let a=r-1;t.dispatch({changes:{from:a,to:i,insert:e.insert},selection:{anchor:a+(e.caret??e.insert.length)},scrollIntoView:!0,userEvent:`input.complete`})}}));function Tt(e){if(e.state.readOnly)return null;let t=e.matchBefore(/\/\w*$/);if(!t)return null;let n=e.state.doc.lineAt(t.from);return e.state.sliceDoc(n.from,t.from).trim()!==``||Y(e.state,t.from)?null:{from:t.from+1,options:wt,validFor:/^\w*$/}}var Et=Te.data.of({autocomplete:Tt}),Dt={bold:(0,L.jsx)(Be,{}),italic:(0,L.jsx)(Re,{}),code:(0,L.jsx)(he,{}),link:(0,L.jsx)(me,{})},Ot=e=>e.preventDefault();function kt({toolbar:e}){let t=(0,I.useSyncExternalStore)(e.subscribe,e.getSnapshot,()=>null),n=y();if(!t)return null;let{host:r,view:a,state:o}=t;return(0,He.createPortal)((0,L.jsx)(`div`,{role:`toolbar`,"aria-label":`Formatting`,className:E(f,`flex items-center gap-0.5 rounded-full p-1`),children:ht.map(e=>{let t=e.isActive(o),r=_(e.key,n),s=e.key.toUpperCase();return(0,L.jsx)(i,{type:`button`,size:`icon-sm`,variant:t?`subtle`:`ghost`,"aria-label":e.label,"aria-pressed":t,"aria-keyshortcuts":n?`Meta+${s}`:`Control+${s}`,tooltip:(0,L.jsx)(S,{label:e.label,shortcut:r}),tabIndex:-1,onMouseDown:Ot,onClick:()=>e.run(a),children:Dt[e.id]},e.id)})}),r)}var At=s(`relative transition-colors duration-normal ease-out-custom`,{variants:{variant:{default:E(o,`rounded-md px-3 py-2`,m),inline:``}},defaultVariants:{variant:`default`}}),jt={lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1,highlightActiveLineGutter:!1,highlightSelectionMatches:!1,bracketMatching:!1,closeBrackets:!1},Mt=[..._e,ge,M.lineWrapping,we({base:Te,codeLanguages:ve}),yt,Ye,gt,Et],Nt=[ke.readOnly.of(!0),Me.highest(M.domEventHandlers({paste:()=>!0}))],Pt=(0,I.forwardRef)(function({value:e,onChange:t,placeholder:n,editable:r=!0,autoFocus:i,variant:a,className:o,id:s,"aria-label":c,"aria-labelledby":l,"aria-describedby":u,"aria-invalid":d,...f},p){let{contentAttributes:m}=ye({id:s,"aria-label":c,"aria-labelledby":l,"aria-describedby":u,"aria-invalid":d},`Markdown editor`),[h]=(0,I.useState)(Ct),g=(0,I.useMemo)(()=>[...Mt,m,h.extension,...r?[]:[Nt]],[m,h,r]);return(0,L.jsxs)(`div`,{className:E(At({variant:a}),o),...f,children:[(0,L.jsx)(xe,{ref:p,value:e,theme:be(`body`),extensions:g,onChange:t,editable:r,placeholder:n,autoFocus:i,basicSetup:jt}),(0,L.jsx)(kt,{toolbar:h})]})});function Ft({value:e,readOnly:t,onChange:n}){return t&&e?(0,L.jsx)(pe,{children:e}):t?(0,L.jsx)(D,{variant:`body`,tone:`muted`,children:`No instructions`}):(0,L.jsx)(Pt,{"aria-label":`Instructions`,value:e,placeholder:`Write the instructions agents follow`,onChange:n,variant:`inline`})}var It=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Lt=64;function Rt(e){if(!(e===``||It.test(e)&&e.length<=Lt))return`Use up to ${Lt} lowercase letters, digits, and single hyphens, such as release-notes.`}function zt(e,t){if(e===``)return`Name the skill to create it.`;if(Rt(e))return`Fix the name to create it.`;if(t.trim()===``)return`Add a description to create it.`}function Bt({factoryId:e,onCreated:t}){let[n,r]=(0,I.useState)(``),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(``),l=oe(e),d=n!==``||a!==``||s!==``,{blocker:f,leave:p}=Ve(d),m=Rt(n),h=zt(n,a);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,L.jsxs)(`div`,{inert:l.isPending,className:`flex flex-col gap-8`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(D,{as:`h1`,variant:`display-lg`,tone:`ink`,className:`min-w-0 break-words`,children:(0,L.jsx)(de,{value:n,label:`Name`,placeholder:`skill-name`,readOnly:!1,autoFocus:!0,variant:`display-lg`,tone:`ink`,onChange:e=>r(e.trim())})}),m&&(0,L.jsx)(D,{as:`p`,variant:`caption`,className:`text-destructive-foreground`,children:m}),(0,L.jsx)(V,{value:a,required:!1,readOnly:!1,onChange:o})]}),(0,L.jsx)(Ft,{value:s,readOnly:!1,onChange:c})]}),d&&(0,L.jsxs)(z,{status:h??`Only this Factory gets the skill. Agents can load it from their next session.`,notices:l.error&&(0,L.jsx)(u,{variant:`destructive`,role:`alert`,children:(0,L.jsx)(u.Message,{children:l.error.message})}),children:[(0,L.jsx)(i,{size:`sm`,variant:`ghost`,onClick:()=>{r(``),o(``),c(``),l.reset()},disabled:l.isPending,children:`Discard`}),(0,L.jsx)(i,{size:`sm`,variant:`primary`,onClick:()=>l.mutate({name:n,content:B({name:n,description:a,instructions:s})},{onSuccess:()=>p(()=>t(n))}),disabled:h!==void 0||l.isPending,children:l.isPending?`Creating…`:`Create`})]}),(0,L.jsx)(R,{blocker:f,title:`Discard this new skill?`,description:`It has not been created yet.`})]})}function Vt({factoryId:e,skill:t,canEdit:n,onDeleted:r}){let[a,o]=(0,I.useState)(),[s,c]=(0,I.useState)(),l=a??t.description,d=s??t.content,[f,p]=(0,I.useState)(!1),m=(0,I.useRef)(null),h=se(e),g=se(e),_=h.isPending||g.isPending,v=n&&(l!==t.description||d!==t.content),{blocker:ee,leave:y}=Ve(v),b=n&&!!t.edited,x=n&&t.origin===`project`,S=(e,t)=>e===t&&!_?void 0:e,C=e=>()=>{o(t=>t===e.description?void 0:t),c(t=>t===e.instructions?void 0:t)};return(0,L.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex min-h-8 flex-wrap items-center gap-2 empty:hidden`,children:[(0,L.jsx)(ce,{skill:t}),(!n||b||x)&&(0,L.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[!n&&(0,L.jsx)(D,{variant:`caption`,tone:`muted`,children:`Only organization admins can edit skills.`}),b&&(0,L.jsx)(i,{size:`sm`,variant:`ghost`,onClick:()=>g.mutate({name:t.name,content:null},{onSuccess:C({description:l,instructions:d})}),disabled:_,children:`Revert to original`}),x&&(0,L.jsx)(i,{ref:m,size:`sm`,variant:`ghost`,onClick:()=>p(!0),disabled:_,children:`Delete`})]})]}),f&&(0,L.jsx)(u,{variant:`warning`,title:`Delete ${t.name}?`,actionPlacement:`end`,action:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(i,{size:`sm`,onClick:()=>{p(!1),m.current?.focus()},disabled:_,autoFocus:!0,children:`Keep`}),(0,L.jsx)(i,{size:`sm`,variant:`destructive`,onClick:()=>g.mutate({name:t.name,content:null},{onSuccess:()=>y(r)}),disabled:_,children:`Delete skill`})]}),children:(0,L.jsx)(u.Message,{children:`Cards entering a phase that runs it won't start until the phase gets another skill.`})}),g.error&&(0,L.jsx)(u,{variant:`destructive`,role:`alert`,children:(0,L.jsx)(u.Message,{children:g.error.message})}),t.error&&(0,L.jsx)(u,{variant:`destructive`,role:`alert`,children:(0,L.jsxs)(u.Message,{children:[`Agents cannot load this skill: `,t.error]})}),t.edited&&t.originalChanged&&(0,L.jsx)(u,{variant:`info`,role:`note`,children:(0,L.jsx)(u.Message,{children:`The original changed since this was edited. Revert to use the new original.`})}),(0,L.jsx)(D,{as:`h1`,variant:`display-lg`,tone:`ink`,className:`min-w-0 break-words`,children:t.name}),(0,L.jsx)(V,{value:l,required:!0,readOnly:!n,onChange:e=>o(S(e,t.description))})]}),(0,L.jsx)(Ft,{value:d,readOnly:!n,onChange:e=>c(S(e,t.content))}),v&&(0,L.jsxs)(z,{status:`Unsaved changes for this Factory. Running sessions keep the version they started with.`,notices:h.error&&(0,L.jsx)(u,{variant:`destructive`,role:`alert`,children:(0,L.jsx)(u.Message,{children:h.error.message})}),children:[(0,L.jsx)(i,{size:`sm`,variant:`ghost`,onClick:()=>{o(void 0),c(void 0),h.reset()},disabled:_,children:`Discard`}),(0,L.jsx)(i,{size:`sm`,variant:`primary`,onClick:()=>h.mutate({name:t.name,content:B({name:t.name,description:l,frontmatter:t.frontmatter,instructions:d})},{onSuccess:C({description:l,instructions:d})}),disabled:_,children:h.isPending?`Saving…`:`Save`})]}),(0,L.jsx)(R,{blocker:ee,title:`Discard changes to ${t.name}?`,description:`Your unsaved changes to this skill will be lost.`})]})}function Ht(){let e=v(),r=b()?.boardId??``,{skillName:o}=p(),s=l(),u=c(),{key:f}=d(),m=f!=="default"&&u!==a.Replace,{isMobile:h,desktopState:g}=C(),_=h||g===`collapsed`,y=ie(e.id,r).data?.board,S=k(e.id,r),w=()=>{s(m?-1:S)},T=x({breadcrumbs:_&&y?(0,L.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,L.jsx)(t,{as:O,to:le(e.id,r),children:y.name}),(0,L.jsx)(t,{as:O,to:S,children:`Skills`}),(0,L.jsx)(t,{as:`span`,isCurrent:!0,children:o??`New skill`})]}):void 0});return(0,L.jsxs)(ee,{...T,children:[(0,L.jsx)(`div`,{className:`sticky top-0 z-10 w-fit p-2`,children:(0,L.jsx)(i,{variant:`default`,size:`sm`,icon:(0,L.jsx)(te,{}),onClick:w,children:`Back`})}),(0,L.jsx)(`div`,{className:E(Fe,`flex flex-col pt-4`),children:(0,L.jsx)(Ut,{factoryId:e.id,boardId:r,skillName:o})})]})}function Ut({factoryId:e,boardId:t,skillName:n}){let r=l(),a=ae(e),o=k(e,t);if(a.isPending)return(0,L.jsxs)(`div`,{role:`status`,"aria-label":`Loading skill`,className:`flex flex-col gap-4`,children:[(0,L.jsx)(w,{className:`h-9 w-2/3`}),(0,L.jsx)(w,{className:`h-5 w-full`}),(0,L.jsx)(w,{className:`h-40 w-full`})]});if(a.isLoadingError)return(0,L.jsx)(Ie,{title:`Couldn’t load skills`,error:a.error,onRetry:()=>void a.refetch(),retrying:a.isFetching});let s=a.data.canEdit??!1;if(n===void 0&&!s)return(0,L.jsx)(u,{variant:`info`,children:`Only organization admins can create skills.`});if(n===void 0)return(0,L.jsx)(Bt,{factoryId:e,onCreated:n=>void r(ue(e,t,n),{replace:!0})},e);let c=a.data.skills.find(e=>e.name===n);return c?(0,L.jsx)(Vt,{factoryId:e,skill:c,canEdit:s,onDeleted:()=>void r(o,{replace:!0})},`${e}/${c.name}`):(0,L.jsx)(g,{variant:`fill`,titleSlot:(0,L.jsxs)(`span`,{role:`alert`,children:[`This factory has no `,n,` skill.`]}),actionSlot:(0,L.jsx)(i,{render:(0,L.jsx)(O,{to:o}),children:`Back to skills`})})}export{Ht as FactorySkillPage};
|