mastra 1.40.0-alpha.5 → 1.40.0-alpha.6
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-U8bssGrG.js → BoardConfigPage-C59a2c_7.js} +1 -1
- package/dist/factory/assets/{BoardIntakePage-IOLk_hcg.js → BoardIntakePage-OOPdyfge.js} +1 -1
- package/dist/factory/assets/{BoardRulesPage-BQFUmRqS.js → BoardRulesPage-DBH9Hx80.js} +1 -1
- package/dist/factory/assets/{Breadcrumb.es-Umaf5xAa.js → Breadcrumb.es-Caa0ta4Z.js} +1 -1
- package/dist/factory/assets/{CardDraftPage-CrP_yV74.js → CardDraftPage-DjBB918q.js} +1 -1
- package/dist/factory/assets/{CardStageBar-BZqlqfRN.js → CardStageBar-DWV6yjSW.js} +1 -1
- package/dist/factory/assets/{ConditionRows-CwdldDit.js → ConditionRows-DUjWJRNa.js} +1 -1
- package/dist/factory/assets/{CreateFactoryPage-2geXWor9.js → CreateFactoryPage-BNgW6jWY.js} +1 -1
- package/dist/factory/assets/{FactorySkillsPage-Bfgg-smA.js → FactorySkillsPage-_8CmueBy.js} +1 -1
- package/dist/factory/assets/{InputNumber.es-Qc2xMZUw.js → InputNumber.es-BzEgsntE.js} +1 -1
- package/dist/factory/assets/{IntakeTesterDialog-CEuLQs7z.js → IntakeTesterDialog-CDbp1koV.js} +1 -1
- package/dist/factory/assets/{KnowledgePage-B7-1aTfU.js → KnowledgePage-C50Ks8JU.js} +1 -1
- package/dist/factory/assets/{MastraGatewayBilling-1KcNk9hF.js → MastraGatewayBilling-C3-b6K5Q.js} +1 -1
- package/dist/factory/assets/{NewBoardPage--855jLtw.js → NewBoardPage-D6G2_ESh.js} +1 -1
- package/dist/factory/assets/{NewPage-D1p4tFix.js → NewPage-DVtL-8xt.js} +1 -1
- package/dist/factory/assets/{OnboardingPage-c0zQ_mB4.js → OnboardingPage-DMNuGkH2.js} +1 -1
- package/dist/factory/assets/{RulesPage-B-1W9NDA.js → RulesPage-I60UkTj3.js} +1 -1
- package/dist/factory/assets/SettingsPage-B_3esjm-.js +3 -0
- package/dist/factory/assets/{SlackConnectionPage-BZ9r8zBJ.js → SlackConnectionPage-F7MTbug7.js} +1 -1
- package/dist/factory/assets/{StackedDiffs-BlFbfMjN.js → StackedDiffs-CIGQW2T9.js} +1 -1
- package/dist/factory/assets/{ThreadPage-jL5B0n9z.js → ThreadPage-CKXuBQQW.js} +2 -2
- package/dist/factory/assets/{Transcript-DhHlVRYl.js → Transcript-9K1Flr3R.js} +1 -1
- package/dist/factory/assets/{Tree-B90XgTY4-14x-IKk1.js → Tree-B90XgTY4-D6BbhzdO.js} +1 -1
- package/dist/factory/assets/{conditionFields-Bxo1maIQ.js → conditionFields-CBXR0ZAG.js} +1 -1
- package/dist/factory/assets/index-BRPMzPXy.css +1 -0
- package/dist/factory/assets/{index-D2WNyeAe.js → index-CqME59pn.js} +21 -21
- package/dist/factory/assets/{settingsSections-CWOH80SC.js → settingsSections-Cijt0lNE.js} +1 -1
- package/dist/factory/assets/{useDraftModelGuards-BXIVJhQ8.js → useDraftModelGuards-oEIWfjNg.js} +1 -1
- package/dist/factory/assets/{workspaces-BMD_Mj8h.js → workspaces-DDVLmBW0.js} +1 -1
- package/dist/factory/index.html +3 -3
- package/dist/index.js +1 -1
- package/dist/studio/assets/{index-COdtaDSX.js → index-CSQ0Ltwq.js} +2 -2
- package/dist/studio/assets/{main-MAtdOvlP.js → main-CgYZzTbo.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/package.json +4 -4
- package/dist/factory/assets/SettingsPage-pRTR_Ntg.js +0 -3
- package/dist/factory/assets/index-Cwp4MQIz.css +0 -1
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-Umaf5xAa.js";import{t as r}from"./EmptyState-juw2jci2-vYAzd7Mx.js";import{$n as i,At as a,Bt as o,Dt as s,En as c,Et as l,Gt as u,Ht as d,It as f,Jt as p,Kt as m,Lt as h,Nt as g,Ot as _,Rt as v,Tt as y,Un as b,Zn as x,h as S,jt as ee,kt as te,m as ne,rn as re,u as ie,wt as C,zt as w}from"./index-D2WNyeAe.js";import{a as T,k as E}from"./Sidebar.es-DGzeKZbU.js";import{d as D,f as O,r as k,t as A,u as j}from"./settings-DmdIP3xB-Ivg55Tc-.js";import{D as M,O as N,d as P,i as F,n as I,o as L,t as ae,w as R}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{t as z}from"./lib-C4aHsZXk.js";import{c as oe,o as se,r as ce,s as le,t as ue}from"./useBoardEditor-D_XHmLsE.js";import{n as B,t as de}from"./FactorySkillEditorDialog-33yz9UNC.js";import{a as fe,c as pe,o as me,r as he}from"./boardConfigPaths-CyCwKxS5.js";import{t as V}from"./AlertDialog.es-egsOmf9n.js";import{Xn as ge,ca as H,ki as U,or as _e,sa as W,ua as G}from"./useFactories-B-Om6aVq.js";import{Z as ve,a as ye,c as be,i as xe,o as Se,r as K,s as Ce}from"./request-CPtLhnSV.js";import{n as we}from"./useBoardCatalog-Bwbdd2Vb.js";import{n as Te,t as Ee}from"./boardCatalog-y-s19dQU.js";import{a as De,d as Oe,t as ke}from"./BoardIcons-RydpbVA4.js";import{t as q}from"./SettingsSubsection-BTekyheK.js";import{o as Ae,u as je}from"./board-events-BVnaMaTS.js";import{S as Me,o as Ne,t as Pe,v as Fe,y as Ie}from"./conditionFields-Bxo1maIQ.js";import{t as Le}from"./CodeEditor-AaW7HgY9-BnB7l8h1.js";import{a as Re,n as ze,r as Be,t as Ve}from"./Field.es-NxMTQ8PW.js";import{t as He}from"./input-DqReKX0A-2mZo-XW9.js";import{a as Ue,n as We}from"./input-group-CXvse9n7-C2R5K-Tq.js";import{a as Ge,i as Ke,n as qe,r as Je,t as Ye}from"./InputNumber.es-Qc2xMZUw.js";import{n as Xe}from"./IconPlugin1.es-CZs2N-e2.js";import{r as Ze}from"./overlays-eEEsk-kD.js";import{t as Qe}from"./ConditionRows-CwdldDit.js";import{t as $e}from"./IconLock.es-0eb6hipg.js";import{n as et}from"./SlackIcon.es-4iabNI5s.js";import{a as tt}from"./IconClipboard2.es-DIRDjMMg.js";import{t as J}from"./page-header-Maytcmgh-Dm4StKTd.js";import{r as nt}from"./Input-A03ee_nt.js";import{t as rt}from"./LoadErrorState-dfQWbyzw.js";var Y=e(N(),1),X=M();function it({factoryId:e,board:t}){let n=je(e,t.id),r=Me(e),{count:i}=Fe(n.data?.intakeRoutes??[]),a=(r.data?.boards??[]).findIndex(e=>e.boardKey===t.id),o=n.isError||r.isError;return(0,X.jsx)(q,{title:`New items`,action:(0,X.jsx)(U,{size:`sm`,variant:`ghost`,render:(0,X.jsx)(z,{to:fe(e,t.id)}),children:`Edit rules`}),children:(0,X.jsx)(I,{as:`p`,variant:`caption`,tone:`muted`,role:o?`alert`:`status`,className:`flex flex-wrap gap-x-3 gap-y-1`,children:n.isPending||r.isPending?`Loading rules…`:o?`Rules didn’t load.`:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:at(i)}),(0,X.jsx)(`span`,{children:a===-1?`Not in the intake order`:`Checked ${Ie(a+1)}`})]})})})}function at(e){return e===0?`No rules for new items`:e===1?`1 rule for new items`:`${e} rules for new items`}var ot=`Finish or remove unfinished conditions to save.`;function st({label:e,description:t,rule:n,disabled:r,facts:i=Pe,options:a,schema:o,json:s,onChange:c,onUnfinished:l}){let[d,f]=(0,Y.useState)(void 0),h=s?s.text:d,g=s?s.onChange:f,_=(0,Y.useId)(),v=h===void 0?p(o,n):u(o,h),y=e=>{g(e);let t=m(o,e);`problem`in t?c(n??null,t.problem):c(t.rule,void 0)};return(0,X.jsxs)(Ve,{invalid:v!==void 0,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(Re,{htmlFor:_,children:e}),(0,X.jsx)(U,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{h===void 0?g(n?JSON.stringify(n,null,2):``):(g(void 0),c(n??null,p(o,n)))},children:h===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,X.jsx)(ze,{children:t}),h===void 0?r?(0,X.jsx)(I,{id:_,as:`p`,variant:`caption`,tone:`muted`,children:Ne(n,a)}):(0,X.jsx)(`div`,{id:_,children:(0,X.jsx)(Qe,{label:e,rule:n,facts:i,options:a,onChange:(e,t)=>{l?.(t),t?c(n??null,ot):c(e,p(o,e))}})}):(0,X.jsx)(Ze,{id:_,"aria-label":`${e} JSON`,value:h,disabled:r,rows:6,onChange:e=>y(e.target.value)}),v&&(0,X.jsx)(Be,{children:v})]})}var ct=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function lt({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,X.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,X.jsx)(ke,{stage:t.key,kind:De(i,t.kind),decorative:!0});if(t.key===e.key)return(0,X.jsxs)(`li`,{className:R(ct,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,X.jsx)(ut,{children:t.name}),(0,X.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,X.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:R(ct,`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`,L),children:[(0,X.jsx)(`span`,{className:R(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,X.jsx)(ut,{children:t.name}),(0,X.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,X.jsx)($e,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,X.jsx)(ve,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,X.jsx)(et,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,X.jsx)(`li`,{className:`min-w-0`,children:l?(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{render:d}),(0,X.jsx)(H,{children:`Factory's code makes this move`})]}):d},t.key)})})}function ut({children:e}){return(0,X.jsx)(I,{as:`span`,variant:`label`,className:`truncate`,children:e})}function dt({label:e,children:t}){return(0,X.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Z({icon:e,title:t,description:n,children:r}){let i=(0,Y.useId)();return(0,X.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,X.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,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,X.jsx)(I,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,X.jsx)(I,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var ft=P(`IconFlag2`,()=>(0,X.jsx)(`path`,{d:`M5 15.0002V4.61942C5 4.24002 5.21411 3.88671 5.56677 3.74679C9.85713 2.0446 13.3106 5.53259 17.4846 4.5523C18.2075 4.38251 19 4.87246 19 5.61508V14.3809C19 14.7603 18.7859 15.1137 18.4332 15.2536C13.6349 17.1573 9.88335 12.5691 5 15.0002ZM5 15.0002V21.0002`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})),pt=`__none__`,mt=`sm:max-w-xs`,ht=(e,t)=>e>=t-200?` ${e}/${t}`:``,gt=`work`;function _t({skill:e,missing:t}){return(0,X.jsxs)(X.Fragment,{children:[t&&(0,X.jsx)(E,{variant:`destructive`,children:`Not found`}),e?.error&&(0,X.jsx)(E,{variant:`destructive`,children:`Failed to load`}),e?.builtIn&&e.origin!==void 0&&e.origin!==`bundled`&&(0,X.jsx)(E,{children:`Overridden by app`}),e?.edited&&(0,X.jsx)(E,{children:`Edited`})]})}function Q({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,X.jsxs)(k,{children:[(0,X.jsxs)(Ve,{invalid:!!n,disabled:r,children:[(0,X.jsx)(D,{children:e}),(0,X.jsx)(ze,{children:t}),i,n&&(0,X.jsx)(Be,{children:n})]}),a]})}function vt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,X.jsx)(A,{children:(0,X.jsx)(`div`,{className:`px-4 py-3`,children:(0,X.jsx)(Le,{"aria-label":e,value:t,placeholder:n,editable:!r,onChange:i,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1})})})}function yt({phase:e,phases:t,requiredNextPhases:n,skills:r,skillsEditable:i,factoryId:a,boardId:o,disabled:l,rawRules:u,onChange:d,onRawRule:f,onUnfinished:p,onRemove:m}){let v=e.kind===`working`,y=h(e,t),b=e.runner?.instructions??``,x=e.runner?.goal,S=x?.objective??``,ee=e.tools??[],C=e.exitTool?.id??``,w=e.runner?.skill,T=w?r?.find(e=>e.name===w):void 0,E=w!==void 0&&r!==void 0&&T===void 0,[D,k]=(0,Y.useState)(),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=>f(e,t)}),N=(0,X.jsx)(lt,{phase:e,phases:t,next:y,required:new Set(n),boardId:o,disabled:l,onChange:t=>d({...e,nextPhases:t})}),P=m&&(0,X.jsx)(`div`,{children:(0,X.jsxs)(U,{variant:`ghost`,icon:(0,X.jsx)(tt,{}),onClick:m,children:[`Remove `,e.name]})});return v?(0,X.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,X.jsxs)(dt,{label:`How ${e.name} runs`,children:[(0,X.jsx)(Z,{icon:(0,X.jsx)(Oe,{}),title:`Starts`,children:(0,X.jsxs)(A,{children:[(0,X.jsx)(O,{label:`Start on its own`,disabled:l,children:(0,X.jsx)(Xe,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:l,onCheckedChange:t=>{d({...e,autoStart:t,autoStartWhen:t?e.autoStartWhen:null}),t||f(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,X.jsx)(`div`,{className:`px-4 py-3`,children:(0,X.jsx)(st,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Ae,disabled:l,json:M(`autoStartWhen`),onUnfinished:e=>p(`autoStartWhen`,e),onChange:t=>d({...e,autoStartWhen:t})})})]})}),(0,X.jsxs)(Z,{icon:(0,X.jsx)(ie,{}),title:`Agent runs`,children:[(0,X.jsx)(Q,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${ht(b.length,s)}`,error:b.length>1e3?`Too long to save.`:void 0,disabled:l,children:(0,X.jsx)(vt,{label:`${e.name} instructions`,value:b,placeholder:`Tell the agent what to do, in Markdown`,disabled:l,onChange:e=>j({instructions:e})})}),(0,X.jsx)(Q,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${ht(S.length,_)}`,error:S.length>2e3?`Too long to save.`:void 0,disabled:l,after:x&&(0,X.jsxs)(Ve,{invalid:!g(x.maxRuns),disabled:l,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(Re,{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,X.jsx)(Ye,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:x.maxRuns??null,disabled:l,onValueChange:e=>{let{maxRuns:t,...n}=x;j({goal:e===null?n:{...n,maxRuns:e}})},children:(0,X.jsxs)(Je,{size:`sm`,children:[(0,X.jsx)(Ge,{placeholder:`Default`}),(0,X.jsxs)(We,{align:`inline-end`,variant:`flush`,children:[(0,X.jsx)(Ue,{className:`mr-1`,children:`runs`}),(0,X.jsx)(qe,{}),(0,X.jsx)(Ke,{})]})]})})]}),!g(x.maxRuns)&&(0,X.jsxs)(Be,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,X.jsx)(vt,{label:`${e.name} goal`,value:S,placeholder:`Describe what done looks like`,disabled:l,onChange:e=>j({goal:e.trim()?{...x,objective:e}:void 0})})}),(0,X.jsx)(Q,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:l,children:(0,X.jsx)(He,{className:mt,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:gt,disabled:l,onChange:e=>j({context:e.target.value})})}),(0,X.jsx)(q,{title:`Skill`,children:(0,X.jsx)(A,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsxs)(ye,{value:w??pt,disabled:l,onValueChange:e=>j({skill:e===pt?void 0:String(e)}),children:[(0,X.jsx)(be,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(ne,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:w??`No skill`})]})}),(0,X.jsxs)(Se,{children:[(0,X.jsx)(Ce,{value:pt,children:`None`}),(r??[]).map(e=>(0,X.jsx)(Ce,{value:e.name,children:e.name},e.name))]})]}),(0,X.jsx)(_t,{skill:T,missing:E}),T&&(0,X.jsx)(U,{size:`sm`,variant:`ghost`,icon:i?(0,X.jsx)(c,{}):(0,X.jsx)(xe,{}),"aria-label":`${i?`Edit`:`View`} ${T.name}`,className:`ml-auto`,onClick:()=>k(T),children:i?`Edit`:`View`})]}),T?.error?(0,X.jsxs)(I,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,T.error]}):E?(0,X.jsxs)(I,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,w,` skill, so cards entering `,e.name,` fail to start.`]}):T?.description&&(0,X.jsx)(I,{as:`p`,variant:`caption`,tone:`muted`,children:T.description})]})})}),(0,X.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,X.jsx)(A,{children:te.map(t=>(0,X.jsx)(O,{label:t.label,disabled:l,children:(0,X.jsx)(Xe,{"aria-label":`${e.name}: ${t.label}`,checked:ee.includes(t.id),disabled:l,onCheckedChange:n=>{let r=te.map(({id:e})=>e).filter(e=>e===t.id?n:ee.includes(e));d({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,X.jsxs)(Z,{icon:(0,X.jsx)(ft,{}),title:`Ends`,children:[(0,X.jsx)(Q,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:l,children:(0,X.jsx)(He,{className:mt,"aria-label":`${e.name} exit tool`,value:C,disabled:l,onChange:t=>{let n=t.target.value.trim();d({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||f(`autoApproveWhen`,void 0)}})}),C!==``&&(0,X.jsxs)(A,{children:[(0,X.jsx)(O,{label:`Approve on its own`,disabled:l,children:(0,X.jsx)(Xe,{"aria-label":`${e.name}: approve ${C} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:l,onCheckedChange:t=>{d({...e,exitTool:{...e.exitTool,id:C,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||f(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,X.jsx)(`div`,{className:`px-4 py-3`,children:(0,X.jsx)(st,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Ae,disabled:l,json:M(`autoApproveWhen`),onUnfinished:e=>p(`autoApproveWhen`,e),onChange:t=>d({...e,exitTool:{...e.exitTool,id:C,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,X.jsx)(Z,{icon:(0,X.jsx)(re,{}),title:`Allowed moves`,children:N})]}),P,D&&(0,X.jsx)(de,{skill:D,factoryId:a,canEdit:i,onClose:()=>k(void 0)})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,X.jsx)(q,{title:`Allowed moves`,children:N}),P]})}var bt=[`autoStartWhen`,`autoApproveWhen`];function xt(e){return e.conflicts.length>0?e.conflicts.join(` `):e.message}function St({factory:e,boardId:t,phaseKey:n,response:i,skills:s,skillsEditable:c,sidebarHidden:l,onReload:u}){let{board:d,canEdit:f}=i,{draft:p,rawRules:m,locked:h,setDraft:g,setRawRule:_,discard:b}=y(e.id,t,d),[x,te]=(0,Y.useState)(0),re=()=>{b(),te(e=>e+1)},ie=we(e.id),C=ie.data?.find(e=>e.id===t),T=_e(),E=oe(e.id,t),D=le(e.id,t),k=(0,Y.useRef)(!1),j=se(e.id,t,()=>{k.current=!0,b();let n=Te(ie.data??[]).find(e=>e.id!==t);T(n?Ee(e.id,n.id):`/factories/${e.id}`,{replace:!0})}),M=!f||!d.editable,N=n?p.phases.find(e=>e.key===n):void 0,P=N&&`${N.key}:${d.revision??`code`}:${x}`,[F,L]=(0,Y.useState)({page:P,fields:[]});F.page!==P&&L({page:P,fields:[]});let R=F.page===P?F.fields:[],ce=(e,t)=>L(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),ue=!M&&(ee(p,d)||Object.keys(m).length>0||R.length>0),B=p.phases.filter(e=>v(e,m)||e===N&&R.length>0),de=p.name.trim()===``,fe=E.error?.code===`revision_mismatch`,H=ge(({nextLocation:n})=>{if(!ue||k.current)return!1;let r=pe(n.pathname);return r?.factoryId!==e.id||r.boardId!==t||r.skills===!0||r.rules===!0||r.intake===!0}),W=he(e.id,t),G;return G=n&&!N?(0,X.jsx)(r,{titleSlot:(0,X.jsxs)(`span`,{role:`alert`,children:[d.name,` has no such phase.`]}),actionSlot:(0,X.jsx)(U,{size:`sm`,render:(0,X.jsx)(z,{to:W}),children:`Back to general`})}):N?(0,X.jsx)(yt,{phase:N,phases:p.phases,requiredNextPhases:d.codeBehaviour?.[N.key]?.requiredNextPhases??[],skills:s,skillsEditable:c,factoryId:e.id,boardId:t,disabled:M||h,rawRules:{autoStartWhen:m[w(N.key,`autoStartWhen`)],autoApproveWhen:m[w(N.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{_(w(N.key,e),t),ce(e,!1)},onUnfinished:ce,onRemove:M||h||!a(p.phases,N.key,d.codeBehaviour)?void 0:()=>{for(let e of bt)_(w(N.key,e),void 0);g(e=>({...e,phases:o(e.phases,N.key)})),T(W)},onChange:e=>g(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},P):(0,X.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[l&&(0,X.jsxs)(q,{title:`Phases`,children:[(0,X.jsx)(A,{children:(0,X.jsx)(`ul`,{children:p.phases.map(n=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(z,{to:he(e.id,t,n.key),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,X.jsx)(ke,{stage:n.key,kind:De(t,n.kind),decorative:!0}),(0,X.jsx)(I,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:n.name}),(0,X.jsx)(ae,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})},n.key))})}),!M&&(0,X.jsx)(S,{factoryId:e.id,boardId:t,board:d,disabled:h})]}),l&&(0,X.jsx)(q,{title:`Factory`,children:(0,X.jsx)(A,{children:(0,X.jsxs)(z,{to:me(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,X.jsx)(ne,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,X.jsx)(I,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,X.jsx)(ae,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})}),C&&(0,X.jsx)(it,{factoryId:e.id,board:C}),d.source!==`stored`&&!M&&(0,X.jsxs)(q,{title:`Default`,children:[(0,X.jsx)(A,{children:(0,X.jsx)(O,{label:`Reset to default`,description:`Go back to Factory's version of this board.`,children:(0,X.jsxs)(V,{children:[(0,X.jsx)(V.Trigger,{render:(0,X.jsx)(U,{size:`sm`,disabled:D.isPending,children:`Reset`})}),(0,X.jsxs)(V.Content,{children:[(0,X.jsxs)(V.Header,{children:[(0,X.jsxs)(V.Title,{children:[`Reset `,d.name,` to default?`]}),(0,X.jsx)(V.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,X.jsxs)(V.Footer,{children:[(0,X.jsx)(V.Cancel,{children:`Cancel`}),(0,X.jsx)(V.Action,{onClick:()=>D.mutate(d.revision??0),children:`Reset`})]})]})]})})}),D.error&&(0,X.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,X.jsxs)(K.Message,{children:[`The board was not reset. `,xt(D.error)]})})]}),d.source!==`builtin`&&!M&&(0,X.jsxs)(q,{title:`Delete`,children:[(0,X.jsx)(A,{children:(0,X.jsx)(O,{label:`Delete board`,description:`A board that still has cards cannot be deleted.`,children:(0,X.jsxs)(V,{children:[(0,X.jsx)(V.Trigger,{render:(0,X.jsx)(U,{size:`sm`,variant:`destructive`,disabled:j.isPending,children:`Delete`})}),(0,X.jsxs)(V.Content,{children:[(0,X.jsxs)(V.Header,{children:[(0,X.jsxs)(V.Title,{children:[`Delete `,d.name,`?`]}),(0,X.jsx)(V.Description,{children:`The board and its phases are removed from this project.`})]}),(0,X.jsxs)(V.Footer,{children:[(0,X.jsx)(V.Cancel,{children:`Cancel`}),(0,X.jsx)(V.Action,{onClick:()=>j.mutate(d.revision??0),children:`Delete`})]})]})]})})}),j.error&&(0,X.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,X.jsxs)(K.Message,{children:[`The board was not deleted. `,xt(j.error)]})})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-8 pb-4`,children:[d.editable?!f&&(0,X.jsx)(K,{variant:`info`,children:`Only organization admins can change this board.`}):(0,X.jsx)(K,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`}),!N&&d.problems.length>0&&(0,X.jsx)(K,{variant:`warning`,title:`This board has problems`,children:(0,X.jsx)(K.Message,{children:d.problems.join(` `)})}),G,ue&&(0,X.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:[fe&&(0,X.jsx)(K,{variant:`warning`,title:`Someone else changed this board`,action:(0,X.jsx)(K.Button,{onClick:u,children:`Reload`}),children:(0,X.jsx)(K.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),E.error&&!fe&&(0,X.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,X.jsxs)(K.Message,{children:[`The board was not saved. `,xt(E.error)]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(I,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:de?`Name the board to save.`:B.length>0?`Fix ${B.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,X.jsx)(U,{size:`sm`,variant:`ghost`,disabled:E.isPending,onClick:re,children:`Discard`}),(0,X.jsx)(U,{size:`sm`,variant:`primary`,disabled:E.isPending||de||B.length>0,onClick:()=>E.mutate({name:p.name,description:p.description,phases:p.phases,expectedRevision:d.revision??0}),children:E.isPending?`Saving…`:`Save`})]})]}),(0,X.jsx)(V,{open:H.state===`blocked`,onOpenChange:e=>!e&&H.reset?.(),children:(0,X.jsxs)(V.Content,{children:[(0,X.jsxs)(V.Header,{children:[(0,X.jsxs)(V.Title,{children:[`Discard changes to `,d.name,`?`]}),(0,X.jsx)(V.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,X.jsxs)(V.Footer,{children:[(0,X.jsx)(V.Cancel,{children:`Keep editing`}),(0,X.jsx)(U,{variant:`destructive`,size:`md`,onClick:()=>{b(),H.proceed?.()},children:`Discard`})]})]})})]})}function Ct({value:e,label:t,placeholder:n,required:r=!1,multiline:i=!1,readOnly:a,variant:o,tone:s,className:c,onChange:l}){let u=(0,Y.useRef)(e),d=(0,Y.useRef)(!1);if(a)return e?(0,X.jsx)(`span`,{className:c,children:e}):null;let f=i?`textarea`:`input`,p=F({variant:o,tone:s}),m=(0,X.jsx)(f,{"aria-label":t,value:e,placeholder:n,rows:i?1:void 0,...nt,onFocus:()=>{u.current=e},onChange:e=>l(e.currentTarget.value),onBlur:()=>{if(d.current){d.current=!1;return}let t=e.trim();r&&t===``?l(u.current):t!==e&&l(t)},onKeyDown:e=>{e.key===`Escape`&&(d.current=!0,l(u.current)),(e.key===`Enter`&&!e.shiftKey||e.key===`Escape`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.blur())},className:R(p,`placeholder:text-muted-foreground resize-none rounded-md bg-transparent px-1.5`,i?`field-sizing-content -mx-1.5`:`absolute inset-0 w-full min-w-0`,`hover:bg-fill`,L,i&&c)});return i?m:(0,X.jsxs)(`span`,{className:R(`relative -mx-1.5 inline-block max-w-[calc(100%+--spacing(3))] min-w-0`,c),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:R(p,`invisible block overflow-hidden px-1.5 whitespace-pre`),children:e||n||` `}),m]})}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.`}},wt=[`resting`,`working`,`terminal`];function Tt({label:e,meaning:t,children:n}){return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{render:(0,X.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:R(`inline-flex rounded-sm`,L),children:n})}),(0,X.jsx)(H,{side:`bottom`,className:`max-w-72`,children:t})]})}function Et({factoryId:e,boardId:t,phaseKey:n,response:r}){let{board:i,canEdit:a}=r,{draft:o,locked:s,setDraft:c,setRawRule:l}=y(e,t,i),u=!a||!i.editable||s,p=n?o.phases.find(e=>e.key===n):void 0;if(n&&!p)return null;let m=e=>c(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),h=e=>{p&&(l(w(p.key,`autoStartWhen`),void 0),l(w(p.key,`autoApproveWhen`),void 0),c(t=>({...t,phases:t.phases.map(n=>n.key===p.key?d(n,e,t.phases):n)})))},g=p?p.name:o.name,_=(p?p.description:o.description)??``,v=p!==void 0&&!u&&!f(o.phases,p.key,i.codeBehaviour);return(0,X.jsxs)(J,{children:[(0,X.jsxs)(J.Title,{className:`gap-2.5`,children:[p&&(0,X.jsx)(ke,{stage:p.key,kind:De(t,p.kind),decorative:!0}),(0,X.jsx)(Ct,{value:g,label:p?`Phase name`:`Board name`,required:!0,readOnly:u,variant:`heading`,tone:`ink`,onChange:e=>p?m({name:e}):c(t=>({...t,name:e}))})]}),(p||i.revision!=null)&&(0,X.jsx)(J.Meta,{beside:!0,children:p&&v?(0,X.jsxs)(ye,{value:p.kind,onValueChange:e=>{let t=wt.find(t=>t===e);t&&h(t)},children:[(0,X.jsx)(be,{size:`sm`,"aria-label":`Phase kind`,children:$[p.kind].label}),(0,X.jsx)(Se,{children:wt.map(e=>(0,X.jsx)(Ce,{value:e,children:$[e].label},e))})]}):p?(0,X.jsx)(Tt,{label:$[p.kind].label,meaning:$[p.kind].meaning,children:(0,X.jsx)(E,{children:$[p.kind].label})}):(0,X.jsxs)(Tt,{label:`Revision ${i.revision}`,meaning:`Goes up each time the board is saved. If someone else saves first, you're asked to reload before saving.`,children:[`Revision `,i.revision]})}),(_||!u)&&(0,X.jsx)(J.Description,{children:(0,X.jsx)(Ct,{value:_,label:p?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:u,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>p?m({description:e||null}):c(t=>({...t,description:e||null}))})})]})}var Dt=`mx-auto w-full max-w-2xl`;function Ot(){let e=b(),a=C(),o=a?.boardId??``,s=a?.phaseKey,{isMobile:c,desktopState:u}=T(),d=c||u===`collapsed`,f=ce(e.id,o),p=B(e.id),m=f.data?.board,h=l(e.id,o,m),g=s?h?.phases.find(e=>e.key===s):void 0,_=he(e.id,o),v=x({breadcrumbs:d&&m?(0,X.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,X.jsx)(t,{as:z,to:Ee(e.id,o),children:h?.name||m.name}),s?(0,X.jsx)(t,{as:z,to:_,children:`Configure`}):(0,X.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),g&&(0,X.jsx)(t,{as:`span`,isCurrent:!0,children:g.name})]}):void 0}),y=f.isSuccess&&(!s||g)?(0,X.jsx)(`div`,{className:R(Dt,`pb-8`),children:(0,X.jsx)(Et,{factoryId:e.id,boardId:o,phaseKey:s,response:f.data},`${o}:${f.data.board.revision??`code`}`)}):void 0;return(0,X.jsx)(i,{variant:`narrow`,header:y,...v,children:(0,X.jsx)(`div`,{className:Dt,children:f.isPending?(0,X.jsx)(A,{children:(0,X.jsx)(j,{label:`Loading board`,rows:3})}):f.isError&&f.error instanceof ue&&f.error.code===`board_not_found`?(0,X.jsx)(r,{variant:`fill`,titleSlot:(0,X.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):f.isError?(0,X.jsx)(rt,{title:`Couldn’t load this board`,error:f.error,onRetry:()=>void f.refetch(),retrying:f.isFetching}):(0,X.jsx)(St,{factory:e,boardId:o,phaseKey:s,response:f.data,skills:p.data?.skills,skillsEditable:p.data?.canEdit??!1,sidebarHidden:d,onReload:()=>void f.refetch()},`${o}:${f.data.board.revision??`code`}`)})})}export{Ot as BoardConfigPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-Caa0ta4Z.js";import{t as r}from"./EmptyState-juw2jci2-vYAzd7Mx.js";import{$n as i,At as a,Bt as o,Dt as s,En as c,Et as l,Gt as u,Ht as d,It as f,Jt as p,Kt as m,Lt as h,Nt as g,Ot as _,Rt as v,Tt as y,Un as b,Zn as x,h as S,jt as ee,kt as te,m as ne,rn as re,u as ie,wt as C,zt as w}from"./index-CqME59pn.js";import{a as T,k as E}from"./Sidebar.es-DGzeKZbU.js";import{d as D,f as O,r as k,t as A,u as j}from"./settings-DmdIP3xB-Ivg55Tc-.js";import{D as M,O as N,d as P,i as F,n as I,o as L,t as ae,w as R}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{t as z}from"./lib-C4aHsZXk.js";import{c as oe,o as se,r as ce,s as le,t as ue}from"./useBoardEditor-D_XHmLsE.js";import{n as B,t as de}from"./FactorySkillEditorDialog-33yz9UNC.js";import{a as fe,c as pe,o as me,r as he}from"./boardConfigPaths-CyCwKxS5.js";import{t as V}from"./AlertDialog.es-egsOmf9n.js";import{Xn as ge,ca as H,ki as U,or as _e,sa as W,ua as G}from"./useFactories-B-Om6aVq.js";import{Z as ve,a as ye,c as be,i as xe,o as Se,r as K,s as Ce}from"./request-CPtLhnSV.js";import{n as we}from"./useBoardCatalog-Bwbdd2Vb.js";import{n as Te,t as Ee}from"./boardCatalog-y-s19dQU.js";import{a as De,d as Oe,t as ke}from"./BoardIcons-RydpbVA4.js";import{t as q}from"./SettingsSubsection-BTekyheK.js";import{o as Ae,u as je}from"./board-events-BVnaMaTS.js";import{S as Me,o as Ne,t as Pe,v as Fe,y as Ie}from"./conditionFields-CBXR0ZAG.js";import{t as Le}from"./CodeEditor-AaW7HgY9-BnB7l8h1.js";import{a as Re,n as ze,r as Be,t as Ve}from"./Field.es-NxMTQ8PW.js";import{t as He}from"./input-DqReKX0A-2mZo-XW9.js";import{a as Ue,n as We}from"./input-group-CXvse9n7-C2R5K-Tq.js";import{a as Ge,i as Ke,n as qe,r as Je,t as Ye}from"./InputNumber.es-BzEgsntE.js";import{n as Xe}from"./IconPlugin1.es-CZs2N-e2.js";import{r as Ze}from"./overlays-eEEsk-kD.js";import{t as Qe}from"./ConditionRows-DUjWJRNa.js";import{t as $e}from"./IconLock.es-0eb6hipg.js";import{n as et}from"./SlackIcon.es-4iabNI5s.js";import{a as tt}from"./IconClipboard2.es-DIRDjMMg.js";import{t as J}from"./page-header-Maytcmgh-Dm4StKTd.js";import{r as nt}from"./Input-A03ee_nt.js";import{t as rt}from"./LoadErrorState-dfQWbyzw.js";var Y=e(N(),1),X=M();function it({factoryId:e,board:t}){let n=je(e,t.id),r=Me(e),{count:i}=Fe(n.data?.intakeRoutes??[]),a=(r.data?.boards??[]).findIndex(e=>e.boardKey===t.id),o=n.isError||r.isError;return(0,X.jsx)(q,{title:`New items`,action:(0,X.jsx)(U,{size:`sm`,variant:`ghost`,render:(0,X.jsx)(z,{to:fe(e,t.id)}),children:`Edit rules`}),children:(0,X.jsx)(I,{as:`p`,variant:`caption`,tone:`muted`,role:o?`alert`:`status`,className:`flex flex-wrap gap-x-3 gap-y-1`,children:n.isPending||r.isPending?`Loading rules…`:o?`Rules didn’t load.`:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:at(i)}),(0,X.jsx)(`span`,{children:a===-1?`Not in the intake order`:`Checked ${Ie(a+1)}`})]})})})}function at(e){return e===0?`No rules for new items`:e===1?`1 rule for new items`:`${e} rules for new items`}var ot=`Finish or remove unfinished conditions to save.`;function st({label:e,description:t,rule:n,disabled:r,facts:i=Pe,options:a,schema:o,json:s,onChange:c,onUnfinished:l}){let[d,f]=(0,Y.useState)(void 0),h=s?s.text:d,g=s?s.onChange:f,_=(0,Y.useId)(),v=h===void 0?p(o,n):u(o,h),y=e=>{g(e);let t=m(o,e);`problem`in t?c(n??null,t.problem):c(t.rule,void 0)};return(0,X.jsxs)(Ve,{invalid:v!==void 0,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(Re,{htmlFor:_,children:e}),(0,X.jsx)(U,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{h===void 0?g(n?JSON.stringify(n,null,2):``):(g(void 0),c(n??null,p(o,n)))},children:h===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,X.jsx)(ze,{children:t}),h===void 0?r?(0,X.jsx)(I,{id:_,as:`p`,variant:`caption`,tone:`muted`,children:Ne(n,a)}):(0,X.jsx)(`div`,{id:_,children:(0,X.jsx)(Qe,{label:e,rule:n,facts:i,options:a,onChange:(e,t)=>{l?.(t),t?c(n??null,ot):c(e,p(o,e))}})}):(0,X.jsx)(Ze,{id:_,"aria-label":`${e} JSON`,value:h,disabled:r,rows:6,onChange:e=>y(e.target.value)}),v&&(0,X.jsx)(Be,{children:v})]})}var ct=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function lt({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,X.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,X.jsx)(ke,{stage:t.key,kind:De(i,t.kind),decorative:!0});if(t.key===e.key)return(0,X.jsxs)(`li`,{className:R(ct,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,X.jsx)(ut,{children:t.name}),(0,X.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,X.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:R(ct,`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`,L),children:[(0,X.jsx)(`span`,{className:R(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,X.jsx)(ut,{children:t.name}),(0,X.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,X.jsx)($e,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,X.jsx)(ve,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,X.jsx)(et,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,X.jsx)(`li`,{className:`min-w-0`,children:l?(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{render:d}),(0,X.jsx)(H,{children:`Factory's code makes this move`})]}):d},t.key)})})}function ut({children:e}){return(0,X.jsx)(I,{as:`span`,variant:`label`,className:`truncate`,children:e})}function dt({label:e,children:t}){return(0,X.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Z({icon:e,title:t,description:n,children:r}){let i=(0,Y.useId)();return(0,X.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,X.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,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,X.jsx)(I,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,X.jsx)(I,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var ft=P(`IconFlag2`,()=>(0,X.jsx)(`path`,{d:`M5 15.0002V4.61942C5 4.24002 5.21411 3.88671 5.56677 3.74679C9.85713 2.0446 13.3106 5.53259 17.4846 4.5523C18.2075 4.38251 19 4.87246 19 5.61508V14.3809C19 14.7603 18.7859 15.1137 18.4332 15.2536C13.6349 17.1573 9.88335 12.5691 5 15.0002ZM5 15.0002V21.0002`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})),pt=`__none__`,mt=`sm:max-w-xs`,ht=(e,t)=>e>=t-200?` ${e}/${t}`:``,gt=`work`;function _t({skill:e,missing:t}){return(0,X.jsxs)(X.Fragment,{children:[t&&(0,X.jsx)(E,{variant:`destructive`,children:`Not found`}),e?.error&&(0,X.jsx)(E,{variant:`destructive`,children:`Failed to load`}),e?.builtIn&&e.origin!==void 0&&e.origin!==`bundled`&&(0,X.jsx)(E,{children:`Overridden by app`}),e?.edited&&(0,X.jsx)(E,{children:`Edited`})]})}function Q({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,X.jsxs)(k,{children:[(0,X.jsxs)(Ve,{invalid:!!n,disabled:r,children:[(0,X.jsx)(D,{children:e}),(0,X.jsx)(ze,{children:t}),i,n&&(0,X.jsx)(Be,{children:n})]}),a]})}function vt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,X.jsx)(A,{children:(0,X.jsx)(`div`,{className:`px-4 py-3`,children:(0,X.jsx)(Le,{"aria-label":e,value:t,placeholder:n,editable:!r,onChange:i,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1})})})}function yt({phase:e,phases:t,requiredNextPhases:n,skills:r,skillsEditable:i,factoryId:a,boardId:o,disabled:l,rawRules:u,onChange:d,onRawRule:f,onUnfinished:p,onRemove:m}){let v=e.kind===`working`,y=h(e,t),b=e.runner?.instructions??``,x=e.runner?.goal,S=x?.objective??``,ee=e.tools??[],C=e.exitTool?.id??``,w=e.runner?.skill,T=w?r?.find(e=>e.name===w):void 0,E=w!==void 0&&r!==void 0&&T===void 0,[D,k]=(0,Y.useState)(),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=>f(e,t)}),N=(0,X.jsx)(lt,{phase:e,phases:t,next:y,required:new Set(n),boardId:o,disabled:l,onChange:t=>d({...e,nextPhases:t})}),P=m&&(0,X.jsx)(`div`,{children:(0,X.jsxs)(U,{variant:`ghost`,icon:(0,X.jsx)(tt,{}),onClick:m,children:[`Remove `,e.name]})});return v?(0,X.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,X.jsxs)(dt,{label:`How ${e.name} runs`,children:[(0,X.jsx)(Z,{icon:(0,X.jsx)(Oe,{}),title:`Starts`,children:(0,X.jsxs)(A,{children:[(0,X.jsx)(O,{label:`Start on its own`,disabled:l,children:(0,X.jsx)(Xe,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:l,onCheckedChange:t=>{d({...e,autoStart:t,autoStartWhen:t?e.autoStartWhen:null}),t||f(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,X.jsx)(`div`,{className:`px-4 py-3`,children:(0,X.jsx)(st,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Ae,disabled:l,json:M(`autoStartWhen`),onUnfinished:e=>p(`autoStartWhen`,e),onChange:t=>d({...e,autoStartWhen:t})})})]})}),(0,X.jsxs)(Z,{icon:(0,X.jsx)(ie,{}),title:`Agent runs`,children:[(0,X.jsx)(Q,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${ht(b.length,s)}`,error:b.length>1e3?`Too long to save.`:void 0,disabled:l,children:(0,X.jsx)(vt,{label:`${e.name} instructions`,value:b,placeholder:`Tell the agent what to do, in Markdown`,disabled:l,onChange:e=>j({instructions:e})})}),(0,X.jsx)(Q,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${ht(S.length,_)}`,error:S.length>2e3?`Too long to save.`:void 0,disabled:l,after:x&&(0,X.jsxs)(Ve,{invalid:!g(x.maxRuns),disabled:l,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(Re,{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,X.jsx)(Ye,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:x.maxRuns??null,disabled:l,onValueChange:e=>{let{maxRuns:t,...n}=x;j({goal:e===null?n:{...n,maxRuns:e}})},children:(0,X.jsxs)(Je,{size:`sm`,children:[(0,X.jsx)(Ge,{placeholder:`Default`}),(0,X.jsxs)(We,{align:`inline-end`,variant:`flush`,children:[(0,X.jsx)(Ue,{className:`mr-1`,children:`runs`}),(0,X.jsx)(qe,{}),(0,X.jsx)(Ke,{})]})]})})]}),!g(x.maxRuns)&&(0,X.jsxs)(Be,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,X.jsx)(vt,{label:`${e.name} goal`,value:S,placeholder:`Describe what done looks like`,disabled:l,onChange:e=>j({goal:e.trim()?{...x,objective:e}:void 0})})}),(0,X.jsx)(Q,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:l,children:(0,X.jsx)(He,{className:mt,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:gt,disabled:l,onChange:e=>j({context:e.target.value})})}),(0,X.jsx)(q,{title:`Skill`,children:(0,X.jsx)(A,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsxs)(ye,{value:w??pt,disabled:l,onValueChange:e=>j({skill:e===pt?void 0:String(e)}),children:[(0,X.jsx)(be,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(ne,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:w??`No skill`})]})}),(0,X.jsxs)(Se,{children:[(0,X.jsx)(Ce,{value:pt,children:`None`}),(r??[]).map(e=>(0,X.jsx)(Ce,{value:e.name,children:e.name},e.name))]})]}),(0,X.jsx)(_t,{skill:T,missing:E}),T&&(0,X.jsx)(U,{size:`sm`,variant:`ghost`,icon:i?(0,X.jsx)(c,{}):(0,X.jsx)(xe,{}),"aria-label":`${i?`Edit`:`View`} ${T.name}`,className:`ml-auto`,onClick:()=>k(T),children:i?`Edit`:`View`})]}),T?.error?(0,X.jsxs)(I,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,T.error]}):E?(0,X.jsxs)(I,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,w,` skill, so cards entering `,e.name,` fail to start.`]}):T?.description&&(0,X.jsx)(I,{as:`p`,variant:`caption`,tone:`muted`,children:T.description})]})})}),(0,X.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,X.jsx)(A,{children:te.map(t=>(0,X.jsx)(O,{label:t.label,disabled:l,children:(0,X.jsx)(Xe,{"aria-label":`${e.name}: ${t.label}`,checked:ee.includes(t.id),disabled:l,onCheckedChange:n=>{let r=te.map(({id:e})=>e).filter(e=>e===t.id?n:ee.includes(e));d({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,X.jsxs)(Z,{icon:(0,X.jsx)(ft,{}),title:`Ends`,children:[(0,X.jsx)(Q,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:l,children:(0,X.jsx)(He,{className:mt,"aria-label":`${e.name} exit tool`,value:C,disabled:l,onChange:t=>{let n=t.target.value.trim();d({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||f(`autoApproveWhen`,void 0)}})}),C!==``&&(0,X.jsxs)(A,{children:[(0,X.jsx)(O,{label:`Approve on its own`,disabled:l,children:(0,X.jsx)(Xe,{"aria-label":`${e.name}: approve ${C} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:l,onCheckedChange:t=>{d({...e,exitTool:{...e.exitTool,id:C,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||f(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,X.jsx)(`div`,{className:`px-4 py-3`,children:(0,X.jsx)(st,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Ae,disabled:l,json:M(`autoApproveWhen`),onUnfinished:e=>p(`autoApproveWhen`,e),onChange:t=>d({...e,exitTool:{...e.exitTool,id:C,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,X.jsx)(Z,{icon:(0,X.jsx)(re,{}),title:`Allowed moves`,children:N})]}),P,D&&(0,X.jsx)(de,{skill:D,factoryId:a,canEdit:i,onClose:()=>k(void 0)})]}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,X.jsx)(q,{title:`Allowed moves`,children:N}),P]})}var bt=[`autoStartWhen`,`autoApproveWhen`];function xt(e){return e.conflicts.length>0?e.conflicts.join(` `):e.message}function St({factory:e,boardId:t,phaseKey:n,response:i,skills:s,skillsEditable:c,sidebarHidden:l,onReload:u}){let{board:d,canEdit:f}=i,{draft:p,rawRules:m,locked:h,setDraft:g,setRawRule:_,discard:b}=y(e.id,t,d),[x,te]=(0,Y.useState)(0),re=()=>{b(),te(e=>e+1)},ie=we(e.id),C=ie.data?.find(e=>e.id===t),T=_e(),E=oe(e.id,t),D=le(e.id,t),k=(0,Y.useRef)(!1),j=se(e.id,t,()=>{k.current=!0,b();let n=Te(ie.data??[]).find(e=>e.id!==t);T(n?Ee(e.id,n.id):`/factories/${e.id}`,{replace:!0})}),M=!f||!d.editable,N=n?p.phases.find(e=>e.key===n):void 0,P=N&&`${N.key}:${d.revision??`code`}:${x}`,[F,L]=(0,Y.useState)({page:P,fields:[]});F.page!==P&&L({page:P,fields:[]});let R=F.page===P?F.fields:[],ce=(e,t)=>L(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),ue=!M&&(ee(p,d)||Object.keys(m).length>0||R.length>0),B=p.phases.filter(e=>v(e,m)||e===N&&R.length>0),de=p.name.trim()===``,fe=E.error?.code===`revision_mismatch`,H=ge(({nextLocation:n})=>{if(!ue||k.current)return!1;let r=pe(n.pathname);return r?.factoryId!==e.id||r.boardId!==t||r.skills===!0||r.rules===!0||r.intake===!0}),W=he(e.id,t),G;return G=n&&!N?(0,X.jsx)(r,{titleSlot:(0,X.jsxs)(`span`,{role:`alert`,children:[d.name,` has no such phase.`]}),actionSlot:(0,X.jsx)(U,{size:`sm`,render:(0,X.jsx)(z,{to:W}),children:`Back to general`})}):N?(0,X.jsx)(yt,{phase:N,phases:p.phases,requiredNextPhases:d.codeBehaviour?.[N.key]?.requiredNextPhases??[],skills:s,skillsEditable:c,factoryId:e.id,boardId:t,disabled:M||h,rawRules:{autoStartWhen:m[w(N.key,`autoStartWhen`)],autoApproveWhen:m[w(N.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{_(w(N.key,e),t),ce(e,!1)},onUnfinished:ce,onRemove:M||h||!a(p.phases,N.key,d.codeBehaviour)?void 0:()=>{for(let e of bt)_(w(N.key,e),void 0);g(e=>({...e,phases:o(e.phases,N.key)})),T(W)},onChange:e=>g(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},P):(0,X.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[l&&(0,X.jsxs)(q,{title:`Phases`,children:[(0,X.jsx)(A,{children:(0,X.jsx)(`ul`,{children:p.phases.map(n=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(z,{to:he(e.id,t,n.key),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,X.jsx)(ke,{stage:n.key,kind:De(t,n.kind),decorative:!0}),(0,X.jsx)(I,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:n.name}),(0,X.jsx)(ae,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})},n.key))})}),!M&&(0,X.jsx)(S,{factoryId:e.id,boardId:t,board:d,disabled:h})]}),l&&(0,X.jsx)(q,{title:`Factory`,children:(0,X.jsx)(A,{children:(0,X.jsxs)(z,{to:me(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,X.jsx)(ne,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,X.jsx)(I,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,X.jsx)(ae,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})}),C&&(0,X.jsx)(it,{factoryId:e.id,board:C}),d.source!==`stored`&&!M&&(0,X.jsxs)(q,{title:`Default`,children:[(0,X.jsx)(A,{children:(0,X.jsx)(O,{label:`Reset to default`,description:`Go back to Factory's version of this board.`,children:(0,X.jsxs)(V,{children:[(0,X.jsx)(V.Trigger,{render:(0,X.jsx)(U,{size:`sm`,disabled:D.isPending,children:`Reset`})}),(0,X.jsxs)(V.Content,{children:[(0,X.jsxs)(V.Header,{children:[(0,X.jsxs)(V.Title,{children:[`Reset `,d.name,` to default?`]}),(0,X.jsx)(V.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,X.jsxs)(V.Footer,{children:[(0,X.jsx)(V.Cancel,{children:`Cancel`}),(0,X.jsx)(V.Action,{onClick:()=>D.mutate(d.revision??0),children:`Reset`})]})]})]})})}),D.error&&(0,X.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,X.jsxs)(K.Message,{children:[`The board was not reset. `,xt(D.error)]})})]}),d.source!==`builtin`&&!M&&(0,X.jsxs)(q,{title:`Delete`,children:[(0,X.jsx)(A,{children:(0,X.jsx)(O,{label:`Delete board`,description:`A board that still has cards cannot be deleted.`,children:(0,X.jsxs)(V,{children:[(0,X.jsx)(V.Trigger,{render:(0,X.jsx)(U,{size:`sm`,variant:`destructive`,disabled:j.isPending,children:`Delete`})}),(0,X.jsxs)(V.Content,{children:[(0,X.jsxs)(V.Header,{children:[(0,X.jsxs)(V.Title,{children:[`Delete `,d.name,`?`]}),(0,X.jsx)(V.Description,{children:`The board and its phases are removed from this project.`})]}),(0,X.jsxs)(V.Footer,{children:[(0,X.jsx)(V.Cancel,{children:`Cancel`}),(0,X.jsx)(V.Action,{onClick:()=>j.mutate(d.revision??0),children:`Delete`})]})]})]})})}),j.error&&(0,X.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,X.jsxs)(K.Message,{children:[`The board was not deleted. `,xt(j.error)]})})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-8 pb-4`,children:[d.editable?!f&&(0,X.jsx)(K,{variant:`info`,children:`Only organization admins can change this board.`}):(0,X.jsx)(K,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`}),!N&&d.problems.length>0&&(0,X.jsx)(K,{variant:`warning`,title:`This board has problems`,children:(0,X.jsx)(K.Message,{children:d.problems.join(` `)})}),G,ue&&(0,X.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:[fe&&(0,X.jsx)(K,{variant:`warning`,title:`Someone else changed this board`,action:(0,X.jsx)(K.Button,{onClick:u,children:`Reload`}),children:(0,X.jsx)(K.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),E.error&&!fe&&(0,X.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,X.jsxs)(K.Message,{children:[`The board was not saved. `,xt(E.error)]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(I,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:de?`Name the board to save.`:B.length>0?`Fix ${B.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,X.jsx)(U,{size:`sm`,variant:`ghost`,disabled:E.isPending,onClick:re,children:`Discard`}),(0,X.jsx)(U,{size:`sm`,variant:`primary`,disabled:E.isPending||de||B.length>0,onClick:()=>E.mutate({name:p.name,description:p.description,phases:p.phases,expectedRevision:d.revision??0}),children:E.isPending?`Saving…`:`Save`})]})]}),(0,X.jsx)(V,{open:H.state===`blocked`,onOpenChange:e=>!e&&H.reset?.(),children:(0,X.jsxs)(V.Content,{children:[(0,X.jsxs)(V.Header,{children:[(0,X.jsxs)(V.Title,{children:[`Discard changes to `,d.name,`?`]}),(0,X.jsx)(V.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,X.jsxs)(V.Footer,{children:[(0,X.jsx)(V.Cancel,{children:`Keep editing`}),(0,X.jsx)(U,{variant:`destructive`,size:`md`,onClick:()=>{b(),H.proceed?.()},children:`Discard`})]})]})})]})}function Ct({value:e,label:t,placeholder:n,required:r=!1,multiline:i=!1,readOnly:a,variant:o,tone:s,className:c,onChange:l}){let u=(0,Y.useRef)(e),d=(0,Y.useRef)(!1);if(a)return e?(0,X.jsx)(`span`,{className:c,children:e}):null;let f=i?`textarea`:`input`,p=F({variant:o,tone:s}),m=(0,X.jsx)(f,{"aria-label":t,value:e,placeholder:n,rows:i?1:void 0,...nt,onFocus:()=>{u.current=e},onChange:e=>l(e.currentTarget.value),onBlur:()=>{if(d.current){d.current=!1;return}let t=e.trim();r&&t===``?l(u.current):t!==e&&l(t)},onKeyDown:e=>{e.key===`Escape`&&(d.current=!0,l(u.current)),(e.key===`Enter`&&!e.shiftKey||e.key===`Escape`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.blur())},className:R(p,`placeholder:text-muted-foreground resize-none rounded-md bg-transparent px-1.5`,i?`field-sizing-content -mx-1.5`:`absolute inset-0 w-full min-w-0`,`hover:bg-fill`,L,i&&c)});return i?m:(0,X.jsxs)(`span`,{className:R(`relative -mx-1.5 inline-block max-w-[calc(100%+--spacing(3))] min-w-0`,c),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:R(p,`invisible block overflow-hidden px-1.5 whitespace-pre`),children:e||n||` `}),m]})}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.`}},wt=[`resting`,`working`,`terminal`];function Tt({label:e,meaning:t,children:n}){return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{render:(0,X.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:R(`inline-flex rounded-sm`,L),children:n})}),(0,X.jsx)(H,{side:`bottom`,className:`max-w-72`,children:t})]})}function Et({factoryId:e,boardId:t,phaseKey:n,response:r}){let{board:i,canEdit:a}=r,{draft:o,locked:s,setDraft:c,setRawRule:l}=y(e,t,i),u=!a||!i.editable||s,p=n?o.phases.find(e=>e.key===n):void 0;if(n&&!p)return null;let m=e=>c(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),h=e=>{p&&(l(w(p.key,`autoStartWhen`),void 0),l(w(p.key,`autoApproveWhen`),void 0),c(t=>({...t,phases:t.phases.map(n=>n.key===p.key?d(n,e,t.phases):n)})))},g=p?p.name:o.name,_=(p?p.description:o.description)??``,v=p!==void 0&&!u&&!f(o.phases,p.key,i.codeBehaviour);return(0,X.jsxs)(J,{children:[(0,X.jsxs)(J.Title,{className:`gap-2.5`,children:[p&&(0,X.jsx)(ke,{stage:p.key,kind:De(t,p.kind),decorative:!0}),(0,X.jsx)(Ct,{value:g,label:p?`Phase name`:`Board name`,required:!0,readOnly:u,variant:`heading`,tone:`ink`,onChange:e=>p?m({name:e}):c(t=>({...t,name:e}))})]}),(p||i.revision!=null)&&(0,X.jsx)(J.Meta,{beside:!0,children:p&&v?(0,X.jsxs)(ye,{value:p.kind,onValueChange:e=>{let t=wt.find(t=>t===e);t&&h(t)},children:[(0,X.jsx)(be,{size:`sm`,"aria-label":`Phase kind`,children:$[p.kind].label}),(0,X.jsx)(Se,{children:wt.map(e=>(0,X.jsx)(Ce,{value:e,children:$[e].label},e))})]}):p?(0,X.jsx)(Tt,{label:$[p.kind].label,meaning:$[p.kind].meaning,children:(0,X.jsx)(E,{children:$[p.kind].label})}):(0,X.jsxs)(Tt,{label:`Revision ${i.revision}`,meaning:`Goes up each time the board is saved. If someone else saves first, you're asked to reload before saving.`,children:[`Revision `,i.revision]})}),(_||!u)&&(0,X.jsx)(J.Description,{children:(0,X.jsx)(Ct,{value:_,label:p?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:u,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>p?m({description:e||null}):c(t=>({...t,description:e||null}))})})]})}var Dt=`mx-auto w-full max-w-2xl`;function Ot(){let e=b(),a=C(),o=a?.boardId??``,s=a?.phaseKey,{isMobile:c,desktopState:u}=T(),d=c||u===`collapsed`,f=ce(e.id,o),p=B(e.id),m=f.data?.board,h=l(e.id,o,m),g=s?h?.phases.find(e=>e.key===s):void 0,_=he(e.id,o),v=x({breadcrumbs:d&&m?(0,X.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,X.jsx)(t,{as:z,to:Ee(e.id,o),children:h?.name||m.name}),s?(0,X.jsx)(t,{as:z,to:_,children:`Configure`}):(0,X.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),g&&(0,X.jsx)(t,{as:`span`,isCurrent:!0,children:g.name})]}):void 0}),y=f.isSuccess&&(!s||g)?(0,X.jsx)(`div`,{className:R(Dt,`pb-8`),children:(0,X.jsx)(Et,{factoryId:e.id,boardId:o,phaseKey:s,response:f.data},`${o}:${f.data.board.revision??`code`}`)}):void 0;return(0,X.jsx)(i,{variant:`narrow`,header:y,...v,children:(0,X.jsx)(`div`,{className:Dt,children:f.isPending?(0,X.jsx)(A,{children:(0,X.jsx)(j,{label:`Loading board`,rows:3})}):f.isError&&f.error instanceof ue&&f.error.code===`board_not_found`?(0,X.jsx)(r,{variant:`fill`,titleSlot:(0,X.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):f.isError?(0,X.jsx)(rt,{title:`Couldn’t load this board`,error:f.error,onRetry:()=>void f.refetch(),retrying:f.isFetching}):(0,X.jsx)(St,{factory:e,boardId:o,phaseKey:s,response:f.data,skills:p.data?.skills,skillsEditable:p.data?.canEdit??!1,sidebarHidden:d,onReload:()=>void f.refetch()},`${o}:${f.data.board.revision??`code`}`)})})}export{Ot as BoardConfigPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-Caa0ta4Z.js";import{t as r}from"./page-header-Maytcmgh-Dm4StKTd.js";import{$n as i,Un as a,Zn as o,wt as s}from"./index-CqME59pn.js";import{a as c,k as l}from"./Sidebar.es-DGzeKZbU.js";import{D as u,O as d,n as f,w as p}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{t as m}from"./lib-C4aHsZXk.js";import{r as h}from"./useBoardEditor-D_XHmLsE.js";import{a as g,n as _,r as v,t as y}from"./boardConfigPaths-CyCwKxS5.js";import{ki as b}from"./useFactories-B-Om6aVq.js";import{Q as x,r as S}from"./request-CPtLhnSV.js";import{a as C,n as w,o as T,t as E,u as D}from"./settings-DmdIP3xB-Ivg55Tc-.js";import{a as O,i as k,n as A,r as j,t as M}from"./IntakeTesterDialog-CDbp1koV.js";import{C as N,S as P,T as F,v as I,w as L}from"./conditionFields-CBXR0ZAG.js";import{p as R}from"./board-events-BVnaMaTS.js";import{t as z}from"./SettingsSubsection-BTekyheK.js";import{n as B}from"./useBoardCatalog-Bwbdd2Vb.js";import{s as V}from"./settingsSections-Cijt0lNE.js";var H=e(d(),1),U=u(),W=p(`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 G({factoryId:e}){let t=P(e);return(0,U.jsx)(z,{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; no board taking it leaves it Not routed.`,children:t.isPending?(0,U.jsx)(E,{children:(0,U.jsx)(D,{label:`Loading intake order`,variant:`item`,rows:3})}):t.isError?(0,U.jsx)(S,{variant:`destructive`,children:`The intake order didn’t load.`}):(0,U.jsx)(K,{factoryId:e,order:t.data},e)})}function K({factoryId:e,order:t}){let n=R(e),r=F(e),[i,a]=(0,H.useState)(),o=t.boards.map(e=>e.boardKey),s=i&&Y(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]),d=(e,t)=>{let n=[...c],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),a(n))},h=A({min:0,max:c.length-1,onDrop:d}),_=()=>r.mutate(c,{onSuccess:()=>{a(void 0),x.success(`Intake order saved.`)},onError:e=>x.error(e.message)}),v=t.canEdit&&c.length>1,y=v&&!r.isPending;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(J,{order:t,changed:u}),n.isError&&(0,U.jsx)(S,{variant:`warning`,children:`Rule counts didn’t load.`}),(0,U.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,U.jsx)(C,{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:p(W,i&&`z-10 opacity-90`),media:(0,U.jsx)(T,{children:(0,U.jsx)(f,{as:`span`,variant:`caption`,className:`tabular-nums`,children:r+1})}),title:a,description:(0,U.jsx)(q,{routes:n.data?.intakeRoutes,boardKey:t}),children:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[v&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:`text-icon3 hidden cursor-grab touch-none pointer-fine:inline-flex`,children:(0,U.jsx)(j,{className:`size-icon-md`})}),(0,U.jsx)(b,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!y||r===0,onClick:()=>d(r,r-1),children:(0,U.jsx)(k,{})}),(0,U.jsx)(b,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!y||r===c.length-1,onClick:()=>d(r,r+1),children:(0,U.jsx)(O,{})})]}),(0,U.jsx)(b,{size:`sm`,variant:`ghost`,render:(0,U.jsx)(m,{to:g(e,t)}),children:`Edit rules`})]})},t)})}),t.canEdit&&u&&(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(b,{size:`sm`,variant:`ghost`,onClick:()=>a(void 0),disabled:r.isPending,children:`Discard`}),(0,U.jsx)(b,{size:`sm`,variant:`primary`,onClick:_,disabled:r.isPending,children:`Save order`})]})]})}function q({routes:e,boardKey:t}){if(!e)return null;let{count:n,catchesAll:r}=I(e.filter(e=>e.target.boardKey===t));return(0,U.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{children:n===0?`No rules for new items`:n===1?`1 rule`:`${n} rules`}),r&&(0,U.jsx)(l,{children:`Ends in catch-all`})]})}function J({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,U.jsx)(S,{variant:`info`,children:(0,U.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,U.jsx)(`span`,{children:e},e))})})}function Y(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function X({factoryId:e}){let t=N(e),n=L(e),r=new Map((B(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=>x.success(`Filing “${e.title}” on ${r.get(t.boardKey)??t.boardKey}.`),onError:e=>x.error(e.message)});return(0,U.jsx)(z,{id:_,scope:`factory`,title:`Not routed`,description:`New issues and pull requests no board's rules took. Change a board's rules, then route the item again.`,children:t.isPending?(0,U.jsx)(E,{children:(0,U.jsx)(D,{label:`Loading items not routed`,variant:`item`,rows:2})}):t.isError?(0,U.jsx)(S,{variant:`destructive`,children:`Items not routed didn’t load.`}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.length===0?(0,U.jsx)(E,{children:(0,U.jsx)(w,{children:`Every new item found a board.`})}):(0,U.jsx)(E,{role:`list`,"aria-label":`Not routed`,children:a.map(t=>(0,U.jsxs)(C,{role:`listitem`,title:t.url?(0,U.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:t.title}):t.title,description:(0,U.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[t.sourceKey&&(0,U.jsx)(`span`,{children:t.sourceKey}),(0,U.jsx)(`span`,{children:t.reason??`No board’s rules match it.`}),(0,U.jsx)(`time`,{dateTime:t.decidedAt,children:Z(t.decidedAt)})]}),children:[(0,U.jsx)(M,{factoryProjectId:e,itemId:t.id,label:`Why?`}),o&&(0,U.jsx)(b,{size:`sm`,variant:`ghost`,onClick:()=>s(t),disabled:n.isPending&&n.variables===t.id,children:`Route again`})]},t.id))}),t.hasNextPage&&(0,U.jsx)(`div`,{className:`flex justify-center`,children:(0,U.jsx)(b,{size:`sm`,variant:`ghost`,onClick:()=>void t.fetchNextPage(),disabled:t.isFetchingNextPage,children:t.isFetchingNextPage?`Loading…`:`Load more`})})]})})}function Z(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}var Q=`mx-auto w-full max-w-2xl`;function $(){let e=a(),l=s()?.boardId??``,{isMobile:u,desktopState:d}=c(),f=u||d===`collapsed`,g=h(e.id,l).data?.board,_=o({breadcrumbs:f&&g?(0,U.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,U.jsx)(t,{as:m,to:v(e.id,l),children:g.name}),(0,U.jsx)(t,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,U.jsx)(i,{variant:`narrow`,header:(0,U.jsx)(`div`,{className:p(Q,`pb-8`),children:(0,U.jsxs)(r,{children:[(0,U.jsx)(r.Title,{children:`Routing`}),(0,U.jsxs)(r.Description,{children:[`The order boards are offered new issues and pull requests. What comes in is chosen in`,` `,(0,U.jsx)(m,{to:V(e.id,`intake`),className:`underline`,children:`Settings → Work Intake`}),`.`]})]})}),..._,children:(0,U.jsxs)(`div`,{className:p(Q,`flex flex-col gap-8`),children:[(0,U.jsx)(G,{factoryId:e.id}),(0,U.jsx)(X,{factoryId:e.id})]})})}export{$ as BoardIntakePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-Umaf5xAa.js";import{t as r}from"./page-header-Maytcmgh-Dm4StKTd.js";import{$n as i,Un as a,Zn as o,wt as s}from"./index-D2WNyeAe.js";import{A as c,a as l,p as u}from"./Sidebar.es-DGzeKZbU.js";import{D as d,O as f,n as p,w as m}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{t as h}from"./lib-C4aHsZXk.js";import{r as g,t as _}from"./useBoardEditor-D_XHmLsE.js";import{i as v,r as y}from"./boardConfigPaths-CyCwKxS5.js";import{Q as b,r as x}from"./request-CPtLhnSV.js";import{n as S}from"./useBoardCatalog-Bwbdd2Vb.js";import{E as C,S as w,_ as T,a as E,b as D,c as ee,d as O,f as k,g as A,h as j,l as M,m as N,o as P,p as F,x as I}from"./conditionFields-Bxo1maIQ.js";import{f as L,i as te,s as R,t as z,u as B}from"./board-events-BVnaMaTS.js";import{Ht as ne,It as re,Pt as ie,Ut as ae,Vt as oe,ki as V,zt as se}from"./useFactories-B-Om6aVq.js";import{t as ce}from"./input-DqReKX0A-2mZo-XW9.js";import{n as H,t as U}from"./RadioGroup.es-IC93k6as.js";import{t as W}from"./createLucideIcon-4HMWrBkV.js";import{t as le}from"./ConditionRows-CwdldDit.js";import{a as ue,t as de}from"./BoardIcons-RydpbVA4.js";import{n as fe}from"./IconPlugin1.es-CZs2N-e2.js";import{a as pe,i as G,n as me,r as he,t as ge}from"./IntakeTesterDialog-CEuLQs7z.js";var _e={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};_e.node;var ve=W(_e),ye={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};ye.node;var be=W(ye),xe={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};xe.node;var Se=W(xe),Ce={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`]};Ce.node;var we=W(Ce),Te={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`]};Te.node;var Ee=W(Te),De={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};De.node;var Oe=W(De),ke={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`]};ke.node;var Ae=W(ke),je={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`]};je.node;var K=W(je),q=e(f(),1);function J(e,t){if(!e)return;let n=t??e.initialPhase,r=e.phases.find(e=>e.id===n);return r?r.name??r.title:void 0}function Y(e){return e.name??e.title}function X(e){return e?{"closedIssue.phase":e.phases.map(e=>({value:e.id,label:e.name??e.title}))}:{}}function Me(e,t,n,r){let i=[...t],[a]=i.splice(n,1);if(a===void 0)return e.map(e=>e.id);i.splice(r,0,a);let o=new Set(t),s=0;return e.map(e=>o.has(e.id)?i[s++]??e.id:e.id)}var Z=d(),Ne=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,Pe=`border-border-focus bg-fill-hover`,Fe=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function Ie({selected:e,disabled:t,onClick:n,children:r}){return(0,Z.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,onClick:n,className:m(Ne,`disabled:opacity-50`,e?Pe:Fe),children:r})}function Q({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,q.useId)();return(0,Z.jsxs)(`label`,{onClick:r,className:m(Ne,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?Pe:Fe,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Z.jsx)(H,{value:e,disabled:n,"aria-labelledby":a,className:`sr-only`}),(0,Z.jsx)(`span`,{id:a,className:`flex min-w-0 items-start gap-3`,children:i})]})}function Le({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let i=e.find(e=>e.id===n);if(!i)return(0,Z.jsxs)(p,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let a=r??i.initialPhase,o=i.phases.find(e=>e.id===a);return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[i.id!==t&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(p,{as:`span`,variant:`caption`,className:`truncate`,children:Y(i)}),(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),o&&(0,Z.jsx)(de,{stage:o.id,kind:ue(i.id,o.kind),decorative:!0}),(0,Z.jsx)(p,{as:`span`,variant:`caption`,className:`truncate`,children:J(i,a)??a})]})}var Re=120,ze=R(z),$=[{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 Be(e,t){let n=e?.phases??[];if(!t)return n;let r=n.find(t=>t.id===e?.initialPhase);return n.filter(e=>e.kind!==`terminal`&&(e.id===r?.id||r?.transitions.some(t=>t.to===e.id)===!0))}function Ve(e,t){if(t){let e=ze.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return te(e,t)??void 0}function He(e,t,n){let r=`When ${e.map(e=>A(e).label.toLowerCase()).join(` or `)}${t?`, ${P(t).charAt(0).toLowerCase()}${P(t).slice(1)}`:``}, move to ${n}`;return r.length>Re?`${r.slice(0,119)}…`:r}function Ue({board:e,boards:t,initial:n,initialEvent:r,initialStep:i,readOnly:a,saving:o,error:s,onSave:c,onClose:l}){let[u,d]=(0,q.useState)(()=>n?.on??(r?[r]:[])),[f,h]=(0,q.useState)(()=>n?.when??null),[g,_]=(0,q.useState)(()=>(n?.when?.conditions.length??0)>0),[v,y]=(0,q.useState)(!1),[b,S]=(0,q.useState)(()=>n?.target.moveToBoardKey??e.id),[C,w]=(0,q.useState)(()=>n?n.target.phaseKey??void 0:void 0),[T,E]=(0,q.useState)(()=>n?.name),[O,k]=(0,q.useState)(i),j=D(u),M=t.find(e=>e.id===b),N=Be(M,j),F=N.find(e=>e.id===(C??M?.initialPhase)),I=g?f:null,L=u.length?Ve(u,I):void 0,te=F&&M?`${Y(M)} › ${J(M,F.id)}`:``,R=T??(F?He(u,I,te):``),z={trigger:u.length>0,conditions:u.length>0&&!(g&&v)&&!L,action:F!==void 0,review:R.trim().length>0},B=!a&&z.trigger&&z.conditions&&z.action&&z.review,H=$.findIndex(e=>e.id===O),W=$[H]??$[0],fe=t=>{d(t),D(t)&&b!==e.id&&(S(e.id),w(void 0))},pe=()=>{B&&F&&c({name:R.trim(),on:u,when:I,target:{phaseKey:F.id,moveToBoardKey:b===e.id?null:b}})},G={trigger:u.length?u.map(e=>A(e).label).join(`, `):void 0,conditions:u.length?P(I,X(e)):void 0,action:F?(0,Z.jsx)(Le,{boards:t,ownBoard:e.id,boardKey:b,phaseKey:F.id}):void 0,review:void 0};return(0,Z.jsx)(ie,{open:!0,onOpenChange:e=>!e&&l(),children:(0,Z.jsxs)(se,{size:`xl`,children:[(0,Z.jsx)(ne,{children:(0,Z.jsx)(ae,{children:a?`Rule`:n?`Edit rule`:`Add rule`})}),(0,Z.jsx)(re,{children:(0,Z.jsxs)(`div`,{className:`grid min-h-105 grid-cols-1 gap-6 sm:grid-cols-[12rem_1fr]`,children:[(0,Z.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=>z[e.id]),r=z[e.id]&&e.id!==`review`;return(0,Z.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":O===e.id?`step`:void 0,onClick:()=>k(e.id),className:m(`flex shrink-0 items-start gap-2.5 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-40`,O===e.id?`bg-fill-hover`:`hover:bg-fill-subtle`),children:[(0,Z.jsx)(p,{as:`span`,variant:`meta`,className:m(`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,Z.jsx)(be,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(p,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),G[e.id]&&(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:G[e.id]})]})]},e.id)})}),(0,Z.jsxs)(`section`,{"aria-label":W.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Z.jsx)(p,{as:`h3`,variant:`heading`,children:W.question}),O===`trigger`&&(0,Z.jsx)(Ke,{value:u,disabled:a,onChange:fe}),O===`conditions`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(U,{"aria-label":`Which items`,value:g?`matching`:`every`,disabled:a,onValueChange:e=>{_(e===`matching`),y(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{value:`every`,selected:!g,disabled:a,children:(0,Z.jsx)(We,{title:j?`Every item`:`Every card`,hint:`Run whenever this happens.`})}),(0,Z.jsx)(Q,{value:`matching`,selected:g,disabled:a,children:(0,Z.jsx)(We,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),g&&(0,Z.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Z.jsx)(le,{label:`Conditions`,rule:f,facts:ee(u),options:X(e),onChange:(e,t)=>{h(e),y(t)}})}),L&&(0,Z.jsx)(x,{variant:`warning`,children:L})]}),O===`action`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[j?(0,Z.jsx)(p,{as:`p`,variant:`caption`,tone:`muted`,children:`An item with no card yet can only be filed on this board.`}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(p,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Z.jsx)(U,{"aria-label":`Board`,value:b,disabled:a,onValueChange:e=>{typeof e==`string`&&e!==b&&(S(e),w(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:t.map(t=>(0,Z.jsx)(Q,{value:t.id,selected:t.id===b,disabled:a,children:(0,Z.jsxs)(p,{as:`span`,variant:`label`,tone:`ink`,children:[Y(t),t.id===e.id?` (this board)`:``]})},t.id))})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(p,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Z.jsx)(U,{"aria-label":`Phase`,value:F?.id??null,disabled:a,onValueChange:e=>typeof e==`string`&&w(e),className:`grid-cols-1 sm:grid-cols-2`,children:M&&N.map(e=>(0,Z.jsx)(Q,{value:e.id,selected:e.id===F?.id,disabled:a,onClick:()=>{w(e.id),k(`review`)},children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(de,{stage:e.id,kind:ue(M.id,e.kind),decorative:!0}),(0,Z.jsx)(p,{as:`span`,variant:`label`,tone:`ink`,children:J(M,e.id)})]})},e.id))})]})]}),O===`review`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(p,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Z.jsx)(ce,{value:R,maxLength:Re,disabled:a,onChange:e=>E(e.target.value)})]}),(0,Z.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Z.jsx)(p,{as:`span`,variant:`eyebrow`,tone:`muted`,className:`mb-3 block`,children:`This rule reads as`}),(0,Z.jsxs)(`ol`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Ge,{label:`When`,children:G.trigger}),(0,Z.jsx)(Ge,{label:`Only if`,children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(Ee,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),G.conditions]})}),(0,Z.jsx)(Ge,{label:`Then`,children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Z.jsx)(ve,{className:`size-icon-sm`,"aria-hidden":!0}),` `,G.action]})})]})]})]}),s&&(0,Z.jsx)(x,{variant:`destructive`,role:`alert`,children:s})]})]})}),(0,Z.jsxs)(oe,{children:[(0,Z.jsx)(V,{variant:`ghost`,onClick:l,children:a?`Close`:`Cancel`}),(0,Z.jsx)(`div`,{className:`flex-1`}),H>0&&(0,Z.jsx)(V,{variant:`default`,onClick:()=>k($[H-1].id),children:`Back`}),!a&&(O===`review`||n&&B?(0,Z.jsx)(V,{variant:`primary`,disabled:!B||o,onClick:pe,children:o?`Saving…`:n?`Save rule`:`Create rule`}):(0,Z.jsx)(V,{variant:`primary`,disabled:!z[O],onClick:()=>k($[H+1]?.id??`review`),children:`Continue`}))]})]})})}function We({title:e,hint:t}){return(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(p,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function Ge({label:e,children:t}){return(0,Z.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Z.jsx)(p,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Z.jsx)(p,{as:`span`,variant:`body-sm`,children:t})]})}function Ke({value:e,disabled:t,onChange:n}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.includes(`work_item.created`)&&(0,Z.jsxs)(x,{variant:`info`,children:[`Also listens on “`,A(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),M.map(r=>(0,Z.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Z.jsx)(p,{as:`span`,variant:`eyebrow`,tone:`muted`,children:r.title}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.events.map(r=>{let i=A(r),a=i.icon,o=e.includes(r);return(0,Z.jsxs)(Ie,{selected:o,disabled:t||o&&e.length===1,onClick:()=>n(o?e.filter(e=>e!==r):[...e,r]),children:[(0,Z.jsx)(a,{className:`text-badge-amber-indicator mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(We,{title:i.label,hint:i.description})]},r)})})]},r.title))]})}function qe({when:e,options:t,everything:n}){let r=E(e,t);return!e||!r?(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,children:n}):(0,Z.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,Z.jsxs)(`span`,{className:`contents`,children:[n>0&&(0,Z.jsx)(p,{as:`span`,variant:`meta`,tone:`muted`,children:r.join}),a?(0,Z.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,Z.jsx)(p,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Z.jsx)(Je,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Z.jsx)(Je,{children:t})]},n)})})}function Je({children:e}){return(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}var Ye=m(`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 Xe({event:e,rules:t,board:n,boards:r,phaseOptions:i,canEdit:a,skips:o,note:s,footer:c,onEdit:l,onAdd:d,onMove:f,onToggle:h,onDelete:g}){let _=A(e),v=_.icon,y=O(t,e),b=N(e),x=me({min:0,max:t.length-1,onDrop:f}),S=c??(t.length?`Otherwise, the card stays where it is`:`No rules: the card stays where it is`);return(0,Z.jsxs)(`section`,{"aria-label":_.label,className:m(`grid grid-cols-1 gap-3 rounded-xl border border-border bg-card p-4 md:grid-cols-[13rem_1fr] md:gap-6`,!t.length&&`opacity-60 focus-within:opacity-100 hover:opacity-100`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:pt-1.5`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(v,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(p,{as:`h3`,variant:`label`,tone:`ink`,children:_.label})]}),_.description&&(0,Z.jsx)(p,{as:`p`,variant:`caption`,tone:`muted`,children:_.description}),s]}),(0,Z.jsxs)(`ol`,{"aria-label":`${_.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((s,c)=>{let d=I(t,e,c),_=d>=0,v=!s.enabled||_,S=x.drag?.from===c,C=o?.get(s.id);return(0,Z.jsxs)(`li`,{"aria-label":s.name,"data-drop":x.dropAt(c),style:S?{transform:`translateY(${x.drag?.offset??0}px)`}:void 0,onPointerDown:a&&t.length>1?e=>x.onPointerDown(e,c):void 0,className:m(`group flex flex-col`,Ye,S&&`z-10 opacity-90`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":`Edit conditions of ${s.name}`,onClick:()=>l(s,`conditions`),onKeyDown:a?e=>x.onKeyDown(e,c):void 0,className:m(`flex w-full shrink-0 items-start gap-2.5 rounded-lg border bg-fill-subtle px-3 py-2 text-left transition-colors hover:border-border-hover sm:w-80`,v?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Z.jsx)(p,{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:c+1}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(Ee,{className:`text-muted-foreground size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:s.name})]}),(0,Z.jsx)(qe,{when:s.when,options:i,everything:b?`Every new item`:`Every card`})]})]}),(0,Z.jsxs)(`div`,{className:m(`flex min-w-0 flex-1 items-center gap-2`,v&&`opacity-40`),children:[(0,Z.jsx)(p,{as:`span`,variant:`meta`,tone:`muted`,children:`yes`}),(0,Z.jsx)(`span`,{"aria-hidden":!0,className:m(`h-px min-w-6 flex-1`,v?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Edit where ${s.name} moves the card`,onClick:()=>l(s,`action`),className:`border-border bg-fill-subtle hover:border-border-hover flex w-40 shrink-0 rounded-lg border px-3 py-2 text-left sm:w-48`,children:(0,Z.jsx)(Le,{boards:r,ownBoard:n.id,boardKey:s.target.moveToBoardKey??s.target.boardKey,phaseKey:s.target.phaseKey})})]}),a&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-0.5`,children:[(0,Z.jsxs)(`div`,{className:`flex transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within:opacity-100 pointer-fine:group-hover:opacity-100`,children:[t.length>1&&(0,Z.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:`text-muted-foreground hidden cursor-grab touch-none items-center px-1 pointer-fine:flex`,children:(0,Z.jsx)(he,{className:`size-icon-sm`})}),(0,Z.jsx)(V,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:c===0,onClick:()=>f(c,c-1),children:(0,Z.jsx)(G,{})}),(0,Z.jsx)(V,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:c===t.length-1,onClick:()=>f(c,c+1),children:(0,Z.jsx)(pe,{})})]}),(0,Z.jsx)(fe,{"aria-label":`${s.name} on`,checked:s.enabled,onCheckedChange:e=>h(s,e)}),(0,Z.jsxs)(u,{children:[(0,Z.jsx)(u.Trigger,{render:(0,Z.jsx)(V,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${s.name}`,children:(0,Z.jsx)(we,{})})}),(0,Z.jsx)(u.Content,{align:`end`,children:(0,Z.jsxs)(u.Item,{variant:`destructive`,onClick:()=>g(s),children:[(0,Z.jsx)(Ae,{}),`Delete rule`]})})]})]})]}),v&&(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:_?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,d+1,` above matches every `,b?`item`:`card`,`.`]}):`Off, skipped`}),s.problems.map(e=>(0,Z.jsxs)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Z.jsx)(K,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),C&&(0,Z.jsx)(Qe,{skips:C}),T(s,e)&&(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),b&&F(s)&&(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:A(`work_item.created`).label}),c!==y&&(0,Z.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-7 items-center pl-5.5`,children:[(0,Z.jsx)(`span`,{className:`bg-border-strong h-full w-px`}),(0,Z.jsx)(p,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},s.id)}),(0,Z.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[y<0&&(0,Z.jsxs)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`flex items-center gap-2.5 px-3 py-1.5 sm:w-80`,children:[(0,Z.jsx)(Se,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),S]}),a&&(0,Z.jsx)(V,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(Oe,{}),onClick:d,children:`Add rule`})]})]})]})}function Ze(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function Qe({skips:e}){let{count:t,latest:n}=e;return(0,Z.jsxs)(p,{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,Z.jsx)(K,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[`Skipped `,t===1?`once`:`${t} times`,` in the last 30 days: `,Ze(n.reason),`.`]}),n.url?(0,Z.jsxs)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`Latest: `,n.title]}):(0,Z.jsxs)(`span`,{children:[`Latest: `,n.title]})]})}var $e=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function et(e){return e instanceof _&&e.code!==void 0&&$e.has(e.code)}function tt(e){return et(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function nt({factoryId:e,boardId:t}){let n=S(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Z.jsx)(c,{className:`h-64 w-full`}):n.isError?(0,Z.jsx)(x,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Z.jsx)(rt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Z.jsx)(x,{variant:`warning`,children:`This board isn’t installed.`})}function rt({factoryId:e,board:t,boards:n}){let r=B(e,t.id),i=w(e),a=C(e),o=L(e),[s,l]=(0,q.useState)(),u=(0,q.useRef)(void 0),d=e=>{u.current=e,l(e)},[f,m]=(0,q.useState)(),g=r.data?.intakeRoutes??[],_=r.data?.canEdit??!1,y=X(t),S=new Map(a.data?.skipped.map(e=>[e.routeId,e]));if(r.isPending)return(0,Z.jsx)(c,{className:`h-64 w-full`});if(r.isError)return(0,Z.jsx)(x,{variant:`destructive`,children:`This board’s rules didn’t load.`});let T=e=>o.mutateAsync(e).catch(e=>b.error(tt(e))),E=(e,n,r)=>{let i=j(g,e).map(e=>e.id);T([{kind:`reorder`,boardKey:t.id,ids:Me(g,i,n,r)}])},D=e=>{m(void 0),d(e)},ee=async e=>{let n=u.current,r=n?.rule,i=()=>n!==void 0&&u.current===n;m(void 0);try{if(r)await o.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 o.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:t.id,...e.target}}}]);i()&&d(void 0),n&&await A(n,e.on).catch(e=>b.error(tt(e)));return}i()&&d(void 0)}catch(e){if(!i())return;if(r&&et(e))return O(r);m(tt(e))}},O=async e=>{let t=u.current,n=(await r.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&u.current===t&&(n?(d({...t,rule:n}),m(`Someone else changed this rule first. It now shows their version; make your change again.`)):(d(void 0),b.error(`Someone else deleted this rule first.`)))},A=async(e,n)=>{if(e.target.boardKey!==t.id)return;let i=(await r.refetch()).data?.intakeRoutes??[],a=i.map(e=>e.id),s=a.indexOf(e.id),c=n.flatMap(t=>{let n=j(i,t),r=n[I(n,t,n.findIndex(t=>t.id===e.id))];return r?[a.indexOf(r.id)]:[]}),l=Math.min(...c);s<0||!(l<s)||await o.mutateAsync([{kind:`reorder`,boardKey:t.id,ids:Me(i,a,s,l)}])},P=i.data?k(i.data.boards,t.id):void 0;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[M.map(r=>(0,Z.jsxs)(`section`,{"aria-label":r.title,className:`flex flex-col gap-3`,children:[(0,Z.jsx)(p,{as:`h2`,variant:`subheading`,tone:`ink`,children:r.title}),r.events.map(r=>{let i=N(r),a=j(g,r);return(0,Z.jsx)(Xe,{event:r,rules:a,board:t,boards:n,phaseOptions:y,canEdit:_,skips:S,note:i?(0,Z.jsxs)(p,{as:`p`,variant:`caption`,tone:`muted`,children:[`No card yet:`,` `,P&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{to:v(e,t.id,`intake-order`),className:`underline`,children:P.charAt(0).toLowerCase()+P.slice(1)}),`;`,` `]}),`first matching rule files it on this board.`]}):void 0,footer:i?`Otherwise: checked by the next board, then Not routed`:void 0,onEdit:(e,t)=>D({rule:e,step:t}),onAdd:()=>D({event:r,step:`conditions`}),onMove:(e,t)=>E(r,e,t),onToggle:(e,t)=>void T([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void T([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&b.success(`Deleted “${e.name}”`))},r)})]},r.title)),s&&(0,Z.jsx)(Ue,{board:t,boards:n,initial:s.rule,initialEvent:s.event,initialStep:s.step,readOnly:!_,saving:o.isPending,error:f,onSave:e=>void ee(e),onClose:()=>d(void 0)},s.rule?`${s.rule.id}:${s.rule.revision}`:`new-${s.event}`)]})}var it=`w-full`;function at(){let e=a(),c=s()?.boardId??``,{isMobile:u,desktopState:d}=l(),f=u||d===`collapsed`,p=g(e.id,c).data?.board,_=o({breadcrumbs:f&&p?(0,Z.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(t,{as:h,to:y(e.id,c),children:p.name}),(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Z.jsx)(i,{variant:`narrow`,header:(0,Z.jsxs)(`div`,{className:m(it,`pb-8`),children:[(0,Z.jsxs)(r,{children:[(0,Z.jsx)(r.Title,{children:`Rules`}),(0,Z.jsx)(r.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(ge,{factoryProjectId:e.id,label:`Test an item`})})]}),..._,children:(0,Z.jsx)(`div`,{className:it,children:(0,Z.jsx)(nt,{factoryId:e.id,boardId:c})})})}export{at as BoardRulesPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-Caa0ta4Z.js";import{t as r}from"./page-header-Maytcmgh-Dm4StKTd.js";import{$n as i,Un as a,Zn as o,wt as s}from"./index-CqME59pn.js";import{A as c,a as l,p as u}from"./Sidebar.es-DGzeKZbU.js";import{D as d,O as f,n as p,w as m}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{t as h}from"./lib-C4aHsZXk.js";import{r as g,t as _}from"./useBoardEditor-D_XHmLsE.js";import{i as v,r as y}from"./boardConfigPaths-CyCwKxS5.js";import{Q as b,r as x}from"./request-CPtLhnSV.js";import{n as S}from"./useBoardCatalog-Bwbdd2Vb.js";import{E as C,S as w,_ as T,a as E,b as D,c as ee,d as O,f as k,g as A,h as j,l as M,m as N,o as P,p as F,x as I}from"./conditionFields-CBXR0ZAG.js";import{f as L,i as te,s as R,t as z,u as B}from"./board-events-BVnaMaTS.js";import{Ht as ne,It as re,Pt as ie,Ut as ae,Vt as oe,ki as V,zt as se}from"./useFactories-B-Om6aVq.js";import{t as ce}from"./input-DqReKX0A-2mZo-XW9.js";import{n as H,t as U}from"./RadioGroup.es-IC93k6as.js";import{t as W}from"./createLucideIcon-4HMWrBkV.js";import{t as le}from"./ConditionRows-DUjWJRNa.js";import{a as ue,t as de}from"./BoardIcons-RydpbVA4.js";import{n as fe}from"./IconPlugin1.es-CZs2N-e2.js";import{a as pe,i as G,n as me,r as he,t as ge}from"./IntakeTesterDialog-CDbp1koV.js";var _e={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};_e.node;var ve=W(_e),ye={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};ye.node;var be=W(ye),xe={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};xe.node;var Se=W(xe),Ce={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`]};Ce.node;var we=W(Ce),Te={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`]};Te.node;var Ee=W(Te),De={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};De.node;var Oe=W(De),ke={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`]};ke.node;var Ae=W(ke),je={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`]};je.node;var K=W(je),q=e(f(),1);function J(e,t){if(!e)return;let n=t??e.initialPhase,r=e.phases.find(e=>e.id===n);return r?r.name??r.title:void 0}function Y(e){return e.name??e.title}function X(e){return e?{"closedIssue.phase":e.phases.map(e=>({value:e.id,label:e.name??e.title}))}:{}}function Me(e,t,n,r){let i=[...t],[a]=i.splice(n,1);if(a===void 0)return e.map(e=>e.id);i.splice(r,0,a);let o=new Set(t),s=0;return e.map(e=>o.has(e.id)?i[s++]??e.id:e.id)}var Z=d(),Ne=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,Pe=`border-border-focus bg-fill-hover`,Fe=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function Ie({selected:e,disabled:t,onClick:n,children:r}){return(0,Z.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,onClick:n,className:m(Ne,`disabled:opacity-50`,e?Pe:Fe),children:r})}function Q({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,q.useId)();return(0,Z.jsxs)(`label`,{onClick:r,className:m(Ne,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?Pe:Fe,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Z.jsx)(H,{value:e,disabled:n,"aria-labelledby":a,className:`sr-only`}),(0,Z.jsx)(`span`,{id:a,className:`flex min-w-0 items-start gap-3`,children:i})]})}function Le({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let i=e.find(e=>e.id===n);if(!i)return(0,Z.jsxs)(p,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let a=r??i.initialPhase,o=i.phases.find(e=>e.id===a);return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[i.id!==t&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(p,{as:`span`,variant:`caption`,className:`truncate`,children:Y(i)}),(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),o&&(0,Z.jsx)(de,{stage:o.id,kind:ue(i.id,o.kind),decorative:!0}),(0,Z.jsx)(p,{as:`span`,variant:`caption`,className:`truncate`,children:J(i,a)??a})]})}var Re=120,ze=R(z),$=[{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 Be(e,t){let n=e?.phases??[];if(!t)return n;let r=n.find(t=>t.id===e?.initialPhase);return n.filter(e=>e.kind!==`terminal`&&(e.id===r?.id||r?.transitions.some(t=>t.to===e.id)===!0))}function Ve(e,t){if(t){let e=ze.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return te(e,t)??void 0}function He(e,t,n){let r=`When ${e.map(e=>A(e).label.toLowerCase()).join(` or `)}${t?`, ${P(t).charAt(0).toLowerCase()}${P(t).slice(1)}`:``}, move to ${n}`;return r.length>Re?`${r.slice(0,119)}…`:r}function Ue({board:e,boards:t,initial:n,initialEvent:r,initialStep:i,readOnly:a,saving:o,error:s,onSave:c,onClose:l}){let[u,d]=(0,q.useState)(()=>n?.on??(r?[r]:[])),[f,h]=(0,q.useState)(()=>n?.when??null),[g,_]=(0,q.useState)(()=>(n?.when?.conditions.length??0)>0),[v,y]=(0,q.useState)(!1),[b,S]=(0,q.useState)(()=>n?.target.moveToBoardKey??e.id),[C,w]=(0,q.useState)(()=>n?n.target.phaseKey??void 0:void 0),[T,E]=(0,q.useState)(()=>n?.name),[O,k]=(0,q.useState)(i),j=D(u),M=t.find(e=>e.id===b),N=Be(M,j),F=N.find(e=>e.id===(C??M?.initialPhase)),I=g?f:null,L=u.length?Ve(u,I):void 0,te=F&&M?`${Y(M)} › ${J(M,F.id)}`:``,R=T??(F?He(u,I,te):``),z={trigger:u.length>0,conditions:u.length>0&&!(g&&v)&&!L,action:F!==void 0,review:R.trim().length>0},B=!a&&z.trigger&&z.conditions&&z.action&&z.review,H=$.findIndex(e=>e.id===O),W=$[H]??$[0],fe=t=>{d(t),D(t)&&b!==e.id&&(S(e.id),w(void 0))},pe=()=>{B&&F&&c({name:R.trim(),on:u,when:I,target:{phaseKey:F.id,moveToBoardKey:b===e.id?null:b}})},G={trigger:u.length?u.map(e=>A(e).label).join(`, `):void 0,conditions:u.length?P(I,X(e)):void 0,action:F?(0,Z.jsx)(Le,{boards:t,ownBoard:e.id,boardKey:b,phaseKey:F.id}):void 0,review:void 0};return(0,Z.jsx)(ie,{open:!0,onOpenChange:e=>!e&&l(),children:(0,Z.jsxs)(se,{size:`xl`,children:[(0,Z.jsx)(ne,{children:(0,Z.jsx)(ae,{children:a?`Rule`:n?`Edit rule`:`Add rule`})}),(0,Z.jsx)(re,{children:(0,Z.jsxs)(`div`,{className:`grid min-h-105 grid-cols-1 gap-6 sm:grid-cols-[12rem_1fr]`,children:[(0,Z.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=>z[e.id]),r=z[e.id]&&e.id!==`review`;return(0,Z.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":O===e.id?`step`:void 0,onClick:()=>k(e.id),className:m(`flex shrink-0 items-start gap-2.5 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-40`,O===e.id?`bg-fill-hover`:`hover:bg-fill-subtle`),children:[(0,Z.jsx)(p,{as:`span`,variant:`meta`,className:m(`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,Z.jsx)(be,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(p,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),G[e.id]&&(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:G[e.id]})]})]},e.id)})}),(0,Z.jsxs)(`section`,{"aria-label":W.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Z.jsx)(p,{as:`h3`,variant:`heading`,children:W.question}),O===`trigger`&&(0,Z.jsx)(Ke,{value:u,disabled:a,onChange:fe}),O===`conditions`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(U,{"aria-label":`Which items`,value:g?`matching`:`every`,disabled:a,onValueChange:e=>{_(e===`matching`),y(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{value:`every`,selected:!g,disabled:a,children:(0,Z.jsx)(We,{title:j?`Every item`:`Every card`,hint:`Run whenever this happens.`})}),(0,Z.jsx)(Q,{value:`matching`,selected:g,disabled:a,children:(0,Z.jsx)(We,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),g&&(0,Z.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Z.jsx)(le,{label:`Conditions`,rule:f,facts:ee(u),options:X(e),onChange:(e,t)=>{h(e),y(t)}})}),L&&(0,Z.jsx)(x,{variant:`warning`,children:L})]}),O===`action`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[j?(0,Z.jsx)(p,{as:`p`,variant:`caption`,tone:`muted`,children:`An item with no card yet can only be filed on this board.`}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(p,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Z.jsx)(U,{"aria-label":`Board`,value:b,disabled:a,onValueChange:e=>{typeof e==`string`&&e!==b&&(S(e),w(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:t.map(t=>(0,Z.jsx)(Q,{value:t.id,selected:t.id===b,disabled:a,children:(0,Z.jsxs)(p,{as:`span`,variant:`label`,tone:`ink`,children:[Y(t),t.id===e.id?` (this board)`:``]})},t.id))})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(p,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Z.jsx)(U,{"aria-label":`Phase`,value:F?.id??null,disabled:a,onValueChange:e=>typeof e==`string`&&w(e),className:`grid-cols-1 sm:grid-cols-2`,children:M&&N.map(e=>(0,Z.jsx)(Q,{value:e.id,selected:e.id===F?.id,disabled:a,onClick:()=>{w(e.id),k(`review`)},children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(de,{stage:e.id,kind:ue(M.id,e.kind),decorative:!0}),(0,Z.jsx)(p,{as:`span`,variant:`label`,tone:`ink`,children:J(M,e.id)})]})},e.id))})]})]}),O===`review`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(p,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Z.jsx)(ce,{value:R,maxLength:Re,disabled:a,onChange:e=>E(e.target.value)})]}),(0,Z.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Z.jsx)(p,{as:`span`,variant:`eyebrow`,tone:`muted`,className:`mb-3 block`,children:`This rule reads as`}),(0,Z.jsxs)(`ol`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Ge,{label:`When`,children:G.trigger}),(0,Z.jsx)(Ge,{label:`Only if`,children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(Ee,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),G.conditions]})}),(0,Z.jsx)(Ge,{label:`Then`,children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Z.jsx)(ve,{className:`size-icon-sm`,"aria-hidden":!0}),` `,G.action]})})]})]})]}),s&&(0,Z.jsx)(x,{variant:`destructive`,role:`alert`,children:s})]})]})}),(0,Z.jsxs)(oe,{children:[(0,Z.jsx)(V,{variant:`ghost`,onClick:l,children:a?`Close`:`Cancel`}),(0,Z.jsx)(`div`,{className:`flex-1`}),H>0&&(0,Z.jsx)(V,{variant:`default`,onClick:()=>k($[H-1].id),children:`Back`}),!a&&(O===`review`||n&&B?(0,Z.jsx)(V,{variant:`primary`,disabled:!B||o,onClick:pe,children:o?`Saving…`:n?`Save rule`:`Create rule`}):(0,Z.jsx)(V,{variant:`primary`,disabled:!z[O],onClick:()=>k($[H+1]?.id??`review`),children:`Continue`}))]})]})})}function We({title:e,hint:t}){return(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(p,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function Ge({label:e,children:t}){return(0,Z.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Z.jsx)(p,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Z.jsx)(p,{as:`span`,variant:`body-sm`,children:t})]})}function Ke({value:e,disabled:t,onChange:n}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.includes(`work_item.created`)&&(0,Z.jsxs)(x,{variant:`info`,children:[`Also listens on “`,A(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),M.map(r=>(0,Z.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Z.jsx)(p,{as:`span`,variant:`eyebrow`,tone:`muted`,children:r.title}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.events.map(r=>{let i=A(r),a=i.icon,o=e.includes(r);return(0,Z.jsxs)(Ie,{selected:o,disabled:t||o&&e.length===1,onClick:()=>n(o?e.filter(e=>e!==r):[...e,r]),children:[(0,Z.jsx)(a,{className:`text-badge-amber-indicator mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(We,{title:i.label,hint:i.description})]},r)})})]},r.title))]})}function qe({when:e,options:t,everything:n}){let r=E(e,t);return!e||!r?(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,children:n}):(0,Z.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,Z.jsxs)(`span`,{className:`contents`,children:[n>0&&(0,Z.jsx)(p,{as:`span`,variant:`meta`,tone:`muted`,children:r.join}),a?(0,Z.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,Z.jsx)(p,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Z.jsx)(Je,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Z.jsx)(Je,{children:t})]},n)})})}function Je({children:e}){return(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}var Ye=m(`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 Xe({event:e,rules:t,board:n,boards:r,phaseOptions:i,canEdit:a,skips:o,note:s,footer:c,onEdit:l,onAdd:d,onMove:f,onToggle:h,onDelete:g}){let _=A(e),v=_.icon,y=O(t,e),b=N(e),x=me({min:0,max:t.length-1,onDrop:f}),S=c??(t.length?`Otherwise, the card stays where it is`:`No rules: the card stays where it is`);return(0,Z.jsxs)(`section`,{"aria-label":_.label,className:m(`grid grid-cols-1 gap-3 rounded-xl border border-border bg-card p-4 md:grid-cols-[13rem_1fr] md:gap-6`,!t.length&&`opacity-60 focus-within:opacity-100 hover:opacity-100`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:pt-1.5`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(v,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(p,{as:`h3`,variant:`label`,tone:`ink`,children:_.label})]}),_.description&&(0,Z.jsx)(p,{as:`p`,variant:`caption`,tone:`muted`,children:_.description}),s]}),(0,Z.jsxs)(`ol`,{"aria-label":`${_.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((s,c)=>{let d=I(t,e,c),_=d>=0,v=!s.enabled||_,S=x.drag?.from===c,C=o?.get(s.id);return(0,Z.jsxs)(`li`,{"aria-label":s.name,"data-drop":x.dropAt(c),style:S?{transform:`translateY(${x.drag?.offset??0}px)`}:void 0,onPointerDown:a&&t.length>1?e=>x.onPointerDown(e,c):void 0,className:m(`group flex flex-col`,Ye,S&&`z-10 opacity-90`),children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":`Edit conditions of ${s.name}`,onClick:()=>l(s,`conditions`),onKeyDown:a?e=>x.onKeyDown(e,c):void 0,className:m(`flex w-full shrink-0 items-start gap-2.5 rounded-lg border bg-fill-subtle px-3 py-2 text-left transition-colors hover:border-border-hover sm:w-80`,v?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Z.jsx)(p,{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:c+1}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(Ee,{className:`text-muted-foreground size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:s.name})]}),(0,Z.jsx)(qe,{when:s.when,options:i,everything:b?`Every new item`:`Every card`})]})]}),(0,Z.jsxs)(`div`,{className:m(`flex min-w-0 flex-1 items-center gap-2`,v&&`opacity-40`),children:[(0,Z.jsx)(p,{as:`span`,variant:`meta`,tone:`muted`,children:`yes`}),(0,Z.jsx)(`span`,{"aria-hidden":!0,className:m(`h-px min-w-6 flex-1`,v?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Edit where ${s.name} moves the card`,onClick:()=>l(s,`action`),className:`border-border bg-fill-subtle hover:border-border-hover flex w-40 shrink-0 rounded-lg border px-3 py-2 text-left sm:w-48`,children:(0,Z.jsx)(Le,{boards:r,ownBoard:n.id,boardKey:s.target.moveToBoardKey??s.target.boardKey,phaseKey:s.target.phaseKey})})]}),a&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-0.5`,children:[(0,Z.jsxs)(`div`,{className:`flex transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within:opacity-100 pointer-fine:group-hover:opacity-100`,children:[t.length>1&&(0,Z.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:`text-muted-foreground hidden cursor-grab touch-none items-center px-1 pointer-fine:flex`,children:(0,Z.jsx)(he,{className:`size-icon-sm`})}),(0,Z.jsx)(V,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:c===0,onClick:()=>f(c,c-1),children:(0,Z.jsx)(G,{})}),(0,Z.jsx)(V,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:c===t.length-1,onClick:()=>f(c,c+1),children:(0,Z.jsx)(pe,{})})]}),(0,Z.jsx)(fe,{"aria-label":`${s.name} on`,checked:s.enabled,onCheckedChange:e=>h(s,e)}),(0,Z.jsxs)(u,{children:[(0,Z.jsx)(u.Trigger,{render:(0,Z.jsx)(V,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${s.name}`,children:(0,Z.jsx)(we,{})})}),(0,Z.jsx)(u.Content,{align:`end`,children:(0,Z.jsxs)(u.Item,{variant:`destructive`,onClick:()=>g(s),children:[(0,Z.jsx)(Ae,{}),`Delete rule`]})})]})]})]}),v&&(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:_?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(K,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,d+1,` above matches every `,b?`item`:`card`,`.`]}):`Off, skipped`}),s.problems.map(e=>(0,Z.jsxs)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Z.jsx)(K,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),C&&(0,Z.jsx)(Qe,{skips:C}),T(s,e)&&(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),b&&F(s)&&(0,Z.jsx)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:A(`work_item.created`).label}),c!==y&&(0,Z.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-7 items-center pl-5.5`,children:[(0,Z.jsx)(`span`,{className:`bg-border-strong h-full w-px`}),(0,Z.jsx)(p,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},s.id)}),(0,Z.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[y<0&&(0,Z.jsxs)(p,{as:`span`,variant:`caption`,tone:`muted`,className:`flex items-center gap-2.5 px-3 py-1.5 sm:w-80`,children:[(0,Z.jsx)(Se,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),S]}),a&&(0,Z.jsx)(V,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(Oe,{}),onClick:d,children:`Add rule`})]})]})]})}function Ze(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function Qe({skips:e}){let{count:t,latest:n}=e;return(0,Z.jsxs)(p,{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,Z.jsx)(K,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[`Skipped `,t===1?`once`:`${t} times`,` in the last 30 days: `,Ze(n.reason),`.`]}),n.url?(0,Z.jsxs)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`Latest: `,n.title]}):(0,Z.jsxs)(`span`,{children:[`Latest: `,n.title]})]})}var $e=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function et(e){return e instanceof _&&e.code!==void 0&&$e.has(e.code)}function tt(e){return et(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function nt({factoryId:e,boardId:t}){let n=S(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Z.jsx)(c,{className:`h-64 w-full`}):n.isError?(0,Z.jsx)(x,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Z.jsx)(rt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Z.jsx)(x,{variant:`warning`,children:`This board isn’t installed.`})}function rt({factoryId:e,board:t,boards:n}){let r=B(e,t.id),i=w(e),a=C(e),o=L(e),[s,l]=(0,q.useState)(),u=(0,q.useRef)(void 0),d=e=>{u.current=e,l(e)},[f,m]=(0,q.useState)(),g=r.data?.intakeRoutes??[],_=r.data?.canEdit??!1,y=X(t),S=new Map(a.data?.skipped.map(e=>[e.routeId,e]));if(r.isPending)return(0,Z.jsx)(c,{className:`h-64 w-full`});if(r.isError)return(0,Z.jsx)(x,{variant:`destructive`,children:`This board’s rules didn’t load.`});let T=e=>o.mutateAsync(e).catch(e=>b.error(tt(e))),E=(e,n,r)=>{let i=j(g,e).map(e=>e.id);T([{kind:`reorder`,boardKey:t.id,ids:Me(g,i,n,r)}])},D=e=>{m(void 0),d(e)},ee=async e=>{let n=u.current,r=n?.rule,i=()=>n!==void 0&&u.current===n;m(void 0);try{if(r)await o.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 o.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:t.id,...e.target}}}]);i()&&d(void 0),n&&await A(n,e.on).catch(e=>b.error(tt(e)));return}i()&&d(void 0)}catch(e){if(!i())return;if(r&&et(e))return O(r);m(tt(e))}},O=async e=>{let t=u.current,n=(await r.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&u.current===t&&(n?(d({...t,rule:n}),m(`Someone else changed this rule first. It now shows their version; make your change again.`)):(d(void 0),b.error(`Someone else deleted this rule first.`)))},A=async(e,n)=>{if(e.target.boardKey!==t.id)return;let i=(await r.refetch()).data?.intakeRoutes??[],a=i.map(e=>e.id),s=a.indexOf(e.id),c=n.flatMap(t=>{let n=j(i,t),r=n[I(n,t,n.findIndex(t=>t.id===e.id))];return r?[a.indexOf(r.id)]:[]}),l=Math.min(...c);s<0||!(l<s)||await o.mutateAsync([{kind:`reorder`,boardKey:t.id,ids:Me(i,a,s,l)}])},P=i.data?k(i.data.boards,t.id):void 0;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[M.map(r=>(0,Z.jsxs)(`section`,{"aria-label":r.title,className:`flex flex-col gap-3`,children:[(0,Z.jsx)(p,{as:`h2`,variant:`subheading`,tone:`ink`,children:r.title}),r.events.map(r=>{let i=N(r),a=j(g,r);return(0,Z.jsx)(Xe,{event:r,rules:a,board:t,boards:n,phaseOptions:y,canEdit:_,skips:S,note:i?(0,Z.jsxs)(p,{as:`p`,variant:`caption`,tone:`muted`,children:[`No card yet:`,` `,P&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{to:v(e,t.id,`intake-order`),className:`underline`,children:P.charAt(0).toLowerCase()+P.slice(1)}),`;`,` `]}),`first matching rule files it on this board.`]}):void 0,footer:i?`Otherwise: checked by the next board, then Not routed`:void 0,onEdit:(e,t)=>D({rule:e,step:t}),onAdd:()=>D({event:r,step:`conditions`}),onMove:(e,t)=>E(r,e,t),onToggle:(e,t)=>void T([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void T([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&b.success(`Deleted “${e.name}”`))},r)})]},r.title)),s&&(0,Z.jsx)(Ue,{board:t,boards:n,initial:s.rule,initialEvent:s.event,initialStep:s.step,readOnly:!_,saving:o.isPending,error:f,onSave:e=>void ee(e),onClose:()=>d(void 0)},s.rule?`${s.rule.id}:${s.rule.revision}`:`new-${s.event}`)]})}var it=`w-full`;function at(){let e=a(),c=s()?.boardId??``,{isMobile:u,desktopState:d}=l(),f=u||d===`collapsed`,p=g(e.id,c).data?.board,_=o({breadcrumbs:f&&p?(0,Z.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(t,{as:h,to:y(e.id,c),children:p.name}),(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Z.jsx)(i,{variant:`narrow`,header:(0,Z.jsxs)(`div`,{className:m(it,`pb-8`),children:[(0,Z.jsxs)(r,{children:[(0,Z.jsx)(r.Title,{children:`Rules`}),(0,Z.jsx)(r.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsx)(ge,{factoryProjectId:e.id,label:`Test an item`})})]}),..._,children:(0,Z.jsx)(`div`,{className:it,children:(0,Z.jsx)(nt,{factoryId:e.id,boardId:c})})})}export{at as BoardRulesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$i as t,aa as n,an as r,on as i}from"./useFactories-B-Om6aVq.js";import{D as a,O as o,a as s,w as c}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{A as l}from"./Sidebar.es-DGzeKZbU.js";import{Hn as u}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$i as t,aa as n,an as r,on as i}from"./useFactories-B-Om6aVq.js";import{D as a,O as o,a as s,w as c}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{A as l}from"./Sidebar.es-DGzeKZbU.js";import{Hn as u}from"./index-CqME59pn.js";var d=e(o(),1),f=a(),p=e=>(0,f.jsx)(`svg`,{width:`19.125`,height:`18`,viewBox:`-1.0625 -1 19.125 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,f.jsx)(`path`,{d:`M5.25684 12.6387L10.4003 3.36133H11.7432L6.5997 12.6387H5.25684Z`,fill:`currentColor`})}),m=({children:e,label:t,className:n,listClassName:r})=>(0,f.jsx)(`nav`,{"aria-label":t,className:n,children:(0,f.jsx)(`ol`,{className:c(`flex items-center gap-0.5`,r),children:e})}),h=e=>(0,f.jsx)(l,{className:`h-3 w-24`,...e}),g=({className:e,as:a,to:o,isCurrent:l,action:m,switcher:g,icon:_,isLoading:v,children:y,...b})=>{let x=a||`span`,S=!(!g||!l&&o),C=d.useRef(null);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`li`,{ref:C,className:c(`group flex h-control-sm min-w-0 items-center`,l?`shrink`:`shrink-0`,S&&`relative rounded-full has-[[data-slot=crumb-switcher]_[data-popup-open]]:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:hover:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:active:bg-fill`),children:[(0,f.jsxs)(x,{"aria-current":l?`page`:void 0,className:c(`inline-flex min-w-0 items-center gap-2 overflow-hidden rounded-full px-[.9em]`,t.sm,s,l?`max-w-xs cursor-default text-foreground`:S?c(i,`max-w-48`):c(r,`max-w-48 cursor-pointer hover:bg-fill-subtle active:bg-fill`),e),to:o,...b,children:[_&&(0,f.jsx)(n,{className:c(`ml-[-.3em] shrink-0 opacity-50 group-hover:opacity-100`,`transition-opacity duration-normal ease-out-custom`),children:_}),v?(0,f.jsx)(h,{}):(0,f.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:y})]}),g&&(0,f.jsx)(`span`,{"data-slot":`crumb-switcher`,className:c(`-ml-1 flex h-control-sm shrink-0 items-center`,S&&`[&_button]:bg-transparent! [&_button:enabled]:after:absolute [&_button:enabled]:after:inset-0 [&_button:enabled]:after:rounded-full`),children:(0,f.jsx)(u,{value:C,children:g})}),m&&(0,f.jsx)(`span`,{className:`-ml-1 flex h-control-sm shrink-0 items-center`,children:m})]}),!l&&(0,f.jsx)(`li`,{role:`separator`,className:`flex h-full items-center`,children:(0,f.jsx)(n,{className:`text-placeholder`,children:(0,f.jsx)(p,{})})})]})};export{g as n,m as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-XKyaHtl9.js";import{_ as e}from"./cardStageBar-BqHQPxtk.js";import{Ei as t,Jn as n,Jr as r,Ni as i,Wr as a,Y as o,Zt as s,ki as c,lr as l,or as u}from"./useFactories-B-Om6aVq.js";import{t as d}from"./EmptyState-juw2jci2-vYAzd7Mx.js";import{t as f}from"./Logo.es-DqYFa-ke.js";import{Q as p,r as m}from"./request-CPtLhnSV.js";import{A as h}from"./Sidebar.es-DGzeKZbU.js";import{D as g,n as _}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{A as ee,N as v,m as y}from"./use-providers-DPSMm1ii.js";import{G as b,J as x,at as te,et as ne,g as S,tn as C,x as w}from"./index-
|
|
1
|
+
import"./rolldown-runtime-XKyaHtl9.js";import{_ as e}from"./cardStageBar-BqHQPxtk.js";import{Ei as t,Jn as n,Jr as r,Ni as i,Wr as a,Y as o,Zt as s,ki as c,lr as l,or as u}from"./useFactories-B-Om6aVq.js";import{t as d}from"./EmptyState-juw2jci2-vYAzd7Mx.js";import{t as f}from"./Logo.es-DqYFa-ke.js";import{Q as p,r as m}from"./request-CPtLhnSV.js";import{A as h}from"./Sidebar.es-DGzeKZbU.js";import{D as g,n as _}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{A as ee,N as v,m as y}from"./use-providers-DPSMm1ii.js";import{G as b,J as x,at as te,et as ne,g as S,tn as C,x as w}from"./index-CqME59pn.js";import{o as T,t as E}from"./lib-C4aHsZXk.js";import{n as D,o as O}from"./useBoardCatalog-Bwbdd2Vb.js";import{A as k,R as A,b as j,j as M,pt as N,r as P,st as F,y as I}from"./IconFormCircle.es-4bcuYhrK.js";import{b as L,v as R,y as z}from"./Transcript-9K1Flr3R.js";import{i as B,n as V,r as H,t as re}from"./useDraftModelGuards-oEIWfjNg.js";import{i as U,o as W,t as G}from"./CardStageBar-DWV6yjSW.js";import{s as K}from"./useFactoryDecisions-B_eptAHT.js";import{a as q,s as J}from"./boardCardState-BTP1-1PJ.js";import{D as Y,U as X,w as ie}from"./useSessionRows-K8nhJELk.js";import{s as ae}from"./settingsSections-Cijt0lNE.js";var Z=g();function oe({factory:e,item:t,board:n}){let r=o().data?.user?.userId,i=J(e.id),a=K(e.id).data?.queued.find(e=>e.workItem?.id===t.id)?.position,s=q({factoryProjectId:e.id,kind:n.id,items:[t],currentUserId:r,onFailure:e=>p.error(e)}),{actions:l}=C({item:t,definition:n,columnStage:N(t,n)??n.initialPhase,evaluatingStage:s.evaluatingStages.get(t.id),transitionReason:s.transitionReasons[t.id],decision:i.effectByItem.get(t.id),queuePosition:a,proposal:i.proposalByItem.get(t.id),approvingDecisionId:i.approvingId,retryingDecisionId:i.retryingId,onApproveProposal:i.approve,onRetryDecision:i.retry,onMove:e=>s.move(t.id,e)});return(0,Z.jsxs)(Z.Fragment,{children:[i.error&&(0,Z.jsx)(m,{variant:`destructive`,children:i.error.message}),l.length>0&&(0,Z.jsx)(`div`,{role:`group`,"aria-label":`Suggested actions`,className:`flex flex-wrap justify-center gap-2`,children:l.map((e,t)=>(0,Z.jsx)(c,{type:`button`,size:`md`,variant:t===0&&!e.disabled?`primary`:`default`,"aria-label":e.ariaLabel,disabled:e.disabled,onClick:()=>e.start(),children:e.label},e.label))})]})}function se(e,t){let{baseUrl:i}=n();return r({queryKey:s.workItemSessionRepository(e,t.id,t.updatedAt),queryFn:({signal:n})=>ie(i,e,t.id,n),staleTime:0,refetchOnWindowFocus:!0})}function Q(e,n){let{baseUrl:r}=P(),{activeModelId:i,defaultModelId:o}=te(),{override:c}=ne(),{factoryId:d}=l(),f=t(),p=u(),m=n?.status===`resolved`?n:void 0,h=a({mutationFn:async({factoryId:t,repository:n})=>{let i=e.workItem?{}:e.metadata??{},{branch:a,threadTitle:o}=X(e),{sessionId:s}=await k(r,n.projectRepositoryId,{branch:a});return await Y(r,t,{sessionId:s,threadTitle:o,kickoffKey:crypto.randomUUID(),workItem:{id:e.id,role:`chat`,input:{source:e.source,sourceKey:e.sourceKey,title:e.title,url:null,metadata:i}}}),M(r,s)},onSettled:(e,t,{factoryId:n})=>f.invalidateQueries({queryKey:s.workItems(n)})});return{ready:m!==void 0&&!h.isPending,start:async({prompt:e,files:t})=>{if(!d||!m)throw Error(`Could not create the session. Reload the page and try again.`);if(!i)throw Error(`Session configuration is not ready. Try again.`);let n=await h.mutateAsync({factoryId:d,repository:m}).catch(e=>{let t=e instanceof Error?e.message:`Session creation failed`;throw Error(`Could not create the session: ${t}. Try again.`,{cause:e})}),{sessionId:r}=n;f.setQueryData(s.userSession(r),n),I(f,d,n),j(f,d),f.setQueryData(s.agentControllerThreadMessages(A,r,r,100),[]),x(r,t);let a=i===o&&!c;p(v(d,{sessionId:r,threadId:r}),{replace:!0,state:b(r,e,{modelId:a?void 0:i,thinkingLevel:c})})}}}var $=`New session`;function ce(){let{factoryId:e=``,workItemId:t=``,draftSessionId:n}=l(),r=re(e,`factory`);return(0,Z.jsx)(w,{children:(0,Z.jsx)(le,{factoryId:e,workItemId:t,guards:r})},n)}function le({factoryId:t,workItemId:n,guards:r}){let a=F(t,n),o=D(t),s=r.activeFactory;if(a.isLoadingError)return(0,Z.jsx)(L,{title:$,children:(0,Z.jsx)(`div`,{className:B,children:(0,Z.jsx)(d,{as:`h2`,iconSlot:(0,Z.jsx)(S,{}),titleSlot:`Could not load this card`,descriptionSlot:a.error.message,actionSlot:(0,Z.jsx)(c,{variant:`primary`,onClick:()=>void a.refetch(),children:`Try again`})})})});if(a.data===null)return(0,Z.jsx)(L,{title:$,children:(0,Z.jsx)(`div`,{className:B,children:(0,Z.jsx)(d,{as:`h2`,iconSlot:(0,Z.jsx)(S,{}),titleSlot:`This card no longer exists`,descriptionSlot:`It was removed from the board.`,actionSlot:(0,Z.jsx)(E,{to:ee({id:t}),className:i({variant:`primary`}),children:`Back to the board`})})})});if(!a.data||o.isPending||!s)return(0,Z.jsx)(L,{title:$,children:(0,Z.jsxs)(`div`,{className:B,"aria-busy":`true`,children:[(0,Z.jsx)(h,{"aria-label":`Loading card`,className:`h-8 w-2/3`}),(0,Z.jsx)(h,{className:`h-36 w-full rounded-xl`})]})});let l=a.data,u=O(o.data,l),f=e(l,u?.phases,N(l,u)??``);return f?(0,Z.jsx)(T,{replace:!0,to:v(t,f)}):(0,Z.jsx)(L,{title:$,headerCenter:u&&(0,Z.jsx)(G,{item:l,sessionItems:[l],board:u,factory:s}),children:r.missingModel||r.missingCredential?(0,Z.jsx)(H,{heading:l.title,guards:r}):(0,Z.jsx)(ue,{factory:s,item:l,board:u,configurationError:r.configurationError})})}function ue({factory:e,item:t,board:n,configurationError:r}){z();let i=se(e.id,t),a=Q(t,i.error?void 0:i.data);return(0,Z.jsx)(R.Provider,{value:a,children:(0,Z.jsx)(U,{composerLabel:`Thread composer`,emptyState:(0,Z.jsxs)(`section`,{className:W,"aria-labelledby":`card-draft-title`,children:[(0,Z.jsx)(f,{size:`md`,"aria-label":`Mastra Code`}),(0,Z.jsx)(_,{as:`h2`,variant:`title`,tone:`ink`,id:`card-draft-title`,className:`mt-7 max-w-2xl text-balance`,children:t.title}),(0,Z.jsx)(_,{variant:`body-sm`,tone:`muted`,className:`mt-2 max-w-lg text-pretty`,children:`No session yet. Your first message starts one.`}),(0,Z.jsxs)(`div`,{className:`mt-7 flex w-full max-w-2xl flex-col items-center gap-3`,children:[r&&(0,Z.jsx)(V,{error:r}),(0,Z.jsx)(de,{factoryId:e.id,lookup:i}),n&&(0,Z.jsx)(oe,{factory:e,item:t,board:n})]})]})})})}function de({factoryId:e,lookup:t}){return t.error?(0,Z.jsx)(m,{variant:`warning`,action:(0,Z.jsxs)(m.Button,{onClick:()=>void t.refetch(),disabled:t.isFetching,children:[`Retry `,(0,Z.jsx)(y,{})]}),children:`Could not find this card's repository: ${t.error.message}`}):t.data?.status===`unlinked`?(0,Z.jsx)(m,{variant:`warning`,action:(0,Z.jsx)(m.Button,{render:(0,Z.jsx)(E,{to:ae(e,`repositories`)}),children:`Open repository settings`}),children:t.data.hint}):null}export{ce as CardDraftPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{D as t,O as n,i as r,l as i,n as a,o,t as s,u as c,w as l}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{$t as u,Jr as d,Qt as f,Y as p,a as m,ca as h,ki as g,la as _,lr as v,oc as y,sa as b,sn as x,ua as S}from"./useFactories-B-Om6aVq.js";import{T as C,r as w,yt as T}from"./IconFormCircle.es-4bcuYhrK.js";import{Q as ee}from"./request-CPtLhnSV.js";import{p as E}from"./Sidebar.es-DGzeKZbU.js";import{r as te}from"./useSessionRows-K8nhJELk.js";import{t as D}from"./spinner-B9ykw74u-DxtuBv70.js";import{a as ne,c as re,i as ie,n as ae,t as oe}from"./boardCardState-BTP1-1PJ.js";import{a as se,i as O,l as k,n as ce,r as le,s as ue,t as de}from"./cardStageBar-BqHQPxtk.js";import{a as fe,t as pe}from"./BoardIcons-RydpbVA4.js";import{B as me,H as he,O as ge,P as A,R as j,S as M,V as N,c as P,i as F,k as I,l as L,s as R,t as _e,x as ve,z as ye}from"./Transcript-DhHlVRYl.js";import{d as be}from"./MarkdownRenderer-De9m5Xru-Bc4g8gee.js";import{$ as xe,B as Se,C as Ce,D as z,S as we,V as Te,X as Ee,Z as B,_t as De,b as Oe,nn as ke,o as Ae,z as je}from"./index-D2WNyeAe.js";import{t as Me}from"./Logo.es-DqYFa-ke.js";var V=t(),H=`flex w-full min-w-0 max-w-full flex-1 flex-col items-center justify-center px-6 py-12 text-center`;function U({label:e,value:t,font:n=`mono`}){return(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[7rem_minmax(0,1fr)] gap-2`,children:[(0,V.jsx)(`dt`,{className:r({variant:`caption`,tone:`muted`}),children:e}),(0,V.jsx)(`dd`,{className:l(r({variant:`caption`,tone:`ink`,font:n}),`min-w-0 truncate`),children:t})]})}function Ne(){let{factoryId:e}=v(),{data:t}=m(e),{sessionId:n,resourceId:r,factorySessionState:i}=w(),{prefillComposer:s}=Ee();if(!t)return null;let c=t.repositories.find(e=>e.projectRepositoryId===i?.projectRepositoryId)?.gitBranch;return(0,V.jsxs)(`section`,{className:H,"aria-labelledby":`empty-thread-title`,children:[(0,V.jsx)(Me,{size:`md`,"aria-label":`Mastra Code`}),(0,V.jsx)(a,{as:`h2`,variant:`display`,tone:`ink`,id:`empty-thread-title`,className:`mt-7 text-balance`,children:`What can I help you build?`}),(0,V.jsx)(a,{variant:`body-sm`,tone:`muted`,className:`mt-2 max-w-lg text-pretty`,children:`Ask about this codebase, plan a change, or describe something that isn't working.`}),(0,V.jsxs)(`div`,{className:`mt-7 flex w-full max-w-2xl flex-wrap justify-center gap-2`,"aria-label":`Suggested prompts`,children:[(0,V.jsx)(g,{type:`button`,size:`md`,onClick:()=>s(`Help me understand how this codebase is structured.`),children:`Explore this codebase`}),(0,V.jsx)(g,{type:`button`,size:`md`,onClick:()=>s(`Help me plan a new feature.`),children:`Plan a feature`}),(0,V.jsx)(g,{type:`button`,size:`md`,onClick:()=>s(`Review the recent changes and suggest improvements.`),children:`Review recent changes`}),(0,V.jsx)(g,{type:`button`,size:`md`,onClick:()=>s(`Help me debug an issue.`),children:`Debug an issue`})]}),(0,V.jsxs)(`details`,{className:`text-muted-foreground group mt-8 w-full max-w-lg min-w-0`,children:[(0,V.jsxs)(`summary`,{className:`hover:text-foreground flex cursor-pointer list-none items-center justify-center gap-1.5 rounded-full px-3 py-2 transition-colors [&::-webkit-details-marker]:hidden ${o}`,children:[(0,V.jsxs)(a,{as:`span`,variant:`caption`,children:[`Working in`,` `,(0,V.jsx)(a,{as:`span`,variant:`column`,tone:`ink`,children:t.name})]}),(0,V.jsx)(ke,{className:`size-3.5 group-open:rotate-180`})]}),(0,V.jsxs)(`dl`,{className:`mx-auto mt-3 grid w-full min-w-0 gap-1 text-left`,children:[(0,V.jsx)(U,{label:`Factory`,value:t.name,font:`body`}),r&&(0,V.jsx)(U,{label:`Resource ID`,value:r}),c&&(0,V.jsx)(U,{label:`Branch`,value:c}),n&&n!==r&&(0,V.jsx)(U,{label:`Session ID`,value:n})]})]})]})}var W=e(n(),1),Pe={memory:`Updating memory`,thinking:`Thinking`,waiting:`Waiting for you`,done:`Done`,error:`Something went wrong`},Fe={memory:`running`,thinking:`running`,waiting:`idle`,done:`idle`,error:`error`};function Ie(e){return e===`thinking`||typeof e!=`string`}function Le(e){switch(e.type){case`text`:return e.text.trim().length>0;case`reasoning`:return e.reasoning.trim().length>0;case`file`:return!0;case`tool-invocation`:{let{toolName:t,state:n}=e.toolInvocation;return je(t)?!1:t!==`ask_user`||z(n)}default:return!1}}function Re(e){return e.type===`text`?`writing`:e.type!==`tool-invocation`||z(e.toolInvocation.state)?`thinking`:e.toolInvocation}function ze(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.id===t)return`thinking`;if(r.kind===`approval`||r.kind===`suspension`)return`waiting`;if(r.kind===`notice`&&r.level===`error`)return`error`;if(r.kind!==`message`)continue;if(r.message.role===`user`)return`thinking`;if(r.message.role!==`assistant`)continue;let{parts:i}=r.message.content;if(i.some(e=>e.type===`error`))return`error`;let a=i.findLast(Le);if(a)return Re(a)}return`thinking`}function Be(e,t,n){return e===`waiting`||e===`error`||e===`writing`?e:t?n?`memory`:e:`done`}function Ve(e){if(typeof e==`string`)return{pose:e,label:Pe[e],status:Fe[e]};let{label:t,detail:n}=F([{...e,status:`running`}]);return{pose:Se(e.toolName,e.args).pose,label:t,detail:n,status:`running`}}function He({state:e,live:t,onSettled:n}){let{pose:r,label:i,detail:a,status:o}=Ve(e);return(0,V.jsx)(be,{children:(0,V.jsx)(`div`,{"aria-hidden":!0,className:l(`transition-opacity duration-300 motion-reduce:duration-0`,!t&&`opacity-0 delay-1100 starting:opacity-100`),onTransitionEnd:e=>{e.target===e.currentTarget&&!t&&n()},children:(0,V.jsx)(j,{foldable:!1,status:o,appearance:`inline`,children:(0,V.jsxs)(me,{children:[(0,V.jsx)(N,{className:`[&_svg]:size-icon-md`,children:(0,V.jsx)(Te,{state:r})}),(0,V.jsx)(he,{className:`text-subheading`,children:i}),a&&(0,V.jsx)(ye,{className:`text-body-sm`,children:a})]})})})})}function Ue({stretchLive:e}){let{busy:t,transcript:n}=B(),r=xe(),i=ze(n.entries,n.lastEntryBeforeRun),a=t||i===`waiting`,o=r.runsStarted,[s,c]=(0,W.useState)(a?void 0:o),l=Be(i,t,Object.values(L(r)).includes(`blocking`));return l===`writing`||e&&Ie(l)||!a&&s===o?null:(0,V.jsx)(He,{state:l,live:a,onSettled:()=>c(o)})}function We({historyInitializing:e,preparing:t}){return(0,V.jsxs)(`div`,{"aria-hidden":!t,className:`session-preparation-overlay pointer-events-none absolute inset-0 z-5 overflow-hidden bg-(--chat-surface) data-[preparing=false]:bg-transparent`,"data-preparing":t,children:[(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`session-preparation-veil absolute inset-x-0 opacity-0`}),(0,V.jsx)(`div`,{className:`session-preparation-loader invisible absolute inset-0 z-1 flex -translate-y-1 bg-(--chat-surface) opacity-0`,children:(0,V.jsx)(we,{finishing:!t,historyInitializing:e})})]})}var G=`duration-[600ms] ease-(--resize-ease) motion-reduce:transition-none`,Ge=`absolute top-1/2 left-0.5 -translate-y-1/2 transition-[translate]`,Ke={completed:`translate-x-0`,in_progress:`translate-x-4`,pending:`translate-x-0`},qe=8,Je=24,K=(e,t)=>e===`in_progress`&&!t?Je:qe,q=e=>e*28+14,J={completed:`var(--success-indicator)`,in_progress:`var(--warning-indicator)`,pending:`var(--border-strong)`},Ye=(e,t,n,r)=>{let i=q(n),a=q(n+1),o=(i+a)/2,s=K(e,r),c=K(t,r);return`M ${s} ${i} C ${s} ${o} ${c} ${o} ${c} ${a}`},Xe=({upper:e,lower:t,index:n,graphId:r,singleLane:i})=>{let a=Ye(e,t,n,i),o=`path("${a}")`,s=e!==`pending`&&t!==`pending`,c=e===`in_progress`||t===`in_progress`;return(0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{d:a,fill:`none`,strokeWidth:1,mask:`url(#${r}-future)`,className:l(`transition-[d]`,G),style:{d:o,stroke:J.pending}}),(0,V.jsx)(`path`,{d:a,fill:`none`,strokeWidth:1,pathLength:1,strokeDasharray:`1 1`,className:l(`transition-[d,stroke-dashoffset,stroke]`,G),style:{d:o,strokeDashoffset:+!s,stroke:c?J.in_progress:J.completed}})]})},Ze=({statuses:e,singleLane:t=!1})=>{let n=`task-graph${(0,W.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,r=e.length*28,i={x:-8,y:0,width:48,height:r};return(0,V.jsxs)(`svg`,{"aria-hidden":!0,width:32,height:r,className:`pointer-events-none absolute top-0 left-0 overflow-visible`,children:[(0,V.jsxs)(`defs`,{children:[(0,V.jsxs)(`linearGradient`,{id:`${n}-fade`,gradientUnits:`userSpaceOnUse`,x1:0,x2:0,y1:0,y2:r,children:[(0,V.jsx)(`stop`,{offset:`0`,stopColor:`white`,stopOpacity:1}),(0,V.jsx)(`stop`,{offset:`1`,stopColor:`white`,stopOpacity:.15})]}),(0,V.jsx)(`mask`,{id:`${n}-future`,maskUnits:`userSpaceOnUse`,...i,children:(0,V.jsx)(`rect`,{...i,fill:`url(#${n}-fade)`})}),(0,V.jsxs)(`linearGradient`,{id:`${n}-gap`,x1:0,x2:0,y1:0,y2:1,children:[(0,V.jsx)(`stop`,{offset:`0.2`,stopColor:`white`,stopOpacity:0}),(0,V.jsx)(`stop`,{offset:`0.4`,stopColor:`white`,stopOpacity:1}),(0,V.jsx)(`stop`,{offset:`0.6`,stopColor:`white`,stopOpacity:1}),(0,V.jsx)(`stop`,{offset:`0.8`,stopColor:`white`,stopOpacity:0})]}),(0,V.jsx)(`pattern`,{id:`${n}-gaps`,patternUnits:`userSpaceOnUse`,x:i.x,y:14,width:i.width,height:28,children:(0,V.jsx)(`rect`,{width:i.width,height:28,fill:`url(#${n}-gap)`})}),(0,V.jsx)(`mask`,{id:`${n}-between-nodes`,maskUnits:`userSpaceOnUse`,...i,children:(0,V.jsx)(`rect`,{...i,fill:`url(#${n}-gaps)`})})]}),(0,V.jsx)(`g`,{mask:`url(#${n}-between-nodes)`,children:e.map((r,i)=>{let a=e[i+1];return a?(0,V.jsx)(Xe,{upper:r,lower:a,index:i,graphId:n,singleLane:t},i):null})})]})},Qe=()=>window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,$e=e=>1-(1-e)**5,et=(e,t)=>{let n=e.scrollTop,r=t-n;if(Qe())return e.scrollTo({top:t}),()=>{};let i=0,a=performance.now(),o=t=>{let s=Math.min((t-a)/600,1);e.scrollTo({top:n+r*$e(s)}),s<1&&(i=requestAnimationFrame(o))};return i=requestAnimationFrame(o),()=>cancelAnimationFrame(i)},tt=(e,t,n)=>{let r=e*28,i=r+28;return r<t?r:i>t+n?i-n:t},nt=4.5,Y=(e,t)=>t?Math.min(e,nt)*28:28,rt=(e,{focusIndex:t,windowHeight:n,open:r,followFocus:i})=>r?i?tt(t,e,n):e:t*28,it=(e,t,n)=>Math.min(Math.max(e,0),Math.max(t-n,0)),at=({focusIndex:e,rowCount:t,open:n,followFocus:r})=>{let i=(0,W.useRef)(null),a=(0,W.useRef)(void 0),o=(0,W.useRef)(!1),s=n=>{let s=i.current;if(!s||typeof s.scrollTo!=`function`)return;let c=Y(t,n),l=it(rt(s.scrollTop,{focusIndex:e,windowHeight:c,open:n,followFocus:r}),t*28,c);a.current?.(),o.current?l!==s.scrollTop&&(a.current=et(s,l)):(o.current=!0,s.scrollTo({top:l}))},c=(0,W.useEffectEvent)(()=>s(n));return(0,W.useEffect)(()=>(c(),()=>a.current?.()),[e]),{viewportRef:i,glideForOpen:s}},ot=({className:e,...t})=>(0,V.jsx)(`section`,{className:l(y,`overflow-hidden rounded-2xl`,e),...t}),st={completed:`bg-success-indicator`,in_progress:`bg-warning-indicator`,pending:`bg-fill-hover`},ct=({tasks:e,className:t,...n})=>{let r=e.filter(e=>e.status===`completed`).length;return(0,V.jsx)(_,{delayDuration:0,children:(0,V.jsxs)(b,{children:[(0,V.jsx)(S,{render:(0,V.jsx)(`span`,{role:`progressbar`,"aria-label":`Task completion`,"aria-valuemin":0,"aria-valuemax":e.length,"aria-valuenow":r,className:l(`ml-auto flex h-4 w-fit max-w-40 shrink-0 items-center gap-1 overflow-hidden`,t),...n,children:e.map(e=>(0,V.jsx)(`span`,{className:l(`h-full w-0.5 min-w-px shrink rounded-full transition-colors`,G,st[e.status])},e.id))})}),(0,V.jsxs)(h,{children:[r,`/`,e.length,` completed`]})]})})},lt={completed:`Completed`,in_progress:`In progress`,pending:`Pending`},ut={completed:`size-[7px] border-success-indicator bg-card`,in_progress:`size-2 border-warning-indicator bg-warning-subtle`,pending:`size-1.5 border-muted-foreground/45 bg-card`},dt=({status:e,className:t,...n})=>(0,V.jsx)(`span`,{role:`img`,"aria-label":lt[e],className:l(`grid size-3 shrink-0 place-items-center rounded-full`,t),...n,children:(0,V.jsx)(`span`,{className:l(`rounded-full border-[1.5px] transition-[width,height,border-color,background-color]`,G,ut[e])})}),ft=({task:e})=>{let t=e.status===`in_progress`;return(0,V.jsxs)(a,{as:`span`,variant:`caption`,className:`grid min-w-0`,children:[(0,V.jsx)(`span`,{"aria-hidden":t,className:l(`col-start-1 row-start-1 truncate transition-[opacity,color,translate,filter]`,G,e.status===`pending`?`text-muted-foreground/70`:`text-muted-foreground`,t?`-translate-y-1 opacity-0 blur-[2px]`:`translate-y-0 opacity-100 blur-none`),children:(0,V.jsx)(`span`,{className:l(`bg-[linear-gradient(currentColor,currentColor)] bg-no-repeat transition-[background-size]`,G,e.status===`completed`?`bg-size-[100%_1px] bg-position-[left_55%]`:`bg-size-[0%_1px] bg-position-[right_55%]`),children:e.content})}),(0,V.jsx)(`span`,{"aria-hidden":!t,className:l(`col-start-1 row-start-1 truncate bg-linear-to-r from-warning-indicator to-foreground to-30% bg-size-[200%_100%] bg-clip-text font-medium text-transparent transition-[opacity,translate,filter,background-position]`,G,t?`translate-y-0 bg-position-[0%_0] opacity-100 blur-none`:`translate-y-1 bg-position-[100%_0] opacity-0 blur-[2px]`),children:e.activeForm})]})},pt=({task:e,className:t,style:n,...r})=>(0,V.jsxs)(`li`,{className:l(`relative flex items-center`,t),style:{height:28,...n},...r,children:[(0,V.jsx)(dt,{status:e.status,className:l(Ge,G,Ke[e.status],`group-data-collapsed/task-list:translate-x-0`)}),(0,V.jsx)(`span`,{className:l(`flex min-w-0 transition-[padding-left]`,G,e.status===`in_progress`?`pl-10 group-data-collapsed/task-list:pl-6`:`pl-6`),children:(0,V.jsx)(ft,{task:e})})]}),mt=10,ht=`mask-no-repeat [--fade-bottom:0.875rem] [--fade-top:0.875rem] [mask-composite:subtract,add] [mask-image:linear-gradient(black,black),linear-gradient(to_bottom,black,transparent),linear-gradient(to_top,black,transparent)] [mask-position:0_0,0_0,0_100%] [mask-size:100%_100%,100%_var(--fade-top),100%_var(--fade-bottom)]`,X=`data-[overflow-y-end]:[--fade-bottom:2rem] data-[overflow-y-start]:[--fade-top:2rem]`,gt=e=>{let t=e.findIndex(e=>e.status===`in_progress`);if(t>=0)return t;let n=e.findIndex(e=>e.status===`pending`);return n>=0?n:e.length-1},_t=({tasks:e,hideWhenComplete:t=!0,scrollActiveIntoView:n=!0,defaultOpen:r=!0,className:a,...s})=>{let[d,p]=(0,W.useState)(r),m=(0,W.useId)(),h=e.filter(e=>e.status===`completed`).length,g=e.length,_=gt(e),v=Y(g,d),{viewportRef:y,glideForOpen:b}=at({focusIndex:_,rowCount:g,open:d,followFocus:n}),x=e=>{p(e),b(e)};return g===0||t&&h===g?null:(0,V.jsxs)(ot,{"aria-label":`Task list`,"data-testid":`task-list`,"data-collapsed":d?void 0:``,onClick:d?void 0:()=>x(!0),className:l(`group/task-list relative`,!d&&`cursor-pointer`,a),...s,children:[(0,V.jsx)(f,{id:m,maxHeight:`${v+20}px`,mask:!1,children:(0,V.jsx)(u,{ref:y,className:l(ht,`transition-[max-height,mask-size]`,G,d?X:`overflow-hidden!`),children:(0,V.jsx)(`div`,{className:`px-3`,style:{paddingBlock:mt},children:(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(Ze,{statuses:e.map(e=>e.status),singleLane:!d}),(0,V.jsx)(`ul`,{children:e.map((e,t)=>{let n=!d&&t!==_;return(0,V.jsx)(pt,{task:e,inert:n,"aria-hidden":n},e.id)})})]})})})}),(0,V.jsxs)(`div`,{className:`absolute top-2.5 right-3 flex h-7 items-center bg-linear-to-r from-transparent to-card to-[1.5rem] pl-6`,children:[(0,V.jsx)(`div`,{inert:d,"aria-hidden":d,className:l(`grid transition-[grid-template-columns,opacity]`,G,d?`grid-cols-[0fr] opacity-0`:`grid-cols-[1fr] opacity-100`),children:(0,V.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,V.jsx)(ct,{tasks:e,className:`mr-2`})})}),(0,V.jsx)(`button`,{type:`button`,"aria-label":d?`Collapse tasks`:`Show all tasks`,"aria-expanded":d,"aria-controls":m,onClick:e=>{e.stopPropagation(),x(!d)},className:l(`grid size-6 cursor-pointer place-items-center rounded-md text-muted-foreground hover:text-foreground`,i.colors,o,!d&&`group-hover/task-list:text-foreground`),children:(0,V.jsx)(c,{className:l(`size-icon-sm transition-[rotate]`,G,d?`rotate-180`:`rotate-0`)})})]})]})};function vt(){let{transcript:e}=B();return e.tasks.some(e=>e.status!==`completed`)?(0,V.jsx)(`div`,{role:`region`,"aria-label":`Current tasks`,"data-testid":`task-panel`,children:(0,V.jsx)(_t,{tasks:e.tasks})}):null}function yt(){let{loadMore:e}=B();return e.isLoading?(0,V.jsx)(`div`,{className:`flex w-full justify-center py-2`,children:(0,V.jsx)(D,{size:`sm`,className:`text-muted-foreground`,"aria-label":`Loading older messages`})}):null}var bt=64,xt=e=>(0,V.jsx)(Ue,{stretchLive:e});function St({secondaryBar:e,emptyState:t,composerLabel:n,composerStatus:r,contentOverlay:i}){let{busy:a,loadMore:o,transcript:s}=B(),{historyInitializing:c,preparing:u}=Ce(),d=o.hasMore&&!o.isLoading,f=s.entries.some(e=>e.kind!==`notice`);return(0,V.jsxs)(R,{className:l(`chat-surface-enter flex-1 [--chat-gutter:0.25rem]`,ge),scroller:{autoScroll:!0,defaultScrollPosition:a?`end`:`last-anchor`,preserveScrollOnPrepend:!0,onReachStart:d?o.load:void 0,scrollPreviousItemPeek:ve+bt},children:[e&&(0,V.jsx)(R.Bar,{className:`not-empty:mt-(--chat-header-room)`,children:e}),(0,V.jsx)(R.Stage,{children:(0,V.jsx)(R.Viewport,{className:A.viewport,children:(0,V.jsxs)(`div`,{className:`relative flex min-h-full min-w-0 flex-1 flex-col`,children:[(0,V.jsx)(`div`,{className:`contents`,children:i}),(0,V.jsxs)(R.Content,{role:`region`,"aria-label":`Conversation`,"aria-busy":u,className:`relative gap-0 pt-[calc(var(--chat-header-room,0px)+1.5rem)] [[data-slot=chat-shell-bar]:not(:empty)~[data-slot=message-scroller]_&]:pt-6`,children:[(0,V.jsx)(We,{historyInitializing:c,preparing:u}),(0,V.jsxs)(R.Transcript,{className:`flex-1`,children:[(0,V.jsx)(De,{}),(0,V.jsxs)(Oe,{showPreparation:!1,children:[(0,V.jsx)(yt,{}),!f&&t,(0,V.jsx)(_e,{tail:xt})]})]})]}),(0,V.jsxs)(R.Dock,{className:`pb-[calc(var(--chat-gutter)+env(safe-area-inset-bottom))]`,children:[(0,V.jsx)(R.ScrollButton,{"aria-label":`Jump to latest message`}),(0,V.jsxs)(R.Column,{className:l(`gap-2`,I),children:[(0,V.jsx)(vt,{}),(0,V.jsx)(`div`,{role:`region`,"aria-label":n,children:(0,V.jsx)(P,{statusLead:r})})]})]})]})})})]})}var Ct=[];function wt(e,t,n=`github`){let{baseUrl:r,sessionId:i}=w(),a=t&&!!e,o=d(ue(r,i,e,n,a));return{subscriptions:o.data??Ct,pending:a&&o.isPending,failed:a&&o.isLoadingError}}function Z(){let{factoryId:e}=v(),t=C(k()),n=m(e),r=n.data?.repositories.find(e=>e.projectRepositoryId===t.data?.projectRepositoryId);return{repository:r,provider:r?.provider===`gitlab`?`gitlab`:`github`,loading:t.isLoading||n.isLoading,failed:t.isLoadingError||n.isLoadingError}}function Q(){let{threadId:e}=v(),t=Z();return{session:t,links:wt(e,t.repository!==void 0,t.provider)}}function Tt({item:e,sessionItems:t,board:n,factory:r,openContext:i}){let{effectByItem:o}=re(r.id),s=p().data?.user?.userId,{move:l,evaluatingStages:u}=ne({factoryProjectId:r.id,kind:n.id,items:t,currentUserId:s,onFailure:e=>ee.error(e)}),{session:d,links:f}=Q(),m=d.repository,h=f.subscriptions,g=te(r.id),_=g.current&&g.held.has(e.id),{owner:v}=oe({decision:o.get(e.id),sessionHolds:_}),y=de(e,n),b=y?.current.kind===`working`?le(e,y.current.id):void 0,x=Ae(e=>b===void 0?void 0:ce(b,e));if(!y)return null;let{current:S}=y,C=u.has(e.id),w=e=>!ae(v.kind,e.kind),D=t=>l(e.id,t),O=e=>(0,V.jsx)(pe,{stage:e.id,kind:fe(n.id,e.kind),decorative:!0}),k=t=>{let r=t.id===S.id;return(0,V.jsxs)(E.RadioItem,{value:t.id,closeOnClick:!0,"aria-label":r?`${T(t)}, current stage`:`Move to ${T(t)}`,className:`items-start`,disabled:!r&&w(t),children:[O(t),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,V.jsx)(`span`,{className:`truncate`,children:T(t)}),r?null:(0,V.jsx)(a,{as:`span`,variant:`meta`,tone:`muted`,children:w(t)?ie:se(n,e,t,i,{repository:m?.slug,subscriptions:h})})]})]},t.id)};return(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(`div`,{role:`group`,"aria-label":`Card stage`,className:M,children:[y.previous?(0,V.jsx)($,{direction:`previous`,step:y.previous,held:w(y.previous.phase),disabled:C,onMove:D}):null,(0,V.jsxs)(E,{children:[(0,V.jsxs)(E.Trigger,{variant:`subtle`,size:`sm`,"aria-label":`Change stage from ${T(S)}`,disabled:C,children:[O(S),(0,V.jsx)(`span`,{children:T(S)}),x?(0,V.jsx)(a,{as:`span`,variant:`meta`,tone:`muted`,font:`mono`,children:x}):null,(0,V.jsx)(c,{"aria-hidden":!0})]}),(0,V.jsx)(E.Content,{align:`center`,className:`max-h-(--available-height) w-72`,children:(0,V.jsxs)(E.RadioGroup,{value:S.id,onValueChange:e=>{e!==S.id&&D(e)},children:[y.track.map(k),y.track.length>0&&y.stop.length>0?(0,V.jsx)(E.Separator,{}):null,y.stop.map(k)]})})]}),y.next?(0,V.jsx)($,{direction:`next`,step:y.next,held:w(y.next.phase),disabled:C,onMove:D}):null]})})}function $({direction:e,step:t,held:n,disabled:r,onMove:i}){let a=T(t.phase),o=e===`previous`?`Move back to ${a}`:`Move to ${a}`,c=O(t)??(n?`Another run can't start while this card is busy.`:void 0);return(0,V.jsxs)(g,{variant:`ghost`,size:`sm`,"aria-label":c?`${o}, ${c}`:o,tooltip:c??o,disabled:r||n||t.blocked!==void 0,onClick:()=>i(t.phase.id),children:[e===`previous`?(0,V.jsx)(x,{"aria-hidden":!0}):null,(0,V.jsx)(`span`,{className:`hidden @2xl:inline`,children:a}),e===`next`?(0,V.jsx)(s,{"aria-hidden":!0}):null]})}export{Ne as a,St as i,Q as n,H as o,Z as r,Tt as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{D as t,O as n,i as r,l as i,n as a,o,t as s,u as c,w as l}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{$t as u,Jr as d,Qt as f,Y as p,a as m,ca as h,ki as g,la as _,lr as v,oc as y,sa as b,sn as x,ua as S}from"./useFactories-B-Om6aVq.js";import{T as C,r as w,yt as T}from"./IconFormCircle.es-4bcuYhrK.js";import{Q as ee}from"./request-CPtLhnSV.js";import{p as E}from"./Sidebar.es-DGzeKZbU.js";import{r as te}from"./useSessionRows-K8nhJELk.js";import{t as D}from"./spinner-B9ykw74u-DxtuBv70.js";import{a as ne,c as re,i as ie,n as ae,t as oe}from"./boardCardState-BTP1-1PJ.js";import{a as se,i as O,l as k,n as ce,r as le,s as ue,t as de}from"./cardStageBar-BqHQPxtk.js";import{a as fe,t as pe}from"./BoardIcons-RydpbVA4.js";import{B as me,H as he,O as ge,P as A,R as j,S as M,V as N,c as P,i as F,k as I,l as L,s as R,t as _e,x as ve,z as ye}from"./Transcript-9K1Flr3R.js";import{d as be}from"./MarkdownRenderer-De9m5Xru-Bc4g8gee.js";import{$ as xe,B as Se,C as Ce,D as z,S as we,V as Te,X as Ee,Z as B,_t as De,b as Oe,nn as ke,o as Ae,z as je}from"./index-CqME59pn.js";import{t as Me}from"./Logo.es-DqYFa-ke.js";var V=t(),H=`flex w-full min-w-0 max-w-full flex-1 flex-col items-center justify-center px-6 py-12 text-center`;function U({label:e,value:t,font:n=`mono`}){return(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[7rem_minmax(0,1fr)] gap-2`,children:[(0,V.jsx)(`dt`,{className:r({variant:`caption`,tone:`muted`}),children:e}),(0,V.jsx)(`dd`,{className:l(r({variant:`caption`,tone:`ink`,font:n}),`min-w-0 truncate`),children:t})]})}function Ne(){let{factoryId:e}=v(),{data:t}=m(e),{sessionId:n,resourceId:r,factorySessionState:i}=w(),{prefillComposer:s}=Ee();if(!t)return null;let c=t.repositories.find(e=>e.projectRepositoryId===i?.projectRepositoryId)?.gitBranch;return(0,V.jsxs)(`section`,{className:H,"aria-labelledby":`empty-thread-title`,children:[(0,V.jsx)(Me,{size:`md`,"aria-label":`Mastra Code`}),(0,V.jsx)(a,{as:`h2`,variant:`display`,tone:`ink`,id:`empty-thread-title`,className:`mt-7 text-balance`,children:`What can I help you build?`}),(0,V.jsx)(a,{variant:`body-sm`,tone:`muted`,className:`mt-2 max-w-lg text-pretty`,children:`Ask about this codebase, plan a change, or describe something that isn't working.`}),(0,V.jsxs)(`div`,{className:`mt-7 flex w-full max-w-2xl flex-wrap justify-center gap-2`,"aria-label":`Suggested prompts`,children:[(0,V.jsx)(g,{type:`button`,size:`md`,onClick:()=>s(`Help me understand how this codebase is structured.`),children:`Explore this codebase`}),(0,V.jsx)(g,{type:`button`,size:`md`,onClick:()=>s(`Help me plan a new feature.`),children:`Plan a feature`}),(0,V.jsx)(g,{type:`button`,size:`md`,onClick:()=>s(`Review the recent changes and suggest improvements.`),children:`Review recent changes`}),(0,V.jsx)(g,{type:`button`,size:`md`,onClick:()=>s(`Help me debug an issue.`),children:`Debug an issue`})]}),(0,V.jsxs)(`details`,{className:`text-muted-foreground group mt-8 w-full max-w-lg min-w-0`,children:[(0,V.jsxs)(`summary`,{className:`hover:text-foreground flex cursor-pointer list-none items-center justify-center gap-1.5 rounded-full px-3 py-2 transition-colors [&::-webkit-details-marker]:hidden ${o}`,children:[(0,V.jsxs)(a,{as:`span`,variant:`caption`,children:[`Working in`,` `,(0,V.jsx)(a,{as:`span`,variant:`column`,tone:`ink`,children:t.name})]}),(0,V.jsx)(ke,{className:`size-3.5 group-open:rotate-180`})]}),(0,V.jsxs)(`dl`,{className:`mx-auto mt-3 grid w-full min-w-0 gap-1 text-left`,children:[(0,V.jsx)(U,{label:`Factory`,value:t.name,font:`body`}),r&&(0,V.jsx)(U,{label:`Resource ID`,value:r}),c&&(0,V.jsx)(U,{label:`Branch`,value:c}),n&&n!==r&&(0,V.jsx)(U,{label:`Session ID`,value:n})]})]})]})}var W=e(n(),1),Pe={memory:`Updating memory`,thinking:`Thinking`,waiting:`Waiting for you`,done:`Done`,error:`Something went wrong`},Fe={memory:`running`,thinking:`running`,waiting:`idle`,done:`idle`,error:`error`};function Ie(e){return e===`thinking`||typeof e!=`string`}function Le(e){switch(e.type){case`text`:return e.text.trim().length>0;case`reasoning`:return e.reasoning.trim().length>0;case`file`:return!0;case`tool-invocation`:{let{toolName:t,state:n}=e.toolInvocation;return je(t)?!1:t!==`ask_user`||z(n)}default:return!1}}function Re(e){return e.type===`text`?`writing`:e.type!==`tool-invocation`||z(e.toolInvocation.state)?`thinking`:e.toolInvocation}function ze(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.id===t)return`thinking`;if(r.kind===`approval`||r.kind===`suspension`)return`waiting`;if(r.kind===`notice`&&r.level===`error`)return`error`;if(r.kind!==`message`)continue;if(r.message.role===`user`)return`thinking`;if(r.message.role!==`assistant`)continue;let{parts:i}=r.message.content;if(i.some(e=>e.type===`error`))return`error`;let a=i.findLast(Le);if(a)return Re(a)}return`thinking`}function Be(e,t,n){return e===`waiting`||e===`error`||e===`writing`?e:t?n?`memory`:e:`done`}function Ve(e){if(typeof e==`string`)return{pose:e,label:Pe[e],status:Fe[e]};let{label:t,detail:n}=F([{...e,status:`running`}]);return{pose:Se(e.toolName,e.args).pose,label:t,detail:n,status:`running`}}function He({state:e,live:t,onSettled:n}){let{pose:r,label:i,detail:a,status:o}=Ve(e);return(0,V.jsx)(be,{children:(0,V.jsx)(`div`,{"aria-hidden":!0,className:l(`transition-opacity duration-300 motion-reduce:duration-0`,!t&&`opacity-0 delay-1100 starting:opacity-100`),onTransitionEnd:e=>{e.target===e.currentTarget&&!t&&n()},children:(0,V.jsx)(j,{foldable:!1,status:o,appearance:`inline`,children:(0,V.jsxs)(me,{children:[(0,V.jsx)(N,{className:`[&_svg]:size-icon-md`,children:(0,V.jsx)(Te,{state:r})}),(0,V.jsx)(he,{className:`text-subheading`,children:i}),a&&(0,V.jsx)(ye,{className:`text-body-sm`,children:a})]})})})})}function Ue({stretchLive:e}){let{busy:t,transcript:n}=B(),r=xe(),i=ze(n.entries,n.lastEntryBeforeRun),a=t||i===`waiting`,o=r.runsStarted,[s,c]=(0,W.useState)(a?void 0:o),l=Be(i,t,Object.values(L(r)).includes(`blocking`));return l===`writing`||e&&Ie(l)||!a&&s===o?null:(0,V.jsx)(He,{state:l,live:a,onSettled:()=>c(o)})}function We({historyInitializing:e,preparing:t}){return(0,V.jsxs)(`div`,{"aria-hidden":!t,className:`session-preparation-overlay pointer-events-none absolute inset-0 z-5 overflow-hidden bg-(--chat-surface) data-[preparing=false]:bg-transparent`,"data-preparing":t,children:[(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`session-preparation-veil absolute inset-x-0 opacity-0`}),(0,V.jsx)(`div`,{className:`session-preparation-loader invisible absolute inset-0 z-1 flex -translate-y-1 bg-(--chat-surface) opacity-0`,children:(0,V.jsx)(we,{finishing:!t,historyInitializing:e})})]})}var G=`duration-[600ms] ease-(--resize-ease) motion-reduce:transition-none`,Ge=`absolute top-1/2 left-0.5 -translate-y-1/2 transition-[translate]`,Ke={completed:`translate-x-0`,in_progress:`translate-x-4`,pending:`translate-x-0`},qe=8,Je=24,K=(e,t)=>e===`in_progress`&&!t?Je:qe,q=e=>e*28+14,J={completed:`var(--success-indicator)`,in_progress:`var(--warning-indicator)`,pending:`var(--border-strong)`},Ye=(e,t,n,r)=>{let i=q(n),a=q(n+1),o=(i+a)/2,s=K(e,r),c=K(t,r);return`M ${s} ${i} C ${s} ${o} ${c} ${o} ${c} ${a}`},Xe=({upper:e,lower:t,index:n,graphId:r,singleLane:i})=>{let a=Ye(e,t,n,i),o=`path("${a}")`,s=e!==`pending`&&t!==`pending`,c=e===`in_progress`||t===`in_progress`;return(0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{d:a,fill:`none`,strokeWidth:1,mask:`url(#${r}-future)`,className:l(`transition-[d]`,G),style:{d:o,stroke:J.pending}}),(0,V.jsx)(`path`,{d:a,fill:`none`,strokeWidth:1,pathLength:1,strokeDasharray:`1 1`,className:l(`transition-[d,stroke-dashoffset,stroke]`,G),style:{d:o,strokeDashoffset:+!s,stroke:c?J.in_progress:J.completed}})]})},Ze=({statuses:e,singleLane:t=!1})=>{let n=`task-graph${(0,W.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,r=e.length*28,i={x:-8,y:0,width:48,height:r};return(0,V.jsxs)(`svg`,{"aria-hidden":!0,width:32,height:r,className:`pointer-events-none absolute top-0 left-0 overflow-visible`,children:[(0,V.jsxs)(`defs`,{children:[(0,V.jsxs)(`linearGradient`,{id:`${n}-fade`,gradientUnits:`userSpaceOnUse`,x1:0,x2:0,y1:0,y2:r,children:[(0,V.jsx)(`stop`,{offset:`0`,stopColor:`white`,stopOpacity:1}),(0,V.jsx)(`stop`,{offset:`1`,stopColor:`white`,stopOpacity:.15})]}),(0,V.jsx)(`mask`,{id:`${n}-future`,maskUnits:`userSpaceOnUse`,...i,children:(0,V.jsx)(`rect`,{...i,fill:`url(#${n}-fade)`})}),(0,V.jsxs)(`linearGradient`,{id:`${n}-gap`,x1:0,x2:0,y1:0,y2:1,children:[(0,V.jsx)(`stop`,{offset:`0.2`,stopColor:`white`,stopOpacity:0}),(0,V.jsx)(`stop`,{offset:`0.4`,stopColor:`white`,stopOpacity:1}),(0,V.jsx)(`stop`,{offset:`0.6`,stopColor:`white`,stopOpacity:1}),(0,V.jsx)(`stop`,{offset:`0.8`,stopColor:`white`,stopOpacity:0})]}),(0,V.jsx)(`pattern`,{id:`${n}-gaps`,patternUnits:`userSpaceOnUse`,x:i.x,y:14,width:i.width,height:28,children:(0,V.jsx)(`rect`,{width:i.width,height:28,fill:`url(#${n}-gap)`})}),(0,V.jsx)(`mask`,{id:`${n}-between-nodes`,maskUnits:`userSpaceOnUse`,...i,children:(0,V.jsx)(`rect`,{...i,fill:`url(#${n}-gaps)`})})]}),(0,V.jsx)(`g`,{mask:`url(#${n}-between-nodes)`,children:e.map((r,i)=>{let a=e[i+1];return a?(0,V.jsx)(Xe,{upper:r,lower:a,index:i,graphId:n,singleLane:t},i):null})})]})},Qe=()=>window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,$e=e=>1-(1-e)**5,et=(e,t)=>{let n=e.scrollTop,r=t-n;if(Qe())return e.scrollTo({top:t}),()=>{};let i=0,a=performance.now(),o=t=>{let s=Math.min((t-a)/600,1);e.scrollTo({top:n+r*$e(s)}),s<1&&(i=requestAnimationFrame(o))};return i=requestAnimationFrame(o),()=>cancelAnimationFrame(i)},tt=(e,t,n)=>{let r=e*28,i=r+28;return r<t?r:i>t+n?i-n:t},nt=4.5,Y=(e,t)=>t?Math.min(e,nt)*28:28,rt=(e,{focusIndex:t,windowHeight:n,open:r,followFocus:i})=>r?i?tt(t,e,n):e:t*28,it=(e,t,n)=>Math.min(Math.max(e,0),Math.max(t-n,0)),at=({focusIndex:e,rowCount:t,open:n,followFocus:r})=>{let i=(0,W.useRef)(null),a=(0,W.useRef)(void 0),o=(0,W.useRef)(!1),s=n=>{let s=i.current;if(!s||typeof s.scrollTo!=`function`)return;let c=Y(t,n),l=it(rt(s.scrollTop,{focusIndex:e,windowHeight:c,open:n,followFocus:r}),t*28,c);a.current?.(),o.current?l!==s.scrollTop&&(a.current=et(s,l)):(o.current=!0,s.scrollTo({top:l}))},c=(0,W.useEffectEvent)(()=>s(n));return(0,W.useEffect)(()=>(c(),()=>a.current?.()),[e]),{viewportRef:i,glideForOpen:s}},ot=({className:e,...t})=>(0,V.jsx)(`section`,{className:l(y,`overflow-hidden rounded-2xl`,e),...t}),st={completed:`bg-success-indicator`,in_progress:`bg-warning-indicator`,pending:`bg-fill-hover`},ct=({tasks:e,className:t,...n})=>{let r=e.filter(e=>e.status===`completed`).length;return(0,V.jsx)(_,{delayDuration:0,children:(0,V.jsxs)(b,{children:[(0,V.jsx)(S,{render:(0,V.jsx)(`span`,{role:`progressbar`,"aria-label":`Task completion`,"aria-valuemin":0,"aria-valuemax":e.length,"aria-valuenow":r,className:l(`ml-auto flex h-4 w-fit max-w-40 shrink-0 items-center gap-1 overflow-hidden`,t),...n,children:e.map(e=>(0,V.jsx)(`span`,{className:l(`h-full w-0.5 min-w-px shrink rounded-full transition-colors`,G,st[e.status])},e.id))})}),(0,V.jsxs)(h,{children:[r,`/`,e.length,` completed`]})]})})},lt={completed:`Completed`,in_progress:`In progress`,pending:`Pending`},ut={completed:`size-[7px] border-success-indicator bg-card`,in_progress:`size-2 border-warning-indicator bg-warning-subtle`,pending:`size-1.5 border-muted-foreground/45 bg-card`},dt=({status:e,className:t,...n})=>(0,V.jsx)(`span`,{role:`img`,"aria-label":lt[e],className:l(`grid size-3 shrink-0 place-items-center rounded-full`,t),...n,children:(0,V.jsx)(`span`,{className:l(`rounded-full border-[1.5px] transition-[width,height,border-color,background-color]`,G,ut[e])})}),ft=({task:e})=>{let t=e.status===`in_progress`;return(0,V.jsxs)(a,{as:`span`,variant:`caption`,className:`grid min-w-0`,children:[(0,V.jsx)(`span`,{"aria-hidden":t,className:l(`col-start-1 row-start-1 truncate transition-[opacity,color,translate,filter]`,G,e.status===`pending`?`text-muted-foreground/70`:`text-muted-foreground`,t?`-translate-y-1 opacity-0 blur-[2px]`:`translate-y-0 opacity-100 blur-none`),children:(0,V.jsx)(`span`,{className:l(`bg-[linear-gradient(currentColor,currentColor)] bg-no-repeat transition-[background-size]`,G,e.status===`completed`?`bg-size-[100%_1px] bg-position-[left_55%]`:`bg-size-[0%_1px] bg-position-[right_55%]`),children:e.content})}),(0,V.jsx)(`span`,{"aria-hidden":!t,className:l(`col-start-1 row-start-1 truncate bg-linear-to-r from-warning-indicator to-foreground to-30% bg-size-[200%_100%] bg-clip-text font-medium text-transparent transition-[opacity,translate,filter,background-position]`,G,t?`translate-y-0 bg-position-[0%_0] opacity-100 blur-none`:`translate-y-1 bg-position-[100%_0] opacity-0 blur-[2px]`),children:e.activeForm})]})},pt=({task:e,className:t,style:n,...r})=>(0,V.jsxs)(`li`,{className:l(`relative flex items-center`,t),style:{height:28,...n},...r,children:[(0,V.jsx)(dt,{status:e.status,className:l(Ge,G,Ke[e.status],`group-data-collapsed/task-list:translate-x-0`)}),(0,V.jsx)(`span`,{className:l(`flex min-w-0 transition-[padding-left]`,G,e.status===`in_progress`?`pl-10 group-data-collapsed/task-list:pl-6`:`pl-6`),children:(0,V.jsx)(ft,{task:e})})]}),mt=10,ht=`mask-no-repeat [--fade-bottom:0.875rem] [--fade-top:0.875rem] [mask-composite:subtract,add] [mask-image:linear-gradient(black,black),linear-gradient(to_bottom,black,transparent),linear-gradient(to_top,black,transparent)] [mask-position:0_0,0_0,0_100%] [mask-size:100%_100%,100%_var(--fade-top),100%_var(--fade-bottom)]`,X=`data-[overflow-y-end]:[--fade-bottom:2rem] data-[overflow-y-start]:[--fade-top:2rem]`,gt=e=>{let t=e.findIndex(e=>e.status===`in_progress`);if(t>=0)return t;let n=e.findIndex(e=>e.status===`pending`);return n>=0?n:e.length-1},_t=({tasks:e,hideWhenComplete:t=!0,scrollActiveIntoView:n=!0,defaultOpen:r=!0,className:a,...s})=>{let[d,p]=(0,W.useState)(r),m=(0,W.useId)(),h=e.filter(e=>e.status===`completed`).length,g=e.length,_=gt(e),v=Y(g,d),{viewportRef:y,glideForOpen:b}=at({focusIndex:_,rowCount:g,open:d,followFocus:n}),x=e=>{p(e),b(e)};return g===0||t&&h===g?null:(0,V.jsxs)(ot,{"aria-label":`Task list`,"data-testid":`task-list`,"data-collapsed":d?void 0:``,onClick:d?void 0:()=>x(!0),className:l(`group/task-list relative`,!d&&`cursor-pointer`,a),...s,children:[(0,V.jsx)(f,{id:m,maxHeight:`${v+20}px`,mask:!1,children:(0,V.jsx)(u,{ref:y,className:l(ht,`transition-[max-height,mask-size]`,G,d?X:`overflow-hidden!`),children:(0,V.jsx)(`div`,{className:`px-3`,style:{paddingBlock:mt},children:(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(Ze,{statuses:e.map(e=>e.status),singleLane:!d}),(0,V.jsx)(`ul`,{children:e.map((e,t)=>{let n=!d&&t!==_;return(0,V.jsx)(pt,{task:e,inert:n,"aria-hidden":n},e.id)})})]})})})}),(0,V.jsxs)(`div`,{className:`absolute top-2.5 right-3 flex h-7 items-center bg-linear-to-r from-transparent to-card to-[1.5rem] pl-6`,children:[(0,V.jsx)(`div`,{inert:d,"aria-hidden":d,className:l(`grid transition-[grid-template-columns,opacity]`,G,d?`grid-cols-[0fr] opacity-0`:`grid-cols-[1fr] opacity-100`),children:(0,V.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,V.jsx)(ct,{tasks:e,className:`mr-2`})})}),(0,V.jsx)(`button`,{type:`button`,"aria-label":d?`Collapse tasks`:`Show all tasks`,"aria-expanded":d,"aria-controls":m,onClick:e=>{e.stopPropagation(),x(!d)},className:l(`grid size-6 cursor-pointer place-items-center rounded-md text-muted-foreground hover:text-foreground`,i.colors,o,!d&&`group-hover/task-list:text-foreground`),children:(0,V.jsx)(c,{className:l(`size-icon-sm transition-[rotate]`,G,d?`rotate-180`:`rotate-0`)})})]})]})};function vt(){let{transcript:e}=B();return e.tasks.some(e=>e.status!==`completed`)?(0,V.jsx)(`div`,{role:`region`,"aria-label":`Current tasks`,"data-testid":`task-panel`,children:(0,V.jsx)(_t,{tasks:e.tasks})}):null}function yt(){let{loadMore:e}=B();return e.isLoading?(0,V.jsx)(`div`,{className:`flex w-full justify-center py-2`,children:(0,V.jsx)(D,{size:`sm`,className:`text-muted-foreground`,"aria-label":`Loading older messages`})}):null}var bt=64,xt=e=>(0,V.jsx)(Ue,{stretchLive:e});function St({secondaryBar:e,emptyState:t,composerLabel:n,composerStatus:r,contentOverlay:i}){let{busy:a,loadMore:o,transcript:s}=B(),{historyInitializing:c,preparing:u}=Ce(),d=o.hasMore&&!o.isLoading,f=s.entries.some(e=>e.kind!==`notice`);return(0,V.jsxs)(R,{className:l(`chat-surface-enter flex-1 [--chat-gutter:0.25rem]`,ge),scroller:{autoScroll:!0,defaultScrollPosition:a?`end`:`last-anchor`,preserveScrollOnPrepend:!0,onReachStart:d?o.load:void 0,scrollPreviousItemPeek:ve+bt},children:[e&&(0,V.jsx)(R.Bar,{className:`not-empty:mt-(--chat-header-room)`,children:e}),(0,V.jsx)(R.Stage,{children:(0,V.jsx)(R.Viewport,{className:A.viewport,children:(0,V.jsxs)(`div`,{className:`relative flex min-h-full min-w-0 flex-1 flex-col`,children:[(0,V.jsx)(`div`,{className:`contents`,children:i}),(0,V.jsxs)(R.Content,{role:`region`,"aria-label":`Conversation`,"aria-busy":u,className:`relative gap-0 pt-[calc(var(--chat-header-room,0px)+1.5rem)] [[data-slot=chat-shell-bar]:not(:empty)~[data-slot=message-scroller]_&]:pt-6`,children:[(0,V.jsx)(We,{historyInitializing:c,preparing:u}),(0,V.jsxs)(R.Transcript,{className:`flex-1`,children:[(0,V.jsx)(De,{}),(0,V.jsxs)(Oe,{showPreparation:!1,children:[(0,V.jsx)(yt,{}),!f&&t,(0,V.jsx)(_e,{tail:xt})]})]})]}),(0,V.jsxs)(R.Dock,{className:`pb-[calc(var(--chat-gutter)+env(safe-area-inset-bottom))]`,children:[(0,V.jsx)(R.ScrollButton,{"aria-label":`Jump to latest message`}),(0,V.jsxs)(R.Column,{className:l(`gap-2`,I),children:[(0,V.jsx)(vt,{}),(0,V.jsx)(`div`,{role:`region`,"aria-label":n,children:(0,V.jsx)(P,{statusLead:r})})]})]})]})})})]})}var Ct=[];function wt(e,t,n=`github`){let{baseUrl:r,sessionId:i}=w(),a=t&&!!e,o=d(ue(r,i,e,n,a));return{subscriptions:o.data??Ct,pending:a&&o.isPending,failed:a&&o.isLoadingError}}function Z(){let{factoryId:e}=v(),t=C(k()),n=m(e),r=n.data?.repositories.find(e=>e.projectRepositoryId===t.data?.projectRepositoryId);return{repository:r,provider:r?.provider===`gitlab`?`gitlab`:`github`,loading:t.isLoading||n.isLoading,failed:t.isLoadingError||n.isLoadingError}}function Q(){let{threadId:e}=v(),t=Z();return{session:t,links:wt(e,t.repository!==void 0,t.provider)}}function Tt({item:e,sessionItems:t,board:n,factory:r,openContext:i}){let{effectByItem:o}=re(r.id),s=p().data?.user?.userId,{move:l,evaluatingStages:u}=ne({factoryProjectId:r.id,kind:n.id,items:t,currentUserId:s,onFailure:e=>ee.error(e)}),{session:d,links:f}=Q(),m=d.repository,h=f.subscriptions,g=te(r.id),_=g.current&&g.held.has(e.id),{owner:v}=oe({decision:o.get(e.id),sessionHolds:_}),y=de(e,n),b=y?.current.kind===`working`?le(e,y.current.id):void 0,x=Ae(e=>b===void 0?void 0:ce(b,e));if(!y)return null;let{current:S}=y,C=u.has(e.id),w=e=>!ae(v.kind,e.kind),D=t=>l(e.id,t),O=e=>(0,V.jsx)(pe,{stage:e.id,kind:fe(n.id,e.kind),decorative:!0}),k=t=>{let r=t.id===S.id;return(0,V.jsxs)(E.RadioItem,{value:t.id,closeOnClick:!0,"aria-label":r?`${T(t)}, current stage`:`Move to ${T(t)}`,className:`items-start`,disabled:!r&&w(t),children:[O(t),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,V.jsx)(`span`,{className:`truncate`,children:T(t)}),r?null:(0,V.jsx)(a,{as:`span`,variant:`meta`,tone:`muted`,children:w(t)?ie:se(n,e,t,i,{repository:m?.slug,subscriptions:h})})]})]},t.id)};return(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(`div`,{role:`group`,"aria-label":`Card stage`,className:M,children:[y.previous?(0,V.jsx)($,{direction:`previous`,step:y.previous,held:w(y.previous.phase),disabled:C,onMove:D}):null,(0,V.jsxs)(E,{children:[(0,V.jsxs)(E.Trigger,{variant:`subtle`,size:`sm`,"aria-label":`Change stage from ${T(S)}`,disabled:C,children:[O(S),(0,V.jsx)(`span`,{children:T(S)}),x?(0,V.jsx)(a,{as:`span`,variant:`meta`,tone:`muted`,font:`mono`,children:x}):null,(0,V.jsx)(c,{"aria-hidden":!0})]}),(0,V.jsx)(E.Content,{align:`center`,className:`max-h-(--available-height) w-72`,children:(0,V.jsxs)(E.RadioGroup,{value:S.id,onValueChange:e=>{e!==S.id&&D(e)},children:[y.track.map(k),y.track.length>0&&y.stop.length>0?(0,V.jsx)(E.Separator,{}):null,y.stop.map(k)]})})]}),y.next?(0,V.jsx)($,{direction:`next`,step:y.next,held:w(y.next.phase),disabled:C,onMove:D}):null]})})}function $({direction:e,step:t,held:n,disabled:r,onMove:i}){let a=T(t.phase),o=e===`previous`?`Move back to ${a}`:`Move to ${a}`,c=O(t)??(n?`Another run can't start while this card is busy.`:void 0);return(0,V.jsxs)(g,{variant:`ghost`,size:`sm`,"aria-label":c?`${o}, ${c}`:o,tooltip:c??o,disabled:r||n||t.blocked!==void 0,onClick:()=>i(t.phase.id),children:[e===`previous`?(0,V.jsx)(x,{"aria-hidden":!0}):null,(0,V.jsx)(`span`,{className:`hidden @2xl:inline`,children:a}),e===`next`?(0,V.jsx)(s,{"aria-hidden":!0}):null]})}export{Ne as a,St as i,Q as n,H as o,Z as r,Tt as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{An as t,Cn as n,Fn as r,In as i,Ln as a,Nn as o,Pn as s,Ut as c,Wt as l,jn as u,mn as d,qt as f,wn as p}from"./index-D2WNyeAe.js";import{t as m}from"./input-DqReKX0A-2mZo-XW9.js";import{Wn as h,ki as g}from"./useFactories-B-Om6aVq.js";import{a as _,c as v,o as y,s as b}from"./request-CPtLhnSV.js";import{a as x,i as S,r as C}from"./IconClipboard2.es-DIRDjMMg.js";import{D as ee,O as te,d as w,i as T,n as E,o as ne,w as D}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{t as re}from"./createLucideIcon-4HMWrBkV.js";import{t as ie}from"./IconCircleCheck.es-jA-dYNOs.js";import{t as ae}from"./IconHashtag.es-D4hsTU7s.js";import{t as oe}from"./IconMerged.es-yVyZYELD.js";import{t as O}from"./IconPlugin1.es-CZs2N-e2.js";import{t as k}from"./IconShieldCheck.es-B3i3R9pw.js";import{t as se}from"./IconUser.es-BEU0-Pi9.js";import{t as ce}from"./IconUserDuo.es-BDaCO0PB.js";import{i as le,n as A,r as j}from"./conditionFields-Bxo1maIQ.js";import{a as ue}from"./board-events-BVnaMaTS.js";import{n as de}from"./SlackIcon.es-4iabNI5s.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 fe=re(M),N=ee(),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:D(`flex flex-col gap-2`,e),...t})}function I({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line`,className:D(`flex items-start gap-2`,e),...t})}function L({className:e,children:t,...n}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-keyword`,"aria-hidden":t===void 0||void 0,className:D(P,T({variant:`caption`,tone:`muted`}),e),...n,children:t})}function pe({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)(_,{value:e,onValueChange:e=>e&&t(e),children:[(0,N.jsx)(v,{size:`sm`,variant:`ghost`,"aria-label":n,className:`-ml-2 w-fit px-2`,children:(0,N.jsx)(`span`,{className:T({variant:`caption`,tone:`ink`}),children:e===`AND`?`and`:`or`})}),(0,N.jsxs)(y,{children:[(0,N.jsx)(b,{value:`AND`,children:`and`}),(0,N.jsx)(b,{value:`OR`,children:`or`})]})]})})}function R({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line-content`,className:D(`flex min-h-control-sm min-w-0 flex-1 flex-wrap items-center gap-1.5`,e),...t})}function me({depth:e,className:t,...n}){return(0,N.jsx)(`div`,{role:`group`,"data-slot":`rule-line-group`,className:D(`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),...n})}function he({className:e,...t}){return(0,N.jsx)(g,{variant:`ghost`,size:`icon-sm`,className:D(`ml-auto`,e),...t,children:(0,N.jsx)(h,{})})}function ge({className:e,children:t,...n}){return(0,N.jsxs)(g,{variant:`ghost`,size:`sm`,className:D(`ml-auto`,e),...n,children:[(0,N.jsx)(x,{}),t]})}function _e({className:e,...t}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-hint`,className:D(T({variant:`caption`,tone:`muted`}),`px-1`,e),...t})}function z({icon:e,className:t,children:n,...r}){return(0,N.jsxs)(`button`,{type:`button`,"data-slot":`rule-add-button`,className:D(T({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`,ne,t),...r,children:[e,n]})}var ve=w(`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`})]})),ye=w(`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`})),be=w(`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(te(),1),V=new Set([`exists`,`not_exists`]),H=new Set([`in`,`not_in`]),U=e=>`items`in e,xe=0,W=()=>`condition-${++xe}`,G=()=>({key:W(),field:``,operator:``}),Se=e=>e+2<=3;function Ce(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 we=e=>ue.some(t=>t===e);function Te(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(!we(r)||!Te(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 Ee=e=>`provider`in e&&typeof e.provider==`string`;function De(e,t){if(!Array.isArray(e.suggestions))return e;let n=l(t),r=new Set;return{...e,suggestions:e.suggestions.filter(e=>{if(n&&Ee(e)&&!n.has(e.provider))return!1;let t=e.value.toLowerCase();return!r.has(t)&&(r.add(t),!0)})}}var Oe=w(`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`})]})),ke={"item.labels":d,"item.title":ye,"item.author":se,"item.key":ae,"item.state":S,"item.assignees":ce,"item.pullRequest":C,"item.trusted":k,"pullRequest.trusted":k,"source.kind":C,"source.integration":O,"source.provider":O,"source.repository":fe,"pullRequest.closesIssue":oe,"closedIssue.phase":ve,"closedIssue.hasPullRequest":C,"event.type":be,"event.reason":ie};function J(e,t){return e?.operatorLabels?.[t]??A.find(e=>e.id===t)?.label??t}function Y(e){return Array.isArray(e?.suggestions)&&e.suggestions.length>0?e.suggestions:void 0}function Ae({label:e,rule:t,facts:n,options:r,emptyHint:i,onChange:a}){let o=le(n,r),[s,c]=(0,B.useState)(()=>Ce(t)),{rule:l,incomplete:u}=K(s),d=f(l);return(0,N.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,N.jsx)(X,{role:`group`,"aria-label":e,group:s,depth:0,fields:o,emptyHint:i,onChange:e=>{c(e);let{rule:t,incomplete:n}=K(e);a(t,n)}}),u&&(0,N.jsx)(E,{as:`p`,variant:`caption`,tone:`muted`,children:`Finish or remove unfinished conditions to save.`}),d&&(0,N.jsx)(E,{as:`p`,variant:`caption`,tone:`muted`,children:d})]})}function X({role:e,"aria-label":t,group:n,depth:r,fields:i,limits:a=[],emptyHint:o,onChange:s,onRemove:l}){let u=(e,t)=>s({...n,items:t===void 0?n.items.filter((t,n)=>n!==e):n.items.with(e,t)}),d=e=>s({...n,items:[...n.items,e]}),f=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(z,{icon:(0,N.jsx)(de,{}),onClick:()=>d(G()),children:`Add condition`}),Se(r)&&(0,N.jsx)(z,{icon:(0,N.jsx)(Oe,{}),onClick:()=>d({key:W(),logic:n.logic===`AND`?`OR`:`AND`,items:[G()]}),children:`Add group`}),l&&(0,N.jsx)(ge,{onClick:l,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:[f,o&&(0,N.jsx)(_e,{children:o})]})]})});let p=n.logic===`AND`?`and`:`or`,m=c(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)(pe,{value:n.logic,onValueChange:e=>s({...n,logic:e})}):(0,N.jsx)(L,{children:t===0?`Where`:p}),U(e)?(0,N.jsx)(me,{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:m,onChange:e=>u(t,e.items.length>0?e:void 0),onRemove:()=>u(t,void 0)})}):(0,N.jsx)(je,{row:e,fields:i,limits:m.filter(t=>t!==e),onChange:e=>u(t,e),onRemove:()=>u(t,void 0)})]},e.key)),(0,N.jsxs)(I,{children:[(0,N.jsx)(L,{}),(0,N.jsx)(R,{children:f})]})]})}function Z({id:e}){let t=ke[e]??S;return(0,N.jsx)(t,{"aria-hidden":`true`,className:`text-muted-foreground size-3.5 shrink-0`})}function je({row:e,fields:t,limits:n,onChange:r,onRemove:i}){let a=t.find(t=>t.id===e.field),o=a&&De(a,n);return(0,N.jsxs)(R,{children:[(0,N.jsxs)(_,{value:e.field||null,onValueChange:n=>{let i=t.find(e=>e.id===n);if(!i)return;let a=i.operators?.[0]??`equals`;r({...e,field:i.id,operator:a,value:q(i,a,void 0)})},children:[(0,N.jsx)(v,{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:[o&&(0,N.jsx)(Z,{id:o.id}),(0,N.jsx)(E,{as:`span`,variant:`caption`,className:`truncate`,children:o?.label??(e.field||`Choose a field`)})]})}),(0,N.jsx)(y,{children:t.map(e=>(0,N.jsx)(b,{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))})]}),o?.type===`boolean`&&(0,N.jsx)(Me,{row:e,field:o,onChange:r}),o&&o.type!==`boolean`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(_,{value:e.operator,onValueChange:t=>t&&r({...e,operator:t,value:q(o,t,e.value)}),children:[(0,N.jsx)(v,{size:`sm`,variant:`ghost`,"aria-label":`Operator`,className:`w-fit`,children:(0,N.jsx)(E,{as:`span`,variant:`caption`,children:J(o,e.operator)})}),(0,N.jsx)(y,{children:(o.operators??[]).map(e=>(0,N.jsx)(b,{value:e,children:J(o,e)},e))})]}),!V.has(e.operator)&&(0,N.jsx)(Ne,{row:e,field:o,onChange:r})]}),(0,N.jsx)(he,{"aria-label":`Remove condition`,onClick:i})]})}function Me({row:e,field:t,onChange:r}){let i=Y(t)??[{value:`true`,label:`Yes`},{value:`false`,label:`No`}],a=e.operator!==`not_equals`==(e.value!==!1);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(E,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,N.jsx)(n,{size:`sm`,"aria-label":t.label,value:String(a),onValueChange:t=>r({...e,operator:`equals`,value:t===`true`}),children:i.map(e=>(0,N.jsx)(p,{value:e.value,children:e.label},e.value))})]})}function Ne({row:e,field:t,onChange:n}){let r=Y(t),i=H.has(e.operator),a=A.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)(Fe,{options:(r??[]).map(e=>({value:e.value,label:e.label??e.value})),values:a,many:i,placeholder:j[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)(Pe,{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)(_,{value:e.value===void 0?null:String(e.value),onValueChange:t=>t!==null&&n({...e,value:t}),children:[(0,N.jsx)(v,{size:`sm`,"aria-label":`Value`,className:`w-fit`,children:(0,N.jsx)(E,{as:`span`,variant:`caption`,className:`font-medium`,children:t?.label??(e.value===void 0?`Choose a value`:String(e.value))})}),(0,N.jsx)(y,{children:r.map(e=>(0,N.jsx)(b,{value:e.value,children:e.label},e.value))})]})}return(0,N.jsx)(Ie,{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 Pe({options:e,values:n,onChange:c}){let l=n.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),d=[...e,...l.filter(t=>!e.includes(t))],f=l.map(e=>e.label);return(0,N.jsxs)(r,{multiple:!0,autoHighlight:!0,items:d,value:l,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:e=>c(e.map(e=>e.value)),children:[(0,N.jsx)(a,{size:`sm`,"aria-label":`Values`,title:f.join(`, `),className:`w-fit max-w-64`,children:(0,N.jsx)(E,{as:`span`,variant:`caption`,className:D(`font-medium`,f.length===0&&`text-muted-foreground`),children:Q(f)})}),(0,N.jsxs)(t,{children:[(0,N.jsx)(i,{placeholder:`Search`}),(0,N.jsx)(u,{children:`No option found.`}),(0,N.jsx)(s,{children:e=>(0,N.jsx)(o,{value:e,children:e.label},e.value)})]})]})}function Fe({options:e,values:n,many:c,placeholder:l,onChange:d}){let[f,p]=(0,B.useState)(``),m=f.trim(),h=t=>e.some(e=>e.value.toLowerCase()===t.toLowerCase()),g=n.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),_=[...e,...g.filter(t=>!e.includes(t)),...m&&!h(m)&&!n.includes(m)?[{value:m,label:`Use “${m}”`}]:[]],v=g.map(e=>e.value),y={autoHighlight:!0,items:_,inputValue:f,onInputValueChange:p,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value},b=(0,N.jsxs)(t,{children:[(0,N.jsx)(i,{placeholder:l}),(0,N.jsx)(u,{children:`Type a value to use it.`}),(0,N.jsx)(s,{children:e=>(0,N.jsx)(o,{value:e,children:e.label},e.value)})]}),x=(0,N.jsx)(E,{as:`span`,variant:`caption`,className:D(`font-medium`,v.length===0&&`text-muted-foreground`),children:v.length===0?l:Q(v)});return c?(0,N.jsxs)(r,{...y,multiple:!0,value:g,onValueChange:e=>d(e.map(e=>e.value)),children:[(0,N.jsx)(a,{size:`sm`,"aria-label":`Values`,title:v.join(`, `),className:`w-fit max-w-64`,children:x}),b]}):(0,N.jsxs)(r,{...y,value:g[0]??null,onValueChange:e=>e&&d([e.value]),children:[(0,N.jsx)(a,{size:`sm`,"aria-label":`Value`,title:v[0],className:`w-fit max-w-64`,children:x}),b]})}function $(e){return Array.isArray(e)?e.join(`, `):e===void 0?``:String(e)}function Ie({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)(m,{size:`sm`,"aria-label":`Value`,type:t.type===`number`&&!n?`number`:`text`,placeholder:j[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{Ae as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{An as t,Cn as n,Fn as r,In as i,Ln as a,Nn as o,Pn as s,Ut as c,Wt as l,jn as u,mn as d,qt as f,wn as p}from"./index-CqME59pn.js";import{t as m}from"./input-DqReKX0A-2mZo-XW9.js";import{Wn as h,ki as g}from"./useFactories-B-Om6aVq.js";import{a as _,c as v,o as y,s as b}from"./request-CPtLhnSV.js";import{a as x,i as S,r as C}from"./IconClipboard2.es-DIRDjMMg.js";import{D as ee,O as te,d as w,i as T,n as E,o as ne,w as D}from"./IconChevronRightMedium.es-DYcwXRfK.js";import{t as re}from"./createLucideIcon-4HMWrBkV.js";import{t as ie}from"./IconCircleCheck.es-jA-dYNOs.js";import{t as ae}from"./IconHashtag.es-D4hsTU7s.js";import{t as oe}from"./IconMerged.es-yVyZYELD.js";import{t as O}from"./IconPlugin1.es-CZs2N-e2.js";import{t as k}from"./IconShieldCheck.es-B3i3R9pw.js";import{t as se}from"./IconUser.es-BEU0-Pi9.js";import{t as ce}from"./IconUserDuo.es-BDaCO0PB.js";import{i as le,n as A,r as j}from"./conditionFields-CBXR0ZAG.js";import{a as ue}from"./board-events-BVnaMaTS.js";import{n as de}from"./SlackIcon.es-4iabNI5s.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 fe=re(M),N=ee(),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:D(`flex flex-col gap-2`,e),...t})}function I({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line`,className:D(`flex items-start gap-2`,e),...t})}function L({className:e,children:t,...n}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-keyword`,"aria-hidden":t===void 0||void 0,className:D(P,T({variant:`caption`,tone:`muted`}),e),...n,children:t})}function pe({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)(_,{value:e,onValueChange:e=>e&&t(e),children:[(0,N.jsx)(v,{size:`sm`,variant:`ghost`,"aria-label":n,className:`-ml-2 w-fit px-2`,children:(0,N.jsx)(`span`,{className:T({variant:`caption`,tone:`ink`}),children:e===`AND`?`and`:`or`})}),(0,N.jsxs)(y,{children:[(0,N.jsx)(b,{value:`AND`,children:`and`}),(0,N.jsx)(b,{value:`OR`,children:`or`})]})]})})}function R({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line-content`,className:D(`flex min-h-control-sm min-w-0 flex-1 flex-wrap items-center gap-1.5`,e),...t})}function me({depth:e,className:t,...n}){return(0,N.jsx)(`div`,{role:`group`,"data-slot":`rule-line-group`,className:D(`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),...n})}function he({className:e,...t}){return(0,N.jsx)(g,{variant:`ghost`,size:`icon-sm`,className:D(`ml-auto`,e),...t,children:(0,N.jsx)(h,{})})}function ge({className:e,children:t,...n}){return(0,N.jsxs)(g,{variant:`ghost`,size:`sm`,className:D(`ml-auto`,e),...n,children:[(0,N.jsx)(x,{}),t]})}function _e({className:e,...t}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-hint`,className:D(T({variant:`caption`,tone:`muted`}),`px-1`,e),...t})}function z({icon:e,className:t,children:n,...r}){return(0,N.jsxs)(`button`,{type:`button`,"data-slot":`rule-add-button`,className:D(T({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`,ne,t),...r,children:[e,n]})}var ve=w(`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`})]})),ye=w(`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`})),be=w(`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(te(),1),V=new Set([`exists`,`not_exists`]),H=new Set([`in`,`not_in`]),U=e=>`items`in e,xe=0,W=()=>`condition-${++xe}`,G=()=>({key:W(),field:``,operator:``}),Se=e=>e+2<=3;function Ce(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 we=e=>ue.some(t=>t===e);function Te(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(!we(r)||!Te(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 Ee=e=>`provider`in e&&typeof e.provider==`string`;function De(e,t){if(!Array.isArray(e.suggestions))return e;let n=l(t),r=new Set;return{...e,suggestions:e.suggestions.filter(e=>{if(n&&Ee(e)&&!n.has(e.provider))return!1;let t=e.value.toLowerCase();return!r.has(t)&&(r.add(t),!0)})}}var Oe=w(`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`})]})),ke={"item.labels":d,"item.title":ye,"item.author":se,"item.key":ae,"item.state":S,"item.assignees":ce,"item.pullRequest":C,"item.trusted":k,"pullRequest.trusted":k,"source.kind":C,"source.integration":O,"source.provider":O,"source.repository":fe,"pullRequest.closesIssue":oe,"closedIssue.phase":ve,"closedIssue.hasPullRequest":C,"event.type":be,"event.reason":ie};function J(e,t){return e?.operatorLabels?.[t]??A.find(e=>e.id===t)?.label??t}function Y(e){return Array.isArray(e?.suggestions)&&e.suggestions.length>0?e.suggestions:void 0}function Ae({label:e,rule:t,facts:n,options:r,emptyHint:i,onChange:a}){let o=le(n,r),[s,c]=(0,B.useState)(()=>Ce(t)),{rule:l,incomplete:u}=K(s),d=f(l);return(0,N.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,N.jsx)(X,{role:`group`,"aria-label":e,group:s,depth:0,fields:o,emptyHint:i,onChange:e=>{c(e);let{rule:t,incomplete:n}=K(e);a(t,n)}}),u&&(0,N.jsx)(E,{as:`p`,variant:`caption`,tone:`muted`,children:`Finish or remove unfinished conditions to save.`}),d&&(0,N.jsx)(E,{as:`p`,variant:`caption`,tone:`muted`,children:d})]})}function X({role:e,"aria-label":t,group:n,depth:r,fields:i,limits:a=[],emptyHint:o,onChange:s,onRemove:l}){let u=(e,t)=>s({...n,items:t===void 0?n.items.filter((t,n)=>n!==e):n.items.with(e,t)}),d=e=>s({...n,items:[...n.items,e]}),f=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(z,{icon:(0,N.jsx)(de,{}),onClick:()=>d(G()),children:`Add condition`}),Se(r)&&(0,N.jsx)(z,{icon:(0,N.jsx)(Oe,{}),onClick:()=>d({key:W(),logic:n.logic===`AND`?`OR`:`AND`,items:[G()]}),children:`Add group`}),l&&(0,N.jsx)(ge,{onClick:l,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:[f,o&&(0,N.jsx)(_e,{children:o})]})]})});let p=n.logic===`AND`?`and`:`or`,m=c(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)(pe,{value:n.logic,onValueChange:e=>s({...n,logic:e})}):(0,N.jsx)(L,{children:t===0?`Where`:p}),U(e)?(0,N.jsx)(me,{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:m,onChange:e=>u(t,e.items.length>0?e:void 0),onRemove:()=>u(t,void 0)})}):(0,N.jsx)(je,{row:e,fields:i,limits:m.filter(t=>t!==e),onChange:e=>u(t,e),onRemove:()=>u(t,void 0)})]},e.key)),(0,N.jsxs)(I,{children:[(0,N.jsx)(L,{}),(0,N.jsx)(R,{children:f})]})]})}function Z({id:e}){let t=ke[e]??S;return(0,N.jsx)(t,{"aria-hidden":`true`,className:`text-muted-foreground size-3.5 shrink-0`})}function je({row:e,fields:t,limits:n,onChange:r,onRemove:i}){let a=t.find(t=>t.id===e.field),o=a&&De(a,n);return(0,N.jsxs)(R,{children:[(0,N.jsxs)(_,{value:e.field||null,onValueChange:n=>{let i=t.find(e=>e.id===n);if(!i)return;let a=i.operators?.[0]??`equals`;r({...e,field:i.id,operator:a,value:q(i,a,void 0)})},children:[(0,N.jsx)(v,{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:[o&&(0,N.jsx)(Z,{id:o.id}),(0,N.jsx)(E,{as:`span`,variant:`caption`,className:`truncate`,children:o?.label??(e.field||`Choose a field`)})]})}),(0,N.jsx)(y,{children:t.map(e=>(0,N.jsx)(b,{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))})]}),o?.type===`boolean`&&(0,N.jsx)(Me,{row:e,field:o,onChange:r}),o&&o.type!==`boolean`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(_,{value:e.operator,onValueChange:t=>t&&r({...e,operator:t,value:q(o,t,e.value)}),children:[(0,N.jsx)(v,{size:`sm`,variant:`ghost`,"aria-label":`Operator`,className:`w-fit`,children:(0,N.jsx)(E,{as:`span`,variant:`caption`,children:J(o,e.operator)})}),(0,N.jsx)(y,{children:(o.operators??[]).map(e=>(0,N.jsx)(b,{value:e,children:J(o,e)},e))})]}),!V.has(e.operator)&&(0,N.jsx)(Ne,{row:e,field:o,onChange:r})]}),(0,N.jsx)(he,{"aria-label":`Remove condition`,onClick:i})]})}function Me({row:e,field:t,onChange:r}){let i=Y(t)??[{value:`true`,label:`Yes`},{value:`false`,label:`No`}],a=e.operator!==`not_equals`==(e.value!==!1);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(E,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,N.jsx)(n,{size:`sm`,"aria-label":t.label,value:String(a),onValueChange:t=>r({...e,operator:`equals`,value:t===`true`}),children:i.map(e=>(0,N.jsx)(p,{value:e.value,children:e.label},e.value))})]})}function Ne({row:e,field:t,onChange:n}){let r=Y(t),i=H.has(e.operator),a=A.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)(Fe,{options:(r??[]).map(e=>({value:e.value,label:e.label??e.value})),values:a,many:i,placeholder:j[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)(Pe,{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)(_,{value:e.value===void 0?null:String(e.value),onValueChange:t=>t!==null&&n({...e,value:t}),children:[(0,N.jsx)(v,{size:`sm`,"aria-label":`Value`,className:`w-fit`,children:(0,N.jsx)(E,{as:`span`,variant:`caption`,className:`font-medium`,children:t?.label??(e.value===void 0?`Choose a value`:String(e.value))})}),(0,N.jsx)(y,{children:r.map(e=>(0,N.jsx)(b,{value:e.value,children:e.label},e.value))})]})}return(0,N.jsx)(Ie,{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 Pe({options:e,values:n,onChange:c}){let l=n.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),d=[...e,...l.filter(t=>!e.includes(t))],f=l.map(e=>e.label);return(0,N.jsxs)(r,{multiple:!0,autoHighlight:!0,items:d,value:l,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:e=>c(e.map(e=>e.value)),children:[(0,N.jsx)(a,{size:`sm`,"aria-label":`Values`,title:f.join(`, `),className:`w-fit max-w-64`,children:(0,N.jsx)(E,{as:`span`,variant:`caption`,className:D(`font-medium`,f.length===0&&`text-muted-foreground`),children:Q(f)})}),(0,N.jsxs)(t,{children:[(0,N.jsx)(i,{placeholder:`Search`}),(0,N.jsx)(u,{children:`No option found.`}),(0,N.jsx)(s,{children:e=>(0,N.jsx)(o,{value:e,children:e.label},e.value)})]})]})}function Fe({options:e,values:n,many:c,placeholder:l,onChange:d}){let[f,p]=(0,B.useState)(``),m=f.trim(),h=t=>e.some(e=>e.value.toLowerCase()===t.toLowerCase()),g=n.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),_=[...e,...g.filter(t=>!e.includes(t)),...m&&!h(m)&&!n.includes(m)?[{value:m,label:`Use “${m}”`}]:[]],v=g.map(e=>e.value),y={autoHighlight:!0,items:_,inputValue:f,onInputValueChange:p,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value},b=(0,N.jsxs)(t,{children:[(0,N.jsx)(i,{placeholder:l}),(0,N.jsx)(u,{children:`Type a value to use it.`}),(0,N.jsx)(s,{children:e=>(0,N.jsx)(o,{value:e,children:e.label},e.value)})]}),x=(0,N.jsx)(E,{as:`span`,variant:`caption`,className:D(`font-medium`,v.length===0&&`text-muted-foreground`),children:v.length===0?l:Q(v)});return c?(0,N.jsxs)(r,{...y,multiple:!0,value:g,onValueChange:e=>d(e.map(e=>e.value)),children:[(0,N.jsx)(a,{size:`sm`,"aria-label":`Values`,title:v.join(`, `),className:`w-fit max-w-64`,children:x}),b]}):(0,N.jsxs)(r,{...y,value:g[0]??null,onValueChange:e=>e&&d([e.value]),children:[(0,N.jsx)(a,{size:`sm`,"aria-label":`Value`,title:v[0],className:`w-fit max-w-64`,children:x}),b]})}function $(e){return Array.isArray(e)?e.join(`, `):e===void 0?``:String(e)}function Ie({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)(m,{size:`sm`,"aria-label":`Value`,type:t.type===`number`&&!n?`number`:`text`,placeholder:j[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{Ae as t};
|